@jupyter-notebook/application-extension 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +253 -106
- package/package.json +19 -20
- package/schema/menus.json +44 -1
- package/schema/pages.json +24 -0
- package/schema/title.json +10 -0
- package/schema/top.json +13 -0
- package/schema/zen.json +20 -0
- package/style/base.css +15 -0
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { ILabStatus, IRouter, ITreePathUpdater, JupyterFrontEnd
|
|
4
|
-
import { sessionContextDialogs, ISessionContextDialogs, DOMUtils, ICommandPalette } from '@jupyterlab/apputils';
|
|
3
|
+
import { ILabStatus, IRouter, ITreePathUpdater, JupyterFrontEnd } from '@jupyterlab/application';
|
|
4
|
+
import { sessionContextDialogs, ISessionContextDialogs, DOMUtils, ICommandPalette, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
|
|
5
5
|
import { ConsolePanel } from '@jupyterlab/console';
|
|
6
6
|
import { PageConfig, PathExt, URLExt } from '@jupyterlab/coreutils';
|
|
7
7
|
import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
|
|
@@ -9,19 +9,11 @@ import { DocumentWidget } from '@jupyterlab/docregistry';
|
|
|
9
9
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
10
10
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
11
11
|
import { ITranslator } from '@jupyterlab/translation';
|
|
12
|
-
import { NotebookApp, NotebookShell, INotebookShell } from '@jupyter-notebook/application';
|
|
12
|
+
import { NotebookApp, NotebookShell, INotebookShell, SidePanelPalette } from '@jupyter-notebook/application';
|
|
13
13
|
import { jupyterIcon } from '@jupyter-notebook/ui-components';
|
|
14
14
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
15
15
|
import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
|
|
16
|
-
import { Widget } from '@lumino/widgets';
|
|
17
|
-
/**
|
|
18
|
-
* The default notebook factory.
|
|
19
|
-
*/
|
|
20
|
-
const NOTEBOOK_FACTORY = 'Notebook';
|
|
21
|
-
/**
|
|
22
|
-
* The editor factory.
|
|
23
|
-
*/
|
|
24
|
-
const EDITOR_FACTORY = 'Editor';
|
|
16
|
+
import { Menu, Widget } from '@lumino/widgets';
|
|
25
17
|
/**
|
|
26
18
|
* A regular expression to match path to notebooks and documents
|
|
27
19
|
*/
|
|
@@ -39,6 +31,10 @@ var CommandIDs;
|
|
|
39
31
|
* Toggle Top Bar visibility
|
|
40
32
|
*/
|
|
41
33
|
CommandIDs.toggleTop = 'application:toggle-top';
|
|
34
|
+
/**
|
|
35
|
+
* Toggle side panel visibility
|
|
36
|
+
*/
|
|
37
|
+
CommandIDs.togglePanel = 'application:toggle-panel';
|
|
42
38
|
/**
|
|
43
39
|
* Toggle the Zen mode
|
|
44
40
|
*/
|
|
@@ -98,7 +94,8 @@ const logo = {
|
|
|
98
94
|
elementPosition: 'center',
|
|
99
95
|
padding: '2px 2px 2px 8px',
|
|
100
96
|
height: '28px',
|
|
101
|
-
width: 'auto'
|
|
97
|
+
width: 'auto',
|
|
98
|
+
cursor: 'pointer'
|
|
102
99
|
});
|
|
103
100
|
logo.id = 'jp-NotebookLogo';
|
|
104
101
|
app.shell.add(logo, 'top', { rank: 0 });
|
|
@@ -116,7 +113,7 @@ const opener = {
|
|
|
116
113
|
const command = 'router:tree';
|
|
117
114
|
commands.addCommand(command, {
|
|
118
115
|
execute: (args) => {
|
|
119
|
-
var _a;
|
|
116
|
+
var _a, _b;
|
|
120
117
|
const parsed = args;
|
|
121
118
|
const matches = (_a = parsed.path.match(TREE_PATTERN)) !== null && _a !== void 0 ? _a : [];
|
|
122
119
|
const [, , path] = matches;
|
|
@@ -124,19 +121,12 @@ const opener = {
|
|
|
124
121
|
return;
|
|
125
122
|
}
|
|
126
123
|
const file = decodeURIComponent(path);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
docManager.open(file, EDITOR_FACTORY, undefined, {
|
|
137
|
-
ref: '_noref'
|
|
138
|
-
});
|
|
139
|
-
}
|
|
124
|
+
const urlParams = new URLSearchParams(parsed.search);
|
|
125
|
+
const factory = (_b = urlParams.get('factory')) !== null && _b !== void 0 ? _b : 'default';
|
|
126
|
+
app.started.then(async () => {
|
|
127
|
+
docManager.open(file, factory, undefined, {
|
|
128
|
+
ref: '_noref'
|
|
129
|
+
});
|
|
140
130
|
});
|
|
141
131
|
}
|
|
142
132
|
});
|
|
@@ -145,8 +135,6 @@ const opener = {
|
|
|
145
135
|
};
|
|
146
136
|
/**
|
|
147
137
|
* A plugin to customize menus
|
|
148
|
-
*
|
|
149
|
-
* TODO: use this plugin to customize the menu items and their order
|
|
150
138
|
*/
|
|
151
139
|
const menus = {
|
|
152
140
|
id: '@jupyter-notebook/application-extension:menus',
|
|
@@ -173,6 +161,19 @@ const menus = {
|
|
|
173
161
|
}
|
|
174
162
|
}
|
|
175
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* A plugin to provide a spacer at rank 900 in the menu area
|
|
166
|
+
*/
|
|
167
|
+
const menuSpacer = {
|
|
168
|
+
id: '@jupyter-notebook/application-extension:menu-spacer',
|
|
169
|
+
autoStart: true,
|
|
170
|
+
activate: (app) => {
|
|
171
|
+
const menu = new Widget();
|
|
172
|
+
menu.id = DOMUtils.createDomID();
|
|
173
|
+
menu.addClass('jp-NotebookSpacer');
|
|
174
|
+
app.shell.add(menu, 'menu', { rank: 900 });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
176
177
|
/**
|
|
177
178
|
* Add commands to open the tree and running pages.
|
|
178
179
|
*/
|
|
@@ -180,8 +181,8 @@ const pages = {
|
|
|
180
181
|
id: '@jupyter-notebook/application-extension:pages',
|
|
181
182
|
autoStart: true,
|
|
182
183
|
requires: [ITranslator],
|
|
183
|
-
optional: [ICommandPalette
|
|
184
|
-
activate: (app, translator, palette
|
|
184
|
+
optional: [ICommandPalette],
|
|
185
|
+
activate: (app, translator, palette) => {
|
|
185
186
|
const trans = translator.load('notebook');
|
|
186
187
|
const baseUrl = PageConfig.getBaseUrl();
|
|
187
188
|
app.commands.addCommand(CommandIDs.openLab, {
|
|
@@ -190,19 +191,21 @@ const pages = {
|
|
|
190
191
|
window.open(`${baseUrl}lab`);
|
|
191
192
|
}
|
|
192
193
|
});
|
|
194
|
+
const page = PageConfig.getOption('notebookPage');
|
|
193
195
|
app.commands.addCommand(CommandIDs.openTree, {
|
|
194
|
-
label: trans.__('
|
|
196
|
+
label: trans.__('File Browser'),
|
|
195
197
|
execute: () => {
|
|
196
|
-
|
|
198
|
+
if (page === 'tree') {
|
|
199
|
+
app.commands.execute('filebrowser:activate');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
window.open(`${baseUrl}tree`);
|
|
203
|
+
}
|
|
197
204
|
}
|
|
198
205
|
});
|
|
199
206
|
if (palette) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (menu) {
|
|
205
|
-
menu.viewMenu.addGroup([{ command: CommandIDs.openLab }, { command: CommandIDs.openTree }], 0);
|
|
207
|
+
palette.addItem({ command: CommandIDs.openLab, category: 'View' });
|
|
208
|
+
palette.addItem({ command: CommandIDs.openTree, category: 'View' });
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
};
|
|
@@ -220,29 +223,6 @@ const paths = {
|
|
|
220
223
|
return app.paths;
|
|
221
224
|
}
|
|
222
225
|
};
|
|
223
|
-
/**
|
|
224
|
-
* The default URL router provider.
|
|
225
|
-
*/
|
|
226
|
-
const router = {
|
|
227
|
-
id: '@jupyter-notebook/application-extension:router',
|
|
228
|
-
autoStart: true,
|
|
229
|
-
provides: IRouter,
|
|
230
|
-
requires: [JupyterFrontEnd.IPaths],
|
|
231
|
-
activate: (app, paths) => {
|
|
232
|
-
const { commands } = app;
|
|
233
|
-
const base = paths.urls.base;
|
|
234
|
-
const router = new Router({ base, commands });
|
|
235
|
-
void app.started.then(() => {
|
|
236
|
-
// Route the very first request on load.
|
|
237
|
-
void router.route();
|
|
238
|
-
// Route all pop state events.
|
|
239
|
-
window.addEventListener('popstate', () => {
|
|
240
|
-
void router.route();
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
return router;
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
226
|
/**
|
|
247
227
|
* The default session dialogs plugin
|
|
248
228
|
*/
|
|
@@ -266,25 +246,6 @@ const shell = {
|
|
|
266
246
|
autoStart: true,
|
|
267
247
|
provides: INotebookShell
|
|
268
248
|
};
|
|
269
|
-
/**
|
|
270
|
-
* A plugin to provide a spacer at rank 900 for flex panels
|
|
271
|
-
* TODO: reuse upstream @jupyterlab/application-extension:top-spacer plugin when fixed
|
|
272
|
-
* in https://github.com/jupyterlab/jupyterlab/pull/11900
|
|
273
|
-
*/
|
|
274
|
-
const spacer = {
|
|
275
|
-
id: '@jupyter-notebook/application-extension:spacer',
|
|
276
|
-
autoStart: true,
|
|
277
|
-
activate: (app) => {
|
|
278
|
-
const top = new Widget();
|
|
279
|
-
top.id = DOMUtils.createDomID();
|
|
280
|
-
top.addClass('jp-NotebookSpacer');
|
|
281
|
-
app.shell.add(top, 'top', { rank: 900 });
|
|
282
|
-
const menu = new Widget();
|
|
283
|
-
menu.id = DOMUtils.createDomID();
|
|
284
|
-
menu.addClass('jp-NotebookSpacer');
|
|
285
|
-
app.shell.add(menu, 'menu', { rank: 900 });
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
249
|
/**
|
|
289
250
|
* The default JupyterLab application status provider.
|
|
290
251
|
*/
|
|
@@ -340,25 +301,30 @@ const title = {
|
|
|
340
301
|
id: '@jupyter-notebook/application-extension:title',
|
|
341
302
|
autoStart: true,
|
|
342
303
|
requires: [INotebookShell, ITranslator],
|
|
343
|
-
optional: [IDocumentManager, IRouter],
|
|
344
|
-
activate: (app, shell, translator, docManager, router) => {
|
|
304
|
+
optional: [IDocumentManager, IRouter, IToolbarWidgetRegistry],
|
|
305
|
+
activate: (app, shell, translator, docManager, router, toolbarRegistry) => {
|
|
345
306
|
const { commands } = app;
|
|
346
307
|
const trans = translator.load('notebook');
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
308
|
+
const node = document.createElement('div');
|
|
309
|
+
if (toolbarRegistry) {
|
|
310
|
+
toolbarRegistry.addFactory('TopBar', 'widgetTitle', toolbar => {
|
|
311
|
+
const widget = new Widget({ node });
|
|
312
|
+
widget.id = 'jp-title';
|
|
313
|
+
return widget;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
350
316
|
const addTitle = async () => {
|
|
351
317
|
const current = shell.currentWidget;
|
|
352
318
|
if (!current || !(current instanceof DocumentWidget)) {
|
|
353
319
|
return;
|
|
354
320
|
}
|
|
355
|
-
if (
|
|
321
|
+
if (node.children.length > 0) {
|
|
356
322
|
return;
|
|
357
323
|
}
|
|
358
324
|
const h = document.createElement('h1');
|
|
359
325
|
h.textContent = current.title.label.replace(STRIP_IPYNB, '');
|
|
360
|
-
|
|
361
|
-
|
|
326
|
+
node.appendChild(h);
|
|
327
|
+
node.style.marginLeft = '10px';
|
|
362
328
|
if (!docManager) {
|
|
363
329
|
return;
|
|
364
330
|
}
|
|
@@ -370,11 +336,11 @@ const title = {
|
|
|
370
336
|
label: () => trans.__('Rename…'),
|
|
371
337
|
isEnabled,
|
|
372
338
|
execute: async () => {
|
|
373
|
-
var _a
|
|
339
|
+
var _a;
|
|
374
340
|
if (!isEnabled()) {
|
|
375
341
|
return;
|
|
376
342
|
}
|
|
377
|
-
const result = await renameDialog(docManager, current.context
|
|
343
|
+
const result = await renameDialog(docManager, current.context);
|
|
378
344
|
// activate the current widget to bring the focus
|
|
379
345
|
if (current) {
|
|
380
346
|
current.activate();
|
|
@@ -382,13 +348,13 @@ const title = {
|
|
|
382
348
|
if (result === null) {
|
|
383
349
|
return;
|
|
384
350
|
}
|
|
385
|
-
const newPath =
|
|
351
|
+
const newPath = current.context.path;
|
|
386
352
|
const basename = PathExt.basename(newPath);
|
|
387
353
|
h.textContent = basename.replace(STRIP_IPYNB, '');
|
|
388
354
|
if (!router) {
|
|
389
355
|
return;
|
|
390
356
|
}
|
|
391
|
-
const matches = (
|
|
357
|
+
const matches = (_a = router.current.path.match(TREE_PATTERN)) !== null && _a !== void 0 ? _a : [];
|
|
392
358
|
const [, route, path] = matches;
|
|
393
359
|
if (!route || !path) {
|
|
394
360
|
return;
|
|
@@ -399,7 +365,7 @@ const title = {
|
|
|
399
365
|
});
|
|
400
366
|
}
|
|
401
367
|
});
|
|
402
|
-
|
|
368
|
+
node.onclick = async () => {
|
|
403
369
|
void commands.execute(CommandIDs.rename);
|
|
404
370
|
};
|
|
405
371
|
};
|
|
@@ -413,8 +379,8 @@ const title = {
|
|
|
413
379
|
const topVisibility = {
|
|
414
380
|
id: '@jupyter-notebook/application-extension:top',
|
|
415
381
|
requires: [INotebookShell, ITranslator],
|
|
416
|
-
optional: [
|
|
417
|
-
activate: (app, notebookShell, translator,
|
|
382
|
+
optional: [ISettingRegistry, ICommandPalette],
|
|
383
|
+
activate: (app, notebookShell, translator, settingRegistry, palette) => {
|
|
418
384
|
const trans = translator.load('notebook');
|
|
419
385
|
const top = notebookShell.top;
|
|
420
386
|
const pluginId = topVisibility.id;
|
|
@@ -428,9 +394,6 @@ const topVisibility = {
|
|
|
428
394
|
},
|
|
429
395
|
isToggled: () => top.isVisible
|
|
430
396
|
});
|
|
431
|
-
if (menu) {
|
|
432
|
-
menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
|
|
433
|
-
}
|
|
434
397
|
let settingsOverride = false;
|
|
435
398
|
if (settingRegistry) {
|
|
436
399
|
const loadSettings = settingRegistry.load(pluginId);
|
|
@@ -452,6 +415,9 @@ const topVisibility = {
|
|
|
452
415
|
console.error(reason.message);
|
|
453
416
|
});
|
|
454
417
|
}
|
|
418
|
+
if (palette) {
|
|
419
|
+
palette.addItem({ command: CommandIDs.toggleTop, category: 'View' });
|
|
420
|
+
}
|
|
455
421
|
const onChanged = () => {
|
|
456
422
|
if (settingsOverride) {
|
|
457
423
|
return;
|
|
@@ -468,6 +434,190 @@ const topVisibility = {
|
|
|
468
434
|
},
|
|
469
435
|
autoStart: true
|
|
470
436
|
};
|
|
437
|
+
/**
|
|
438
|
+
* Plugin to toggle the left or right side panel's visibility.
|
|
439
|
+
*/
|
|
440
|
+
const sidePanelVisibility = {
|
|
441
|
+
id: '@jupyter-notebook/application-extension:sidepanel',
|
|
442
|
+
requires: [INotebookShell, ITranslator],
|
|
443
|
+
optional: [IMainMenu, ICommandPalette],
|
|
444
|
+
autoStart: true,
|
|
445
|
+
activate: (app, notebookShell, translator, menu, palette) => {
|
|
446
|
+
const trans = translator.load('notebook');
|
|
447
|
+
/* Arguments for togglePanel command:
|
|
448
|
+
* side, left or right area
|
|
449
|
+
* title, widget title to show in the menu
|
|
450
|
+
* id, widget ID to activate in the side panel
|
|
451
|
+
*/
|
|
452
|
+
app.commands.addCommand(CommandIDs.togglePanel, {
|
|
453
|
+
label: args => args['title'],
|
|
454
|
+
caption: args => {
|
|
455
|
+
// We do not substitute the parameter into the string because the parameter is not
|
|
456
|
+
// localized (e.g., it is always 'left') even though the string is localized.
|
|
457
|
+
if (args['side'] === 'left') {
|
|
458
|
+
return trans.__('Show %1 in the left sidebar', args['title']);
|
|
459
|
+
}
|
|
460
|
+
else if (args['side'] === 'right') {
|
|
461
|
+
return trans.__('Show %1 in the right sidebar', args['title']);
|
|
462
|
+
}
|
|
463
|
+
return trans.__('Show %1 in the sidebar', args['title']);
|
|
464
|
+
},
|
|
465
|
+
execute: args => {
|
|
466
|
+
var _a, _b;
|
|
467
|
+
switch (args['side']) {
|
|
468
|
+
case 'left':
|
|
469
|
+
if (notebookShell.leftCollapsed) {
|
|
470
|
+
notebookShell.expandLeft(args.id);
|
|
471
|
+
}
|
|
472
|
+
else if (((_a = notebookShell.leftHandler.currentWidget) === null || _a === void 0 ? void 0 : _a.id) !== args.id) {
|
|
473
|
+
notebookShell.expandLeft(args.id);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
notebookShell.collapseLeft();
|
|
477
|
+
if (notebookShell.currentWidget) {
|
|
478
|
+
notebookShell.activateById(notebookShell.currentWidget.id);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
case 'right':
|
|
483
|
+
if (notebookShell.rightCollapsed) {
|
|
484
|
+
notebookShell.expandRight(args.id);
|
|
485
|
+
}
|
|
486
|
+
else if (((_b = notebookShell.rightHandler.currentWidget) === null || _b === void 0 ? void 0 : _b.id) !== args.id) {
|
|
487
|
+
notebookShell.expandRight(args.id);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
notebookShell.collapseRight();
|
|
491
|
+
if (notebookShell.currentWidget) {
|
|
492
|
+
notebookShell.activateById(notebookShell.currentWidget.id);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
isToggled: args => {
|
|
499
|
+
switch (args['side']) {
|
|
500
|
+
case 'left': {
|
|
501
|
+
if (notebookShell.leftCollapsed) {
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
const currentWidget = notebookShell.leftHandler.currentWidget;
|
|
505
|
+
if (!currentWidget) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
return currentWidget.id === args['id'];
|
|
509
|
+
}
|
|
510
|
+
case 'right': {
|
|
511
|
+
if (notebookShell.rightCollapsed) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
const currentWidget = notebookShell.rightHandler.currentWidget;
|
|
515
|
+
if (!currentWidget) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
return currentWidget.id === args['id'];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
const sidePanelMenu = {
|
|
525
|
+
left: null,
|
|
526
|
+
right: null
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* The function which adds entries to the View menu for each widget of a side panel.
|
|
530
|
+
*
|
|
531
|
+
* @param area - 'left' or 'right', the area of the side panel.
|
|
532
|
+
* @param entryLabel - the name of the main entry in the View menu for that side panel.
|
|
533
|
+
* @returns - The disposable menu added to the View menu or null.
|
|
534
|
+
*/
|
|
535
|
+
const updateMenu = (area, entryLabel) => {
|
|
536
|
+
var _a;
|
|
537
|
+
if (menu === null) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
// Remove the previous menu entry for this side panel.
|
|
541
|
+
(_a = sidePanelMenu[area]) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
542
|
+
// Creates a new menu entry and populates it with side panel widgets.
|
|
543
|
+
const newMenu = new Menu({ commands: app.commands });
|
|
544
|
+
newMenu.title.label = entryLabel;
|
|
545
|
+
const widgets = notebookShell.widgets(area);
|
|
546
|
+
let menuToAdd = false;
|
|
547
|
+
for (const widget of widgets) {
|
|
548
|
+
newMenu.addItem({
|
|
549
|
+
command: CommandIDs.togglePanel,
|
|
550
|
+
args: {
|
|
551
|
+
side: area,
|
|
552
|
+
title: `Show ${widget.title.caption}`,
|
|
553
|
+
id: widget.id
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
menuToAdd = true;
|
|
557
|
+
}
|
|
558
|
+
// If there are widgets, add the menu to the main menu entry.
|
|
559
|
+
if (menuToAdd) {
|
|
560
|
+
sidePanelMenu[area] = menu.viewMenu.addItem({
|
|
561
|
+
type: 'submenu',
|
|
562
|
+
submenu: newMenu
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
app.restored.then(() => {
|
|
567
|
+
// Create menu entries for the left and right panel.
|
|
568
|
+
if (menu) {
|
|
569
|
+
const getSidePanelLabel = (area) => {
|
|
570
|
+
if (area === 'left') {
|
|
571
|
+
return trans.__('Left Sidebar');
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
return trans.__('Right Sidebar');
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
const leftArea = notebookShell.leftHandler.area;
|
|
578
|
+
const leftLabel = getSidePanelLabel(leftArea);
|
|
579
|
+
updateMenu(leftArea, leftLabel);
|
|
580
|
+
const rightArea = notebookShell.rightHandler.area;
|
|
581
|
+
const rightLabel = getSidePanelLabel(rightArea);
|
|
582
|
+
updateMenu(rightArea, rightLabel);
|
|
583
|
+
const handleSidePanelChange = (sidePanel, widget) => {
|
|
584
|
+
const label = getSidePanelLabel(sidePanel.area);
|
|
585
|
+
updateMenu(sidePanel.area, label);
|
|
586
|
+
};
|
|
587
|
+
notebookShell.leftHandler.widgetAdded.connect(handleSidePanelChange);
|
|
588
|
+
notebookShell.leftHandler.widgetRemoved.connect(handleSidePanelChange);
|
|
589
|
+
notebookShell.rightHandler.widgetAdded.connect(handleSidePanelChange);
|
|
590
|
+
notebookShell.rightHandler.widgetRemoved.connect(handleSidePanelChange);
|
|
591
|
+
}
|
|
592
|
+
// Add palette entries for side panels.
|
|
593
|
+
if (palette) {
|
|
594
|
+
const sidePanelPalette = new SidePanelPalette({
|
|
595
|
+
commandPalette: palette,
|
|
596
|
+
command: CommandIDs.togglePanel
|
|
597
|
+
});
|
|
598
|
+
notebookShell.leftHandler.widgets.forEach(widget => {
|
|
599
|
+
sidePanelPalette.addItem(widget, notebookShell.leftHandler.area);
|
|
600
|
+
});
|
|
601
|
+
notebookShell.rightHandler.widgets.forEach(widget => {
|
|
602
|
+
sidePanelPalette.addItem(widget, notebookShell.rightHandler.area);
|
|
603
|
+
});
|
|
604
|
+
// Update menu and palette when widgets are added or removed from side panels.
|
|
605
|
+
notebookShell.leftHandler.widgetAdded.connect((sidePanel, widget) => {
|
|
606
|
+
sidePanelPalette.addItem(widget, sidePanel.area);
|
|
607
|
+
});
|
|
608
|
+
notebookShell.leftHandler.widgetRemoved.connect((sidePanel, widget) => {
|
|
609
|
+
sidePanelPalette.removeItem(widget, sidePanel.area);
|
|
610
|
+
});
|
|
611
|
+
notebookShell.rightHandler.widgetAdded.connect((sidePanel, widget) => {
|
|
612
|
+
sidePanelPalette.addItem(widget, sidePanel.area);
|
|
613
|
+
});
|
|
614
|
+
notebookShell.rightHandler.widgetRemoved.connect((sidePanel, widget) => {
|
|
615
|
+
sidePanelPalette.removeItem(widget, sidePanel.area);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
};
|
|
471
621
|
/**
|
|
472
622
|
* The default tree route resolver plugin.
|
|
473
623
|
*/
|
|
@@ -537,8 +687,8 @@ const zen = {
|
|
|
537
687
|
id: '@jupyter-notebook/application-extension:zen',
|
|
538
688
|
autoStart: true,
|
|
539
689
|
requires: [ITranslator],
|
|
540
|
-
optional: [ICommandPalette, INotebookShell
|
|
541
|
-
activate: (app, translator, palette, notebookShell
|
|
690
|
+
optional: [ICommandPalette, INotebookShell],
|
|
691
|
+
activate: (app, translator, palette, notebookShell) => {
|
|
542
692
|
const { commands } = app;
|
|
543
693
|
const elem = document.documentElement;
|
|
544
694
|
const trans = translator.load('notebook');
|
|
@@ -574,9 +724,6 @@ const zen = {
|
|
|
574
724
|
if (palette) {
|
|
575
725
|
palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
|
|
576
726
|
}
|
|
577
|
-
if (menu) {
|
|
578
|
-
menu.viewMenu.addGroup([{ command: CommandIDs.toggleZen }], 3);
|
|
579
|
-
}
|
|
580
727
|
}
|
|
581
728
|
};
|
|
582
729
|
/**
|
|
@@ -586,13 +733,13 @@ const plugins = [
|
|
|
586
733
|
dirty,
|
|
587
734
|
logo,
|
|
588
735
|
menus,
|
|
736
|
+
menuSpacer,
|
|
589
737
|
opener,
|
|
590
738
|
pages,
|
|
591
739
|
paths,
|
|
592
|
-
router,
|
|
593
740
|
sessionDialogs,
|
|
594
741
|
shell,
|
|
595
|
-
|
|
742
|
+
sidePanelVisibility,
|
|
596
743
|
status,
|
|
597
744
|
tabTitle,
|
|
598
745
|
title,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/application-extension",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.11",
|
|
4
4
|
"description": "Jupyter Notebook - Application Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -39,27 +39,26 @@
|
|
|
39
39
|
"watch": "tsc -b --watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@jupyter-notebook/application": "^7.0.0-alpha.
|
|
43
|
-
"@jupyter-notebook/ui-components": "^7.0.0-alpha.
|
|
44
|
-
"@jupyterlab/application": "^4.0.0-alpha.
|
|
45
|
-
"@jupyterlab/apputils": "^4.0.0-alpha.
|
|
46
|
-
"@jupyterlab/celltags": "^4.0.0-alpha.
|
|
47
|
-
"@jupyterlab/codeeditor": "^4.0.0-alpha.
|
|
48
|
-
"@jupyterlab/
|
|
49
|
-
"@jupyterlab/
|
|
50
|
-
"@jupyterlab/
|
|
51
|
-
"@jupyterlab/
|
|
52
|
-
"@jupyterlab/
|
|
53
|
-
"@jupyterlab/
|
|
54
|
-
"@jupyterlab/
|
|
55
|
-
"@
|
|
56
|
-
"@lumino/
|
|
57
|
-
"@lumino/
|
|
58
|
-
"@lumino/widgets": "^1.31.1"
|
|
42
|
+
"@jupyter-notebook/application": "^7.0.0-alpha.11",
|
|
43
|
+
"@jupyter-notebook/ui-components": "^7.0.0-alpha.11",
|
|
44
|
+
"@jupyterlab/application": "^4.0.0-alpha.17",
|
|
45
|
+
"@jupyterlab/apputils": "^4.0.0-alpha.17",
|
|
46
|
+
"@jupyterlab/celltags": "^4.0.0-alpha.17",
|
|
47
|
+
"@jupyterlab/codeeditor": "^4.0.0-alpha.17",
|
|
48
|
+
"@jupyterlab/console": "^4.0.0-alpha.17",
|
|
49
|
+
"@jupyterlab/coreutils": "^6.0.0-alpha.17",
|
|
50
|
+
"@jupyterlab/docmanager": "^4.0.0-alpha.17",
|
|
51
|
+
"@jupyterlab/docregistry": "^4.0.0-alpha.17",
|
|
52
|
+
"@jupyterlab/mainmenu": "^4.0.0-alpha.17",
|
|
53
|
+
"@jupyterlab/settingregistry": "^4.0.0-alpha.17",
|
|
54
|
+
"@jupyterlab/translation": "^4.0.0-alpha.17",
|
|
55
|
+
"@lumino/coreutils": "^2.0.0-alpha.7",
|
|
56
|
+
"@lumino/disposable": "^2.0.0-alpha.7",
|
|
57
|
+
"@lumino/widgets": "^2.0.0-alpha.7"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
|
-
"rimraf": "
|
|
62
|
-
"typescript": "~4.
|
|
60
|
+
"rimraf": "^3.0.2",
|
|
61
|
+
"typescript": "~4.9.3"
|
|
63
62
|
},
|
|
64
63
|
"publishConfig": {
|
|
65
64
|
"access": "public"
|
package/schema/menus.json
CHANGED
|
@@ -8,13 +8,56 @@
|
|
|
8
8
|
"items": [
|
|
9
9
|
{
|
|
10
10
|
"command": "application:rename",
|
|
11
|
-
"rank": 4
|
|
11
|
+
"rank": 4.5
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"command": "notebook:trust",
|
|
15
15
|
"rank": 20
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "jp-mainmenu-view",
|
|
21
|
+
"items": [
|
|
22
|
+
{
|
|
23
|
+
"type": "submenu",
|
|
24
|
+
"disabled": true,
|
|
25
|
+
"submenu": {
|
|
26
|
+
"id": "jp-mainmenu-view-appearance"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "jp-mainmenu-run",
|
|
33
|
+
"items": [
|
|
34
|
+
{
|
|
35
|
+
"type": "separator",
|
|
36
|
+
"rank": 1000
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "submenu",
|
|
40
|
+
"rank": 1010,
|
|
41
|
+
"submenu": {
|
|
42
|
+
"id": "jp-runmenu-change-cell-type",
|
|
43
|
+
"label": "Cell Type",
|
|
44
|
+
"items": [
|
|
45
|
+
{
|
|
46
|
+
"command": "notebook:change-cell-to-code",
|
|
47
|
+
"rank": 0
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"command": "notebook:change-cell-to-markdown",
|
|
51
|
+
"rank": 0
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"command": "notebook:change-cell-to-raw",
|
|
55
|
+
"rank": 0
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
18
61
|
}
|
|
19
62
|
]
|
|
20
63
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Jupyter Notebook Pages",
|
|
3
|
+
"description": "Jupyter Notebook Pages",
|
|
4
|
+
"jupyter.lab.menus": {
|
|
5
|
+
"main": [
|
|
6
|
+
{
|
|
7
|
+
"id": "jp-mainmenu-view",
|
|
8
|
+
"items": [
|
|
9
|
+
{
|
|
10
|
+
"command": "application:open-lab",
|
|
11
|
+
"rank": 2
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"command": "application:open-tree",
|
|
15
|
+
"rank": 2
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"properties": {},
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"type": "object"
|
|
24
|
+
}
|
package/schema/top.json
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
"jupyter.lab.setting-icon-label": "Jupyter Notebook Top Area",
|
|
4
4
|
"title": "Jupyter Notebook Top Area",
|
|
5
5
|
"description": "Jupyter Notebook Top Area settings",
|
|
6
|
+
"jupyter.lab.menus": {
|
|
7
|
+
"main": [
|
|
8
|
+
{
|
|
9
|
+
"id": "jp-mainmenu-view",
|
|
10
|
+
"items": [
|
|
11
|
+
{
|
|
12
|
+
"command": "application:toggle-top",
|
|
13
|
+
"rank": 2
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
6
19
|
"properties": {
|
|
7
20
|
"visible": {
|
|
8
21
|
"type": "boolean",
|
package/schema/zen.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Jupyter Notebook Zen Mode",
|
|
3
|
+
"description": "Jupyter Notebook Zen Mode",
|
|
4
|
+
"jupyter.lab.menus": {
|
|
5
|
+
"main": [
|
|
6
|
+
{
|
|
7
|
+
"id": "jp-mainmenu-view",
|
|
8
|
+
"items": [
|
|
9
|
+
{
|
|
10
|
+
"command": "application:toggle-zen",
|
|
11
|
+
"rank": 3
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"properties": {},
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"type": "object"
|
|
20
|
+
}
|
package/style/base.css
CHANGED
|
@@ -12,3 +12,18 @@
|
|
|
12
12
|
.jp-MainAreaWidget {
|
|
13
13
|
height: 100%;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
.jp-Toolbar > .jp-Toolbar-item {
|
|
17
|
+
height: unset;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#jp-UserMenu {
|
|
21
|
+
flex: 0 0 auto;
|
|
22
|
+
display: flex;
|
|
23
|
+
text-align: center;
|
|
24
|
+
margin-top: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.jp-MimeDocument .jp-RenderedJSON {
|
|
28
|
+
background: var(--jp-layout-color0);
|
|
29
|
+
}
|