@jupyter-notebook/lab-extension 7.0.0-alpha.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.
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ /**
3
+ * Export the plugins as default.
4
+ */
5
+ declare const plugins: JupyterFrontEndPlugin<any>[];
6
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,142 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { ILabShell } from '@jupyterlab/application';
4
+ import { ICommandPalette, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
5
+ import { PageConfig } from '@jupyterlab/coreutils';
6
+ import { IMainMenu } from '@jupyterlab/mainmenu';
7
+ import { INotebookTracker } from '@jupyterlab/notebook';
8
+ import { ITranslator } from '@jupyterlab/translation';
9
+ import { Menu, MenuBar } from '@lumino/widgets';
10
+ import { INotebookShell } from '@jupyter-notebook/application';
11
+ /**
12
+ * The command IDs used by the application plugin.
13
+ */
14
+ var CommandIDs;
15
+ (function (CommandIDs) {
16
+ /**
17
+ * Launch Jupyter Notebook Tree
18
+ */
19
+ CommandIDs.launchNotebookTree = 'jupyter-notebook:launch-tree';
20
+ /**
21
+ * Open Jupyter Notebook
22
+ */
23
+ CommandIDs.openNotebook = 'jupyter-notebook:open-notebook';
24
+ /**
25
+ * Open in JupyterLab
26
+ */
27
+ CommandIDs.openLab = 'jupyter-notebook:open-lab';
28
+ })(CommandIDs || (CommandIDs = {}));
29
+ /**
30
+ * A plugin to add custom toolbar items to the notebook page
31
+ */
32
+ const launchButtons = {
33
+ id: '@jupyter-notebook/lab-extension:interface-switcher',
34
+ autoStart: true,
35
+ requires: [ITranslator],
36
+ optional: [
37
+ INotebookTracker,
38
+ ICommandPalette,
39
+ IMainMenu,
40
+ INotebookShell,
41
+ ILabShell,
42
+ IToolbarWidgetRegistry
43
+ ],
44
+ activate: (app, translator, notebookTracker, palette, menu, notebookShell, labShell, toolbarRegistry) => {
45
+ if (!notebookTracker) {
46
+ // to prevent showing the toolbar button in non-notebook pages
47
+ return;
48
+ }
49
+ const { commands, shell } = app;
50
+ const baseUrl = PageConfig.getBaseUrl();
51
+ const trans = translator.load('notebook');
52
+ const menubar = new MenuBar();
53
+ const switcher = new Menu({ commands });
54
+ switcher.title.label = trans.__('Interface');
55
+ menubar.addMenu(switcher);
56
+ const isEnabled = () => {
57
+ return (notebookTracker.currentWidget !== null &&
58
+ notebookTracker.currentWidget === shell.currentWidget);
59
+ };
60
+ const addInterface = (option) => {
61
+ const { command, commandLabel, urlPrefix } = option;
62
+ commands.addCommand(command, {
63
+ label: args => (args.noLabel ? '' : commandLabel),
64
+ caption: commandLabel,
65
+ execute: () => {
66
+ const current = notebookTracker.currentWidget;
67
+ if (!current) {
68
+ return;
69
+ }
70
+ window.open(`${urlPrefix}${current.context.path}`);
71
+ },
72
+ isEnabled
73
+ });
74
+ if (palette) {
75
+ palette.addItem({ command, category: 'Other' });
76
+ }
77
+ if (menu) {
78
+ menu.viewMenu.addGroup([{ command }], 1);
79
+ }
80
+ switcher.addItem({ command });
81
+ };
82
+ if (!notebookShell) {
83
+ addInterface({
84
+ command: CommandIDs.openNotebook,
85
+ commandLabel: trans.__('Open With %1', 'Jupyter Notebook'),
86
+ buttonLabel: 'openNotebook',
87
+ urlPrefix: `${baseUrl}tree/`
88
+ });
89
+ }
90
+ if (!labShell) {
91
+ addInterface({
92
+ command: CommandIDs.openLab,
93
+ commandLabel: trans.__('Open With %1', 'JupyterLab'),
94
+ buttonLabel: 'openLab',
95
+ urlPrefix: `${baseUrl}doc/tree/`
96
+ });
97
+ }
98
+ if (toolbarRegistry) {
99
+ toolbarRegistry.registerFactory('Notebook', 'interfaceSwitcher', panel => {
100
+ const menubar = new MenuBar();
101
+ menubar.addMenu(switcher);
102
+ menubar.addClass('jp-InterfaceSwitcher');
103
+ return menubar;
104
+ });
105
+ }
106
+ }
107
+ };
108
+ /**
109
+ * A plugin to add a command to open the Jupyter Notebook Tree.
110
+ */
111
+ const launchNotebookTree = {
112
+ id: '@jupyter-notebook/lab-extension:launch-tree',
113
+ autoStart: true,
114
+ requires: [ITranslator],
115
+ optional: [IMainMenu, ICommandPalette],
116
+ activate: (app, translator, menu, palette) => {
117
+ const { commands } = app;
118
+ const trans = translator.load('notebook');
119
+ const category = trans.__('Help');
120
+ commands.addCommand(CommandIDs.launchNotebookTree, {
121
+ label: trans.__('Launch Jupyter Notebook File Browser'),
122
+ execute: () => {
123
+ window.open(PageConfig.getBaseUrl() + 'tree');
124
+ }
125
+ });
126
+ if (menu) {
127
+ const helpMenu = menu.helpMenu;
128
+ helpMenu.addGroup([{ command: CommandIDs.launchNotebookTree }], 1);
129
+ }
130
+ if (palette) {
131
+ palette.addItem({ command: CommandIDs.launchNotebookTree, category });
132
+ }
133
+ }
134
+ };
135
+ /**
136
+ * Export the plugins as default.
137
+ */
138
+ const plugins = [
139
+ launchNotebookTree,
140
+ launchButtons
141
+ ];
142
+ export default plugins;
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@jupyter-notebook/lab-extension",
3
+ "version": "7.0.0-alpha.1",
4
+ "description": "Jupyter Notebook - Lab Extension",
5
+ "homepage": "https://github.com/jupyter/notebook",
6
+ "bugs": {
7
+ "url": "https://github.com/jupyter/notebook/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jupyter/notebook.git"
12
+ },
13
+ "license": "BSD-3-Clause",
14
+ "author": "Project Jupyter",
15
+ "sideEffects": [
16
+ "style/**/*.css",
17
+ "style/index.js"
18
+ ],
19
+ "main": "lib/index.js",
20
+ "types": "lib/index.d.ts",
21
+ "style": "style/index.css",
22
+ "directories": {
23
+ "lib": "lib/"
24
+ },
25
+ "files": [
26
+ "lib/*.d.ts",
27
+ "lib/*.js.map",
28
+ "lib/*.js",
29
+ "schema/*.json",
30
+ "style/index.js"
31
+ ],
32
+ "scripts": {
33
+ "build": "jlpm run build:lib && jlpm run build:labextension:dev",
34
+ "build:labextension": "jupyter labextension build .",
35
+ "build:labextension:dev": "jupyter labextension build --development True .",
36
+ "build:lib": "tsc",
37
+ "build:prod": "jlpm run build:lib && jlpm run build:labextension",
38
+ "clean": "jlpm run clean:lib && jlpm run clean:labextension",
39
+ "clean:labextension": "rimraf ../../notebook/labextension",
40
+ "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
41
+ "watch": "run-p watch:src watch:labextension",
42
+ "watch:labextension": "jupyter labextension watch .",
43
+ "watch:src": "tsc -w"
44
+ },
45
+ "dependencies": {
46
+ "@jupyter-notebook/application": "^7.0.0-alpha.1",
47
+ "@jupyterlab/application": "^4.0.0-alpha.5",
48
+ "@jupyterlab/apputils": "^4.0.0-alpha.5",
49
+ "@jupyterlab/coreutils": "^6.0.0-alpha.5",
50
+ "@jupyterlab/docregistry": "^4.0.0-alpha.5",
51
+ "@jupyterlab/mainmenu": "^4.0.0-alpha.5",
52
+ "@jupyterlab/notebook": "^4.0.0-alpha.5",
53
+ "@jupyterlab/translation": "^4.0.0-alpha.4",
54
+ "@lumino/commands": "^1.20.0",
55
+ "@lumino/disposable": "^1.10.1"
56
+ },
57
+ "devDependencies": {
58
+ "@jupyterlab/builder": "^4.0.0-alpha.5",
59
+ "rimraf": "~3.0.0",
60
+ "typescript": "~4.1.3"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
65
+ "jupyterlab": {
66
+ "extension": true,
67
+ "outputDir": "../../notebook/labextension",
68
+ "schemaDir": "schema"
69
+ },
70
+ "styleModule": "style/index.js"
71
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Interface Switcher",
3
+ "description": "Interface Switcher settings.",
4
+ "jupyter.lab.toolbars": {
5
+ "Notebook": [{ "name": "interfaceSwitcher", "rank": 990 }]
6
+ },
7
+ "properties": {},
8
+ "additionalProperties": false,
9
+ "type": "object"
10
+ }
package/style/index.js ADDED
@@ -0,0 +1 @@
1
+ import './base.css';