@jupyterlab/notebook 4.6.0-alpha.2 → 4.6.0-alpha.4
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 +23 -11
- package/lib/actions.js +78 -14
- package/lib/actions.js.map +1 -1
- package/lib/celllist.d.ts +4 -4
- package/lib/celllist.js.map +1 -1
- package/lib/default-toolbar.d.ts +6 -6
- package/lib/default-toolbar.js.map +1 -1
- package/lib/executionindicator.d.ts +6 -6
- package/lib/executionindicator.js.map +1 -1
- package/lib/history.d.ts +6 -6
- package/lib/history.js.map +1 -1
- package/lib/model.d.ts +5 -5
- package/lib/model.js +1 -0
- package/lib/model.js.map +1 -1
- package/lib/modelfactory.d.ts +3 -3
- package/lib/modelfactory.js.map +1 -1
- package/lib/modestatus.d.ts +2 -2
- package/lib/modestatus.js.map +1 -1
- package/lib/notebookfooter.d.ts +2 -2
- package/lib/notebooklspadapter.d.ts +10 -9
- package/lib/notebooklspadapter.js +1 -1
- package/lib/notebooklspadapter.js.map +1 -1
- package/lib/notebooktools.d.ts +9 -7
- package/lib/notebooktools.js.map +1 -1
- package/lib/panel.d.ts +7 -5
- package/lib/panel.js.map +1 -1
- package/lib/searchprovider.d.ts +5 -4
- package/lib/searchprovider.js.map +1 -1
- package/lib/testutils.d.ts +6 -4
- package/lib/testutils.js.map +1 -1
- package/lib/toc.d.ts +9 -7
- package/lib/toc.js.map +1 -1
- package/lib/tracker.d.ts +4 -4
- package/lib/tracker.js.map +1 -1
- package/lib/truststatus.d.ts +2 -2
- package/lib/truststatus.js.map +1 -1
- package/lib/widget.d.ts +19 -11
- package/lib/widget.js +33 -30
- package/lib/widget.js.map +1 -1
- package/lib/widgetfactory.d.ts +6 -5
- package/lib/widgetfactory.js.map +1 -1
- package/lib/windowing.d.ts +4 -3
- package/lib/windowing.js.map +1 -1
- package/package.json +23 -23
- package/src/actions.tsx +117 -27
- package/src/celllist.ts +5 -5
- package/src/default-toolbar.tsx +11 -12
- package/src/executionindicator.tsx +12 -10
- package/src/history.ts +8 -11
- package/src/model.ts +13 -15
- package/src/modelfactory.ts +5 -6
- package/src/modestatus.tsx +3 -6
- package/src/notebookfooter.ts +2 -2
- package/src/notebooklspadapter.ts +12 -14
- package/src/notebooktools.ts +12 -9
- package/src/panel.ts +10 -12
- package/src/searchprovider.ts +15 -15
- package/src/testutils.ts +9 -6
- package/src/toc.ts +10 -8
- package/src/tracker.ts +6 -5
- package/src/truststatus.tsx +4 -3
- package/src/widget.ts +59 -53
- package/src/widgetfactory.ts +13 -9
- package/src/windowing.ts +6 -7
- package/style/base.css +8 -1
package/src/actions.tsx
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
+
import type {
|
|
5
|
+
ISessionContext,
|
|
6
|
+
ISessionContextDialogs
|
|
7
|
+
} from '@jupyterlab/apputils';
|
|
4
8
|
import {
|
|
5
9
|
Clipboard,
|
|
6
10
|
Dialog,
|
|
7
|
-
ISessionContext,
|
|
8
|
-
ISessionContextDialogs,
|
|
9
11
|
showDialog,
|
|
10
12
|
SystemClipboard
|
|
11
13
|
} from '@jupyterlab/apputils';
|
|
12
|
-
import {
|
|
14
|
+
import type {
|
|
13
15
|
Cell,
|
|
14
16
|
CodeCell,
|
|
15
|
-
CodeCellModel,
|
|
16
17
|
ICellModel,
|
|
17
|
-
ICodeCellModel
|
|
18
|
+
ICodeCellModel
|
|
19
|
+
} from '@jupyterlab/cells';
|
|
20
|
+
import {
|
|
21
|
+
CodeCellModel,
|
|
18
22
|
isMarkdownCellModel,
|
|
19
23
|
isRawCellModel,
|
|
20
24
|
MarkdownCell
|
|
@@ -22,17 +26,20 @@ import {
|
|
|
22
26
|
import { Notification } from '@jupyterlab/apputils';
|
|
23
27
|
import { signalToPromise } from '@jupyterlab/coreutils';
|
|
24
28
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
25
|
-
import { KernelMessage } from '@jupyterlab/services';
|
|
26
|
-
import { ISharedAttachmentsCell } from '@jupyter/ydoc';
|
|
27
|
-
import { ITranslator
|
|
29
|
+
import type { KernelMessage } from '@jupyterlab/services';
|
|
30
|
+
import type { ISharedAttachmentsCell } from '@jupyter/ydoc';
|
|
31
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
32
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
28
33
|
import { every, findIndex } from '@lumino/algorithm';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
34
|
+
import type { JSONObject } from '@lumino/coreutils';
|
|
35
|
+
import { JSONExt } from '@lumino/coreutils';
|
|
36
|
+
import type { ISignal } from '@lumino/signaling';
|
|
37
|
+
import { Signal } from '@lumino/signaling';
|
|
31
38
|
import * as React from 'react';
|
|
32
39
|
import { runCell as defaultRunCell } from './cellexecutor';
|
|
33
|
-
import { Notebook, StaticNotebook } from './widget';
|
|
34
|
-
import { NotebookWindowedLayout } from './windowing';
|
|
35
|
-
import { INotebookCellExecutor } from './tokens';
|
|
40
|
+
import type { Notebook, StaticNotebook } from './widget';
|
|
41
|
+
import type { NotebookWindowedLayout } from './windowing';
|
|
42
|
+
import type { INotebookCellExecutor } from './tokens';
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
45
|
* The mimetype used for Jupyter cell data.
|
|
@@ -139,11 +146,32 @@ export class NotebookActions {
|
|
|
139
146
|
* A namespace for `NotebookActions` static methods.
|
|
140
147
|
*/
|
|
141
148
|
export namespace NotebookActions {
|
|
149
|
+
const READ_ONLY_ACTION_AUTO_CLOSE = 5000;
|
|
150
|
+
|
|
151
|
+
function notifySplitReadOnlyAction(translator?: ITranslator): void {
|
|
152
|
+
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
153
|
+
Notification.error(trans.__('The cell is read-only and cannot be split.'), {
|
|
154
|
+
autoClose: READ_ONLY_ACTION_AUTO_CLOSE
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function notifyMergeReadOnlyAction(translator?: ITranslator): void {
|
|
159
|
+
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
160
|
+
Notification.error(
|
|
161
|
+
trans.__('The cell is read-only and cannot be merged.'),
|
|
162
|
+
{
|
|
163
|
+
autoClose: READ_ONLY_ACTION_AUTO_CLOSE
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
142
168
|
/**
|
|
143
169
|
* Split the active cell into two or more cells.
|
|
144
170
|
*
|
|
145
171
|
* @param notebook The target notebook widget.
|
|
146
172
|
*
|
|
173
|
+
* @param translator - Application translator.
|
|
174
|
+
*
|
|
147
175
|
* #### Notes
|
|
148
176
|
* It will preserve the existing mode.
|
|
149
177
|
* The last cell will be activated if no selection is found.
|
|
@@ -158,10 +186,17 @@ export namespace NotebookActions {
|
|
|
158
186
|
* This action can be undone.
|
|
159
187
|
* The original cell is preserved to maintain kernel connections.
|
|
160
188
|
*/
|
|
161
|
-
export function splitCell(
|
|
189
|
+
export function splitCell(
|
|
190
|
+
notebook: Notebook,
|
|
191
|
+
translator?: ITranslator
|
|
192
|
+
): void {
|
|
162
193
|
if (!notebook.model || !notebook.activeCell) {
|
|
163
194
|
return;
|
|
164
195
|
}
|
|
196
|
+
if (notebook.activeCell.model.getMetadata('editable') === false) {
|
|
197
|
+
notifySplitReadOnlyAction(translator);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
165
200
|
|
|
166
201
|
const state = Private.getState(notebook);
|
|
167
202
|
// We force the notebook back in edit mode as splitting a cell
|
|
@@ -298,6 +333,8 @@ export namespace NotebookActions {
|
|
|
298
333
|
* @param addExtraLine - Whether to add an extra newline between merged cell contents
|
|
299
334
|
* (true, default) or use only a single newline (false).
|
|
300
335
|
*
|
|
336
|
+
* @param translator - Application translator.
|
|
337
|
+
*
|
|
301
338
|
* #### Notes
|
|
302
339
|
* The widget mode will be preserved.
|
|
303
340
|
* If only one cell is selected and `mergeAbove` is true, the above cell will be selected.
|
|
@@ -310,7 +347,8 @@ export namespace NotebookActions {
|
|
|
310
347
|
export function mergeCells(
|
|
311
348
|
notebook: Notebook,
|
|
312
349
|
mergeAbove: boolean = false,
|
|
313
|
-
addExtraLine: boolean = true
|
|
350
|
+
addExtraLine: boolean = true,
|
|
351
|
+
translator?: ITranslator
|
|
314
352
|
): void {
|
|
315
353
|
if (!notebook.model || !notebook.activeCell) {
|
|
316
354
|
return;
|
|
@@ -324,10 +362,15 @@ export namespace NotebookActions {
|
|
|
324
362
|
const primary = notebook.activeCell;
|
|
325
363
|
const active = notebook.activeCellIndex;
|
|
326
364
|
const attachments: nbformat.IAttachments = {};
|
|
365
|
+
let hasReadOnlyCell = false;
|
|
327
366
|
|
|
328
367
|
// Get the cells to merge.
|
|
329
368
|
notebook.widgets.forEach((child, index) => {
|
|
330
369
|
if (notebook.isSelectedOrActive(child)) {
|
|
370
|
+
if (child.model.getMetadata('editable') === false) {
|
|
371
|
+
hasReadOnlyCell = true;
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
331
374
|
toMerge.push(child.model.sharedModel.getSource());
|
|
332
375
|
if (index !== active) {
|
|
333
376
|
toDelete.push(index);
|
|
@@ -342,6 +385,11 @@ export namespace NotebookActions {
|
|
|
342
385
|
}
|
|
343
386
|
});
|
|
344
387
|
|
|
388
|
+
if (hasReadOnlyCell) {
|
|
389
|
+
notifyMergeReadOnlyAction(translator);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
345
393
|
// Check for only a single cell selected.
|
|
346
394
|
if (toMerge.length === 1) {
|
|
347
395
|
// Merge with the cell above when mergeAbove is true
|
|
@@ -350,6 +398,12 @@ export namespace NotebookActions {
|
|
|
350
398
|
if (active === 0) {
|
|
351
399
|
return;
|
|
352
400
|
}
|
|
401
|
+
if (
|
|
402
|
+
notebook.widgets[active - 1].model.getMetadata('editable') === false
|
|
403
|
+
) {
|
|
404
|
+
notifyMergeReadOnlyAction(translator);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
353
407
|
// Otherwise merge with the previous cell.
|
|
354
408
|
const cellModel = cells.get(active - 1);
|
|
355
409
|
|
|
@@ -360,6 +414,12 @@ export namespace NotebookActions {
|
|
|
360
414
|
if (active === cells.length - 1) {
|
|
361
415
|
return;
|
|
362
416
|
}
|
|
417
|
+
if (
|
|
418
|
+
notebook.widgets[active + 1].model.getMetadata('editable') === false
|
|
419
|
+
) {
|
|
420
|
+
notifyMergeReadOnlyAction(translator);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
363
423
|
// Otherwise merge with the next cell.
|
|
364
424
|
const cellModel = cells.get(active + 1);
|
|
365
425
|
|
|
@@ -1309,6 +1369,8 @@ export namespace NotebookActions {
|
|
|
1309
1369
|
* 'above' adds cells above the active cell, and
|
|
1310
1370
|
* 'replace' removes the currently selected cells and adds cells in their place.
|
|
1311
1371
|
*
|
|
1372
|
+
* @param options - Optional. Set `stripOutputs: true` to paste code cells without their outputs.
|
|
1373
|
+
*
|
|
1312
1374
|
* #### Notes
|
|
1313
1375
|
* The last pasted cell becomes the active cell.
|
|
1314
1376
|
* This is a no-op if there is no cell data on the clipboard.
|
|
@@ -1316,7 +1378,8 @@ export namespace NotebookActions {
|
|
|
1316
1378
|
*/
|
|
1317
1379
|
export function paste(
|
|
1318
1380
|
notebook: Notebook,
|
|
1319
|
-
mode: 'below' | 'belowSelected' | 'above' | 'replace' = 'below'
|
|
1381
|
+
mode: 'below' | 'belowSelected' | 'above' | 'replace' = 'below',
|
|
1382
|
+
options?: { stripOutputs?: boolean }
|
|
1320
1383
|
): void {
|
|
1321
1384
|
const clipboard = Clipboard.getInstance();
|
|
1322
1385
|
|
|
@@ -1324,7 +1387,10 @@ export namespace NotebookActions {
|
|
|
1324
1387
|
return;
|
|
1325
1388
|
}
|
|
1326
1389
|
|
|
1327
|
-
|
|
1390
|
+
let values = clipboard.getData(JUPYTER_CELL_MIME) as nbformat.IBaseCell[];
|
|
1391
|
+
if (options?.stripOutputs) {
|
|
1392
|
+
values = Private.stripCodeCellOutputs(values);
|
|
1393
|
+
}
|
|
1328
1394
|
|
|
1329
1395
|
addCells(notebook, mode, values, true);
|
|
1330
1396
|
void focusActiveCell(notebook);
|
|
@@ -1341,6 +1407,8 @@ export namespace NotebookActions {
|
|
|
1341
1407
|
* 'above' adds cells above the active cell, and
|
|
1342
1408
|
* 'replace' removes the currently selected cells and adds cells in their place.
|
|
1343
1409
|
*
|
|
1410
|
+
* @param options - Optional. Set `stripOutputs: true` to paste code cells without their outputs.
|
|
1411
|
+
*
|
|
1344
1412
|
* #### Notes
|
|
1345
1413
|
* The last pasted cell becomes the active cell.
|
|
1346
1414
|
* This is a no-op if there is no cell data on the clipboard.
|
|
@@ -1348,7 +1416,8 @@ export namespace NotebookActions {
|
|
|
1348
1416
|
*/
|
|
1349
1417
|
export async function pasteFromSystemClipboard(
|
|
1350
1418
|
notebook: Notebook,
|
|
1351
|
-
mode: 'below' | 'belowSelected' | 'above' | 'replace' = 'below'
|
|
1419
|
+
mode: 'below' | 'belowSelected' | 'above' | 'replace' = 'below',
|
|
1420
|
+
options?: { stripOutputs?: boolean }
|
|
1352
1421
|
): Promise<void> {
|
|
1353
1422
|
const clipboard = SystemClipboard.getInstance();
|
|
1354
1423
|
|
|
@@ -1357,7 +1426,10 @@ export namespace NotebookActions {
|
|
|
1357
1426
|
return;
|
|
1358
1427
|
}
|
|
1359
1428
|
|
|
1360
|
-
|
|
1429
|
+
let values = stored as nbformat.IBaseCell[];
|
|
1430
|
+
if (options?.stripOutputs) {
|
|
1431
|
+
values = Private.stripCodeCellOutputs(values);
|
|
1432
|
+
}
|
|
1361
1433
|
|
|
1362
1434
|
addCells(notebook, mode, values, true);
|
|
1363
1435
|
void focusActiveCell(notebook);
|
|
@@ -1494,7 +1566,7 @@ export namespace NotebookActions {
|
|
|
1494
1566
|
notebook.activeCellIndex = prevActiveCellIndex + values.length;
|
|
1495
1567
|
notebook.deselectAll();
|
|
1496
1568
|
if (cellsFromClipboard) {
|
|
1497
|
-
notebook.
|
|
1569
|
+
notebook.recordCellClipboardInteraction('paste', values);
|
|
1498
1570
|
}
|
|
1499
1571
|
void Private.handleState(notebook, state, true);
|
|
1500
1572
|
}
|
|
@@ -2393,6 +2465,7 @@ namespace Private {
|
|
|
2393
2465
|
/**
|
|
2394
2466
|
* Notebook cell executor
|
|
2395
2467
|
*/
|
|
2468
|
+
// eslint-disable-next-line no-unassigned-vars
|
|
2396
2469
|
export let executor: INotebookCellExecutor;
|
|
2397
2470
|
|
|
2398
2471
|
/**
|
|
@@ -2538,9 +2611,7 @@ namespace Private {
|
|
|
2538
2611
|
`Kernel '${sessionContext.kernelDisplayName}' for '${sessionContext.path}' is still initializing. You can run code cells when the kernel has initialized.`
|
|
2539
2612
|
),
|
|
2540
2613
|
'warning',
|
|
2541
|
-
{
|
|
2542
|
-
autoClose: false
|
|
2543
|
-
}
|
|
2614
|
+
{ autoClose: false }
|
|
2544
2615
|
);
|
|
2545
2616
|
return Promise.resolve(false);
|
|
2546
2617
|
}
|
|
@@ -2670,6 +2741,25 @@ namespace Private {
|
|
|
2670
2741
|
return executor ? executor.runCell(options) : defaultRunCell(options);
|
|
2671
2742
|
}
|
|
2672
2743
|
|
|
2744
|
+
/**
|
|
2745
|
+
* Return a deep copy of cells with code cell outputs and execution_count cleared.
|
|
2746
|
+
*
|
|
2747
|
+
* @param cells - The cells to process.
|
|
2748
|
+
* @returns New cell objects.
|
|
2749
|
+
*/
|
|
2750
|
+
export function stripCodeCellOutputs(
|
|
2751
|
+
cells: nbformat.IBaseCell[]
|
|
2752
|
+
): nbformat.IBaseCell[] {
|
|
2753
|
+
return cells.map(cell => {
|
|
2754
|
+
const copy = JSONExt.deepCopy(cell) as nbformat.ICell;
|
|
2755
|
+
if (copy && nbformat.isCode(copy)) {
|
|
2756
|
+
copy.outputs = [];
|
|
2757
|
+
copy.execution_count = null;
|
|
2758
|
+
}
|
|
2759
|
+
return copy;
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2673
2763
|
/**
|
|
2674
2764
|
* Get the selected cell(s) without affecting the clipboard.
|
|
2675
2765
|
*
|
|
@@ -2716,9 +2806,9 @@ namespace Private {
|
|
|
2716
2806
|
notebook.deselectAll();
|
|
2717
2807
|
}
|
|
2718
2808
|
if (cut) {
|
|
2719
|
-
notebook.
|
|
2809
|
+
notebook.recordCellClipboardInteraction('cut', data);
|
|
2720
2810
|
} else {
|
|
2721
|
-
notebook.
|
|
2811
|
+
notebook.recordCellClipboardInteraction('copy', data);
|
|
2722
2812
|
}
|
|
2723
2813
|
void handleState(notebook, state);
|
|
2724
2814
|
}
|
|
@@ -2753,9 +2843,9 @@ namespace Private {
|
|
|
2753
2843
|
notebook.deselectAll();
|
|
2754
2844
|
}
|
|
2755
2845
|
if (cut) {
|
|
2756
|
-
notebook.
|
|
2846
|
+
notebook.recordCellClipboardInteraction('cut', data);
|
|
2757
2847
|
} else {
|
|
2758
|
-
notebook.
|
|
2848
|
+
notebook.recordCellClipboardInteraction('copy', data);
|
|
2759
2849
|
}
|
|
2760
2850
|
void handleState(notebook, state);
|
|
2761
2851
|
}
|
package/src/celllist.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
+
import type { CellModel, ICellModel } from '@jupyterlab/cells';
|
|
4
5
|
import {
|
|
5
|
-
CellModel,
|
|
6
6
|
CodeCellModel,
|
|
7
|
-
ICellModel,
|
|
8
7
|
MarkdownCellModel,
|
|
9
8
|
RawCellModel
|
|
10
9
|
} from '@jupyterlab/cells';
|
|
11
|
-
import { IObservableList } from '@jupyterlab/observables';
|
|
12
|
-
import {
|
|
10
|
+
import type { IObservableList } from '@jupyterlab/observables';
|
|
11
|
+
import type {
|
|
13
12
|
ISharedCell,
|
|
14
13
|
ISharedCodeCell,
|
|
15
14
|
ISharedMarkdownCell,
|
|
@@ -17,7 +16,8 @@ import {
|
|
|
17
16
|
ISharedRawCell,
|
|
18
17
|
NotebookChange
|
|
19
18
|
} from '@jupyter/ydoc';
|
|
20
|
-
import { ISignal
|
|
19
|
+
import type { ISignal } from '@lumino/signaling';
|
|
20
|
+
import { Signal } from '@lumino/signaling';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* A cell list object that supports undo/redo.
|
package/src/default-toolbar.tsx
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
+
import type {
|
|
5
|
+
ISessionContext,
|
|
6
|
+
ISessionContextDialogs
|
|
7
|
+
} from '@jupyterlab/apputils';
|
|
4
8
|
import {
|
|
5
9
|
Toolbar as AppToolbar,
|
|
6
10
|
Dialog,
|
|
7
|
-
ISessionContext,
|
|
8
|
-
ISessionContextDialogs,
|
|
9
11
|
SessionContextDialogs,
|
|
10
12
|
showDialog
|
|
11
13
|
} from '@jupyterlab/apputils';
|
|
12
|
-
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
13
|
-
import * as nbformat from '@jupyterlab/nbformat';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
nullTranslator,
|
|
17
|
-
TranslationBundle
|
|
18
|
-
} from '@jupyterlab/translation';
|
|
14
|
+
import type { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
15
|
+
import type * as nbformat from '@jupyterlab/nbformat';
|
|
16
|
+
import type { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
17
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
19
18
|
import {
|
|
20
19
|
addIcon,
|
|
21
20
|
addToolbarButtonClass,
|
|
@@ -34,9 +33,9 @@ import {
|
|
|
34
33
|
} from '@jupyterlab/ui-components';
|
|
35
34
|
import * as React from 'react';
|
|
36
35
|
import { NotebookActions } from './actions';
|
|
37
|
-
import { NotebookPanel } from './panel';
|
|
38
|
-
import { Notebook } from './widget';
|
|
39
|
-
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
36
|
+
import type { NotebookPanel } from './panel';
|
|
37
|
+
import type { Notebook } from './widget';
|
|
38
|
+
import type { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
40
39
|
|
|
41
40
|
/**
|
|
42
41
|
* The class name added to toolbar cell type dropdown wrapper.
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import { ISessionContext
|
|
4
|
+
import type { ISessionContext } from '@jupyterlab/apputils';
|
|
5
|
+
import { translateKernelStatuses } from '@jupyterlab/apputils';
|
|
5
6
|
|
|
6
|
-
import { ITranslator
|
|
7
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
8
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
7
9
|
import React from 'react';
|
|
8
10
|
import { ProgressCircle } from '@jupyterlab/statusbar';
|
|
9
11
|
|
|
12
|
+
import type { LabIcon } from '@jupyterlab/ui-components';
|
|
10
13
|
import {
|
|
11
14
|
Button,
|
|
12
15
|
circleIcon,
|
|
13
|
-
LabIcon,
|
|
14
16
|
offlineBoltIcon,
|
|
15
17
|
VDomModel,
|
|
16
18
|
VDomRenderer
|
|
17
19
|
} from '@jupyterlab/ui-components';
|
|
18
20
|
|
|
19
|
-
import { Notebook } from './widget';
|
|
21
|
+
import type { Notebook } from './widget';
|
|
20
22
|
import { KernelMessage } from '@jupyterlab/services';
|
|
21
|
-
import { Kernel } from '@jupyterlab/services';
|
|
22
|
-
import { NotebookPanel } from './panel';
|
|
23
|
-
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
24
|
-
import { Widget } from '@lumino/widgets';
|
|
25
|
-
import { JSONObject } from '@lumino/coreutils';
|
|
26
|
-
import { IChangedArgs } from '@jupyterlab/coreutils';
|
|
23
|
+
import type { Kernel } from '@jupyterlab/services';
|
|
24
|
+
import type { NotebookPanel } from './panel';
|
|
25
|
+
import type { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
26
|
+
import type { Widget } from '@lumino/widgets';
|
|
27
|
+
import type { JSONObject } from '@lumino/coreutils';
|
|
28
|
+
import type { IChangedArgs } from '@jupyterlab/coreutils';
|
|
27
29
|
import { NotebookActions } from './actions';
|
|
28
30
|
|
|
29
31
|
/**
|
package/src/history.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import { Cell } from '@jupyterlab/cells';
|
|
5
|
-
import { ISessionContext } from '@jupyterlab/apputils';
|
|
6
|
-
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
7
|
-
import { KernelMessage } from '@jupyterlab/services';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
TranslationBundle
|
|
12
|
-
} from '@jupyterlab/translation';
|
|
13
|
-
import { IDisposable } from '@lumino/disposable';
|
|
4
|
+
import type { Cell } from '@jupyterlab/cells';
|
|
5
|
+
import type { ISessionContext } from '@jupyterlab/apputils';
|
|
6
|
+
import type { CodeEditor } from '@jupyterlab/codeeditor';
|
|
7
|
+
import type { KernelMessage } from '@jupyterlab/services';
|
|
8
|
+
import type { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
9
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
10
|
+
import type { IDisposable } from '@lumino/disposable';
|
|
14
11
|
import { Signal } from '@lumino/signaling';
|
|
15
|
-
import { IKernelConnection } from '@jupyterlab/services/lib/kernel/kernel';
|
|
12
|
+
import type { IKernelConnection } from '@jupyterlab/services/lib/kernel/kernel';
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* The definition of a console history manager object.
|
package/src/model.ts
CHANGED
|
@@ -2,24 +2,22 @@
|
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
4
|
import { Dialog, showDialog } from '@jupyterlab/apputils';
|
|
5
|
-
import { ICellModel } from '@jupyterlab/cells';
|
|
6
|
-
import { IChangedArgs } from '@jupyterlab/coreutils';
|
|
7
|
-
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
5
|
+
import type { ICellModel } from '@jupyterlab/cells';
|
|
6
|
+
import type { IChangedArgs } from '@jupyterlab/coreutils';
|
|
7
|
+
import type { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
8
8
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
9
|
-
import { IObservableList } from '@jupyterlab/observables';
|
|
10
|
-
import {
|
|
9
|
+
import type { IObservableList } from '@jupyterlab/observables';
|
|
10
|
+
import type {
|
|
11
11
|
IMapChange,
|
|
12
12
|
ISharedNotebook,
|
|
13
|
-
NotebookChange
|
|
14
|
-
YNotebook
|
|
13
|
+
NotebookChange
|
|
15
14
|
} from '@jupyter/ydoc';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
TranslationBundle
|
|
20
|
-
} from '@jupyterlab/translation';
|
|
15
|
+
import { YNotebook } from '@jupyter/ydoc';
|
|
16
|
+
import type { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
17
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
21
18
|
import { JSONExt } from '@lumino/coreutils';
|
|
22
|
-
import { ISignal
|
|
19
|
+
import type { ISignal } from '@lumino/signaling';
|
|
20
|
+
import { Signal } from '@lumino/signaling';
|
|
23
21
|
import { CellList } from './celllist';
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -397,6 +395,7 @@ close the notebook without saving it.`,
|
|
|
397
395
|
list: CellList,
|
|
398
396
|
change: IObservableList.IChangedArgs<ICellModel>
|
|
399
397
|
): void {
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
400
399
|
switch (change.type) {
|
|
401
400
|
case 'add':
|
|
402
401
|
change.newValues.forEach(cell => {
|
|
@@ -515,8 +514,7 @@ export namespace NotebookModel {
|
|
|
515
514
|
/**
|
|
516
515
|
* An options object for initializing a notebook model.
|
|
517
516
|
*/
|
|
518
|
-
export interface IOptions
|
|
519
|
-
extends DocumentRegistry.IModelOptions<ISharedNotebook> {
|
|
517
|
+
export interface IOptions extends DocumentRegistry.IModelOptions<ISharedNotebook> {
|
|
520
518
|
/**
|
|
521
519
|
* Default cell type.
|
|
522
520
|
*/
|
package/src/modelfactory.ts
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
4
|
import type { ISharedNotebook } from '@jupyter/ydoc';
|
|
5
|
-
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
6
|
-
import { Contents } from '@jupyterlab/services';
|
|
7
|
-
import { INotebookModel
|
|
5
|
+
import type { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
6
|
+
import type { Contents } from '@jupyterlab/services';
|
|
7
|
+
import type { INotebookModel } from './model';
|
|
8
|
+
import { NotebookModel } from './model';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A model factory for notebooks.
|
|
11
12
|
*/
|
|
12
|
-
export class NotebookModelFactory
|
|
13
|
-
implements DocumentRegistry.IModelFactory<INotebookModel>
|
|
14
|
-
{
|
|
13
|
+
export class NotebookModelFactory implements DocumentRegistry.IModelFactory<INotebookModel> {
|
|
15
14
|
/**
|
|
16
15
|
* Construct a new notebook model factory.
|
|
17
16
|
*/
|
package/src/modestatus.tsx
CHANGED
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { TextItem } from '@jupyterlab/statusbar';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
nullTranslator,
|
|
10
|
-
TranslationBundle
|
|
11
|
-
} from '@jupyterlab/translation';
|
|
7
|
+
import type { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
8
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
12
9
|
import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
|
13
10
|
import * as React from 'react';
|
|
14
|
-
import { Notebook, NotebookMode } from '.';
|
|
11
|
+
import type { Notebook, NotebookMode } from '.';
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* A pure function for rendering a Command/Edit mode component.
|
package/src/notebookfooter.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Widget } from '@lumino/widgets';
|
|
7
|
-
import { Message } from '@lumino/messaging';
|
|
8
|
-
import { Notebook } from './widget';
|
|
7
|
+
import type { Message } from '@lumino/messaging';
|
|
8
|
+
import type { Notebook } from './widget';
|
|
9
9
|
import { NotebookActions } from './actions';
|
|
10
10
|
|
|
11
11
|
const NOTEBOOK_FOOTER_CLASS = 'jp-Notebook-footer';
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import { SessionContext } from '@jupyterlab/apputils';
|
|
5
|
-
import { Cell, ICellModel } from '@jupyterlab/cells';
|
|
4
|
+
import type { SessionContext } from '@jupyterlab/apputils';
|
|
5
|
+
import type { Cell, ICellModel } from '@jupyterlab/cells';
|
|
6
6
|
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
7
|
-
import {
|
|
7
|
+
import type {
|
|
8
8
|
Document,
|
|
9
9
|
IAdapterOptions,
|
|
10
|
-
IVirtualPosition
|
|
11
|
-
untilReady,
|
|
12
|
-
VirtualDocument,
|
|
13
|
-
WidgetLSPAdapter
|
|
10
|
+
IVirtualPosition
|
|
14
11
|
} from '@jupyterlab/lsp';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
12
|
+
import { untilReady, VirtualDocument, WidgetLSPAdapter } from '@jupyterlab/lsp';
|
|
13
|
+
import type * as nbformat from '@jupyterlab/nbformat';
|
|
14
|
+
import type { IObservableList } from '@jupyterlab/observables';
|
|
15
|
+
import type { Session } from '@jupyterlab/services';
|
|
18
16
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
19
17
|
import { Signal } from '@lumino/signaling';
|
|
20
18
|
|
|
21
|
-
import { NotebookPanel } from './panel';
|
|
22
|
-
import { Notebook } from './widget';
|
|
23
|
-
import { CellList } from './celllist';
|
|
19
|
+
import type { NotebookPanel } from './panel';
|
|
20
|
+
import type { Notebook } from './widget';
|
|
21
|
+
import type { CellList } from './celllist';
|
|
24
22
|
|
|
25
23
|
type ILanguageInfoMetadata = nbformat.ILanguageInfoMetadata;
|
|
26
24
|
|
|
@@ -70,7 +68,7 @@ export class NotebookAdapter extends WidgetLSPAdapter<NotebookPanel> {
|
|
|
70
68
|
mimeType = languageMetadata.mimetype;
|
|
71
69
|
}
|
|
72
70
|
return Array.isArray(mimeType)
|
|
73
|
-
? mimeType[0] ?? IEditorMimeTypeService.defaultMimeType
|
|
71
|
+
? (mimeType[0] ?? IEditorMimeTypeService.defaultMimeType)
|
|
74
72
|
: mimeType;
|
|
75
73
|
}
|
|
76
74
|
|
package/src/notebooktools.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import { Cell, ICellModel } from '@jupyterlab/cells';
|
|
5
|
-
import { CodeEditor
|
|
4
|
+
import type { Cell, ICellModel } from '@jupyterlab/cells';
|
|
5
|
+
import type { CodeEditor } from '@jupyterlab/codeeditor';
|
|
6
|
+
import { JSONEditor } from '@jupyterlab/codeeditor';
|
|
6
7
|
import { ObservableJSON } from '@jupyterlab/observables';
|
|
7
|
-
import { IMapChange } from '@jupyter/ydoc';
|
|
8
|
-
import { ITranslator
|
|
8
|
+
import type { IMapChange } from '@jupyter/ydoc';
|
|
9
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
10
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
9
11
|
import { Collapser } from '@jupyterlab/ui-components';
|
|
10
12
|
import { ArrayExt } from '@lumino/algorithm';
|
|
11
|
-
import { ReadonlyPartialJSONValue } from '@lumino/coreutils';
|
|
12
|
-
import {
|
|
13
|
+
import type { ReadonlyPartialJSONValue } from '@lumino/coreutils';
|
|
14
|
+
import type { Message } from '@lumino/messaging';
|
|
15
|
+
import { ConflatableMessage, MessageLoop } from '@lumino/messaging';
|
|
13
16
|
import { PanelLayout, Widget } from '@lumino/widgets';
|
|
14
|
-
import { INotebookModel } from './model';
|
|
15
|
-
import { NotebookPanel } from './panel';
|
|
16
|
-
import { INotebookTools, INotebookTracker } from './tokens';
|
|
17
|
+
import type { INotebookModel } from './model';
|
|
18
|
+
import type { NotebookPanel } from './panel';
|
|
19
|
+
import type { INotebookTools, INotebookTracker } from './tokens';
|
|
17
20
|
|
|
18
21
|
class RankedPanel<T extends Widget = Widget> extends Widget {
|
|
19
22
|
constructor() {
|