@jupyter-notebook/application-extension 7.0.0-beta.4 → 7.0.0-rc.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.js +52 -10
- package/package.json +14 -14
- package/schema/menus.json +8 -0
- package/schema/shell.json +34 -0
- package/style/base.css +5 -0
package/lib/index.js
CHANGED
|
@@ -23,6 +23,10 @@ const TREE_PATTERN = new RegExp('/(notebooks|edit)/(.*)');
|
|
|
23
23
|
* A regular expression to suppress the file extension from display for .ipynb files.
|
|
24
24
|
*/
|
|
25
25
|
const STRIP_IPYNB = /\.ipynb$/;
|
|
26
|
+
/**
|
|
27
|
+
* The JupyterLab document manager plugin id.
|
|
28
|
+
*/
|
|
29
|
+
const JUPYTERLAB_DOCMANAGER_PLUGIN_ID = '@jupyterlab/docmanager-extension:plugin';
|
|
26
30
|
/**
|
|
27
31
|
* The command IDs used by the application plugin.
|
|
28
32
|
*/
|
|
@@ -101,6 +105,7 @@ const logo = {
|
|
|
101
105
|
height: '28px',
|
|
102
106
|
width: 'auto',
|
|
103
107
|
cursor: 'pointer',
|
|
108
|
+
margin: 'auto',
|
|
104
109
|
});
|
|
105
110
|
logo.id = 'jp-NotebookLogo';
|
|
106
111
|
app.shell.add(logo, 'top', { rank: 0 });
|
|
@@ -113,22 +118,43 @@ const opener = {
|
|
|
113
118
|
id: '@jupyter-notebook/application-extension:opener',
|
|
114
119
|
autoStart: true,
|
|
115
120
|
requires: [IRouter, IDocumentManager],
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
optional: [ISettingRegistry],
|
|
122
|
+
activate: (app, router, docManager, settingRegistry) => {
|
|
123
|
+
const { commands, docRegistry } = app;
|
|
118
124
|
const command = 'router:tree';
|
|
119
125
|
commands.addCommand(command, {
|
|
120
126
|
execute: (args) => {
|
|
121
|
-
var _a
|
|
127
|
+
var _a;
|
|
122
128
|
const parsed = args;
|
|
123
129
|
const matches = (_a = parsed.path.match(TREE_PATTERN)) !== null && _a !== void 0 ? _a : [];
|
|
124
130
|
const [, , path] = matches;
|
|
125
131
|
if (!path) {
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
|
-
const file = decodeURIComponent(path);
|
|
129
|
-
const urlParams = new URLSearchParams(parsed.search);
|
|
130
|
-
const factory = (_b = urlParams.get('factory')) !== null && _b !== void 0 ? _b : 'default';
|
|
131
134
|
app.started.then(async () => {
|
|
135
|
+
var _a;
|
|
136
|
+
const file = decodeURIComponent(path);
|
|
137
|
+
const urlParams = new URLSearchParams(parsed.search);
|
|
138
|
+
let defaultFactory = docRegistry.defaultWidgetFactory(path).name;
|
|
139
|
+
// Explicitely get the default viewers from the settings because
|
|
140
|
+
// JupyterLab might not have had the time to load the settings yet (race condition)
|
|
141
|
+
// Relevant code: https://github.com/jupyterlab/jupyterlab/blob/d56ff811f39b3c10c6d8b6eb27a94624b753eb53/packages/docmanager-extension/src/index.tsx#L265-L293
|
|
142
|
+
if (settingRegistry) {
|
|
143
|
+
const settings = await settingRegistry.load(JUPYTERLAB_DOCMANAGER_PLUGIN_ID);
|
|
144
|
+
const defaultViewers = settings.get('defaultViewers').composite;
|
|
145
|
+
// get the file types for the path
|
|
146
|
+
const types = docRegistry.getFileTypesForPath(path);
|
|
147
|
+
// for each file type, check if there is a default viewer and if it
|
|
148
|
+
// is available in the docRegistry. If it is the case, use it as the
|
|
149
|
+
// default factory
|
|
150
|
+
types.forEach((ft) => {
|
|
151
|
+
if (defaultViewers[ft.name] !== undefined &&
|
|
152
|
+
docRegistry.getWidgetFactory(defaultViewers[ft.name])) {
|
|
153
|
+
defaultFactory = defaultViewers[ft.name];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const factory = (_a = urlParams.get('factory')) !== null && _a !== void 0 ? _a : defaultFactory;
|
|
132
158
|
docManager.open(file, factory, undefined, {
|
|
133
159
|
ref: '_noref',
|
|
134
160
|
});
|
|
@@ -293,14 +319,30 @@ const rendermime = {
|
|
|
293
319
|
*/
|
|
294
320
|
const shell = {
|
|
295
321
|
id: '@jupyter-notebook/application-extension:shell',
|
|
296
|
-
|
|
322
|
+
autoStart: true,
|
|
323
|
+
provides: INotebookShell,
|
|
324
|
+
optional: [ISettingRegistry],
|
|
325
|
+
activate: (app, settingRegistry) => {
|
|
297
326
|
if (!(app.shell instanceof NotebookShell)) {
|
|
298
327
|
throw new Error(`${shell.id} did not find a NotebookShell instance.`);
|
|
299
328
|
}
|
|
300
|
-
|
|
329
|
+
const notebookShell = app.shell;
|
|
330
|
+
if (settingRegistry) {
|
|
331
|
+
settingRegistry
|
|
332
|
+
.load(shell.id)
|
|
333
|
+
.then((settings) => {
|
|
334
|
+
// Add a layer of customization to support app shell mode
|
|
335
|
+
const customLayout = settings.composite['layout'];
|
|
336
|
+
// Restore the layout.
|
|
337
|
+
void notebookShell.restoreLayout(customLayout);
|
|
338
|
+
})
|
|
339
|
+
.catch((reason) => {
|
|
340
|
+
console.error('Fail to load settings for the layout restorer.');
|
|
341
|
+
console.error(reason);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return notebookShell;
|
|
301
345
|
},
|
|
302
|
-
autoStart: true,
|
|
303
|
-
provides: INotebookShell,
|
|
304
346
|
};
|
|
305
347
|
/**
|
|
306
348
|
* The default splash screen provider.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/application-extension",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.1",
|
|
4
4
|
"description": "Jupyter Notebook - Application Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyter-notebook/application": "^7.0.0-
|
|
42
|
-
"@jupyter-notebook/ui-components": "^7.0.0-
|
|
43
|
-
"@jupyterlab/application": "^4.0.
|
|
44
|
-
"@jupyterlab/apputils": "^4.1.
|
|
45
|
-
"@jupyterlab/codeeditor": "^4.0.
|
|
46
|
-
"@jupyterlab/console": "^4.0.
|
|
47
|
-
"@jupyterlab/coreutils": "^6.0.
|
|
48
|
-
"@jupyterlab/docmanager": "^4.0.
|
|
49
|
-
"@jupyterlab/docregistry": "^4.0.
|
|
50
|
-
"@jupyterlab/mainmenu": "^4.0.
|
|
51
|
-
"@jupyterlab/rendermime": "^4.0.
|
|
52
|
-
"@jupyterlab/settingregistry": "^4.0.
|
|
53
|
-
"@jupyterlab/translation": "^4.0.
|
|
41
|
+
"@jupyter-notebook/application": "^7.0.0-rc.1",
|
|
42
|
+
"@jupyter-notebook/ui-components": "^7.0.0-rc.1",
|
|
43
|
+
"@jupyterlab/application": "^4.0.2",
|
|
44
|
+
"@jupyterlab/apputils": "^4.1.2",
|
|
45
|
+
"@jupyterlab/codeeditor": "^4.0.2",
|
|
46
|
+
"@jupyterlab/console": "^4.0.2",
|
|
47
|
+
"@jupyterlab/coreutils": "^6.0.2",
|
|
48
|
+
"@jupyterlab/docmanager": "^4.0.2",
|
|
49
|
+
"@jupyterlab/docregistry": "^4.0.2",
|
|
50
|
+
"@jupyterlab/mainmenu": "^4.0.2",
|
|
51
|
+
"@jupyterlab/rendermime": "^4.0.2",
|
|
52
|
+
"@jupyterlab/settingregistry": "^4.0.2",
|
|
53
|
+
"@jupyterlab/translation": "^4.0.2",
|
|
54
54
|
"@lumino/coreutils": "^2.1.1",
|
|
55
55
|
"@lumino/disposable": "^2.1.1",
|
|
56
56
|
"@lumino/widgets": "^2.1.1"
|
package/schema/menus.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"title": "Notebook Shell",
|
|
4
|
+
"description": "Notebook Shell layout settings.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"layout": {
|
|
7
|
+
"$ref": "#/definitions/layout",
|
|
8
|
+
"type": "object",
|
|
9
|
+
"title": "Customize shell widget positioning",
|
|
10
|
+
"description": "Overrides default widget position in the application layout",
|
|
11
|
+
"default": {
|
|
12
|
+
"Markdown Preview": { "area": "right" }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"type": "object",
|
|
18
|
+
"definitions": {
|
|
19
|
+
"layout": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"[\\w-]+": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"area": {
|
|
26
|
+
"enum": ["left", "right"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"additionalProperties": false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|