@datalayer/jupyter-react 0.19.2 → 0.19.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/components/console/Console.js +5 -5
- package/lib/components/console/Console.js.map +1 -1
- package/lib/components/jupyterlab/JupyterLabApp.js +3 -4
- package/lib/components/jupyterlab/JupyterLabApp.js.map +1 -1
- package/lib/components/jupyterlab/JupyterLabAppPlugins.d.ts +1 -1
- package/lib/components/jupyterlab/JupyterLabAppPlugins.js +1 -1
- package/lib/components/jupyterlab/JupyterLabAppPlugins.js.map +1 -1
- package/lib/components/notebook/BaseNotebook.d.ts +148 -0
- package/lib/components/notebook/BaseNotebook.js +717 -0
- package/lib/components/notebook/BaseNotebook.js.map +1 -0
- package/lib/components/notebook/Notebook.d.ts +16 -14
- package/lib/components/notebook/Notebook.js +153 -28
- package/lib/components/notebook/Notebook.js.map +1 -1
- package/lib/components/notebook/NotebookAdapter.js +2 -2
- package/lib/components/notebook/NotebookAdapter.js.map +1 -1
- package/lib/components/notebook/NotebookCommands.d.ts +14 -4
- package/lib/components/notebook/NotebookCommands.js +213 -149
- package/lib/components/notebook/NotebookCommands.js.map +1 -1
- package/lib/components/notebook/NotebookState.js +15 -15
- package/lib/components/notebook/NotebookState.js.map +1 -1
- package/lib/components/notebook/SimpleNotebook.d.ts +34 -0
- package/lib/components/notebook/SimpleNotebook.js +84 -0
- package/lib/components/notebook/SimpleNotebook.js.map +1 -0
- package/lib/components/notebook/content/JupyterReactContentFactory.js +2 -1
- 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/output/Output.js +1 -1
- package/lib/components/output/Output.js.map +1 -1
- package/lib/components/output/OutputAdapter.js +2 -2
- package/lib/components/output/OutputAdapter.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/CellLite.js +2 -2
- package/lib/examples/CellLite.js.map +1 -1
- package/lib/examples/ConsoleLite.js +2 -2
- package/lib/examples/ConsoleLite.js.map +1 -1
- package/lib/examples/KernelExecute.js +1 -1
- package/lib/examples/KernelExecute.js.map +1 -1
- package/lib/examples/KernelExecutor.js +1 -1
- package/lib/examples/KernelExecutor.js.map +1 -1
- package/lib/examples/Kernels.js +1 -1
- package/lib/examples/Kernels.js.map +1 -1
- package/lib/examples/NotebookCellSidebar.js +1 -1
- package/lib/examples/NotebookCellSidebar.js.map +1 -1
- package/lib/examples/NotebookCellToolbar.js +1 -1
- package/lib/examples/NotebookCellToolbar.js.map +1 -1
- package/lib/examples/NotebookCollaborative.d.ts +1 -0
- package/lib/examples/NotebookCollaborative.js +20 -0
- package/lib/examples/NotebookCollaborative.js.map +1 -0
- package/lib/examples/NotebookColormode.js +1 -1
- package/lib/examples/NotebookColormode.js.map +1 -1
- package/lib/examples/NotebookLite.js +1 -1
- package/lib/examples/NotebookLite.js.map +1 -1
- package/lib/examples/NotebookReadonly.js +1 -1
- package/lib/examples/NotebookReadonly.js.map +1 -1
- package/lib/examples/NotebookSimple.d.ts +1 -0
- package/lib/examples/NotebookSimple.js +36 -0
- package/lib/examples/NotebookSimple.js.map +1 -0
- package/lib/examples/Output.js +3 -3
- package/lib/examples/Output.js.map +1 -1
- package/lib/examples/OutputWithMonitoring.js +1 -1
- package/lib/examples/OutputWithMonitoring.js.map +1 -1
- package/lib/examples/Outputs.js +3 -3
- package/lib/examples/Outputs.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/notebooks/Lite.ipynb.json +146 -0
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js +3 -3
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js.map +1 -1
- package/lib/jupyter/JupyterConfig.d.ts +1 -2
- package/lib/jupyter/JupyterConfig.js +1 -2
- package/lib/jupyter/JupyterConfig.js.map +1 -1
- package/lib/jupyter/JupyterContext.d.ts +0 -15
- package/lib/jupyter/JupyterContext.js +2 -6
- package/lib/jupyter/JupyterContext.js.map +1 -1
- package/lib/jupyter/collaboration/DatalayerCollaboration.d.ts +7 -0
- package/lib/jupyter/collaboration/DatalayerCollaboration.js +30 -0
- package/lib/jupyter/collaboration/DatalayerCollaboration.js.map +1 -0
- package/lib/jupyter/collaboration/ICollaborative.d.ts +2 -0
- package/lib/jupyter/collaboration/ICollaborative.js +7 -0
- package/lib/jupyter/collaboration/ICollaborative.js.map +1 -0
- package/lib/jupyter/collaboration/JupyterCollaboration.d.ts +27 -0
- package/lib/jupyter/collaboration/JupyterCollaboration.js +39 -0
- package/lib/jupyter/collaboration/JupyterCollaboration.js.map +1 -0
- package/lib/jupyter/collaboration/index.d.ts +3 -0
- package/lib/jupyter/collaboration/index.js +9 -0
- package/lib/jupyter/collaboration/index.js.map +1 -0
- package/lib/jupyter/index.d.ts +1 -0
- package/lib/jupyter/index.js +1 -0
- package/lib/jupyter/index.js.map +1 -1
- package/lib/state/JupyterReactState.js +2 -2
- package/lib/state/JupyterReactState.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 +3 -3
|
@@ -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,62 +47,77 @@ 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 commandRegistry 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(commandRegistry, completerHandler, tracker, path) {
|
|
60
|
+
const allCommands = new DisposableSet();
|
|
61
|
+
// Add commands.
|
|
50
62
|
if (path) {
|
|
51
|
-
commandRegistry.addCommand(
|
|
63
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.save, {
|
|
52
64
|
label: 'Save',
|
|
53
|
-
execute: () =>
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
execute: () => {
|
|
66
|
+
tracker.currentWidget?.context.save();
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
allCommands.add(commandRegistry.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(commandRegistry.addCommand(NotebookCommandIds.invoke, {
|
|
63
76
|
label: 'Completer: Invoke',
|
|
64
77
|
execute: () => completerHandler.invoke(),
|
|
65
|
-
});
|
|
66
|
-
commandRegistry.addCommand(
|
|
78
|
+
}));
|
|
79
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.select, {
|
|
67
80
|
label: 'Completer: Select',
|
|
68
81
|
execute: () => completerHandler.completer.selectActive(),
|
|
69
|
-
});
|
|
70
|
-
commandRegistry.addCommand(
|
|
82
|
+
}));
|
|
83
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.invokeNotebook, {
|
|
71
84
|
label: 'Invoke Notebook',
|
|
72
85
|
execute: () => {
|
|
73
|
-
if (
|
|
74
|
-
return commandRegistry.execute(
|
|
86
|
+
if (tracker.currentWidget?.content.activeCell?.model.type === 'code') {
|
|
87
|
+
return commandRegistry.execute(NotebookCommandIds.invoke);
|
|
75
88
|
}
|
|
76
89
|
},
|
|
77
|
-
});
|
|
78
|
-
commandRegistry.addCommand(
|
|
90
|
+
}));
|
|
91
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.selectNotebook, {
|
|
79
92
|
label: 'Select Notebook',
|
|
80
93
|
execute: () => {
|
|
81
|
-
if (
|
|
82
|
-
return commandRegistry.execute(
|
|
94
|
+
if (tracker.currentWidget?.content.activeCell?.model.type === 'code') {
|
|
95
|
+
return commandRegistry.execute(NotebookCommandIds.select);
|
|
83
96
|
}
|
|
84
97
|
},
|
|
85
|
-
});
|
|
98
|
+
}));
|
|
86
99
|
let searchInstance;
|
|
87
|
-
commandRegistry.addCommand(
|
|
100
|
+
allCommands.add(commandRegistry.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
|
commandRegistry.notifyCommandChanged();
|
|
@@ -109,24 +125,27 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
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
|
-
commandRegistry.addCommand(
|
|
147
|
+
}));
|
|
148
|
+
allCommands.add(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
157
|
+
}));
|
|
158
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.findPrevious, {
|
|
140
159
|
label: 'Find Previous',
|
|
141
160
|
isEnabled: () => !!searchInstance,
|
|
142
161
|
execute: async () => {
|
|
@@ -145,153 +164,197 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
145
164
|
}
|
|
146
165
|
await searchInstance.model.highlightPrevious();
|
|
147
166
|
},
|
|
148
|
-
});
|
|
149
|
-
commandRegistry.addCommand(
|
|
167
|
+
}));
|
|
168
|
+
allCommands.add(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
173
|
+
allCommands.add(commandRegistry.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(commandRegistry.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(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
196
|
+
}));
|
|
197
|
+
allCommands.add(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
204
|
+
}));
|
|
205
|
+
allCommands.add(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
212
|
+
}));
|
|
213
|
+
allCommands.add(commandRegistry.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
|
-
commandRegistry.addCommand(
|
|
220
|
+
}));
|
|
221
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.insertAbove, {
|
|
187
222
|
label: 'Insert Above',
|
|
188
223
|
execute: () => {
|
|
189
|
-
return
|
|
224
|
+
return tracker.currentWidget
|
|
225
|
+
? NotebookActions.insertAbove(tracker.currentWidget.content)
|
|
226
|
+
: undefined;
|
|
190
227
|
},
|
|
191
|
-
});
|
|
192
|
-
commandRegistry.addCommand(
|
|
228
|
+
}));
|
|
229
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.insertBelow, {
|
|
193
230
|
label: 'Insert Below',
|
|
194
231
|
execute: () => {
|
|
195
|
-
return
|
|
232
|
+
return tracker.currentWidget
|
|
233
|
+
? NotebookActions.insertBelow(tracker.currentWidget.content)
|
|
234
|
+
: undefined;
|
|
196
235
|
},
|
|
197
|
-
});
|
|
198
|
-
commandRegistry.addCommand(
|
|
236
|
+
}));
|
|
237
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.editMode, {
|
|
199
238
|
label: 'Edit Mode',
|
|
200
239
|
execute: () => {
|
|
201
|
-
|
|
240
|
+
if (tracker.currentWidget) {
|
|
241
|
+
tracker.currentWidget.content.mode = 'edit';
|
|
242
|
+
}
|
|
202
243
|
},
|
|
203
|
-
});
|
|
204
|
-
commandRegistry.addCommand(
|
|
244
|
+
}));
|
|
245
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.commandMode, {
|
|
205
246
|
label: 'Command Mode',
|
|
206
247
|
execute: () => {
|
|
207
|
-
|
|
248
|
+
if (tracker.currentWidget) {
|
|
249
|
+
tracker.currentWidget.content.mode = 'command';
|
|
250
|
+
}
|
|
208
251
|
},
|
|
209
|
-
});
|
|
210
|
-
commandRegistry.addCommand(
|
|
252
|
+
}));
|
|
253
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.selectBelow, {
|
|
211
254
|
label: 'Select Below',
|
|
212
|
-
execute: () =>
|
|
213
|
-
|
|
214
|
-
|
|
255
|
+
execute: () => tracker.currentWidget
|
|
256
|
+
? NotebookActions.selectBelow(tracker.currentWidget.content)
|
|
257
|
+
: undefined,
|
|
258
|
+
}));
|
|
259
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.selectAbove, {
|
|
215
260
|
label: 'Select Above',
|
|
216
|
-
execute: () =>
|
|
217
|
-
|
|
218
|
-
|
|
261
|
+
execute: () => tracker.currentWidget
|
|
262
|
+
? NotebookActions.selectAbove(tracker.currentWidget.content)
|
|
263
|
+
: undefined,
|
|
264
|
+
}));
|
|
265
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.extendAbove, {
|
|
219
266
|
label: 'Extend Above',
|
|
220
|
-
execute: () =>
|
|
221
|
-
|
|
222
|
-
|
|
267
|
+
execute: () => tracker.currentWidget
|
|
268
|
+
? NotebookActions.extendSelectionAbove(tracker.currentWidget.content)
|
|
269
|
+
: undefined,
|
|
270
|
+
}));
|
|
271
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.extendTop, {
|
|
223
272
|
label: 'Extend to Top',
|
|
224
|
-
execute: () =>
|
|
225
|
-
|
|
226
|
-
|
|
273
|
+
execute: () => tracker.currentWidget
|
|
274
|
+
? NotebookActions.extendSelectionAbove(tracker.currentWidget.content, true)
|
|
275
|
+
: undefined,
|
|
276
|
+
}));
|
|
277
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.extendBelow, {
|
|
227
278
|
label: 'Extend Below',
|
|
228
|
-
execute: () =>
|
|
229
|
-
|
|
230
|
-
|
|
279
|
+
execute: () => tracker.currentWidget
|
|
280
|
+
? NotebookActions.extendSelectionBelow(tracker.currentWidget.content)
|
|
281
|
+
: undefined,
|
|
282
|
+
}));
|
|
283
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.extendBottom, {
|
|
231
284
|
label: 'Extend to Bottom',
|
|
232
|
-
execute: () =>
|
|
233
|
-
|
|
234
|
-
|
|
285
|
+
execute: () => tracker.currentWidget
|
|
286
|
+
? NotebookActions.extendSelectionBelow(tracker.currentWidget.content, true)
|
|
287
|
+
: undefined,
|
|
288
|
+
}));
|
|
289
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.merge, {
|
|
235
290
|
label: 'Merge Cells',
|
|
236
|
-
execute: () =>
|
|
237
|
-
|
|
238
|
-
|
|
291
|
+
execute: () => tracker.currentWidget
|
|
292
|
+
? NotebookActions.mergeCells(tracker.currentWidget.content)
|
|
293
|
+
: undefined,
|
|
294
|
+
}));
|
|
295
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.split, {
|
|
239
296
|
label: 'Split Cell',
|
|
240
|
-
execute: () =>
|
|
241
|
-
|
|
242
|
-
|
|
297
|
+
execute: () => tracker.currentWidget
|
|
298
|
+
? NotebookActions.splitCell(tracker.currentWidget.content)
|
|
299
|
+
: undefined,
|
|
300
|
+
}));
|
|
301
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.undo, {
|
|
243
302
|
label: 'Undo',
|
|
244
303
|
execute: () => {
|
|
245
|
-
const activeCell =
|
|
304
|
+
const activeCell = tracker.currentWidget?.content.activeCell;
|
|
246
305
|
if (activeCell) {
|
|
247
|
-
const sharedModel = activeCell.model
|
|
248
|
-
.sharedModel;
|
|
306
|
+
const sharedModel = activeCell.model.sharedModel;
|
|
249
307
|
if (sharedModel.undoManager) {
|
|
250
308
|
sharedModel.undoManager.undo();
|
|
251
309
|
}
|
|
252
310
|
else {
|
|
253
311
|
// Fallback to default undo if Yjs undo manager is not available
|
|
254
|
-
NotebookActions.undo(
|
|
312
|
+
NotebookActions.undo(tracker.currentWidget.content);
|
|
255
313
|
}
|
|
256
314
|
}
|
|
257
315
|
},
|
|
258
|
-
});
|
|
259
|
-
commandRegistry.addCommand(
|
|
316
|
+
}));
|
|
317
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.redo, {
|
|
260
318
|
label: 'Redo',
|
|
261
319
|
execute: () => {
|
|
262
|
-
const activeCell =
|
|
320
|
+
const activeCell = tracker.currentWidget?.content.activeCell;
|
|
263
321
|
if (activeCell) {
|
|
264
|
-
const sharedModel = activeCell.model
|
|
265
|
-
.sharedModel;
|
|
322
|
+
const sharedModel = activeCell.model.sharedModel;
|
|
266
323
|
if (sharedModel.undoManager) {
|
|
267
324
|
sharedModel.undoManager.redo();
|
|
268
325
|
}
|
|
269
326
|
else {
|
|
270
327
|
// Fallback to default redo if Yjs undo manager is not available
|
|
271
|
-
NotebookActions.redo(
|
|
328
|
+
NotebookActions.redo(tracker.currentWidget.content);
|
|
272
329
|
}
|
|
273
330
|
}
|
|
274
331
|
},
|
|
275
|
-
});
|
|
276
|
-
commandRegistry.addCommand(
|
|
332
|
+
}));
|
|
333
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.changeCellTypeToCode, {
|
|
277
334
|
label: 'Change Cell Type to Code',
|
|
278
|
-
execute: args =>
|
|
279
|
-
|
|
280
|
-
|
|
335
|
+
execute: args => tracker.currentWidget
|
|
336
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'code')
|
|
337
|
+
: undefined,
|
|
338
|
+
}));
|
|
339
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.changeCellTypeToMarkdown, {
|
|
281
340
|
label: 'Change Cell Type to Markdown',
|
|
282
|
-
execute: args =>
|
|
283
|
-
|
|
284
|
-
|
|
341
|
+
execute: args => tracker.currentWidget
|
|
342
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'markdown')
|
|
343
|
+
: undefined,
|
|
344
|
+
}));
|
|
345
|
+
allCommands.add(commandRegistry.addCommand(NotebookCommandIds.changeCellTypeToRaw, {
|
|
285
346
|
label: 'Change Cell Type to Raw',
|
|
286
|
-
execute: args =>
|
|
287
|
-
|
|
347
|
+
execute: args => tracker.currentWidget
|
|
348
|
+
? NotebookActions.changeCellType(tracker.currentWidget.content, 'raw')
|
|
349
|
+
: undefined,
|
|
350
|
+
}));
|
|
288
351
|
function getCurrent(args) {
|
|
289
352
|
return tracker.currentWidget;
|
|
290
353
|
}
|
|
291
354
|
function isEnabled() {
|
|
292
355
|
return tracker.currentWidget !== null;
|
|
293
356
|
}
|
|
294
|
-
commandRegistry.addCommand('run-selected-codecell', {
|
|
357
|
+
allCommands.add(commandRegistry.addCommand('run-selected-codecell', {
|
|
295
358
|
label: 'Run Cell',
|
|
296
359
|
execute: args => {
|
|
297
360
|
const current = getCurrent(args);
|
|
@@ -301,145 +364,146 @@ export const NotebookCommands = (commandRegistry, notebookPanel, completerHandle
|
|
|
301
364
|
}
|
|
302
365
|
},
|
|
303
366
|
isEnabled,
|
|
304
|
-
});
|
|
367
|
+
}));
|
|
305
368
|
const bindings = [
|
|
306
369
|
{
|
|
307
370
|
selector: '.jp-Notebook.jp-mod-editMode .jp-mod-completer-enabled',
|
|
308
371
|
keys: ['Tab'],
|
|
309
|
-
command:
|
|
372
|
+
command: NotebookCommandIds.invokeNotebook,
|
|
310
373
|
},
|
|
311
374
|
{
|
|
312
375
|
selector: '.jp-mod-completer-active',
|
|
313
376
|
keys: ['Enter'],
|
|
314
|
-
command:
|
|
377
|
+
command: NotebookCommandIds.selectNotebook,
|
|
315
378
|
},
|
|
316
379
|
{
|
|
317
380
|
selector: '.jp-Notebook',
|
|
318
381
|
keys: ['Ctrl Enter'],
|
|
319
|
-
command:
|
|
382
|
+
command: NotebookCommandIds.run,
|
|
320
383
|
},
|
|
321
384
|
{
|
|
322
385
|
selector: '.jp-Notebook',
|
|
323
386
|
keys: ['Shift Enter'],
|
|
324
|
-
command:
|
|
387
|
+
command: NotebookCommandIds.runAndAdvance,
|
|
325
388
|
},
|
|
326
389
|
{
|
|
327
390
|
selector: '.jp-Notebook',
|
|
328
391
|
keys: ['Accel F'],
|
|
329
|
-
command:
|
|
392
|
+
command: NotebookCommandIds.startSearch,
|
|
330
393
|
},
|
|
331
394
|
{
|
|
332
395
|
selector: '.jp-Notebook:focus',
|
|
333
396
|
keys: ['D', 'D'],
|
|
334
|
-
command:
|
|
397
|
+
command: NotebookCommandIds.deleteCells,
|
|
335
398
|
},
|
|
336
399
|
{
|
|
337
400
|
selector: '.jp-Notebook',
|
|
338
401
|
keys: ['Accel G'],
|
|
339
|
-
command:
|
|
402
|
+
command: NotebookCommandIds.findNext,
|
|
340
403
|
},
|
|
341
404
|
{
|
|
342
405
|
selector: '.jp-Notebook',
|
|
343
406
|
keys: ['Accel Shift G'],
|
|
344
|
-
command:
|
|
407
|
+
command: NotebookCommandIds.findPrevious,
|
|
345
408
|
},
|
|
346
409
|
{
|
|
347
410
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
348
411
|
keys: ['I', 'I'],
|
|
349
|
-
command:
|
|
412
|
+
command: NotebookCommandIds.interrupt,
|
|
350
413
|
},
|
|
351
414
|
{
|
|
352
415
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
353
416
|
keys: ['0', '0'],
|
|
354
|
-
command:
|
|
417
|
+
command: NotebookCommandIds.restart,
|
|
355
418
|
},
|
|
356
419
|
{
|
|
357
420
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
358
421
|
keys: ['Enter'],
|
|
359
|
-
command:
|
|
422
|
+
command: NotebookCommandIds.editMode,
|
|
360
423
|
},
|
|
361
424
|
{
|
|
362
425
|
selector: '.jp-Notebook.jp-mod-editMode',
|
|
363
426
|
keys: ['Escape'],
|
|
364
|
-
command:
|
|
427
|
+
command: NotebookCommandIds.commandMode,
|
|
365
428
|
},
|
|
366
429
|
{
|
|
367
430
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
368
431
|
keys: ['Shift M'],
|
|
369
|
-
command:
|
|
432
|
+
command: NotebookCommandIds.merge,
|
|
370
433
|
},
|
|
371
434
|
{
|
|
372
435
|
selector: '.jp-Notebook.jp-mod-editMode',
|
|
373
436
|
keys: ['Ctrl Shift -'],
|
|
374
|
-
command:
|
|
437
|
+
command: NotebookCommandIds.split,
|
|
375
438
|
},
|
|
376
439
|
{
|
|
377
440
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
378
441
|
keys: ['J'],
|
|
379
|
-
command:
|
|
442
|
+
command: NotebookCommandIds.selectBelow,
|
|
380
443
|
},
|
|
381
444
|
{
|
|
382
445
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
383
446
|
keys: ['ArrowDown'],
|
|
384
|
-
command:
|
|
447
|
+
command: NotebookCommandIds.selectBelow,
|
|
385
448
|
},
|
|
386
449
|
{
|
|
387
450
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
388
451
|
keys: ['A'],
|
|
389
|
-
command:
|
|
452
|
+
command: NotebookCommandIds.insertAbove,
|
|
390
453
|
},
|
|
391
454
|
{
|
|
392
455
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
393
456
|
keys: ['B'],
|
|
394
|
-
command:
|
|
457
|
+
command: NotebookCommandIds.insertBelow,
|
|
395
458
|
},
|
|
396
459
|
{
|
|
397
460
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
398
461
|
keys: ['K'],
|
|
399
|
-
command:
|
|
462
|
+
command: NotebookCommandIds.selectAbove,
|
|
400
463
|
},
|
|
401
464
|
{
|
|
402
465
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
403
466
|
keys: ['ArrowUp'],
|
|
404
|
-
command:
|
|
467
|
+
command: NotebookCommandIds.selectAbove,
|
|
405
468
|
},
|
|
406
469
|
{
|
|
407
470
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
408
471
|
keys: ['Shift K'],
|
|
409
|
-
command:
|
|
472
|
+
command: NotebookCommandIds.extendAbove,
|
|
410
473
|
},
|
|
411
474
|
{
|
|
412
475
|
selector: '.jp-Notebook.jp-mod-commandMode :focus:not(:read-write)',
|
|
413
476
|
keys: ['Shift J'],
|
|
414
|
-
command:
|
|
477
|
+
command: NotebookCommandIds.extendBelow,
|
|
415
478
|
},
|
|
416
479
|
{
|
|
417
480
|
selector: '.jp-Notebook',
|
|
418
481
|
keys: ['Ctrl Z'],
|
|
419
|
-
command:
|
|
482
|
+
command: NotebookCommandIds.undo,
|
|
420
483
|
},
|
|
421
484
|
{
|
|
422
485
|
selector: '.jp-Notebook',
|
|
423
486
|
keys: ['Ctrl Y'],
|
|
424
|
-
command:
|
|
487
|
+
command: NotebookCommandIds.redo,
|
|
425
488
|
},
|
|
426
489
|
{
|
|
427
490
|
selector: '.jp-Notebook:focus',
|
|
428
491
|
keys: ['M'],
|
|
429
|
-
command:
|
|
492
|
+
command: NotebookCommandIds.changeCellTypeToMarkdown,
|
|
430
493
|
},
|
|
431
494
|
{
|
|
432
495
|
selector: '.jp-Notebook:focus',
|
|
433
496
|
keys: ['R'],
|
|
434
|
-
command:
|
|
497
|
+
command: NotebookCommandIds.changeCellTypeToRaw,
|
|
435
498
|
},
|
|
436
499
|
{
|
|
437
500
|
selector: '.jp-Notebook:focus',
|
|
438
501
|
keys: ['Y'],
|
|
439
|
-
command:
|
|
502
|
+
command: NotebookCommandIds.changeCellTypeToCode,
|
|
440
503
|
},
|
|
441
504
|
];
|
|
442
|
-
bindings.
|
|
443
|
-
|
|
444
|
-
|
|
505
|
+
bindings.forEach(binding => allCommands.add(commandRegistry.addKeyBinding(binding)));
|
|
506
|
+
return allCommands;
|
|
507
|
+
}
|
|
508
|
+
export default addNotebookCommands;
|
|
445
509
|
//# sourceMappingURL=NotebookCommands.js.map
|