@jupyterlab/settingeditor 4.0.0-alpha.3 → 4.0.0-alpha.6
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/SettingsFormEditor.d.ts +83 -0
- package/lib/SettingsFormEditor.js +206 -0
- package/lib/SettingsFormEditor.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/inspector.js +23 -29
- package/lib/inspector.js.map +1 -1
- package/lib/{settingeditor.d.ts → jsonsettingeditor.d.ts} +5 -6
- package/lib/{settingeditor.js → jsonsettingeditor.js} +24 -42
- package/lib/jsonsettingeditor.js.map +1 -0
- package/lib/plugineditor.d.ts +3 -3
- package/lib/plugineditor.js +2 -6
- package/lib/plugineditor.js.map +1 -1
- package/lib/pluginlist.d.ts +38 -24
- package/lib/pluginlist.js +157 -115
- package/lib/pluginlist.js.map +1 -1
- package/lib/settingseditor.d.ts +80 -0
- package/lib/settingseditor.js +116 -0
- package/lib/settingseditor.js.map +1 -0
- package/lib/settingspanel.d.ts +45 -0
- package/lib/settingspanel.js +62 -0
- package/lib/settingspanel.js.map +1 -0
- package/lib/tokens.d.ts +12 -2
- package/lib/tokens.js +4 -1
- package/lib/tokens.js.map +1 -1
- package/package.json +19 -15
- package/style/base.css +364 -86
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/lib/settingeditor.js.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ILabStatus } from '@jupyterlab/application';
|
|
2
|
+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
3
|
+
import { IStateDB } from '@jupyterlab/statedb';
|
|
4
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
5
|
+
import { IFormComponentRegistry } from '@jupyterlab/ui-components';
|
|
6
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
7
|
+
import { Message } from '@lumino/messaging';
|
|
8
|
+
import { ISignal } from '@lumino/signaling';
|
|
9
|
+
import { SplitPanel } from '@lumino/widgets';
|
|
10
|
+
/**
|
|
11
|
+
* Form based interface for editing settings.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SettingsEditor extends SplitPanel {
|
|
14
|
+
constructor(options: SettingsEditor.IOptions);
|
|
15
|
+
/**
|
|
16
|
+
* A signal emitted on the start and end of a saving operation.
|
|
17
|
+
*/
|
|
18
|
+
get saveStateChanged(): ISignal<this, SettingsEditor.SaveState>;
|
|
19
|
+
/**
|
|
20
|
+
* Set the dirty state status
|
|
21
|
+
*
|
|
22
|
+
* @param dirty New status
|
|
23
|
+
*/
|
|
24
|
+
setDirtyState(dirty: boolean): void;
|
|
25
|
+
/**
|
|
26
|
+
* A message handler invoked on a `'close-request'` message.
|
|
27
|
+
*
|
|
28
|
+
* @param msg Widget message
|
|
29
|
+
*/
|
|
30
|
+
protected onCloseRequest(msg: Message): void;
|
|
31
|
+
protected translator: ITranslator;
|
|
32
|
+
private _clearDirty;
|
|
33
|
+
private _status;
|
|
34
|
+
private _dirty;
|
|
35
|
+
private _list;
|
|
36
|
+
private _saveStateChange;
|
|
37
|
+
}
|
|
38
|
+
export declare namespace SettingsEditor {
|
|
39
|
+
/**
|
|
40
|
+
* Settings editor save state
|
|
41
|
+
*/
|
|
42
|
+
type SaveState = 'started' | 'failed' | 'completed';
|
|
43
|
+
/**
|
|
44
|
+
* Settings editor options
|
|
45
|
+
*/
|
|
46
|
+
interface IOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Form component registry
|
|
49
|
+
*/
|
|
50
|
+
editorRegistry: IFormComponentRegistry;
|
|
51
|
+
/**
|
|
52
|
+
* The state database key for the editor's state management.
|
|
53
|
+
*/
|
|
54
|
+
key: string;
|
|
55
|
+
/**
|
|
56
|
+
* The setting registry the editor modifies.
|
|
57
|
+
*/
|
|
58
|
+
registry: ISettingRegistry;
|
|
59
|
+
/**
|
|
60
|
+
* The state database used to store layout.
|
|
61
|
+
*/
|
|
62
|
+
state: IStateDB;
|
|
63
|
+
/**
|
|
64
|
+
* Command registry used to open the JSON settings editor.
|
|
65
|
+
*/
|
|
66
|
+
commands: CommandRegistry;
|
|
67
|
+
/**
|
|
68
|
+
* Application status
|
|
69
|
+
*/
|
|
70
|
+
status: ILabStatus;
|
|
71
|
+
/**
|
|
72
|
+
* List of plugins to skip
|
|
73
|
+
*/
|
|
74
|
+
toSkip?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* The application language translator.
|
|
77
|
+
*/
|
|
78
|
+
translator?: ITranslator;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { showDialog } from '@jupyterlab/apputils';
|
|
2
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
3
|
+
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
4
|
+
import { Signal } from '@lumino/signaling';
|
|
5
|
+
import { SplitPanel } from '@lumino/widgets';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { PluginList } from './pluginlist';
|
|
8
|
+
import { SettingsPanel } from './settingspanel';
|
|
9
|
+
/**
|
|
10
|
+
* Form based interface for editing settings.
|
|
11
|
+
*/
|
|
12
|
+
export class SettingsEditor extends SplitPanel {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super({
|
|
15
|
+
orientation: 'horizontal',
|
|
16
|
+
renderer: SplitPanel.defaultRenderer,
|
|
17
|
+
spacing: 1
|
|
18
|
+
});
|
|
19
|
+
this._clearDirty = null;
|
|
20
|
+
this._dirty = false;
|
|
21
|
+
this._saveStateChange = new Signal(this);
|
|
22
|
+
this.translator = options.translator || nullTranslator;
|
|
23
|
+
this._status = options.status;
|
|
24
|
+
const list = (this._list = new PluginList({
|
|
25
|
+
registry: options.registry,
|
|
26
|
+
toSkip: options.toSkip,
|
|
27
|
+
translator: this.translator
|
|
28
|
+
}));
|
|
29
|
+
this.addWidget(list);
|
|
30
|
+
this.setDirtyState = this.setDirtyState.bind(this);
|
|
31
|
+
/**
|
|
32
|
+
* Initializes the settings panel after loading the schema for all plugins.
|
|
33
|
+
*/
|
|
34
|
+
void Promise.all(PluginList.sortPlugins(options.registry)
|
|
35
|
+
.filter(plugin => {
|
|
36
|
+
const { schema } = plugin;
|
|
37
|
+
const deprecated = schema['jupyter.lab.setting-deprecated'] === true;
|
|
38
|
+
const editable = Object.keys(schema.properties || {}).length > 0;
|
|
39
|
+
const extensible = schema.additionalProperties !== false;
|
|
40
|
+
return !deprecated && (editable || extensible);
|
|
41
|
+
})
|
|
42
|
+
.map(async (plugin) => await options.registry.load(plugin.id)))
|
|
43
|
+
.then(settings => {
|
|
44
|
+
const settingsPanel = ReactWidget.create(React.createElement(SettingsPanel, { settings: settings.filter(pluginSettings => { var _a; return !((_a = options.toSkip) !== null && _a !== void 0 ? _a : []).includes(pluginSettings.id); }), editorRegistry: options.editorRegistry, handleSelectSignal: this._list.handleSelectSignal, onSelect: (id) => (this._list.selection = id), hasError: this._list.setError, updateDirtyState: this.setDirtyState, translator: this.translator }));
|
|
45
|
+
this.addWidget(settingsPanel);
|
|
46
|
+
})
|
|
47
|
+
.catch(reason => {
|
|
48
|
+
console.error(`Fail to load the setting plugins:\n${reason}`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A signal emitted on the start and end of a saving operation.
|
|
53
|
+
*/
|
|
54
|
+
get saveStateChanged() {
|
|
55
|
+
return this._saveStateChange;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set the dirty state status
|
|
59
|
+
*
|
|
60
|
+
* @param dirty New status
|
|
61
|
+
*/
|
|
62
|
+
setDirtyState(dirty) {
|
|
63
|
+
this._dirty = dirty;
|
|
64
|
+
if (this._dirty && !this._clearDirty) {
|
|
65
|
+
this._clearDirty = this._status.setDirty();
|
|
66
|
+
}
|
|
67
|
+
else if (!this._dirty && this._clearDirty) {
|
|
68
|
+
this._clearDirty.dispose();
|
|
69
|
+
this._clearDirty = null;
|
|
70
|
+
}
|
|
71
|
+
if (dirty) {
|
|
72
|
+
if (!this.title.className.includes('jp-mod-dirty')) {
|
|
73
|
+
this.title.className += ' jp-mod-dirty';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.title.className = this.title.className.replace('jp-mod-dirty', '');
|
|
78
|
+
}
|
|
79
|
+
this._saveStateChange.emit(dirty ? 'started' : 'completed');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A message handler invoked on a `'close-request'` message.
|
|
83
|
+
*
|
|
84
|
+
* @param msg Widget message
|
|
85
|
+
*/
|
|
86
|
+
onCloseRequest(msg) {
|
|
87
|
+
const trans = this.translator.load('jupyterlab');
|
|
88
|
+
if (this._list.hasErrors) {
|
|
89
|
+
showDialog({
|
|
90
|
+
title: trans.__('Warning'),
|
|
91
|
+
body: trans.__('Unsaved changes due to validation error. Continue without saving?')
|
|
92
|
+
}).then(value => {
|
|
93
|
+
if (value.button.accept) {
|
|
94
|
+
this.dispose();
|
|
95
|
+
super.onCloseRequest(msg);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else if (this._dirty) {
|
|
100
|
+
showDialog({
|
|
101
|
+
title: trans.__('Warning'),
|
|
102
|
+
body: trans.__('Some changes have not been saved. Continue without saving?')
|
|
103
|
+
}).then(value => {
|
|
104
|
+
if (value.button.accept) {
|
|
105
|
+
this.dispose();
|
|
106
|
+
super.onCloseRequest(msg);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this.dispose();
|
|
112
|
+
super.onCloseRequest(msg);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=settingseditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingseditor.js","sourceRoot":"","sources":["../src/settingseditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,C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AE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC;gBAC1B,IAAI,EAAE,KAAK,CAAC,EAAE,CACZ,mEAAmE,CACpE;aACF,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;oBACvB,IAAI,CAAC,OAAO,EAAE,CAAC;oBACf,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;iBAC3B;YACH,CAAC,CAAC,CAAC;SACJ;aAAM,IAAI,IAAI,CAAC,MAAM,EAAE;YACtB,UAAU,CAAC;gBACT,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC;gBAC1B,IAAI,EAAE,KAAK,CAAC,EAAE,CACZ,4DAA4D,CAC7D;aACF,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;oBACvB,IAAI,CAAC,OAAO,EAAE,CAAC;oBACf,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;iBAC3B;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;SAC3B;IACH,CAAC;CAQF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Settings } from '@jupyterlab/settingregistry';
|
|
2
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
3
|
+
import { IFormComponentRegistry } from '@jupyterlab/ui-components';
|
|
4
|
+
import { ISignal } from '@lumino/signaling';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PluginList } from './pluginlist';
|
|
7
|
+
export interface ISettingsPanelProps {
|
|
8
|
+
/**
|
|
9
|
+
* List of Settings objects that provide schema and values
|
|
10
|
+
* of plugins.
|
|
11
|
+
*/
|
|
12
|
+
settings: Settings[];
|
|
13
|
+
/**
|
|
14
|
+
* Form component registry that provides renderers
|
|
15
|
+
* for the form editor.
|
|
16
|
+
*/
|
|
17
|
+
editorRegistry: IFormComponentRegistry;
|
|
18
|
+
/**
|
|
19
|
+
* Handler for when selection change is triggered by scrolling
|
|
20
|
+
* in the SettingsPanel.
|
|
21
|
+
*/
|
|
22
|
+
onSelect: (id: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Signal that fires when a selection is made in the plugin list.
|
|
25
|
+
*/
|
|
26
|
+
handleSelectSignal: ISignal<PluginList, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Translator object
|
|
29
|
+
*/
|
|
30
|
+
translator: ITranslator;
|
|
31
|
+
/**
|
|
32
|
+
* Callback to update the plugin list to display plugins with
|
|
33
|
+
* invalid / unsaved settings in red.
|
|
34
|
+
*/
|
|
35
|
+
hasError: (id: string, error: boolean) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Sends the updated dirty state to the parent class.
|
|
38
|
+
*/
|
|
39
|
+
updateDirtyState: (dirty: boolean) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* React component that displays a list of SettingsFormEditor
|
|
43
|
+
* components.
|
|
44
|
+
*/
|
|
45
|
+
export declare const SettingsPanel: React.FC<ISettingsPanelProps>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* -----------------------------------------------------------------------------
|
|
2
|
+
| Copyright (c) Jupyter Development Team.
|
|
3
|
+
| Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|----------------------------------------------------------------------------*/
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { SettingsFormEditor } from './SettingsFormEditor';
|
|
7
|
+
/**
|
|
8
|
+
* React component that displays a list of SettingsFormEditor
|
|
9
|
+
* components.
|
|
10
|
+
*/
|
|
11
|
+
export const SettingsPanel = ({ settings, editorRegistry, onSelect, handleSelectSignal, hasError, updateDirtyState, translator }) => {
|
|
12
|
+
const [expandedPlugin, setExpandedPlugin] = useState(null);
|
|
13
|
+
// Refs used to keep track of "selected" plugin based on scroll location
|
|
14
|
+
const editorRefs = {};
|
|
15
|
+
for (const setting of settings) {
|
|
16
|
+
editorRefs[setting.id] = React.useRef(null);
|
|
17
|
+
}
|
|
18
|
+
const wrapperRef = React.useRef(null);
|
|
19
|
+
const editorDirtyStates = React.useRef({});
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
var _a;
|
|
22
|
+
const onSelectChange = (list, pluginId) => {
|
|
23
|
+
var _a;
|
|
24
|
+
setExpandedPlugin(expandedPlugin !== pluginId ? pluginId : null);
|
|
25
|
+
// Scroll to the plugin when a selection is made in the left panel.
|
|
26
|
+
(_a = editorRefs[pluginId].current) === null || _a === void 0 ? void 0 : _a.scrollIntoView(true);
|
|
27
|
+
};
|
|
28
|
+
(_a = handleSelectSignal === null || handleSelectSignal === void 0 ? void 0 : handleSelectSignal.connect) === null || _a === void 0 ? void 0 : _a.call(handleSelectSignal, onSelectChange);
|
|
29
|
+
return () => {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = handleSelectSignal === null || handleSelectSignal === void 0 ? void 0 : handleSelectSignal.disconnect) === null || _a === void 0 ? void 0 : _a.call(handleSelectSignal, onSelectChange);
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
const updateDirtyStates = (id, dirty) => {
|
|
35
|
+
if (editorDirtyStates.current) {
|
|
36
|
+
editorDirtyStates.current[id] = dirty;
|
|
37
|
+
for (const editor in editorDirtyStates.current) {
|
|
38
|
+
if (editorDirtyStates.current[editor]) {
|
|
39
|
+
updateDirtyState(true);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
updateDirtyState(false);
|
|
45
|
+
};
|
|
46
|
+
return (React.createElement("div", { className: "jp-SettingsPanel", ref: wrapperRef }, settings.map(pluginSettings => {
|
|
47
|
+
return (React.createElement("div", { ref: editorRefs[pluginSettings.id], className: "jp-SettingsForm", key: `${pluginSettings.id}SettingsEditor` },
|
|
48
|
+
React.createElement(SettingsFormEditor, { isCollapsed: pluginSettings.id !== expandedPlugin, onCollapseChange: (willCollapse) => {
|
|
49
|
+
if (!willCollapse) {
|
|
50
|
+
setExpandedPlugin(pluginSettings.id);
|
|
51
|
+
}
|
|
52
|
+
else if (pluginSettings.id === expandedPlugin) {
|
|
53
|
+
setExpandedPlugin(null);
|
|
54
|
+
}
|
|
55
|
+
}, settings: pluginSettings, renderers: editorRegistry.renderers, hasError: (error) => {
|
|
56
|
+
hasError(pluginSettings.id, error);
|
|
57
|
+
}, updateDirtyState: (dirty) => {
|
|
58
|
+
updateDirtyStates(pluginSettings.id, dirty);
|
|
59
|
+
}, onSelect: onSelect, translator: translator })));
|
|
60
|
+
})));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=settingspanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingspanel.js","sourceRoot":"","sources":["../src/settingspanel.tsx"],"names":[],"mappings":"AAAA;;;+EAG+E;AAM/E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA2C1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkC,CAAC,EAC3D,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACU,EAAe,EAAE;IACrC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAE1E,wEAAwE;IACxE,MAAM,UAAU,GAEZ,EAAE,CAAC;IACP,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KAC7C;IACD,MAAM,UAAU,GAAoC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,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AG,EAAE,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,EAClC,SAAS,EAAC,iBAAiB,EAC3B,GAAG,EAAE,GAAG,cAAc,CAAC,EAAE,gBAAgB;YAEzC,oBAAC,kBAAkB,IACjB,WAAW,EAAE,cAAc,CAAC,EAAE,KAAK,cAAc,EACjD,gBAAgB,EAAE,CAAC,YAAqB,EAAE,EAAE;oBAC1C,IAAI,CAAC,YAAY,EAAE;wBACjB,iBAAiB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;qBACtC;yBAAM,IAAI,cAAc,CAAC,EAAE,KAAK,cAAc,EAAE;wBAC/C,iBAAiB,CAAC,IAAI,CAAC,CAAC;qBACzB;gBACH,CAAC,EACD,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,cAAc,CAAC,SAAS,EACnC,QAAQ,EAAE,CAAC,KAAc,EAAE,EAAE;oBAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBACrC,CAAC,EACD,gBAAgB,EAAE,CAAC,KAAc,EAAE,EAAE;oBACnC,iBAAiB,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBAC9C,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,GACtB,CACE,CACP,CAAC;IACJ,CAAC,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/tokens.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
|
|
2
2
|
import { Token } from '@lumino/coreutils';
|
|
3
|
-
import {
|
|
3
|
+
import { JsonSettingEditor as JSONSettingEditor } from './jsonsettingeditor';
|
|
4
|
+
import { SettingsEditor } from './settingseditor';
|
|
4
5
|
/**
|
|
5
6
|
* The setting editor tracker token.
|
|
6
7
|
*/
|
|
7
8
|
export declare const ISettingEditorTracker: Token<ISettingEditorTracker>;
|
|
9
|
+
/**
|
|
10
|
+
* The setting editor tracker token.
|
|
11
|
+
*/
|
|
12
|
+
export declare const IJSONSettingEditorTracker: Token<IJSONSettingEditorTracker>;
|
|
13
|
+
/**
|
|
14
|
+
* A class that tracks the setting editor.
|
|
15
|
+
*/
|
|
16
|
+
export interface IJSONSettingEditorTracker extends IWidgetTracker<MainAreaWidget<JSONSettingEditor>> {
|
|
17
|
+
}
|
|
8
18
|
/**
|
|
9
19
|
* A class that tracks the setting editor.
|
|
10
20
|
*/
|
|
11
|
-
export interface ISettingEditorTracker extends IWidgetTracker<MainAreaWidget<
|
|
21
|
+
export interface ISettingEditorTracker extends IWidgetTracker<MainAreaWidget<SettingsEditor>> {
|
|
12
22
|
}
|
package/lib/tokens.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { Token } from '@lumino/coreutils';
|
|
4
|
-
/* tslint:disable */
|
|
5
4
|
/**
|
|
6
5
|
* The setting editor tracker token.
|
|
7
6
|
*/
|
|
8
7
|
export const ISettingEditorTracker = new Token('@jupyterlab/settingeditor:ISettingEditorTracker');
|
|
8
|
+
/**
|
|
9
|
+
* The setting editor tracker token.
|
|
10
|
+
*/
|
|
11
|
+
export const IJSONSettingEditorTracker = new Token('@jupyterlab/settingeditor:IJSONSettingEditorTracker');
|
|
9
12
|
//# sourceMappingURL=tokens.js.map
|
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;AAG3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,KAAK,CAC5C,iDAAiD,CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAChD,qDAAqD,CACtD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/settingeditor",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"description": "The JupyterLab default setting editor interface",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -36,25 +36,29 @@
|
|
|
36
36
|
"watch": "tsc -b --watch"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@jupyterlab/
|
|
40
|
-
"@jupyterlab/
|
|
41
|
-
"@jupyterlab/
|
|
42
|
-
"@jupyterlab/
|
|
43
|
-
"@jupyterlab/
|
|
44
|
-
"@jupyterlab/
|
|
45
|
-
"@jupyterlab/
|
|
46
|
-
"@jupyterlab/
|
|
47
|
-
"@
|
|
48
|
-
"@lumino/
|
|
39
|
+
"@jupyterlab/application": "^4.0.0-alpha.6",
|
|
40
|
+
"@jupyterlab/apputils": "^4.0.0-alpha.6",
|
|
41
|
+
"@jupyterlab/codeeditor": "^4.0.0-alpha.6",
|
|
42
|
+
"@jupyterlab/inspector": "^4.0.0-alpha.6",
|
|
43
|
+
"@jupyterlab/rendermime": "^4.0.0-alpha.6",
|
|
44
|
+
"@jupyterlab/settingregistry": "^4.0.0-alpha.6",
|
|
45
|
+
"@jupyterlab/statedb": "^4.0.0-alpha.6",
|
|
46
|
+
"@jupyterlab/translation": "^4.0.0-alpha.6",
|
|
47
|
+
"@jupyterlab/ui-components": "^4.0.0-alpha.21",
|
|
48
|
+
"@lumino/algorithm": "^1.9.1",
|
|
49
|
+
"@lumino/commands": "^1.20.0",
|
|
50
|
+
"@lumino/coreutils": "^1.12.0",
|
|
51
|
+
"@lumino/disposable": "^1.10.1",
|
|
49
52
|
"@lumino/messaging": "^1.10.1",
|
|
53
|
+
"@lumino/polling": "^1.10.0",
|
|
50
54
|
"@lumino/signaling": "^1.10.1",
|
|
51
|
-
"@lumino/widgets": "^1.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
55
|
+
"@lumino/widgets": "^1.31.1",
|
|
56
|
+
"@rjsf/core": "^3.1.0",
|
|
57
|
+
"json-schema": "^0.4.0",
|
|
58
|
+
"react": "^17.0.1"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
61
|
"@types/react": "^17.0.0",
|
|
57
|
-
"@types/react-dom": "^17.0.0",
|
|
58
62
|
"rimraf": "~3.0.0",
|
|
59
63
|
"typedoc": "~0.22.10",
|
|
60
64
|
"typescript": "~4.5.2"
|