UNPKG

6.23 kBTypeScriptView Raw
1import { IHighlightAdjacentMatchOptions } from '@jupyterlab/codemirror';
2import { IFilter, IFilters, IReplaceOptions, IReplaceOptionsSupport, ISearchMatch, ISearchProvider, SearchProvider, SelectionState } from '@jupyterlab/documentsearch';
3import { ITranslator } from '@jupyterlab/translation';
4import { Widget } from '@lumino/widgets';
5import { NotebookPanel } from './panel';
6/**
7 * Notebook document search provider
8 */
9export declare class NotebookSearchProvider extends SearchProvider<NotebookPanel> {
10 protected translator: ITranslator;
11 /**
12 * Constructor
13 *
14 * @param widget The widget to search in
15 * @param translator Application translator
16 */
17 constructor(widget: NotebookPanel, translator?: ITranslator);
18 private _onNotebookStateChanged;
19 /**
20 * Report whether or not this provider has the ability to search on the given object
21 *
22 * @param domain Widget to test
23 * @returns Search ability
24 */
25 static isApplicable(domain: Widget): domain is NotebookPanel;
26 /**
27 * Instantiate a search provider for the notebook panel.
28 *
29 * #### Notes
30 * The widget provided is always checked using `isApplicable` before calling
31 * this factory.
32 *
33 * @param widget The widget to search on
34 * @param translator [optional] The translator object
35 *
36 * @returns The search provider on the notebook panel
37 */
38 static createNew(widget: NotebookPanel, translator?: ITranslator): ISearchProvider;
39 /**
40 * The current index of the selected match.
41 */
42 get currentMatchIndex(): number | null;
43 /**
44 * The number of matches.
45 */
46 get matchesCount(): number | null;
47 /**
48 * Set to true if the widget under search is read-only, false
49 * if it is editable. Will be used to determine whether to show
50 * the replace option.
51 */
52 get isReadOnly(): boolean;
53 /**
54 * Support for options adjusting replacement behavior.
55 */
56 get replaceOptionsSupport(): IReplaceOptionsSupport;
57 getSelectionState(): SelectionState;
58 /**
59 * Dispose of the resources held by the search provider.
60 *
61 * #### Notes
62 * If the object's `dispose` method is called more than once, all
63 * calls made after the first will be a no-op.
64 *
65 * #### Undefined Behavior
66 * It is undefined behavior to use any functionality of the object
67 * after it has been disposed unless otherwise explicitly noted.
68 */
69 dispose(): void;
70 /**
71 * Get the filters for the given provider.
72 *
73 * @returns The filters.
74 */
75 getFilters(): {
76 [key: string]: IFilter;
77 };
78 /**
79 * Update the search in selection mode; it should only be called when user
80 * navigates the notebook (enters editing/command mode, changes selection)
81 * but not when the searchbox gets focused (switching the notebook to command
82 * mode) nor when search highlights a match (switching notebook to edit mode).
83 */
84 private _updateSelectionMode;
85 /**
86 * Get an initial query value if applicable so that it can be entered
87 * into the search box as an initial query
88 *
89 * @returns Initial value used to populate the search box.
90 */
91 getInitialQuery(): string;
92 /**
93 * Clear currently highlighted match.
94 */
95 clearHighlight(): Promise<void>;
96 /**
97 * Highlight the next match.
98 *
99 * @param loop Whether to loop within the matches list.
100 *
101 * @returns The next match if available.
102 */
103 highlightNext(loop?: boolean, options?: IHighlightAdjacentMatchOptions): Promise<ISearchMatch | undefined>;
104 /**
105 * Highlight the previous match.
106 *
107 * @param loop Whether to loop within the matches list.
108 *
109 * @returns The previous match if available.
110 */
111 highlightPrevious(loop?: boolean, options?: IHighlightAdjacentMatchOptions): Promise<ISearchMatch | undefined>;
112 /**
113 * Search for a regular expression with optional filters.
114 *
115 * @param query A regular expression to test for
116 * @param filters Filter parameters to pass to provider
117 *
118 */
119 startQuery(query: RegExp, filters: IFilters | undefined): Promise<void>;
120 /**
121 * Stop the search and clear all internal state.
122 */
123 endQuery(): Promise<void>;
124 /**
125 * Replace the currently selected match with the provided text
126 *
127 * @param newText The replacement text.
128 * @param loop Whether to loop within the matches list.
129 *
130 * @returns A promise that resolves with a boolean indicating whether a replace occurred.
131 */
132 replaceCurrentMatch(newText: string, loop?: boolean, options?: IReplaceOptions): Promise<boolean>;
133 /**
134 * Replace all matches in the notebook with the provided text
135 *
136 * @param newText The replacement text.
137 *
138 * @returns A promise that resolves with a boolean indicating whether a replace occurred.
139 */
140 replaceAllMatches(newText: string, options?: IReplaceOptions): Promise<boolean>;
141 validateFilter(name: string, value: boolean): Promise<boolean>;
142 private _addCellProvider;
143 private _removeCellProvider;
144 private _onCellsChanged;
145 private _stepNext;
146 private _onActiveCellChanged;
147 private _handleHighlightsAfterActiveCellChange;
148 /**
149 * If there are results but no match is designated as current,
150 * mark a result as current and highlight it.
151 */
152 private _ensureCurrentMatch;
153 private _observeActiveCell;
154 private _stopObservingLastCell;
155 private _setSelectedLines;
156 private _textSelection;
157 /**
158 * Set whether the engines should search within selection only or full text.
159 */
160 private _setEnginesSelectionSearchMode;
161 private _onCellSelectionChanged;
162 private _updateCellSelection;
163 protected delayedActiveCellChangeHandlerReady: Promise<void>;
164 private _currentProviderIndex;
165 private _delayedActiveCellChangeHandler;
166 private _filters;
167 private _onSelection;
168 private _selectedCells;
169 private _selectedLines;
170 private _query;
171 private _searchProviders;
172 private _editorSelectionsObservable;
173 private _selectionSearchMode;
174 private _selectionLock;
175 private _searchActive;
176}