@jupyterlab/notebook 3.4.3 → 4.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions.d.ts +34 -2
- package/lib/actions.js +250 -8
- package/lib/actions.js.map +1 -1
- package/lib/celllist.d.ts +1 -1
- package/lib/celllist.js +1 -1
- package/lib/celllist.js.map +1 -1
- package/lib/default-toolbar.d.ts +2 -1
- package/lib/default-toolbar.js +5 -5
- package/lib/default-toolbar.js.map +1 -1
- package/lib/executionindicator.d.ts +3 -2
- package/lib/executionindicator.js +13 -22
- package/lib/executionindicator.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/model.d.ts +1 -0
- package/lib/model.js +24 -17
- package/lib/model.js.map +1 -1
- package/lib/modelfactory.js.map +1 -1
- package/lib/modestatus.d.ts +1 -2
- package/lib/modestatus.js +1 -1
- package/lib/modestatus.js.map +1 -1
- package/lib/notebooktools.d.ts +58 -1
- package/lib/notebooktools.js +157 -5
- package/lib/notebooktools.js.map +1 -1
- package/lib/panel.d.ts +8 -2
- package/lib/panel.js +6 -2
- package/lib/panel.js.map +1 -1
- package/lib/searchprovider.d.ts +141 -0
- package/lib/searchprovider.js +421 -0
- package/lib/searchprovider.js.map +1 -0
- package/lib/toc.d.ts +179 -0
- package/lib/toc.js +483 -0
- package/lib/toc.js.map +1 -0
- package/lib/tokens.js +0 -4
- package/lib/tokens.js.map +1 -1
- package/lib/tracker.js.map +1 -1
- package/lib/truststatus.d.ts +1 -2
- package/lib/truststatus.js +1 -2
- package/lib/truststatus.js.map +1 -1
- package/lib/widget.d.ts +6 -0
- package/lib/widget.js +23 -9
- package/lib/widget.js.map +1 -1
- package/lib/widgetfactory.js +2 -1
- package/lib/widgetfactory.js.map +1 -1
- package/package.json +30 -27
- package/style/base.css +28 -27
- package/style/index.css +5 -2
- package/style/index.js +5 -2
- package/style/toc.css +31 -0
- package/style/toolbar.css +2 -2
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { createCellSearchProvider, SELECTED_HIGHLIGHT_CLASS } from '@jupyterlab/cells';
|
|
4
|
+
import { SearchProvider } from '@jupyterlab/documentsearch';
|
|
5
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
6
|
+
import { ArrayExt } from '@lumino/algorithm';
|
|
7
|
+
import { NotebookPanel } from './panel';
|
|
8
|
+
/**
|
|
9
|
+
* Notebook document search provider
|
|
10
|
+
*/
|
|
11
|
+
export class NotebookSearchProvider extends SearchProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
*
|
|
15
|
+
* @param widget The widget to search in
|
|
16
|
+
* @param translator Application translator
|
|
17
|
+
*/
|
|
18
|
+
constructor(widget, translator = nullTranslator) {
|
|
19
|
+
super(widget);
|
|
20
|
+
this.translator = translator;
|
|
21
|
+
this._currentProviderIndex = null;
|
|
22
|
+
this._onSelectedCells = false;
|
|
23
|
+
this._query = null;
|
|
24
|
+
this._searchProviders = [];
|
|
25
|
+
this._documentHasChanged = false;
|
|
26
|
+
this.widget.model.cells.changed.connect(this._onCellsChanged, this);
|
|
27
|
+
this.widget.content.activeCellChanged.connect(this._onActiveCellChanged, this);
|
|
28
|
+
this.widget.content.placeholderCellRendered.connect(this._onPlaceholderRendered, this);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Report whether or not this provider has the ability to search on the given object
|
|
32
|
+
*
|
|
33
|
+
* @param domain Widget to test
|
|
34
|
+
* @returns Search ability
|
|
35
|
+
*/
|
|
36
|
+
static isApplicable(domain) {
|
|
37
|
+
// check to see if the CMSearchProvider can search on the
|
|
38
|
+
// first cell, false indicates another editor is present
|
|
39
|
+
return domain instanceof NotebookPanel;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Instantiate a search provider for the notebook panel.
|
|
43
|
+
*
|
|
44
|
+
* #### Notes
|
|
45
|
+
* The widget provided is always checked using `isApplicable` before calling
|
|
46
|
+
* this factory.
|
|
47
|
+
*
|
|
48
|
+
* @param widget The widget to search on
|
|
49
|
+
* @param translator [optional] The translator object
|
|
50
|
+
*
|
|
51
|
+
* @returns The search provider on the notebook panel
|
|
52
|
+
*/
|
|
53
|
+
static createNew(widget, translator) {
|
|
54
|
+
return new NotebookSearchProvider(widget, translator);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The current index of the selected match.
|
|
58
|
+
*/
|
|
59
|
+
get currentMatchIndex() {
|
|
60
|
+
let agg = 0;
|
|
61
|
+
let found = false;
|
|
62
|
+
for (let idx = 0; idx < this._searchProviders.length; idx++) {
|
|
63
|
+
const provider = this._searchProviders[idx];
|
|
64
|
+
const localMatch = provider.currentMatchIndex;
|
|
65
|
+
if (localMatch !== null) {
|
|
66
|
+
agg += localMatch;
|
|
67
|
+
found = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
agg += provider.matchesCount;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return found ? agg : null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The number of matches.
|
|
78
|
+
*/
|
|
79
|
+
get matchesCount() {
|
|
80
|
+
return this._searchProviders.reduce((sum, provider) => (sum += provider.matchesCount), 0);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set to true if the widget under search is read-only, false
|
|
84
|
+
* if it is editable. Will be used to determine whether to show
|
|
85
|
+
* the replace option.
|
|
86
|
+
*/
|
|
87
|
+
get isReadOnly() {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
return (_c = (_b = (_a = this.widget) === null || _a === void 0 ? void 0 : _a.content.model) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Dispose of the resources held by the search provider.
|
|
93
|
+
*
|
|
94
|
+
* #### Notes
|
|
95
|
+
* If the object's `dispose` method is called more than once, all
|
|
96
|
+
* calls made after the first will be a no-op.
|
|
97
|
+
*
|
|
98
|
+
* #### Undefined Behavior
|
|
99
|
+
* It is undefined behavior to use any functionality of the object
|
|
100
|
+
* after it has been disposed unless otherwise explicitly noted.
|
|
101
|
+
*/
|
|
102
|
+
dispose() {
|
|
103
|
+
var _a;
|
|
104
|
+
if (this.isDisposed) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.widget.content.placeholderCellRendered.disconnect(this._onPlaceholderRendered, this);
|
|
108
|
+
this.widget.content.activeCellChanged.disconnect(this._onActiveCellChanged, this);
|
|
109
|
+
(_a = this.widget.model) === null || _a === void 0 ? void 0 : _a.cells.changed.disconnect(this._onCellsChanged, this);
|
|
110
|
+
super.dispose();
|
|
111
|
+
const index = this.widget.content.activeCellIndex;
|
|
112
|
+
this.endQuery()
|
|
113
|
+
.then(() => {
|
|
114
|
+
if (!this.widget.isDisposed) {
|
|
115
|
+
this.widget.content.activeCellIndex = index;
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
.catch(reason => {
|
|
119
|
+
console.error(`Fail to end search query in notebook:\n${reason}`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the filters for the given provider.
|
|
124
|
+
*
|
|
125
|
+
* @returns The filters.
|
|
126
|
+
*/
|
|
127
|
+
getFilters() {
|
|
128
|
+
const trans = this.translator.load('jupyterlab');
|
|
129
|
+
return {
|
|
130
|
+
output: {
|
|
131
|
+
title: trans.__('Search Cell Outputs'),
|
|
132
|
+
description: trans.__('Search in the cell outputs.'),
|
|
133
|
+
default: false,
|
|
134
|
+
supportReplace: false
|
|
135
|
+
},
|
|
136
|
+
selectedCells: {
|
|
137
|
+
title: trans.__('Search Selected Cell(s)'),
|
|
138
|
+
description: trans.__('Search only in the selected cell(s).'),
|
|
139
|
+
default: false,
|
|
140
|
+
supportReplace: true
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get an initial query value if applicable so that it can be entered
|
|
146
|
+
* into the search box as an initial query
|
|
147
|
+
*
|
|
148
|
+
* @returns Initial value used to populate the search box.
|
|
149
|
+
*/
|
|
150
|
+
getInitialQuery() {
|
|
151
|
+
var _a;
|
|
152
|
+
const activeCell = this.widget.content.activeCell;
|
|
153
|
+
const selection = (_a = activeCell === null || activeCell === void 0 ? void 0 : activeCell.editor) === null || _a === void 0 ? void 0 : _a.doc.getSelection();
|
|
154
|
+
// if there are newlines, just return empty string
|
|
155
|
+
return (selection === null || selection === void 0 ? void 0 : selection.search(/\r?\n|\r/g)) === -1 ? selection : '';
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Clear currently highlighted match.
|
|
159
|
+
*/
|
|
160
|
+
async clearHighlight() {
|
|
161
|
+
if (this._currentProviderIndex !== null) {
|
|
162
|
+
await this._searchProviders[this._currentProviderIndex].clearHighlight();
|
|
163
|
+
this._currentProviderIndex = null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Highlight the next match.
|
|
168
|
+
*
|
|
169
|
+
* @param loop Whether to loop within the matches list.
|
|
170
|
+
*
|
|
171
|
+
* @returns The next match if available.
|
|
172
|
+
*/
|
|
173
|
+
async highlightNext(loop = true) {
|
|
174
|
+
const match = await this._stepNext(false, loop);
|
|
175
|
+
return match !== null && match !== void 0 ? match : undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Highlight the previous match.
|
|
179
|
+
*
|
|
180
|
+
* @param loop Whether to loop within the matches list.
|
|
181
|
+
*
|
|
182
|
+
* @returns The previous match if available.
|
|
183
|
+
*/
|
|
184
|
+
async highlightPrevious(loop = true) {
|
|
185
|
+
const match = await this._stepNext(true, loop);
|
|
186
|
+
return match !== null && match !== void 0 ? match : undefined;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Search for a regular expression with optional filters.
|
|
190
|
+
*
|
|
191
|
+
* @param query A regular expression to test for
|
|
192
|
+
* @param filters Filter parameters to pass to provider
|
|
193
|
+
*
|
|
194
|
+
*/
|
|
195
|
+
async startQuery(query, filters) {
|
|
196
|
+
if (!this.widget) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
await this.endQuery();
|
|
200
|
+
let cells = this.widget.content.widgets;
|
|
201
|
+
this._query = query;
|
|
202
|
+
this._filters = Object.assign({ output: false, selectedCells: false }, (filters !== null && filters !== void 0 ? filters : {}));
|
|
203
|
+
this._onSelectedCells = this._filters.selectedCells;
|
|
204
|
+
if (this._filters.selectedCells) {
|
|
205
|
+
this.widget.content.selectionChanged.connect(this._onSelectionChanged, this);
|
|
206
|
+
}
|
|
207
|
+
// For each cell, create a search provider
|
|
208
|
+
this._searchProviders = await Promise.all(cells.map(async (cell) => {
|
|
209
|
+
const cellSearchProvider = createCellSearchProvider(cell);
|
|
210
|
+
cellSearchProvider.stateChanged.connect(this._onSearchProviderChanged, this);
|
|
211
|
+
await cellSearchProvider.setIsActive(!this._filters.selectedCells ||
|
|
212
|
+
this.widget.content.isSelectedOrActive(cell));
|
|
213
|
+
await cellSearchProvider.startQuery(query, this._filters);
|
|
214
|
+
return cellSearchProvider;
|
|
215
|
+
}));
|
|
216
|
+
this._currentProviderIndex = this.widget.content.activeCellIndex;
|
|
217
|
+
if (!this._documentHasChanged) {
|
|
218
|
+
await this.highlightNext(false);
|
|
219
|
+
}
|
|
220
|
+
this._documentHasChanged = false;
|
|
221
|
+
return Promise.resolve();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Stop the search and clear all internal state.
|
|
225
|
+
*/
|
|
226
|
+
async endQuery() {
|
|
227
|
+
await Promise.all(this._searchProviders.map(provider => {
|
|
228
|
+
provider.stateChanged.disconnect(this._onSearchProviderChanged, this);
|
|
229
|
+
return provider.endQuery().then(() => {
|
|
230
|
+
provider.dispose();
|
|
231
|
+
});
|
|
232
|
+
}));
|
|
233
|
+
this._searchProviders.length = 0;
|
|
234
|
+
this._currentProviderIndex = null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Replace the currently selected match with the provided text
|
|
238
|
+
*
|
|
239
|
+
* @param newText The replacement text.
|
|
240
|
+
* @param loop Whether to loop within the matches list.
|
|
241
|
+
*
|
|
242
|
+
* @returns A promise that resolves with a boolean indicating whether a replace occurred.
|
|
243
|
+
*/
|
|
244
|
+
async replaceCurrentMatch(newText, loop = true) {
|
|
245
|
+
let replaceOccurred = false;
|
|
246
|
+
const unrenderMarkdownCell = async (highlightNext = false) => {
|
|
247
|
+
var _a;
|
|
248
|
+
// Unrendered markdown cell
|
|
249
|
+
const activeCell = (_a = this.widget) === null || _a === void 0 ? void 0 : _a.content.activeCell;
|
|
250
|
+
if ((activeCell === null || activeCell === void 0 ? void 0 : activeCell.model.type) === 'markdown' &&
|
|
251
|
+
activeCell.rendered) {
|
|
252
|
+
activeCell.rendered = false;
|
|
253
|
+
if (highlightNext) {
|
|
254
|
+
await this.highlightNext(loop);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
if (this._currentProviderIndex !== null) {
|
|
259
|
+
await unrenderMarkdownCell();
|
|
260
|
+
const searchEngine = this._searchProviders[this._currentProviderIndex];
|
|
261
|
+
replaceOccurred = await searchEngine.replaceCurrentMatch(newText);
|
|
262
|
+
}
|
|
263
|
+
await this.highlightNext(loop);
|
|
264
|
+
// Force highlighting the first hit in the unrendered cell
|
|
265
|
+
await unrenderMarkdownCell(true);
|
|
266
|
+
return replaceOccurred;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Replace all matches in the notebook with the provided text
|
|
270
|
+
*
|
|
271
|
+
* @param newText The replacement text.
|
|
272
|
+
*
|
|
273
|
+
* @returns A promise that resolves with a boolean indicating whether a replace occurred.
|
|
274
|
+
*/
|
|
275
|
+
async replaceAllMatches(newText) {
|
|
276
|
+
const replacementOccurred = await Promise.all(this._searchProviders.map(provider => {
|
|
277
|
+
return provider.replaceAllMatches(newText);
|
|
278
|
+
}));
|
|
279
|
+
return replacementOccurred.includes(true);
|
|
280
|
+
}
|
|
281
|
+
_addCellProvider(index) {
|
|
282
|
+
var _a, _b;
|
|
283
|
+
const cell = this.widget.content.widgets[index];
|
|
284
|
+
const cellSearchProvider = createCellSearchProvider(cell);
|
|
285
|
+
cellSearchProvider.stateChanged.connect(this._onSearchProviderChanged, this);
|
|
286
|
+
ArrayExt.insert(this._searchProviders, index, cellSearchProvider);
|
|
287
|
+
cellSearchProvider
|
|
288
|
+
.setIsActive(!((_b = (_a = this._filters) === null || _a === void 0 ? void 0 : _a.selectedCells) !== null && _b !== void 0 ? _b : false) ||
|
|
289
|
+
this.widget.content.isSelectedOrActive(cell))
|
|
290
|
+
.then(() => {
|
|
291
|
+
cellSearchProvider.startQuery(this._query, this._filters);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
_removeCellProvider(index) {
|
|
295
|
+
const provider = ArrayExt.removeAt(this._searchProviders, index);
|
|
296
|
+
provider === null || provider === void 0 ? void 0 : provider.stateChanged.disconnect(this._onSearchProviderChanged, this);
|
|
297
|
+
provider === null || provider === void 0 ? void 0 : provider.dispose();
|
|
298
|
+
}
|
|
299
|
+
async _onCellsChanged(cells, changes) {
|
|
300
|
+
await this.clearHighlight();
|
|
301
|
+
switch (changes.type) {
|
|
302
|
+
case 'add':
|
|
303
|
+
changes.newValues.forEach((model, index) => {
|
|
304
|
+
this._addCellProvider(changes.newIndex + index);
|
|
305
|
+
});
|
|
306
|
+
break;
|
|
307
|
+
case 'move':
|
|
308
|
+
ArrayExt.move(this._searchProviders, changes.oldIndex, changes.newIndex);
|
|
309
|
+
break;
|
|
310
|
+
case 'remove':
|
|
311
|
+
for (let index = 0; index < changes.oldValues.length; index++) {
|
|
312
|
+
this._removeCellProvider(changes.oldIndex);
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
case 'set':
|
|
316
|
+
changes.newValues.forEach((model, index) => {
|
|
317
|
+
this._addCellProvider(changes.newIndex + index);
|
|
318
|
+
this._removeCellProvider(changes.newIndex + index + 1);
|
|
319
|
+
});
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
this._onSearchProviderChanged();
|
|
323
|
+
}
|
|
324
|
+
_onPlaceholderRendered(panel, renderedCell) {
|
|
325
|
+
const index = panel.widgets.findIndex(cell => cell.id === renderedCell.id);
|
|
326
|
+
if (index >= 0) {
|
|
327
|
+
void this._onCellsChanged(panel.model.cells, {
|
|
328
|
+
newIndex: index,
|
|
329
|
+
newValues: [renderedCell.model],
|
|
330
|
+
oldIndex: index,
|
|
331
|
+
oldValues: [renderedCell.model],
|
|
332
|
+
type: 'set'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async _stepNext(reverse = false, loop = false) {
|
|
337
|
+
const activateNewMatch = () => {
|
|
338
|
+
var _a;
|
|
339
|
+
if (this.widget.content.activeCellIndex !== this._currentProviderIndex) {
|
|
340
|
+
this.widget.content.activeCellIndex = this._currentProviderIndex;
|
|
341
|
+
}
|
|
342
|
+
const activeCell = this.widget.content.activeCell;
|
|
343
|
+
// Unhide cell
|
|
344
|
+
if (activeCell.inputHidden) {
|
|
345
|
+
activeCell.inputHidden = false;
|
|
346
|
+
}
|
|
347
|
+
// scroll to newly activate highlight
|
|
348
|
+
const containerRect = this.widget.content.node.getBoundingClientRect();
|
|
349
|
+
const element = (_a = activeCell.node.querySelector(`.${SELECTED_HIGHLIGHT_CLASS}`)) !== null && _a !== void 0 ? _a : activeCell.node.querySelector('.CodeMirror-selected');
|
|
350
|
+
if (element) {
|
|
351
|
+
const elementRect = element.getBoundingClientRect();
|
|
352
|
+
if (elementRect.top < containerRect.top ||
|
|
353
|
+
elementRect.top > containerRect.bottom) {
|
|
354
|
+
element.scrollIntoView({ block: 'center' });
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
if (this._currentProviderIndex === null) {
|
|
359
|
+
this._currentProviderIndex = this.widget.content.activeCellIndex;
|
|
360
|
+
}
|
|
361
|
+
const startIndex = this._currentProviderIndex;
|
|
362
|
+
do {
|
|
363
|
+
const searchEngine = this._searchProviders[this._currentProviderIndex];
|
|
364
|
+
const match = reverse
|
|
365
|
+
? await searchEngine.highlightPrevious()
|
|
366
|
+
: await searchEngine.highlightNext();
|
|
367
|
+
if (match) {
|
|
368
|
+
activateNewMatch();
|
|
369
|
+
return match;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
this._currentProviderIndex =
|
|
373
|
+
this._currentProviderIndex + (reverse ? -1 : 1);
|
|
374
|
+
if (loop) {
|
|
375
|
+
// We loop on all cells, not hit found
|
|
376
|
+
if (this._currentProviderIndex === startIndex) {
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
this._currentProviderIndex =
|
|
380
|
+
(this._currentProviderIndex + this._searchProviders.length) %
|
|
381
|
+
this._searchProviders.length;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
} while (0 <= this._currentProviderIndex &&
|
|
385
|
+
this._currentProviderIndex < this._searchProviders.length);
|
|
386
|
+
if (loop) {
|
|
387
|
+
// Search a last time in the first provider as it may contain more
|
|
388
|
+
// than one matches
|
|
389
|
+
const searchEngine = this._searchProviders[this._currentProviderIndex];
|
|
390
|
+
const match = reverse
|
|
391
|
+
? await searchEngine.highlightPrevious()
|
|
392
|
+
: await searchEngine.highlightNext();
|
|
393
|
+
if (match) {
|
|
394
|
+
activateNewMatch();
|
|
395
|
+
return match;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
this._currentProviderIndex = null;
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
async _onActiveCellChanged() {
|
|
402
|
+
await this._onSelectionChanged();
|
|
403
|
+
if (this.widget.content.activeCellIndex !== this._currentProviderIndex) {
|
|
404
|
+
await this.clearHighlight();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
_onSearchProviderChanged() {
|
|
408
|
+
// Don't highlight the next occurrence when the query
|
|
409
|
+
// follows a document change
|
|
410
|
+
this._documentHasChanged = true;
|
|
411
|
+
this._stateChanged.emit();
|
|
412
|
+
}
|
|
413
|
+
async _onSelectionChanged() {
|
|
414
|
+
if (this._onSelectedCells) {
|
|
415
|
+
const cells = this.widget.content.widgets;
|
|
416
|
+
await Promise.all(this._searchProviders.map((provider, index) => provider.setIsActive(this.widget.content.isSelectedOrActive(cells[index]))));
|
|
417
|
+
this._onSearchProviderChanged();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=searchprovider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchprovider.js","sourceRoot":"","sources":["../src/searchprovider.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAGL,wBAAwB,EAGxB,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAKL,cAAc,EACf,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,cAA6B;IACvE;;;;;OAKG;IACH,YACE,MAAqB,EACX,aAA0B,cAAc;QAElD,KAAK,CAAC,MAAM,CAAC,CAAC;QAFJ,eAAU,GAAV,UAAU,CAA8B;QA4gB5C,0BAAqB,GAAkB,IAAI,CAAC;QAE5C,qBAAgB,GAAG,KAAK,CAAC;QACzB,WAAM,GAAkB,IAAI,CAAC;QAC7B,qBAAgB,GAAyB,EAAE,CAAC;QAC5C,wBAAmB,GAAG,KAAK,CAAC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BAAqB,GAAG,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,KAAK,CAAC,oBAAoB;QAChC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,KAAK,IAAI,CAAC,qBAAqB,EAAE;YACtE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;SAC7B;IACH,CAAC;IAEO,wBAAwB;QAC9B,qDAAqD;QACrD,4BAA4B;QAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAC/B,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;YAC1C,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAC5C,QAAQ,CAAC,WAAW,CAClB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CACrD,CACF,CACF,CAAC;YAEF,IAAI,CAAC,wBAAwB,EAAE,CAAC;SACjC;IACH,CAAC;CAQF"}
|
package/lib/toc.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { ISanitizer } from '@jupyterlab/apputils';
|
|
2
|
+
import { Cell, ICellModel } from '@jupyterlab/cells';
|
|
3
|
+
import { IMarkdownParser } from '@jupyterlab/rendermime';
|
|
4
|
+
import { TableOfContents, TableOfContentsFactory, TableOfContentsModel } from '@jupyterlab/toc';
|
|
5
|
+
import { NotebookPanel } from './panel';
|
|
6
|
+
import { INotebookTracker } from './tokens';
|
|
7
|
+
import { Notebook } from './widget';
|
|
8
|
+
/**
|
|
9
|
+
* Cell running status
|
|
10
|
+
*/
|
|
11
|
+
export declare enum RunningStatus {
|
|
12
|
+
/**
|
|
13
|
+
* Cell is idle
|
|
14
|
+
*/
|
|
15
|
+
Idle = -1,
|
|
16
|
+
/**
|
|
17
|
+
* Cell execution is scheduled
|
|
18
|
+
*/
|
|
19
|
+
Scheduled = 0,
|
|
20
|
+
/**
|
|
21
|
+
* Cell is running
|
|
22
|
+
*/
|
|
23
|
+
Running = 1
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type of headings
|
|
27
|
+
*/
|
|
28
|
+
export declare enum HeadingType {
|
|
29
|
+
/**
|
|
30
|
+
* Heading from HTML output
|
|
31
|
+
*/
|
|
32
|
+
HTML = 0,
|
|
33
|
+
/**
|
|
34
|
+
* Heading from Markdown cell or Markdown output
|
|
35
|
+
*/
|
|
36
|
+
Markdown = 1
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Interface describing a notebook cell heading.
|
|
40
|
+
*/
|
|
41
|
+
export interface INotebookHeading extends TableOfContents.IHeading {
|
|
42
|
+
/**
|
|
43
|
+
* Reference to a notebook cell.
|
|
44
|
+
*/
|
|
45
|
+
cellRef: Cell;
|
|
46
|
+
/**
|
|
47
|
+
* Running status of the cells in the heading
|
|
48
|
+
*/
|
|
49
|
+
isRunning: RunningStatus;
|
|
50
|
+
/**
|
|
51
|
+
* Index of the output containing the heading
|
|
52
|
+
*/
|
|
53
|
+
outputIndex?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Type of heading
|
|
56
|
+
*/
|
|
57
|
+
type: HeadingType;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Table of content model for Notebook files.
|
|
61
|
+
*/
|
|
62
|
+
export declare class NotebookToCModel extends TableOfContentsModel<INotebookHeading, NotebookPanel> {
|
|
63
|
+
protected parser: IMarkdownParser | null;
|
|
64
|
+
protected sanitizer: ISanitizer;
|
|
65
|
+
/**
|
|
66
|
+
* Constructor
|
|
67
|
+
*
|
|
68
|
+
* @param widget The widget to search in
|
|
69
|
+
* @param parser Markdown parser
|
|
70
|
+
* @param sanitizer Sanitizer
|
|
71
|
+
* @param configuration Default model configuration
|
|
72
|
+
*/
|
|
73
|
+
constructor(widget: NotebookPanel, parser: IMarkdownParser | null, sanitizer: ISanitizer, configuration?: TableOfContents.IConfig);
|
|
74
|
+
/**
|
|
75
|
+
* Type of document supported by the model.
|
|
76
|
+
*
|
|
77
|
+
* #### Notes
|
|
78
|
+
* A `data-document-type` attribute with this value will be set
|
|
79
|
+
* on the tree view `.jp-TableOfContents-content[data-document-type="..."]`
|
|
80
|
+
*/
|
|
81
|
+
get documentType(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the model gets updated even if the table of contents panel
|
|
84
|
+
* is hidden or not.
|
|
85
|
+
*/
|
|
86
|
+
protected get isAlwaysActive(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* List of configuration options supported by the model.
|
|
89
|
+
*/
|
|
90
|
+
get supportedOptions(): (keyof TableOfContents.IConfig)[];
|
|
91
|
+
/**
|
|
92
|
+
* Get the first heading of a given cell.
|
|
93
|
+
*
|
|
94
|
+
* It will be `null` if the cell has no headings.
|
|
95
|
+
*
|
|
96
|
+
* @param cell Cell
|
|
97
|
+
* @returns The associated heading
|
|
98
|
+
*/
|
|
99
|
+
getCellHeading(cell: Cell): INotebookHeading | null;
|
|
100
|
+
/**
|
|
101
|
+
* Dispose the object
|
|
102
|
+
*/
|
|
103
|
+
dispose(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Model configuration setter.
|
|
106
|
+
*
|
|
107
|
+
* @param c New configuration
|
|
108
|
+
*/
|
|
109
|
+
setConfiguration(c: Partial<TableOfContents.IConfig>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Callback on heading collapse.
|
|
112
|
+
*
|
|
113
|
+
* @param options.heading The heading to change state (all headings if not provided)
|
|
114
|
+
* @param options.collapsed The new collapsed status (toggle existing status if not provided)
|
|
115
|
+
*/
|
|
116
|
+
toggleCollapse(options: {
|
|
117
|
+
heading?: INotebookHeading;
|
|
118
|
+
collapsed?: boolean;
|
|
119
|
+
}): void;
|
|
120
|
+
/**
|
|
121
|
+
* Produce the headings for a document.
|
|
122
|
+
*
|
|
123
|
+
* @returns The list of new headings or `null` if nothing needs to be updated.
|
|
124
|
+
*/
|
|
125
|
+
protected getHeadings(): Promise<INotebookHeading[] | null>;
|
|
126
|
+
/**
|
|
127
|
+
* Read table of content configuration from notebook metadata.
|
|
128
|
+
*
|
|
129
|
+
* @returns ToC configuration from metadata
|
|
130
|
+
*/
|
|
131
|
+
protected loadConfigurationFromMetadata(): Partial<TableOfContents.IConfig>;
|
|
132
|
+
protected onActiveCellChanged(notebook: Notebook, cell: Cell<ICellModel>): void;
|
|
133
|
+
protected onHeadingsChanged(): void;
|
|
134
|
+
protected onExecuted(_: unknown, args: {
|
|
135
|
+
notebook: Notebook;
|
|
136
|
+
cell: Cell;
|
|
137
|
+
}): void;
|
|
138
|
+
protected onExecutionScheduled(_: unknown, args: {
|
|
139
|
+
notebook: Notebook;
|
|
140
|
+
cell: Cell;
|
|
141
|
+
}): void;
|
|
142
|
+
protected onMetadataChanged(): void;
|
|
143
|
+
protected updateRunningStatus(headings: INotebookHeading[]): void;
|
|
144
|
+
/**
|
|
145
|
+
* Mapping between configuration options and notebook metadata.
|
|
146
|
+
*
|
|
147
|
+
* If it starts with `!`, the boolean value of the configuration option is
|
|
148
|
+
* opposite to the one stored in metadata.
|
|
149
|
+
* If it contains `/`, the metadata data is nested.
|
|
150
|
+
*/
|
|
151
|
+
protected configMetadataMap: {
|
|
152
|
+
[k: keyof TableOfContents.IConfig]: string[];
|
|
153
|
+
};
|
|
154
|
+
private _runningCells;
|
|
155
|
+
private _cellToHeadingIndex;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Table of content model factory for Notebook files.
|
|
159
|
+
*/
|
|
160
|
+
export declare class NotebookToCFactory extends TableOfContentsFactory<NotebookPanel> {
|
|
161
|
+
protected parser: IMarkdownParser | null;
|
|
162
|
+
protected sanitizer: ISanitizer;
|
|
163
|
+
/**
|
|
164
|
+
* Constructor
|
|
165
|
+
*
|
|
166
|
+
* @param tracker Widget tracker
|
|
167
|
+
* @param parser Markdown parser
|
|
168
|
+
* @param sanitizer Sanitizer
|
|
169
|
+
*/
|
|
170
|
+
constructor(tracker: INotebookTracker, parser: IMarkdownParser | null, sanitizer: ISanitizer);
|
|
171
|
+
/**
|
|
172
|
+
* Create a new table of contents model for the widget
|
|
173
|
+
*
|
|
174
|
+
* @param widget - widget
|
|
175
|
+
* @param configuration - Table of contents configuration
|
|
176
|
+
* @returns The table of contents model
|
|
177
|
+
*/
|
|
178
|
+
protected _createNew(widget: NotebookPanel, configuration?: TableOfContents.IConfig): TableOfContentsModel<TableOfContents.IHeading, NotebookPanel>;
|
|
179
|
+
}
|