@jupyterlab/notebook 4.1.0-alpha.3 → 4.1.0-beta.0
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 +16 -2
- package/lib/actions.js +86 -50
- package/lib/actions.js.map +1 -1
- package/lib/notebookfooter.js +2 -5
- package/lib/notebookfooter.js.map +1 -1
- package/lib/searchprovider.d.ts +1 -0
- package/lib/searchprovider.js +7 -2
- package/lib/searchprovider.js.map +1 -1
- package/lib/toc.d.ts +7 -0
- package/lib/toc.js +28 -7
- package/lib/toc.js.map +1 -1
- package/lib/widget.d.ts +14 -0
- package/lib/widget.js +145 -43
- package/lib/widget.js.map +1 -1
- package/lib/windowing.js +2 -2
- package/lib/windowing.js.map +1 -1
- package/package.json +21 -21
- package/src/actions.tsx +96 -56
- package/src/notebookfooter.ts +2 -6
- package/src/searchprovider.ts +7 -2
- package/src/toc.ts +36 -10
- package/src/widget.ts +163 -44
- package/src/windowing.ts +2 -2
- package/style/base.css +29 -3
- package/style/executionindicator.css +1 -1
- package/style/toolbar.css +2 -19
package/lib/actions.d.ts
CHANGED
|
@@ -649,10 +649,24 @@ export declare namespace NotebookActions {
|
|
|
649
649
|
*/
|
|
650
650
|
function trust(notebook: Notebook, translator?: ITranslator): Promise<void>;
|
|
651
651
|
/**
|
|
652
|
-
*
|
|
652
|
+
* If the notebook has an active cell, focus it.
|
|
653
653
|
*
|
|
654
|
-
* @param notebook
|
|
654
|
+
* @param notebook The target notebook widget
|
|
655
|
+
* @param options Optional options to change the behavior of this function
|
|
656
|
+
* @param options.waitUntilReady If true, do not call focus until activeCell.ready is resolved
|
|
657
|
+
* @param options.preventScroll If true, do not scroll the active cell into view
|
|
658
|
+
*
|
|
659
|
+
* @returns a promise that resolves when focus has been called on the active
|
|
660
|
+
* cell's node.
|
|
661
|
+
*
|
|
662
|
+
* #### Notes
|
|
663
|
+
* By default, waits until after the active cell has been attached unless
|
|
664
|
+
* called with { waitUntilReady: false }
|
|
655
665
|
*/
|
|
666
|
+
function focusActiveCell(notebook: Notebook, options?: {
|
|
667
|
+
waitUntilReady?: boolean;
|
|
668
|
+
preventScroll?: boolean;
|
|
669
|
+
}): Promise<void>;
|
|
656
670
|
function accessPreviousHistory(notebook: Notebook): Promise<void>;
|
|
657
671
|
/**
|
|
658
672
|
* Access next notebook history.
|
package/lib/actions.js
CHANGED
|
@@ -165,7 +165,7 @@ export class NotebookActions {
|
|
|
165
165
|
.catch(reason => {
|
|
166
166
|
// no-op
|
|
167
167
|
});
|
|
168
|
-
Private.handleState(notebook, state);
|
|
168
|
+
void Private.handleState(notebook, state);
|
|
169
169
|
}
|
|
170
170
|
NotebookActions.splitCell = splitCell;
|
|
171
171
|
/**
|
|
@@ -268,7 +268,7 @@ export class NotebookActions {
|
|
|
268
268
|
if (primary instanceof MarkdownCell) {
|
|
269
269
|
notebook.activeCell.rendered = false;
|
|
270
270
|
}
|
|
271
|
-
Private.handleState(notebook, state);
|
|
271
|
+
void Private.handleState(notebook, state);
|
|
272
272
|
}
|
|
273
273
|
NotebookActions.mergeCells = mergeCells;
|
|
274
274
|
/**
|
|
@@ -287,7 +287,7 @@ export class NotebookActions {
|
|
|
287
287
|
}
|
|
288
288
|
const state = Private.getState(notebook);
|
|
289
289
|
Private.deleteCells(notebook);
|
|
290
|
-
Private.handleState(notebook, state, true);
|
|
290
|
+
void Private.handleState(notebook, state, true);
|
|
291
291
|
}
|
|
292
292
|
NotebookActions.deleteCells = deleteCells;
|
|
293
293
|
/**
|
|
@@ -320,7 +320,7 @@ export class NotebookActions {
|
|
|
320
320
|
// Make the newly inserted cell active.
|
|
321
321
|
notebook.activeCellIndex = newIndex;
|
|
322
322
|
notebook.deselectAll();
|
|
323
|
-
Private.handleState(notebook, state, true);
|
|
323
|
+
void Private.handleState(notebook, state, true);
|
|
324
324
|
}
|
|
325
325
|
NotebookActions.insertAbove = insertAbove;
|
|
326
326
|
/**
|
|
@@ -353,7 +353,7 @@ export class NotebookActions {
|
|
|
353
353
|
// Make the newly inserted cell active.
|
|
354
354
|
notebook.activeCellIndex = newIndex;
|
|
355
355
|
notebook.deselectAll();
|
|
356
|
-
Private.handleState(notebook, state, true);
|
|
356
|
+
void Private.handleState(notebook, state, true);
|
|
357
357
|
}
|
|
358
358
|
NotebookActions.insertBelow = insertBelow;
|
|
359
359
|
function move(notebook, shift) {
|
|
@@ -377,7 +377,7 @@ export class NotebookActions {
|
|
|
377
377
|
else {
|
|
378
378
|
notebook.moveCell(firstIndex, firstIndex + shift, lastIndex - firstIndex);
|
|
379
379
|
}
|
|
380
|
-
Private.handleState(notebook, state, true);
|
|
380
|
+
void Private.handleState(notebook, state, true);
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
383
|
* Move the selected cell(s) down.
|
|
@@ -416,7 +416,7 @@ export class NotebookActions {
|
|
|
416
416
|
}
|
|
417
417
|
const state = Private.getState(notebook);
|
|
418
418
|
Private.changeCellType(notebook, value);
|
|
419
|
-
Private.handleState(notebook, state);
|
|
419
|
+
void Private.handleState(notebook, state);
|
|
420
420
|
}
|
|
421
421
|
NotebookActions.changeCellType = changeCellType;
|
|
422
422
|
/**
|
|
@@ -439,7 +439,7 @@ export class NotebookActions {
|
|
|
439
439
|
}
|
|
440
440
|
const state = Private.getState(notebook);
|
|
441
441
|
const promise = Private.runSelected(notebook, sessionContext, sessionDialogs, translator);
|
|
442
|
-
Private.handleRunState(notebook, state, false);
|
|
442
|
+
void Private.handleRunState(notebook, state, false);
|
|
443
443
|
return promise;
|
|
444
444
|
}
|
|
445
445
|
NotebookActions.run = run;
|
|
@@ -464,7 +464,7 @@ export class NotebookActions {
|
|
|
464
464
|
}
|
|
465
465
|
const state = Private.getState(notebook);
|
|
466
466
|
const promise = Private.runCells(notebook, cells, sessionContext, sessionDialogs, translator);
|
|
467
|
-
Private.handleRunState(notebook, state, false);
|
|
467
|
+
void Private.handleRunState(notebook, state, false);
|
|
468
468
|
return promise;
|
|
469
469
|
}
|
|
470
470
|
NotebookActions.runCells = runCells;
|
|
@@ -515,7 +515,7 @@ export class NotebookActions {
|
|
|
515
515
|
else {
|
|
516
516
|
notebook.activeCellIndex++;
|
|
517
517
|
}
|
|
518
|
-
Private.handleRunState(notebook, state, true);
|
|
518
|
+
void Private.handleRunState(notebook, state, true);
|
|
519
519
|
return promise;
|
|
520
520
|
}
|
|
521
521
|
NotebookActions.runAndAdvance = runAndAdvance;
|
|
@@ -559,7 +559,7 @@ export class NotebookActions {
|
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
561
|
notebook.mode = 'edit';
|
|
562
|
-
Private.handleRunState(notebook, state, true);
|
|
562
|
+
void Private.handleRunState(notebook, state, true);
|
|
563
563
|
return promise;
|
|
564
564
|
}
|
|
565
565
|
NotebookActions.runAndInsert = runAndInsert;
|
|
@@ -586,7 +586,7 @@ export class NotebookActions {
|
|
|
586
586
|
const promise = Private.runCells(notebook, notebook.widgets, sessionContext, sessionDialogs, translator);
|
|
587
587
|
notebook.activeCellIndex = lastIndex;
|
|
588
588
|
notebook.deselectAll();
|
|
589
|
-
Private.handleRunState(notebook, state, true);
|
|
589
|
+
void Private.handleRunState(notebook, state, true);
|
|
590
590
|
return promise;
|
|
591
591
|
}
|
|
592
592
|
NotebookActions.runAll = runAll;
|
|
@@ -609,7 +609,7 @@ export class NotebookActions {
|
|
|
609
609
|
}
|
|
610
610
|
const promise = Private.runSelected(notebook);
|
|
611
611
|
notebook.activeCellIndex = previousIndex;
|
|
612
|
-
Private.handleRunState(notebook, state, true);
|
|
612
|
+
void Private.handleRunState(notebook, state, true);
|
|
613
613
|
return promise;
|
|
614
614
|
}
|
|
615
615
|
NotebookActions.renderAllMarkdown = renderAllMarkdown;
|
|
@@ -635,7 +635,7 @@ export class NotebookActions {
|
|
|
635
635
|
const state = Private.getState(notebook);
|
|
636
636
|
const promise = Private.runCells(notebook, notebook.widgets.slice(0, notebook.activeCellIndex), sessionContext, sessionDialogs, translator);
|
|
637
637
|
notebook.deselectAll();
|
|
638
|
-
Private.handleRunState(notebook, state, true);
|
|
638
|
+
void Private.handleRunState(notebook, state, true);
|
|
639
639
|
return promise;
|
|
640
640
|
}
|
|
641
641
|
NotebookActions.runAllAbove = runAllAbove;
|
|
@@ -662,7 +662,7 @@ export class NotebookActions {
|
|
|
662
662
|
const promise = Private.runCells(notebook, notebook.widgets.slice(notebook.activeCellIndex), sessionContext, sessionDialogs, translator);
|
|
663
663
|
notebook.activeCellIndex = lastIndex;
|
|
664
664
|
notebook.deselectAll();
|
|
665
|
-
Private.handleRunState(notebook, state, true);
|
|
665
|
+
void Private.handleRunState(notebook, state, true);
|
|
666
666
|
return promise;
|
|
667
667
|
}
|
|
668
668
|
NotebookActions.runAllBelow = runAllBelow;
|
|
@@ -716,7 +716,7 @@ export class NotebookActions {
|
|
|
716
716
|
const state = Private.getState(notebook);
|
|
717
717
|
notebook.activeCellIndex = possibleNextCellIndex;
|
|
718
718
|
notebook.deselectAll();
|
|
719
|
-
Private.handleState(notebook, state, true);
|
|
719
|
+
void Private.handleState(notebook, state, true);
|
|
720
720
|
}
|
|
721
721
|
NotebookActions.selectAbove = selectAbove;
|
|
722
722
|
/**
|
|
@@ -757,7 +757,7 @@ export class NotebookActions {
|
|
|
757
757
|
const state = Private.getState(notebook);
|
|
758
758
|
notebook.activeCellIndex = possibleNextCellIndex;
|
|
759
759
|
notebook.deselectAll();
|
|
760
|
-
Private.handleState(notebook, state, true);
|
|
760
|
+
void Private.handleState(notebook, state, true);
|
|
761
761
|
}
|
|
762
762
|
NotebookActions.selectBelow = selectBelow;
|
|
763
763
|
/** Insert new heading of same level above active cell.
|
|
@@ -821,7 +821,7 @@ export class NotebookActions {
|
|
|
821
821
|
}
|
|
822
822
|
// clear selection and handle state
|
|
823
823
|
notebook.deselectAll();
|
|
824
|
-
Private.handleState(notebook, state, true);
|
|
824
|
+
void Private.handleState(notebook, state, true);
|
|
825
825
|
}
|
|
826
826
|
NotebookActions.selectHeadingAboveOrCollapseHeading = selectHeadingAboveOrCollapseHeading;
|
|
827
827
|
/**
|
|
@@ -851,7 +851,7 @@ export class NotebookActions {
|
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
notebook.deselectAll();
|
|
854
|
-
Private.handleState(notebook, state, true);
|
|
854
|
+
void Private.handleState(notebook, state, true);
|
|
855
855
|
}
|
|
856
856
|
NotebookActions.selectHeadingBelowOrExpandHeading = selectHeadingBelowOrExpandHeading;
|
|
857
857
|
/**
|
|
@@ -881,7 +881,7 @@ export class NotebookActions {
|
|
|
881
881
|
else {
|
|
882
882
|
notebook.extendContiguousSelectionTo(notebook.activeCellIndex - 1);
|
|
883
883
|
}
|
|
884
|
-
Private.handleState(notebook, state, true);
|
|
884
|
+
void Private.handleState(notebook, state, true);
|
|
885
885
|
}
|
|
886
886
|
NotebookActions.extendSelectionAbove = extendSelectionAbove;
|
|
887
887
|
/**
|
|
@@ -911,7 +911,7 @@ export class NotebookActions {
|
|
|
911
911
|
else {
|
|
912
912
|
notebook.extendContiguousSelectionTo(notebook.activeCellIndex + 1);
|
|
913
913
|
}
|
|
914
|
-
Private.handleState(notebook, state, true);
|
|
914
|
+
void Private.handleState(notebook, state, true);
|
|
915
915
|
}
|
|
916
916
|
NotebookActions.extendSelectionBelow = extendSelectionBelow;
|
|
917
917
|
/**
|
|
@@ -985,6 +985,7 @@ export class NotebookActions {
|
|
|
985
985
|
}
|
|
986
986
|
const values = clipboard.getData(JUPYTER_CELL_MIME);
|
|
987
987
|
addCells(notebook, mode, values, true);
|
|
988
|
+
void focusActiveCell(notebook);
|
|
988
989
|
}
|
|
989
990
|
NotebookActions.paste = paste;
|
|
990
991
|
/**
|
|
@@ -1093,7 +1094,7 @@ export class NotebookActions {
|
|
|
1093
1094
|
if (cellsFromClipboard) {
|
|
1094
1095
|
notebook.lastClipboardInteraction = 'paste';
|
|
1095
1096
|
}
|
|
1096
|
-
Private.handleState(notebook, state, true);
|
|
1097
|
+
void Private.handleState(notebook, state, true);
|
|
1097
1098
|
}
|
|
1098
1099
|
/**
|
|
1099
1100
|
* Undo a cell action.
|
|
@@ -1111,7 +1112,7 @@ export class NotebookActions {
|
|
|
1111
1112
|
notebook.mode = 'command';
|
|
1112
1113
|
notebook.model.sharedModel.undo();
|
|
1113
1114
|
notebook.deselectAll();
|
|
1114
|
-
Private.handleState(notebook, state);
|
|
1115
|
+
void Private.handleState(notebook, state);
|
|
1115
1116
|
}
|
|
1116
1117
|
NotebookActions.undo = undo;
|
|
1117
1118
|
/**
|
|
@@ -1130,7 +1131,7 @@ export class NotebookActions {
|
|
|
1130
1131
|
notebook.mode = 'command';
|
|
1131
1132
|
notebook.model.sharedModel.redo();
|
|
1132
1133
|
notebook.deselectAll();
|
|
1133
|
-
Private.handleState(notebook, state);
|
|
1134
|
+
void Private.handleState(notebook, state);
|
|
1134
1135
|
}
|
|
1135
1136
|
NotebookActions.redo = redo;
|
|
1136
1137
|
/**
|
|
@@ -1157,7 +1158,7 @@ export class NotebookActions {
|
|
|
1157
1158
|
raw: { ...config.raw, lineNumbers }
|
|
1158
1159
|
};
|
|
1159
1160
|
notebook.editorConfig = newConfig;
|
|
1160
|
-
Private.handleState(notebook, state);
|
|
1161
|
+
void Private.handleState(notebook, state);
|
|
1161
1162
|
}
|
|
1162
1163
|
NotebookActions.toggleAllLineNumbers = toggleAllLineNumbers;
|
|
1163
1164
|
/**
|
|
@@ -1184,7 +1185,7 @@ export class NotebookActions {
|
|
|
1184
1185
|
Private.outputCleared.emit({ notebook, cell: child });
|
|
1185
1186
|
}
|
|
1186
1187
|
}
|
|
1187
|
-
Private.handleState(notebook, state, true);
|
|
1188
|
+
void Private.handleState(notebook, state, true);
|
|
1188
1189
|
}
|
|
1189
1190
|
NotebookActions.clearOutputs = clearOutputs;
|
|
1190
1191
|
/**
|
|
@@ -1211,7 +1212,7 @@ export class NotebookActions {
|
|
|
1211
1212
|
Private.outputCleared.emit({ notebook, cell: child });
|
|
1212
1213
|
}
|
|
1213
1214
|
}
|
|
1214
|
-
Private.handleState(notebook, state, true);
|
|
1215
|
+
void Private.handleState(notebook, state, true);
|
|
1215
1216
|
}
|
|
1216
1217
|
NotebookActions.clearAllOutputs = clearAllOutputs;
|
|
1217
1218
|
/**
|
|
@@ -1229,7 +1230,7 @@ export class NotebookActions {
|
|
|
1229
1230
|
cell.inputHidden = true;
|
|
1230
1231
|
}
|
|
1231
1232
|
});
|
|
1232
|
-
Private.handleState(notebook, state);
|
|
1233
|
+
void Private.handleState(notebook, state);
|
|
1233
1234
|
}
|
|
1234
1235
|
NotebookActions.hideCode = hideCode;
|
|
1235
1236
|
/**
|
|
@@ -1247,7 +1248,7 @@ export class NotebookActions {
|
|
|
1247
1248
|
cell.inputHidden = false;
|
|
1248
1249
|
}
|
|
1249
1250
|
});
|
|
1250
|
-
Private.handleState(notebook, state);
|
|
1251
|
+
void Private.handleState(notebook, state);
|
|
1251
1252
|
}
|
|
1252
1253
|
NotebookActions.showCode = showCode;
|
|
1253
1254
|
/**
|
|
@@ -1265,7 +1266,7 @@ export class NotebookActions {
|
|
|
1265
1266
|
cell.inputHidden = true;
|
|
1266
1267
|
}
|
|
1267
1268
|
});
|
|
1268
|
-
Private.handleState(notebook, state);
|
|
1269
|
+
void Private.handleState(notebook, state);
|
|
1269
1270
|
}
|
|
1270
1271
|
NotebookActions.hideAllCode = hideAllCode;
|
|
1271
1272
|
/**
|
|
@@ -1283,7 +1284,7 @@ export class NotebookActions {
|
|
|
1283
1284
|
cell.inputHidden = false;
|
|
1284
1285
|
}
|
|
1285
1286
|
});
|
|
1286
|
-
Private.handleState(notebook, state);
|
|
1287
|
+
void Private.handleState(notebook, state);
|
|
1287
1288
|
}
|
|
1288
1289
|
NotebookActions.showAllCode = showAllCode;
|
|
1289
1290
|
/**
|
|
@@ -1301,7 +1302,7 @@ export class NotebookActions {
|
|
|
1301
1302
|
cell.outputHidden = true;
|
|
1302
1303
|
}
|
|
1303
1304
|
});
|
|
1304
|
-
Private.handleState(notebook, state, true);
|
|
1305
|
+
void Private.handleState(notebook, state, true);
|
|
1305
1306
|
}
|
|
1306
1307
|
NotebookActions.hideOutput = hideOutput;
|
|
1307
1308
|
/**
|
|
@@ -1319,7 +1320,7 @@ export class NotebookActions {
|
|
|
1319
1320
|
cell.outputHidden = false;
|
|
1320
1321
|
}
|
|
1321
1322
|
});
|
|
1322
|
-
Private.handleState(notebook, state);
|
|
1323
|
+
void Private.handleState(notebook, state);
|
|
1323
1324
|
}
|
|
1324
1325
|
NotebookActions.showOutput = showOutput;
|
|
1325
1326
|
/**
|
|
@@ -1337,7 +1338,7 @@ export class NotebookActions {
|
|
|
1337
1338
|
cell.outputHidden = true;
|
|
1338
1339
|
}
|
|
1339
1340
|
});
|
|
1340
|
-
Private.handleState(notebook, state, true);
|
|
1341
|
+
void Private.handleState(notebook, state, true);
|
|
1341
1342
|
}
|
|
1342
1343
|
NotebookActions.hideAllOutputs = hideAllOutputs;
|
|
1343
1344
|
/**
|
|
@@ -1373,7 +1374,7 @@ export class NotebookActions {
|
|
|
1373
1374
|
cell.outputHidden = false;
|
|
1374
1375
|
}
|
|
1375
1376
|
});
|
|
1376
|
-
Private.handleState(notebook, state);
|
|
1377
|
+
void Private.handleState(notebook, state);
|
|
1377
1378
|
}
|
|
1378
1379
|
NotebookActions.showAllOutputs = showAllOutputs;
|
|
1379
1380
|
/**
|
|
@@ -1391,7 +1392,7 @@ export class NotebookActions {
|
|
|
1391
1392
|
cell.outputsScrolled = true;
|
|
1392
1393
|
}
|
|
1393
1394
|
});
|
|
1394
|
-
Private.handleState(notebook, state, true);
|
|
1395
|
+
void Private.handleState(notebook, state, true);
|
|
1395
1396
|
}
|
|
1396
1397
|
NotebookActions.enableOutputScrolling = enableOutputScrolling;
|
|
1397
1398
|
/**
|
|
@@ -1409,7 +1410,7 @@ export class NotebookActions {
|
|
|
1409
1410
|
cell.outputsScrolled = false;
|
|
1410
1411
|
}
|
|
1411
1412
|
});
|
|
1412
|
-
Private.handleState(notebook, state);
|
|
1413
|
+
void Private.handleState(notebook, state);
|
|
1413
1414
|
}
|
|
1414
1415
|
NotebookActions.disableOutputScrolling = disableOutputScrolling;
|
|
1415
1416
|
/**
|
|
@@ -1474,7 +1475,7 @@ export class NotebookActions {
|
|
|
1474
1475
|
}
|
|
1475
1476
|
});
|
|
1476
1477
|
Private.changeCellType(notebook, 'markdown');
|
|
1477
|
-
Private.handleState(notebook, state);
|
|
1478
|
+
void Private.handleState(notebook, state);
|
|
1478
1479
|
}
|
|
1479
1480
|
NotebookActions.setMarkdownHeader = setMarkdownHeader;
|
|
1480
1481
|
/**
|
|
@@ -1483,12 +1484,15 @@ export class NotebookActions {
|
|
|
1483
1484
|
* @param notebook - The target notebook widget.
|
|
1484
1485
|
*/
|
|
1485
1486
|
function collapseAllHeadings(notebook) {
|
|
1487
|
+
const state = Private.getState(notebook);
|
|
1486
1488
|
for (const cell of notebook.widgets) {
|
|
1487
1489
|
if (NotebookActions.getHeadingInfo(cell).isHeading) {
|
|
1488
1490
|
NotebookActions.setHeadingCollapse(cell, true, notebook);
|
|
1489
1491
|
NotebookActions.setCellCollapse(cell, true);
|
|
1490
1492
|
}
|
|
1491
1493
|
}
|
|
1494
|
+
notebook.activeCellIndex = 0;
|
|
1495
|
+
void Private.handleState(notebook, state, true);
|
|
1492
1496
|
}
|
|
1493
1497
|
NotebookActions.collapseAllHeadings = collapseAllHeadings;
|
|
1494
1498
|
/**
|
|
@@ -1756,6 +1760,38 @@ export class NotebookActions {
|
|
|
1756
1760
|
}
|
|
1757
1761
|
NotebookActions.trust = trust;
|
|
1758
1762
|
/**
|
|
1763
|
+
* If the notebook has an active cell, focus it.
|
|
1764
|
+
*
|
|
1765
|
+
* @param notebook The target notebook widget
|
|
1766
|
+
* @param options Optional options to change the behavior of this function
|
|
1767
|
+
* @param options.waitUntilReady If true, do not call focus until activeCell.ready is resolved
|
|
1768
|
+
* @param options.preventScroll If true, do not scroll the active cell into view
|
|
1769
|
+
*
|
|
1770
|
+
* @returns a promise that resolves when focus has been called on the active
|
|
1771
|
+
* cell's node.
|
|
1772
|
+
*
|
|
1773
|
+
* #### Notes
|
|
1774
|
+
* By default, waits until after the active cell has been attached unless
|
|
1775
|
+
* called with { waitUntilReady: false }
|
|
1776
|
+
*/
|
|
1777
|
+
async function focusActiveCell(notebook, options = { waitUntilReady: true, preventScroll: false }) {
|
|
1778
|
+
const { activeCell } = notebook;
|
|
1779
|
+
const { waitUntilReady, preventScroll } = options;
|
|
1780
|
+
if (!activeCell) {
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
if (waitUntilReady) {
|
|
1784
|
+
await activeCell.ready;
|
|
1785
|
+
}
|
|
1786
|
+
if (notebook.isDisposed || activeCell.isDisposed) {
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
activeCell.node.focus({
|
|
1790
|
+
preventScroll
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
NotebookActions.focusActiveCell = focusActiveCell;
|
|
1794
|
+
/*
|
|
1759
1795
|
* Access last notebook history.
|
|
1760
1796
|
*
|
|
1761
1797
|
* @param notebook - The target notebook widget.
|
|
@@ -1827,31 +1863,31 @@ var Private;
|
|
|
1827
1863
|
/**
|
|
1828
1864
|
* Handle the state of a widget after running an action.
|
|
1829
1865
|
*/
|
|
1830
|
-
function handleState(notebook, state, scrollIfNeeded = false) {
|
|
1866
|
+
async function handleState(notebook, state, scrollIfNeeded = false) {
|
|
1831
1867
|
const { activeCell, activeCellIndex } = notebook;
|
|
1832
|
-
if (state.wasFocused || notebook.mode === 'edit') {
|
|
1833
|
-
notebook.activate();
|
|
1834
|
-
}
|
|
1835
1868
|
if (scrollIfNeeded && activeCell) {
|
|
1836
|
-
notebook.scrollToItem(activeCellIndex, 'auto', 0).catch(reason => {
|
|
1869
|
+
await notebook.scrollToItem(activeCellIndex, 'auto', 0).catch(reason => {
|
|
1837
1870
|
// no-op
|
|
1838
1871
|
});
|
|
1839
1872
|
}
|
|
1873
|
+
if (state.wasFocused || notebook.mode === 'edit') {
|
|
1874
|
+
notebook.activate();
|
|
1875
|
+
}
|
|
1840
1876
|
}
|
|
1841
1877
|
Private.handleState = handleState;
|
|
1842
1878
|
/**
|
|
1843
1879
|
* Handle the state of a widget after running a run action.
|
|
1844
1880
|
*/
|
|
1845
|
-
function handleRunState(notebook, state, scroll = false) {
|
|
1846
|
-
if (state.wasFocused || notebook.mode === 'edit') {
|
|
1847
|
-
notebook.activate();
|
|
1848
|
-
}
|
|
1881
|
+
async function handleRunState(notebook, state, scroll = false) {
|
|
1849
1882
|
const { activeCell, activeCellIndex } = notebook;
|
|
1850
1883
|
if (scroll && activeCell) {
|
|
1851
|
-
notebook.scrollToItem(activeCellIndex, 'smart', 0).catch(reason => {
|
|
1884
|
+
await notebook.scrollToItem(activeCellIndex, 'smart', 0).catch(reason => {
|
|
1852
1885
|
// no-op
|
|
1853
1886
|
});
|
|
1854
1887
|
}
|
|
1888
|
+
if (state.wasFocused || notebook.mode === 'edit') {
|
|
1889
|
+
notebook.activate();
|
|
1890
|
+
}
|
|
1855
1891
|
}
|
|
1856
1892
|
Private.handleRunState = handleRunState;
|
|
1857
1893
|
/**
|
|
@@ -2120,7 +2156,7 @@ var Private;
|
|
|
2120
2156
|
else {
|
|
2121
2157
|
notebook.lastClipboardInteraction = 'copy';
|
|
2122
2158
|
}
|
|
2123
|
-
handleState(notebook, state);
|
|
2159
|
+
void handleState(notebook, state);
|
|
2124
2160
|
}
|
|
2125
2161
|
Private.copyOrCut = copyOrCut;
|
|
2126
2162
|
/**
|
|
@@ -2402,7 +2438,7 @@ var Private;
|
|
|
2402
2438
|
});
|
|
2403
2439
|
}
|
|
2404
2440
|
notebook.deselectAll();
|
|
2405
|
-
Private.handleState(notebook, state, true);
|
|
2441
|
+
void Private.handleState(notebook, state, true);
|
|
2406
2442
|
notebook.mode = 'edit';
|
|
2407
2443
|
notebook.widgets[cellIndex].setHidden(false);
|
|
2408
2444
|
}
|