@jupyter-notebook/docmanager-extension 7.0.0-alpha.1 → 7.0.0-alpha.10
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 +48 -17
- package/package.json +10 -9
package/lib/index.js
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { PageConfig, PathExt } from '@jupyterlab/coreutils';
|
|
4
|
-
import {
|
|
4
|
+
import { IDocumentWidgetOpener } from '@jupyterlab/docmanager';
|
|
5
|
+
import { Signal } from '@lumino/signaling';
|
|
5
6
|
/**
|
|
6
|
-
* A plugin to open
|
|
7
|
+
* A plugin to open documents in a new browser tab.
|
|
7
8
|
*
|
|
8
|
-
* TODO: remove and use a custom doc manager?
|
|
9
9
|
*/
|
|
10
10
|
const opener = {
|
|
11
11
|
id: '@jupyter-notebook/docmanager-extension:opener',
|
|
12
|
-
requires: [IDocumentManager],
|
|
13
12
|
autoStart: true,
|
|
14
|
-
|
|
13
|
+
provides: IDocumentWidgetOpener,
|
|
14
|
+
activate: (app) => {
|
|
15
15
|
const baseUrl = PageConfig.getBaseUrl();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (ref === '_noref') {
|
|
21
|
-
docOpen.call(docManager, path, widgetName, kernel, options);
|
|
22
|
-
return;
|
|
16
|
+
let id = 0;
|
|
17
|
+
return new (class {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._opened = new Signal(this);
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
open(widget, options) {
|
|
22
|
+
const widgetName = options === null || options === void 0 ? void 0 : options.type;
|
|
23
|
+
const ref = options === null || options === void 0 ? void 0 : options.ref;
|
|
24
|
+
if (ref !== '_noref') {
|
|
25
|
+
const path = widget.context.path;
|
|
26
|
+
const ext = PathExt.extname(path);
|
|
27
|
+
let route = 'edit';
|
|
28
|
+
if ((widgetName === 'default' && ext === '.ipynb') ||
|
|
29
|
+
widgetName === 'Notebook') {
|
|
30
|
+
route = 'notebooks';
|
|
31
|
+
}
|
|
32
|
+
let url = `${baseUrl}${route}/${path}`;
|
|
33
|
+
// append ?factory only if it's not the default
|
|
34
|
+
if (widgetName !== 'default') {
|
|
35
|
+
url = `${url}?factory=${widgetName}`;
|
|
36
|
+
}
|
|
37
|
+
window.open(url);
|
|
38
|
+
// dispose the widget since it is not used on this page
|
|
39
|
+
widget.dispose();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// otherwise open the document on the current page
|
|
43
|
+
if (!widget.id) {
|
|
44
|
+
widget.id = `document-manager-${++id}`;
|
|
45
|
+
}
|
|
46
|
+
widget.title.dataset = {
|
|
47
|
+
type: 'document-title',
|
|
48
|
+
...widget.title.dataset
|
|
49
|
+
};
|
|
50
|
+
if (!widget.isAttached) {
|
|
51
|
+
app.shell.add(widget, 'main', options || {});
|
|
52
|
+
}
|
|
53
|
+
app.shell.activateById(widget.id);
|
|
54
|
+
this._opened.emit(widget);
|
|
55
|
+
}
|
|
56
|
+
get opened() {
|
|
57
|
+
return this._opened;
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
29
60
|
}
|
|
30
61
|
};
|
|
31
62
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/docmanager-extension",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.10",
|
|
4
4
|
"description": "Jupyter Notebook - Document Manager Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -39,16 +39,17 @@
|
|
|
39
39
|
"watch": "tsc -b --watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@jupyterlab/application": "^4.0.0-alpha.
|
|
43
|
-
"@jupyterlab/coreutils": "^6.0.0-alpha.
|
|
44
|
-
"@jupyterlab/docmanager": "^4.0.0-alpha.
|
|
45
|
-
"@jupyterlab/docregistry": "^4.0.0-alpha.
|
|
46
|
-
"@jupyterlab/services": "^7.0.0-alpha.
|
|
47
|
-
"@lumino/algorithm": "^
|
|
42
|
+
"@jupyterlab/application": "^4.0.0-alpha.17",
|
|
43
|
+
"@jupyterlab/coreutils": "^6.0.0-alpha.17",
|
|
44
|
+
"@jupyterlab/docmanager": "^4.0.0-alpha.17",
|
|
45
|
+
"@jupyterlab/docregistry": "^4.0.0-alpha.17",
|
|
46
|
+
"@jupyterlab/services": "^7.0.0-alpha.17",
|
|
47
|
+
"@lumino/algorithm": "^2.0.0-alpha.7",
|
|
48
|
+
"@lumino/signaling": "^2.0.0-alpha.7"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"rimraf": "
|
|
51
|
-
"typescript": "~4.
|
|
51
|
+
"rimraf": "^3.0.2",
|
|
52
|
+
"typescript": "~4.9.3"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|