@difizen/libro-core 0.2.34 → 0.2.35-next.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.
@@ -1,6 +1,11 @@
1
- import type { IEditor } from '@difizen/libro-code-editor';
1
+ import type { CodeEditorView, CodeEditorViewOptions, IEditor } from '@difizen/libro-code-editor';
2
+ import { CodeEditorManager } from '@difizen/libro-code-editor';
3
+ import { DisposableCollection } from '@difizen/mana-app';
2
4
  import type { ReactNode } from 'react';
3
- import type { CellView, EditorStatus } from '../libro-protocol.js';
5
+ import { LibroContextKey } from '../libro-context-key.js';
6
+ import type { CellView, CellViewOptions } from '../libro-protocol.js';
7
+ import { EditorStatus } from '../libro-protocol.js';
8
+ import { CellService } from './libro-cell-protocol.js';
4
9
  import { LibroCellView } from './libro-cell-view.js';
5
10
  export interface EditorCellView extends CellView {
6
11
  editor: IEditor | undefined;
@@ -16,9 +21,22 @@ export declare const EditorCellView: {
16
21
  * 超出编辑器的相关能力放在其他的更高抽象中
17
22
  */
18
23
  export declare abstract class LibroEditorCellView extends LibroCellView implements EditorCellView {
24
+ protected toDisposeOnEditor: DisposableCollection;
19
25
  editor: IEditor | undefined;
26
+ protected readonly libroContextKey: LibroContextKey;
27
+ codeEditorManager: CodeEditorManager;
28
+ editorView?: CodeEditorView;
29
+ constructor(options: CellViewOptions, cellService: CellService);
30
+ protected getEditorOption(): CodeEditorViewOptions;
31
+ protected afterEditorReady(): Promise<void>;
32
+ createEditor(): Promise<void>;
20
33
  editorStatus: EditorStatus;
21
- renderEditor: () => ReactNode;
34
+ renderEditor: () => import("react/jsx-runtime").JSX.Element | null;
35
+ onViewMount(): void;
36
+ shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
37
+ protected focusEditor(): void;
38
+ focus: (toEdit: boolean) => void;
39
+ blur: () => void;
22
40
  get wrapperCls(): string;
23
41
  redo(): void;
24
42
  undo(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"libro-edit-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/libro-edit-cell-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAE5B,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,YAAY,EAAE,MAAM,SAAS,CAAC;CAC/B;AAED,eAAO,MAAM,cAAc;cACf,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAWvC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,mBACpB,SAAQ,aACR,YAAW,cAAc;IAGzB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAG5B,YAAY,EAAE,YAAY,CAAC;IAE3B,YAAY,EAAE,MAAM,SAAS,CAAC;IAE9B,IAAI,UAAU,WAEb;IAED,IAAI,IAAI,IAAI;IAIZ,IAAI,IAAI,IAAI;CAGb"}
1
+ {"version":3,"file":"libro-edit-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/libro-edit-cell-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,OAAO,EACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAEL,oBAAoB,EAOrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAE5B,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,YAAY,EAAE,MAAM,SAAS,CAAC;CAC/B;AAED,eAAO,MAAM,cAAc;cACf,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAWvC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,mBACpB,SAAQ,aACR,YAAW,cAAc;IAEzB,SAAS,CAAC,iBAAiB,uBAA8B;IAEzD,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAEH,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAClD,iBAAiB,EAAE,iBAAiB,CAAC;IAGhE,UAAU,CAAC,EAAE,cAAc,CAAC;gBAGN,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW;IAK/C,SAAS,CAAC,eAAe,IAAI,qBAAqB;cAalC,gBAAgB;IAoB1B,YAAY;IA2BlB,YAAY,EAAE,YAAY,CAA0B;IAEpD,YAAY,uDAKV;IAEO,WAAW;IAQX,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAQ/D,SAAS,CAAC,WAAW;IAgBZ,KAAK,WAAY,OAAO,UAS/B;IAEO,IAAI,aAGX;IAEF,IAAI,UAAU,WAEb;IAED,IAAI,IAAI,IAAI;IAIZ,IAAI,IAAI,IAAI;CAGb"}
@@ -1,5 +1,8 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _dec, _dec2, _class, _descriptor, _descriptor2;
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
6
  function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
8
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
@@ -15,9 +18,15 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
15
18
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
19
  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; }
17
20
  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.'); }
18
- import { prop } from '@difizen/mana-app';
21
+ import { CodeEditorManager } from '@difizen/libro-code-editor';
22
+ import { CellUri } from '@difizen/libro-common';
23
+ import { Disposable, DisposableCollection, getOrigin, inject, prop, ViewOption, ViewRender, watch } from '@difizen/mana-app';
24
+ import { LibroContextKey } from "../libro-context-key.js";
25
+ import { EditorStatus } from "../libro-protocol.js";
19
26
  import { isCellView } from "../libro-protocol.js";
27
+ import { CellService } from "./libro-cell-protocol.js";
20
28
  import { LibroCellView } from "./libro-cell-view.js";
29
+ import { jsx as _jsx } from "react/jsx-runtime";
21
30
  export var EditorCellView = {
22
31
  is: function is(arg) {
23
32
  return !!arg && isCellView(arg) &&
@@ -30,22 +39,175 @@ export var EditorCellView = {
30
39
  * 带有编辑器能力的cell view,例如raw、markdown、python、sql等
31
40
  * 超出编辑器的相关能力放在其他的更高抽象中
32
41
  */
33
- export var LibroEditorCellView = (_dec = prop(), _dec2 = prop(), (_class = /*#__PURE__*/function (_LibroCellView) {
42
+ export var LibroEditorCellView = (_dec = prop(), _dec2 = inject(LibroContextKey), _dec3 = inject(CodeEditorManager), _dec4 = prop(), _dec5 = prop(), (_class = /*#__PURE__*/function (_LibroCellView) {
34
43
  _inherits(LibroEditorCellView, _LibroCellView);
35
44
  var _super = _createSuper(LibroEditorCellView);
36
- function LibroEditorCellView() {
45
+ function LibroEditorCellView(options, cellService) {
37
46
  var _this;
38
47
  _classCallCheck(this, LibroEditorCellView);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _super.call.apply(_super, [this].concat(args));
48
+ _this = _super.call(this, options, cellService);
49
+ _this.toDisposeOnEditor = new DisposableCollection();
43
50
  _initializerDefineProperty(_this, "editor", _descriptor, _assertThisInitialized(_this));
44
- _initializerDefineProperty(_this, "editorStatus", _descriptor2, _assertThisInitialized(_this));
45
- _this.renderEditor = void 0;
51
+ _initializerDefineProperty(_this, "libroContextKey", _descriptor2, _assertThisInitialized(_this));
52
+ _initializerDefineProperty(_this, "codeEditorManager", _descriptor3, _assertThisInitialized(_this));
53
+ _initializerDefineProperty(_this, "editorView", _descriptor4, _assertThisInitialized(_this));
54
+ _initializerDefineProperty(_this, "editorStatus", _descriptor5, _assertThisInitialized(_this));
55
+ _this.renderEditor = function () {
56
+ if (_this.editorView) {
57
+ return /*#__PURE__*/_jsx(ViewRender, {
58
+ view: _this.editorView
59
+ });
60
+ }
61
+ return null;
62
+ };
63
+ _this.focus = function (toEdit) {
64
+ if (toEdit) {
65
+ _this.focusEditor();
66
+ } else {
67
+ var _this$container, _this$container2;
68
+ if ((_this$container = _this.container) !== null && _this$container !== void 0 && (_this$container = _this$container.current) !== null && _this$container !== void 0 && (_this$container = _this$container.parentElement) !== null && _this$container !== void 0 && _this$container.contains(document.activeElement)) {
69
+ return;
70
+ }
71
+ (_this$container2 = _this.container) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.current) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.parentElement) === null || _this$container2 === void 0 || _this$container2.focus();
72
+ }
73
+ };
74
+ _this.blur = function () {
75
+ var _this$editorView, _this$editorView2;
76
+ (_this$editorView = _this.editorView) === null || _this$editorView === void 0 || (_this$editorView = _this$editorView.editor) === null || _this$editorView === void 0 || _this$editorView.setOption('styleActiveLine', false);
77
+ (_this$editorView2 = _this.editorView) === null || _this$editorView2 === void 0 || (_this$editorView2 = _this$editorView2.editor) === null || _this$editorView2 === void 0 || _this$editorView2.setOption('highlightActiveLineGutter', false);
78
+ };
46
79
  return _this;
47
80
  }
81
+ LibroEditorCellView = inject(CellService)(LibroEditorCellView, undefined, 1) || LibroEditorCellView;
82
+ LibroEditorCellView = inject(ViewOption)(LibroEditorCellView, undefined, 0) || LibroEditorCellView;
48
83
  _createClass(LibroEditorCellView, [{
84
+ key: "getEditorOption",
85
+ value: function getEditorOption() {
86
+ var option = {
87
+ uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
88
+ editorHostId: this.parent.id + this.id,
89
+ model: this.model,
90
+ config: {
91
+ readOnly: !this.parent.model.inputEditable,
92
+ editable: this.parent.model.inputEditable
93
+ }
94
+ };
95
+ return option;
96
+ }
97
+ }, {
98
+ key: "afterEditorReady",
99
+ value: function () {
100
+ var _afterEditorReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
101
+ var _this2 = this,
102
+ _this$editorView$onMo,
103
+ _this$editorView3,
104
+ _this$editor$onModelC,
105
+ _this$editor,
106
+ _this$editor$onModelC2;
107
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ this.focusEditor();
111
+ this.toDisposeOnEditor.push(watch(this.parent.model, 'inputEditable', function () {
112
+ var _this2$editorView;
113
+ (_this2$editorView = _this2.editorView) === null || _this2$editorView === void 0 || (_this2$editorView = _this2$editorView.editor) === null || _this2$editorView === void 0 || _this2$editorView.setOption('readOnly', getOrigin(!_this2.parent.model.inputEditable));
114
+ }));
115
+ this.toDisposeOnEditor.push((_this$editorView$onMo = (_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 ? void 0 : _this$editorView3.onModalChange(function (val) {
116
+ return _this2.hasModal = val;
117
+ })) !== null && _this$editorView$onMo !== void 0 ? _this$editorView$onMo : Disposable.NONE);
118
+ 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) {
119
+ _this2.parent.model.onCellContentChange({
120
+ cell: _this2,
121
+ changes: e
122
+ });
123
+ })) !== null && _this$editor$onModelC !== void 0 ? _this$editor$onModelC : Disposable.NONE);
124
+ case 4:
125
+ case "end":
126
+ return _context.stop();
127
+ }
128
+ }, _callee, this);
129
+ }));
130
+ function afterEditorReady() {
131
+ return _afterEditorReady.apply(this, arguments);
132
+ }
133
+ return afterEditorReady;
134
+ }()
135
+ }, {
136
+ key: "createEditor",
137
+ value: function () {
138
+ var _createEditor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
139
+ var _this3 = this;
140
+ var option, editorView;
141
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
142
+ while (1) switch (_context2.prev = _context2.next) {
143
+ case 0:
144
+ option = this.getEditorOption();
145
+ this.editorStatus = EditorStatus.LOADING;
146
+
147
+ // 防止虚拟滚动中编辑器被频繁创建
148
+ if (!this.editorView) {
149
+ _context2.next = 5;
150
+ break;
151
+ }
152
+ this.editorStatus = EditorStatus.LOADED;
153
+ return _context2.abrupt("return");
154
+ case 5:
155
+ _context2.next = 7;
156
+ return this.codeEditorManager.getOrCreateEditorView(option);
157
+ case 7:
158
+ editorView = _context2.sent;
159
+ this.editorView = editorView;
160
+ this.editorStatus = EditorStatus.LOADED;
161
+ editorView.onEditorStatusChange(function (e) {
162
+ if (e.status === 'ready') {
163
+ _this3.editor = _this3.editorView.editor;
164
+ _this3.afterEditorReady();
165
+ } else if (e.status === 'disposed') {
166
+ _this3.toDisposeOnEditor.dispose();
167
+ }
168
+ });
169
+ case 11:
170
+ case "end":
171
+ return _context2.stop();
172
+ }
173
+ }, _callee2, this);
174
+ }));
175
+ function createEditor() {
176
+ return _createEditor.apply(this, arguments);
177
+ }
178
+ return createEditor;
179
+ }()
180
+ }, {
181
+ key: "onViewMount",
182
+ value: function onViewMount() {
183
+ var _this$parent$model$ac;
184
+ this.createEditor();
185
+ //选中cell时才focus
186
+ if (((_this$parent$model$ac = this.parent.model.active) === null || _this$parent$model$ac === void 0 ? void 0 : _this$parent$model$ac.id) === this.id) {
187
+ this.focus(!this.parent.model.commandMode);
188
+ }
189
+ }
190
+ }, {
191
+ key: "shouldEnterEditorMode",
192
+ value: function shouldEnterEditorMode(e) {
193
+ var _getOrigin;
194
+ return (_getOrigin = getOrigin(this.editorView)) !== null && _getOrigin !== void 0 && (_getOrigin = _getOrigin.editor) !== null && _getOrigin !== void 0 && (_getOrigin = _getOrigin.host) !== null && _getOrigin !== void 0 && _getOrigin.contains(e.target) && this.parent.model.commandMode ? true : false;
195
+ }
196
+ }, {
197
+ key: "focusEditor",
198
+ value: function focusEditor() {
199
+ var _this$editorView4, _this$parent$model$ac2;
200
+ //选中cell、编辑模式、非只读时才focus
201
+ if ((_this$editorView4 = this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.editor && this.editorView.editorStatus === 'ready' && ((_this$parent$model$ac2 = this.parent.model.active) === null || _this$parent$model$ac2 === void 0 ? void 0 : _this$parent$model$ac2.id) === this.id && !this.parent.model.commandMode && this.libroContextKey.commandModeEnabled === true &&
202
+ // 排除弹窗等情况
203
+ this.parent.model.inputEditable) {
204
+ var _this$editorView5, _this$editorView6, _this$editorView7;
205
+ (_this$editorView5 = this.editorView) === null || _this$editorView5 === void 0 || _this$editorView5.editor.setOption('styleActiveLine', true);
206
+ (_this$editorView6 = this.editorView) === null || _this$editorView6 === void 0 || _this$editorView6.editor.setOption('highlightActiveLineGutter', true);
207
+ (_this$editorView7 = this.editorView) === null || _this$editorView7 === void 0 || _this$editorView7.editor.focus();
208
+ }
209
+ }
210
+ }, {
49
211
  key: "wrapperCls",
50
212
  get: function get() {
51
213
  return '';
@@ -53,14 +215,14 @@ export var LibroEditorCellView = (_dec = prop(), _dec2 = prop(), (_class = /*#__
53
215
  }, {
54
216
  key: "redo",
55
217
  value: function redo() {
56
- var _this$editor;
57
- (_this$editor = this.editor) === null || _this$editor === void 0 || _this$editor.redo();
218
+ var _this$editor2;
219
+ (_this$editor2 = this.editor) === null || _this$editor2 === void 0 || _this$editor2.redo();
58
220
  }
59
221
  }, {
60
222
  key: "undo",
61
223
  value: function undo() {
62
- var _this$editor2;
63
- (_this$editor2 = this.editor) === null || _this$editor2 === void 0 || _this$editor2.undo();
224
+ var _this$editor3;
225
+ (_this$editor3 = this.editor) === null || _this$editor3 === void 0 || _this$editor3.undo();
64
226
  }
65
227
  }]);
66
228
  return LibroEditorCellView;
@@ -69,9 +231,26 @@ export var LibroEditorCellView = (_dec = prop(), _dec2 = prop(), (_class = /*#__
69
231
  enumerable: true,
70
232
  writable: true,
71
233
  initializer: null
72
- }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "editorStatus", [_dec2], {
234
+ }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "libroContextKey", [_dec2], {
73
235
  configurable: true,
74
236
  enumerable: true,
75
237
  writable: true,
76
238
  initializer: null
239
+ }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "codeEditorManager", [_dec3], {
240
+ configurable: true,
241
+ enumerable: true,
242
+ writable: true,
243
+ initializer: null
244
+ }), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "editorView", [_dec4], {
245
+ configurable: true,
246
+ enumerable: true,
247
+ writable: true,
248
+ initializer: null
249
+ }), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "editorStatus", [_dec5], {
250
+ configurable: true,
251
+ enumerable: true,
252
+ writable: true,
253
+ initializer: function initializer() {
254
+ return EditorStatus.NOTLOADED;
255
+ }
77
256
  })), _class));
@@ -17,7 +17,7 @@ export declare const ExecutableCellView: {
17
17
  * 带有编辑器、执行、output相关能力的cell view,例如python、sql
18
18
  * model 必须为 ExecutableCellModel
19
19
  */
20
- export declare abstract class LibroExecutableCellView extends LibroEditorCellView implements ExecutableCellView {
20
+ export declare abstract class LibroEditableExecutableCellView extends LibroEditorCellView implements ExecutableCellView {
21
21
  model: CellModel & ExecutableCellModel;
22
22
  outputArea: BaseOutputArea;
23
23
  noEditorAreaHeight: number;
@@ -26,5 +26,9 @@ export declare abstract class LibroExecutableCellView extends LibroEditorCellVie
26
26
  hasCellHidden(): boolean;
27
27
  outputWatch(): void;
28
28
  }
29
+ /**
30
+ * @deprecated use LibroEditableExecutableCellView instead.
31
+ */
32
+ export declare const LibroExecutableCellView: typeof LibroEditableExecutableCellView;
29
33
  export {};
30
34
  //# sourceMappingURL=libro-executable-cell-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"libro-executable-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/libro-executable-cell-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,UAAU,kBAAmB,SAAQ,cAAc;IACjD,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B,UAAU,EAAE,cAAc,CAAC;IAE3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,kBAAkB;cACnB,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAYvC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,uBACpB,SAAQ,mBACR,YAAW,kBAAkB;IAErB,KAAK,EAAE,SAAS,GAAG,mBAAmB,CAAC;IAE/C,UAAU,EAAE,cAAc,CAAC;IAEnB,kBAAkB,EAAE,MAAM,CAAC;gBAGb,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW;IAM/C,cAAc,EAAE,MAAM,IAAI,CAExB;IAGO,aAAa;IAUtB,WAAW;CAOZ"}
1
+ {"version":3,"file":"libro-executable-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/libro-executable-cell-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,UAAU,kBAAmB,SAAQ,cAAc;IACjD,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B,UAAU,EAAE,cAAc,CAAC;IAE3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,kBAAkB;cACnB,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAYvC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,+BACpB,SAAQ,mBACR,YAAW,kBAAkB;IAErB,KAAK,EAAE,SAAS,GAAG,mBAAmB,CAAC;IAE/C,UAAU,EAAE,cAAc,CAAC;IAEnB,kBAAkB,EAAE,MAAM,CAAC;gBAGb,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW;IAM/C,cAAc,EAAE,MAAM,IAAI,CAExB;IAGO,aAAa;IAUtB,WAAW;CAOZ;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,wCAAkC,CAAC"}
@@ -29,12 +29,12 @@ export var ExecutableCellView = {
29
29
  * 带有编辑器、执行、output相关能力的cell view,例如python、sql
30
30
  * model 必须为 ExecutableCellModel
31
31
  */
32
- export var LibroExecutableCellView = /*#__PURE__*/function (_LibroEditorCellView) {
33
- _inherits(LibroExecutableCellView, _LibroEditorCellView);
34
- var _super = _createSuper(LibroExecutableCellView);
35
- function LibroExecutableCellView(options, cellService) {
32
+ export var LibroEditableExecutableCellView = /*#__PURE__*/function (_LibroEditorCellView) {
33
+ _inherits(LibroEditableExecutableCellView, _LibroEditorCellView);
34
+ var _super = _createSuper(LibroEditableExecutableCellView);
35
+ function LibroEditableExecutableCellView(options, cellService) {
36
36
  var _this;
37
- _classCallCheck(this, LibroExecutableCellView);
37
+ _classCallCheck(this, LibroEditableExecutableCellView);
38
38
  _this = _super.call(this, options, cellService);
39
39
  _this.outputArea = void 0;
40
40
  _this.clearExecution = function () {
@@ -43,9 +43,9 @@ export var LibroExecutableCellView = /*#__PURE__*/function (_LibroEditorCellView
43
43
  _this.outputWatch();
44
44
  return _this;
45
45
  }
46
- LibroExecutableCellView = inject(CellService)(LibroExecutableCellView, undefined, 1) || LibroExecutableCellView;
47
- LibroExecutableCellView = inject(ViewOption)(LibroExecutableCellView, undefined, 0) || LibroExecutableCellView;
48
- _createClass(LibroExecutableCellView, [{
46
+ LibroEditableExecutableCellView = inject(CellService)(LibroEditableExecutableCellView, undefined, 1) || LibroEditableExecutableCellView;
47
+ LibroEditableExecutableCellView = inject(ViewOption)(LibroEditableExecutableCellView, undefined, 0) || LibroEditableExecutableCellView;
48
+ _createClass(LibroEditableExecutableCellView, [{
49
49
  key: "hasCellHidden",
50
50
  value:
51
51
  // TODO: 性能!
@@ -65,5 +65,10 @@ export var LibroExecutableCellView = /*#__PURE__*/function (_LibroEditorCellView
65
65
  }));
66
66
  }
67
67
  }]);
68
- return LibroExecutableCellView;
69
- }(LibroEditorCellView);
68
+ return LibroEditableExecutableCellView;
69
+ }(LibroEditorCellView);
70
+
71
+ /**
72
+ * @deprecated use LibroEditableExecutableCellView instead.
73
+ */
74
+ export var LibroExecutableCellView = LibroEditableExecutableCellView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-core",
3
- "version": "0.2.34",
3
+ "version": "0.2.35-next.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -34,10 +34,10 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.1.0",
37
- "@difizen/libro-code-editor": "^0.2.34",
38
- "@difizen/libro-common": "^0.2.34",
39
- "@difizen/libro-shared-model": "^0.2.34",
40
- "@difizen/libro-virtualized": "^0.2.34",
37
+ "@difizen/libro-code-editor": "^0.2.35-next.0",
38
+ "@difizen/libro-common": "^0.2.35-next.0",
39
+ "@difizen/libro-shared-model": "^0.2.35-next.0",
40
+ "@difizen/libro-virtualized": "^0.2.35-next.0",
41
41
  "@difizen/mana-app": "latest",
42
42
  "@difizen/mana-l10n": "latest",
43
43
  "@difizen/mana-react": "latest",
@@ -6,7 +6,7 @@
6
6
 
7
7
  - LibroCellView
8
8
  - LibroEditorCellView: 带有文本编辑器相关能力
9
- - LibroExecutableCellView: 带有执行、输出能力
9
+ - LibroEditableExecutableCellView: 带有执行、输出能力
10
10
  - LibroCodeCellView
11
11
  - AIStudioLibroCodeCellView
12
12
  - LibroSqlCellView
@@ -1,10 +1,28 @@
1
- import type { IEditor } from '@difizen/libro-code-editor';
2
- import { prop } from '@difizen/mana-app';
1
+ import type {
2
+ CodeEditorView,
3
+ CodeEditorViewOptions,
4
+ IEditor,
5
+ } from '@difizen/libro-code-editor';
6
+ import { CodeEditorManager } from '@difizen/libro-code-editor';
7
+ import { CellUri } from '@difizen/libro-common';
8
+ import {
9
+ Disposable,
10
+ DisposableCollection,
11
+ getOrigin,
12
+ inject,
13
+ prop,
14
+ ViewOption,
15
+ ViewRender,
16
+ watch,
17
+ } from '@difizen/mana-app';
3
18
  import type { ReactNode } from 'react';
4
19
 
5
- import type { CellView, EditorStatus } from '../libro-protocol.js';
20
+ import { LibroContextKey } from '../libro-context-key.js';
21
+ import type { CellView, CellViewOptions } from '../libro-protocol.js';
22
+ import { EditorStatus } from '../libro-protocol.js';
6
23
  import { isCellView } from '../libro-protocol.js';
7
24
 
25
+ import { CellService } from './libro-cell-protocol.js';
8
26
  import { LibroCellView } from './libro-cell-view.js';
9
27
 
10
28
  export interface EditorCellView extends CellView {
@@ -39,13 +57,139 @@ export abstract class LibroEditorCellView
39
57
  extends LibroCellView
40
58
  implements EditorCellView
41
59
  {
60
+ protected toDisposeOnEditor = new DisposableCollection();
42
61
  @prop()
43
62
  editor: IEditor | undefined;
44
63
 
64
+ @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
65
+ @inject(CodeEditorManager) codeEditorManager: CodeEditorManager;
66
+
45
67
  @prop()
46
- editorStatus: EditorStatus;
68
+ editorView?: CodeEditorView;
47
69
 
48
- renderEditor: () => ReactNode;
70
+ constructor(
71
+ @inject(ViewOption) options: CellViewOptions,
72
+ @inject(CellService) cellService: CellService,
73
+ ) {
74
+ super(options, cellService);
75
+ }
76
+
77
+ protected getEditorOption(): CodeEditorViewOptions {
78
+ const option: CodeEditorViewOptions = {
79
+ uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
80
+ editorHostId: this.parent.id + this.id,
81
+ model: this.model,
82
+ config: {
83
+ readOnly: !this.parent.model.inputEditable,
84
+ editable: this.parent.model.inputEditable,
85
+ },
86
+ };
87
+ return option;
88
+ }
89
+
90
+ protected async afterEditorReady() {
91
+ this.focusEditor();
92
+ this.toDisposeOnEditor.push(
93
+ watch(this.parent.model, 'inputEditable', () => {
94
+ this.editorView?.editor?.setOption(
95
+ 'readOnly',
96
+ getOrigin(!this.parent.model.inputEditable),
97
+ );
98
+ }),
99
+ );
100
+ this.toDisposeOnEditor.push(
101
+ this.editorView?.onModalChange((val) => (this.hasModal = val)) ?? Disposable.NONE,
102
+ );
103
+ this.toDisposeOnEditor.push(
104
+ this.editor?.onModelContentChanged?.((e) => {
105
+ this.parent.model.onCellContentChange({ cell: this, changes: e });
106
+ }) ?? Disposable.NONE,
107
+ );
108
+ }
109
+
110
+ async createEditor() {
111
+ const option = this.getEditorOption();
112
+
113
+ this.editorStatus = EditorStatus.LOADING;
114
+
115
+ // 防止虚拟滚动中编辑器被频繁创建
116
+ if (this.editorView) {
117
+ this.editorStatus = EditorStatus.LOADED;
118
+ return;
119
+ }
120
+
121
+ const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
122
+
123
+ this.editorView = editorView;
124
+ this.editorStatus = EditorStatus.LOADED;
125
+
126
+ editorView.onEditorStatusChange((e) => {
127
+ if (e.status === 'ready') {
128
+ this.editor = this.editorView!.editor;
129
+ this.afterEditorReady();
130
+ } else if (e.status === 'disposed') {
131
+ this.toDisposeOnEditor.dispose();
132
+ }
133
+ });
134
+ }
135
+
136
+ @prop()
137
+ editorStatus: EditorStatus = EditorStatus.NOTLOADED;
138
+
139
+ renderEditor = () => {
140
+ if (this.editorView) {
141
+ return <ViewRender view={this.editorView} />;
142
+ }
143
+ return null;
144
+ };
145
+
146
+ override onViewMount() {
147
+ this.createEditor();
148
+ //选中cell时才focus
149
+ if (this.parent.model.active?.id === this.id) {
150
+ this.focus(!this.parent.model.commandMode);
151
+ }
152
+ }
153
+
154
+ override shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
155
+ return getOrigin(this.editorView)?.editor?.host?.contains(
156
+ e.target as HTMLElement,
157
+ ) && this.parent.model.commandMode
158
+ ? true
159
+ : false;
160
+ }
161
+
162
+ protected focusEditor() {
163
+ //选中cell、编辑模式、非只读时才focus
164
+ if (
165
+ this.editorView?.editor &&
166
+ this.editorView.editorStatus === 'ready' &&
167
+ this.parent.model.active?.id === this.id &&
168
+ !this.parent.model.commandMode &&
169
+ this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
170
+ this.parent.model.inputEditable
171
+ ) {
172
+ this.editorView?.editor.setOption('styleActiveLine', true);
173
+ this.editorView?.editor.setOption('highlightActiveLineGutter', true);
174
+ this.editorView?.editor.focus();
175
+ }
176
+ }
177
+
178
+ override focus = (toEdit: boolean) => {
179
+ if (toEdit) {
180
+ this.focusEditor();
181
+ } else {
182
+ if (this.container?.current?.parentElement?.contains(document.activeElement)) {
183
+ return;
184
+ }
185
+ this.container?.current?.parentElement?.focus();
186
+ }
187
+ };
188
+
189
+ override blur = () => {
190
+ this.editorView?.editor?.setOption('styleActiveLine', false);
191
+ this.editorView?.editor?.setOption('highlightActiveLineGutter', false);
192
+ };
49
193
 
50
194
  get wrapperCls() {
51
195
  return '';
@@ -38,7 +38,7 @@ export const ExecutableCellView = {
38
38
  * 带有编辑器、执行、output相关能力的cell view,例如python、sql
39
39
  * model 必须为 ExecutableCellModel
40
40
  */
41
- export abstract class LibroExecutableCellView
41
+ export abstract class LibroEditableExecutableCellView
42
42
  extends LibroEditorCellView
43
43
  implements ExecutableCellView
44
44
  {
@@ -79,3 +79,8 @@ export abstract class LibroExecutableCellView
79
79
  );
80
80
  }
81
81
  }
82
+
83
+ /**
84
+ * @deprecated use LibroEditableExecutableCellView instead.
85
+ */
86
+ export const LibroExecutableCellView = LibroEditableExecutableCellView;