@jupyter-notebook/application-extension 7.0.0-alpha.2 → 7.0.0-alpha.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/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
3
  import { ILabStatus, IRouter, ITreePathUpdater, JupyterFrontEnd, Router } from '@jupyterlab/application';
4
- import { sessionContextDialogs, ISessionContextDialogs, DOMUtils, ICommandPalette } from '@jupyterlab/apputils';
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';
@@ -158,6 +158,19 @@ const menus = {
158
158
  }
159
159
  }
160
160
  };
161
+ /**
162
+ * A plugin to provide a spacer at rank 900 in the menu area
163
+ */
164
+ const menuSpacer = {
165
+ id: '@jupyter-notebook/application-extension:menu-spacer',
166
+ autoStart: true,
167
+ activate: (app) => {
168
+ const menu = new Widget();
169
+ menu.id = DOMUtils.createDomID();
170
+ menu.addClass('jp-NotebookSpacer');
171
+ app.shell.add(menu, 'menu', { rank: 900 });
172
+ }
173
+ };
161
174
  /**
162
175
  * Add commands to open the tree and running pages.
163
176
  */
@@ -165,8 +178,8 @@ const pages = {
165
178
  id: '@jupyter-notebook/application-extension:pages',
166
179
  autoStart: true,
167
180
  requires: [ITranslator],
168
- optional: [ICommandPalette, IMainMenu],
169
- activate: (app, translator, palette, menu) => {
181
+ optional: [ICommandPalette],
182
+ activate: (app, translator, palette) => {
170
183
  const trans = translator.load('notebook');
171
184
  const baseUrl = PageConfig.getBaseUrl();
172
185
  app.commands.addCommand(CommandIDs.openLab, {
@@ -186,9 +199,6 @@ const pages = {
186
199
  palette.addItem({ command, category: 'View' });
187
200
  });
188
201
  }
189
- if (menu) {
190
- menu.viewMenu.addGroup([{ command: CommandIDs.openLab }, { command: CommandIDs.openTree }], 0);
191
- }
192
202
  }
193
203
  };
194
204
  /**
@@ -251,25 +261,6 @@ const shell = {
251
261
  autoStart: true,
252
262
  provides: INotebookShell
253
263
  };
254
- /**
255
- * A plugin to provide a spacer at rank 900 for flex panels
256
- * TODO: reuse upstream @jupyterlab/application-extension:top-spacer plugin when fixed
257
- * in https://github.com/jupyterlab/jupyterlab/pull/11900
258
- */
259
- const spacer = {
260
- id: '@jupyter-notebook/application-extension:spacer',
261
- autoStart: true,
262
- activate: (app) => {
263
- const top = new Widget();
264
- top.id = DOMUtils.createDomID();
265
- top.addClass('jp-NotebookSpacer');
266
- app.shell.add(top, 'top', { rank: 900 });
267
- const menu = new Widget();
268
- menu.id = DOMUtils.createDomID();
269
- menu.addClass('jp-NotebookSpacer');
270
- app.shell.add(menu, 'menu', { rank: 900 });
271
- }
272
- };
273
264
  /**
274
265
  * The default JupyterLab application status provider.
275
266
  */
@@ -325,25 +316,30 @@ const title = {
325
316
  id: '@jupyter-notebook/application-extension:title',
326
317
  autoStart: true,
327
318
  requires: [INotebookShell, ITranslator],
328
- optional: [IDocumentManager, IRouter],
329
- activate: (app, shell, translator, docManager, router) => {
319
+ optional: [IDocumentManager, IRouter, IToolbarWidgetRegistry],
320
+ activate: (app, shell, translator, docManager, router, toolbarRegistry) => {
330
321
  const { commands } = app;
331
322
  const trans = translator.load('notebook');
332
- const widget = new Widget();
333
- widget.id = 'jp-title';
334
- app.shell.add(widget, 'top', { rank: 10 });
323
+ const node = document.createElement('div');
324
+ if (toolbarRegistry) {
325
+ toolbarRegistry.addFactory('TopBar', 'widgetTitle', toolbar => {
326
+ const widget = new Widget({ node });
327
+ widget.id = 'jp-title';
328
+ return widget;
329
+ });
330
+ }
335
331
  const addTitle = async () => {
336
332
  const current = shell.currentWidget;
337
333
  if (!current || !(current instanceof DocumentWidget)) {
338
334
  return;
339
335
  }
340
- if (widget.node.children.length > 0) {
336
+ if (node.children.length > 0) {
341
337
  return;
342
338
  }
343
339
  const h = document.createElement('h1');
344
340
  h.textContent = current.title.label.replace(STRIP_IPYNB, '');
345
- widget.node.appendChild(h);
346
- widget.node.style.marginLeft = '10px';
341
+ node.appendChild(h);
342
+ node.style.marginLeft = '10px';
347
343
  if (!docManager) {
348
344
  return;
349
345
  }
@@ -384,7 +380,7 @@ const title = {
384
380
  });
385
381
  }
386
382
  });
387
- widget.node.onclick = async () => {
383
+ node.onclick = async () => {
388
384
  void commands.execute(CommandIDs.rename);
389
385
  };
390
386
  };
@@ -398,8 +394,8 @@ const title = {
398
394
  const topVisibility = {
399
395
  id: '@jupyter-notebook/application-extension:top',
400
396
  requires: [INotebookShell, ITranslator],
401
- optional: [IMainMenu, ISettingRegistry],
402
- activate: (app, notebookShell, translator, menu, settingRegistry) => {
397
+ optional: [ISettingRegistry, ICommandPalette],
398
+ activate: (app, notebookShell, translator, settingRegistry, palette) => {
403
399
  const trans = translator.load('notebook');
404
400
  const top = notebookShell.top;
405
401
  const pluginId = topVisibility.id;
@@ -413,9 +409,6 @@ const topVisibility = {
413
409
  },
414
410
  isToggled: () => top.isVisible
415
411
  });
416
- if (menu) {
417
- menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
418
- }
419
412
  let settingsOverride = false;
420
413
  if (settingRegistry) {
421
414
  const loadSettings = settingRegistry.load(pluginId);
@@ -437,6 +430,9 @@ const topVisibility = {
437
430
  console.error(reason.message);
438
431
  });
439
432
  }
433
+ if (palette) {
434
+ palette.addItem({ command: CommandIDs.toggleTop, category: 'View' });
435
+ }
440
436
  const onChanged = () => {
441
437
  if (settingsOverride) {
442
438
  return;
@@ -522,8 +518,8 @@ const zen = {
522
518
  id: '@jupyter-notebook/application-extension:zen',
523
519
  autoStart: true,
524
520
  requires: [ITranslator],
525
- optional: [ICommandPalette, INotebookShell, IMainMenu],
526
- activate: (app, translator, palette, notebookShell, menu) => {
521
+ optional: [ICommandPalette, INotebookShell],
522
+ activate: (app, translator, palette, notebookShell) => {
527
523
  const { commands } = app;
528
524
  const elem = document.documentElement;
529
525
  const trans = translator.load('notebook');
@@ -559,9 +555,6 @@ const zen = {
559
555
  if (palette) {
560
556
  palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
561
557
  }
562
- if (menu) {
563
- menu.viewMenu.addGroup([{ command: CommandIDs.toggleZen }], 3);
564
- }
565
558
  }
566
559
  };
567
560
  /**
@@ -571,13 +564,13 @@ const plugins = [
571
564
  dirty,
572
565
  logo,
573
566
  menus,
567
+ menuSpacer,
574
568
  opener,
575
569
  pages,
576
570
  paths,
577
571
  router,
578
572
  sessionDialogs,
579
573
  shell,
580
- spacer,
581
574
  status,
582
575
  tabTitle,
583
576
  title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/application-extension",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0-alpha.5",
4
4
  "description": "Jupyter Notebook - Application Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -39,27 +39,27 @@
39
39
  "watch": "tsc -b --watch"
40
40
  },
41
41
  "dependencies": {
42
- "@jupyter-notebook/application": "^7.0.0-alpha.2",
43
- "@jupyter-notebook/ui-components": "^7.0.0-alpha.2",
44
- "@jupyterlab/application": "^4.0.0-alpha.7",
45
- "@jupyterlab/apputils": "^4.0.0-alpha.7",
46
- "@jupyterlab/celltags": "^4.0.0-alpha.7",
47
- "@jupyterlab/codeeditor": "^4.0.0-alpha.7",
48
- "@jupyterlab/codemirror": "^4.0.0-alpha.7",
49
- "@jupyterlab/console": "^4.0.0-alpha.7",
50
- "@jupyterlab/coreutils": "^6.0.0-alpha.7",
51
- "@jupyterlab/docmanager": "^4.0.0-alpha.7",
52
- "@jupyterlab/docregistry": "^4.0.0-alpha.7",
53
- "@jupyterlab/mainmenu": "^4.0.0-alpha.7",
54
- "@jupyterlab/settingregistry": "^4.0.0-alpha.7",
55
- "@jupyterlab/translation": "^4.0.0-alpha.7",
42
+ "@jupyter-notebook/application": "^7.0.0-alpha.5",
43
+ "@jupyter-notebook/ui-components": "^7.0.0-alpha.5",
44
+ "@jupyterlab/application": "^4.0.0-alpha.10",
45
+ "@jupyterlab/apputils": "^4.0.0-alpha.10",
46
+ "@jupyterlab/celltags": "^4.0.0-alpha.10",
47
+ "@jupyterlab/codeeditor": "^4.0.0-alpha.10",
48
+ "@jupyterlab/codemirror": "^4.0.0-alpha.10",
49
+ "@jupyterlab/console": "^4.0.0-alpha.10",
50
+ "@jupyterlab/coreutils": "^6.0.0-alpha.10",
51
+ "@jupyterlab/docmanager": "^4.0.0-alpha.10",
52
+ "@jupyterlab/docregistry": "^4.0.0-alpha.10",
53
+ "@jupyterlab/mainmenu": "^4.0.0-alpha.10",
54
+ "@jupyterlab/settingregistry": "^4.0.0-alpha.10",
55
+ "@jupyterlab/translation": "^4.0.0-alpha.10",
56
56
  "@lumino/coreutils": "^1.12.0",
57
57
  "@lumino/disposable": "^1.10.1",
58
- "@lumino/widgets": "^1.31.1"
58
+ "@lumino/widgets": "^1.32.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "rimraf": "~3.0.0",
62
- "typescript": "~4.1.3"
62
+ "typescript": "~4.6.3"
63
63
  },
64
64
  "publishConfig": {
65
65
  "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
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Title widget",
3
+ "description": "Title widget",
4
+ "jupyter.lab.toolbars": {
5
+ "TopBar": [{ "name": "widgetTitle", "rank": 10 }]
6
+ },
7
+ "properties": {},
8
+ "additionalProperties": false,
9
+ "type": "object"
10
+ }
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",
@@ -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,7 @@
12
12
  .jp-MainAreaWidget {
13
13
  height: 100%;
14
14
  }
15
+
16
+ .jp-Toolbar > .jp-Toolbar-item {
17
+ height: unset;
18
+ }