@jupyter-notebook/application-extension 7.0.0-alpha.9 → 7.0.0-beta.1

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.
Files changed (3) hide show
  1. package/lib/index.js +65 -61
  2. package/package.json +18 -19
  3. package/style/base.css +10 -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 } from '@jupyterlab/application';
4
- import { sessionContextDialogs, ISessionContextDialogs, DOMUtils, ICommandPalette, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
3
+ import { ILabStatus, IRouter, ITreePathUpdater, JupyterFrontEnd, } from '@jupyterlab/application';
4
+ import { 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,10 +9,10 @@ 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, SidePanelPalette } 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
- import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
15
+ import { DisposableDelegate, DisposableSet, } from '@lumino/disposable';
16
16
  import { Menu, Widget } from '@lumino/widgets';
17
17
  /**
18
18
  * A regular expression to match path to notebooks and documents
@@ -69,12 +69,12 @@ const dirty = {
69
69
  }
70
70
  const trans = translator.load('notebook');
71
71
  const message = trans.__('Are you sure you want to exit Jupyter Notebook?\n\nAny unsaved changes will be lost.');
72
- window.addEventListener('beforeunload', event => {
72
+ window.addEventListener('beforeunload', (event) => {
73
73
  if (app.status.isDirty) {
74
74
  return (event.returnValue = message);
75
75
  }
76
76
  });
77
- }
77
+ },
78
78
  };
79
79
  /**
80
80
  * The logo plugin.
@@ -95,11 +95,11 @@ const logo = {
95
95
  padding: '2px 2px 2px 8px',
96
96
  height: '28px',
97
97
  width: 'auto',
98
- cursor: 'pointer'
98
+ cursor: 'pointer',
99
99
  });
100
100
  logo.id = 'jp-NotebookLogo';
101
101
  app.shell.add(logo, 'top', { rank: 0 });
102
- }
102
+ },
103
103
  };
104
104
  /**
105
105
  * A plugin to open documents in the main area.
@@ -125,13 +125,13 @@ const opener = {
125
125
  const factory = (_b = urlParams.get('factory')) !== null && _b !== void 0 ? _b : 'default';
126
126
  app.started.then(async () => {
127
127
  docManager.open(file, factory, undefined, {
128
- ref: '_noref'
128
+ ref: '_noref',
129
129
  });
130
130
  });
131
- }
131
+ },
132
132
  });
133
133
  router.register({ command, pattern: TREE_PATTERN });
134
- }
134
+ },
135
135
  };
136
136
  /**
137
137
  * A plugin to customize menus
@@ -159,7 +159,7 @@ const menus = {
159
159
  default:
160
160
  break;
161
161
  }
162
- }
162
+ },
163
163
  };
164
164
  /**
165
165
  * A plugin to provide a spacer at rank 900 in the menu area
@@ -172,7 +172,7 @@ const menuSpacer = {
172
172
  menu.id = DOMUtils.createDomID();
173
173
  menu.addClass('jp-NotebookSpacer');
174
174
  app.shell.add(menu, 'menu', { rank: 900 });
175
- }
175
+ },
176
176
  };
177
177
  /**
178
178
  * Add commands to open the tree and running pages.
@@ -189,20 +189,25 @@ const pages = {
189
189
  label: trans.__('Open JupyterLab'),
190
190
  execute: () => {
191
191
  window.open(`${baseUrl}lab`);
192
- }
192
+ },
193
193
  });
194
+ const page = PageConfig.getOption('notebookPage');
194
195
  app.commands.addCommand(CommandIDs.openTree, {
195
- label: trans.__('Open Files'),
196
+ label: trans.__('File Browser'),
196
197
  execute: () => {
197
- window.open(`${baseUrl}tree`);
198
- }
198
+ if (page === 'tree') {
199
+ app.commands.execute('filebrowser:activate');
200
+ }
201
+ else {
202
+ window.open(`${baseUrl}tree`);
203
+ }
204
+ },
199
205
  });
200
206
  if (palette) {
201
- [CommandIDs.openLab, CommandIDs.openTree].forEach(command => {
202
- palette.addItem({ command, category: 'View' });
203
- });
207
+ palette.addItem({ command: CommandIDs.openLab, category: 'View' });
208
+ palette.addItem({ command: CommandIDs.openTree, category: 'View' });
204
209
  }
205
- }
210
+ },
206
211
  };
207
212
  /**
208
213
  * The default paths for a Jupyter Notebook app.
@@ -216,16 +221,7 @@ const paths = {
216
221
  throw new Error(`${paths.id} must be activated in Jupyter Notebook.`);
217
222
  }
218
223
  return app.paths;
219
- }
220
- };
221
- /**
222
- * The default session dialogs plugin
223
- */
224
- const sessionDialogs = {
225
- id: '@jupyter-notebook/application-extension:session-dialogs',
226
- provides: ISessionContextDialogs,
227
- autoStart: true,
228
- activate: () => sessionContextDialogs
224
+ },
229
225
  };
230
226
  /**
231
227
  * The default Jupyter Notebook application shell.
@@ -239,7 +235,7 @@ const shell = {
239
235
  return app.shell;
240
236
  },
241
237
  autoStart: true,
242
- provides: INotebookShell
238
+ provides: INotebookShell,
243
239
  };
244
240
  /**
245
241
  * The default JupyterLab application status provider.
@@ -253,7 +249,7 @@ const status = {
253
249
  throw new Error(`${status.id} must be activated in Jupyter Notebook.`);
254
250
  }
255
251
  return app.status;
256
- }
252
+ },
257
253
  };
258
254
  /**
259
255
  * A plugin to display the document title in the browser tab title
@@ -287,7 +283,7 @@ const tabTitle = {
287
283
  };
288
284
  shell.currentChanged.connect(setTabTitle);
289
285
  setTabTitle();
290
- }
286
+ },
291
287
  };
292
288
  /**
293
289
  * A plugin to display and rename the title of a file
@@ -302,7 +298,7 @@ const title = {
302
298
  const trans = translator.load('notebook');
303
299
  const node = document.createElement('div');
304
300
  if (toolbarRegistry) {
305
- toolbarRegistry.addFactory('TopBar', 'widgetTitle', toolbar => {
301
+ toolbarRegistry.addFactory('TopBar', 'widgetTitle', (toolbar) => {
306
302
  const widget = new Widget({ node });
307
303
  widget.id = 'jp-title';
308
304
  return widget;
@@ -356,9 +352,9 @@ const title = {
356
352
  }
357
353
  const encoded = encodeURIComponent(newPath);
358
354
  router.navigate(`/${route}/${encoded}`, {
359
- skipRouting: true
355
+ skipRouting: true,
360
356
  });
361
- }
357
+ },
362
358
  });
363
359
  node.onclick = async () => {
364
360
  void commands.execute(CommandIDs.rename);
@@ -366,7 +362,7 @@ const title = {
366
362
  };
367
363
  shell.currentChanged.connect(addTitle);
368
364
  void addTitle();
369
- }
365
+ },
370
366
  };
371
367
  /**
372
368
  * Plugin to toggle the top header visibility.
@@ -387,7 +383,7 @@ const topVisibility = {
387
383
  void settingRegistry.set(pluginId, 'visible', top.isVisible);
388
384
  }
389
385
  },
390
- isToggled: () => top.isVisible
386
+ isToggled: () => top.isVisible,
391
387
  });
392
388
  let settingsOverride = false;
393
389
  if (settingRegistry) {
@@ -402,7 +398,7 @@ const topVisibility = {
402
398
  Promise.all([loadSettings, app.restored])
403
399
  .then(([settings]) => {
404
400
  updateSettings(settings);
405
- settings.changed.connect(settings => {
401
+ settings.changed.connect((settings) => {
406
402
  updateSettings(settings);
407
403
  });
408
404
  })
@@ -427,7 +423,7 @@ const topVisibility = {
427
423
  // listen on format change (mobile and desktop) to make the view more compact
428
424
  app.formatChanged.connect(onChanged);
429
425
  },
430
- autoStart: true
426
+ autoStart: true,
431
427
  };
432
428
  /**
433
429
  * Plugin to toggle the left or right side panel's visibility.
@@ -445,8 +441,8 @@ const sidePanelVisibility = {
445
441
  * id, widget ID to activate in the side panel
446
442
  */
447
443
  app.commands.addCommand(CommandIDs.togglePanel, {
448
- label: args => args['title'],
449
- caption: args => {
444
+ label: (args) => args['title'],
445
+ caption: (args) => {
450
446
  // We do not substitute the parameter into the string because the parameter is not
451
447
  // localized (e.g., it is always 'left') even though the string is localized.
452
448
  if (args['side'] === 'left') {
@@ -457,7 +453,7 @@ const sidePanelVisibility = {
457
453
  }
458
454
  return trans.__('Show %1 in the sidebar', args['title']);
459
455
  },
460
- execute: args => {
456
+ execute: (args) => {
461
457
  var _a, _b;
462
458
  switch (args['side']) {
463
459
  case 'left':
@@ -490,7 +486,7 @@ const sidePanelVisibility = {
490
486
  break;
491
487
  }
492
488
  },
493
- isToggled: args => {
489
+ isToggled: (args) => {
494
490
  switch (args['side']) {
495
491
  case 'left': {
496
492
  if (notebookShell.leftCollapsed) {
@@ -514,11 +510,11 @@ const sidePanelVisibility = {
514
510
  }
515
511
  }
516
512
  return false;
517
- }
513
+ },
518
514
  });
519
515
  const sidePanelMenu = {
520
516
  left: null,
521
- right: null
517
+ right: null,
522
518
  };
523
519
  /**
524
520
  * The function which adds entries to the View menu for each widget of a side panel.
@@ -545,8 +541,8 @@ const sidePanelVisibility = {
545
541
  args: {
546
542
  side: area,
547
543
  title: `Show ${widget.title.caption}`,
548
- id: widget.id
549
- }
544
+ id: widget.id,
545
+ },
550
546
  });
551
547
  menuToAdd = true;
552
548
  }
@@ -554,7 +550,7 @@ const sidePanelVisibility = {
554
550
  if (menuToAdd) {
555
551
  sidePanelMenu[area] = menu.viewMenu.addItem({
556
552
  type: 'submenu',
557
- submenu: newMenu
553
+ submenu: newMenu,
558
554
  });
559
555
  }
560
556
  };
@@ -588,12 +584,12 @@ const sidePanelVisibility = {
588
584
  if (palette) {
589
585
  const sidePanelPalette = new SidePanelPalette({
590
586
  commandPalette: palette,
591
- command: CommandIDs.togglePanel
587
+ command: CommandIDs.togglePanel,
592
588
  });
593
- notebookShell.leftHandler.widgets.forEach(widget => {
589
+ notebookShell.leftHandler.widgets.forEach((widget) => {
594
590
  sidePanelPalette.addItem(widget, notebookShell.leftHandler.area);
595
591
  });
596
- notebookShell.rightHandler.widgets.forEach(widget => {
592
+ notebookShell.rightHandler.widgets.forEach((widget) => {
597
593
  sidePanelPalette.addItem(widget, notebookShell.rightHandler.area);
598
594
  });
599
595
  // Update menu and palette when widgets are added or removed from side panels.
@@ -611,7 +607,7 @@ const sidePanelVisibility = {
611
607
  });
612
608
  }
613
609
  });
614
- }
610
+ },
615
611
  };
616
612
  /**
617
613
  * The default tree route resolver plugin.
@@ -639,7 +635,7 @@ const tree = {
639
635
  // Clean up artifacts immediately upon routing.
640
636
  set.dispose();
641
637
  delegate.resolve({ browser, file: PageConfig.getOption('treePath') });
642
- })
638
+ }),
643
639
  }));
644
640
  set.add(router.register({ command: CommandIDs.resolveTree, pattern: treePattern }));
645
641
  // If a route is handled by the router without the tree command being
@@ -656,7 +652,7 @@ const tree = {
656
652
  router.routed.disconnect(listener);
657
653
  }));
658
654
  return { paths: delegate.promise };
659
- }
655
+ },
660
656
  };
661
657
  const treePathUpdater = {
662
658
  id: '@jupyter-notebook/application-extension:tree-updater',
@@ -673,7 +669,15 @@ const treePathUpdater = {
673
669
  }
674
670
  return updateTreePath;
675
671
  },
676
- autoStart: true
672
+ autoStart: true,
673
+ };
674
+ const translator = {
675
+ id: '@jupyter-notebook/application-extension:translator',
676
+ requires: [INotebookShell, ITranslator],
677
+ autoStart: true,
678
+ activate: (app, notebookShell, translator) => {
679
+ notebookShell.translator = translator;
680
+ },
677
681
  };
678
682
  /**
679
683
  * Zen mode plugin
@@ -709,7 +713,7 @@ const zen = {
709
713
  document.exitFullscreen();
710
714
  toggleOff();
711
715
  }
712
- }
716
+ },
713
717
  });
714
718
  document.addEventListener('fullscreenchange', () => {
715
719
  if (!document.fullscreenElement) {
@@ -719,7 +723,7 @@ const zen = {
719
723
  if (palette) {
720
724
  palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
721
725
  }
722
- }
726
+ },
723
727
  };
724
728
  /**
725
729
  * Export the plugins as default.
@@ -732,7 +736,6 @@ const plugins = [
732
736
  opener,
733
737
  pages,
734
738
  paths,
735
- sessionDialogs,
736
739
  shell,
737
740
  sidePanelVisibility,
738
741
  status,
@@ -741,6 +744,7 @@ const plugins = [
741
744
  topVisibility,
742
745
  tree,
743
746
  treePathUpdater,
744
- zen
747
+ translator,
748
+ zen,
745
749
  ];
746
750
  export default plugins;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/application-extension",
3
- "version": "7.0.0-alpha.9",
3
+ "version": "7.0.0-beta.1",
4
4
  "description": "Jupyter Notebook - Application Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -35,30 +35,29 @@
35
35
  "build:prod": "tsc -b",
36
36
  "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
37
37
  "docs": "typedoc src",
38
- "prepublishOnly": "npm run build",
39
38
  "watch": "tsc -b --watch"
40
39
  },
41
40
  "dependencies": {
42
- "@jupyter-notebook/application": "^7.0.0-alpha.9",
43
- "@jupyter-notebook/ui-components": "^7.0.0-alpha.9",
44
- "@jupyterlab/application": "^4.0.0-alpha.16",
45
- "@jupyterlab/apputils": "^4.0.0-alpha.16",
46
- "@jupyterlab/celltags": "^4.0.0-alpha.16",
47
- "@jupyterlab/codeeditor": "^4.0.0-alpha.16",
48
- "@jupyterlab/console": "^4.0.0-alpha.16",
49
- "@jupyterlab/coreutils": "^6.0.0-alpha.16",
50
- "@jupyterlab/docmanager": "^4.0.0-alpha.16",
51
- "@jupyterlab/docregistry": "^4.0.0-alpha.16",
52
- "@jupyterlab/mainmenu": "^4.0.0-alpha.16",
53
- "@jupyterlab/settingregistry": "^4.0.0-alpha.16",
54
- "@jupyterlab/translation": "^4.0.0-alpha.16",
55
- "@lumino/coreutils": "^2.0.0-alpha.6",
56
- "@lumino/disposable": "^2.0.0-alpha.6",
57
- "@lumino/widgets": "^2.0.0-alpha.6"
41
+ "@jupyter-notebook/application": "^7.0.0-beta.1",
42
+ "@jupyter-notebook/ui-components": "^7.0.0-beta.1",
43
+ "@jupyterlab/application": "^4.0.0-rc.0",
44
+ "@jupyterlab/apputils": "^4.0.0-rc.0",
45
+ "@jupyterlab/celltags": "^4.0.0-alpha.20",
46
+ "@jupyterlab/codeeditor": "^4.0.0-rc.0",
47
+ "@jupyterlab/console": "^4.0.0-rc.0",
48
+ "@jupyterlab/coreutils": "^6.0.0-rc.0",
49
+ "@jupyterlab/docmanager": "^4.0.0-rc.0",
50
+ "@jupyterlab/docregistry": "^4.0.0-rc.0",
51
+ "@jupyterlab/mainmenu": "^4.0.0-rc.0",
52
+ "@jupyterlab/settingregistry": "^4.0.0-rc.0",
53
+ "@jupyterlab/translation": "^4.0.0-rc.0",
54
+ "@lumino/coreutils": "^2.1.1",
55
+ "@lumino/disposable": "^2.1.1",
56
+ "@lumino/widgets": "^2.1.1"
58
57
  },
59
58
  "devDependencies": {
60
59
  "rimraf": "^3.0.2",
61
- "typescript": "~4.7.3"
60
+ "typescript": "~5.0.2"
62
61
  },
63
62
  "publishConfig": {
64
63
  "access": "public"
package/style/base.css CHANGED
@@ -23,3 +23,13 @@
23
23
  text-align: center;
24
24
  margin-top: 8px;
25
25
  }
26
+
27
+ .jp-MimeDocument .jp-RenderedJSON {
28
+ background: var(--jp-layout-color0);
29
+ }
30
+
31
+ /* Hide the stub toolbar that appears above terminals and documents */
32
+
33
+ .jp-MainAreaWidget > .jp-Toolbar-micro {
34
+ display: none;
35
+ }