@jupyter-notebook/application-extension 7.7.0-alpha.1 → 7.7.0-alpha.2
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 +42 -20
- package/lib/settingconnector.d.ts +4 -13
- package/lib/settingconnector.js +33 -38
- package/package.json +14 -16
- package/schema/shell.json +16 -2
package/lib/index.js
CHANGED
|
@@ -114,7 +114,7 @@ const logo = {
|
|
|
114
114
|
description: 'The logo plugin.',
|
|
115
115
|
autoStart: true,
|
|
116
116
|
activate: (app) => {
|
|
117
|
-
const baseUrl =
|
|
117
|
+
const baseUrl = app.serviceManager.serverSettings.baseUrl;
|
|
118
118
|
const node = document.createElement('a');
|
|
119
119
|
node.href = `${baseUrl}tree`;
|
|
120
120
|
node.target = '_blank';
|
|
@@ -178,9 +178,31 @@ const opener = {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
const factory = (_a = urlParams.get('factory')) !== null && _a !== void 0 ? _a : defaultFactory;
|
|
181
|
-
|
|
181
|
+
const kernelPreference = urlParams.get('kernel') === 'none'
|
|
182
|
+
? { shouldStart: false, shouldReuse: false }
|
|
183
|
+
: undefined;
|
|
184
|
+
const widget = docManager.openOrReveal(file, factory, undefined, {
|
|
182
185
|
ref: '_noref',
|
|
183
|
-
});
|
|
186
|
+
}, kernelPreference);
|
|
187
|
+
if (kernelPreference && widget) {
|
|
188
|
+
const { sessionContext } = widget.context;
|
|
189
|
+
/**
|
|
190
|
+
* `kernel=none` only describes how to open the notebook. Drop it
|
|
191
|
+
* as soon as a kernel runs, so a reload reconnects to that session.
|
|
192
|
+
*/
|
|
193
|
+
const clearNoKernelQuery = () => {
|
|
194
|
+
var _a;
|
|
195
|
+
if (!((_a = sessionContext.session) === null || _a === void 0 ? void 0 : _a.kernel)) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const url = new URL(window.location.href);
|
|
199
|
+
url.searchParams.delete('kernel');
|
|
200
|
+
window.history.replaceState(window.history.state, '', url.toString());
|
|
201
|
+
sessionContext.kernelChanged.disconnect(clearNoKernelQuery);
|
|
202
|
+
};
|
|
203
|
+
sessionContext.kernelChanged.connect(clearNoKernelQuery);
|
|
204
|
+
clearNoKernelQuery();
|
|
205
|
+
}
|
|
184
206
|
});
|
|
185
207
|
},
|
|
186
208
|
describedBy: {
|
|
@@ -257,7 +279,7 @@ const pages = {
|
|
|
257
279
|
optional: [ICommandPalette],
|
|
258
280
|
activate: (app, translator, palette) => {
|
|
259
281
|
const trans = translator.load('notebook');
|
|
260
|
-
const baseUrl =
|
|
282
|
+
const baseUrl = app.serviceManager.serverSettings.baseUrl;
|
|
261
283
|
app.commands.addCommand(CommandIDs.openLab, {
|
|
262
284
|
label: trans.__('Open JupyterLab'),
|
|
263
285
|
execute: () => {
|
|
@@ -351,7 +373,7 @@ const rendermime = {
|
|
|
351
373
|
return docManager.services.contents
|
|
352
374
|
.get(path, { content: false })
|
|
353
375
|
.then((model) => {
|
|
354
|
-
const baseUrl =
|
|
376
|
+
const baseUrl = app.serviceManager.serverSettings.baseUrl;
|
|
355
377
|
opener.open({
|
|
356
378
|
prefix: URLExt.join(baseUrl, 'tree'),
|
|
357
379
|
path: model.path,
|
|
@@ -715,7 +737,7 @@ const sidePanelVisibility = {
|
|
|
715
737
|
* id, widget ID to activate in the side panel
|
|
716
738
|
*/
|
|
717
739
|
app.commands.addCommand(CommandIDs.togglePanel, {
|
|
718
|
-
label: (args) => args['title'],
|
|
740
|
+
label: (args) => trans.__('Show %1', args['title']),
|
|
719
741
|
caption: (args) => {
|
|
720
742
|
// We do not substitute the parameter into the string because the parameter is not
|
|
721
743
|
// localized (e.g., it is always 'left') even though the string is localized.
|
|
@@ -796,7 +818,7 @@ const sidePanelVisibility = {
|
|
|
796
818
|
},
|
|
797
819
|
title: {
|
|
798
820
|
type: 'string',
|
|
799
|
-
description: 'The title
|
|
821
|
+
description: 'The title of the side panel widget.',
|
|
800
822
|
},
|
|
801
823
|
id: {
|
|
802
824
|
type: 'string',
|
|
@@ -816,38 +838,38 @@ const sidePanelVisibility = {
|
|
|
816
838
|
*
|
|
817
839
|
* @param area - 'left' or 'right', the area of the side panel.
|
|
818
840
|
* @param entryLabel - the name of the main entry in the View menu for that side panel.
|
|
819
|
-
* @returns - The disposable menu added to the View menu or null.
|
|
820
841
|
*/
|
|
821
842
|
const updateMenu = (area, entryLabel) => {
|
|
822
843
|
var _a;
|
|
823
844
|
if (menu === null) {
|
|
824
|
-
return
|
|
845
|
+
return;
|
|
825
846
|
}
|
|
826
847
|
// Remove the previous menu entry for this side panel.
|
|
827
848
|
(_a = sidePanelMenu[area]) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
849
|
+
sidePanelMenu[area] = null;
|
|
850
|
+
// Nothing to add to the View menu if the side panel has no widget.
|
|
851
|
+
const widgets = Array.from(notebookShell.widgets(area));
|
|
852
|
+
if (widgets.length === 0) {
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
828
855
|
// Creates a new menu entry and populates it with side panel widgets.
|
|
829
856
|
const newMenu = new Menu({ commands: app.commands });
|
|
830
857
|
newMenu.title.label = entryLabel;
|
|
831
|
-
const widgets = notebookShell.widgets(area);
|
|
832
|
-
let menuToAdd = false;
|
|
833
858
|
for (const widget of widgets) {
|
|
834
859
|
newMenu.addItem({
|
|
835
860
|
command: CommandIDs.togglePanel,
|
|
836
861
|
args: {
|
|
837
862
|
side: area,
|
|
838
|
-
title:
|
|
863
|
+
title: widget.title.caption,
|
|
839
864
|
id: widget.id,
|
|
840
865
|
},
|
|
841
866
|
});
|
|
842
|
-
menuToAdd = true;
|
|
843
|
-
}
|
|
844
|
-
// If there are widgets, add the menu to the main menu entry.
|
|
845
|
-
if (menuToAdd) {
|
|
846
|
-
sidePanelMenu[area] = menu.viewMenu.addItem({
|
|
847
|
-
type: 'submenu',
|
|
848
|
-
submenu: newMenu,
|
|
849
|
-
});
|
|
850
867
|
}
|
|
868
|
+
// Add the menu to the main menu entry.
|
|
869
|
+
sidePanelMenu[area] = menu.viewMenu.addItem({
|
|
870
|
+
type: 'submenu',
|
|
871
|
+
submenu: newMenu,
|
|
872
|
+
});
|
|
851
873
|
};
|
|
852
874
|
app.restored.then(() => {
|
|
853
875
|
// Create menu entries for the left and right panel.
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { IDataConnector } from '@jupyterlab/statedb';
|
|
3
|
-
import { DataConnector } from '@jupyterlab/statedb';
|
|
1
|
+
import { ISettingRegistry, SettingConnector as BaseSettingConnector } from '@jupyterlab/settingregistry';
|
|
4
2
|
/**
|
|
5
3
|
* A data connector for fetching settings.
|
|
6
4
|
*
|
|
7
5
|
* #### Notes
|
|
8
|
-
* This connector
|
|
9
|
-
*
|
|
6
|
+
* This connector extends the default JupyterLab setting connector with
|
|
7
|
+
* Jupyter Notebook-specific overrides.
|
|
10
8
|
*/
|
|
11
|
-
export declare class SettingConnector extends
|
|
12
|
-
constructor(connector: IDataConnector<ISettingRegistry.IPlugin, string>);
|
|
9
|
+
export declare class SettingConnector extends BaseSettingConnector {
|
|
13
10
|
/**
|
|
14
11
|
* Fetch settings for a plugin.
|
|
15
12
|
* @param id - The plugin ID
|
|
16
|
-
*
|
|
17
|
-
* #### Notes
|
|
18
|
-
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
19
13
|
*/
|
|
20
14
|
fetch(id: string): Promise<ISettingRegistry.IPlugin | undefined>;
|
|
21
15
|
list(query: 'ids'): Promise<{
|
|
@@ -25,7 +19,4 @@ export declare class SettingConnector extends DataConnector<ISettingRegistry.IPl
|
|
|
25
19
|
ids: string[];
|
|
26
20
|
values: ISettingRegistry.IPlugin[];
|
|
27
21
|
}>;
|
|
28
|
-
save(id: string, raw: string): Promise<void>;
|
|
29
|
-
private _connector;
|
|
30
|
-
private _throttlers;
|
|
31
22
|
}
|
package/lib/settingconnector.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { PageConfig } from '@jupyterlab/coreutils';
|
|
4
|
-
import {
|
|
5
|
-
import { Throttler } from '@lumino/polling';
|
|
4
|
+
import { SettingConnector as BaseSettingConnector, } from '@jupyterlab/settingregistry';
|
|
6
5
|
/**
|
|
7
6
|
* The default setting values overridden in Jupyter Notebook, mapping
|
|
8
7
|
* a plugin identifier to the overridden properties.
|
|
@@ -21,54 +20,30 @@ const SETTING_OVERRIDES = {
|
|
|
21
20
|
helpInBottomPanel: true,
|
|
22
21
|
},
|
|
23
22
|
};
|
|
23
|
+
const FILE_EDITOR_PLUGIN_ID = '@jupyterlab/fileeditor-extension:plugin';
|
|
24
|
+
const SYNTAX_HIGHLIGHTING_SUBMENU_ID = 'jp-mainmenu-view-codemirror-language';
|
|
24
25
|
/**
|
|
25
26
|
* A data connector for fetching settings.
|
|
26
27
|
*
|
|
27
28
|
* #### Notes
|
|
28
|
-
* This connector
|
|
29
|
-
*
|
|
29
|
+
* This connector extends the default JupyterLab setting connector with
|
|
30
|
+
* Jupyter Notebook-specific overrides.
|
|
30
31
|
*/
|
|
31
|
-
export class SettingConnector extends
|
|
32
|
-
constructor(connector) {
|
|
33
|
-
super();
|
|
34
|
-
this._throttlers = Object.create(null);
|
|
35
|
-
this._connector = connector;
|
|
36
|
-
}
|
|
32
|
+
export class SettingConnector extends BaseSettingConnector {
|
|
37
33
|
/**
|
|
38
34
|
* Fetch settings for a plugin.
|
|
39
35
|
* @param id - The plugin ID
|
|
40
|
-
*
|
|
41
|
-
* #### Notes
|
|
42
|
-
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
43
36
|
*/
|
|
44
|
-
fetch(id) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
throttlers[id] = new Throttler(async () => {
|
|
48
|
-
const plugin = await this._connector.fetch(id);
|
|
49
|
-
return plugin && Private.overrideDefaults(plugin);
|
|
50
|
-
}, 100);
|
|
51
|
-
}
|
|
52
|
-
return throttlers[id].invoke();
|
|
37
|
+
async fetch(id) {
|
|
38
|
+
const plugin = await super.fetch(id);
|
|
39
|
+
return plugin && Private.applyOverrides(plugin);
|
|
53
40
|
}
|
|
54
41
|
async list(query = 'all') {
|
|
55
|
-
const { isDisabled } = PageConfig.Extension;
|
|
56
|
-
const { ids, values } = await this._connector.list(query === 'ids' ? 'ids' : undefined);
|
|
57
42
|
if (query === 'ids') {
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
if (query === 'all') {
|
|
61
|
-
return { ids, values: values.map(Private.overrideDefaults) };
|
|
43
|
+
return super.list(query);
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
values: values
|
|
66
|
-
.filter(({ id }) => !isDisabled(id))
|
|
67
|
-
.map(Private.overrideDefaults),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async save(id, raw) {
|
|
71
|
-
await this._connector.save(id, raw);
|
|
45
|
+
const { ids, values } = await super.list(query);
|
|
46
|
+
return { ids, values: values.map(Private.applyOverrides) };
|
|
72
47
|
}
|
|
73
48
|
}
|
|
74
49
|
/**
|
|
@@ -76,6 +51,10 @@ export class SettingConnector extends DataConnector {
|
|
|
76
51
|
*/
|
|
77
52
|
var Private;
|
|
78
53
|
(function (Private) {
|
|
54
|
+
function applyOverrides(plugin) {
|
|
55
|
+
return hideSyntaxHighlightingMenu(overrideDefaults(plugin));
|
|
56
|
+
}
|
|
57
|
+
Private.applyOverrides = applyOverrides;
|
|
79
58
|
/**
|
|
80
59
|
* Override the default values of the plugin settings listed
|
|
81
60
|
* in `SETTING_OVERRIDES`.
|
|
@@ -93,5 +72,21 @@ var Private;
|
|
|
93
72
|
}
|
|
94
73
|
return plugin;
|
|
95
74
|
}
|
|
96
|
-
|
|
75
|
+
function hideSyntaxHighlightingMenu(plugin) {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
const page = PageConfig.getOption('notebookPage');
|
|
78
|
+
if (plugin.id !== FILE_EDITOR_PLUGIN_ID || page === 'edit') {
|
|
79
|
+
return plugin;
|
|
80
|
+
}
|
|
81
|
+
const menus = (_b = (_a = plugin.schema['jupyter.lab.menus']) === null || _a === void 0 ? void 0 : _a.main) !== null && _b !== void 0 ? _b : [];
|
|
82
|
+
for (const menu of menus) {
|
|
83
|
+
for (const item of (_c = menu.items) !== null && _c !== void 0 ? _c : []) {
|
|
84
|
+
if (item.type === 'submenu' &&
|
|
85
|
+
((_d = item.submenu) === null || _d === void 0 ? void 0 : _d.id) === SYNTAX_HIGHLIGHTING_SUBMENU_ID) {
|
|
86
|
+
item.disabled = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return plugin;
|
|
91
|
+
}
|
|
97
92
|
})(Private || (Private = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/application-extension",
|
|
3
|
-
"version": "7.7.0-alpha.
|
|
3
|
+
"version": "7.7.0-alpha.2",
|
|
4
4
|
"description": "Jupyter Notebook - Application Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -38,23 +38,21 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyter-notebook/application": "^7.7.0-alpha.
|
|
42
|
-
"@jupyter-notebook/ui-components": "^7.7.0-alpha.
|
|
43
|
-
"@jupyterlab/application": "~4.7.0-alpha.
|
|
44
|
-
"@jupyterlab/apputils": "~4.8.0-alpha.
|
|
45
|
-
"@jupyterlab/codeeditor": "~4.7.0-alpha.
|
|
46
|
-
"@jupyterlab/console": "~4.7.0-alpha.
|
|
47
|
-
"@jupyterlab/coreutils": "~6.7.0-alpha.
|
|
48
|
-
"@jupyterlab/docmanager": "~4.7.0-alpha.
|
|
49
|
-
"@jupyterlab/docregistry": "~4.7.0-alpha.
|
|
50
|
-
"@jupyterlab/mainmenu": "~4.7.0-alpha.
|
|
51
|
-
"@jupyterlab/rendermime": "~4.7.0-alpha.
|
|
52
|
-
"@jupyterlab/settingregistry": "~4.7.0-alpha.
|
|
53
|
-
"@jupyterlab/
|
|
54
|
-
"@jupyterlab/translation": "~4.7.0-alpha.1",
|
|
41
|
+
"@jupyter-notebook/application": "^7.7.0-alpha.2",
|
|
42
|
+
"@jupyter-notebook/ui-components": "^7.7.0-alpha.2",
|
|
43
|
+
"@jupyterlab/application": "~4.7.0-alpha.2",
|
|
44
|
+
"@jupyterlab/apputils": "~4.8.0-alpha.2",
|
|
45
|
+
"@jupyterlab/codeeditor": "~4.7.0-alpha.2",
|
|
46
|
+
"@jupyterlab/console": "~4.7.0-alpha.2",
|
|
47
|
+
"@jupyterlab/coreutils": "~6.7.0-alpha.2",
|
|
48
|
+
"@jupyterlab/docmanager": "~4.7.0-alpha.2",
|
|
49
|
+
"@jupyterlab/docregistry": "~4.7.0-alpha.2",
|
|
50
|
+
"@jupyterlab/mainmenu": "~4.7.0-alpha.2",
|
|
51
|
+
"@jupyterlab/rendermime": "~4.7.0-alpha.2",
|
|
52
|
+
"@jupyterlab/settingregistry": "~4.7.0-alpha.2",
|
|
53
|
+
"@jupyterlab/translation": "~4.7.0-alpha.2",
|
|
55
54
|
"@lumino/coreutils": "^2.2.2",
|
|
56
55
|
"@lumino/disposable": "^2.1.5",
|
|
57
|
-
"@lumino/polling": "^2.1.5",
|
|
58
56
|
"@lumino/widgets": "^2.7.2"
|
|
59
57
|
},
|
|
60
58
|
"devDependencies": {
|
package/schema/shell.json
CHANGED
|
@@ -20,20 +20,34 @@
|
|
|
20
20
|
"definitions": {
|
|
21
21
|
"layout": {
|
|
22
22
|
"type": "object",
|
|
23
|
-
"
|
|
23
|
+
"patternProperties": {
|
|
24
24
|
"[\\w-]+": {
|
|
25
25
|
"type": "object",
|
|
26
26
|
"properties": {
|
|
27
27
|
"area": {
|
|
28
|
+
"type": "string",
|
|
28
29
|
"oneOf": [
|
|
30
|
+
{ "const": "main", "title": "Main" },
|
|
31
|
+
{ "const": "top", "title": "Top" },
|
|
32
|
+
{ "const": "menu", "title": "Menu" },
|
|
29
33
|
{ "const": "left", "title": "Left" },
|
|
30
|
-
{ "const": "right", "title": "Right" }
|
|
34
|
+
{ "const": "right", "title": "Right" },
|
|
35
|
+
{ "const": "down", "title": "Down" }
|
|
31
36
|
]
|
|
37
|
+
},
|
|
38
|
+
"options": {
|
|
39
|
+
"$ref": "#/definitions/options"
|
|
32
40
|
}
|
|
33
41
|
},
|
|
34
42
|
"additionalProperties": false
|
|
35
43
|
}
|
|
36
44
|
}
|
|
45
|
+
},
|
|
46
|
+
"options": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"rank": { "type": "number", "minimum": 0 }
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
53
|
}
|