@jupyter-notebook/notebook-extension 7.6.0-alpha.0 → 7.6.0-alpha.2

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
@@ -2,12 +2,15 @@
2
2
  // Distributed under the terms of the Modified BSD License.
3
3
  import { DOMUtils, IToolbarWidgetRegistry, ICommandPalette, } from '@jupyterlab/apputils';
4
4
  import { PageConfig, Text, Time, URLExt } from '@jupyterlab/coreutils';
5
+ import { IDebuggerSidebar } from '@jupyterlab/debugger';
5
6
  import { IDocumentManager } from '@jupyterlab/docmanager';
6
7
  import { IMainMenu } from '@jupyterlab/mainmenu';
7
8
  import { NotebookPanel, INotebookTracker, INotebookTools, } from '@jupyterlab/notebook';
8
9
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
10
+ import { ITableOfContentsTracker } from '@jupyterlab/toc';
9
11
  import { ITranslator, nullTranslator } from '@jupyterlab/translation';
10
12
  import { INotebookShell } from '@jupyter-notebook/application';
13
+ import { find } from '@lumino/algorithm';
11
14
  import { Poll } from '@lumino/polling';
12
15
  import { Widget } from '@lumino/widgets';
13
16
  import { TrustedComponent } from './trusted';
@@ -588,6 +591,102 @@ const editNotebookMetadata = {
588
591
  }
589
592
  },
590
593
  };
594
+ /**
595
+ * A plugin to replace the menu item activating the TOC panel, to allow toggling it.
596
+ */
597
+ const overrideMenuItems = {
598
+ id: '@jupyter-notebook/notebook-extension:menu-override',
599
+ description: 'A plugin to override some menu items',
600
+ autoStart: true,
601
+ optional: [
602
+ IDebuggerSidebar,
603
+ IMainMenu,
604
+ INotebookShell,
605
+ ITableOfContentsTracker,
606
+ ITranslator,
607
+ ],
608
+ activate: (app, debuggerSidebar, mainMenu, shell, tocTracker, translator) => {
609
+ if (!mainMenu || !shell) {
610
+ return;
611
+ }
612
+ const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('notebook');
613
+ const { commands } = app;
614
+ if (tocTracker) {
615
+ const TOC_PANEL_ID = 'table-of-contents';
616
+ commands.addCommand('toc:toggle-panel', {
617
+ label: trans.__('Table of Contents'),
618
+ isToggleable: true,
619
+ isToggled: () => {
620
+ const area = shell.getWidgetArea(TOC_PANEL_ID);
621
+ if (!area) {
622
+ return false;
623
+ }
624
+ const widget = find(shell.widgets(area), (w) => w.id === TOC_PANEL_ID);
625
+ if (!widget) {
626
+ return false;
627
+ }
628
+ return shell.isSidePanelVisible(area) && widget.isVisible;
629
+ },
630
+ execute: () => {
631
+ const area = shell.getWidgetArea(TOC_PANEL_ID);
632
+ if (!area) {
633
+ return;
634
+ }
635
+ const widget = find(shell.widgets(area), (w) => w.id === TOC_PANEL_ID);
636
+ if (shell.isSidePanelVisible(area) && (widget === null || widget === void 0 ? void 0 : widget.isVisible)) {
637
+ shell.collapse(area);
638
+ }
639
+ else {
640
+ shell.activateById(TOC_PANEL_ID);
641
+ }
642
+ },
643
+ describedBy: {
644
+ args: {
645
+ type: 'object',
646
+ properties: {},
647
+ },
648
+ },
649
+ });
650
+ }
651
+ if (debuggerSidebar) {
652
+ const DEBUGGER_PANEL_ID = 'jp-debugger-sidebar';
653
+ commands.addCommand('debugger:toggle-panel', {
654
+ label: trans.__('Debugger Panel'),
655
+ isToggleable: true,
656
+ isToggled: () => {
657
+ const area = shell.getWidgetArea(DEBUGGER_PANEL_ID);
658
+ if (!area) {
659
+ return false;
660
+ }
661
+ const widget = find(shell.widgets(area), (w) => w.id === DEBUGGER_PANEL_ID);
662
+ if (!widget) {
663
+ return false;
664
+ }
665
+ return shell.isSidePanelVisible(area) && widget.isVisible;
666
+ },
667
+ execute: () => {
668
+ const area = shell.getWidgetArea(DEBUGGER_PANEL_ID);
669
+ if (!area) {
670
+ return;
671
+ }
672
+ const widget = find(shell.widgets(area), (w) => w.id === DEBUGGER_PANEL_ID);
673
+ if (shell.isSidePanelVisible(area) && (widget === null || widget === void 0 ? void 0 : widget.isVisible)) {
674
+ shell.collapse(area);
675
+ }
676
+ else {
677
+ shell.activateById(DEBUGGER_PANEL_ID);
678
+ }
679
+ },
680
+ describedBy: {
681
+ args: {
682
+ type: 'object',
683
+ properties: {},
684
+ },
685
+ },
686
+ });
687
+ }
688
+ },
689
+ };
591
690
  /**
592
691
  * Export the plugins as default.
593
692
  */
@@ -600,6 +699,7 @@ const plugins = [
600
699
  kernelLogo,
601
700
  kernelStatus,
602
701
  notebookToolsWidget,
702
+ overrideMenuItems,
603
703
  scrollOutput,
604
704
  tabIcon,
605
705
  trusted,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/notebook-extension",
3
- "version": "7.6.0-alpha.0",
3
+ "version": "7.6.0-alpha.2",
4
4
  "description": "Jupyter Notebook - Notebook Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -38,14 +38,17 @@
38
38
  "watch": "tsc -b --watch"
39
39
  },
40
40
  "dependencies": {
41
- "@jupyter-notebook/application": "^7.6.0-alpha.0",
42
- "@jupyterlab/application": "~4.6.0-alpha.0",
43
- "@jupyterlab/apputils": "~4.7.0-alpha.0",
44
- "@jupyterlab/cells": "~4.6.0-alpha.0",
45
- "@jupyterlab/docmanager": "~4.6.0-alpha.0",
46
- "@jupyterlab/notebook": "~4.6.0-alpha.0",
47
- "@jupyterlab/settingregistry": "~4.6.0-alpha.0",
48
- "@jupyterlab/translation": "~4.6.0-alpha.0",
41
+ "@jupyter-notebook/application": "^7.6.0-alpha.2",
42
+ "@jupyterlab/application": "~4.6.0-alpha.2",
43
+ "@jupyterlab/apputils": "~4.7.0-alpha.2",
44
+ "@jupyterlab/cells": "~4.6.0-alpha.2",
45
+ "@jupyterlab/debugger": "~4.6.0-alpha.2",
46
+ "@jupyterlab/docmanager": "~4.6.0-alpha.2",
47
+ "@jupyterlab/notebook": "~4.6.0-alpha.2",
48
+ "@jupyterlab/settingregistry": "~4.6.0-alpha.2",
49
+ "@jupyterlab/toc": "~6.6.0-alpha.2",
50
+ "@jupyterlab/translation": "~4.6.0-alpha.2",
51
+ "@lumino/algorithm": "2.0.4",
49
52
  "@lumino/polling": "^2.1.5",
50
53
  "@lumino/widgets": "^2.7.2",
51
54
  "react": "^18.2.0",
@@ -0,0 +1,32 @@
1
+ {
2
+ "title": "Menu override",
3
+ "description": "Override some menu items",
4
+ "jupyter.lab.menus": {
5
+ "main": [
6
+ {
7
+ "id": "jp-mainmenu-view",
8
+ "items": [
9
+ {
10
+ "command": "toc:show-panel",
11
+ "disabled": true
12
+ },
13
+ {
14
+ "command": "toc:toggle-panel",
15
+ "rank": 4
16
+ },
17
+ {
18
+ "command": "debugger:show-panel",
19
+ "disabled": true
20
+ },
21
+ {
22
+ "command": "debugger:toggle-panel",
23
+ "rank": 5
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ },
29
+ "properties": {},
30
+ "additionalProperties": false,
31
+ "type": "object"
32
+ }