@jupyter-notebook/application-extension 7.0.0-alpha.7 → 7.0.0-alpha.9
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 +40 -41
- package/package.json +14 -14
- package/lib/sidebarpalette.d.ts +0 -61
- package/lib/sidebarpalette.js +0 -61
package/lib/index.js
CHANGED
|
@@ -9,12 +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
16
|
import { Menu, Widget } from '@lumino/widgets';
|
|
17
|
-
import { SideBarPalette } from './sidebarpalette';
|
|
18
17
|
/**
|
|
19
18
|
* A regular expression to match path to notebooks and documents
|
|
20
19
|
*/
|
|
@@ -33,7 +32,7 @@ var CommandIDs;
|
|
|
33
32
|
*/
|
|
34
33
|
CommandIDs.toggleTop = 'application:toggle-top';
|
|
35
34
|
/**
|
|
36
|
-
* Toggle
|
|
35
|
+
* Toggle side panel visibility
|
|
37
36
|
*/
|
|
38
37
|
CommandIDs.togglePanel = 'application:toggle-panel';
|
|
39
38
|
/**
|
|
@@ -431,10 +430,10 @@ const topVisibility = {
|
|
|
431
430
|
autoStart: true
|
|
432
431
|
};
|
|
433
432
|
/**
|
|
434
|
-
* Plugin to toggle the left or right
|
|
433
|
+
* Plugin to toggle the left or right side panel's visibility.
|
|
435
434
|
*/
|
|
436
|
-
const
|
|
437
|
-
id: '@jupyter-notebook/application-extension:
|
|
435
|
+
const sidePanelVisibility = {
|
|
436
|
+
id: '@jupyter-notebook/application-extension:sidepanel',
|
|
438
437
|
requires: [INotebookShell, ITranslator],
|
|
439
438
|
optional: [IMainMenu, ICommandPalette],
|
|
440
439
|
autoStart: true,
|
|
@@ -443,7 +442,7 @@ const sidebarVisibility = {
|
|
|
443
442
|
/* Arguments for togglePanel command:
|
|
444
443
|
* side, left or right area
|
|
445
444
|
* title, widget title to show in the menu
|
|
446
|
-
* id, widget ID to activate in the
|
|
445
|
+
* id, widget ID to activate in the side panel
|
|
447
446
|
*/
|
|
448
447
|
app.commands.addCommand(CommandIDs.togglePanel, {
|
|
449
448
|
label: args => args['title'],
|
|
@@ -517,15 +516,15 @@ const sidebarVisibility = {
|
|
|
517
516
|
return false;
|
|
518
517
|
}
|
|
519
518
|
});
|
|
520
|
-
const
|
|
519
|
+
const sidePanelMenu = {
|
|
521
520
|
left: null,
|
|
522
521
|
right: null
|
|
523
522
|
};
|
|
524
523
|
/**
|
|
525
|
-
* The function which adds entries to the View menu for each widget of a
|
|
524
|
+
* The function which adds entries to the View menu for each widget of a side panel.
|
|
526
525
|
*
|
|
527
|
-
* @param area - 'left' or 'right', the area of the side
|
|
528
|
-
* @param entryLabel - the name of the main entry in the View menu for that
|
|
526
|
+
* @param area - 'left' or 'right', the area of the side panel.
|
|
527
|
+
* @param entryLabel - the name of the main entry in the View menu for that side panel.
|
|
529
528
|
* @returns - The disposable menu added to the View menu or null.
|
|
530
529
|
*/
|
|
531
530
|
const updateMenu = (area, entryLabel) => {
|
|
@@ -533,14 +532,14 @@ const sidebarVisibility = {
|
|
|
533
532
|
if (menu === null) {
|
|
534
533
|
return null;
|
|
535
534
|
}
|
|
536
|
-
// Remove the previous menu entry for this
|
|
537
|
-
(_a =
|
|
538
|
-
// Creates a new menu entry and populates it with
|
|
535
|
+
// Remove the previous menu entry for this side panel.
|
|
536
|
+
(_a = sidePanelMenu[area]) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
537
|
+
// Creates a new menu entry and populates it with side panel widgets.
|
|
539
538
|
const newMenu = new Menu({ commands: app.commands });
|
|
540
539
|
newMenu.title.label = entryLabel;
|
|
541
540
|
const widgets = notebookShell.widgets(area);
|
|
542
541
|
let menuToAdd = false;
|
|
543
|
-
for (
|
|
542
|
+
for (const widget of widgets) {
|
|
544
543
|
newMenu.addItem({
|
|
545
544
|
command: CommandIDs.togglePanel,
|
|
546
545
|
args: {
|
|
@@ -553,7 +552,7 @@ const sidebarVisibility = {
|
|
|
553
552
|
}
|
|
554
553
|
// If there are widgets, add the menu to the main menu entry.
|
|
555
554
|
if (menuToAdd) {
|
|
556
|
-
|
|
555
|
+
sidePanelMenu[area] = menu.viewMenu.addItem({
|
|
557
556
|
type: 'submenu',
|
|
558
557
|
submenu: newMenu
|
|
559
558
|
});
|
|
@@ -562,53 +561,53 @@ const sidebarVisibility = {
|
|
|
562
561
|
app.restored.then(() => {
|
|
563
562
|
// Create menu entries for the left and right panel.
|
|
564
563
|
if (menu) {
|
|
565
|
-
const
|
|
564
|
+
const getSidePanelLabel = (area) => {
|
|
566
565
|
if (area === 'left') {
|
|
567
|
-
return trans.__(
|
|
566
|
+
return trans.__('Left Sidebar');
|
|
568
567
|
}
|
|
569
568
|
else {
|
|
570
|
-
return trans.__(
|
|
569
|
+
return trans.__('Right Sidebar');
|
|
571
570
|
}
|
|
572
571
|
};
|
|
573
572
|
const leftArea = notebookShell.leftHandler.area;
|
|
574
|
-
const leftLabel =
|
|
573
|
+
const leftLabel = getSidePanelLabel(leftArea);
|
|
575
574
|
updateMenu(leftArea, leftLabel);
|
|
576
575
|
const rightArea = notebookShell.rightHandler.area;
|
|
577
|
-
const rightLabel =
|
|
576
|
+
const rightLabel = getSidePanelLabel(rightArea);
|
|
578
577
|
updateMenu(rightArea, rightLabel);
|
|
579
|
-
const
|
|
580
|
-
const label =
|
|
581
|
-
updateMenu(
|
|
578
|
+
const handleSidePanelChange = (sidePanel, widget) => {
|
|
579
|
+
const label = getSidePanelLabel(sidePanel.area);
|
|
580
|
+
updateMenu(sidePanel.area, label);
|
|
582
581
|
};
|
|
583
|
-
notebookShell.leftHandler.widgetAdded.connect(
|
|
584
|
-
notebookShell.leftHandler.widgetRemoved.connect(
|
|
585
|
-
notebookShell.rightHandler.widgetAdded.connect(
|
|
586
|
-
notebookShell.rightHandler.widgetRemoved.connect(
|
|
582
|
+
notebookShell.leftHandler.widgetAdded.connect(handleSidePanelChange);
|
|
583
|
+
notebookShell.leftHandler.widgetRemoved.connect(handleSidePanelChange);
|
|
584
|
+
notebookShell.rightHandler.widgetAdded.connect(handleSidePanelChange);
|
|
585
|
+
notebookShell.rightHandler.widgetRemoved.connect(handleSidePanelChange);
|
|
587
586
|
}
|
|
588
587
|
// Add palette entries for side panels.
|
|
589
588
|
if (palette) {
|
|
590
|
-
const
|
|
589
|
+
const sidePanelPalette = new SidePanelPalette({
|
|
591
590
|
commandPalette: palette,
|
|
592
591
|
command: CommandIDs.togglePanel
|
|
593
592
|
});
|
|
594
593
|
notebookShell.leftHandler.widgets.forEach(widget => {
|
|
595
|
-
|
|
594
|
+
sidePanelPalette.addItem(widget, notebookShell.leftHandler.area);
|
|
596
595
|
});
|
|
597
596
|
notebookShell.rightHandler.widgets.forEach(widget => {
|
|
598
|
-
|
|
597
|
+
sidePanelPalette.addItem(widget, notebookShell.rightHandler.area);
|
|
599
598
|
});
|
|
600
|
-
// Update menu and palette when widgets are added or removed from
|
|
601
|
-
notebookShell.leftHandler.widgetAdded.connect((
|
|
602
|
-
|
|
599
|
+
// Update menu and palette when widgets are added or removed from side panels.
|
|
600
|
+
notebookShell.leftHandler.widgetAdded.connect((sidePanel, widget) => {
|
|
601
|
+
sidePanelPalette.addItem(widget, sidePanel.area);
|
|
603
602
|
});
|
|
604
|
-
notebookShell.leftHandler.widgetRemoved.connect((
|
|
605
|
-
|
|
603
|
+
notebookShell.leftHandler.widgetRemoved.connect((sidePanel, widget) => {
|
|
604
|
+
sidePanelPalette.removeItem(widget, sidePanel.area);
|
|
606
605
|
});
|
|
607
|
-
notebookShell.rightHandler.widgetAdded.connect((
|
|
608
|
-
|
|
606
|
+
notebookShell.rightHandler.widgetAdded.connect((sidePanel, widget) => {
|
|
607
|
+
sidePanelPalette.addItem(widget, sidePanel.area);
|
|
609
608
|
});
|
|
610
|
-
notebookShell.rightHandler.widgetRemoved.connect((
|
|
611
|
-
|
|
609
|
+
notebookShell.rightHandler.widgetRemoved.connect((sidePanel, widget) => {
|
|
610
|
+
sidePanelPalette.removeItem(widget, sidePanel.area);
|
|
612
611
|
});
|
|
613
612
|
}
|
|
614
613
|
});
|
|
@@ -735,7 +734,7 @@ const plugins = [
|
|
|
735
734
|
paths,
|
|
736
735
|
sessionDialogs,
|
|
737
736
|
shell,
|
|
738
|
-
|
|
737
|
+
sidePanelVisibility,
|
|
739
738
|
status,
|
|
740
739
|
tabTitle,
|
|
741
740
|
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.9",
|
|
4
4
|
"description": "Jupyter Notebook - Application Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -39,19 +39,19 @@
|
|
|
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/console": "^4.0.0-alpha.
|
|
49
|
-
"@jupyterlab/coreutils": "^6.0.0-alpha.
|
|
50
|
-
"@jupyterlab/docmanager": "^4.0.0-alpha.
|
|
51
|
-
"@jupyterlab/docregistry": "^4.0.0-alpha.
|
|
52
|
-
"@jupyterlab/mainmenu": "^4.0.0-alpha.
|
|
53
|
-
"@jupyterlab/settingregistry": "^4.0.0-alpha.
|
|
54
|
-
"@jupyterlab/translation": "^4.0.0-alpha.
|
|
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
55
|
"@lumino/coreutils": "^2.0.0-alpha.6",
|
|
56
56
|
"@lumino/disposable": "^2.0.0-alpha.6",
|
|
57
57
|
"@lumino/widgets": "^2.0.0-alpha.6"
|
package/lib/sidebarpalette.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ICommandPalette } from '@jupyterlab/apputils';
|
|
2
|
-
import { IDisposable } from '@lumino/disposable';
|
|
3
|
-
import { Widget } from '@lumino/widgets';
|
|
4
|
-
/**
|
|
5
|
-
* A class to manages the palette entries associated to the side bar.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SideBarPalette {
|
|
8
|
-
/**
|
|
9
|
-
* Construct a new side bar palette.
|
|
10
|
-
*/
|
|
11
|
-
constructor(options: SideBarPaletteOption);
|
|
12
|
-
/**
|
|
13
|
-
* Get a command palette item from the widget id and the area.
|
|
14
|
-
*/
|
|
15
|
-
getItem(widget: Readonly<Widget>, area: 'left' | 'right'): SideBarPaletteItem | null;
|
|
16
|
-
/**
|
|
17
|
-
* Add an item to the command palette.
|
|
18
|
-
*/
|
|
19
|
-
addItem(widget: Readonly<Widget>, area: 'left' | 'right'): void;
|
|
20
|
-
/**
|
|
21
|
-
* Remove an item from the command palette.
|
|
22
|
-
*/
|
|
23
|
-
removeItem(widget: Readonly<Widget>, area: 'left' | 'right'): void;
|
|
24
|
-
_command: string;
|
|
25
|
-
_commandPalette: ICommandPalette;
|
|
26
|
-
_items: SideBarPaletteItem[];
|
|
27
|
-
}
|
|
28
|
-
declare type SideBarPaletteItem = {
|
|
29
|
-
/**
|
|
30
|
-
* The ID of the widget associated to the command palette.
|
|
31
|
-
*/
|
|
32
|
-
widgetId: string;
|
|
33
|
-
/**
|
|
34
|
-
* The area of the panel associated to the command palette.
|
|
35
|
-
*/
|
|
36
|
-
area: 'left' | 'right';
|
|
37
|
-
/**
|
|
38
|
-
* The disposable object to remove the item from command palette.
|
|
39
|
-
*/
|
|
40
|
-
disposable: IDisposable;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* An interface for the options to include in SideBarPalette constructor.
|
|
44
|
-
*/
|
|
45
|
-
declare type SideBarPaletteOption = {
|
|
46
|
-
/**
|
|
47
|
-
* The commands palette.
|
|
48
|
-
*/
|
|
49
|
-
commandPalette: ICommandPalette;
|
|
50
|
-
/**
|
|
51
|
-
* The command to call from each sidebar menu entry.
|
|
52
|
-
*
|
|
53
|
-
* ### Notes
|
|
54
|
-
* That command required 3 args :
|
|
55
|
-
* side: 'left' | 'right', the area to toggle
|
|
56
|
-
* title: string, label of the command
|
|
57
|
-
* id: string, id of the widget to activate
|
|
58
|
-
*/
|
|
59
|
-
command: string;
|
|
60
|
-
};
|
|
61
|
-
export {};
|
package/lib/sidebarpalette.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class to manages the palette entries associated to the side bar.
|
|
3
|
-
*/
|
|
4
|
-
export class SideBarPalette {
|
|
5
|
-
/**
|
|
6
|
-
* Construct a new side bar palette.
|
|
7
|
-
*/
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this._items = [];
|
|
10
|
-
this._commandPalette = options.commandPalette;
|
|
11
|
-
this._command = options.command;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get a command palette item from the widget id and the area.
|
|
15
|
-
*/
|
|
16
|
-
getItem(widget, area) {
|
|
17
|
-
const itemList = this._items;
|
|
18
|
-
for (let i = 0; i < itemList.length; i++) {
|
|
19
|
-
const item = itemList[i];
|
|
20
|
-
if (item.widgetId == widget.id && item.area == area) {
|
|
21
|
-
return item;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Add an item to the command palette.
|
|
28
|
-
*/
|
|
29
|
-
addItem(widget, area) {
|
|
30
|
-
// Check if the item does not already exist.
|
|
31
|
-
if (this.getItem(widget, area)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Add a new item in command palette.
|
|
35
|
-
const disposableDelegate = this._commandPalette.addItem({
|
|
36
|
-
command: this._command,
|
|
37
|
-
category: 'View',
|
|
38
|
-
args: {
|
|
39
|
-
side: area,
|
|
40
|
-
title: `Show ${widget.title.caption}`,
|
|
41
|
-
id: widget.id
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
// Keep the disposableDelegate objet to be able to dispose of the item if the widget
|
|
45
|
-
// is remove from the side bar.
|
|
46
|
-
this._items.push({
|
|
47
|
-
widgetId: widget.id,
|
|
48
|
-
area: area,
|
|
49
|
-
disposable: disposableDelegate
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Remove an item from the command palette.
|
|
54
|
-
*/
|
|
55
|
-
removeItem(widget, area) {
|
|
56
|
-
const item = this.getItem(widget, area);
|
|
57
|
-
if (item) {
|
|
58
|
-
item.disposable.dispose();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|