@datalayer/jupyter-react 0.19.9 → 0.20.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/components/cell/Cell.d.ts +5 -0
- package/lib/components/cell/Cell.js +6 -3
- package/lib/components/cell/Cell.js.map +1 -1
- package/lib/components/cell/CellAdapter.d.ts +3 -0
- package/lib/components/cell/CellAdapter.js +4 -1
- package/lib/components/cell/CellAdapter.js.map +1 -1
- package/lib/components/console/Console.js +5 -5
- package/lib/components/console/Console.js.map +1 -1
- package/lib/components/notebook/Notebook.d.ts +1 -1
- package/lib/components/notebook/Notebook.js +1 -2
- package/lib/components/notebook/Notebook.js.map +1 -1
- package/lib/components/output/Output.js +1 -1
- package/lib/components/output/Output.js.map +1 -1
- package/lib/components/output/OutputAdapter.js +2 -2
- package/lib/components/output/OutputAdapter.js.map +1 -1
- package/lib/examples/CellLite.js +2 -2
- package/lib/examples/CellLite.js.map +1 -1
- package/lib/examples/ConsoleLite.js +2 -2
- package/lib/examples/ConsoleLite.js.map +1 -1
- package/lib/examples/KernelExecute.js +1 -1
- package/lib/examples/KernelExecute.js.map +1 -1
- package/lib/examples/KernelExecutor.js +1 -1
- package/lib/examples/KernelExecutor.js.map +1 -1
- package/lib/examples/Kernels.js +1 -1
- package/lib/examples/Kernels.js.map +1 -1
- package/lib/examples/NotebookCellSidebar.js +1 -1
- package/lib/examples/NotebookCellSidebar.js.map +1 -1
- package/lib/examples/NotebookCellToolbar.js +1 -1
- package/lib/examples/NotebookCellToolbar.js.map +1 -1
- package/lib/examples/NotebookColormode.js +1 -1
- package/lib/examples/NotebookColormode.js.map +1 -1
- package/lib/examples/NotebookLite.js +1 -1
- package/lib/examples/NotebookLite.js.map +1 -1
- package/lib/examples/NotebookReadonly.js +1 -1
- package/lib/examples/NotebookReadonly.js.map +1 -1
- package/lib/examples/NotebookSimple.d.ts +1 -0
- package/lib/examples/NotebookSimple.js +35 -0
- package/lib/examples/NotebookSimple.js.map +1 -0
- package/lib/examples/Output.js +3 -3
- package/lib/examples/Output.js.map +1 -1
- package/lib/examples/OutputWithMonitoring.js +1 -1
- package/lib/examples/OutputWithMonitoring.js.map +1 -1
- package/lib/examples/Outputs.js +3 -3
- package/lib/examples/Outputs.js.map +1 -1
- package/lib/examples/notebooks/Lite.ipynb.json +146 -0
- package/lib/jupyter/JupyterContext.d.ts +0 -11
- package/lib/jupyter/JupyterContext.js +0 -2
- package/lib/jupyter/JupyterContext.js.map +1 -1
- package/lib/jupyter/lab/notebook/content/plugin.d.ts +1 -1
- package/lib/jupyter/lab/notebook/content/plugin.js +2 -2
- package/lib/jupyter/lab/notebook/content/plugin.js.map +1 -1
- package/lib/jupyter/lab/notebook/editor/history.d.ts +193 -0
- package/lib/jupyter/lab/notebook/editor/history.js +304 -0
- package/lib/jupyter/lab/notebook/editor/history.js.map +1 -0
- package/lib/jupyter/lab/notebook/editor/index.d.ts +0 -0
- package/lib/jupyter/lab/notebook/editor/index.js +6 -0
- package/lib/jupyter/lab/notebook/editor/index.js.map +1 -0
- package/lib/jupyter/lab/notebook/editor/plugin.d.ts +7 -0
- package/lib/jupyter/lab/notebook/editor/plugin.js +62 -0
- package/lib/jupyter/lab/notebook/editor/plugin.js.map +1 -0
- package/lib/jupyter/lab/notebook/editor/widgetfactory.d.ts +96 -0
- package/lib/jupyter/lab/notebook/editor/widgetfactory.js +89 -0
- package/lib/jupyter/lab/notebook/editor/widgetfactory.js.map +1 -0
- package/lib/jupyter/lab/plugin.d.ts +1 -1
- package/lib/jupyter/lab/plugin.js +6 -4
- package/lib/jupyter/lab/plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
7
|
+
import { Signal } from '@lumino/signaling';
|
|
8
|
+
/**
|
|
9
|
+
* A console history manager object.
|
|
10
|
+
*/
|
|
11
|
+
export class NotebookHistory {
|
|
12
|
+
/**
|
|
13
|
+
* Construct a new console history object.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this._sessionContext = options.sessionContext;
|
|
17
|
+
this._trans = (options.translator || nullTranslator).load('jupyterlab');
|
|
18
|
+
void this._handleKernel().then(() => {
|
|
19
|
+
this._sessionContext.kernelChanged.connect(this._handleKernel, this);
|
|
20
|
+
});
|
|
21
|
+
this._toRequest = this._requestBatchSize;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The client session used to query history.
|
|
25
|
+
*/
|
|
26
|
+
_sessionContext;
|
|
27
|
+
/**
|
|
28
|
+
* Translator to be used for warnings
|
|
29
|
+
*/
|
|
30
|
+
_trans;
|
|
31
|
+
/**
|
|
32
|
+
* The number of history items to request.
|
|
33
|
+
*/
|
|
34
|
+
_toRequest;
|
|
35
|
+
/**
|
|
36
|
+
* The number of history items to increase a batch size by per subsequent request.
|
|
37
|
+
*/
|
|
38
|
+
_requestBatchSize = 10;
|
|
39
|
+
/**
|
|
40
|
+
* The current editor used by the history manager.
|
|
41
|
+
*/
|
|
42
|
+
get editor() {
|
|
43
|
+
return this._editor;
|
|
44
|
+
}
|
|
45
|
+
set editor(value) {
|
|
46
|
+
if (this._editor === value) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const prev = this._editor;
|
|
50
|
+
if (prev) {
|
|
51
|
+
prev.model.sharedModel.changed.disconnect(this.onTextChange, this);
|
|
52
|
+
}
|
|
53
|
+
this._editor = value;
|
|
54
|
+
if (value) {
|
|
55
|
+
value.model.sharedModel.changed.connect(this.onTextChange, this);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The placeholder text that a history session began with.
|
|
60
|
+
*/
|
|
61
|
+
get placeholder() {
|
|
62
|
+
return this._placeholder;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Kernel session number for filtering
|
|
66
|
+
*/
|
|
67
|
+
get kernelSession() {
|
|
68
|
+
return this._kernelSession;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get whether the notebook history manager is disposed.
|
|
72
|
+
*/
|
|
73
|
+
get isDisposed() {
|
|
74
|
+
return this._isDisposed;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Dispose of the resources held by the notebook history manager.
|
|
78
|
+
*/
|
|
79
|
+
dispose() {
|
|
80
|
+
this._isDisposed = true;
|
|
81
|
+
this._history.length = 0;
|
|
82
|
+
Signal.clearData(this);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Set placeholder and editor. Start session if one is not already started.
|
|
86
|
+
*
|
|
87
|
+
* @param activeCell - The currently selected Cell in the notebook.
|
|
88
|
+
*/
|
|
89
|
+
async checkSession(activeCell) {
|
|
90
|
+
if (!this._hasSession) {
|
|
91
|
+
await this._retrieveHistory();
|
|
92
|
+
this._hasSession = true;
|
|
93
|
+
this.editor = activeCell.editor;
|
|
94
|
+
this._placeholder = this._editor?.model.sharedModel.getSource() || '';
|
|
95
|
+
// Filter the history with the placeholder string.
|
|
96
|
+
this.setFilter(this._placeholder);
|
|
97
|
+
this._cursor = this._filtered.length - 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the previous item in the notebook history.
|
|
102
|
+
*
|
|
103
|
+
* @param activeCell - The currently selected Cell in the notebook.
|
|
104
|
+
*
|
|
105
|
+
* @returns A Promise resolving to the historical cell content text.
|
|
106
|
+
*/
|
|
107
|
+
async back(activeCell) {
|
|
108
|
+
await this.checkSession(activeCell);
|
|
109
|
+
--this._cursor;
|
|
110
|
+
if (this._cursor < 0) {
|
|
111
|
+
await this.fetchBatch();
|
|
112
|
+
}
|
|
113
|
+
this._cursor = Math.max(0, this._cursor);
|
|
114
|
+
const content = this._filtered[this._cursor];
|
|
115
|
+
// This shouldn't ever be undefined as `setFilter` will always be run first
|
|
116
|
+
return content;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the next item in the notebook history.
|
|
120
|
+
*
|
|
121
|
+
* @param activeCell - The currently selected Cell in the notebook.
|
|
122
|
+
*
|
|
123
|
+
* @returns A Promise resolving to the historical cell content text.
|
|
124
|
+
*/
|
|
125
|
+
async forward(activeCell) {
|
|
126
|
+
await this.checkSession(activeCell);
|
|
127
|
+
++this._cursor;
|
|
128
|
+
this._cursor = Math.min(this._filtered.length - 1, this._cursor);
|
|
129
|
+
const content = this._filtered[this._cursor];
|
|
130
|
+
// This shouldn't ever be undefined as `setFilter` will always be run first
|
|
131
|
+
return content;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Update the editor of the cell with provided text content.
|
|
135
|
+
*
|
|
136
|
+
* @param activeCell - The currently selected Cell in the notebook.
|
|
137
|
+
* @param content - the result from back or forward
|
|
138
|
+
*/
|
|
139
|
+
updateEditor(activeCell, content) {
|
|
140
|
+
if (activeCell) {
|
|
141
|
+
const model = activeCell.editor?.model;
|
|
142
|
+
const source = model?.sharedModel.getSource();
|
|
143
|
+
if (this.isDisposed || !content) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (source === content) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
this._setByHistory = true;
|
|
150
|
+
model?.sharedModel.setSource(content);
|
|
151
|
+
let columnPos = 0;
|
|
152
|
+
columnPos = content.indexOf('\n');
|
|
153
|
+
if (columnPos < 0) {
|
|
154
|
+
columnPos = content.length;
|
|
155
|
+
}
|
|
156
|
+
activeCell.editor?.setCursorPosition({ line: 0, column: columnPos });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Reset the history navigation state, i.e., start a new history session.
|
|
161
|
+
*/
|
|
162
|
+
reset() {
|
|
163
|
+
this._hasSession = false;
|
|
164
|
+
this._placeholder = '';
|
|
165
|
+
this._toRequest = this._requestBatchSize;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Fetches a subsequent batch of history. Updates the filtered history and cursor to correct place in history,
|
|
169
|
+
* accounting for potentially new history items above it.
|
|
170
|
+
*/
|
|
171
|
+
async fetchBatch() {
|
|
172
|
+
this._toRequest += this._requestBatchSize;
|
|
173
|
+
let oldFilteredReversed = this._filtered.slice().reverse();
|
|
174
|
+
let oldHistory = this._history.slice();
|
|
175
|
+
await this._retrieveHistory().then(() => {
|
|
176
|
+
this.setFilter(this._placeholder);
|
|
177
|
+
let cursorOffset = 0;
|
|
178
|
+
let filteredReversed = this._filtered.slice().reverse();
|
|
179
|
+
for (let i = 0; i < oldFilteredReversed.length; i++) {
|
|
180
|
+
let item = oldFilteredReversed[i];
|
|
181
|
+
for (let ij = i + cursorOffset; ij < filteredReversed.length; ij++) {
|
|
182
|
+
if (item === filteredReversed[ij]) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
cursorOffset += 1;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
this._cursor =
|
|
191
|
+
this._filtered.length - (oldFilteredReversed.length + 1) - cursorOffset;
|
|
192
|
+
});
|
|
193
|
+
if (this._cursor < 0) {
|
|
194
|
+
if (this._history.length > oldHistory.length) {
|
|
195
|
+
await this.fetchBatch();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Populate the history collection on history reply from a kernel.
|
|
201
|
+
*
|
|
202
|
+
* @param value The kernel message history reply.
|
|
203
|
+
*
|
|
204
|
+
* #### Notes
|
|
205
|
+
* History entries have the shape:
|
|
206
|
+
* [session: number, line: number, input: string]
|
|
207
|
+
* Contiguous duplicates are stripped out of the API response.
|
|
208
|
+
*/
|
|
209
|
+
onHistory(value, cell) {
|
|
210
|
+
this._history.length = 0;
|
|
211
|
+
let last = ['', '', ''];
|
|
212
|
+
let current = ['', '', ''];
|
|
213
|
+
let kernelSession = '';
|
|
214
|
+
if (value.content.status === 'ok') {
|
|
215
|
+
for (let i = 0; i < value.content.history.length; i++) {
|
|
216
|
+
current = value.content.history[i];
|
|
217
|
+
if (current !== last) {
|
|
218
|
+
kernelSession = value.content.history[i][0];
|
|
219
|
+
this._history.push((last = current));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// set the kernel session for filtering
|
|
223
|
+
if (!this.kernelSession) {
|
|
224
|
+
if (current[2] == cell?.model.sharedModel.getSource()) {
|
|
225
|
+
this._kernelSession = kernelSession;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Handle a text change signal from the editor.
|
|
232
|
+
*/
|
|
233
|
+
onTextChange() {
|
|
234
|
+
if (this._setByHistory) {
|
|
235
|
+
this._setByHistory = false;
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
this.reset();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Handle the current kernel changing.
|
|
242
|
+
*/
|
|
243
|
+
async _handleKernel() {
|
|
244
|
+
this._kernel = this._sessionContext.session?.kernel;
|
|
245
|
+
if (!this._kernel) {
|
|
246
|
+
this._history.length = 0;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
await this._retrieveHistory().catch();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* retrieve the history from the kernel
|
|
254
|
+
*
|
|
255
|
+
* @param cell - The string to use when filtering the data.
|
|
256
|
+
*/
|
|
257
|
+
async _retrieveHistory(cell) {
|
|
258
|
+
return await this._kernel
|
|
259
|
+
?.requestHistory(request(this._toRequest))
|
|
260
|
+
.then(v => {
|
|
261
|
+
this.onHistory(v, cell);
|
|
262
|
+
})
|
|
263
|
+
.catch(() => {
|
|
264
|
+
console.warn(this._trans.__('History was unable to be retrieved'));
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Set the filter data.
|
|
269
|
+
*
|
|
270
|
+
* @param filterStr - The string to use when filtering the data.
|
|
271
|
+
*/
|
|
272
|
+
setFilter(filterStr = '') {
|
|
273
|
+
// Apply the new filter and remove contiguous duplicates.
|
|
274
|
+
this._filtered.length = 0;
|
|
275
|
+
let last = '';
|
|
276
|
+
let current = '';
|
|
277
|
+
for (let i = 0; i < this._history.length; i++) {
|
|
278
|
+
current = this._history[i][2];
|
|
279
|
+
if (current !== last && filterStr !== current) {
|
|
280
|
+
this._filtered.push((last = current));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
this._filtered.push(filterStr);
|
|
284
|
+
}
|
|
285
|
+
_cursor = 0;
|
|
286
|
+
_hasSession = false;
|
|
287
|
+
_history = [];
|
|
288
|
+
_placeholder = '';
|
|
289
|
+
_kernelSession = '';
|
|
290
|
+
_setByHistory = false;
|
|
291
|
+
_isDisposed = false;
|
|
292
|
+
_editor = null;
|
|
293
|
+
_filtered = [];
|
|
294
|
+
_kernel = null;
|
|
295
|
+
}
|
|
296
|
+
function request(n) {
|
|
297
|
+
return {
|
|
298
|
+
output: false,
|
|
299
|
+
raw: true,
|
|
300
|
+
hist_access_type: 'tail',
|
|
301
|
+
n: n
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../../../../src/jupyter/lab/notebook/editor/history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAsD3C;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACH,YAAY,OAAiC;QAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;QAC9C,IAAI,CAAC,MA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C,CAAC,CAAC;aACvC;SACF;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAEO,OAAO,GAAG,CAAC,CAAC;IACZ,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,GAAyB,EAAE,CAAC;IACpC,YAAY,GAAW,EAAE,CAAC;IAC1B,cAAc,GAAW,EAAE,CAAC;IAC5B,aAAa,GAAG,KAAK,CAAC;IACtB,WAAW,GAAG,KAAK,CAAC;IACpB,OAAO,GAA8B,IAAI,CAAC;IAC1C,SAAS,GAAa,EAAE,CAAC;IACzB,OAAO,GAAyC,IAAI,CAAC;CAC9D;AAsBD,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,IAAI;QACT,gBAAgB,EAAE,MAAM;QACxB,CAAC,EAAE,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/jupyter/lab/notebook/editor/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
+
import { NotebookWidgetFactory } from '@jupyterlab/notebook';
|
|
3
|
+
/**
|
|
4
|
+
* The notebook widget factory provider.
|
|
5
|
+
*/
|
|
6
|
+
export declare const widgetFactoryPlugin: JupyterFrontEndPlugin<NotebookWidgetFactory.IFactory>;
|
|
7
|
+
export default widgetFactoryPlugin;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { ISessionContextDialogs, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
|
|
7
|
+
import { NotebookPanel, NotebookWidgetFactory, INotebookWidgetFactory, StaticNotebook } from '@jupyterlab/notebook';
|
|
8
|
+
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
9
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
10
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
11
|
+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
12
|
+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
13
|
+
/**
|
|
14
|
+
* The name of the factory that creates notebooks.
|
|
15
|
+
*/
|
|
16
|
+
const FACTORY = 'Datalayer Notebook';
|
|
17
|
+
/**
|
|
18
|
+
* Activate the notebook widget factory.
|
|
19
|
+
*/
|
|
20
|
+
function activateWidgetFactory(app, contentFactory, editorServices, rendermime, toolbarRegistry, settingRegistry, sessionContextDialogs_, translator_) {
|
|
21
|
+
const translator = translator_ ?? nullTranslator;
|
|
22
|
+
const preferKernelOption = PageConfig.getOption('notebookStartsKernel');
|
|
23
|
+
// If the option is not set, assume `true`
|
|
24
|
+
const preferKernelValue = preferKernelOption === '' || preferKernelOption.toLowerCase() === 'true';
|
|
25
|
+
const trans = translator.load('jupyterlab');
|
|
26
|
+
const factory = new NotebookWidgetFactory({
|
|
27
|
+
name: FACTORY,
|
|
28
|
+
label: trans.__('Datalayer Notebook'),
|
|
29
|
+
fileTypes: ['notebook'],
|
|
30
|
+
modelName: 'notebook',
|
|
31
|
+
defaultFor: ['notebook'],
|
|
32
|
+
preferKernel: preferKernelValue,
|
|
33
|
+
canStartKernel: true,
|
|
34
|
+
rendermime,
|
|
35
|
+
contentFactory,
|
|
36
|
+
editorConfig: StaticNotebook.defaultEditorConfig,
|
|
37
|
+
notebookConfig: StaticNotebook.defaultNotebookConfig,
|
|
38
|
+
mimeTypeService: editorServices.mimeTypeService,
|
|
39
|
+
translator
|
|
40
|
+
});
|
|
41
|
+
app.docRegistry.addWidgetFactory(factory);
|
|
42
|
+
return factory;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The notebook widget factory provider.
|
|
46
|
+
*/
|
|
47
|
+
export const widgetFactoryPlugin = {
|
|
48
|
+
id: '@datalayer/notebook-extension:widget-factory',
|
|
49
|
+
description: 'Provides the notebook widget factory.',
|
|
50
|
+
provides: INotebookWidgetFactory,
|
|
51
|
+
requires: [
|
|
52
|
+
NotebookPanel.IContentFactory,
|
|
53
|
+
IEditorServices,
|
|
54
|
+
IRenderMimeRegistry,
|
|
55
|
+
IToolbarWidgetRegistry
|
|
56
|
+
],
|
|
57
|
+
optional: [ISettingRegistry, ISessionContextDialogs, ITranslator],
|
|
58
|
+
activate: activateWidgetFactory,
|
|
59
|
+
autoStart: true
|
|
60
|
+
};
|
|
61
|
+
export default widgetFactoryPlugin;
|
|
62
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/jupyter/lab/notebook/editor/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,GAAG,oBAAoB,CAAC;AAErC;;GAEG;AACH,SAAS,qBAAqB,CAC5B,GAAoB,EACpB,cAA6C,EAC7C,cAA+B,EAC/B,UAA+B,EAC/B,eAAuC,EACvC,eAAw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AmB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
2
|
+
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
4
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
5
|
+
import { INotebookModel, NotebookPanel, StaticNotebook } from '@jupyterlab/notebook';
|
|
6
|
+
/**
|
|
7
|
+
* A widget factory for notebook panels.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NotebookWidgetFactory extends ABCWidgetFactory<NotebookPanel, INotebookModel> {
|
|
10
|
+
/**
|
|
11
|
+
* Construct a new notebook widget factory.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The options used to construct the factory.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options: NotebookWidgetFactory.IOptions<NotebookPanel>);
|
|
16
|
+
readonly rendermime: IRenderMimeRegistry;
|
|
17
|
+
/**
|
|
18
|
+
* The content factory used by the widget factory.
|
|
19
|
+
*/
|
|
20
|
+
readonly contentFactory: NotebookPanel.IContentFactory;
|
|
21
|
+
/**
|
|
22
|
+
* The service used to look up mime types.
|
|
23
|
+
*/
|
|
24
|
+
readonly mimeTypeService: IEditorMimeTypeService;
|
|
25
|
+
/**
|
|
26
|
+
* A configuration object for cell editor settings.
|
|
27
|
+
*/
|
|
28
|
+
get editorConfig(): StaticNotebook.IEditorConfig;
|
|
29
|
+
set editorConfig(value: StaticNotebook.IEditorConfig);
|
|
30
|
+
/**
|
|
31
|
+
* A configuration object for notebook settings.
|
|
32
|
+
*/
|
|
33
|
+
get notebookConfig(): StaticNotebook.INotebookConfig;
|
|
34
|
+
set notebookConfig(value: StaticNotebook.INotebookConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Create a new widget.
|
|
37
|
+
*
|
|
38
|
+
* #### Notes
|
|
39
|
+
* The factory will start the appropriate kernel.
|
|
40
|
+
*/
|
|
41
|
+
protected createNewWidget(context: DocumentRegistry.IContext<INotebookModel>, source?: NotebookPanel): NotebookPanel;
|
|
42
|
+
private _editorConfig;
|
|
43
|
+
private _notebookConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The namespace for `NotebookWidgetFactory` statics.
|
|
47
|
+
*/
|
|
48
|
+
export declare namespace NotebookWidgetFactory {
|
|
49
|
+
/**
|
|
50
|
+
* The options used to construct a `NotebookWidgetFactory`.
|
|
51
|
+
*/
|
|
52
|
+
interface IOptions<T extends NotebookPanel> extends DocumentRegistry.IWidgetFactoryOptions<T> {
|
|
53
|
+
rendermime: IRenderMimeRegistry;
|
|
54
|
+
/**
|
|
55
|
+
* A notebook panel content factory.
|
|
56
|
+
*/
|
|
57
|
+
contentFactory: NotebookPanel.IContentFactory;
|
|
58
|
+
/**
|
|
59
|
+
* The service used to look up mime types.
|
|
60
|
+
*/
|
|
61
|
+
mimeTypeService: IEditorMimeTypeService;
|
|
62
|
+
/**
|
|
63
|
+
* The notebook cell editor configuration.
|
|
64
|
+
*/
|
|
65
|
+
editorConfig?: StaticNotebook.IEditorConfig;
|
|
66
|
+
/**
|
|
67
|
+
* The notebook configuration.
|
|
68
|
+
*/
|
|
69
|
+
notebookConfig?: StaticNotebook.INotebookConfig;
|
|
70
|
+
/**
|
|
71
|
+
* The application language translator.
|
|
72
|
+
*/
|
|
73
|
+
translator?: ITranslator;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The interface for a notebook widget factory.
|
|
77
|
+
*/
|
|
78
|
+
interface IFactory extends DocumentRegistry.IWidgetFactory<NotebookPanel, INotebookModel> {
|
|
79
|
+
/**
|
|
80
|
+
* Whether to automatically start the preferred kernel.
|
|
81
|
+
*/
|
|
82
|
+
autoStartDefault: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* A configuration object for cell editor settings.
|
|
85
|
+
*/
|
|
86
|
+
editorConfig: StaticNotebook.IEditorConfig;
|
|
87
|
+
/**
|
|
88
|
+
* A configuration object for notebook settings.
|
|
89
|
+
*/
|
|
90
|
+
notebookConfig: StaticNotebook.INotebookConfig;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the kernel should be shutdown when the widget is closed.
|
|
93
|
+
*/
|
|
94
|
+
shutdownOnClose: boolean;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
|
7
|
+
import { NotebookPanel, StaticNotebook } from '@jupyterlab/notebook';
|
|
8
|
+
import { NotebookHistory } from './history';
|
|
9
|
+
/**
|
|
10
|
+
* A widget factory for notebook panels.
|
|
11
|
+
*/
|
|
12
|
+
export class NotebookWidgetFactory extends ABCWidgetFactory {
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new notebook widget factory.
|
|
15
|
+
*
|
|
16
|
+
* @param options - The options used to construct the factory.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super(options);
|
|
20
|
+
this.rendermime = options.rendermime;
|
|
21
|
+
this.contentFactory = options.contentFactory;
|
|
22
|
+
this.mimeTypeService = options.mimeTypeService;
|
|
23
|
+
this._editorConfig =
|
|
24
|
+
options.editorConfig || StaticNotebook.defaultEditorConfig;
|
|
25
|
+
this._notebookConfig =
|
|
26
|
+
options.notebookConfig || StaticNotebook.defaultNotebookConfig;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* The rendermime instance.
|
|
30
|
+
*/
|
|
31
|
+
rendermime;
|
|
32
|
+
/**
|
|
33
|
+
* The content factory used by the widget factory.
|
|
34
|
+
*/
|
|
35
|
+
contentFactory;
|
|
36
|
+
/**
|
|
37
|
+
* The service used to look up mime types.
|
|
38
|
+
*/
|
|
39
|
+
mimeTypeService;
|
|
40
|
+
/**
|
|
41
|
+
* A configuration object for cell editor settings.
|
|
42
|
+
*/
|
|
43
|
+
get editorConfig() {
|
|
44
|
+
return this._editorConfig;
|
|
45
|
+
}
|
|
46
|
+
set editorConfig(value) {
|
|
47
|
+
this._editorConfig = value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A configuration object for notebook settings.
|
|
51
|
+
*/
|
|
52
|
+
get notebookConfig() {
|
|
53
|
+
return this._notebookConfig;
|
|
54
|
+
}
|
|
55
|
+
set notebookConfig(value) {
|
|
56
|
+
this._notebookConfig = value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a new widget.
|
|
60
|
+
*
|
|
61
|
+
* #### Notes
|
|
62
|
+
* The factory will start the appropriate kernel.
|
|
63
|
+
*/
|
|
64
|
+
createNewWidget(context, source) {
|
|
65
|
+
const translator = context.translator;
|
|
66
|
+
const kernelHistory = new NotebookHistory({
|
|
67
|
+
sessionContext: context.sessionContext,
|
|
68
|
+
translator: translator
|
|
69
|
+
});
|
|
70
|
+
const nbOptions = {
|
|
71
|
+
rendermime: source
|
|
72
|
+
? source.content.rendermime
|
|
73
|
+
: this.rendermime.clone({ resolver: context.urlResolver }),
|
|
74
|
+
contentFactory: this.contentFactory,
|
|
75
|
+
mimeTypeService: this.mimeTypeService,
|
|
76
|
+
editorConfig: source ? source.content.editorConfig : this._editorConfig,
|
|
77
|
+
notebookConfig: source
|
|
78
|
+
? source.content.notebookConfig
|
|
79
|
+
: this._notebookConfig,
|
|
80
|
+
translator,
|
|
81
|
+
kernelHistory
|
|
82
|
+
};
|
|
83
|
+
const content = this.contentFactory.createNotebook(nbOptions);
|
|
84
|
+
return new NotebookPanel({ context, content });
|
|
85
|
+
}
|
|
86
|
+
_editorConfig;
|
|
87
|
+
_notebookConfig;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=widgetfactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetfactory.js","sourceRoot":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AC/C,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC;YACxC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,UAAU,EAAE,UAAU;SACvB,CAAC,CAAC;QACH,MAAM,SAAS,GAAG;YAChB,UAAU,EAAE,MAAM;gBAChB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU;gBAC3B,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5D,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa;YACvE,cAAc,EAAE,MAAM;gBACpB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc;gBAC/B,CAAC,CAAC,IAAI,CAAC,eAAe;YACxB,UAAU;YACV,aAAa;SACd,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC9D,OAAO,IAAI,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IAEO,aAAa,CAA+B;IAC5C,eAAe,CAAiC;CACzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
2
|
import '../../../style/index.css';
|
|
3
|
-
declare const _default: (JupyterFrontEndPlugin<void> | JupyterFrontEndPlugin<import("@jupyterlab/notebook").NotebookPanel.IContentFactory>)[];
|
|
3
|
+
declare const _default: (JupyterFrontEndPlugin<void> | JupyterFrontEndPlugin<import("@jupyterlab/notebook").NotebookPanel.IContentFactory> | JupyterFrontEndPlugin<import("@jupyterlab/notebook").NotebookWidgetFactory.IFactory>)[];
|
|
4
4
|
export default _default;
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import { ILayoutRestorer
|
|
7
|
-
import { MainAreaWidget, ICommandPalette, WidgetTracker
|
|
6
|
+
import { ILayoutRestorer } from '@jupyterlab/application';
|
|
7
|
+
import { MainAreaWidget, ICommandPalette, WidgetTracker } from '@jupyterlab/apputils';
|
|
8
8
|
import { ILauncher } from '@jupyterlab/launcher';
|
|
9
9
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
10
10
|
import { ServerConnection } from '@jupyterlab/services';
|
|
11
11
|
import icon from '@datalayer/icons-react/data2/AtomSymbolIconJupyterLab';
|
|
12
12
|
import { requestAPI } from './../JupyterHandlers';
|
|
13
13
|
import { JupyterReactWidget } from './widget';
|
|
14
|
-
import notebookContentFactoryPlugin from './notebook/content/plugin';
|
|
14
|
+
import { contentFactoryPlugin as notebookContentFactoryPlugin } from './notebook/content/plugin';
|
|
15
|
+
import { widgetFactoryPlugin as notebookWidgetFactoryPlugin } from './notebook/editor/plugin';
|
|
15
16
|
import '../../../style/index.css';
|
|
16
17
|
/**
|
|
17
18
|
* The command IDs used by the plugin.
|
|
@@ -97,6 +98,7 @@ const jupyterReactPlugin = {
|
|
|
97
98
|
};
|
|
98
99
|
export default [
|
|
99
100
|
jupyterReactPlugin,
|
|
100
|
-
notebookContentFactoryPlugin
|
|
101
|
+
notebookContentFactoryPlugin,
|
|
102
|
+
notebookWidgetFactoryPlugin,
|
|
101
103
|
];
|
|
102
104
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/jupyter/lab/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/jupyter/lab/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,E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