@jupyter-notebook/application-extension 7.0.0-alpha.1 → 7.0.0-alpha.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/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';
@@ -14,14 +14,6 @@ import { jupyterIcon } from '@jupyter-notebook/ui-components';
14
14
  import { PromiseDelegate } from '@lumino/coreutils';
15
15
  import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
16
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';
25
17
  /**
26
18
  * A regular expression to match path to notebooks and documents
27
19
  */
@@ -116,7 +108,7 @@ const opener = {
116
108
  const command = 'router:tree';
117
109
  commands.addCommand(command, {
118
110
  execute: (args) => {
119
- var _a;
111
+ var _a, _b;
120
112
  const parsed = args;
121
113
  const matches = (_a = parsed.path.match(TREE_PATTERN)) !== null && _a !== void 0 ? _a : [];
122
114
  const [, , path] = matches;
@@ -124,19 +116,12 @@ const opener = {
124
116
  return;
125
117
  }
126
118
  const file = decodeURIComponent(path);
127
- const ext = PathExt.extname(file);
119
+ const urlParams = new URLSearchParams(parsed.search);
120
+ const factory = (_b = urlParams.get('factory')) !== null && _b !== void 0 ? _b : 'default';
128
121
  app.restored.then(async () => {
129
- // TODO: get factory from file type instead?
130
- if (ext === '.ipynb') {
131
- docManager.open(file, NOTEBOOK_FACTORY, undefined, {
132
- ref: '_noref'
133
- });
134
- }
135
- else {
136
- docManager.open(file, EDITOR_FACTORY, undefined, {
137
- ref: '_noref'
138
- });
139
- }
122
+ docManager.open(file, factory, undefined, {
123
+ ref: '_noref'
124
+ });
140
125
  });
141
126
  }
142
127
  });
@@ -173,6 +158,19 @@ const menus = {
173
158
  }
174
159
  }
175
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
+ };
176
174
  /**
177
175
  * Add commands to open the tree and running pages.
178
176
  */
@@ -180,8 +178,8 @@ const pages = {
180
178
  id: '@jupyter-notebook/application-extension:pages',
181
179
  autoStart: true,
182
180
  requires: [ITranslator],
183
- optional: [ICommandPalette, IMainMenu],
184
- activate: (app, translator, palette, menu) => {
181
+ optional: [ICommandPalette],
182
+ activate: (app, translator, palette) => {
185
183
  const trans = translator.load('notebook');
186
184
  const baseUrl = PageConfig.getBaseUrl();
187
185
  app.commands.addCommand(CommandIDs.openLab, {
@@ -201,9 +199,6 @@ const pages = {
201
199
  palette.addItem({ command, category: 'View' });
202
200
  });
203
201
  }
204
- if (menu) {
205
- menu.viewMenu.addGroup([{ command: CommandIDs.openLab }, { command: CommandIDs.openTree }], 0);
206
- }
207
202
  }
208
203
  };
209
204
  /**
@@ -266,25 +261,6 @@ const shell = {
266
261
  autoStart: true,
267
262
  provides: INotebookShell
268
263
  };
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
264
  /**
289
265
  * The default JupyterLab application status provider.
290
266
  */
@@ -340,25 +316,30 @@ const title = {
340
316
  id: '@jupyter-notebook/application-extension:title',
341
317
  autoStart: true,
342
318
  requires: [INotebookShell, ITranslator],
343
- optional: [IDocumentManager, IRouter],
344
- activate: (app, shell, translator, docManager, router) => {
319
+ optional: [IDocumentManager, IRouter, IToolbarWidgetRegistry],
320
+ activate: (app, shell, translator, docManager, router, toolbarRegistry) => {
345
321
  const { commands } = app;
346
322
  const trans = translator.load('notebook');
347
- const widget = new Widget();
348
- widget.id = 'jp-title';
349
- 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
+ }
350
331
  const addTitle = async () => {
351
332
  const current = shell.currentWidget;
352
333
  if (!current || !(current instanceof DocumentWidget)) {
353
334
  return;
354
335
  }
355
- if (widget.node.children.length > 0) {
336
+ if (node.children.length > 0) {
356
337
  return;
357
338
  }
358
339
  const h = document.createElement('h1');
359
340
  h.textContent = current.title.label.replace(STRIP_IPYNB, '');
360
- widget.node.appendChild(h);
361
- widget.node.style.marginLeft = '10px';
341
+ node.appendChild(h);
342
+ node.style.marginLeft = '10px';
362
343
  if (!docManager) {
363
344
  return;
364
345
  }
@@ -399,7 +380,7 @@ const title = {
399
380
  });
400
381
  }
401
382
  });
402
- widget.node.onclick = async () => {
383
+ node.onclick = async () => {
403
384
  void commands.execute(CommandIDs.rename);
404
385
  };
405
386
  };
@@ -413,8 +394,8 @@ const title = {
413
394
  const topVisibility = {
414
395
  id: '@jupyter-notebook/application-extension:top',
415
396
  requires: [INotebookShell, ITranslator],
416
- optional: [IMainMenu, ISettingRegistry],
417
- activate: (app, notebookShell, translator, menu, settingRegistry) => {
397
+ optional: [ISettingRegistry, ICommandPalette],
398
+ activate: (app, notebookShell, translator, settingRegistry, palette) => {
418
399
  const trans = translator.load('notebook');
419
400
  const top = notebookShell.top;
420
401
  const pluginId = topVisibility.id;
@@ -428,9 +409,6 @@ const topVisibility = {
428
409
  },
429
410
  isToggled: () => top.isVisible
430
411
  });
431
- if (menu) {
432
- menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
433
- }
434
412
  let settingsOverride = false;
435
413
  if (settingRegistry) {
436
414
  const loadSettings = settingRegistry.load(pluginId);
@@ -452,6 +430,9 @@ const topVisibility = {
452
430
  console.error(reason.message);
453
431
  });
454
432
  }
433
+ if (palette) {
434
+ palette.addItem({ command: CommandIDs.toggleTop, category: 'View' });
435
+ }
455
436
  const onChanged = () => {
456
437
  if (settingsOverride) {
457
438
  return;
@@ -537,8 +518,8 @@ const zen = {
537
518
  id: '@jupyter-notebook/application-extension:zen',
538
519
  autoStart: true,
539
520
  requires: [ITranslator],
540
- optional: [ICommandPalette, INotebookShell, IMainMenu],
541
- activate: (app, translator, palette, notebookShell, menu) => {
521
+ optional: [ICommandPalette, INotebookShell],
522
+ activate: (app, translator, palette, notebookShell) => {
542
523
  const { commands } = app;
543
524
  const elem = document.documentElement;
544
525
  const trans = translator.load('notebook');
@@ -574,9 +555,6 @@ const zen = {
574
555
  if (palette) {
575
556
  palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
576
557
  }
577
- if (menu) {
578
- menu.viewMenu.addGroup([{ command: CommandIDs.toggleZen }], 3);
579
- }
580
558
  }
581
559
  };
582
560
  /**
@@ -586,13 +564,13 @@ const plugins = [
586
564
  dirty,
587
565
  logo,
588
566
  menus,
567
+ menuSpacer,
589
568
  opener,
590
569
  pages,
591
570
  paths,
592
571
  router,
593
572
  sessionDialogs,
594
573
  shell,
595
- spacer,
596
574
  status,
597
575
  tabTitle,
598
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.1",
3
+ "version": "7.0.0-alpha.4",
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.1",
43
- "@jupyter-notebook/ui-components": "^7.0.0-alpha.1",
44
- "@jupyterlab/application": "^4.0.0-alpha.5",
45
- "@jupyterlab/apputils": "^4.0.0-alpha.5",
46
- "@jupyterlab/celltags": "^4.0.0-alpha.5",
47
- "@jupyterlab/codeeditor": "^4.0.0-alpha.5",
48
- "@jupyterlab/codemirror": "^4.0.0-alpha.5",
49
- "@jupyterlab/console": "^4.0.0-alpha.5",
50
- "@jupyterlab/coreutils": "^6.0.0-alpha.5",
51
- "@jupyterlab/docmanager": "^4.0.0-alpha.5",
52
- "@jupyterlab/docregistry": "^4.0.0-alpha.5",
53
- "@jupyterlab/mainmenu": "^4.0.0-alpha.5",
54
- "@jupyterlab/settingregistry": "^4.0.0-alpha.5",
55
- "@jupyterlab/translation": "^4.0.0-alpha.4",
42
+ "@jupyter-notebook/application": "^7.0.0-alpha.4",
43
+ "@jupyter-notebook/ui-components": "^7.0.0-alpha.4",
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
+ }