@jupyterlab/notebook-extension 4.6.2 → 4.6.4
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 -21
- package/lib/index.js.map +1 -1
- package/lib/tool-widgets/activeCellToolWidget.d.ts +40 -2
- package/lib/tool-widgets/activeCellToolWidget.js +160 -29
- package/lib/tool-widgets/activeCellToolWidget.js.map +1 -1
- package/lib/tool-widgets/metadataEditorFields.js +8 -0
- package/lib/tool-widgets/metadataEditorFields.js.map +1 -1
- package/package.json +31 -31
- package/src/index.ts +50 -20
- package/src/tool-widgets/activeCellToolWidget.tsx +187 -38
- package/src/tool-widgets/metadataEditorFields.tsx +8 -0
|
@@ -22,14 +22,52 @@ declare namespace Private {
|
|
|
22
22
|
*
|
|
23
23
|
* ## Note
|
|
24
24
|
* This field does not work as other metadata form fields, as it does not update metadata.
|
|
25
|
+
*
|
|
26
|
+
* A single instance is meant to be shared by every render of the field. The
|
|
27
|
+
* displayed cell follows the notebook tracker rather than the render calls, so
|
|
28
|
+
* that the field keeps working when the metadata form is not being rebuilt, and
|
|
29
|
+
* so that it does not hold on to a cell model of a closed notebook.
|
|
30
|
+
*
|
|
31
|
+
* One instance owns one node, so the field can only be mounted in one place at
|
|
32
|
+
* a time: `render` moves the node to the most recent mount point and leaves any
|
|
33
|
+
* earlier one empty. Nothing renders this field twice today.
|
|
25
34
|
*/
|
|
26
35
|
export declare class ActiveCellTool extends NotebookTools.Tool {
|
|
27
36
|
constructor(options: Private.IOptions);
|
|
37
|
+
dispose(): void;
|
|
28
38
|
render(props: FieldProps): JSX.Element;
|
|
29
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Follow the active cell of the tracker, which is null once the last
|
|
41
|
+
* notebook is closed.
|
|
42
|
+
*/
|
|
43
|
+
private _onActiveCellChanged;
|
|
44
|
+
/**
|
|
45
|
+
* Handle a change to the current cell source, mime type or execution count.
|
|
46
|
+
*/
|
|
47
|
+
private _onCellContentChanged;
|
|
48
|
+
/**
|
|
49
|
+
* Stop listening to the cell model the tool is currently displaying.
|
|
50
|
+
*/
|
|
51
|
+
private _disconnectCellModel;
|
|
52
|
+
/**
|
|
53
|
+
* Reflect the execution count of the current cell.
|
|
54
|
+
*/
|
|
55
|
+
private _updatePrompt;
|
|
56
|
+
/**
|
|
57
|
+
* Refresh the preview, writing an outdated prompt along with it.
|
|
58
|
+
*
|
|
59
|
+
* The prompt is written in the same task as the preview it belongs with, so
|
|
60
|
+
* that the field never shows the prompt of one cell above the source line of
|
|
61
|
+
* another while a language mode is being loaded.
|
|
62
|
+
*/
|
|
63
|
+
private _update;
|
|
30
64
|
private _tracker;
|
|
65
|
+
private _languages;
|
|
31
66
|
private _cellModel;
|
|
32
|
-
private
|
|
67
|
+
private _previewDebouncer;
|
|
68
|
+
private _updateId;
|
|
69
|
+
private _pendingUpdate;
|
|
70
|
+
private _promptOutdated;
|
|
33
71
|
private _editorEl;
|
|
34
72
|
private _inputPrompt;
|
|
35
73
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { NotebookTools } from '@jupyterlab/notebook';
|
|
7
7
|
import { PanelLayout, Widget } from '@lumino/widgets';
|
|
8
|
-
import { InputPrompt } from '@jupyterlab/cells';
|
|
8
|
+
import { InputPrompt, isCodeCellModel } from '@jupyterlab/cells';
|
|
9
9
|
import { Debouncer } from '@lumino/polling';
|
|
10
10
|
/**
|
|
11
11
|
* The class name added to the ActiveCellTool.
|
|
@@ -24,12 +24,25 @@ const ACTIVE_CELL_TOOL_CELL_CONTENT_CLASS = 'jp-ActiveCellTool-CellContent';
|
|
|
24
24
|
*
|
|
25
25
|
* ## Note
|
|
26
26
|
* This field does not work as other metadata form fields, as it does not update metadata.
|
|
27
|
+
*
|
|
28
|
+
* A single instance is meant to be shared by every render of the field. The
|
|
29
|
+
* displayed cell follows the notebook tracker rather than the render calls, so
|
|
30
|
+
* that the field keeps working when the metadata form is not being rebuilt, and
|
|
31
|
+
* so that it does not hold on to a cell model of a closed notebook.
|
|
32
|
+
*
|
|
33
|
+
* One instance owns one node, so the field can only be mounted in one place at
|
|
34
|
+
* a time: `render` moves the node to the most recent mount point and leaves any
|
|
35
|
+
* earlier one empty. Nothing renders this field twice today.
|
|
27
36
|
*/
|
|
28
37
|
export class ActiveCellTool extends NotebookTools.Tool {
|
|
29
38
|
constructor(options) {
|
|
30
39
|
super();
|
|
31
|
-
|
|
40
|
+
this._cellModel = null;
|
|
41
|
+
this._updateId = 0;
|
|
42
|
+
this._pendingUpdate = false;
|
|
43
|
+
this._promptOutdated = false;
|
|
32
44
|
this._tracker = options.tracker;
|
|
45
|
+
this._languages = options.languages;
|
|
33
46
|
this.addClass(ACTIVE_CELL_TOOL_CLASS);
|
|
34
47
|
this.layout = new PanelLayout();
|
|
35
48
|
this._inputPrompt = new InputPrompt();
|
|
@@ -42,37 +55,155 @@ export class ActiveCellTool extends NotebookTools.Tool {
|
|
|
42
55
|
container.className = ACTIVE_CELL_TOOL_CELL_CONTENT_CLASS;
|
|
43
56
|
this._editorEl = editor;
|
|
44
57
|
this.layout.addWidget(new Widget({ node }));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
this.
|
|
58
|
+
// Only edits to the current cell are rate-limited; switching cells updates
|
|
59
|
+
// the display immediately, see `_onActiveCellChanged`.
|
|
60
|
+
this._previewDebouncer = new Debouncer(() => this._update(), 150);
|
|
61
|
+
this._tracker.activeCellChanged.connect(this._onActiveCellChanged, this);
|
|
62
|
+
// `activeCellChanged` is not emitted when the last notebook is closed:
|
|
63
|
+
// NotebookTracker.onCurrentChanged returns early on a null widget. Without
|
|
64
|
+
// this second connection the field would keep the cell model of a closed
|
|
65
|
+
// notebook, and its shared model, alive for the rest of the session.
|
|
66
|
+
this._tracker.currentChanged.connect(this._onActiveCellChanged, this);
|
|
67
|
+
this._onActiveCellChanged();
|
|
68
|
+
}
|
|
69
|
+
dispose() {
|
|
70
|
+
if (this.isDisposed) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._tracker.activeCellChanged.disconnect(this._onActiveCellChanged, this);
|
|
74
|
+
this._tracker.currentChanged.disconnect(this._onActiveCellChanged, this);
|
|
75
|
+
this._disconnectCellModel();
|
|
76
|
+
this._previewDebouncer.dispose();
|
|
77
|
+
super.dispose();
|
|
61
78
|
}
|
|
62
79
|
render(props) {
|
|
80
|
+
// The content is driven by the tracker; React only supplies the mount
|
|
81
|
+
// point, which is a different element on every rebuild of the form.
|
|
82
|
+
return (React.createElement("div", { ref: ref => {
|
|
83
|
+
if (!ref || this.node.parentElement === ref) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
ref.appendChild(this.node);
|
|
87
|
+
if (this._pendingUpdate) {
|
|
88
|
+
this._update().catch(console.warn);
|
|
89
|
+
}
|
|
90
|
+
} }));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Follow the active cell of the tracker, which is null once the last
|
|
94
|
+
* notebook is closed.
|
|
95
|
+
*/
|
|
96
|
+
_onActiveCellChanged() {
|
|
63
97
|
var _a, _b;
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
98
|
+
const cellModel = (_b = (_a = this._tracker.activeCell) === null || _a === void 0 ? void 0 : _a.model) !== null && _b !== void 0 ? _b : null;
|
|
99
|
+
if (cellModel === this._cellModel) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this._disconnectCellModel();
|
|
103
|
+
this._cellModel = cellModel;
|
|
104
|
+
if (cellModel) {
|
|
105
|
+
cellModel.sharedModel.changed.connect(this._onCellContentChanged, this);
|
|
106
|
+
cellModel.mimeTypeChanged.connect(this._onCellContentChanged, this);
|
|
107
|
+
}
|
|
108
|
+
// The prompt now belongs to a cell whose source line is not on screen yet,
|
|
109
|
+
// so leave it to `_update` to write both together.
|
|
110
|
+
this._promptOutdated = true;
|
|
111
|
+
this._update().catch(console.warn);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Handle a change to the current cell source, mime type or execution count.
|
|
115
|
+
*/
|
|
116
|
+
_onCellContentChanged() {
|
|
117
|
+
if (!this.node.isConnected) {
|
|
118
|
+
this._pendingUpdate = true;
|
|
119
|
+
this._promptOutdated = true;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!this._promptOutdated) {
|
|
123
|
+
// The cell is unchanged and no switch is in flight, so writing the prompt
|
|
124
|
+
// now cannot pair it with the source line of a different cell.
|
|
125
|
+
this._updatePrompt();
|
|
126
|
+
}
|
|
127
|
+
this._previewDebouncer.invoke().catch(console.warn);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Stop listening to the cell model the tool is currently displaying.
|
|
131
|
+
*/
|
|
132
|
+
_disconnectCellModel() {
|
|
133
|
+
const cellModel = this._cellModel;
|
|
134
|
+
if (!cellModel) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
cellModel.sharedModel.changed.disconnect(this._onCellContentChanged, this);
|
|
138
|
+
cellModel.mimeTypeChanged.disconnect(this._onCellContentChanged, this);
|
|
139
|
+
this._cellModel = null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Reflect the execution count of the current cell.
|
|
143
|
+
*/
|
|
144
|
+
_updatePrompt() {
|
|
145
|
+
var _a;
|
|
146
|
+
const cellModel = this._cellModel;
|
|
147
|
+
if (cellModel && isCodeCellModel(cellModel)) {
|
|
148
|
+
this._inputPrompt.executionCount = `${(_a = cellModel.executionCount) !== null && _a !== void 0 ? _a : ''}`;
|
|
149
|
+
this._inputPrompt.show();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this._inputPrompt.executionCount = null;
|
|
153
|
+
this._inputPrompt.hide();
|
|
154
|
+
}
|
|
73
155
|
}
|
|
74
|
-
|
|
75
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Refresh the preview, writing an outdated prompt along with it.
|
|
158
|
+
*
|
|
159
|
+
* The prompt is written in the same task as the preview it belongs with, so
|
|
160
|
+
* that the field never shows the prompt of one cell above the source line of
|
|
161
|
+
* another while a language mode is being loaded.
|
|
162
|
+
*/
|
|
163
|
+
async _update() {
|
|
164
|
+
if (!this.node.isConnected) {
|
|
165
|
+
// Nothing is on screen; catch up when the field is mounted again.
|
|
166
|
+
this._pendingUpdate = true;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this._pendingUpdate = false;
|
|
170
|
+
const cellModel = this._cellModel;
|
|
171
|
+
const pending = ++this._updateId;
|
|
172
|
+
if (!cellModel) {
|
|
173
|
+
this._promptOutdated = false;
|
|
174
|
+
this._updatePrompt();
|
|
175
|
+
this._editorEl.replaceChildren();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const source = cellModel.sharedModel.getSource();
|
|
179
|
+
const lineEnd = source.indexOf('\n');
|
|
180
|
+
const firstLine = lineEnd === -1 ? source : source.slice(0, lineEnd);
|
|
181
|
+
// Highlight into a detached node, so that the preview is never cleared
|
|
182
|
+
// while waiting for a language mode to load.
|
|
183
|
+
const staging = document.createElement('pre');
|
|
184
|
+
try {
|
|
185
|
+
await this._languages.highlight(firstLine, this._languages.findByMIME(cellModel.mimeType), staging);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
// Fall back to unhighlighted source rather than keeping the previous
|
|
189
|
+
// cell's line on screen.
|
|
190
|
+
console.warn(error);
|
|
191
|
+
staging.replaceChildren(document.createTextNode(firstLine));
|
|
192
|
+
}
|
|
193
|
+
if (pending !== this._updateId) {
|
|
194
|
+
// A newer update started while this one was highlighting; it still owes
|
|
195
|
+
// the prompt write, so `_promptOutdated` is deliberately left set.
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (this._promptOutdated) {
|
|
199
|
+
this._updatePrompt();
|
|
200
|
+
this._promptOutdated = false;
|
|
201
|
+
}
|
|
202
|
+
const fragment = document.createDocumentFragment();
|
|
203
|
+
while (staging.firstChild) {
|
|
204
|
+
fragment.appendChild(staging.firstChild);
|
|
205
|
+
}
|
|
206
|
+
this._editorEl.replaceChildren(fragment);
|
|
76
207
|
}
|
|
77
208
|
}
|
|
78
209
|
//# sourceMappingURL=activeCellToolWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activeCellToolWidget.js","sourceRoot":"","sources":["../../src/tool-widgets/activeCellToolWidget.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"activeCellToolWidget.js","sourceRoot":"","sources":["../../src/tool-widgets/activeCellToolWidget.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD;;GAEG;AACH,MAAM,8BAA8B,GAAG,2BAA2B,CAAC;AACnE;;GAEG;AACH,MAAM,mCA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export class CellMetadataField extends NotebookTools.MetadataEditorTool {
|
|
|
40
40
|
render(props) {
|
|
41
41
|
var _a;
|
|
42
42
|
const cell = this._tracker.activeCell;
|
|
43
|
+
// The editor detaches the previous source but does not dispose it, and
|
|
44
|
+
// this runs on every rebuild of the form.
|
|
45
|
+
const previousSource = this.editor.source;
|
|
43
46
|
this.editor.source = cell
|
|
44
47
|
? new ObservableJSON({ values: cell.model.metadata })
|
|
45
48
|
: null;
|
|
49
|
+
previousSource === null || previousSource === void 0 ? void 0 : previousSource.dispose();
|
|
46
50
|
(_a = this.editor.source) === null || _a === void 0 ? void 0 : _a.changed.connect(this._onSourceChanged, this);
|
|
47
51
|
return (React.createElement("div", { className: CELL_METADATA_EDITOR_CLASS },
|
|
48
52
|
React.createElement("div", { ref: ref => ref === null || ref === void 0 ? void 0 : ref.appendChild(this.node) })));
|
|
@@ -73,9 +77,13 @@ export class NotebookMetadataField extends NotebookTools.MetadataEditorTool {
|
|
|
73
77
|
render(props) {
|
|
74
78
|
var _a, _b;
|
|
75
79
|
const notebook = this._tracker.currentWidget;
|
|
80
|
+
// The editor detaches the previous source but does not dispose it, and
|
|
81
|
+
// this runs on every rebuild of the form.
|
|
82
|
+
const previousSource = this.editor.source;
|
|
76
83
|
this.editor.source = notebook
|
|
77
84
|
? new ObservableJSON({ values: (_a = notebook.model) === null || _a === void 0 ? void 0 : _a.metadata })
|
|
78
85
|
: null;
|
|
86
|
+
previousSource === null || previousSource === void 0 ? void 0 : previousSource.dispose();
|
|
79
87
|
(_b = this.editor.source) === null || _b === void 0 ? void 0 : _b.changed.connect(this._onSourceChanged, this);
|
|
80
88
|
return (React.createElement("div", { className: NOTEBOOK_METADATA_EDITOR_CLASS },
|
|
81
89
|
React.createElement("div", { ref: ref => ref === null || ref === void 0 ? void 0 : ref.appendChild(this.node) })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadataEditorFields.js","sourceRoot":"","sources":["../../src/tool-widgets/metadataEditorFields.ts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B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACvB,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,aAAa,0CAAE,KAAK,0CAAE,WAAW,CAAC,WAAW,CACzD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAC5B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAiB;;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC7C,uEAAuE;QACvE,0CAA0C;QAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,QAAQ;YAC3B,CAAC,CAAC,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,MAAA,QAAQ,CAAC,KAAK,0CAAE,QAAsB,EAAE,CAAC;YACxE,CAAC,CAAC,IAAI,CAAC;QACT,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,EAAE,CAAC;QAC1B,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAEjE,OAAO,CACL,6BAAK,SAAS,EAAE,8BAA8B;YAC5C,6BAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,CAChD,CACP,CAAC;IACJ,CAAC;CAGF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/notebook-extension",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.4",
|
|
4
4
|
"description": "JupyterLab - Notebook Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -37,36 +37,36 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jupyter/ydoc": "^4.0.0",
|
|
40
|
-
"@jupyterlab/application": "^4.6.
|
|
41
|
-
"@jupyterlab/apputils": "^4.7.
|
|
42
|
-
"@jupyterlab/cell-toolbar": "^4.6.
|
|
43
|
-
"@jupyterlab/cells": "^4.6.
|
|
44
|
-
"@jupyterlab/codeeditor": "^4.6.
|
|
45
|
-
"@jupyterlab/codemirror": "^4.6.
|
|
46
|
-
"@jupyterlab/completer": "^4.6.
|
|
47
|
-
"@jupyterlab/coreutils": "^6.6.
|
|
48
|
-
"@jupyterlab/docmanager": "^4.6.
|
|
49
|
-
"@jupyterlab/docmanager-extension": "^4.6.
|
|
50
|
-
"@jupyterlab/docregistry": "^4.6.
|
|
51
|
-
"@jupyterlab/documentsearch": "^4.6.
|
|
52
|
-
"@jupyterlab/filebrowser": "^4.6.
|
|
53
|
-
"@jupyterlab/launcher": "^4.6.
|
|
54
|
-
"@jupyterlab/logconsole": "^4.6.
|
|
55
|
-
"@jupyterlab/lsp": "^4.6.
|
|
56
|
-
"@jupyterlab/mainmenu": "^4.6.
|
|
57
|
-
"@jupyterlab/metadataform": "^4.6.
|
|
58
|
-
"@jupyterlab/nbformat": "^4.6.
|
|
59
|
-
"@jupyterlab/notebook": "^4.6.
|
|
60
|
-
"@jupyterlab/observables": "^5.6.
|
|
61
|
-
"@jupyterlab/property-inspector": "^4.6.
|
|
62
|
-
"@jupyterlab/rendermime": "^4.6.
|
|
63
|
-
"@jupyterlab/services": "^7.6.
|
|
64
|
-
"@jupyterlab/settingregistry": "^4.6.
|
|
65
|
-
"@jupyterlab/statedb": "^4.6.
|
|
66
|
-
"@jupyterlab/statusbar": "^4.6.
|
|
67
|
-
"@jupyterlab/toc": "^6.6.
|
|
68
|
-
"@jupyterlab/translation": "^4.6.
|
|
69
|
-
"@jupyterlab/ui-components": "^4.6.
|
|
40
|
+
"@jupyterlab/application": "^4.6.4",
|
|
41
|
+
"@jupyterlab/apputils": "^4.7.4",
|
|
42
|
+
"@jupyterlab/cell-toolbar": "^4.6.4",
|
|
43
|
+
"@jupyterlab/cells": "^4.6.4",
|
|
44
|
+
"@jupyterlab/codeeditor": "^4.6.4",
|
|
45
|
+
"@jupyterlab/codemirror": "^4.6.4",
|
|
46
|
+
"@jupyterlab/completer": "^4.6.4",
|
|
47
|
+
"@jupyterlab/coreutils": "^6.6.4",
|
|
48
|
+
"@jupyterlab/docmanager": "^4.6.4",
|
|
49
|
+
"@jupyterlab/docmanager-extension": "^4.6.4",
|
|
50
|
+
"@jupyterlab/docregistry": "^4.6.4",
|
|
51
|
+
"@jupyterlab/documentsearch": "^4.6.4",
|
|
52
|
+
"@jupyterlab/filebrowser": "^4.6.4",
|
|
53
|
+
"@jupyterlab/launcher": "^4.6.4",
|
|
54
|
+
"@jupyterlab/logconsole": "^4.6.4",
|
|
55
|
+
"@jupyterlab/lsp": "^4.6.4",
|
|
56
|
+
"@jupyterlab/mainmenu": "^4.6.4",
|
|
57
|
+
"@jupyterlab/metadataform": "^4.6.4",
|
|
58
|
+
"@jupyterlab/nbformat": "^4.6.4",
|
|
59
|
+
"@jupyterlab/notebook": "^4.6.4",
|
|
60
|
+
"@jupyterlab/observables": "^5.6.4",
|
|
61
|
+
"@jupyterlab/property-inspector": "^4.6.4",
|
|
62
|
+
"@jupyterlab/rendermime": "^4.6.4",
|
|
63
|
+
"@jupyterlab/services": "^7.6.4",
|
|
64
|
+
"@jupyterlab/settingregistry": "^4.6.4",
|
|
65
|
+
"@jupyterlab/statedb": "^4.6.4",
|
|
66
|
+
"@jupyterlab/statusbar": "^4.6.4",
|
|
67
|
+
"@jupyterlab/toc": "^6.6.4",
|
|
68
|
+
"@jupyterlab/translation": "^4.6.4",
|
|
69
|
+
"@jupyterlab/ui-components": "^4.6.4",
|
|
70
70
|
"@lumino/algorithm": "^2.0.4",
|
|
71
71
|
"@lumino/commands": "^2.3.3",
|
|
72
72
|
"@lumino/coreutils": "^2.2.2",
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { ILabShell, ILayoutRestorer, IRouter } from '@jupyterlab/application';
|
|
|
16
16
|
import type { ISessionContext } from '@jupyterlab/apputils';
|
|
17
17
|
import {
|
|
18
18
|
Clipboard,
|
|
19
|
+
CommandLinker,
|
|
19
20
|
createToolbarFactory,
|
|
20
21
|
Dialog,
|
|
21
22
|
ICommandPalette,
|
|
@@ -772,6 +773,9 @@ export const exportPlugin: JupyterFrontEndPlugin<void> = {
|
|
|
772
773
|
const formatList = Object.keys(response);
|
|
773
774
|
formatList.forEach(function (key) {
|
|
774
775
|
const formattedKey = key[0].toLocaleUpperCase() + key.slice(1);
|
|
776
|
+
// Fallback for export formats the server offers but `formatLabels`
|
|
777
|
+
// does not know about, so there is no literal to extract.
|
|
778
|
+
// eslint-disable-next-line jupyter/no-dynamic-translation
|
|
775
779
|
const capCaseKey = trans.__(formattedKey);
|
|
776
780
|
const labelStr = formatLabels[key] ? formatLabels[key] : capCaseKey;
|
|
777
781
|
let args = {
|
|
@@ -1114,6 +1118,9 @@ const updateRawMimetype: JupyterFrontEndPlugin<void> = {
|
|
|
1114
1118
|
).length > 0;
|
|
1115
1119
|
if (!mimetypeExists) {
|
|
1116
1120
|
const formattedKey = key[0].toLocaleUpperCase() + key.slice(1);
|
|
1121
|
+
// Fallback for export formats the server offers but `formatLabels`
|
|
1122
|
+
// does not know about, so there is no literal to extract.
|
|
1123
|
+
// eslint-disable-next-line jupyter/no-dynamic-translation
|
|
1117
1124
|
const altOption = trans.__(formattedKey);
|
|
1118
1125
|
const option = formatLabels[key] ? formatLabels[key] : altOption;
|
|
1119
1126
|
const mimeTypeValue = response[key].output_mimetype;
|
|
@@ -1151,15 +1158,20 @@ const customMetadataEditorFields: JupyterFrontEndPlugin<void> = {
|
|
|
1151
1158
|
) => {
|
|
1152
1159
|
const editorFactory: CodeEditor.Factory = options =>
|
|
1153
1160
|
editorServices.factoryService.newInlineEditor(options);
|
|
1154
|
-
// Register the custom fields.
|
|
1161
|
+
// Register the custom fields. As with the active cell tool below, the
|
|
1162
|
+
// field renderers are used by rjsf as React components, so they run on
|
|
1163
|
+
// every rebuild of the metadata form. Each field is created once and
|
|
1164
|
+
// reused: constructing one per render abandons an editor, its host node
|
|
1165
|
+
// and its listeners on every keystroke that rebuilds the form.
|
|
1166
|
+
const cellMetadataField = new CellMetadataField({
|
|
1167
|
+
editorFactory,
|
|
1168
|
+
tracker,
|
|
1169
|
+
label: 'Cell metadata',
|
|
1170
|
+
translator: translator
|
|
1171
|
+
});
|
|
1155
1172
|
const cellComponent: IFormRenderer = {
|
|
1156
1173
|
fieldRenderer: (props: FieldProps) => {
|
|
1157
|
-
return
|
|
1158
|
-
editorFactory,
|
|
1159
|
-
tracker,
|
|
1160
|
-
label: 'Cell metadata',
|
|
1161
|
-
translator: translator
|
|
1162
|
-
}).render(props);
|
|
1174
|
+
return cellMetadataField.render(props);
|
|
1163
1175
|
}
|
|
1164
1176
|
};
|
|
1165
1177
|
formRegistry.addRenderer(
|
|
@@ -1167,14 +1179,15 @@ const customMetadataEditorFields: JupyterFrontEndPlugin<void> = {
|
|
|
1167
1179
|
cellComponent
|
|
1168
1180
|
);
|
|
1169
1181
|
|
|
1182
|
+
const notebookMetadataField = new NotebookMetadataField({
|
|
1183
|
+
editorFactory,
|
|
1184
|
+
tracker,
|
|
1185
|
+
label: 'Notebook metadata',
|
|
1186
|
+
translator: translator
|
|
1187
|
+
});
|
|
1170
1188
|
const notebookComponent: IFormRenderer = {
|
|
1171
1189
|
fieldRenderer: (props: FieldProps) => {
|
|
1172
|
-
return
|
|
1173
|
-
editorFactory,
|
|
1174
|
-
tracker,
|
|
1175
|
-
label: 'Notebook metadata',
|
|
1176
|
-
translator: translator
|
|
1177
|
-
}).render(props);
|
|
1190
|
+
return notebookMetadataField.render(props);
|
|
1178
1191
|
}
|
|
1179
1192
|
};
|
|
1180
1193
|
formRegistry.addRenderer(
|
|
@@ -1199,12 +1212,18 @@ const activeCellTool: JupyterFrontEndPlugin<void> = {
|
|
|
1199
1212
|
formRegistry: IFormRendererRegistry,
|
|
1200
1213
|
languages: IEditorLanguageRegistry
|
|
1201
1214
|
) => {
|
|
1215
|
+
// The field renderer is used by rjsf as a React component, so it runs on
|
|
1216
|
+
// every rebuild of the metadata form. The tool is created once and reused:
|
|
1217
|
+
// constructing one per render would rebuild the prompt and the preview from
|
|
1218
|
+
// scratch (showing them empty until the next update) and would leave a
|
|
1219
|
+
// connection to the cell model behind for every abandoned instance.
|
|
1220
|
+
const tool = new ActiveCellTool({
|
|
1221
|
+
tracker,
|
|
1222
|
+
languages
|
|
1223
|
+
});
|
|
1202
1224
|
const component: IFormRenderer = {
|
|
1203
1225
|
fieldRenderer: (props: FieldProps) => {
|
|
1204
|
-
return
|
|
1205
|
-
tracker,
|
|
1206
|
-
languages
|
|
1207
|
-
}).render(props);
|
|
1226
|
+
return tool.render(props);
|
|
1208
1227
|
}
|
|
1209
1228
|
};
|
|
1210
1229
|
formRegistry.addRenderer(
|
|
@@ -2969,8 +2988,14 @@ function addCommands(
|
|
|
2969
2988
|
commands.addCommand(CommandIDs.trust, {
|
|
2970
2989
|
label: () => trans.__('Trust Notebook'),
|
|
2971
2990
|
execute: async args => {
|
|
2972
|
-
const
|
|
2973
|
-
|
|
2991
|
+
const trustBoundaryId = args[CommandLinker.TRUST_BOUNDARY_ID_ARG];
|
|
2992
|
+
const current =
|
|
2993
|
+
typeof trustBoundaryId === 'string'
|
|
2994
|
+
? (tracker.find(
|
|
2995
|
+
widget => widget.content.node.id === trustBoundaryId
|
|
2996
|
+
) ?? null)
|
|
2997
|
+
: getCurrent(tracker, shell, args);
|
|
2998
|
+
if (current && !current.isDisposed) {
|
|
2974
2999
|
const { context, content } = current;
|
|
2975
3000
|
const trustResult = await NotebookActions.trust(content);
|
|
2976
3001
|
if (trustResult.trusted) {
|
|
@@ -2984,7 +3009,12 @@ function addCommands(
|
|
|
2984
3009
|
describedBy: {
|
|
2985
3010
|
args: {
|
|
2986
3011
|
type: 'object',
|
|
2987
|
-
properties: {
|
|
3012
|
+
properties: {
|
|
3013
|
+
[CommandLinker.TRUST_BOUNDARY_ID_ARG]: {
|
|
3014
|
+
type: 'string',
|
|
3015
|
+
description: trans.__('The notebook trust boundary ID')
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
2988
3018
|
}
|
|
2989
3019
|
}
|
|
2990
3020
|
});
|