@jupyterlab/cells 4.0.0-alpha.2 → 4.0.0-alpha.21

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.
Files changed (46) hide show
  1. package/lib/celldragutils.d.ts +1 -7
  2. package/lib/celldragutils.js +12 -13
  3. package/lib/celldragutils.js.map +1 -1
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/inputarea.d.ts +9 -19
  8. package/lib/inputarea.js +16 -29
  9. package/lib/inputarea.js.map +1 -1
  10. package/lib/model.d.ts +121 -79
  11. package/lib/model.js +179 -392
  12. package/lib/model.js.map +1 -1
  13. package/lib/placeholder.d.ts +23 -19
  14. package/lib/placeholder.js +30 -35
  15. package/lib/placeholder.js.map +1 -1
  16. package/lib/resizeHandle.d.ts +0 -1
  17. package/lib/resizeHandle.js +9 -11
  18. package/lib/resizeHandle.js.map +1 -1
  19. package/lib/searchprovider.d.ts +31 -0
  20. package/lib/searchprovider.js +359 -0
  21. package/lib/searchprovider.js.map +1 -0
  22. package/lib/testutils.d.ts +22 -0
  23. package/lib/testutils.js +48 -0
  24. package/lib/testutils.js.map +1 -0
  25. package/lib/widget.d.ts +226 -42
  26. package/lib/widget.js +672 -270
  27. package/lib/widget.js.map +1 -1
  28. package/package.json +36 -33
  29. package/src/celldragutils.ts +214 -0
  30. package/src/collapser.tsx +150 -0
  31. package/src/headerfooter.ts +52 -0
  32. package/src/index.ts +17 -0
  33. package/src/inputarea.ts +292 -0
  34. package/src/model.ts +845 -0
  35. package/src/placeholder.ts +125 -0
  36. package/src/resizeHandle.ts +96 -0
  37. package/src/searchprovider.ts +436 -0
  38. package/src/testutils.ts +57 -0
  39. package/src/widget.ts +2290 -0
  40. package/style/collapser.css +5 -4
  41. package/style/headerfooter.css +3 -3
  42. package/style/index.css +4 -2
  43. package/style/index.js +4 -2
  44. package/style/inputarea.css +19 -17
  45. package/style/placeholder.css +1 -1
  46. package/style/widget.css +85 -7
@@ -0,0 +1,359 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { EditorSearchProvider } from '@jupyterlab/codemirror';
4
+ import { signalToPromise } from '@jupyterlab/coreutils';
5
+ import { GenericSearchProvider } from '@jupyterlab/documentsearch';
6
+ /**
7
+ * Class applied on highlighted search matches
8
+ */
9
+ export const SELECTED_HIGHLIGHT_CLASS = 'jp-mod-selected';
10
+ /**
11
+ * Search provider for cells.
12
+ */
13
+ export class CellSearchProvider extends EditorSearchProvider {
14
+ constructor(cell) {
15
+ super();
16
+ this.cell = cell;
17
+ if (!this.cell.inViewport && !this.cell.editor) {
18
+ void signalToPromise(cell.inViewportChanged).then(([, inViewport]) => {
19
+ if (inViewport) {
20
+ this.cmHandler.setEditor(this.editor);
21
+ }
22
+ });
23
+ }
24
+ }
25
+ /**
26
+ * Text editor
27
+ */
28
+ get editor() {
29
+ return this.cell.editor;
30
+ }
31
+ /**
32
+ * Editor content model
33
+ */
34
+ get model() {
35
+ return this.cell.model;
36
+ }
37
+ }
38
+ /**
39
+ * Code cell search provider
40
+ */
41
+ class CodeCellSearchProvider extends CellSearchProvider {
42
+ /**
43
+ * Constructor
44
+ *
45
+ * @param cell Cell widget
46
+ */
47
+ constructor(cell) {
48
+ super(cell);
49
+ this.currentProviderIndex = -1;
50
+ this.outputsProvider = [];
51
+ const outputs = this.cell.outputArea;
52
+ this._onOutputsChanged(outputs, outputs.widgets.length).catch(reason => {
53
+ console.error(`Failed to initialize search on cell outputs.`, reason);
54
+ });
55
+ outputs.outputLengthChanged.connect(this._onOutputsChanged, this);
56
+ outputs.disposed.connect(() => {
57
+ outputs.outputLengthChanged.disconnect(this._onOutputsChanged);
58
+ }, this);
59
+ }
60
+ /**
61
+ * Number of matches in the cell.
62
+ */
63
+ get matchesCount() {
64
+ if (!this.isActive) {
65
+ return 0;
66
+ }
67
+ return (super.matchesCount +
68
+ this.outputsProvider.reduce((sum, provider) => { var _a; return sum + ((_a = provider.matchesCount) !== null && _a !== void 0 ? _a : 0); }, 0));
69
+ }
70
+ /**
71
+ * Clear currently highlighted match.
72
+ */
73
+ async clearHighlight() {
74
+ await super.clearHighlight();
75
+ await Promise.all(this.outputsProvider.map(provider => provider.clearHighlight()));
76
+ }
77
+ /**
78
+ * Dispose the search provider
79
+ */
80
+ dispose() {
81
+ if (this.isDisposed) {
82
+ return;
83
+ }
84
+ super.dispose();
85
+ this.outputsProvider.map(provider => {
86
+ provider.dispose();
87
+ });
88
+ this.outputsProvider.length = 0;
89
+ }
90
+ /**
91
+ * Highlight the next match.
92
+ *
93
+ * @returns The next match if there is one.
94
+ */
95
+ async highlightNext(loop, fromCursor = false) {
96
+ if (this.matchesCount === 0 || !this.isActive) {
97
+ this.currentIndex = null;
98
+ }
99
+ else {
100
+ if (this.currentProviderIndex === -1) {
101
+ const match = await super.highlightNext(true, fromCursor);
102
+ if (match) {
103
+ this.currentIndex = this.cmHandler.currentIndex;
104
+ return match;
105
+ }
106
+ else {
107
+ this.currentProviderIndex = 0;
108
+ }
109
+ }
110
+ while (this.currentProviderIndex < this.outputsProvider.length) {
111
+ const provider = this.outputsProvider[this.currentProviderIndex];
112
+ const match = await provider.highlightNext(false);
113
+ if (match) {
114
+ this.currentIndex =
115
+ super.matchesCount +
116
+ this.outputsProvider
117
+ .slice(0, this.currentProviderIndex)
118
+ .reduce((sum, provider) => { var _a; return (sum += (_a = provider.matchesCount) !== null && _a !== void 0 ? _a : 0); }, 0) +
119
+ provider.currentMatchIndex;
120
+ return match;
121
+ }
122
+ else {
123
+ this.currentProviderIndex += 1;
124
+ }
125
+ }
126
+ this.currentProviderIndex = -1;
127
+ this.currentIndex = null;
128
+ return undefined;
129
+ }
130
+ }
131
+ /**
132
+ * Highlight the previous match.
133
+ *
134
+ * @returns The previous match if there is one.
135
+ */
136
+ async highlightPrevious() {
137
+ if (this.matchesCount === 0 || !this.isActive) {
138
+ this.currentIndex = null;
139
+ }
140
+ else {
141
+ if (this.currentIndex === null) {
142
+ this.currentProviderIndex = this.outputsProvider.length - 1;
143
+ }
144
+ while (this.currentProviderIndex >= 0) {
145
+ const provider = this.outputsProvider[this.currentProviderIndex];
146
+ const match = await provider.highlightPrevious(false);
147
+ if (match) {
148
+ this.currentIndex =
149
+ super.matchesCount +
150
+ this.outputsProvider
151
+ .slice(0, this.currentProviderIndex)
152
+ .reduce((sum, provider) => { var _a; return (sum += (_a = provider.matchesCount) !== null && _a !== void 0 ? _a : 0); }, 0) +
153
+ provider.currentMatchIndex;
154
+ return match;
155
+ }
156
+ else {
157
+ this.currentProviderIndex -= 1;
158
+ }
159
+ }
160
+ const match = await super.highlightPrevious();
161
+ if (match) {
162
+ this.currentIndex = this.cmHandler.currentIndex;
163
+ return match;
164
+ }
165
+ else {
166
+ this.currentIndex = null;
167
+ return undefined;
168
+ }
169
+ }
170
+ }
171
+ /**
172
+ * Initialize the search using the provided options. Should update the UI to highlight
173
+ * all matches and "select" the first match.
174
+ *
175
+ * @param query A RegExp to be use to perform the search
176
+ * @param filters Filter parameters to pass to provider
177
+ */
178
+ async startQuery(query, filters) {
179
+ await super.startQuery(query, filters);
180
+ // Search outputs
181
+ if ((filters === null || filters === void 0 ? void 0 : filters.output) !== false && this.isActive) {
182
+ await Promise.all(this.outputsProvider.map(provider => provider.startQuery(query)));
183
+ }
184
+ }
185
+ async endQuery() {
186
+ var _a;
187
+ await super.endQuery();
188
+ if (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.output) !== false && this.isActive) {
189
+ await Promise.all(this.outputsProvider.map(provider => provider.endQuery()));
190
+ }
191
+ }
192
+ async _onOutputsChanged(outputArea, changes) {
193
+ var _a;
194
+ this.outputsProvider.forEach(provider => {
195
+ provider.dispose();
196
+ });
197
+ this.outputsProvider.length = 0;
198
+ this.currentProviderIndex = -1;
199
+ this.outputsProvider = this.cell.outputArea.widgets.map(output => new GenericSearchProvider(output));
200
+ if (this.isActive && this.query && ((_a = this.filters) === null || _a === void 0 ? void 0 : _a.output) !== false) {
201
+ await Promise.all([
202
+ this.outputsProvider.map(provider => {
203
+ void provider.startQuery(this.query);
204
+ })
205
+ ]);
206
+ }
207
+ this._stateChanged.emit();
208
+ }
209
+ }
210
+ /**
211
+ * Markdown cell search provider
212
+ */
213
+ class MarkdownCellSearchProvider extends CellSearchProvider {
214
+ /**
215
+ * Constructor
216
+ *
217
+ * @param cell Cell widget
218
+ */
219
+ constructor(cell) {
220
+ super(cell);
221
+ this._unrenderedByHighligh = false;
222
+ this.renderedProvider = new GenericSearchProvider(cell.renderer);
223
+ }
224
+ /**
225
+ * Clear currently highlighted match
226
+ */
227
+ async clearHighlight() {
228
+ await super.clearHighlight();
229
+ await this.renderedProvider.clearHighlight();
230
+ }
231
+ /**
232
+ * Dispose the search provider
233
+ */
234
+ dispose() {
235
+ if (this.isDisposed) {
236
+ return;
237
+ }
238
+ super.dispose();
239
+ this.renderedProvider.dispose();
240
+ }
241
+ /**
242
+ * Stop the search and clean any UI elements.
243
+ */
244
+ async endQuery() {
245
+ await super.endQuery();
246
+ await this.renderedProvider.endQuery();
247
+ }
248
+ /**
249
+ * Highlight the next match.
250
+ *
251
+ * @returns The next match if there is one.
252
+ */
253
+ async highlightNext() {
254
+ let match = undefined;
255
+ if (!this.isActive) {
256
+ return match;
257
+ }
258
+ const cell = this.cell;
259
+ if (cell.rendered && this.matchesCount > 0) {
260
+ // Unrender the cell
261
+ this._unrenderedByHighligh = true;
262
+ const waitForRendered = signalToPromise(cell.renderedChanged);
263
+ cell.rendered = false;
264
+ await waitForRendered;
265
+ }
266
+ match = await super.highlightNext();
267
+ return match;
268
+ }
269
+ /**
270
+ * Highlight the previous match.
271
+ *
272
+ * @returns The previous match if there is one.
273
+ */
274
+ async highlightPrevious() {
275
+ let match = undefined;
276
+ const cell = this.cell;
277
+ if (cell.rendered && this.matchesCount > 0) {
278
+ // Unrender the cell if there are matches within the cell
279
+ this._unrenderedByHighligh = true;
280
+ const waitForRendered = signalToPromise(cell.renderedChanged);
281
+ cell.rendered = false;
282
+ await waitForRendered;
283
+ }
284
+ match = await super.highlightPrevious();
285
+ return match;
286
+ }
287
+ /**
288
+ * Initialize the search using the provided options. Should update the UI
289
+ * to highlight all matches and "select" the first match.
290
+ *
291
+ * @param query A RegExp to be use to perform the search
292
+ * @param filters Filter parameters to pass to provider
293
+ */
294
+ async startQuery(query, filters) {
295
+ await super.startQuery(query, filters);
296
+ const cell = this.cell;
297
+ if (cell.rendered) {
298
+ this.onRenderedChanged(cell, cell.rendered);
299
+ }
300
+ cell.renderedChanged.connect(this.onRenderedChanged, this);
301
+ }
302
+ /**
303
+ * Replace all matches in the cell source with the provided text
304
+ *
305
+ * @param newText The replacement text.
306
+ * @returns Whether a replace occurred.
307
+ */
308
+ async replaceAllMatches(newText) {
309
+ const result = await super.replaceAllMatches(newText);
310
+ // if the cell is rendered force update
311
+ if (this.cell.rendered) {
312
+ this.cell.update();
313
+ }
314
+ return result;
315
+ }
316
+ /**
317
+ * Callback on rendered state change
318
+ *
319
+ * @param cell Cell that emitted the change
320
+ * @param rendered New rendered value
321
+ */
322
+ onRenderedChanged(cell, rendered) {
323
+ var _a;
324
+ if (!this._unrenderedByHighligh) {
325
+ this.currentIndex = null;
326
+ }
327
+ this._unrenderedByHighligh = false;
328
+ if (this.isActive) {
329
+ if (rendered) {
330
+ void this.renderedProvider.startQuery(this.query);
331
+ }
332
+ else {
333
+ // Force cursor position to ensure reverse search is working as expected
334
+ (_a = cell.editor) === null || _a === void 0 ? void 0 : _a.setCursorPosition({ column: 0, line: 0 });
335
+ void this.renderedProvider.endQuery();
336
+ }
337
+ }
338
+ }
339
+ }
340
+ /**
341
+ * Factory to create a cell search provider
342
+ *
343
+ * @param cell Cell widget
344
+ * @returns Cell search provider
345
+ */
346
+ export function createCellSearchProvider(cell) {
347
+ if (cell.isPlaceholder()) {
348
+ return new CellSearchProvider(cell);
349
+ }
350
+ switch (cell.model.type) {
351
+ case 'code':
352
+ return new CodeCellSearchProvider(cell);
353
+ case 'markdown':
354
+ return new MarkdownCellSearchProvider(cell);
355
+ default:
356
+ return new CellSearchProvider(cell);
357
+ }
358
+ }
359
+ //# sourceMappingURL=searchprovider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchprovider.js","sourceRoot":"","sources":["../src/searchprovider.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAoB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qBAAqB,EAItB,MAAM,4BAA4B,CAAC;AAKpC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,oBAAgC;IAGxC,YAAsB,IAAsB;QAC1C,KAAK,EAAE,CAAC;QADY,SAAI,GAAJ,IAAI,CAAkB;QAE1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAC9C,KAAK,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE;gBACnE,IAAI,UAAU,EAAE;oBACd,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAA0B,CAAC,CAAC;iBAC3D;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACH,IAAc,MAAM;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,sBAAuB,SAAQ,kBAAkB;IACrD;;;;OAIG;IACH,YAAY,IAAsB;QAChC,KA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AC,EAAE,CAAC,CAAC;gBACvD,KAAK,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;aACvC;SACF;IACH,CAAC;CAIF;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAsB;IAEtB,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;QACxB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACrC;IAED,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QACvB,KAAK,MAAM;YACT,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC1C,KAAK,UAAU;YACb,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,CAAC;QAC9C;YACE,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACvC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { CodeEditorWrapper } from '@jupyterlab/codeeditor';
2
+ import { CodeCellModel } from './model';
3
+ import { Cell } from './widget';
4
+ /**
5
+ * The default notebook content.
6
+ */
7
+ export declare namespace NBTestUtils {
8
+ const editorFactory: any;
9
+ const mimeTypeService: import("@jupyterlab/codeeditor").IEditorMimeTypeService;
10
+ /**
11
+ * Create a base cell content factory.
12
+ */
13
+ function createBaseCellFactory(): Cell.IContentFactory;
14
+ /**
15
+ * Create a new code cell content factory.
16
+ */
17
+ function createCodeCellFactory(): Cell.IContentFactory;
18
+ /**
19
+ * Create a cell editor widget.
20
+ */
21
+ function createCellEditor(model?: CodeCellModel): CodeEditorWrapper;
22
+ }
@@ -0,0 +1,48 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { CodeEditorWrapper } from '@jupyterlab/codeeditor';
4
+ import { CodeMirrorEditorFactory, CodeMirrorMimeTypeService, EditorLanguageRegistry } from '@jupyterlab/codemirror';
5
+ import { CodeCellModel } from './model';
6
+ import { Cell } from './widget';
7
+ /**
8
+ * The default notebook content.
9
+ */
10
+ export var NBTestUtils;
11
+ (function (NBTestUtils) {
12
+ const editorServices = (function () {
13
+ const languages = new EditorLanguageRegistry();
14
+ const factoryService = new CodeMirrorEditorFactory({ languages });
15
+ const mimeTypeService = new CodeMirrorMimeTypeService(languages);
16
+ return {
17
+ factoryService,
18
+ mimeTypeService
19
+ };
20
+ })();
21
+ NBTestUtils.editorFactory = editorServices.factoryService.newInlineEditor.bind(editorServices.factoryService);
22
+ NBTestUtils.mimeTypeService = editorServices.mimeTypeService;
23
+ /**
24
+ * Create a base cell content factory.
25
+ */
26
+ function createBaseCellFactory() {
27
+ return new Cell.ContentFactory({ editorFactory: NBTestUtils.editorFactory });
28
+ }
29
+ NBTestUtils.createBaseCellFactory = createBaseCellFactory;
30
+ /**
31
+ * Create a new code cell content factory.
32
+ */
33
+ function createCodeCellFactory() {
34
+ return new Cell.ContentFactory({ editorFactory: NBTestUtils.editorFactory });
35
+ }
36
+ NBTestUtils.createCodeCellFactory = createCodeCellFactory;
37
+ /**
38
+ * Create a cell editor widget.
39
+ */
40
+ function createCellEditor(model) {
41
+ return new CodeEditorWrapper({
42
+ model: model !== null && model !== void 0 ? model : new CodeCellModel(),
43
+ factory: NBTestUtils.editorFactory
44
+ });
45
+ }
46
+ NBTestUtils.createCellEditor = createCellEditor;
47
+ })(NBTestUtils || (NBTestUtils = {}));
48
+ //# sourceMappingURL=testutils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testutils.js","sourceRoot":"","sources":["../src/testutils.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAmB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC;;GAEG;AAEH,MAAM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