@jupyterlab/apputils 4.0.0-alpha.8 → 4.0.0-beta.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/clipboard.d.ts +1 -1
- package/lib/dialog.d.ts +66 -4
- package/lib/dialog.js +126 -29
- package/lib/dialog.js.map +1 -1
- package/lib/domutils.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/inputdialog.d.ts +35 -3
- package/lib/inputdialog.js +122 -12
- package/lib/inputdialog.js.map +1 -1
- package/lib/kernelstatuses.js +26 -25
- package/lib/kernelstatuses.js.map +1 -1
- package/lib/mainareawidget.d.ts +9 -0
- package/lib/mainareawidget.js +29 -4
- package/lib/mainareawidget.js.map +1 -1
- package/lib/menufactory.js +14 -15
- package/lib/menufactory.js.map +1 -1
- package/lib/notification.d.ts +336 -0
- package/lib/notification.js +310 -0
- package/lib/notification.js.map +1 -0
- package/lib/runningSessions.js +2 -2
- package/lib/runningSessions.js.map +1 -1
- package/lib/sanitizer.d.ts +20 -7
- package/lib/sanitizer.js +34 -7
- package/lib/sanitizer.js.map +1 -1
- package/lib/semanticCommand.js +11 -2
- package/lib/semanticCommand.js.map +1 -1
- package/lib/sessioncontext.d.ts +53 -6
- package/lib/sessioncontext.js +100 -68
- package/lib/sessioncontext.js.map +1 -1
- package/lib/testutils.d.ts +5 -0
- package/lib/testutils.js +46 -0
- package/lib/testutils.js.map +1 -0
- package/lib/thememanager.js +20 -5
- package/lib/thememanager.js.map +1 -1
- package/lib/tokens.d.ts +21 -42
- package/lib/tokens.js.map +1 -1
- package/lib/toolbar/factory.d.ts +2 -1
- package/lib/toolbar/factory.js +132 -105
- package/lib/toolbar/factory.js.map +1 -1
- package/lib/toolbar/index.js +4 -0
- package/lib/toolbar/index.js.map +1 -1
- package/lib/toolbar/registry.d.ts +11 -0
- package/lib/toolbar/registry.js +20 -3
- package/lib/toolbar/registry.js.map +1 -1
- package/lib/toolbar/widget.d.ts +3 -0
- package/lib/toolbar/widget.js +8 -5
- package/lib/toolbar/widget.js.map +1 -1
- package/lib/widgettracker.d.ts +13 -1
- package/lib/widgettracker.js +29 -2
- package/lib/widgettracker.js.map +1 -1
- package/package.json +31 -30
- package/src/clipboard.ts +107 -0
- package/src/commandlinker.ts +209 -0
- package/src/commandpalette.ts +175 -0
- package/src/dialog.tsx +1133 -0
- package/src/domutils.ts +53 -0
- package/src/index.ts +78 -0
- package/src/inputdialog.ts +551 -0
- package/src/kernelstatuses.tsx +279 -0
- package/src/mainareawidget.ts +362 -0
- package/src/menufactory.ts +201 -0
- package/src/notification.ts +559 -0
- package/src/printing.ts +180 -0
- package/src/runningSessions.tsx +233 -0
- package/src/sanitizer.ts +986 -0
- package/src/semanticCommand.ts +77 -0
- package/src/sessioncontext.tsx +1774 -0
- package/src/testutils.ts +49 -0
- package/src/thememanager.ts +530 -0
- package/src/tokens.ts +351 -0
- package/src/toolbar/factory.ts +422 -0
- package/src/toolbar/index.ts +8 -0
- package/src/toolbar/registry.ts +158 -0
- package/src/toolbar/widget.tsx +242 -0
- package/src/widgettracker.ts +391 -0
- package/src/windowresolver.ts +218 -0
- package/style/dialog.css +16 -1
- package/style/inputdialog.css +5 -0
- package/style/materialcolors.css +5 -0
package/lib/tokens.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IChangedArgs } from '@jupyterlab/coreutils';
|
|
2
|
+
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
|
2
3
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
3
4
|
import { Token } from '@lumino/coreutils';
|
|
4
5
|
import { IDisposable } from '@lumino/disposable';
|
|
@@ -153,46 +154,21 @@ export declare namespace IThemeManager {
|
|
|
153
154
|
/**
|
|
154
155
|
* The sanitizer token.
|
|
155
156
|
*/
|
|
156
|
-
export declare const ISanitizer: Token<ISanitizer>;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* @param dirty - The dirty text.
|
|
162
|
-
*
|
|
163
|
-
* @param options - The optional sanitization options.
|
|
164
|
-
*
|
|
165
|
-
* @returns The sanitized string.
|
|
166
|
-
*/
|
|
167
|
-
sanitize(dirty: string, options?: ISanitizer.IOptions): string;
|
|
168
|
-
}
|
|
157
|
+
export declare const ISanitizer: Token<IRenderMime.ISanitizer>;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated since v4 use {@link IRenderMime.ISanitizer}
|
|
160
|
+
*/
|
|
161
|
+
export type ISanitizer = IRenderMime.ISanitizer;
|
|
169
162
|
/**
|
|
170
163
|
* The namespace for `ISanitizer` related interfaces.
|
|
171
164
|
*/
|
|
172
165
|
export declare namespace ISanitizer {
|
|
173
166
|
/**
|
|
174
167
|
* The options used to sanitize.
|
|
168
|
+
*
|
|
169
|
+
* @deprecated in v4 use {@link IRenderMime.ISanitizerOptions}
|
|
175
170
|
*/
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* The allowed tags.
|
|
179
|
-
*/
|
|
180
|
-
allowedTags?: string[];
|
|
181
|
-
/**
|
|
182
|
-
* The allowed attributes for a given tag.
|
|
183
|
-
*/
|
|
184
|
-
allowedAttributes?: {
|
|
185
|
-
[key: string]: string[];
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* The allowed style values for a given tag.
|
|
189
|
-
*/
|
|
190
|
-
allowedStyles?: {
|
|
191
|
-
[key: string]: {
|
|
192
|
-
[key: string]: RegExp[];
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
}
|
|
171
|
+
type IOptions = IRenderMime.ISanitizerOptions;
|
|
196
172
|
}
|
|
197
173
|
/**
|
|
198
174
|
* The main menu token.
|
|
@@ -231,15 +207,7 @@ export declare namespace ToolbarRegistry {
|
|
|
231
207
|
/**
|
|
232
208
|
* Interface of item to be inserted in a toolbar
|
|
233
209
|
*/
|
|
234
|
-
interface IToolbarItem {
|
|
235
|
-
/**
|
|
236
|
-
* Unique item name
|
|
237
|
-
*/
|
|
238
|
-
name: string;
|
|
239
|
-
/**
|
|
240
|
-
* Toolbar widget
|
|
241
|
-
*/
|
|
242
|
-
widget: Widget;
|
|
210
|
+
interface IToolbarItem extends IRenderMime.IToolbarItem {
|
|
243
211
|
}
|
|
244
212
|
/**
|
|
245
213
|
* Interface describing a toolbar item widget
|
|
@@ -266,6 +234,15 @@ export declare namespace ToolbarRegistry {
|
|
|
266
234
|
* Toolbar widget registry interface
|
|
267
235
|
*/
|
|
268
236
|
export interface IToolbarWidgetRegistry {
|
|
237
|
+
/**
|
|
238
|
+
* Add a new toolbar item factory
|
|
239
|
+
*
|
|
240
|
+
* @param widgetFactory The widget factory name that creates the toolbar
|
|
241
|
+
* @param toolbarItemName The unique toolbar item
|
|
242
|
+
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
243
|
+
* @returns The previously defined factory
|
|
244
|
+
*/
|
|
245
|
+
addFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
|
|
269
246
|
/**
|
|
270
247
|
* Default toolbar item factory
|
|
271
248
|
*/
|
|
@@ -286,6 +263,8 @@ export interface IToolbarWidgetRegistry {
|
|
|
286
263
|
* @param toolbarItemName The unique toolbar item
|
|
287
264
|
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
288
265
|
* @returns The previously defined factory
|
|
266
|
+
*
|
|
267
|
+
* @deprecated since v4 use `addFactory` instead
|
|
289
268
|
*/
|
|
290
269
|
registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
|
|
291
270
|
}
|
package/lib/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAK3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM1C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,KAAK,CACtC,sCAAsC,CACvC,CAAC;AA+BF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CACzC,yCAAyC,CAC1C,CAAC;AAsBF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,KAAK,CAC7C,6CAA6C,CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACpC,oCAAoC,CACrC,CAAC;AA0GF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,KAAK,CACjC,iCAAiC,CAClC,CAAC;AAmBF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACpC,oCAAoC,CACrC,CAAC;AAgBF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,KAAK,CACtC,sCAAsC,CACvC,CAAC;AAyGF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,KAAK,CAC7C,6CAA6C,CAC9C,CAAC"}
|
package/lib/toolbar/factory.d.ts
CHANGED
|
@@ -22,5 +22,6 @@ export declare function createToolbarFactory(toolbarRegistry: IToolbarWidgetRegi
|
|
|
22
22
|
*
|
|
23
23
|
* @param widget Widget with the toolbar to set
|
|
24
24
|
* @param factory Toolbar items factory
|
|
25
|
+
* @param toolbar Separated toolbar if widget is a raw widget
|
|
25
26
|
*/
|
|
26
|
-
export declare function setToolbar(widget: Toolbar.IWidgetToolbar, factory: (widget: Widget) => IObservableList<ToolbarRegistry.IToolbarItem> | ToolbarRegistry.IToolbarItem[]): void;
|
|
27
|
+
export declare function setToolbar(widget: Toolbar.IWidgetToolbar | Widget, factory: (widget: Widget) => IObservableList<ToolbarRegistry.IToolbarItem> | ToolbarRegistry.IToolbarItem[], toolbar?: Toolbar): void;
|
package/lib/toolbar/factory.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
1
5
|
import { ObservableList } from '@jupyterlab/observables';
|
|
2
6
|
import { SettingRegistry } from '@jupyterlab/settingregistry';
|
|
3
|
-
import { findIndex
|
|
7
|
+
import { findIndex } from '@lumino/algorithm';
|
|
4
8
|
import { JSONExt } from '@lumino/coreutils';
|
|
5
9
|
import { Dialog, showDialog } from '../dialog';
|
|
6
10
|
/**
|
|
@@ -10,6 +14,7 @@ import { Dialog, showDialog } from '../dialog';
|
|
|
10
14
|
* This will place item just before the white spacer item in the notebook toolbar.
|
|
11
15
|
*/
|
|
12
16
|
const DEFAULT_TOOLBAR_ITEM_RANK = 50;
|
|
17
|
+
const TOOLBAR_KEY = 'jupyter.lab.toolbars';
|
|
13
18
|
/**
|
|
14
19
|
* Display warning when the toolbar definition have been modified.
|
|
15
20
|
*
|
|
@@ -44,77 +49,93 @@ async function displayInformation(trans) {
|
|
|
44
49
|
async function setToolbarItems(toolbarItems, registry, factoryName, pluginId, translator, propertyId = 'toolbar') {
|
|
45
50
|
var _a;
|
|
46
51
|
const trans = translator.load('jupyterlab');
|
|
47
|
-
let canonical;
|
|
52
|
+
let canonical = null;
|
|
48
53
|
let loaded = {};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const pluginDefaults = Object.keys(registry.plugins)
|
|
59
|
-
.map(plugin => {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
const items = (_b = ((_a = registry.plugins[plugin].schema['jupyter.lab.toolbars']) !== null && _a !== void 0 ? _a : {})[factoryName]) !== null && _b !== void 0 ? _b : [];
|
|
62
|
-
loaded[plugin] = items;
|
|
63
|
-
return items;
|
|
64
|
-
})
|
|
65
|
-
.concat([(_b = ((_a = schema['jupyter.lab.toolbars']) !== null && _a !== void 0 ? _a : {})[factoryName]) !== null && _b !== void 0 ? _b : []])
|
|
66
|
-
.reduceRight((acc, val) => SettingRegistry.reconcileToolbarItems(acc, val, true), []);
|
|
67
|
-
// Apply default value as last step to take into account overrides.json
|
|
68
|
-
// The standard default being [] as the plugin must use `jupyter.lab.toolbars.<factory>`
|
|
69
|
-
// to define their default value.
|
|
70
|
-
schema.properties[propertyId].default = SettingRegistry.reconcileToolbarItems(pluginDefaults, schema.properties[propertyId].default, true).sort((a, b) => {
|
|
54
|
+
let listenPlugin = true;
|
|
55
|
+
try {
|
|
56
|
+
/**
|
|
57
|
+
* Populate the plugin's schema defaults.
|
|
58
|
+
*
|
|
59
|
+
* We keep track of disabled entries in case the plugin is loaded
|
|
60
|
+
* after the toolbar initialization.
|
|
61
|
+
*/
|
|
62
|
+
function populate(schema) {
|
|
71
63
|
var _a, _b;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
compose: plugin => {
|
|
79
|
-
var _a, _b, _c, _d, _e;
|
|
80
|
-
// Only override the canonical schema the first time.
|
|
81
|
-
if (!canonical) {
|
|
82
|
-
canonical = JSONExt.deepCopy(plugin.schema);
|
|
83
|
-
populate(canonical);
|
|
84
|
-
}
|
|
85
|
-
const defaults = (_c = ((_b = ((_a = canonical.properties) !== null && _a !== void 0 ? _a : {})[propertyId]) !== null && _b !== void 0 ? _b : {}).default) !== null && _c !== void 0 ? _c : [];
|
|
86
|
-
// Initialize the settings
|
|
87
|
-
const user = plugin.data.user;
|
|
88
|
-
const composite = plugin.data.composite;
|
|
89
|
-
// Overrides the value with using the aggregated default for the toolbar property
|
|
90
|
-
user[propertyId] =
|
|
91
|
-
(_d = plugin.data.user[propertyId]) !== null && _d !== void 0 ? _d : [];
|
|
92
|
-
composite[propertyId] = ((_e = SettingRegistry.reconcileToolbarItems(defaults, user[propertyId], false)) !== null && _e !== void 0 ? _e : []).sort((a, b) => {
|
|
64
|
+
loaded = {};
|
|
65
|
+
const pluginDefaults = Object.keys(registry.plugins)
|
|
66
|
+
// Filter out the current plugin (will be listed when reloading)
|
|
67
|
+
// because we control its addition after the mapping step
|
|
68
|
+
.filter(plugin => plugin !== pluginId)
|
|
69
|
+
.map(plugin => {
|
|
93
70
|
var _a, _b;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
71
|
+
const items = (_b = ((_a = registry.plugins[plugin].schema[TOOLBAR_KEY]) !== null && _a !== void 0 ? _a : {})[factoryName]) !== null && _b !== void 0 ? _b : [];
|
|
72
|
+
loaded[plugin] = items;
|
|
73
|
+
return items;
|
|
74
|
+
})
|
|
75
|
+
.concat([(_b = ((_a = schema[TOOLBAR_KEY]) !== null && _a !== void 0 ? _a : {})[factoryName]) !== null && _b !== void 0 ? _b : []])
|
|
76
|
+
.reduceRight((acc, val) => SettingRegistry.reconcileToolbarItems(acc, val, true), []);
|
|
77
|
+
// Apply default value as last step to take into account overrides.json
|
|
78
|
+
// The standard toolbars default is [] as the plugin must use
|
|
79
|
+
// `jupyter.lab.toolbars.<factory>` to define its default value.
|
|
80
|
+
schema.properties[propertyId].default =
|
|
81
|
+
SettingRegistry.reconcileToolbarItems(pluginDefaults, schema.properties[propertyId].default, true).sort((a, b) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return ((_a = a.rank) !== null && _a !== void 0 ? _a : DEFAULT_TOOLBAR_ITEM_RANK) -
|
|
84
|
+
((_b = b.rank) !== null && _b !== void 0 ? _b : DEFAULT_TOOLBAR_ITEM_RANK);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Transform the plugin object to return different schema than the default.
|
|
88
|
+
registry.transform(pluginId, {
|
|
89
|
+
compose: plugin => {
|
|
90
|
+
var _a, _b, _c, _d, _e;
|
|
91
|
+
// Only override the canonical schema the first time.
|
|
92
|
+
if (!canonical) {
|
|
93
|
+
canonical = JSONExt.deepCopy(plugin.schema);
|
|
94
|
+
populate(canonical);
|
|
95
|
+
}
|
|
96
|
+
const defaults = (_c = ((_b = ((_a = canonical.properties) !== null && _a !== void 0 ? _a : {})[propertyId]) !== null && _b !== void 0 ? _b : {}).default) !== null && _c !== void 0 ? _c : [];
|
|
97
|
+
// Initialize the settings
|
|
98
|
+
const user = plugin.data.user;
|
|
99
|
+
const composite = plugin.data.composite;
|
|
100
|
+
// Overrides the value with using the aggregated default for the toolbar property
|
|
101
|
+
user[propertyId] =
|
|
102
|
+
(_d = plugin.data.user[propertyId]) !== null && _d !== void 0 ? _d : [];
|
|
103
|
+
composite[propertyId] = ((_e = SettingRegistry.reconcileToolbarItems(defaults, user[propertyId], false)) !== null && _e !== void 0 ? _e : []).sort((a, b) => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
return ((_a = a.rank) !== null && _a !== void 0 ? _a : DEFAULT_TOOLBAR_ITEM_RANK) -
|
|
106
|
+
((_b = b.rank) !== null && _b !== void 0 ? _b : DEFAULT_TOOLBAR_ITEM_RANK);
|
|
107
|
+
});
|
|
108
|
+
plugin.data = { composite, user };
|
|
109
|
+
return plugin;
|
|
110
|
+
},
|
|
111
|
+
fetch: plugin => {
|
|
112
|
+
// Only override the canonical schema the first time.
|
|
113
|
+
if (!canonical) {
|
|
114
|
+
canonical = JSONExt.deepCopy(plugin.schema);
|
|
115
|
+
populate(canonical);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
data: plugin.data,
|
|
119
|
+
id: plugin.id,
|
|
120
|
+
raw: plugin.raw,
|
|
121
|
+
schema: canonical,
|
|
122
|
+
version: plugin.version
|
|
123
|
+
};
|
|
105
124
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (error.name === 'TransformError') {
|
|
129
|
+
// Assume the existing transformer is the toolbar builder transformer
|
|
130
|
+
// from another factory set up.
|
|
131
|
+
listenPlugin = false;
|
|
113
132
|
}
|
|
114
|
-
|
|
133
|
+
else {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
115
137
|
// Repopulate the canonical variable after the setting registry has
|
|
116
138
|
// preloaded all initial plugins.
|
|
117
|
-
canonical = null;
|
|
118
139
|
const settings = await registry.load(pluginId);
|
|
119
140
|
// React to customization by the user
|
|
120
141
|
settings.changed.connect(() => {
|
|
@@ -122,35 +143,6 @@ async function setToolbarItems(toolbarItems, registry, factoryName, pluginId, tr
|
|
|
122
143
|
const newItems = (_a = settings.composite[propertyId]) !== null && _a !== void 0 ? _a : [];
|
|
123
144
|
transferSettings(newItems);
|
|
124
145
|
});
|
|
125
|
-
// React to plugin changes
|
|
126
|
-
registry.pluginChanged.connect(async (sender, plugin) => {
|
|
127
|
-
var _a, _b, _c, _d;
|
|
128
|
-
// As the plugin storing the toolbar definition is transformed using
|
|
129
|
-
// the above definition, if it changes, this means that a request to
|
|
130
|
-
// reloaded was triggered. Hence the toolbar definitions from the other
|
|
131
|
-
// plugins has been automatically reset during the transform step.
|
|
132
|
-
if (plugin !== pluginId) {
|
|
133
|
-
// If a plugin changed its toolbar items
|
|
134
|
-
const oldItems = (_a = loaded[plugin]) !== null && _a !== void 0 ? _a : [];
|
|
135
|
-
const newItems = (_c = ((_b = registry.plugins[plugin].schema['jupyter.lab.toolbars']) !== null && _b !== void 0 ? _b : {})[factoryName]) !== null && _c !== void 0 ? _c : [];
|
|
136
|
-
if (!JSONExt.deepEqual(oldItems, newItems)) {
|
|
137
|
-
if (loaded[plugin]) {
|
|
138
|
-
// The plugin has changed, request the user to reload the UI
|
|
139
|
-
await displayInformation(trans);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
// The plugin was not yet loaded => update the toolbar items list
|
|
143
|
-
loaded[plugin] = JSONExt.deepCopy(newItems);
|
|
144
|
-
const newList = ((_d = SettingRegistry.reconcileToolbarItems(toArray(toolbarItems), newItems, false)) !== null && _d !== void 0 ? _d : []).sort((a, b) => {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
return ((_a = a.rank) !== null && _a !== void 0 ? _a : DEFAULT_TOOLBAR_ITEM_RANK) -
|
|
147
|
-
((_b = b.rank) !== null && _b !== void 0 ? _b : DEFAULT_TOOLBAR_ITEM_RANK);
|
|
148
|
-
});
|
|
149
|
-
transferSettings(newList);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
146
|
const transferSettings = (newItems) => {
|
|
155
147
|
// This is not optimal but safer because a toolbar item with the same
|
|
156
148
|
// name cannot be inserted (it will be a no-op). But that could happen
|
|
@@ -160,6 +152,36 @@ async function setToolbarItems(toolbarItems, registry, factoryName, pluginId, tr
|
|
|
160
152
|
};
|
|
161
153
|
// Initialize the toolbar
|
|
162
154
|
transferSettings((_a = settings.composite[propertyId]) !== null && _a !== void 0 ? _a : []);
|
|
155
|
+
// React to plugin changes if no other transformer exists, otherwise bail.
|
|
156
|
+
if (!listenPlugin) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
registry.pluginChanged.connect(async (sender, plugin) => {
|
|
160
|
+
var _a, _b, _c;
|
|
161
|
+
// Since the plugin storing the toolbar definition is transformed above,
|
|
162
|
+
// if it has changed, it means that a request to reload was triggered.
|
|
163
|
+
// Hence the toolbar definitions from the other plugins have been
|
|
164
|
+
// automatically reset during the transform step.
|
|
165
|
+
if (plugin === pluginId) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// If a plugin changed its toolbar items
|
|
169
|
+
const oldItems = (_a = loaded[plugin]) !== null && _a !== void 0 ? _a : [];
|
|
170
|
+
const newItems = (_c = ((_b = registry.plugins[plugin].schema[TOOLBAR_KEY]) !== null && _b !== void 0 ? _b : {})[factoryName]) !== null && _c !== void 0 ? _c : [];
|
|
171
|
+
if (!JSONExt.deepEqual(oldItems, newItems)) {
|
|
172
|
+
if (loaded[plugin]) {
|
|
173
|
+
// The plugin has changed, request the user to reload the UI
|
|
174
|
+
await displayInformation(trans);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (newItems.length > 0) {
|
|
178
|
+
canonical = null;
|
|
179
|
+
// This will trigger a settings.changed signal that will update the items
|
|
180
|
+
await registry.reload(pluginId);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
163
185
|
}
|
|
164
186
|
/**
|
|
165
187
|
* Create the toolbar factory for a given container widget based
|
|
@@ -205,7 +227,7 @@ export function createToolbarFactory(toolbarRegistry, settingsRegistry, factoryN
|
|
|
205
227
|
}
|
|
206
228
|
};
|
|
207
229
|
const toolbar = new ObservableList({
|
|
208
|
-
values:
|
|
230
|
+
values: Array.from(items).map(item => {
|
|
209
231
|
return {
|
|
210
232
|
name: item.name,
|
|
211
233
|
widget: toolbarRegistry.createWidget(factoryName, widget, item)
|
|
@@ -224,16 +246,21 @@ export function createToolbarFactory(toolbarRegistry, settingsRegistry, factoryN
|
|
|
224
246
|
*
|
|
225
247
|
* @param widget Widget with the toolbar to set
|
|
226
248
|
* @param factory Toolbar items factory
|
|
249
|
+
* @param toolbar Separated toolbar if widget is a raw widget
|
|
227
250
|
*/
|
|
228
|
-
export function setToolbar(widget, factory) {
|
|
229
|
-
|
|
230
|
-
|
|
251
|
+
export function setToolbar(widget, factory, toolbar) {
|
|
252
|
+
var _a;
|
|
253
|
+
// @ts-expect-error Widget has no toolbar
|
|
254
|
+
if (!widget.toolbar && !toolbar) {
|
|
255
|
+
console.log(`Widget ${widget.id} has no 'toolbar' and no explicit toolbar was provided.`);
|
|
231
256
|
return;
|
|
232
257
|
}
|
|
258
|
+
// @ts-expect-error Widget has no toolbar
|
|
259
|
+
const toolbar_ = (_a = widget.toolbar) !== null && _a !== void 0 ? _a : toolbar;
|
|
233
260
|
const items = factory(widget);
|
|
234
261
|
if (Array.isArray(items)) {
|
|
235
262
|
items.forEach(({ name, widget: item }) => {
|
|
236
|
-
|
|
263
|
+
toolbar_.addItem(name, item);
|
|
237
264
|
});
|
|
238
265
|
}
|
|
239
266
|
else {
|
|
@@ -241,7 +268,7 @@ export function setToolbar(widget, factory) {
|
|
|
241
268
|
switch (changes.type) {
|
|
242
269
|
case 'add':
|
|
243
270
|
changes.newValues.forEach((item, index) => {
|
|
244
|
-
|
|
271
|
+
toolbar_.insertItem(changes.newIndex + index, item.name, item.widget);
|
|
245
272
|
});
|
|
246
273
|
break;
|
|
247
274
|
case 'move':
|
|
@@ -249,7 +276,7 @@ export function setToolbar(widget, factory) {
|
|
|
249
276
|
item.widget.parent = null;
|
|
250
277
|
});
|
|
251
278
|
changes.newValues.forEach((item, index) => {
|
|
252
|
-
|
|
279
|
+
toolbar_.insertItem(changes.newIndex + index, item.name, item.widget);
|
|
253
280
|
});
|
|
254
281
|
break;
|
|
255
282
|
case 'remove':
|
|
@@ -262,18 +289,18 @@ export function setToolbar(widget, factory) {
|
|
|
262
289
|
item.widget.parent = null;
|
|
263
290
|
});
|
|
264
291
|
changes.newValues.forEach((item, index) => {
|
|
265
|
-
const existingIndex = findIndex(
|
|
292
|
+
const existingIndex = findIndex(toolbar_.names(), name => item.name === name);
|
|
266
293
|
if (existingIndex >= 0) {
|
|
267
|
-
|
|
294
|
+
Array.from(toolbar_.children())[existingIndex].parent = null;
|
|
268
295
|
}
|
|
269
|
-
|
|
296
|
+
toolbar_.insertItem(changes.newIndex + index, item.name, item.widget);
|
|
270
297
|
});
|
|
271
298
|
break;
|
|
272
299
|
}
|
|
273
300
|
};
|
|
274
301
|
updateToolbar(items, {
|
|
275
302
|
newIndex: 0,
|
|
276
|
-
newValues:
|
|
303
|
+
newValues: Array.from(items),
|
|
277
304
|
oldIndex: 0,
|
|
278
305
|
oldValues: [],
|
|
279
306
|
type: 'add'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/toolbar/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAoB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/toolbar/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAoB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAqB,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG/C;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAE3C;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,KAAwB;IACxD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC;QAC9B,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC;QAC9B,IAAI,EAAE,KAAK,CAAC,EAAE,CACZ,2FAA2F,CAC5F;QACD,OAAO,EAAE;YACP,MAAM,CAAC,YAAY,EAAE;YACrB,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;SAC/C;KACF,CAAC,CAAC;IAEH,IAAI,MAAM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/index.js
CHANGED
package/lib/toolbar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/toolbar/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/toolbar/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -20,6 +20,15 @@ export declare class ToolbarWidgetRegistry implements IToolbarWidgetRegistry {
|
|
|
20
20
|
* @returns The widget to be inserted in the toolbar.
|
|
21
21
|
*/
|
|
22
22
|
createWidget(widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget): Widget;
|
|
23
|
+
/**
|
|
24
|
+
* Add a new toolbar item factory
|
|
25
|
+
*
|
|
26
|
+
* @param widgetFactory The widget factory name that creates the toolbar
|
|
27
|
+
* @param toolbarItemName The unique toolbar item
|
|
28
|
+
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
29
|
+
* @returns The previously defined factory
|
|
30
|
+
*/
|
|
31
|
+
addFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
|
|
23
32
|
/**
|
|
24
33
|
* Register a new toolbar item factory
|
|
25
34
|
*
|
|
@@ -27,6 +36,8 @@ export declare class ToolbarWidgetRegistry implements IToolbarWidgetRegistry {
|
|
|
27
36
|
* @param toolbarItemName The unique toolbar item
|
|
28
37
|
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
29
38
|
* @returns The previously defined factory
|
|
39
|
+
*
|
|
40
|
+
* @deprecated since v4 use `addFactory` instead
|
|
30
41
|
*/
|
|
31
42
|
registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
|
|
32
43
|
protected _defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
|
package/lib/toolbar/registry.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
1
5
|
import { CommandToolbarButton, LabIcon, Toolbar } from '@jupyterlab/ui-components';
|
|
2
6
|
import { Widget } from '@lumino/widgets';
|
|
3
7
|
/**
|
|
@@ -33,14 +37,14 @@ export class ToolbarWidgetRegistry {
|
|
|
33
37
|
: this._defaultFactory(widgetFactory, widget, toolbarItem);
|
|
34
38
|
}
|
|
35
39
|
/**
|
|
36
|
-
*
|
|
40
|
+
* Add a new toolbar item factory
|
|
37
41
|
*
|
|
38
42
|
* @param widgetFactory The widget factory name that creates the toolbar
|
|
39
43
|
* @param toolbarItemName The unique toolbar item
|
|
40
44
|
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
41
45
|
* @returns The previously defined factory
|
|
42
46
|
*/
|
|
43
|
-
|
|
47
|
+
addFactory(widgetFactory, toolbarItemName, factory) {
|
|
44
48
|
let namespace = this._widgets.get(widgetFactory);
|
|
45
49
|
const oldFactory = namespace === null || namespace === void 0 ? void 0 : namespace.get(toolbarItemName);
|
|
46
50
|
if (!namespace) {
|
|
@@ -50,6 +54,19 @@ export class ToolbarWidgetRegistry {
|
|
|
50
54
|
namespace.set(toolbarItemName, factory);
|
|
51
55
|
return oldFactory;
|
|
52
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Register a new toolbar item factory
|
|
59
|
+
*
|
|
60
|
+
* @param widgetFactory The widget factory name that creates the toolbar
|
|
61
|
+
* @param toolbarItemName The unique toolbar item
|
|
62
|
+
* @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
|
63
|
+
* @returns The previously defined factory
|
|
64
|
+
*
|
|
65
|
+
* @deprecated since v4 use `addFactory` instead
|
|
66
|
+
*/
|
|
67
|
+
registerFactory(widgetFactory, toolbarItemName, factory) {
|
|
68
|
+
return this.addFactory(widgetFactory, toolbarItemName, factory);
|
|
69
|
+
}
|
|
53
70
|
}
|
|
54
71
|
/**
|
|
55
72
|
* Create the default toolbar item widget factory
|
|
@@ -64,7 +81,7 @@ export function createDefaultFactory(commands) {
|
|
|
64
81
|
case 'command': {
|
|
65
82
|
const { command: tId, args: tArgs, label: tLabel, icon: tIcon } = toolbarItem;
|
|
66
83
|
const id = tId !== null && tId !== void 0 ? tId : '';
|
|
67
|
-
const args =
|
|
84
|
+
const args = { toolbar: true, ...tArgs };
|
|
68
85
|
const icon = tIcon ? LabIcon.resolve({ icon: tIcon }) : undefined;
|
|
69
86
|
// If there is an icon, undefined label will results in no label
|
|
70
87
|
// otherwise the label will be set using the setting or the command label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/toolbar/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,OAAO,EACR,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAChC,YAAY,OAAiC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/toolbar/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,OAAO,EACR,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAChC,YAAY,OAAiC;QAyFnC,aAAQ,GAChB,IAAI,GAAG,EAAiD,CAAC;QAzFzD,IAAI,CAAC,eAAe,GAAG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*
|
|
33
|
+
* @deprecated since v3.5
|
|
34
|
+
* The kernel status indicator is now replaced by the execution status indicator.
|
|
35
|
+
*
|
|
33
36
|
* #### Notes
|
|
34
37
|
* It will show a busy status if the kernel status is busy.
|
|
35
38
|
* It will show the current status in the node title.
|