@datalayer/jupyter-react 0.19.3 → 0.19.5
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/app/tabs/components/NotebookComponent.js +3 -2
- package/lib/app/tabs/components/NotebookComponent.js.map +1 -1
- package/lib/components/cell/CellCommands.d.ts +1 -1
- package/lib/components/cell/CellCommands.js +7 -7
- package/lib/components/cell/CellCommands.js.map +1 -1
- package/lib/components/notebook/BaseNotebook.d.ts +148 -0
- package/lib/components/notebook/BaseNotebook.js +732 -0
- package/lib/components/notebook/BaseNotebook.js.map +1 -0
- package/lib/components/notebook/Notebook.css +13 -0
- package/lib/components/notebook/Notebook.d.ts +14 -16
- package/lib/components/notebook/Notebook.js +143 -65
- package/lib/components/notebook/Notebook.js.map +1 -1
- package/lib/components/notebook/NotebookAdapter.d.ts +7 -9
- package/lib/components/notebook/NotebookAdapter.js +18 -22
- package/lib/components/notebook/NotebookAdapter.js.map +1 -1
- package/lib/components/notebook/NotebookCommands.d.ts +14 -4
- package/lib/components/notebook/NotebookCommands.js +230 -156
- package/lib/components/notebook/NotebookCommands.js.map +1 -1
- package/lib/components/notebook/NotebookState.js +6 -6
- package/lib/components/notebook/NotebookState.js.map +1 -1
- package/lib/components/notebook/SimpleNotebook.d.ts +40 -0
- package/lib/components/notebook/SimpleNotebook.js +73 -0
- package/lib/components/notebook/SimpleNotebook.js.map +1 -0
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.d.ts +14 -6
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js +35 -37
- package/lib/components/notebook/cell/metadata/CellMetadataEditor.js.map +1 -1
- package/lib/components/notebook/cell/metadata/NbGraderCells.d.ts +2 -2
- package/lib/components/notebook/cell/metadata/NbGraderCells.js +2 -2
- package/lib/components/notebook/cell/metadata/NbGraderCells.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebar.d.ts +28 -2
- package/lib/components/notebook/cell/sidebar/CellSidebar.js +64 -78
- package/lib/components/notebook/cell/sidebar/CellSidebar.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.d.ts +3 -2
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.js +57 -72
- package/lib/components/notebook/cell/sidebar/CellSidebarButton.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.d.ts +3 -2
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.js +14 -29
- package/lib/components/notebook/cell/sidebar/CellSidebarRun.js.map +1 -1
- package/lib/components/notebook/cell/sidebar/extension.d.ts +31 -0
- package/lib/components/notebook/cell/sidebar/extension.js +121 -0
- package/lib/components/notebook/cell/sidebar/extension.js.map +1 -0
- package/lib/components/notebook/cell/sidebar/index.d.ts +1 -1
- package/lib/components/notebook/cell/sidebar/index.js +1 -1
- package/lib/components/notebook/cell/sidebar/index.js.map +1 -1
- package/lib/components/notebook/content/JupyterReactContentFactory.d.ts +1 -12
- package/lib/components/notebook/content/JupyterReactContentFactory.js +4 -22
- package/lib/components/notebook/content/JupyterReactContentFactory.js.map +1 -1
- package/lib/components/notebook/index.d.ts +2 -0
- package/lib/components/notebook/index.js +2 -0
- package/lib/components/notebook/index.js.map +1 -1
- package/lib/components/utils/Loader.d.ts +4 -0
- package/lib/components/utils/Loader.js +23 -0
- package/lib/components/utils/Loader.js.map +1 -0
- package/lib/components/utils/SpinnerCentered.d.ts +2 -1
- package/lib/components/utils/SpinnerCentered.js +2 -2
- package/lib/components/utils/SpinnerCentered.js.map +1 -1
- package/lib/components/utils/index.d.ts +1 -0
- package/lib/components/utils/index.js +1 -0
- package/lib/components/utils/index.js.map +1 -1
- package/lib/examples/Bokeh.js +8 -4
- package/lib/examples/Bokeh.js.map +1 -1
- package/lib/examples/Bqplot.js +8 -4
- package/lib/examples/Bqplot.js.map +1 -1
- package/lib/examples/Dashboard.js +8 -9
- package/lib/examples/Dashboard.js.map +1 -1
- package/lib/examples/Deno.js +8 -4
- package/lib/examples/Deno.js.map +1 -1
- package/lib/examples/GeoJson.js +10 -5
- package/lib/examples/GeoJson.js.map +1 -1
- package/lib/examples/IPyLeaflet.js +8 -4
- package/lib/examples/IPyLeaflet.js.map +1 -1
- package/lib/examples/IPyReact.js +8 -4
- package/lib/examples/IPyReact.js.map +1 -1
- package/lib/examples/IPyWidgets.js +8 -9
- package/lib/examples/IPyWidgets.js.map +1 -1
- package/lib/examples/IPyWidgetsState.js +8 -9
- package/lib/examples/IPyWidgetsState.js.map +1 -1
- package/lib/examples/JupyterContext.js +20 -22
- package/lib/examples/JupyterContext.js.map +1 -1
- package/lib/examples/Matplotlib.js +8 -9
- package/lib/examples/Matplotlib.js.map +1 -1
- package/lib/examples/Notebook.js +4 -3
- package/lib/examples/Notebook.js.map +1 -1
- package/lib/examples/NotebookCellSidebar.js +4 -8
- package/lib/examples/NotebookCellSidebar.js.map +1 -1
- package/lib/examples/NotebookCellToolbar.js +11 -12
- package/lib/examples/NotebookCellToolbar.js.map +1 -1
- package/lib/examples/NotebookCollaborative.js +6 -3
- package/lib/examples/NotebookCollaborative.js.map +1 -1
- package/lib/examples/NotebookColormode.js +6 -10
- package/lib/examples/NotebookColormode.js.map +1 -1
- package/lib/examples/NotebookExtension.js +11 -12
- package/lib/examples/NotebookExtension.js.map +1 -1
- package/lib/examples/NotebookExternalContent.js +10 -12
- package/lib/examples/NotebookExternalContent.js.map +1 -1
- package/lib/examples/NotebookInit.js +5 -4
- package/lib/examples/NotebookInit.js.map +1 -1
- package/lib/examples/NotebookKernelChange.js +7 -6
- package/lib/examples/NotebookKernelChange.js.map +1 -1
- package/lib/examples/NotebookLess.js +8 -12
- package/lib/examples/NotebookLess.js.map +1 -1
- package/lib/examples/NotebookLite.js +5 -10
- package/lib/examples/NotebookLite.js.map +1 -1
- package/lib/examples/NotebookLiteContext.js +9 -10
- package/lib/examples/NotebookLiteContext.js.map +1 -1
- package/lib/examples/NotebookLocalServer.js +10 -7
- package/lib/examples/NotebookLocalServer.js.map +1 -1
- package/lib/examples/NotebookNbformat.js +8 -9
- package/lib/examples/NotebookNbformat.js.map +1 -1
- package/lib/examples/NotebookNbformatChange.js +9 -11
- package/lib/examples/NotebookNbformatChange.js.map +1 -1
- package/lib/examples/NotebookNoContext.js +4 -3
- package/lib/examples/NotebookNoContext.js.map +1 -1
- package/lib/examples/NotebookNoPrimer.js +5 -4
- package/lib/examples/NotebookNoPrimer.js.map +1 -1
- package/lib/examples/NotebookOnSessionConnection.js +7 -11
- package/lib/examples/NotebookOnSessionConnection.js.map +1 -1
- package/lib/examples/NotebookPath.js +4 -3
- package/lib/examples/NotebookPath.js.map +1 -1
- package/lib/examples/NotebookPathChange.js +9 -6
- package/lib/examples/NotebookPathChange.js.map +1 -1
- package/lib/examples/NotebookReadonly.js +6 -4
- package/lib/examples/NotebookReadonly.js.map +1 -1
- package/lib/examples/NotebookServiceManager.js +10 -14
- package/lib/examples/NotebookServiceManager.js.map +1 -1
- package/lib/examples/NotebookSkeleton.js +5 -4
- package/lib/examples/NotebookSkeleton.js.map +1 -1
- package/lib/examples/NotebookTheme.js +6 -10
- package/lib/examples/NotebookTheme.js.map +1 -1
- package/lib/examples/NotebookThemeColormode.js +6 -10
- package/lib/examples/NotebookThemeColormode.js.map +1 -1
- package/lib/examples/NotebookURL.js +4 -3
- package/lib/examples/NotebookURL.js.map +1 -1
- package/lib/examples/NotebookUnmount.js +7 -11
- package/lib/examples/NotebookUnmount.js.map +1 -1
- package/lib/examples/ObservableHQ.js +8 -4
- package/lib/examples/ObservableHQ.js.map +1 -1
- package/lib/examples/Panel.js +6 -3
- package/lib/examples/Panel.js.map +1 -1
- package/lib/examples/Plotly.js +8 -4
- package/lib/examples/Plotly.js.map +1 -1
- package/lib/examples/PyGWalker.js +8 -9
- package/lib/examples/PyGWalker.js.map +1 -1
- package/lib/examples/Vega.js +5 -4
- package/lib/examples/Vega.js.map +1 -1
- package/lib/examples/extensions/celltoolbar/CellToolbarExtension.d.ts +1 -1
- package/lib/examples/extensions/celltoolbar/CellToolbarExtension.js +6 -2
- package/lib/examples/extensions/celltoolbar/CellToolbarExtension.js.map +1 -1
- package/lib/examples/extensions/exectime/ExecTimeExtension.d.ts +1 -1
- package/lib/examples/extensions/exectime/ExecTimeExtension.js +1 -1
- package/lib/examples/extensions/exectime/ExecTimeExtension.js.map +1 -1
- package/lib/examples/sidebars/CellSidebarSource.js +56 -73
- package/lib/examples/sidebars/CellSidebarSource.js.map +1 -1
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js +3 -3
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js.map +1 -1
- package/lib/jupyter/collaboration/DatalayerCollaboration.d.ts +7 -2
- package/lib/jupyter/collaboration/DatalayerCollaboration.js +24 -1
- package/lib/jupyter/collaboration/DatalayerCollaboration.js.map +1 -1
- package/lib/jupyter/collaboration/JupyterCollaboration.d.ts +2 -2
- package/lib/jupyter/collaboration/JupyterCollaboration.js +3 -3
- package/lib/jupyter/collaboration/JupyterCollaboration.js.map +1 -1
- package/lib/utils/Utils.d.ts +6 -0
- package/lib/utils/Utils.js +9 -1
- package/lib/utils/Utils.js.map +1 -1
- package/package.json +1 -1
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.d.ts +0 -16
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js +0 -37
- package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
+
import { DisposableSet } from '@lumino/disposable';
|
|
6
7
|
import { SessionContextDialogs } from '@jupyterlab/apputils';
|
|
7
8
|
import { NotebookActions, NotebookSearchProvider, } from '@jupyterlab/notebook';
|
|
8
9
|
import { SearchDocumentModel, SearchDocumentView, } from '@jupyterlab/documentsearch';
|
|
@@ -11,7 +12,7 @@ import { nullTranslator } from '@jupyterlab/translation';
|
|
|
11
12
|
/**
|
|
12
13
|
* The map of command ids used by the notebook.
|
|
13
14
|
*/
|
|
14
|
-
export const
|
|
15
|
+
export const NotebookCommandIds = {
|
|
15
16
|
changeCellType: 'notebook-cell:change-cell-type',
|
|
16
17
|
changeCellTypeToCode: 'notebook-cell:change-cell-to-code',
|
|
17
18
|
changeCellTypeToMarkdown: 'notebook-cell:change-cell-to-markdown',
|
|
@@ -46,87 +47,105 @@ export const cmdIds = {
|
|
|
46
47
|
switchKernel: 'notebook:switch-kernel',
|
|
47
48
|
undo: 'notebook-cells:undo',
|
|
48
49
|
};
|
|
49
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Register notebook commands.
|
|
52
|
+
*
|
|
53
|
+
* @param commands Command registry
|
|
54
|
+
* @param completerHandler Completion handler
|
|
55
|
+
* @param tracker Notebook tracker
|
|
56
|
+
* @param path Notebook path
|
|
57
|
+
* @returns Commands disposer
|
|
58
|
+
*/
|
|
59
|
+
export function addNotebookCommands(commands, completerHandler, tracker, path) {
|
|
60
|
+
const allCommands = new DisposableSet();
|
|
61
|
+
// Add commands.
|
|
50
62
|
if (path) {
|
|
51
|
-
|
|
63
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.save, {
|
|
52
64
|
label: 'Save',
|
|
53
|
-
execute: () =>
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
execute: () => {
|
|
66
|
+
tracker.currentWidget?.context.save();
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
allCommands.add(commands.addKeyBinding({
|
|
56
70
|
selector: '.jp-Notebook',
|
|
57
71
|
keys: ['Accel S'],
|
|
58
|
-
command:
|
|
59
|
-
});
|
|
72
|
+
command: NotebookCommandIds.save,
|
|
73
|
+
}));
|
|
60
74
|
}
|
|
61
|
-
|
|
62
|
-
commandRegistry.addCommand(cmdIds.invoke, {
|
|
75
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.invoke, {
|
|
63
76
|
label: 'Completer: Invoke',
|
|
64
77
|
execute: () => completerHandler.invoke(),
|
|
65
|
-
});
|
|
66
|
-
|
|
78
|
+
}));
|
|
79
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.select, {
|
|
67
80
|
label: 'Completer: Select',
|
|
68
81
|
execute: () => completerHandler.completer.selectActive(),
|
|
69
|
-
});
|
|
70
|
-
|
|
82
|
+
}));
|
|
83
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.invokeNotebook, {
|
|
71
84
|
label: 'Invoke Notebook',
|
|
72
85
|
execute: () => {
|
|
73
|
-
if (
|
|
74
|
-
return
|
|
86
|
+
if (tracker.currentWidget?.content.activeCell?.model.type === 'code') {
|
|
87
|
+
return commands.execute(NotebookCommandIds.invoke);
|
|
75
88
|
}
|
|
76
89
|
},
|
|
77
|
-
});
|
|
78
|
-
|
|
90
|
+
}));
|
|
91
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.selectNotebook, {
|
|
79
92
|
label: 'Select Notebook',
|
|
80
93
|
execute: () => {
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
94
|
+
if (tracker.currentWidget?.content.activeCell?.model.type === 'code') {
|
|
95
|
+
return commands.execute(NotebookCommandIds.select);
|
|
83
96
|
}
|
|
84
97
|
},
|
|
85
|
-
});
|
|
98
|
+
}));
|
|
86
99
|
let searchInstance;
|
|
87
|
-
|
|
100
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.startSearch, {
|
|
88
101
|
label: 'Find…',
|
|
89
102
|
execute: () => {
|
|
90
|
-
if (!
|
|
91
|
-
|
|
103
|
+
if (!tracker.currentWidget) {
|
|
104
|
+
searchInstance = undefined;
|
|
105
|
+
}
|
|
106
|
+
else if (!searchInstance) {
|
|
107
|
+
const provider = new NotebookSearchProvider(tracker.currentWidget, nullTranslator);
|
|
92
108
|
const searchModel = new SearchDocumentModel(provider, 500);
|
|
93
109
|
searchInstance = new SearchDocumentView(searchModel);
|
|
94
110
|
/**
|
|
95
111
|
* Activate the target widget when the search panel is closing
|
|
96
112
|
*/
|
|
97
113
|
searchInstance.closed.connect(() => {
|
|
98
|
-
if (!
|
|
99
|
-
|
|
114
|
+
if (!tracker.currentWidget?.isDisposed) {
|
|
115
|
+
tracker.currentWidget?.activate();
|
|
100
116
|
}
|
|
101
117
|
});
|
|
102
118
|
searchInstance.disposed.connect(() => {
|
|
103
|
-
if (!
|
|
104
|
-
|
|
119
|
+
if (!tracker.currentWidget?.isDisposed) {
|
|
120
|
+
tracker.currentWidget?.activate();
|
|
105
121
|
}
|
|
106
122
|
// find next and previous are now disabled
|
|
107
|
-
|
|
123
|
+
commands.notifyCommandChanged();
|
|
108
124
|
});
|
|
109
125
|
/**
|
|
110
126
|
* Dispose resources when the widget is disposed.
|
|
111
127
|
*/
|
|
112
|
-
|
|
128
|
+
tracker.currentWidget?.disposed.connect(() => {
|
|
113
129
|
searchInstance?.dispose();
|
|
114
130
|
searchModel.dispose();
|
|
115
131
|
provider.dispose();
|
|
116
132
|
});
|
|
117
133
|
}
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
searchInstance.
|
|
121
|
-
|
|
134
|
+
if (searchInstance &&
|
|
135
|
+
tracker.currentWidget &&
|
|
136
|
+
!searchInstance.isAttached) {
|
|
137
|
+
Widget.attach(searchInstance, tracker.currentWidget?.node);
|
|
138
|
+
searchInstance.node.style.top = `${tracker.currentWidget?.toolbar.node.getBoundingClientRect().height +
|
|
139
|
+
tracker.currentWidget?.contentHeader.node.getBoundingClientRect()
|
|
140
|
+
.height}px`;
|
|
122
141
|
if (searchInstance.model.searchExpression) {
|
|
123
142
|
searchInstance.model.refresh();
|
|
124
143
|
}
|
|
125
144
|
}
|
|
126
|
-
searchInstance
|
|
145
|
+
searchInstance?.focusSearchInput();
|
|
127
146
|
},
|
|
128
|
-
});
|
|
129
|
-
|
|
147
|
+
}));
|
|
148
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.findNext, {
|
|
130
149
|
label: 'Find Next',
|
|
131
150
|
isEnabled: () => !!searchInstance,
|
|
132
151
|
execute: async () => {
|
|
@@ -135,8 +154,8 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
135
154
|
}
|
|
136
155
|
await searchInstance.model.highlightNext();
|
|
137
156
|
},
|
|
138
|
-
});
|
|
139
|
-
|
|
157
|
+
}));
|
|
158
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.findPrevious, {
|
|
140
159
|
label: 'Find Previous',
|
|
141
160
|
isEnabled: () => !!searchInstance,
|
|
142
161
|
execute: async () => {
|
|
@@ -145,153 +164,207 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
145
164
|
}
|
|
146
165
|
await searchInstance.model.highlightPrevious();
|
|
147
166
|
},
|
|
148
|
-
});
|
|
149
|
-
|
|
167
|
+
}));
|
|
168
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.interrupt, {
|
|
150
169
|
label: 'Interrupt',
|
|
151
|
-
execute: async () =>
|
|
152
|
-
});
|
|
170
|
+
execute: async () => tracker.currentWidget?.context.sessionContext.session?.kernel?.interrupt(),
|
|
171
|
+
}));
|
|
153
172
|
const sessionContextDialogs = new SessionContextDialogs();
|
|
154
|
-
|
|
173
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.restart, {
|
|
155
174
|
label: 'Restart Kernel',
|
|
156
|
-
execute: () =>
|
|
157
|
-
|
|
158
|
-
|
|
175
|
+
execute: () => {
|
|
176
|
+
if (tracker.currentWidget) {
|
|
177
|
+
sessionContextDialogs.restart(tracker.currentWidget.context.sessionContext);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
}));
|
|
181
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.switchKernel, {
|
|
159
182
|
label: 'Switch Kernel',
|
|
160
|
-
execute: () =>
|
|
161
|
-
|
|
162
|
-
|
|
183
|
+
execute: () => {
|
|
184
|
+
if (tracker.currentWidget) {
|
|
185
|
+
sessionContextDialogs.selectKernel(tracker.currentWidget.context.sessionContext);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
}));
|
|
189
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.runAndAdvance, {
|
|
163
190
|
label: 'Run and Advance',
|
|
164
191
|
execute: () => {
|
|
165
|
-
return
|
|
192
|
+
return tracker.currentWidget
|
|
193
|
+
? NotebookActions.runAndAdvance(tracker.currentWidget.content, tracker.currentWidget.context.sessionContext)
|
|
194
|
+
: undefined;
|
|
166
195
|
},
|
|
167
|
-
});
|
|
168
|
-
|
|
196
|
+
}));
|
|
197
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.run, {
|
|
169
198
|
label: 'Run',
|
|
170
199
|
execute: () => {
|
|
171
|
-
return
|
|
200
|
+
return tracker.currentWidget
|
|
201
|
+
? NotebookActions.run(tracker.currentWidget.content, tracker.currentWidget.context.sessionContext)
|
|
202
|
+
: undefined;
|
|
172
203
|
},
|
|
173
|
-
});
|
|
174
|
-
|
|
204
|
+
}));
|
|
205
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.runAll, {
|
|
175
206
|
label: 'Run all',
|
|
176
207
|
execute: () => {
|
|
177
|
-
return
|
|
208
|
+
return tracker.currentWidget
|
|
209
|
+
? NotebookActions.runAll(tracker.currentWidget.content, tracker.currentWidget.context.sessionContext)
|
|
210
|
+
: undefined;
|
|
178
211
|
},
|
|
179
|
-
});
|
|
180
|
-
|
|
212
|
+
}));
|
|
213
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.deleteCells, {
|
|
181
214
|
label: 'Delete Cells',
|
|
182
215
|
execute: () => {
|
|
183
|
-
return
|
|
216
|
+
return tracker.currentWidget
|
|
217
|
+
? NotebookActions.deleteCells(tracker.currentWidget.content)
|
|
218
|
+
: undefined;
|
|
184
219
|
},
|
|
185
|
-
});
|
|
186
|
-
|
|
220
|
+
}));
|
|
221
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.insertAbove, {
|
|
187
222
|
label: 'Insert Above',
|
|
188
|
-
execute:
|
|
189
|
-
|
|
223
|
+
execute: args => {
|
|
224
|
+
const { cellType } = (args ?? {});
|
|
225
|
+
const notebook = tracker.currentWidget?.content;
|
|
226
|
+
if (notebook) {
|
|
227
|
+
NotebookActions.insertAbove(notebook);
|
|
228
|
+
if (cellType) {
|
|
229
|
+
NotebookActions.changeCellType(notebook, cellType);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
190
232
|
},
|
|
191
|
-
});
|
|
192
|
-
|
|
233
|
+
}));
|
|
234
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.insertBelow, {
|
|
193
235
|
label: 'Insert Below',
|
|
194
|
-
execute:
|
|
195
|
-
|
|
236
|
+
execute: args => {
|
|
237
|
+
const { cellType } = (args ?? {});
|
|
238
|
+
const notebook = tracker.currentWidget?.content;
|
|
239
|
+
if (notebook) {
|
|
240
|
+
NotebookActions.insertBelow(notebook);
|
|
241
|
+
if (cellType) {
|
|
242
|
+
NotebookActions.changeCellType(notebook, cellType);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
196
245
|
},
|
|
197
|
-
});
|
|
198
|
-
|
|
246
|
+
}));
|
|
247
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.editMode, {
|
|
199
248
|
label: 'Edit Mode',
|
|
200
249
|
execute: () => {
|
|
201
|
-
|
|
250
|
+
if (tracker.currentWidget) {
|
|
251
|
+
tracker.currentWidget.content.mode = 'edit';
|
|
252
|
+
}
|
|
202
253
|
},
|
|
203
|
-
});
|
|
204
|
-
|
|
254
|
+
}));
|
|
255
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.commandMode, {
|
|
205
256
|
label: 'Command Mode',
|
|
206
257
|
execute: () => {
|
|
207
|
-
|
|
258
|
+
if (tracker.currentWidget) {
|
|
259
|
+
tracker.currentWidget.content.mode = 'command';
|
|
260
|
+
}
|
|
208
261
|
},
|
|
209
|
-
});
|
|
210
|
-
|
|
262
|
+
}));
|
|
263
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.selectBelow, {
|
|
211
264
|
label: 'Select Below',
|
|
212
|
-
execute: () =>
|
|
213
|
-
|
|
214
|
-
|
|
265
|
+
execute: () => tracker.currentWidget
|
|
266
|
+
? NotebookActions.selectBelow(tracker.currentWidget.content)
|
|
267
|
+
: undefined,
|
|
268
|
+
}));
|
|
269
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.selectAbove, {
|
|
215
270
|
label: 'Select Above',
|
|
216
|
-
execute: () =>
|
|
217
|
-
|
|
218
|
-
|
|
271
|
+
execute: () => tracker.currentWidget
|
|
272
|
+
? NotebookActions.selectAbove(tracker.currentWidget.content)
|
|
273
|
+
: undefined,
|
|
274
|
+
}));
|
|
275
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.extendAbove, {
|
|
219
276
|
label: 'Extend Above',
|
|
220
|
-
execute: () =>
|
|
221
|
-
|
|
222
|
-
|
|
277
|
+
execute: () => tracker.currentWidget
|
|
278
|
+
? NotebookActions.extendSelectionAbove(tracker.currentWidget.content)
|
|
279
|
+
: undefined,
|
|
280
|
+
}));
|
|
281
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.extendTop, {
|
|
223
282
|
label: 'Extend to Top',
|
|
224
|
-
execute: () =>
|
|
225
|
-
|
|
226
|
-
|
|
283
|
+
execute: () => tracker.currentWidget
|
|
284
|
+
? NotebookActions.extendSelectionAbove(tracker.currentWidget.content, true)
|
|
285
|
+
: undefined,
|
|
286
|
+
}));
|
|
287
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.extendBelow, {
|
|
227
288
|
label: 'Extend Below',
|
|
228
|
-
execute: () =>
|
|
229
|
-
|
|
230
|
-
|
|
289
|
+
execute: () => tracker.currentWidget
|
|
290
|
+
? NotebookActions.extendSelectionBelow(tracker.currentWidget.content)
|
|
291
|
+
: undefined,
|
|
292
|
+
}));
|
|
293
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.extendBottom, {
|
|
231
294
|
label: 'Extend to Bottom',
|
|
232
|
-
execute: () =>
|
|
233
|
-
|
|
234
|
-
|
|
295
|
+
execute: () => tracker.currentWidget
|
|
296
|
+
? NotebookActions.extendSelectionBelow(tracker.currentWidget.content, true)
|
|
297
|
+
: undefined,
|
|
298
|
+
}));
|
|
299
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.merge, {
|
|
235
300
|
label: 'Merge Cells',
|
|
236
|
-
execute: () =>
|
|
237
|
-
|
|
238
|
-
|
|
301
|
+
execute: () => tracker.currentWidget
|
|
302
|
+
? NotebookActions.mergeCells(tracker.currentWidget.content)
|
|
303
|
+
: undefined,
|
|
304
|
+
}));
|
|
305
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.split, {
|
|
239
306
|
label: 'Split Cell',
|
|
240
|
-
execute: () =>
|
|
241
|
-
|
|
242
|
-
|
|
307
|
+
execute: () => tracker.currentWidget
|
|
308
|
+
? NotebookActions.splitCell(tracker.currentWidget.content)
|
|
309
|
+
: undefined,
|
|
310
|
+
}));
|
|
311
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.undo, {
|
|
243
312
|
label: 'Undo',
|
|
244
313
|
execute: () => {
|
|
245
|
-
const activeCell =
|
|
314
|
+
const activeCell = tracker.currentWidget?.content.activeCell;
|
|
246
315
|
if (activeCell) {
|
|
247
|
-
const sharedModel = activeCell.model
|
|
248
|
-
.sharedModel;
|
|
316
|
+
const sharedModel = activeCell.model.sharedModel;
|
|
249
317
|
if (sharedModel.undoManager) {
|
|
250
318
|
sharedModel.undoManager.undo();
|
|
251
319
|
}
|
|
252
320
|
else {
|
|
253
321
|
// Fallback to default undo if Yjs undo manager is not available
|
|
254
|
-
NotebookActions.undo(
|
|
322
|
+
NotebookActions.undo(tracker.currentWidget.content);
|
|
255
323
|
}
|
|
256
324
|
}
|
|
257
325
|
},
|
|
258
|
-
});
|
|
259
|
-
|
|
326
|
+
}));
|
|
327
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.redo, {
|
|
260
328
|
label: 'Redo',
|
|
261
329
|
execute: () => {
|
|
262
|
-
const activeCell =
|
|
330
|
+
const activeCell = tracker.currentWidget?.content.activeCell;
|
|
263
331
|
if (activeCell) {
|
|
264
|
-
const sharedModel = activeCell.model
|
|
265
|
-
.sharedModel;
|
|
332
|
+
const sharedModel = activeCell.model.sharedModel;
|
|
266
333
|
if (sharedModel.undoManager) {
|
|
267
334
|
sharedModel.undoManager.redo();
|
|
268
335
|
}
|
|
269
336
|
else {
|
|
270
337
|
// Fallback to default redo if Yjs undo manager is not available
|
|
271
|
-
NotebookActions.redo(
|
|
338
|
+
NotebookActions.redo(tracker.currentWidget.content);
|
|
272
339
|
}
|
|
273
340
|
}
|
|
274
341
|
},
|
|
275
|
-
});
|
|
276
|
-
|
|
342
|
+
}));
|
|
343
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.changeCellTypeToCode, {
|
|
277
344
|
label: 'Change Cell Type to Code',
|
|
278
|
-
execute: args =>
|
|
279
|
-
|
|
280
|
-
|
|
345
|
+
execute: args => tracker.currentWidget
|
|
346
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'code')
|
|
347
|
+
: undefined,
|
|
348
|
+
}));
|
|
349
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.changeCellTypeToMarkdown, {
|
|
281
350
|
label: 'Change Cell Type to Markdown',
|
|
282
|
-
execute: args =>
|
|
283
|
-
|
|
284
|
-
|
|
351
|
+
execute: args => tracker.currentWidget
|
|
352
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'markdown')
|
|
353
|
+
: undefined,
|
|
354
|
+
}));
|
|
355
|
+
allCommands.add(commands.addCommand(NotebookCommandIds.changeCellTypeToRaw, {
|
|
285
356
|
label: 'Change Cell Type to Raw',
|
|
286
|
-
execute: args =>
|
|
287
|
-
|
|
357
|
+
execute: args => tracker.currentWidget
|
|
358
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'raw')
|
|
359
|
+
: undefined,
|
|
360
|
+
}));
|
|
288
361
|
function getCurrent(args) {
|
|
289
362
|
return tracker.currentWidget;
|
|
290
363
|
}
|
|
291
364
|
function isEnabled() {
|
|
292
365
|
return tracker.currentWidget !== null;
|
|
293
366
|
}
|
|
294
|
-
|
|
367
|
+
allCommands.add(commands.addCommand('run-selected-codecell', {
|
|
295
368
|
label: 'Run Cell',
|
|
296
369
|
execute: args => {
|
|
297
370
|
const current = getCurrent(args);
|
|
@@ -301,145 +374,146 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
301
374
|
}
|
|
302
375
|
},
|
|
303
376
|
isEnabled,
|
|
304
|
-
});
|
|
377
|
+
}));
|
|
305
378
|
const bindings = [
|
|
306
379
|
{
|
|
307
380
|
selector: '.jp-Notebook.jp-mod-editMode .jp-mod-completer-enabled',
|
|
308
381
|
keys: ['Tab'],
|
|
309
|
-
command:
|
|
382
|
+
command: NotebookCommandIds.invokeNotebook,
|
|
310
383
|
},
|
|
311
384
|
{
|
|
312
385
|
selector: '.jp-mod-completer-active',
|
|
313
386
|
keys: ['Enter'],
|
|
314
|
-
command:
|
|
387
|
+
command: NotebookCommandIds.selectNotebook,
|
|
315
388
|
},
|
|
316
389
|
{
|
|
317
390
|
selector: '.jp-Notebook',
|
|
318
391
|
keys: ['Ctrl Enter'],
|
|
319
|
-
command:
|
|
392
|
+
command: NotebookCommandIds.run,
|
|
320
393
|
},
|
|
321
394
|
{
|
|
322
395
|
selector: '.jp-Notebook',
|
|
323
396
|
keys: ['Shift Enter'],
|
|
324
|
-
command:
|
|
397
|
+
command: NotebookCommandIds.runAndAdvance,
|
|
325
398
|
},
|
|
326
399
|
{
|
|
327
400
|
selector: '.jp-Notebook',
|
|
328
401
|
keys: ['Accel F'],
|
|
329
|
-
command:
|
|
402
|
+
command: NotebookCommandIds.startSearch,
|
|
330
403
|
},
|
|
331
404
|
{
|
|
332
|
-
selector: '.jp-Notebook:focus',
|
|
405
|
+
selector: '.jp-Notebook.jp-mod-commandMode :focus',
|
|
333
406
|
keys: ['D', 'D'],
|
|
334
|
-
command:
|
|
407
|
+
command: NotebookCommandIds.deleteCells,
|
|
335
408
|
},
|
|
336
409
|
{
|
|
337
410
|
selector: '.jp-Notebook',
|
|
338
411
|
keys: ['Accel G'],
|
|
339
|
-
command:
|
|
412
|
+
command: NotebookCommandIds.findNext,
|
|
340
413
|
},
|
|
341
414
|
{
|
|
342
415
|
selector: '.jp-Notebook',
|
|
343
416
|
keys: ['Accel Shift G'],
|
|
344
|
-
command:
|
|
417
|
+
command: NotebookCommandIds.findPrevious,
|
|
345
418
|
},
|
|
346
419
|
{
|
|
347
420
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
348
421
|
keys: ['I', 'I'],
|
|
349
|
-
command:
|
|
422
|
+
command: NotebookCommandIds.interrupt,
|
|
350
423
|
},
|
|
351
424
|
{
|
|
352
425
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
353
426
|
keys: ['0', '0'],
|
|
354
|
-
command:
|
|
427
|
+
command: NotebookCommandIds.restart,
|
|
355
428
|
},
|
|
356
429
|
{
|
|
357
430
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
358
431
|
keys: ['Enter'],
|
|
359
|
-
command:
|
|
432
|
+
command: NotebookCommandIds.editMode,
|
|
360
433
|
},
|
|
361
434
|
{
|
|
362
435
|
selector: '.jp-Notebook.jp-mod-editMode',
|
|
363
436
|
keys: ['Escape'],
|
|
364
|
-
command:
|
|
437
|
+
command: NotebookCommandIds.commandMode,
|
|
365
438
|
},
|
|
366
439
|
{
|
|
367
440
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
368
441
|
keys: ['Shift M'],
|
|
369
|
-
command:
|
|
442
|
+
command: NotebookCommandIds.merge,
|
|
370
443
|
},
|
|
371
444
|
{
|
|
372
445
|
selector: '.jp-Notebook.jp-mod-editMode',
|
|
373
446
|
keys: ['Ctrl Shift -'],
|
|
374
|
-
command:
|
|
447
|
+
command: NotebookCommandIds.split,
|
|
375
448
|
},
|
|
376
449
|
{
|
|
377
450
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
378
451
|
keys: ['J'],
|
|
379
|
-
command:
|
|
452
|
+
command: NotebookCommandIds.selectBelow,
|
|
380
453
|
},
|
|
381
454
|
{
|
|
382
455
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
383
456
|
keys: ['ArrowDown'],
|
|
384
|
-
command:
|
|
457
|
+
command: NotebookCommandIds.selectBelow,
|
|
385
458
|
},
|
|
386
459
|
{
|
|
387
460
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
388
461
|
keys: ['A'],
|
|
389
|
-
command:
|
|
462
|
+
command: NotebookCommandIds.insertAbove,
|
|
390
463
|
},
|
|
391
464
|
{
|
|
392
465
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
393
466
|
keys: ['B'],
|
|
394
|
-
command:
|
|
467
|
+
command: NotebookCommandIds.insertBelow,
|
|
395
468
|
},
|
|
396
469
|
{
|
|
397
470
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
398
471
|
keys: ['K'],
|
|
399
|
-
command:
|
|
472
|
+
command: NotebookCommandIds.selectAbove,
|
|
400
473
|
},
|
|
401
474
|
{
|
|
402
475
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
403
476
|
keys: ['ArrowUp'],
|
|
404
|
-
command:
|
|
477
|
+
command: NotebookCommandIds.selectAbove,
|
|
405
478
|
},
|
|
406
479
|
{
|
|
407
480
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
408
481
|
keys: ['Shift K'],
|
|
409
|
-
command:
|
|
482
|
+
command: NotebookCommandIds.extendAbove,
|
|
410
483
|
},
|
|
411
484
|
{
|
|
412
485
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
413
486
|
keys: ['Shift J'],
|
|
414
|
-
command:
|
|
487
|
+
command: NotebookCommandIds.extendBelow,
|
|
415
488
|
},
|
|
416
489
|
{
|
|
417
490
|
selector: '.jp-Notebook',
|
|
418
491
|
keys: ['Ctrl Z'],
|
|
419
|
-
command:
|
|
492
|
+
command: NotebookCommandIds.undo,
|
|
420
493
|
},
|
|
421
494
|
{
|
|
422
495
|
selector: '.jp-Notebook',
|
|
423
496
|
keys: ['Ctrl Y'],
|
|
424
|
-
command:
|
|
497
|
+
command: NotebookCommandIds.redo,
|
|
425
498
|
},
|
|
426
499
|
{
|
|
427
|
-
selector: '.jp-Notebook:focus',
|
|
500
|
+
selector: '.jp-Notebook.jp-mod-commandMode :focus',
|
|
428
501
|
keys: ['M'],
|
|
429
|
-
command:
|
|
502
|
+
command: NotebookCommandIds.changeCellTypeToMarkdown,
|
|
430
503
|
},
|
|
431
504
|
{
|
|
432
|
-
selector: '.jp-Notebook:focus',
|
|
505
|
+
selector: '.jp-Notebook.jp-mod-commandMode :focus',
|
|
433
506
|
keys: ['R'],
|
|
434
|
-
command:
|
|
507
|
+
command: NotebookCommandIds.changeCellTypeToRaw,
|
|
435
508
|
},
|
|
436
509
|
{
|
|
437
|
-
selector: '.jp-Notebook:focus',
|
|
510
|
+
selector: '.jp-Notebook.jp-mod-commandMode :focus',
|
|
438
511
|
keys: ['Y'],
|
|
439
|
-
command:
|
|
512
|
+
command: NotebookCommandIds.changeCellTypeToCode,
|
|
440
513
|
},
|
|
441
514
|
];
|
|
442
|
-
bindings.
|
|
443
|
-
|
|
444
|
-
|
|
515
|
+
bindings.forEach(binding => allCommands.add(commands.addKeyBinding(binding)));
|
|
516
|
+
return allCommands;
|
|
517
|
+
}
|
|
518
|
+
export default addNotebookCommands;
|
|
445
519
|
//# sourceMappingURL=NotebookCommands.js.map
|