@datalayer/jupyter-react 0.12.0 → 0.13.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 +9 -1
- package/lib/components/cell/Cell.js +53 -16
- package/lib/components/cell/Cell.js.map +1 -1
- package/lib/components/cell/CellAdapter.d.ts +9 -3
- package/lib/components/cell/CellAdapter.js +75 -37
- package/lib/components/cell/CellAdapter.js.map +1 -1
- package/lib/components/cell/CellCommands.d.ts +2 -2
- package/lib/components/cell/CellCommands.js +10 -3
- package/lib/components/cell/CellCommands.js.map +1 -1
- package/lib/examples/Cell.js +1 -1
- package/lib/examples/Cell.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
export type ICellProps = {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Cell type
|
|
4
|
+
*/
|
|
5
|
+
type: 'code' | 'markdown' | 'raw';
|
|
6
|
+
/**
|
|
7
|
+
* Cell source
|
|
4
8
|
*/
|
|
5
9
|
source?: string;
|
|
6
10
|
/**
|
|
7
11
|
* Whether to execute directly the code cell or not.
|
|
8
12
|
*/
|
|
9
13
|
autoStart?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to show the toolbar for cell or not
|
|
16
|
+
*/
|
|
17
|
+
showToolbar?: boolean;
|
|
10
18
|
};
|
|
11
19
|
export declare const Cell: {
|
|
12
20
|
(props: ICellProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,42 +5,74 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
* MIT License
|
|
6
6
|
*/
|
|
7
7
|
import { useState, useEffect } from 'react';
|
|
8
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
8
|
+
import { CodeCell, MarkdownCell } from '@jupyterlab/cells';
|
|
9
9
|
import { Box } from '@primer/react';
|
|
10
10
|
import CellAdapter from './CellAdapter';
|
|
11
11
|
import Lumino from '../lumino/Lumino';
|
|
12
12
|
import { useJupyter } from './../../jupyter/JupyterContext';
|
|
13
13
|
import useCellStore from './CellState';
|
|
14
14
|
export const Cell = (props) => {
|
|
15
|
-
const { source = '', autoStart } = props;
|
|
15
|
+
const { type = 'code', source = '', autoStart, showToolbar = true } = props;
|
|
16
16
|
const { serverSettings, defaultKernel } = useJupyter();
|
|
17
17
|
const cellStore = useCellStore();
|
|
18
18
|
const [adapter, setAdapter] = useState();
|
|
19
|
+
const handleCellInitEvents = (adapter) => {
|
|
20
|
+
adapter.cell.model.contentChanged.connect((cellModel, changedArgs) => {
|
|
21
|
+
cellStore.setSource(cellModel.sharedModel.getSource());
|
|
22
|
+
});
|
|
23
|
+
if (adapter.cell instanceof CodeCell) {
|
|
24
|
+
adapter.cell.outputArea.outputLengthChanged?.connect((outputArea, outputsCount) => {
|
|
25
|
+
cellStore.setOutputsCount(outputsCount);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
adapter.sessionContext.initialize().then(() => {
|
|
29
|
+
if (!autoStart) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Perform auto-start for code or markdown cells
|
|
33
|
+
if (adapter.cell instanceof CodeCell) {
|
|
34
|
+
const execute = CodeCell.execute(adapter.cell, adapter.sessionContext);
|
|
35
|
+
execute.then((msg) => {
|
|
36
|
+
cellStore.setKernelAvailable(true);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (adapter.cell instanceof MarkdownCell) {
|
|
40
|
+
adapter.cell.rendered = true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
19
44
|
useEffect(() => {
|
|
20
45
|
if (defaultKernel && serverSettings) {
|
|
21
46
|
defaultKernel.ready.then(() => {
|
|
22
47
|
const adapter = new CellAdapter({
|
|
48
|
+
type,
|
|
23
49
|
source,
|
|
24
50
|
serverSettings,
|
|
25
51
|
kernel: defaultKernel,
|
|
52
|
+
boxOptions: { showToolbar }
|
|
26
53
|
});
|
|
27
54
|
cellStore.setAdapter(adapter);
|
|
28
55
|
cellStore.setSource(source);
|
|
29
|
-
adapter
|
|
30
|
-
cellStore.setSource(cellModel.sharedModel.getSource());
|
|
31
|
-
});
|
|
32
|
-
adapter.codeCell.outputArea.outputLengthChanged.connect((outputArea, outputsCount) => {
|
|
33
|
-
cellStore.setOutputsCount(outputsCount);
|
|
34
|
-
});
|
|
35
|
-
adapter.sessionContext.initialize().then(() => {
|
|
36
|
-
if (autoStart) {
|
|
37
|
-
const execute = CodeCell.execute(adapter.codeCell, adapter.sessionContext);
|
|
38
|
-
execute.then((msg) => {
|
|
39
|
-
cellStore.setKernelAvailable(true);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
56
|
+
handleCellInitEvents(adapter);
|
|
43
57
|
setAdapter(adapter);
|
|
58
|
+
const handleDblClick = (event) => {
|
|
59
|
+
let target = event.target;
|
|
60
|
+
/**
|
|
61
|
+
* Find the DOM searching by the markdown output class (since child elements can be clicked also)
|
|
62
|
+
* If a rendered markdown was found, then back cell to editor mode
|
|
63
|
+
*/
|
|
64
|
+
while (target && !target.classList.contains('jp-MarkdownOutput')) {
|
|
65
|
+
target = target.parentElement;
|
|
66
|
+
}
|
|
67
|
+
if (target && target.classList.contains('jp-MarkdownOutput')) {
|
|
68
|
+
adapter.cell.rendered = false;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// Adds the event for double click and the removal on component's destroy
|
|
72
|
+
document.addEventListener('dblclick', handleDblClick);
|
|
73
|
+
return () => {
|
|
74
|
+
document.removeEventListener('dblclick', handleDblClick);
|
|
75
|
+
};
|
|
44
76
|
});
|
|
45
77
|
}
|
|
46
78
|
}, [source, defaultKernel, serverSettings]);
|
|
@@ -63,6 +95,11 @@ export const Cell = (props) => {
|
|
|
63
95
|
height: 'auto !important',
|
|
64
96
|
position: 'relative',
|
|
65
97
|
},
|
|
98
|
+
'& .jp-MarkdownCell': {
|
|
99
|
+
height: 'auto !important',
|
|
100
|
+
minHeight: '65px',
|
|
101
|
+
position: 'relative',
|
|
102
|
+
},
|
|
66
103
|
'& .jp-Cell-outputArea': {
|
|
67
104
|
paddingBottom: '30px',
|
|
68
105
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cell.js","sourceRoot":"","sources":["../../../src/components/cell/Cell.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Cell.js","sourceRoot":"","sources":["../../../src/components/cell/Cell.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,YAAY,MAAM,aAAa,CAAC;AAsBvC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAiB,EAAE,EAAE;IACxC,MAAM,EAAE,IAAI,GAAC,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,SAAS,EAAE,WAAW,GAAC,IAAI,EAAE,GAAG,KAAK,CAAC;IACxE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;IACvD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAe,CAAC;IAEtD,MAAM,oBAAoB,GAAG,CAAC,OAAoB,EAAE,EAAE;QACpD,OAAO,CAAC,IAA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AE;gBACZ,QAAQ,EAAE,UAAU;aACrB;YACD,gBAAgB,EAAE;gBAChB,MAAM,EAAE,iBAAiB;gBACzB,QAAQ,EAAE,UAAU;aACrB;YACD,oBAAoB,EAAE;gBACpB,MAAM,EAAE,iBAAiB;gBACzB,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,UAAU;aACrB;YACD,uBAAuB,EAAE;gBACvB,aAAa,EAAE,MAAM;aACtB;YACD,wBAAwB,EAAE;gBACxB,MAAM,EAAE,iBAAiB;aAC1B;SACF,YAED,KAAC,MAAM,cACJ,OAAO,CAAC,KAAK,GACP,GACL,CACP,CAAC,CAAC,CAAC,CACF,KAAC,GAAG,0CAEE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,IAAI,CAAC,YAAY,GAAG;IAClB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,IAAI;CACO,CAAC;AAEzB,eAAe,IAAI,CAAC"}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { BoxPanel } from '@lumino/widgets';
|
|
2
2
|
import { SessionContext } from '@jupyterlab/apputils';
|
|
3
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
3
|
+
import { CodeCell, MarkdownCell, RawCell } from '@jupyterlab/cells';
|
|
4
4
|
import { ServerConnection } from '@jupyterlab/services';
|
|
5
5
|
import Kernel from '../../jupyter/kernel/Kernel';
|
|
6
|
+
interface BoxOptions {
|
|
7
|
+
showToolbar?: boolean;
|
|
8
|
+
}
|
|
6
9
|
export declare class CellAdapter {
|
|
7
|
-
private
|
|
10
|
+
private _cell;
|
|
8
11
|
private _kernel;
|
|
9
12
|
private _panel;
|
|
10
13
|
private _sessionContext;
|
|
14
|
+
private _type;
|
|
11
15
|
constructor(options: CellAdapter.ICellAdapterOptions);
|
|
12
16
|
private setupCell;
|
|
13
17
|
get panel(): BoxPanel;
|
|
14
|
-
get
|
|
18
|
+
get cell(): CodeCell | MarkdownCell | RawCell;
|
|
15
19
|
get sessionContext(): SessionContext;
|
|
16
20
|
get kernel(): Kernel;
|
|
17
21
|
execute: () => void;
|
|
18
22
|
}
|
|
19
23
|
export declare namespace CellAdapter {
|
|
20
24
|
type ICellAdapterOptions = {
|
|
25
|
+
type: 'code' | 'markdown' | 'raw';
|
|
21
26
|
source: string;
|
|
22
27
|
serverSettings: ServerConnection.ISettings;
|
|
23
28
|
kernel: Kernel;
|
|
29
|
+
boxOptions?: BoxOptions;
|
|
24
30
|
};
|
|
25
31
|
}
|
|
26
32
|
export default CellAdapter;
|
|
@@ -7,8 +7,9 @@ import { BoxPanel, Widget } from '@lumino/widgets';
|
|
|
7
7
|
import { find } from '@lumino/algorithm';
|
|
8
8
|
import { CommandRegistry } from '@lumino/commands';
|
|
9
9
|
import { SessionContext, Toolbar, ToolbarButton, } from '@jupyterlab/apputils';
|
|
10
|
-
import { CodeCellModel, CodeCell, Cell } from '@jupyterlab/cells';
|
|
10
|
+
import { CodeCellModel, CodeCell, Cell, MarkdownCell, MarkdownCellModel } from '@jupyterlab/cells';
|
|
11
11
|
import { ybinding, CodeMirrorMimeTypeService, EditorLanguageRegistry, CodeMirrorEditorFactory, EditorExtensionRegistry, EditorThemeRegistry, } from '@jupyterlab/codemirror';
|
|
12
|
+
import { MathJaxTypesetter } from '@jupyterlab/mathjax-extension';
|
|
12
13
|
import { Completer, CompleterModel, CompletionHandler, ProviderReconciliator, KernelCompleterProvider, } from '@jupyterlab/completer';
|
|
13
14
|
import { RenderMimeRegistry, standardRendererFactories as initialFactories, } from '@jupyterlab/rendermime';
|
|
14
15
|
import { SessionManager, KernelManager, KernelSpecManager, } from '@jupyterlab/services';
|
|
@@ -17,18 +18,21 @@ import { createStandaloneCell } from '@jupyter/ydoc';
|
|
|
17
18
|
import { WIDGET_MIMETYPE, WidgetRenderer, } from '@jupyter-widgets/html-manager/lib/output_renderers';
|
|
18
19
|
import { requireLoader as loader } from '../../jupyter/ipywidgets/libembed-amd';
|
|
19
20
|
import ClassicWidgetManager from '../../jupyter/ipywidgets/classic/manager';
|
|
21
|
+
import getMarked from '../notebook/marked/marked';
|
|
20
22
|
import CellCommands from './CellCommands';
|
|
21
23
|
export class CellAdapter {
|
|
22
|
-
|
|
24
|
+
_cell;
|
|
23
25
|
_kernel;
|
|
24
26
|
_panel;
|
|
25
27
|
_sessionContext;
|
|
28
|
+
_type;
|
|
26
29
|
constructor(options) {
|
|
27
|
-
const { source, serverSettings, kernel } = options;
|
|
30
|
+
const { type, source, serverSettings, kernel, boxOptions } = options;
|
|
28
31
|
this._kernel = kernel;
|
|
29
|
-
this.
|
|
32
|
+
this._type = type;
|
|
33
|
+
this.setupCell(type, source, serverSettings, kernel, boxOptions);
|
|
30
34
|
}
|
|
31
|
-
setupCell(source, serverSettings, kernel) {
|
|
35
|
+
setupCell(type = 'code', source, serverSettings, kernel, boxOptions) {
|
|
32
36
|
const kernelManager = kernel.kernelManager ??
|
|
33
37
|
new KernelManager({
|
|
34
38
|
serverSettings,
|
|
@@ -132,7 +136,11 @@ export class CellAdapter {
|
|
|
132
136
|
document.addEventListener('keydown', event => {
|
|
133
137
|
commands.processKeydownEvent(event);
|
|
134
138
|
}, useCapture);
|
|
135
|
-
const rendermime = new RenderMimeRegistry({
|
|
139
|
+
const rendermime = new RenderMimeRegistry({
|
|
140
|
+
initialFactories,
|
|
141
|
+
latexTypesetter: new MathJaxTypesetter(),
|
|
142
|
+
markdownParser: getMarked(languages),
|
|
143
|
+
});
|
|
136
144
|
const iPyWidgetsClassicManager = new ClassicWidgetManager({ loader });
|
|
137
145
|
rendermime.addFactory({
|
|
138
146
|
safe: false,
|
|
@@ -144,21 +152,33 @@ export class CellAdapter {
|
|
|
144
152
|
extensions: editorExtensions(),
|
|
145
153
|
languages,
|
|
146
154
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}),
|
|
155
|
-
}),
|
|
156
|
-
contentFactory: new Cell.ContentFactory({
|
|
157
|
-
editorFactory: factoryService.newInlineEditor.bind(factoryService),
|
|
158
|
-
}),
|
|
155
|
+
const cellModel = createStandaloneCell({
|
|
156
|
+
cell_type: type,
|
|
157
|
+
source: source,
|
|
158
|
+
metadata: {},
|
|
159
|
+
});
|
|
160
|
+
const contentFactory = new Cell.ContentFactory({
|
|
161
|
+
editorFactory: factoryService.newInlineEditor.bind(factoryService),
|
|
159
162
|
});
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
if (type === 'code') {
|
|
164
|
+
this._cell = new CodeCell({
|
|
165
|
+
rendermime,
|
|
166
|
+
model: new CodeCellModel({ sharedModel: cellModel }),
|
|
167
|
+
contentFactory: contentFactory,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (type === 'markdown') {
|
|
171
|
+
this._cell = new MarkdownCell({
|
|
172
|
+
rendermime,
|
|
173
|
+
model: new MarkdownCellModel({ sharedModel: cellModel }),
|
|
174
|
+
contentFactory: contentFactory,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
this._cell.addClass('dla-Jupyter-Cell');
|
|
178
|
+
this._cell.initializeState();
|
|
179
|
+
if (this._type === 'markdown') {
|
|
180
|
+
this._cell.rendered = false;
|
|
181
|
+
}
|
|
162
182
|
this._sessionContext.kernelChanged.connect((_, arg) => {
|
|
163
183
|
const kernelConnection = arg.newValue;
|
|
164
184
|
console.log('Current Kernel Connection', kernelConnection);
|
|
@@ -171,19 +191,21 @@ export class CellAdapter {
|
|
|
171
191
|
});
|
|
172
192
|
this._sessionContext.kernelChanged.connect(() => {
|
|
173
193
|
void this._sessionContext.session?.kernel?.info.then(info => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
194
|
+
if (this._type === 'code') {
|
|
195
|
+
const lang = info.language_info;
|
|
196
|
+
const mimeType = mimeService.getMimeTypeByLanguage(lang);
|
|
197
|
+
this._cell.model.mimeType = mimeType;
|
|
198
|
+
}
|
|
177
199
|
});
|
|
178
200
|
});
|
|
179
|
-
const editor = this.
|
|
201
|
+
const editor = this._cell.editor;
|
|
180
202
|
const model = new CompleterModel();
|
|
181
203
|
const completer = new Completer({ editor, model });
|
|
182
204
|
const timeout = 1000;
|
|
183
205
|
const provider = new KernelCompleterProvider();
|
|
184
206
|
const reconciliator = new ProviderReconciliator({
|
|
185
207
|
context: {
|
|
186
|
-
widget: this.
|
|
208
|
+
widget: this._cell,
|
|
187
209
|
editor,
|
|
188
210
|
session: this._sessionContext.session,
|
|
189
211
|
},
|
|
@@ -195,7 +217,7 @@ export class CellAdapter {
|
|
|
195
217
|
const provider = new KernelCompleterProvider();
|
|
196
218
|
handler.reconciliator = new ProviderReconciliator({
|
|
197
219
|
context: {
|
|
198
|
-
widget: this.
|
|
220
|
+
widget: this._cell,
|
|
199
221
|
editor,
|
|
200
222
|
session: this._sessionContext.session,
|
|
201
223
|
},
|
|
@@ -204,7 +226,7 @@ export class CellAdapter {
|
|
|
204
226
|
});
|
|
205
227
|
});
|
|
206
228
|
handler.editor = editor;
|
|
207
|
-
CellCommands(commands, this.
|
|
229
|
+
CellCommands(commands, this._cell, this._sessionContext, handler);
|
|
208
230
|
completer.hide();
|
|
209
231
|
completer.addClass('jp-Completer-Cell');
|
|
210
232
|
Widget.attach(completer, document.body);
|
|
@@ -213,7 +235,12 @@ export class CellAdapter {
|
|
|
213
235
|
const runButton = new ToolbarButton({
|
|
214
236
|
icon: runIcon,
|
|
215
237
|
onClick: () => {
|
|
216
|
-
|
|
238
|
+
if (this._type === 'code') {
|
|
239
|
+
CodeCell.execute(this._cell, this._sessionContext);
|
|
240
|
+
}
|
|
241
|
+
else if (this._type === 'markdown') {
|
|
242
|
+
this._cell.rendered = true;
|
|
243
|
+
}
|
|
217
244
|
},
|
|
218
245
|
tooltip: 'Run',
|
|
219
246
|
});
|
|
@@ -222,15 +249,21 @@ export class CellAdapter {
|
|
|
222
249
|
toolbar.addItem('restart', Toolbar.createRestartButton(this._sessionContext));
|
|
223
250
|
// toolbar.addItem('name', Toolbar.createKernelNameItem(this._sessionContext));
|
|
224
251
|
toolbar.addItem('status', Toolbar.createKernelStatusItem(this._sessionContext));
|
|
225
|
-
this.
|
|
226
|
-
|
|
252
|
+
if (this._type === 'code') {
|
|
253
|
+
this._cell.outputsScrolled = false;
|
|
254
|
+
}
|
|
255
|
+
this._cell.activate();
|
|
227
256
|
this._panel = new BoxPanel();
|
|
228
257
|
this._panel.direction = 'top-to-bottom';
|
|
229
258
|
this._panel.spacing = 0;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
259
|
+
if (boxOptions?.showToolbar !== false) {
|
|
260
|
+
this._panel.addWidget(toolbar);
|
|
261
|
+
}
|
|
262
|
+
this._panel.addWidget(this._cell);
|
|
263
|
+
if (boxOptions?.showToolbar !== false) {
|
|
264
|
+
BoxPanel.setStretch(toolbar, 0);
|
|
265
|
+
}
|
|
266
|
+
BoxPanel.setStretch(this._cell, 1);
|
|
234
267
|
window.addEventListener('resize', () => {
|
|
235
268
|
this._panel.update();
|
|
236
269
|
});
|
|
@@ -239,8 +272,8 @@ export class CellAdapter {
|
|
|
239
272
|
get panel() {
|
|
240
273
|
return this._panel;
|
|
241
274
|
}
|
|
242
|
-
get
|
|
243
|
-
return this.
|
|
275
|
+
get cell() {
|
|
276
|
+
return this._cell;
|
|
244
277
|
}
|
|
245
278
|
get sessionContext() {
|
|
246
279
|
return this._sessionContext;
|
|
@@ -249,7 +282,12 @@ export class CellAdapter {
|
|
|
249
282
|
return this._kernel;
|
|
250
283
|
}
|
|
251
284
|
execute = () => {
|
|
252
|
-
|
|
285
|
+
if (this._type === 'code') {
|
|
286
|
+
CodeCell.execute(this._cell, this._sessionContext);
|
|
287
|
+
}
|
|
288
|
+
else if (this._type === 'markdown') {
|
|
289
|
+
this._cell.rendered = true;
|
|
290
|
+
}
|
|
253
291
|
};
|
|
254
292
|
}
|
|
255
293
|
export default CellAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellAdapter.js","sourceRoot":"","sources":["../../../src/components/cell/CellAdapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,cAAc,EAEd,OAAO,EACP,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CellAdapter.js","sourceRoot":"","sources":["../../../src/components/cell/CellAdapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,cAAc,EAEd,OAAO,EACP,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAW,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,IAAI,gBAAgB,GAC9C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,cAAc,EACd,aAAa,EACb,iBAA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AI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,GAAG,EAAE;QACb,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE;YACzB,QAAQ,CAAC,OAAO,CAAE,IAAI,CAAC,KAAkB,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;SAClE;aAAM,IAAI,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;YACnC,IAAI,CAAC,KAAsB,CAAC,QAAQ,GAAG,IAAI,CAAC;SAC9C;IACH,CAAC,CAAC;CACH;AAYD,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandRegistry } from '@lumino/commands';
|
|
2
2
|
import { CompletionHandler } from '@jupyterlab/completer';
|
|
3
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
3
|
+
import { CodeCell, MarkdownCell, RawCell } from '@jupyterlab/cells';
|
|
4
4
|
import { SessionContext } from '@jupyterlab/apputils';
|
|
5
|
-
export declare const CellCommands: (commandRegistry: CommandRegistry,
|
|
5
|
+
export declare const CellCommands: (commandRegistry: CommandRegistry, cell: CodeCell | MarkdownCell | RawCell, sessionContext: SessionContext, completerHandler: CompletionHandler) => void;
|
|
6
6
|
export default CellCommands;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
6
|
+
import { CodeCell, MarkdownCell } from '@jupyterlab/cells';
|
|
7
7
|
const cmdIds = {
|
|
8
8
|
invoke: 'completer:invoke',
|
|
9
9
|
select: 'completer:select',
|
|
10
10
|
};
|
|
11
|
-
export const CellCommands = (commandRegistry,
|
|
11
|
+
export const CellCommands = (commandRegistry, cell, sessionContext, completerHandler) => {
|
|
12
12
|
commandRegistry.addCommand(cmdIds.invoke, {
|
|
13
13
|
label: 'Completer: Invoke',
|
|
14
14
|
execute: () => completerHandler.invoke(),
|
|
@@ -18,7 +18,14 @@ export const CellCommands = (commandRegistry, codeCell, sessionContext, complete
|
|
|
18
18
|
execute: () => completerHandler.completer.selectActive(),
|
|
19
19
|
});
|
|
20
20
|
commandRegistry.addCommand('run:cell', {
|
|
21
|
-
execute: () =>
|
|
21
|
+
execute: () => {
|
|
22
|
+
if (cell instanceof CodeCell) {
|
|
23
|
+
CodeCell.execute(cell, sessionContext);
|
|
24
|
+
}
|
|
25
|
+
else if (cell instanceof MarkdownCell) {
|
|
26
|
+
cell.rendered = true;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
22
29
|
});
|
|
23
30
|
commandRegistry.addKeyBinding({
|
|
24
31
|
selector: '.jp-InputArea-editor.jp-mod-completer-enabled',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellCommands.js","sourceRoot":"","sources":["../../../src/components/cell/CellCommands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CellCommands.js","sourceRoot":"","sources":["../../../src/components/cell/CellCommands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAW,MAAM,mBAAmB,CAAC;AAGpE,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,eAAgC,EAChC,IAAuC,EACvC,cAA8B,EAC9B,gBAA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cell.js
CHANGED
|
@@ -18,7 +18,7 @@ for i in range(100):
|
|
|
18
18
|
display('I am a long string which is repeatedly added to the dom in separated divs: %d' % i)`;
|
|
19
19
|
const CellExample = () => {
|
|
20
20
|
const cellStore = useJupyterStore().cellStore();
|
|
21
|
-
console.log('Cell Outputs', cellStore.adapter?.
|
|
21
|
+
console.log('Cell Outputs', (cellStore.adapter?.cell).outputArea.model.toJSON());
|
|
22
22
|
return (_jsxs(Jupyter, { children: [_jsx(Box, { as: "h1", children: "A Jupyter Cell" }), _jsxs(Box, { children: ["Outputs Count: ", cellStore.outputsCount] }), _jsxs(Box, { children: ["Source: ", cellStore.source] }), _jsx(Box, { children: _jsx(Button, { onClick: () => cellStore.execute(), children: "Run cell" }) }), _jsx(Cell, { source: DEFAULT_SOURCE })] }));
|
|
23
23
|
};
|
|
24
24
|
root.render(_jsx(CellExample, {}));
|
package/lib/examples/Cell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cell.js","sourceRoot":"","sources":["../../src/examples/Cell.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Cell.js","sourceRoot":"","sources":["../../src/examples/Cell.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAE3C,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,C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