@difizen/libro-raw-cell 0.2.33 → 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,10 +1,6 @@
1
1
  import type { IRawCell } from '@difizen/libro-common';
2
2
  import { CellOptions, LibroCellModel } from '@difizen/libro-core';
3
- import type { Event as ManaEvent } from '@difizen/mana-app';
4
- import { Emitter } from '@difizen/mana-app';
5
3
  export declare class LibroRawCellModel extends LibroCellModel {
6
- msgChangeEmitter: Emitter<any>;
7
- get msgChange(): ManaEvent<any>;
8
4
  constructor(options: CellOptions);
9
5
  toJSON(): IRawCell;
10
6
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"raw-cell-model.d.ts","sourceRoot":"","sources":["../src/raw-cell-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,qBACa,iBAAkB,SAAQ,cAAc;IAEnD,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,CAE9B;gBAEgC,OAAO,EAAE,WAAW;IAM5C,MAAM,IAAI,QAAQ;IASlB,OAAO;IAKhB,SAAS;CAGV"}
1
+ {"version":3,"file":"raw-cell-model.d.ts","sourceRoot":"","sources":["../src/raw-cell-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGlE,qBACa,iBAAkB,SAAQ,cAAc;gBAClB,OAAO,EAAE,WAAW;IAK5C,MAAM,IAAI,QAAQ;IASlB,OAAO;IAIhB,SAAS;CAGV"}
@@ -15,7 +15,6 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
15
15
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
16
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
17
  import { CellOptions, LibroCellModel } from '@difizen/libro-core';
18
- import { Emitter } from '@difizen/mana-app';
19
18
  import { inject, transient } from '@difizen/mana-app';
20
19
  export var LibroRawCellModel = (_dec = transient(), _dec(_class = /*#__PURE__*/function (_LibroCellModel) {
21
20
  _inherits(LibroRawCellModel, _LibroCellModel);
@@ -24,19 +23,11 @@ export var LibroRawCellModel = (_dec = transient(), _dec(_class = /*#__PURE__*/f
24
23
  var _this;
25
24
  _classCallCheck(this, LibroRawCellModel);
26
25
  _this = _super.call(this, options);
27
- // Emitter Msg
28
- _this.msgChangeEmitter = void 0;
29
- _this.msgChangeEmitter = new Emitter();
30
26
  _this.mimeType = 'text/plain';
31
27
  return _this;
32
28
  }
33
29
  LibroRawCellModel = inject(CellOptions)(LibroRawCellModel, undefined, 0) || LibroRawCellModel;
34
30
  _createClass(LibroRawCellModel, [{
35
- key: "msgChange",
36
- get: function get() {
37
- return this.msgChangeEmitter.event;
38
- }
39
- }, {
40
31
  key: "toJSON",
41
32
  value: function toJSON() {
42
33
  return {
@@ -50,7 +41,6 @@ export var LibroRawCellModel = (_dec = transient(), _dec(_class = /*#__PURE__*/f
50
41
  key: "dispose",
51
42
  value: function dispose() {
52
43
  _get(_getPrototypeOf(LibroRawCellModel.prototype), "dispose", this).call(this);
53
- this.msgChangeEmitter.dispose();
54
44
  }
55
45
  }, {
56
46
  key: "getSource",
@@ -1,25 +1,14 @@
1
- import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
2
- import { CodeEditorManager } from '@difizen/libro-code-editor';
1
+ import type { CodeEditorViewOptions } from '@difizen/libro-code-editor';
3
2
  import type { CellViewOptions } from '@difizen/libro-core';
4
- import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
3
+ import { CellService, LibroEditorCellView } from '@difizen/libro-core';
5
4
  import { ViewManager } from '@difizen/mana-app';
6
5
  import React from 'react';
7
6
  import type { LibroRawCellModel } from './raw-cell-model.js';
8
7
  export declare class LibroRawCellView extends LibroEditorCellView {
9
- protected readonly libroContextKey: LibroContextKey;
10
8
  model: LibroRawCellModel;
11
9
  view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
12
10
  viewManager: ViewManager;
13
- codeEditorManager: CodeEditorManager;
14
- editorView?: CodeEditorView;
15
- constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, codeEditorManager: CodeEditorManager);
16
- onViewMount(): void;
11
+ constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager);
17
12
  protected getEditorOption(): CodeEditorViewOptions;
18
- createEditor(): Promise<void>;
19
- protected afterEditorReady(): Promise<void>;
20
- shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
21
- blur: () => void;
22
- protected focusEditor(): void;
23
- focus: (toEdit: boolean) => void;
24
13
  }
25
14
  //# sourceMappingURL=raw-cell-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"raw-cell-view.d.ts","sourceRoot":"","sources":["../src/raw-cell-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAExF,OAAO,EAGL,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyB7D,qBAEa,gBAAiB,SAAQ,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IACrE,KAAK,EAAE,iBAAiB,CAAC;IACxB,IAAI,uEAA2B;IAExC,WAAW,EAAE,WAAW,CAAC;IAEzB,iBAAiB,EAAE,iBAAiB,CAAC;IAGrC,UAAU,CAAC,EAAE,cAAc,CAAC;gBAGN,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB;IAQxD,WAAW;IAQpB,SAAS,CAAC,eAAe,IAAI,qBAAqB;IAkB5C,YAAY;cASF,gBAAgB;IAMvB,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAQtD,IAAI,aAEX;IAEF,SAAS,CAAC,WAAW;IAgBZ,KAAK,WAAY,OAAO,UAS/B;CACH"}
1
+ {"version":3,"file":"raw-cell-view.d.ts","sourceRoot":"","sources":["../src/raw-cell-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAGL,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyB7D,qBAEa,gBAAiB,SAAQ,mBAAmB;IAC/C,KAAK,EAAE,iBAAiB,CAAC;IACxB,IAAI,uEAA2B;IAExC,WAAW,EAAE,WAAW,CAAC;gBAGH,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW;cAO5B,eAAe,IAAI,qBAAqB;CAiB5D"}
@@ -1,9 +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, _class, _class2, _descriptor, _descriptor2;
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); }); }; }
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 }); }
2
+ var _dec, _dec2, _class;
7
3
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
4
  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); } }
9
5
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -16,15 +12,12 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
16
12
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
14
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
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.'); }
21
15
  /* eslint-disable @typescript-eslint/no-parameter-properties */
22
16
  /* eslint-disable @typescript-eslint/parameter-properties */
23
17
 
24
- import { CodeEditorManager } from '@difizen/libro-code-editor';
25
18
  import { CellUri } from '@difizen/libro-common';
26
- import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
27
- import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
19
+ import { CellService, LibroEditorCellView } from '@difizen/libro-core';
20
+ import { getOrigin, useInject } from '@difizen/mana-app';
28
21
  import { view, ViewInstance, ViewManager, ViewOption, ViewRender } from '@difizen/mana-app';
29
22
  import { inject, transient } from '@difizen/mana-app';
30
23
  import React, { useEffect } from 'react';
@@ -55,52 +48,23 @@ var CodeEditorViewComponent = /*#__PURE__*/React.forwardRef(function CodeEditorV
55
48
  children: /*#__PURE__*/_jsx(CellEditorMemo, {})
56
49
  });
57
50
  });
58
- export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec3 = inject(LibroContextKey), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
51
+ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_LibroEditorCellView) {
59
52
  _inherits(LibroRawCellView, _LibroEditorCellView);
60
53
  var _super = _createSuper(LibroRawCellView);
61
- function LibroRawCellView(options, cellService, viewManager, codeEditorManager) {
54
+ function LibroRawCellView(options, cellService, viewManager) {
62
55
  var _this;
63
56
  _classCallCheck(this, LibroRawCellView);
64
57
  _this = _super.call(this, options, cellService);
65
- _initializerDefineProperty(_this, "libroContextKey", _descriptor, _assertThisInitialized(_this));
66
58
  _this.view = CodeEditorViewComponent;
67
59
  _this.viewManager = void 0;
68
- _this.codeEditorManager = void 0;
69
- _initializerDefineProperty(_this, "editorView", _descriptor2, _assertThisInitialized(_this));
70
- _this.blur = function () {
71
- //
72
- };
73
- _this.focus = function (toEdit) {
74
- if (toEdit) {
75
- _this.focusEditor();
76
- } else {
77
- var _this$container, _this$container2;
78
- 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)) {
79
- return;
80
- }
81
- (_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();
82
- }
83
- };
84
60
  _this.viewManager = viewManager;
85
61
  _this.className = _this.className + ' raw';
86
- _this.codeEditorManager = codeEditorManager;
87
62
  return _this;
88
63
  }
89
- LibroRawCellView = inject(CodeEditorManager)(LibroRawCellView, undefined, 3) || LibroRawCellView;
90
64
  LibroRawCellView = inject(ViewManager)(LibroRawCellView, undefined, 2) || LibroRawCellView;
91
65
  LibroRawCellView = inject(CellService)(LibroRawCellView, undefined, 1) || LibroRawCellView;
92
66
  LibroRawCellView = inject(ViewOption)(LibroRawCellView, undefined, 0) || LibroRawCellView;
93
67
  _createClass(LibroRawCellView, [{
94
- key: "onViewMount",
95
- value: function onViewMount() {
96
- var _this$parent$model$ac;
97
- this.createEditor();
98
- //选中cell时才focus
99
- 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) {
100
- this.focus(!this.parent.model.commandMode);
101
- }
102
- }
103
- }, {
104
68
  key: "getEditorOption",
105
69
  value: function getEditorOption() {
106
70
  var option = {
@@ -119,86 +83,6 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
119
83
  };
120
84
  return option;
121
85
  }
122
- }, {
123
- key: "createEditor",
124
- value: function () {
125
- var _createEditor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
126
- var option, editorView;
127
- return _regeneratorRuntime().wrap(function _callee$(_context) {
128
- while (1) switch (_context.prev = _context.next) {
129
- case 0:
130
- option = this.getEditorOption();
131
- _context.next = 3;
132
- return this.codeEditorManager.getOrCreateEditorView(option);
133
- case 3:
134
- editorView = _context.sent;
135
- this.editorView = editorView;
136
- _context.next = 7;
137
- return this.afterEditorReady();
138
- case 7:
139
- case "end":
140
- return _context.stop();
141
- }
142
- }, _callee, this);
143
- }));
144
- function createEditor() {
145
- return _createEditor.apply(this, arguments);
146
- }
147
- return createEditor;
148
- }()
149
- }, {
150
- key: "afterEditorReady",
151
- value: function () {
152
- var _afterEditorReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
153
- var _this2 = this;
154
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
155
- while (1) switch (_context2.prev = _context2.next) {
156
- case 0:
157
- watch(this.parent.model, 'inputEditable', function () {
158
- var _this2$editorView;
159
- (_this2$editorView = _this2.editorView) === null || _this2$editorView === void 0 || _this2$editorView.editor.setOption('readOnly', !_this2.parent.model.inputEditable);
160
- });
161
- case 1:
162
- case "end":
163
- return _context2.stop();
164
- }
165
- }, _callee2, this);
166
- }));
167
- function afterEditorReady() {
168
- return _afterEditorReady.apply(this, arguments);
169
- }
170
- return afterEditorReady;
171
- }()
172
- }, {
173
- key: "shouldEnterEditorMode",
174
- value: function shouldEnterEditorMode(e) {
175
- var _getOrigin;
176
- 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;
177
- }
178
- }, {
179
- key: "focusEditor",
180
- value: function focusEditor() {
181
- var _this$editorView, _this$parent$model$ac2;
182
- //选中cell、编辑模式、非只读时才focus
183
- if ((_this$editorView = this.editorView) !== null && _this$editorView !== void 0 && _this$editorView.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 &&
184
- // 排除弹窗等情况
185
- this.parent.model.inputEditable) {
186
- var _this$editorView2, _this$editorView3, _this$editorView4;
187
- (_this$editorView2 = this.editorView) === null || _this$editorView2 === void 0 || _this$editorView2.editor.setOption('styleActiveLine', true);
188
- (_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 || _this$editorView3.editor.setOption('highlightActiveLineGutter', true);
189
- (_this$editorView4 = this.editorView) === null || _this$editorView4 === void 0 || _this$editorView4.editor.focus();
190
- }
191
- }
192
86
  }]);
193
87
  return LibroRawCellView;
194
- }(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroContextKey", [_dec3], {
195
- configurable: true,
196
- enumerable: true,
197
- writable: true,
198
- initializer: null
199
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorView", [_dec4], {
200
- configurable: true,
201
- enumerable: true,
202
- writable: true,
203
- initializer: null
204
- })), _class2)) || _class) || _class);
88
+ }(LibroEditorCellView)) || _class) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-raw-cell",
3
- "version": "0.2.33",
3
+ "version": "0.2.35-next.0",
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.2.33",
36
- "@difizen/libro-common": "^0.2.33",
37
- "@difizen/libro-core": "^0.2.33",
35
+ "@difizen/libro-code-editor": "^0.2.35-next.0",
36
+ "@difizen/libro-common": "^0.2.35-next.0",
37
+ "@difizen/libro-core": "^0.2.35-next.0",
38
38
  "@difizen/mana-app": "latest"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,21 +1,11 @@
1
1
  import type { IRawCell } from '@difizen/libro-common';
2
2
  import { CellOptions, LibroCellModel } from '@difizen/libro-core';
3
- import type { Event as ManaEvent } from '@difizen/mana-app';
4
- import { Emitter } from '@difizen/mana-app';
5
3
  import { inject, transient } from '@difizen/mana-app';
6
4
 
7
5
  @transient()
8
6
  export class LibroRawCellModel extends LibroCellModel {
9
- // Emitter Msg
10
- msgChangeEmitter: Emitter<any>;
11
-
12
- get msgChange(): ManaEvent<any> {
13
- return this.msgChangeEmitter.event;
14
- }
15
-
16
7
  constructor(@inject(CellOptions) options: CellOptions) {
17
8
  super(options);
18
- this.msgChangeEmitter = new Emitter<any>();
19
9
  this.mimeType = 'text/plain';
20
10
  }
21
11
 
@@ -30,7 +20,6 @@ export class LibroRawCellModel extends LibroCellModel {
30
20
 
31
21
  override dispose() {
32
22
  super.dispose();
33
- this.msgChangeEmitter.dispose();
34
23
  }
35
24
 
36
25
  getSource() {
@@ -1,11 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-parameter-properties */
2
2
  /* eslint-disable @typescript-eslint/parameter-properties */
3
- import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
4
- import { CodeEditorManager } from '@difizen/libro-code-editor';
3
+ import type { CodeEditorViewOptions } from '@difizen/libro-code-editor';
5
4
  import { CellUri } from '@difizen/libro-common';
6
5
  import type { CellViewOptions } from '@difizen/libro-core';
7
- import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
8
- import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
6
+ import { CellService, LibroEditorCellView } from '@difizen/libro-core';
7
+ import { getOrigin, useInject } from '@difizen/mana-app';
9
8
  import {
10
9
  view,
11
10
  ViewInstance,
@@ -44,38 +43,22 @@ const CodeEditorViewComponent = React.forwardRef<HTMLDivElement>(
44
43
  @transient()
45
44
  @view('raw-cell-view')
46
45
  export class LibroRawCellView extends LibroEditorCellView {
47
- @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
48
46
  declare model: LibroRawCellModel;
49
47
  override view = CodeEditorViewComponent;
50
48
 
51
49
  viewManager: ViewManager;
52
50
 
53
- codeEditorManager: CodeEditorManager;
54
-
55
- @prop()
56
- editorView?: CodeEditorView;
57
-
58
51
  constructor(
59
52
  @inject(ViewOption) options: CellViewOptions,
60
53
  @inject(CellService) cellService: CellService,
61
54
  @inject(ViewManager) viewManager: ViewManager,
62
- @inject(CodeEditorManager) codeEditorManager: CodeEditorManager,
63
55
  ) {
64
56
  super(options, cellService);
65
57
  this.viewManager = viewManager;
66
58
  this.className = this.className + ' raw';
67
- this.codeEditorManager = codeEditorManager;
68
- }
69
-
70
- override onViewMount() {
71
- this.createEditor();
72
- //选中cell时才focus
73
- if (this.parent.model.active?.id === this.id) {
74
- this.focus(!this.parent.model.commandMode);
75
- }
76
59
  }
77
60
 
78
- protected getEditorOption(): CodeEditorViewOptions {
61
+ protected override getEditorOption(): CodeEditorViewOptions {
79
62
  const option: CodeEditorViewOptions = {
80
63
  uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
81
64
  editorHostId: this.parent.id + this.id,
@@ -92,58 +75,4 @@ export class LibroRawCellView extends LibroEditorCellView {
92
75
  };
93
76
  return option;
94
77
  }
95
-
96
- async createEditor() {
97
- const option = this.getEditorOption();
98
-
99
- const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
100
-
101
- this.editorView = editorView;
102
- await this.afterEditorReady();
103
- }
104
-
105
- protected async afterEditorReady() {
106
- watch(this.parent.model, 'inputEditable', () => {
107
- this.editorView?.editor.setOption('readOnly', !this.parent.model.inputEditable);
108
- });
109
- }
110
-
111
- override shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
112
- return getOrigin(this.editorView)?.editor?.host?.contains(
113
- e.target as HTMLElement,
114
- ) && this.parent.model.commandMode
115
- ? true
116
- : false;
117
- }
118
-
119
- override blur = () => {
120
- //
121
- };
122
-
123
- protected focusEditor() {
124
- //选中cell、编辑模式、非只读时才focus
125
- if (
126
- this.editorView?.editor &&
127
- this.editorView.editorStatus === 'ready' &&
128
- this.parent.model.active?.id === this.id &&
129
- !this.parent.model.commandMode &&
130
- this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
131
- this.parent.model.inputEditable
132
- ) {
133
- this.editorView?.editor.setOption('styleActiveLine', true);
134
- this.editorView?.editor.setOption('highlightActiveLineGutter', true);
135
- this.editorView?.editor.focus();
136
- }
137
- }
138
-
139
- override focus = (toEdit: boolean) => {
140
- if (toEdit) {
141
- this.focusEditor();
142
- } else {
143
- if (this.container?.current?.parentElement?.contains(document.activeElement)) {
144
- return;
145
- }
146
- this.container?.current?.parentElement?.focus();
147
- }
148
- };
149
78
  }