@jupyter-notebook/application-extension 7.0.0-beta.4 → 7.0.0-rc.0
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 +51 -10
- package/package.json +14 -14
- package/schema/shell.json +34 -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
|
*/
|
|
@@ -113,22 +117,43 @@ const opener = {
|
|
|
113
117
|
id: '@jupyter-notebook/application-extension:opener',
|
|
114
118
|
autoStart: true,
|
|
115
119
|
requires: [IRouter, IDocumentManager],
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
optional: [ISettingRegistry],
|
|
121
|
+
activate: (app, router, docManager, settingRegistry) => {
|
|
122
|
+
const { commands, docRegistry } = app;
|
|
118
123
|
const command = 'router:tree';
|
|
119
124
|
commands.addCommand(command, {
|
|
120
125
|
execute: (args) => {
|
|
121
|
-
var _a
|
|
126
|
+
var _a;
|
|
122
127
|
const parsed = args;
|
|
123
128
|
const matches = (_a = parsed.path.match(TREE_PATTERN)) !== null && _a !== void 0 ? _a : [];
|
|
124
129
|
const [, , path] = matches;
|
|
125
130
|
if (!path) {
|
|
126
131
|
return;
|
|
127
132
|
}
|
|
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
133
|
app.started.then(async () => {
|
|
134
|
+
var _a;
|
|
135
|
+
const file = decodeURIComponent(path);
|
|
136
|
+
const urlParams = new URLSearchParams(parsed.search);
|
|
137
|
+
let defaultFactory = docRegistry.defaultWidgetFactory(path).name;
|
|
138
|
+
// Explicitely get the default viewers from the settings because
|
|
139
|
+
// JupyterLab might not have had the time to load the settings yet (race condition)
|
|
140
|
+
// Relevant code: https://github.com/jupyterlab/jupyterlab/blob/d56ff811f39b3c10c6d8b6eb27a94624b753eb53/packages/docmanager-extension/src/index.tsx#L265-L293
|
|
141
|
+
if (settingRegistry) {
|
|
142
|
+
const settings = await settingRegistry.load(JUPYTERLAB_DOCMANAGER_PLUGIN_ID);
|
|
143
|
+
const defaultViewers = settings.get('defaultViewers').composite;
|
|
144
|
+
// get the file types for the path
|
|
145
|
+
const types = docRegistry.getFileTypesForPath(path);
|
|
146
|
+
// for each file type, check if there is a default viewer and if it
|
|
147
|
+
// is available in the docRegistry. If it is the case, use it as the
|
|
148
|
+
// default factory
|
|
149
|
+
types.forEach((ft) => {
|
|
150
|
+
if (defaultViewers[ft.name] !== undefined &&
|
|
151
|
+
docRegistry.getWidgetFactory(defaultViewers[ft.name])) {
|
|
152
|
+
defaultFactory = defaultViewers[ft.name];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const factory = (_a = urlParams.get('factory')) !== null && _a !== void 0 ? _a : defaultFactory;
|
|
132
157
|
docManager.open(file, factory, undefined, {
|
|
133
158
|
ref: '_noref',
|
|
134
159
|
});
|
|
@@ -293,14 +318,30 @@ const rendermime = {
|
|
|
293
318
|
*/
|
|
294
319
|
const shell = {
|
|
295
320
|
id: '@jupyter-notebook/application-extension:shell',
|
|
296
|
-
|
|
321
|
+
autoStart: true,
|
|
322
|
+
provides: INotebookShell,
|
|
323
|
+
optional: [ISettingRegistry],
|
|
324
|
+
activate: (app, settingRegistry) => {
|
|
297
325
|
if (!(app.shell instanceof NotebookShell)) {
|
|
298
326
|
throw new Error(`${shell.id} did not find a NotebookShell instance.`);
|
|
299
327
|
}
|
|
300
|
-
|
|
328
|
+
const notebookShell = app.shell;
|
|
329
|
+
if (settingRegistry) {
|
|
330
|
+
settingRegistry
|
|
331
|
+
.load(shell.id)
|
|
332
|
+
.then((settings) => {
|
|
333
|
+
// Add a layer of customization to support app shell mode
|
|
334
|
+
const customLayout = settings.composite['layout'];
|
|
335
|
+
// Restore the layout.
|
|
336
|
+
void notebookShell.restoreLayout(customLayout);
|
|
337
|
+
})
|
|
338
|
+
.catch((reason) => {
|
|
339
|
+
console.error('Fail to load settings for the layout restorer.');
|
|
340
|
+
console.error(reason);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
return notebookShell;
|
|
301
344
|
},
|
|
302
|
-
autoStart: true,
|
|
303
|
-
provides: INotebookShell,
|
|
304
345
|
};
|
|
305
346
|
/**
|
|
306
347
|
* 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.0",
|
|
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.0",
|
|
42
|
+
"@jupyter-notebook/ui-components": "^7.0.0-rc.0",
|
|
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"
|
|
@@ -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
|
+
}
|