@difizen/libro-markdown-cell 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,5 +1,5 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
- import type { CodeEditorViewOptions, IEditor, CodeEditorView } from '@difizen/libro-code-editor';
2
+ import type { CodeEditorViewOptions, IEditor } from '@difizen/libro-code-editor';
3
3
  import { CodeEditorManager } from '@difizen/libro-code-editor';
4
4
  import type { CellCollapsible, CellViewOptions } from '@difizen/libro-core';
5
5
  import { CellService, EditorStatus, LibroEditorCellView } from '@difizen/libro-core';
@@ -10,11 +10,9 @@ import './index.less';
10
10
  import type { MarkdownCellModel } from './markdown-cell-model.js';
11
11
  export declare const MarkdownCell: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
12
12
  export declare class MarkdownCellView extends LibroEditorCellView implements CellCollapsible {
13
- get wrapperCls(): "" | "markdown-cell-preview";
13
+ get wrapperCls(): "markdown-cell-preview" | "";
14
14
  view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
15
15
  viewManager: ViewManager;
16
- codeEditorManager: CodeEditorManager;
17
- editorView?: CodeEditorView;
18
16
  editorAreaHeight: number;
19
17
  noEditorAreaHeight: number;
20
18
  editor: IEditor | undefined;
@@ -29,12 +27,8 @@ export declare class MarkdownCellView extends LibroEditorCellView implements Cel
29
27
  onViewResize(size: ViewSize): void;
30
28
  calcEditorAreaHeight(): number;
31
29
  protected getEditorOption(): CodeEditorViewOptions;
32
- createEditor(): Promise<void>;
33
- protected afterEditorReady(): Promise<void>;
34
30
  shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
35
- focus(toEdit: boolean): void;
36
- blur(): void;
37
- redo(): void;
38
- undo(): void;
31
+ focus: (toEdit: boolean) => void;
32
+ blur: () => void;
39
33
  }
40
34
  //# sourceMappingURL=markdown-cell-view.d.ts.map
@@ -1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A0B;IAE7D,IAAI,MAAM,wBAIT;IAED,IAAI,SAAS,sBAEZ;IAED,cAAc,EAAE,cAAc,CAAC;gBAGT,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB,EACvC,cAAc,EAAE,cAAc;IAS/C,WAAW;IAWX,YAAY,CAAC,IAAI,EAAE,QAAQ;IAMpC,oBAAoB;cAID,eAAe,IAAI,qBAAqB;IAiBlD,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAOtD,KAAK,WAAY,OAAO,UAS/B;IAEO,IAAI,aAEX;CACH"}
@@ -1,8 +1,5 @@
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, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
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); }); }; }
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
6
3
  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 }); }
7
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
5
  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); } }
@@ -62,7 +59,7 @@ export var MarkdownCell = /*#__PURE__*/forwardRef(function MarkdownCell(props, r
62
59
  })
63
60
  });
64
61
  });
65
- export var MarkdownCellView = (_dec = transient(), _dec2 = view('libro-markdown-cell-view'), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
62
+ export var MarkdownCellView = (_dec = transient(), _dec2 = view('libro-markdown-cell-view'), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
66
63
  _inherits(MarkdownCellView, _LibroEditorCellView);
67
64
  var _super = _createSuper(MarkdownCellView);
68
65
  function MarkdownCellView(options, cellService, viewManager, codeEditorManager, markdownParser) {
@@ -71,14 +68,26 @@ export var MarkdownCellView = (_dec = transient(), _dec2 = view('libro-markdown-
71
68
  _this = _super.call(this, options, cellService);
72
69
  _this.view = MarkdownCell;
73
70
  _this.viewManager = void 0;
74
- _this.codeEditorManager = void 0;
75
- _initializerDefineProperty(_this, "editorView", _descriptor, _assertThisInitialized(_this));
76
- _initializerDefineProperty(_this, "editorAreaHeight", _descriptor2, _assertThisInitialized(_this));
77
- _initializerDefineProperty(_this, "noEditorAreaHeight", _descriptor3, _assertThisInitialized(_this));
78
- _initializerDefineProperty(_this, "headingCollapsed", _descriptor4, _assertThisInitialized(_this));
79
- _initializerDefineProperty(_this, "collapsibleChildNumber", _descriptor5, _assertThisInitialized(_this));
80
- _initializerDefineProperty(_this, "editorStatus", _descriptor6, _assertThisInitialized(_this));
71
+ _initializerDefineProperty(_this, "editorAreaHeight", _descriptor, _assertThisInitialized(_this));
72
+ _initializerDefineProperty(_this, "noEditorAreaHeight", _descriptor2, _assertThisInitialized(_this));
73
+ _initializerDefineProperty(_this, "headingCollapsed", _descriptor3, _assertThisInitialized(_this));
74
+ _initializerDefineProperty(_this, "collapsibleChildNumber", _descriptor4, _assertThisInitialized(_this));
75
+ _initializerDefineProperty(_this, "editorStatus", _descriptor5, _assertThisInitialized(_this));
81
76
  _this.markdownParser = void 0;
77
+ _this.focus = function (toEdit) {
78
+ if (toEdit) {
79
+ _this.cellmodel.isEdit = true;
80
+ } else {
81
+ var _this$container, _this$container2;
82
+ 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)) {
83
+ return;
84
+ }
85
+ (_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();
86
+ }
87
+ };
88
+ _this.blur = function () {
89
+ _this.cellmodel.isEdit = false;
90
+ };
82
91
  _this.viewManager = viewManager;
83
92
  _this.codeEditorManager = codeEditorManager;
84
93
  _this.markdownParser = markdownParser;
@@ -151,68 +160,8 @@ export var MarkdownCellView = (_dec = transient(), _dec2 = view('libro-markdown-
151
160
  };
152
161
  return option;
153
162
  }
154
- }, {
155
- key: "createEditor",
156
- value: function () {
157
- var _createEditor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
158
- var _this3 = this;
159
- var option, editorView;
160
- return _regeneratorRuntime().wrap(function _callee$(_context) {
161
- while (1) switch (_context.prev = _context.next) {
162
- case 0:
163
- option = this.getEditorOption();
164
- this.editorStatus = EditorStatus.LOADING;
165
163
 
166
- // 防止虚拟滚动中编辑器被频繁创建
167
- if (!this.editorView) {
168
- _context.next = 5;
169
- break;
170
- }
171
- this.editorStatus = EditorStatus.LOADED;
172
- return _context.abrupt("return");
173
- case 5:
174
- _context.next = 7;
175
- return this.codeEditorManager.getOrCreateEditorView(option);
176
- case 7:
177
- editorView = _context.sent;
178
- this.editorView = editorView;
179
- this.editorStatus = EditorStatus.LOADED;
180
- editorView.onEditorStatusChange(function (e) {
181
- if (e.status === 'ready') {
182
- _this3.afterEditorReady();
183
- }
184
- });
185
- case 11:
186
- case "end":
187
- return _context.stop();
188
- }
189
- }, _callee, this);
190
- }));
191
- function createEditor() {
192
- return _createEditor.apply(this, arguments);
193
- }
194
- return createEditor;
195
- }()
196
- }, {
197
- key: "afterEditorReady",
198
- value: function () {
199
- var _afterEditorReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
200
- var _getOrigin;
201
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
202
- while (1) switch (_context2.prev = _context2.next) {
203
- case 0:
204
- (_getOrigin = getOrigin(this.editorView)) === null || _getOrigin === void 0 || _getOrigin.editor.focus();
205
- case 1:
206
- case "end":
207
- return _context2.stop();
208
- }
209
- }, _callee2, this);
210
- }));
211
- function afterEditorReady() {
212
- return _afterEditorReady.apply(this, arguments);
213
- }
214
- return afterEditorReady;
215
- }() // eslint-disable-next-line @typescript-eslint/no-unused-vars
164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
216
165
  }, {
217
166
  key: "shouldEnterEditorMode",
218
167
  value: function shouldEnterEditorMode(e) {
@@ -221,72 +170,37 @@ export var MarkdownCellView = (_dec = transient(), _dec2 = view('libro-markdown-
221
170
  }
222
171
  return true;
223
172
  }
224
- }, {
225
- key: "focus",
226
- value: function focus(toEdit) {
227
- if (toEdit) {
228
- this.cellmodel.isEdit = true;
229
- } else {
230
- var _this$container, _this$container2;
231
- 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)) {
232
- return;
233
- }
234
- (_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();
235
- }
236
- }
237
- }, {
238
- key: "blur",
239
- value: function blur() {
240
- this.cellmodel.isEdit = false;
241
- }
242
- }, {
243
- key: "redo",
244
- value: function redo() {
245
- // this.editor?.trigger('', 'redo', '');
246
- // this.editor?.focus();
247
- }
248
- }, {
249
- key: "undo",
250
- value: function undo() {
251
- // this.editor?.trigger('undo', 'undo', {});
252
- // this.editor?.focus();
253
- }
254
173
  }]);
255
174
  return MarkdownCellView;
256
- }(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "editorView", [_dec3], {
257
- configurable: true,
258
- enumerable: true,
259
- writable: true,
260
- initializer: null
261
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorAreaHeight", [_dec4], {
175
+ }(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "editorAreaHeight", [_dec3], {
262
176
  configurable: true,
263
177
  enumerable: true,
264
178
  writable: true,
265
179
  initializer: function initializer() {
266
180
  return 0;
267
181
  }
268
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "noEditorAreaHeight", [_dec5], {
182
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "noEditorAreaHeight", [_dec4], {
269
183
  configurable: true,
270
184
  enumerable: true,
271
185
  writable: true,
272
186
  initializer: function initializer() {
273
187
  return 0;
274
188
  }
275
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "headingCollapsed", [_dec6], {
189
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "headingCollapsed", [_dec5], {
276
190
  configurable: true,
277
191
  enumerable: true,
278
192
  writable: true,
279
193
  initializer: function initializer() {
280
194
  return false;
281
195
  }
282
- }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "collapsibleChildNumber", [_dec7], {
196
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "collapsibleChildNumber", [_dec6], {
283
197
  configurable: true,
284
198
  enumerable: true,
285
199
  writable: true,
286
200
  initializer: function initializer() {
287
201
  return 0;
288
202
  }
289
- }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "editorStatus", [_dec8], {
203
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "editorStatus", [_dec7], {
290
204
  configurable: true,
291
205
  enumerable: true,
292
206
  writable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-markdown-cell",
3
- "version": "0.2.34",
3
+ "version": "0.2.35-next.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -39,10 +39,10 @@
39
39
  "@types/react": "^18.2.25"
40
40
  },
41
41
  "dependencies": {
42
- "@difizen/libro-core": "^0.2.34",
43
- "@difizen/libro-common": "^0.2.34",
44
- "@difizen/libro-code-editor": "^0.2.34",
45
- "@difizen/libro-markdown": "^0.2.34",
42
+ "@difizen/libro-core": "^0.2.35-next.0",
43
+ "@difizen/libro-common": "^0.2.35-next.0",
44
+ "@difizen/libro-code-editor": "^0.2.35-next.0",
45
+ "@difizen/libro-markdown": "^0.2.35-next.0",
46
46
  "@difizen/mana-app": "latest",
47
47
  "@types/markdown-it": "^12.2.3",
48
48
  "markdown-it": "^13.0.1",
@@ -1,8 +1,4 @@
1
- import type {
2
- CodeEditorViewOptions,
3
- IEditor,
4
- CodeEditorView,
5
- } from '@difizen/libro-code-editor';
1
+ import type { CodeEditorViewOptions, IEditor } from '@difizen/libro-code-editor';
6
2
  import { CodeEditorManager } from '@difizen/libro-code-editor';
7
3
  import { CellUri } from '@difizen/libro-common';
8
4
  import type { CellCollapsible, CellViewOptions } from '@difizen/libro-core';
@@ -74,11 +70,6 @@ export class MarkdownCellView extends LibroEditorCellView implements CellCollaps
74
70
 
75
71
  viewManager: ViewManager;
76
72
 
77
- codeEditorManager: CodeEditorManager;
78
-
79
- @prop()
80
- editorView?: CodeEditorView;
81
-
82
73
  @prop()
83
74
  editorAreaHeight = 0;
84
75
 
@@ -143,7 +134,7 @@ export class MarkdownCellView extends LibroEditorCellView implements CellCollaps
143
134
  return this.editorAreaHeight;
144
135
  }
145
136
 
146
- protected getEditorOption(): CodeEditorViewOptions {
137
+ protected override getEditorOption(): CodeEditorViewOptions {
147
138
  const option: CodeEditorViewOptions = {
148
139
  uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
149
140
  model: this.model,
@@ -159,34 +150,6 @@ export class MarkdownCellView extends LibroEditorCellView implements CellCollaps
159
150
  return option;
160
151
  }
161
152
 
162
- async createEditor() {
163
- const option = this.getEditorOption();
164
-
165
- this.editorStatus = EditorStatus.LOADING;
166
-
167
- // 防止虚拟滚动中编辑器被频繁创建
168
- if (this.editorView) {
169
- this.editorStatus = EditorStatus.LOADED;
170
- return;
171
- }
172
-
173
- const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
174
-
175
- this.editorView = editorView;
176
-
177
- this.editorStatus = EditorStatus.LOADED;
178
-
179
- editorView.onEditorStatusChange((e) => {
180
- if (e.status === 'ready') {
181
- this.afterEditorReady();
182
- }
183
- });
184
- }
185
-
186
- protected async afterEditorReady() {
187
- getOrigin(this.editorView)?.editor.focus();
188
- }
189
-
190
153
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
191
154
  override shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
192
155
  if (!this.cellmodel.isEdit) {
@@ -195,7 +158,7 @@ export class MarkdownCellView extends LibroEditorCellView implements CellCollaps
195
158
  return true;
196
159
  }
197
160
 
198
- override focus(toEdit: boolean) {
161
+ override focus = (toEdit: boolean) => {
199
162
  if (toEdit) {
200
163
  this.cellmodel.isEdit = true;
201
164
  } else {
@@ -204,19 +167,9 @@ export class MarkdownCellView extends LibroEditorCellView implements CellCollaps
204
167
  }
205
168
  this.container?.current?.parentElement?.focus();
206
169
  }
207
- }
170
+ };
208
171
 
209
- override blur() {
172
+ override blur = () => {
210
173
  this.cellmodel.isEdit = false;
211
- }
212
-
213
- override redo(): void {
214
- // this.editor?.trigger('', 'redo', '');
215
- // this.editor?.focus();
216
- }
217
-
218
- override undo(): void {
219
- // this.editor?.trigger('undo', 'undo', {});
220
- // this.editor?.focus();
221
- }
174
+ };
222
175
  }