@difizen/libro-code-cell 0.1.18 → 0.1.19
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/es/code-cell-model.d.ts +1 -2
- package/es/code-cell-model.d.ts.map +1 -1
- package/es/code-cell-model.js +2 -1
- package/es/code-cell-view.d.ts +2 -0
- package/es/code-cell-view.d.ts.map +1 -1
- package/es/code-cell-view.js +22 -7
- package/package.json +4 -4
- package/src/code-cell-model.ts +3 -3
- package/src/code-cell-view.tsx +21 -7
package/es/code-cell-model.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ExecutionCount } from '@difizen/libro-common';
|
|
2
|
-
import type { ICodeCell } from '@difizen/libro-common';
|
|
1
|
+
import type { ICodeCell, ExecutionCount } from '@difizen/libro-common';
|
|
3
2
|
import type { ExecutableCellModel } from '@difizen/libro-core';
|
|
4
3
|
import { CellOptions, LibroCellModel } from '@difizen/libro-core';
|
|
5
4
|
import type { Event as ManaEvent } from '@difizen/mana-app';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-cell-model.d.ts","sourceRoot":"","sources":["../src/code-cell-model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-cell-model.d.ts","sourceRoot":"","sources":["../src/code-cell-model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAA2B,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBACa,kBAAmB,SAAQ,cAAe,YAAW,mBAAmB;IAEnF,YAAY,EAAE,cAAc,CAAC;IAE7B,SAAS,EAAE,OAAO,CAAC;IAEnB,eAAe,EAAE,OAAO,CAAC;IAEzB,kBAAkB,EAAE,OAAO,CAAC;IAEpB,eAAe,EAAE,MAAM,CAAC;IAEhC,WAAW,EAAE,WAAW,CAAC;IAGzB,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,CAE9B;gBAGsB,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,WAAW;IAYtC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC;IAY7C,cAAc,aAGZ;IAEO,OAAO;IAKhB,SAAS;CAGV"}
|
package/es/code-cell-model.js
CHANGED
|
@@ -17,6 +17,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
17
17
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
18
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
19
19
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
20
|
+
import { MIME } from '@difizen/libro-common';
|
|
20
21
|
import { CellOptions, LibroCellModel } from '@difizen/libro-core';
|
|
21
22
|
import { inject, prop, transient, ViewManager } from '@difizen/mana-app';
|
|
22
23
|
import { Emitter } from '@difizen/mana-app';
|
|
@@ -45,7 +46,7 @@ export var LibroCodeCellModel = (_dec = transient(), _dec2 = prop(), _dec3 = pro
|
|
|
45
46
|
_this.executing = false;
|
|
46
47
|
_this.msgChangeEmitter = new Emitter();
|
|
47
48
|
_this.executeCount = options.cell.execution_count || null;
|
|
48
|
-
_this.mimeType =
|
|
49
|
+
_this.mimeType = MIME.python;
|
|
49
50
|
_this.hasOutputHidden = false;
|
|
50
51
|
_this.hasOutputsScrolled = false;
|
|
51
52
|
_this.viewManager = viewManager;
|
package/es/code-cell-view.d.ts
CHANGED
|
@@ -5,10 +5,12 @@ import type { IOutput } from '@difizen/libro-common';
|
|
|
5
5
|
import type { LibroCell, CellViewOptions } from '@difizen/libro-core';
|
|
6
6
|
import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, LirboContextKey } from '@difizen/libro-core';
|
|
7
7
|
import type { ViewSize } from '@difizen/mana-app';
|
|
8
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
8
9
|
import { ViewManager, Deferred } from '@difizen/mana-app';
|
|
9
10
|
import type { LibroCodeCellModel } from './code-cell-model.js';
|
|
10
11
|
export declare const CellEditorMemo: import("react").NamedExoticComponent<{}>;
|
|
11
12
|
export declare class LibroCodeCellView extends LibroExecutableCellView {
|
|
13
|
+
protected toDisposeOnEditor: DisposableCollection;
|
|
12
14
|
protected readonly lirboContextKey: LirboContextKey;
|
|
13
15
|
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
14
16
|
viewManager: ViewManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-cell-view.d.ts","sourceRoot":"","sources":["../src/code-cell-view.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;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IAEzB,iBAAiB,EAAE,iBAAiB,CAAC;IAE7B,KAAK,EAAE,kBAAkB,CAAC;IAElC,OAAO,EAAE,OAAO,EAAE,CAAC;IAGnB,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,gBAAgB,SAAK;IAGZ,kBAAkB,SAAK;IAGvB,cAAc,SAAK;IAGnB,YAAY,EAAE,YAAY,CAA0B;IAE7D,SAAS,CAAC,kBAAkB,4BAAmC;IAC/D,IAAI,eAAe,6BAElB;IAEQ,YAAY,uDAKnB;IAEO,YAAY,CAAC,IAAI,EAAE,QAAQ;IAMpC,oBAAoB;gBAqBE,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB;IA6BxD,WAAW;IAQX,MAAM,IAAI,SAAS;IAQnB,WAAW;IAIpB,aAAa,CAAC,GAAG,EAAE,GAAG;IAKtB,SAAS,CAAC,eAAe,IAAI,qBAAqB;cAclC,YAAY;cA0BZ,gBAAgB;IAoBhC,SAAS,CAAC,WAAW;IAgBZ,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAMtD,IAAI,aAGX;IAEO,KAAK,WAAY,OAAO,UAS/B;IAEO,cAAc,aAGrB;CACH"}
|
package/es/code-cell-view.js
CHANGED
|
@@ -30,6 +30,8 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
|
|
|
30
30
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
31
31
|
import { isOutput } from '@difizen/libro-common';
|
|
32
32
|
import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, VirtualizedManagerHelper, LirboContextKey } from '@difizen/libro-core';
|
|
33
|
+
import { Disposable } from '@difizen/mana-app';
|
|
34
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
33
35
|
import { getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender, watch, Deferred } from '@difizen/mana-app';
|
|
34
36
|
import { useEffect, useRef, memo, forwardRef } from 'react';
|
|
35
37
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -91,6 +93,7 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
|
|
|
91
93
|
var _this;
|
|
92
94
|
_classCallCheck(this, LibroCodeCellView);
|
|
93
95
|
_this = _super.call(this, options, cellService);
|
|
96
|
+
_this.toDisposeOnEditor = new DisposableCollection();
|
|
94
97
|
_initializerDefineProperty(_this, "lirboContextKey", _descriptor, _assertThisInitialized(_this));
|
|
95
98
|
_this.view = CodeEditorViewComponent;
|
|
96
99
|
_this.viewManager = void 0;
|
|
@@ -278,6 +281,8 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
|
|
|
278
281
|
if (e.status === 'ready') {
|
|
279
282
|
_this3.editor = _this3.editorView.editor;
|
|
280
283
|
_this3.afterEditorReady();
|
|
284
|
+
} else if (e.status === 'disposed') {
|
|
285
|
+
_this3.toDisposeOnEditor.dispose();
|
|
281
286
|
}
|
|
282
287
|
});
|
|
283
288
|
case 11:
|
|
@@ -296,19 +301,29 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
|
|
|
296
301
|
value: function () {
|
|
297
302
|
var _afterEditorReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
298
303
|
var _this4 = this,
|
|
299
|
-
_this$
|
|
304
|
+
_this$editorView$onMo,
|
|
305
|
+
_this$editorView3,
|
|
306
|
+
_this$editor$onModelC,
|
|
307
|
+
_this$editor,
|
|
308
|
+
_this$editor$onModelC2;
|
|
300
309
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
301
310
|
while (1) switch (_context3.prev = _context3.next) {
|
|
302
311
|
case 0:
|
|
303
|
-
|
|
312
|
+
this.focusEditor();
|
|
313
|
+
this.toDisposeOnEditor.push(watch(this.parent.model, 'readOnly', function () {
|
|
304
314
|
var _this4$editorView;
|
|
305
315
|
(_this4$editorView = _this4.editorView) === null || _this4$editorView === void 0 || (_this4$editorView = _this4$editorView.editor) === null || _this4$editorView === void 0 || _this4$editorView.setOption('readOnly', getOrigin(_this4.parent.model.readOnly));
|
|
306
|
-
});
|
|
307
|
-
(_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0
|
|
316
|
+
}));
|
|
317
|
+
this.toDisposeOnEditor.push((_this$editorView$onMo = (_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 ? void 0 : _this$editorView3.onModalChange(function (val) {
|
|
308
318
|
return _this4.hasModal = val;
|
|
309
|
-
});
|
|
310
|
-
this.
|
|
311
|
-
|
|
319
|
+
})) !== null && _this$editorView$onMo !== void 0 ? _this$editorView$onMo : Disposable.NONE);
|
|
320
|
+
this.toDisposeOnEditor.push((_this$editor$onModelC = (_this$editor = this.editor) === null || _this$editor === void 0 || (_this$editor$onModelC2 = _this$editor.onModelContentChanged) === null || _this$editor$onModelC2 === void 0 ? void 0 : _this$editor$onModelC2.call(_this$editor, function (e) {
|
|
321
|
+
_this4.parent.model.onCellContentChange({
|
|
322
|
+
cell: _this4,
|
|
323
|
+
changes: e
|
|
324
|
+
});
|
|
325
|
+
})) !== null && _this$editor$onModelC !== void 0 ? _this$editor$onModelC : Disposable.NONE);
|
|
326
|
+
case 4:
|
|
312
327
|
case "end":
|
|
313
328
|
return _context3.stop();
|
|
314
329
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-code-cell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-code-editor": "^0.1.
|
|
36
|
-
"@difizen/libro-common": "^0.1.
|
|
37
|
-
"@difizen/libro-core": "^0.1.
|
|
35
|
+
"@difizen/libro-code-editor": "^0.1.19",
|
|
36
|
+
"@difizen/libro-common": "^0.1.19",
|
|
37
|
+
"@difizen/libro-core": "^0.1.19",
|
|
38
38
|
"@difizen/mana-app": "latest"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/code-cell-model.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ICodeCell } from '@difizen/libro-common';
|
|
1
|
+
import { MIME } from '@difizen/libro-common';
|
|
2
|
+
import type { ICodeCell, ExecutionCount } from '@difizen/libro-common';
|
|
3
3
|
import type { ExecutableCellModel } from '@difizen/libro-core';
|
|
4
4
|
import { CellOptions, LibroCellModel } from '@difizen/libro-core';
|
|
5
5
|
import type { Event as ManaEvent } from '@difizen/mana-app';
|
|
@@ -39,7 +39,7 @@ export class LibroCodeCellModel extends LibroCellModel implements ExecutableCell
|
|
|
39
39
|
this.executing = false;
|
|
40
40
|
this.msgChangeEmitter = new Emitter<any>();
|
|
41
41
|
this.executeCount = (options.cell as ICodeCell).execution_count || null;
|
|
42
|
-
this.mimeType =
|
|
42
|
+
this.mimeType = MIME.python;
|
|
43
43
|
this.hasOutputHidden = false;
|
|
44
44
|
this.hasOutputsScrolled = false;
|
|
45
45
|
this.viewManager = viewManager;
|
package/src/code-cell-view.tsx
CHANGED
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
LirboContextKey,
|
|
20
20
|
} from '@difizen/libro-core';
|
|
21
21
|
import type { ViewSize } from '@difizen/mana-app';
|
|
22
|
+
import { Disposable } from '@difizen/mana-app';
|
|
23
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
22
24
|
import {
|
|
23
25
|
getOrigin,
|
|
24
26
|
inject,
|
|
@@ -100,6 +102,7 @@ const CodeEditorViewComponent = forwardRef<HTMLDivElement>(
|
|
|
100
102
|
@transient()
|
|
101
103
|
@view('code-editor-cell-view')
|
|
102
104
|
export class LibroCodeCellView extends LibroExecutableCellView {
|
|
105
|
+
protected toDisposeOnEditor = new DisposableCollection();
|
|
103
106
|
@inject(LirboContextKey) protected readonly lirboContextKey: LirboContextKey;
|
|
104
107
|
override view = CodeEditorViewComponent;
|
|
105
108
|
|
|
@@ -256,19 +259,30 @@ export class LibroCodeCellView extends LibroExecutableCellView {
|
|
|
256
259
|
if (e.status === 'ready') {
|
|
257
260
|
this.editor = this.editorView!.editor;
|
|
258
261
|
this.afterEditorReady();
|
|
262
|
+
} else if (e.status === 'disposed') {
|
|
263
|
+
this.toDisposeOnEditor.dispose();
|
|
259
264
|
}
|
|
260
265
|
});
|
|
261
266
|
}
|
|
262
267
|
|
|
263
268
|
protected async afterEditorReady() {
|
|
264
|
-
watch(this.parent.model, 'readOnly', () => {
|
|
265
|
-
this.editorView?.editor?.setOption(
|
|
266
|
-
'readOnly',
|
|
267
|
-
getOrigin(this.parent.model.readOnly),
|
|
268
|
-
);
|
|
269
|
-
});
|
|
270
|
-
this.editorView?.onModalChange((val) => (this.hasModal = val));
|
|
271
269
|
this.focusEditor();
|
|
270
|
+
this.toDisposeOnEditor.push(
|
|
271
|
+
watch(this.parent.model, 'readOnly', () => {
|
|
272
|
+
this.editorView?.editor?.setOption(
|
|
273
|
+
'readOnly',
|
|
274
|
+
getOrigin(this.parent.model.readOnly),
|
|
275
|
+
);
|
|
276
|
+
}),
|
|
277
|
+
);
|
|
278
|
+
this.toDisposeOnEditor.push(
|
|
279
|
+
this.editorView?.onModalChange((val) => (this.hasModal = val)) ?? Disposable.NONE,
|
|
280
|
+
);
|
|
281
|
+
this.toDisposeOnEditor.push(
|
|
282
|
+
this.editor?.onModelContentChanged?.((e) => {
|
|
283
|
+
this.parent.model.onCellContentChange({ cell: this, changes: e });
|
|
284
|
+
}) ?? Disposable.NONE,
|
|
285
|
+
);
|
|
272
286
|
}
|
|
273
287
|
|
|
274
288
|
protected focusEditor() {
|