@jupyterlab/notebook-extension 4.0.0-alpha.20 → 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.
- package/lib/index.js +268 -96
- package/lib/index.js.map +1 -1
- package/lib/tool-widgets/activeCellToolWidget.d.ts +35 -0
- package/lib/tool-widgets/activeCellToolWidget.js +78 -0
- package/lib/tool-widgets/activeCellToolWidget.js.map +1 -0
- package/lib/tool-widgets/metadataEditorFields.d.ts +56 -0
- package/lib/tool-widgets/metadataEditorFields.js +76 -0
- package/lib/tool-widgets/metadataEditorFields.js.map +1 -0
- package/package.json +44 -39
- package/schema/tools.json +143 -0
- package/schema/tracker.json +3 -3
- package/src/index.ts +390 -118
- package/src/tool-widgets/activeCellToolWidget.tsx +119 -0
- package/src/tool-widgets/metadataEditorFields.tsx +128 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
|
18
18
|
import { ILauncher } from '@jupyterlab/launcher';
|
|
19
19
|
import { ILSPCodeExtractorsManager, ILSPDocumentConnectionManager, ILSPFeatureManager } from '@jupyterlab/lsp';
|
|
20
20
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
21
|
+
import { IMetadataFormProvider } from '@jupyterlab/metadataform';
|
|
21
22
|
import { CommandEditStatus, ExecutionIndicator, INotebookTools, INotebookTracker, INotebookWidgetFactory, NotebookActions, NotebookAdapter, NotebookModelFactory, NotebookPanel, NotebookSearchProvider, NotebookToCFactory, NotebookTools, NotebookTracker, NotebookTrustStatus, NotebookWidgetFactory, StaticNotebook, ToolbarItems } from '@jupyterlab/notebook';
|
|
22
23
|
import { IPropertyInspectorProvider } from '@jupyterlab/property-inspector';
|
|
23
24
|
import { IMarkdownParser, IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
@@ -33,6 +34,8 @@ import { DisposableSet } from '@lumino/disposable';
|
|
|
33
34
|
import { MessageLoop } from '@lumino/messaging';
|
|
34
35
|
import { Panel } from '@lumino/widgets';
|
|
35
36
|
import { logNotebookOutput } from './nboutput';
|
|
37
|
+
import { ActiveCellTool } from './tool-widgets/activeCellToolWidget';
|
|
38
|
+
import { CellMetadataField, NotebookMetadataField } from './tool-widgets/metadataEditorFields';
|
|
36
39
|
/**
|
|
37
40
|
* The command IDs used by the notebook plugin.
|
|
38
41
|
*/
|
|
@@ -584,6 +587,112 @@ const languageServerPlugin = {
|
|
|
584
587
|
activate: activateNotebookLanguageServer,
|
|
585
588
|
autoStart: true
|
|
586
589
|
};
|
|
590
|
+
const updateRawMimetype = {
|
|
591
|
+
id: '@jupyterlab/notebook-extension:update-raw-mimetype',
|
|
592
|
+
autoStart: true,
|
|
593
|
+
requires: [INotebookTracker, IMetadataFormProvider, ITranslator],
|
|
594
|
+
activate: (app, tracker, metadataForms, translator) => {
|
|
595
|
+
const trans = translator.load('jupyterlab');
|
|
596
|
+
let formatsInitialized = false;
|
|
597
|
+
async function maybeInitializeFormats() {
|
|
598
|
+
if (formatsInitialized) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (!metadataForms.get('commonToolsSection')) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
const properties = metadataForms
|
|
605
|
+
.get('commonToolsSection')
|
|
606
|
+
.getProperties('/raw_mimetype');
|
|
607
|
+
if (!properties) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
tracker.widgetAdded.disconnect(maybeInitializeFormats);
|
|
611
|
+
formatsInitialized = true;
|
|
612
|
+
const services = app.serviceManager;
|
|
613
|
+
const response = await services.nbconvert.getExportFormats(false);
|
|
614
|
+
if (!response) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
// convert exportList to palette and menu items
|
|
618
|
+
const formatList = Object.keys(response);
|
|
619
|
+
const formatLabels = Private.getFormatLabels(translator);
|
|
620
|
+
formatList.forEach(function (key) {
|
|
621
|
+
var _a;
|
|
622
|
+
const mimetypeExists = ((_a = properties.oneOf) === null || _a === void 0 ? void 0 : _a.filter(value => value.const === key).length) > 0;
|
|
623
|
+
if (!mimetypeExists) {
|
|
624
|
+
const altOption = trans.__(key[0].toUpperCase() + key.substr(1));
|
|
625
|
+
const option = formatLabels[key] ? formatLabels[key] : altOption;
|
|
626
|
+
const mimeTypeValue = response[key].output_mimetype;
|
|
627
|
+
properties.oneOf.push({
|
|
628
|
+
const: mimeTypeValue,
|
|
629
|
+
title: option
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
metadataForms
|
|
634
|
+
.get('commonToolsSection')
|
|
635
|
+
.setProperties('/raw_mimetype', properties);
|
|
636
|
+
}
|
|
637
|
+
tracker.widgetAdded.connect(maybeInitializeFormats);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* Registering metadata editor fields.
|
|
642
|
+
*/
|
|
643
|
+
const customMetadataEditorFields = {
|
|
644
|
+
id: '@jupyterlab/notebook-extension:metadata-editor',
|
|
645
|
+
autoStart: true,
|
|
646
|
+
requires: [INotebookTracker, IEditorServices, IFormRendererRegistry],
|
|
647
|
+
optional: [ITranslator],
|
|
648
|
+
activate: (app, tracker, editorServices, formRegistry, translator) => {
|
|
649
|
+
const editorFactory = options => editorServices.factoryService.newInlineEditor(options);
|
|
650
|
+
// Register the custom fields.
|
|
651
|
+
const cellComponent = {
|
|
652
|
+
fieldRenderer: (props) => {
|
|
653
|
+
return new CellMetadataField({
|
|
654
|
+
editorFactory,
|
|
655
|
+
tracker,
|
|
656
|
+
label: 'Cell metadata',
|
|
657
|
+
translator: translator
|
|
658
|
+
}).render(props);
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
formRegistry.addRenderer('notebook-extension:metadata-editor.cell-metadata', cellComponent);
|
|
662
|
+
const notebookComponent = {
|
|
663
|
+
fieldRenderer: (props) => {
|
|
664
|
+
return new NotebookMetadataField({
|
|
665
|
+
editorFactory,
|
|
666
|
+
tracker,
|
|
667
|
+
label: 'Notebook metadata',
|
|
668
|
+
translator: translator
|
|
669
|
+
}).render(props);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
formRegistry.addRenderer('notebook-extension:metadata-editor.notebook-metadata', notebookComponent);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
/**
|
|
676
|
+
* Registering active cell field.
|
|
677
|
+
*/
|
|
678
|
+
const activeCellTool = {
|
|
679
|
+
id: '@jupyterlab/notebook-extension:active-cell-tool',
|
|
680
|
+
autoStart: true,
|
|
681
|
+
requires: [INotebookTracker, IFormRendererRegistry, IEditorLanguageRegistry],
|
|
682
|
+
activate: (
|
|
683
|
+
// Register the custom field.
|
|
684
|
+
app, tracker, formRegistry, languages) => {
|
|
685
|
+
const component = {
|
|
686
|
+
fieldRenderer: (props) => {
|
|
687
|
+
return new ActiveCellTool({
|
|
688
|
+
tracker,
|
|
689
|
+
languages
|
|
690
|
+
}).render(props);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
formRegistry.addRenderer('notebook-extension:active-cell-tool.renderer', component);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
587
696
|
/**
|
|
588
697
|
* Export the plugins as default.
|
|
589
698
|
*/
|
|
@@ -605,7 +714,10 @@ const plugins = [
|
|
|
605
714
|
completerPlugin,
|
|
606
715
|
searchProvider,
|
|
607
716
|
tocPlugin,
|
|
608
|
-
languageServerPlugin
|
|
717
|
+
languageServerPlugin,
|
|
718
|
+
updateRawMimetype,
|
|
719
|
+
customMetadataEditorFields,
|
|
720
|
+
activeCellTool
|
|
609
721
|
];
|
|
610
722
|
export default plugins;
|
|
611
723
|
/**
|
|
@@ -615,21 +727,6 @@ function activateNotebookTools(app, tracker, editorServices, languages, state, t
|
|
|
615
727
|
const trans = translator.load('jupyterlab');
|
|
616
728
|
const id = 'notebook-tools';
|
|
617
729
|
const notebookTools = new NotebookTools({ tracker, translator });
|
|
618
|
-
const activeCellTool = new NotebookTools.ActiveCellTool(languages);
|
|
619
|
-
const editable = NotebookTools.createEditableToggle(translator);
|
|
620
|
-
const slideShow = NotebookTools.createSlideShowSelector(translator);
|
|
621
|
-
const tocBaseNumbering = NotebookTools.createToCBaseNumbering(translator);
|
|
622
|
-
const editorFactory = options => editorServices.factoryService.newInlineEditor(options);
|
|
623
|
-
const cellMetadataEditor = new NotebookTools.CellMetadataEditorTool({
|
|
624
|
-
editorFactory,
|
|
625
|
-
collapsed: false,
|
|
626
|
-
translator
|
|
627
|
-
});
|
|
628
|
-
const notebookMetadataEditor = new NotebookTools.NotebookMetadataEditorTool({
|
|
629
|
-
editorFactory,
|
|
630
|
-
translator
|
|
631
|
-
});
|
|
632
|
-
const services = app.serviceManager;
|
|
633
730
|
// Create message hook for triggers to save to the database.
|
|
634
731
|
const hook = (sender, message) => {
|
|
635
732
|
switch (message.type) {
|
|
@@ -645,63 +742,9 @@ function activateNotebookTools(app, tracker, editorServices, languages, state, t
|
|
|
645
742
|
}
|
|
646
743
|
return true;
|
|
647
744
|
};
|
|
648
|
-
const optionsMap = {};
|
|
649
|
-
optionsMap.None = null;
|
|
650
|
-
let formatsInitialized = false;
|
|
651
|
-
async function maybeInitializeFormats() {
|
|
652
|
-
if (formatsInitialized) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
tracker.widgetAdded.disconnect(maybeInitializeFormats);
|
|
656
|
-
formatsInitialized = true;
|
|
657
|
-
const response = await services.nbconvert.getExportFormats(false);
|
|
658
|
-
if (!response) {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* The excluded Cell Inspector Raw NbConvert Formats
|
|
663
|
-
* (returned from nbconvert's export list)
|
|
664
|
-
*/
|
|
665
|
-
const rawFormatExclude = ['pdf', 'slides', 'script', 'notebook', 'custom'];
|
|
666
|
-
let optionValueArray = [
|
|
667
|
-
[trans.__('PDF'), 'pdf'],
|
|
668
|
-
[trans.__('Slides'), 'slides'],
|
|
669
|
-
[trans.__('Script'), 'script'],
|
|
670
|
-
[trans.__('Notebook'), 'notebook'],
|
|
671
|
-
[trans.__('Custom'), 'custom']
|
|
672
|
-
];
|
|
673
|
-
// convert exportList to palette and menu items
|
|
674
|
-
const formatList = Object.keys(response);
|
|
675
|
-
const formatLabels = Private.getFormatLabels(translator);
|
|
676
|
-
formatList.forEach(function (key) {
|
|
677
|
-
if (rawFormatExclude.indexOf(key) === -1) {
|
|
678
|
-
const altOption = trans.__(key[0].toUpperCase() + key.substr(1));
|
|
679
|
-
const option = formatLabels[key] ? formatLabels[key] : altOption;
|
|
680
|
-
const mimeTypeValue = response[key].output_mimetype;
|
|
681
|
-
optionValueArray.push([option, mimeTypeValue]);
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
const nbConvert = NotebookTools.createNBConvertSelector(optionValueArray, translator);
|
|
685
|
-
notebookTools.addItem({ tool: nbConvert, section: 'common', rank: 3 });
|
|
686
|
-
}
|
|
687
|
-
tracker.widgetAdded.connect(maybeInitializeFormats);
|
|
688
745
|
notebookTools.title.icon = buildIcon;
|
|
689
746
|
notebookTools.title.caption = trans.__('Notebook Tools');
|
|
690
747
|
notebookTools.id = id;
|
|
691
|
-
notebookTools.addItem({ tool: activeCellTool, section: 'common', rank: 1 });
|
|
692
|
-
notebookTools.addItem({ tool: editable, section: 'common', rank: 2 });
|
|
693
|
-
notebookTools.addItem({ tool: slideShow, section: 'common', rank: 3 });
|
|
694
|
-
notebookTools.addItem({ tool: tocBaseNumbering, section: 'common', rank: 4 });
|
|
695
|
-
notebookTools.addItem({
|
|
696
|
-
tool: cellMetadataEditor,
|
|
697
|
-
section: 'advanced',
|
|
698
|
-
rank: 1
|
|
699
|
-
});
|
|
700
|
-
notebookTools.addItem({
|
|
701
|
-
tool: notebookMetadataEditor,
|
|
702
|
-
section: 'advanced',
|
|
703
|
-
rank: 2
|
|
704
|
-
});
|
|
705
748
|
MessageLoop.installMessageHook(notebookTools, hook);
|
|
706
749
|
if (inspectorProvider) {
|
|
707
750
|
tracker.widgetAdded.connect((sender, panel) => {
|
|
@@ -1183,7 +1226,8 @@ function activateNotebookHandler(app, factory, extensions, palette, defaultBrows
|
|
|
1183
1226
|
overscanCount: settings.get('overscanCount').composite,
|
|
1184
1227
|
maxNumberOutputs: settings.get('maxNumberOutputs').composite,
|
|
1185
1228
|
showEditorForReadOnlyMarkdown: settings.get('showEditorForReadOnlyMarkdown').composite,
|
|
1186
|
-
disableDocumentWideUndoRedo: settings.get('
|
|
1229
|
+
disableDocumentWideUndoRedo: !settings.get('documentWideUndoRedo')
|
|
1230
|
+
.composite,
|
|
1187
1231
|
renderingLayout: settings.get('renderingLayout').composite,
|
|
1188
1232
|
sideBySideLeftMarginOverride: settings.get('sideBySideLeftMarginOverride')
|
|
1189
1233
|
.composite,
|
|
@@ -1205,7 +1249,7 @@ function activateNotebookHandler(app, factory, extensions, palette, defaultBrows
|
|
|
1205
1249
|
}
|
|
1206
1250
|
factory.shutdownOnClose = settings.get('kernelShutdown')
|
|
1207
1251
|
.composite;
|
|
1208
|
-
modelFactory.disableDocumentWideUndoRedo = settings.get('
|
|
1252
|
+
modelFactory.disableDocumentWideUndoRedo = !settings.get('documentWideUndoRedo').composite;
|
|
1209
1253
|
updateTracker({
|
|
1210
1254
|
editorConfig: factory.editorConfig,
|
|
1211
1255
|
notebookConfig: factory.notebookConfig,
|
|
@@ -1427,9 +1471,36 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1427
1471
|
NotebookActions.expandParent(cell, notebook);
|
|
1428
1472
|
});
|
|
1429
1473
|
});
|
|
1474
|
+
tracker.selectionChanged.connect(() => {
|
|
1475
|
+
commands.notifyCommandChanged(CommandIDs.duplicateBelow);
|
|
1476
|
+
commands.notifyCommandChanged(CommandIDs.deleteCell);
|
|
1477
|
+
commands.notifyCommandChanged(CommandIDs.copy);
|
|
1478
|
+
commands.notifyCommandChanged(CommandIDs.cut);
|
|
1479
|
+
commands.notifyCommandChanged(CommandIDs.pasteBelow);
|
|
1480
|
+
commands.notifyCommandChanged(CommandIDs.pasteAbove);
|
|
1481
|
+
commands.notifyCommandChanged(CommandIDs.pasteAndReplace);
|
|
1482
|
+
commands.notifyCommandChanged(CommandIDs.moveUp);
|
|
1483
|
+
commands.notifyCommandChanged(CommandIDs.moveDown);
|
|
1484
|
+
commands.notifyCommandChanged(CommandIDs.run);
|
|
1485
|
+
commands.notifyCommandChanged(CommandIDs.runAll);
|
|
1486
|
+
commands.notifyCommandChanged(CommandIDs.runAndAdvance);
|
|
1487
|
+
commands.notifyCommandChanged(CommandIDs.runAndInsert);
|
|
1488
|
+
});
|
|
1489
|
+
tracker.activeCellChanged.connect(() => {
|
|
1490
|
+
commands.notifyCommandChanged(CommandIDs.moveUp);
|
|
1491
|
+
commands.notifyCommandChanged(CommandIDs.moveDown);
|
|
1492
|
+
});
|
|
1430
1493
|
commands.addCommand(CommandIDs.runAndAdvance, {
|
|
1431
|
-
label:
|
|
1432
|
-
|
|
1494
|
+
label: args => {
|
|
1495
|
+
var _a;
|
|
1496
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1497
|
+
return trans._n('Run Selected Cell', 'Run Selected Cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1498
|
+
},
|
|
1499
|
+
caption: args => {
|
|
1500
|
+
var _a;
|
|
1501
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1502
|
+
return trans._n('Run this cell and advance', 'Run these %1 cells and advance', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1503
|
+
},
|
|
1433
1504
|
execute: args => {
|
|
1434
1505
|
const current = getCurrent(tracker, shell, args);
|
|
1435
1506
|
if (current) {
|
|
@@ -1440,8 +1511,11 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1440
1511
|
isEnabled
|
|
1441
1512
|
});
|
|
1442
1513
|
commands.addCommand(CommandIDs.run, {
|
|
1443
|
-
label:
|
|
1444
|
-
|
|
1514
|
+
label: args => {
|
|
1515
|
+
var _a;
|
|
1516
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1517
|
+
return trans._n('Run Selected Cell and Do not Advance', 'Run Selected Cells and Do not Advance', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1518
|
+
},
|
|
1445
1519
|
execute: args => {
|
|
1446
1520
|
const current = getCurrent(tracker, shell, args);
|
|
1447
1521
|
if (current) {
|
|
@@ -1452,7 +1526,11 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1452
1526
|
isEnabled
|
|
1453
1527
|
});
|
|
1454
1528
|
commands.addCommand(CommandIDs.runAndInsert, {
|
|
1455
|
-
label:
|
|
1529
|
+
label: args => {
|
|
1530
|
+
var _a;
|
|
1531
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1532
|
+
return trans._n('Run Selected Cell and Insert Below', 'Run Selected Cells and Insert Below', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1533
|
+
},
|
|
1456
1534
|
execute: args => {
|
|
1457
1535
|
const current = getCurrent(tracker, shell, args);
|
|
1458
1536
|
if (current) {
|
|
@@ -1686,8 +1764,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1686
1764
|
isEnabled
|
|
1687
1765
|
});
|
|
1688
1766
|
commands.addCommand(CommandIDs.cut, {
|
|
1689
|
-
label:
|
|
1690
|
-
|
|
1767
|
+
label: args => {
|
|
1768
|
+
var _a;
|
|
1769
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1770
|
+
return trans._n('Cut Cell', 'Cut Cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1771
|
+
},
|
|
1772
|
+
caption: args => {
|
|
1773
|
+
var _a;
|
|
1774
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1775
|
+
return trans._n('Cut this cell', 'Cut these %1 cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1776
|
+
},
|
|
1691
1777
|
execute: args => {
|
|
1692
1778
|
const current = getCurrent(tracker, shell, args);
|
|
1693
1779
|
if (current) {
|
|
@@ -1698,8 +1784,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1698
1784
|
isEnabled
|
|
1699
1785
|
});
|
|
1700
1786
|
commands.addCommand(CommandIDs.copy, {
|
|
1701
|
-
label:
|
|
1702
|
-
|
|
1787
|
+
label: args => {
|
|
1788
|
+
var _a;
|
|
1789
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1790
|
+
return trans._n('Copy Cell', 'Copy Cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1791
|
+
},
|
|
1792
|
+
caption: args => {
|
|
1793
|
+
var _a;
|
|
1794
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1795
|
+
return trans._n('Copy this cell', 'Copy these %1 cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1796
|
+
},
|
|
1703
1797
|
execute: args => {
|
|
1704
1798
|
const current = getCurrent(tracker, shell, args);
|
|
1705
1799
|
if (current) {
|
|
@@ -1710,8 +1804,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1710
1804
|
isEnabled
|
|
1711
1805
|
});
|
|
1712
1806
|
commands.addCommand(CommandIDs.pasteBelow, {
|
|
1713
|
-
label:
|
|
1714
|
-
|
|
1807
|
+
label: args => {
|
|
1808
|
+
var _a;
|
|
1809
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1810
|
+
return trans._n('Paste Cell Below', 'Paste Cells Below', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1811
|
+
},
|
|
1812
|
+
caption: args => {
|
|
1813
|
+
var _a;
|
|
1814
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1815
|
+
return trans._n('Paste this cell from the clipboard', 'Paste these %1 cells from the clipboard', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1816
|
+
},
|
|
1715
1817
|
execute: args => {
|
|
1716
1818
|
const current = getCurrent(tracker, shell, args);
|
|
1717
1819
|
if (current) {
|
|
@@ -1722,7 +1824,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1722
1824
|
isEnabled
|
|
1723
1825
|
});
|
|
1724
1826
|
commands.addCommand(CommandIDs.pasteAbove, {
|
|
1725
|
-
label:
|
|
1827
|
+
label: args => {
|
|
1828
|
+
var _a;
|
|
1829
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1830
|
+
return trans._n('Paste Cell Above', 'Paste Cells Above', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1831
|
+
},
|
|
1832
|
+
caption: args => {
|
|
1833
|
+
var _a;
|
|
1834
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1835
|
+
return trans._n('Paste this cell from the clipboard', 'Paste these %1 cells from the clipboard', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1836
|
+
},
|
|
1726
1837
|
execute: args => {
|
|
1727
1838
|
const current = getCurrent(tracker, shell, args);
|
|
1728
1839
|
if (current) {
|
|
@@ -1732,8 +1843,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1732
1843
|
isEnabled
|
|
1733
1844
|
});
|
|
1734
1845
|
commands.addCommand(CommandIDs.duplicateBelow, {
|
|
1735
|
-
label:
|
|
1736
|
-
|
|
1846
|
+
label: args => {
|
|
1847
|
+
var _a;
|
|
1848
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1849
|
+
return trans._n('Duplicate Cell Below', 'Duplicate Cells Below', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1850
|
+
},
|
|
1851
|
+
caption: args => {
|
|
1852
|
+
var _a;
|
|
1853
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1854
|
+
return trans._n('Create a duplicate of this cell below', 'Create duplicates of %1 cells below', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1855
|
+
},
|
|
1737
1856
|
execute: args => {
|
|
1738
1857
|
const current = getCurrent(tracker, shell, args);
|
|
1739
1858
|
if (current) {
|
|
@@ -1744,7 +1863,11 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1744
1863
|
isEnabled
|
|
1745
1864
|
});
|
|
1746
1865
|
commands.addCommand(CommandIDs.pasteAndReplace, {
|
|
1747
|
-
label:
|
|
1866
|
+
label: args => {
|
|
1867
|
+
var _a;
|
|
1868
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1869
|
+
return trans._n('Paste Cell and Replace', 'Paste Cells and Replace', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1870
|
+
},
|
|
1748
1871
|
execute: args => {
|
|
1749
1872
|
const current = getCurrent(tracker, shell, args);
|
|
1750
1873
|
if (current) {
|
|
@@ -1754,7 +1877,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1754
1877
|
isEnabled
|
|
1755
1878
|
});
|
|
1756
1879
|
commands.addCommand(CommandIDs.deleteCell, {
|
|
1757
|
-
label:
|
|
1880
|
+
label: args => {
|
|
1881
|
+
var _a;
|
|
1882
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1883
|
+
return trans._n('Delete Cell', 'Delete Cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1884
|
+
},
|
|
1885
|
+
caption: args => {
|
|
1886
|
+
var _a;
|
|
1887
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
1888
|
+
return trans._n('Delete this cell', 'Delete these %1 cells', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
1889
|
+
},
|
|
1758
1890
|
execute: args => {
|
|
1759
1891
|
const current = getCurrent(tracker, shell, args);
|
|
1760
1892
|
if (current) {
|
|
@@ -1805,6 +1937,7 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1805
1937
|
});
|
|
1806
1938
|
commands.addCommand(CommandIDs.insertAbove, {
|
|
1807
1939
|
label: trans.__('Insert Cell Above'),
|
|
1940
|
+
caption: trans.__('Insert a cell above'),
|
|
1808
1941
|
execute: args => {
|
|
1809
1942
|
const current = getCurrent(tracker, shell, args);
|
|
1810
1943
|
if (current) {
|
|
@@ -1947,7 +2080,16 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1947
2080
|
isEnabled
|
|
1948
2081
|
});
|
|
1949
2082
|
commands.addCommand(CommandIDs.moveUp, {
|
|
1950
|
-
label:
|
|
2083
|
+
label: args => {
|
|
2084
|
+
var _a;
|
|
2085
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2086
|
+
return trans._n('Move Cell Up', 'Move Cells Up', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
2087
|
+
},
|
|
2088
|
+
caption: args => {
|
|
2089
|
+
var _a;
|
|
2090
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2091
|
+
return trans._n('Move this cell up', 'Move these %1 cells up', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
2092
|
+
},
|
|
1951
2093
|
execute: args => {
|
|
1952
2094
|
const current = getCurrent(tracker, shell, args);
|
|
1953
2095
|
if (current) {
|
|
@@ -1955,11 +2097,26 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1955
2097
|
Private.raiseSilentNotification(trans.__('Notebook cell shifted up successfully'), current.node);
|
|
1956
2098
|
}
|
|
1957
2099
|
},
|
|
1958
|
-
isEnabled
|
|
2100
|
+
isEnabled: args => {
|
|
2101
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2102
|
+
if (!current) {
|
|
2103
|
+
return false;
|
|
2104
|
+
}
|
|
2105
|
+
return current.content.activeCellIndex >= 1;
|
|
2106
|
+
},
|
|
1959
2107
|
icon: args => (args.toolbar ? moveUpIcon : undefined)
|
|
1960
2108
|
});
|
|
1961
2109
|
commands.addCommand(CommandIDs.moveDown, {
|
|
1962
|
-
label:
|
|
2110
|
+
label: args => {
|
|
2111
|
+
var _a;
|
|
2112
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2113
|
+
return trans._n('Move Cell Down', 'Move Cells Down', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
2114
|
+
},
|
|
2115
|
+
caption: args => {
|
|
2116
|
+
var _a;
|
|
2117
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2118
|
+
return trans._n('Move this cell down', 'Move these %1 cells down', (_a = current === null || current === void 0 ? void 0 : current.content.selectedCells.length) !== null && _a !== void 0 ? _a : 1);
|
|
2119
|
+
},
|
|
1963
2120
|
execute: args => {
|
|
1964
2121
|
const current = getCurrent(tracker, shell, args);
|
|
1965
2122
|
if (current) {
|
|
@@ -1967,7 +2124,14 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
1967
2124
|
Private.raiseSilentNotification(trans.__('Notebook cell shifted down successfully'), current.node);
|
|
1968
2125
|
}
|
|
1969
2126
|
},
|
|
1970
|
-
isEnabled
|
|
2127
|
+
isEnabled: args => {
|
|
2128
|
+
const current = getCurrent(tracker, shell, { ...args, activate: false });
|
|
2129
|
+
if (!current || !current.content.model) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2132
|
+
const length = current.content.model.cells.length;
|
|
2133
|
+
return current.content.activeCellIndex < length - 1;
|
|
2134
|
+
},
|
|
1971
2135
|
icon: args => (args.toolbar ? moveDownIcon : undefined)
|
|
1972
2136
|
});
|
|
1973
2137
|
commands.addCommand(CommandIDs.toggleAllLines, {
|
|
@@ -2035,20 +2199,28 @@ function addCommands(app, tracker, translator, sessionDialogs, isEnabled) {
|
|
|
2035
2199
|
commands.addCommand(CommandIDs.redo, {
|
|
2036
2200
|
label: trans.__('Redo'),
|
|
2037
2201
|
execute: args => {
|
|
2038
|
-
var _a
|
|
2202
|
+
var _a;
|
|
2039
2203
|
const current = getCurrent(tracker, shell, args);
|
|
2040
2204
|
if (current) {
|
|
2041
|
-
|
|
2205
|
+
const cell = current.content.activeCell;
|
|
2206
|
+
if (cell) {
|
|
2207
|
+
cell.inputHidden = false;
|
|
2208
|
+
return (_a = cell.editor) === null || _a === void 0 ? void 0 : _a.redo();
|
|
2209
|
+
}
|
|
2042
2210
|
}
|
|
2043
2211
|
}
|
|
2044
2212
|
});
|
|
2045
2213
|
commands.addCommand(CommandIDs.undo, {
|
|
2046
2214
|
label: trans.__('Undo'),
|
|
2047
2215
|
execute: args => {
|
|
2048
|
-
var _a
|
|
2216
|
+
var _a;
|
|
2049
2217
|
const current = getCurrent(tracker, shell, args);
|
|
2050
2218
|
if (current) {
|
|
2051
|
-
|
|
2219
|
+
const cell = current.content.activeCell;
|
|
2220
|
+
if (cell) {
|
|
2221
|
+
cell.inputHidden = false;
|
|
2222
|
+
return (_a = cell.editor) === null || _a === void 0 ? void 0 : _a.undo();
|
|
2223
|
+
}
|
|
2052
2224
|
}
|
|
2053
2225
|
}
|
|
2054
2226
|
});
|