@difizen/libro-raw-cell 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/raw-cell-view.d.ts +3 -4
- package/es/raw-cell-view.d.ts.map +1 -1
- package/es/raw-cell-view.js +29 -39
- package/package.json +4 -4
- package/src/raw-cell-view.tsx +21 -31
package/es/raw-cell-view.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
|
|
2
2
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
3
3
|
import type { CellViewOptions } from '@difizen/libro-core';
|
|
4
|
-
import { CellService, LibroEditorCellView } from '@difizen/libro-core';
|
|
5
|
-
import { Deferred } from '@difizen/mana-app';
|
|
4
|
+
import { CellService, LibroEditorCellView, LirboContextKey } from '@difizen/libro-core';
|
|
6
5
|
import { ViewManager } from '@difizen/mana-app';
|
|
7
6
|
import React from 'react';
|
|
8
7
|
import type { LibroRawCellModel } from './raw-cell-model.js';
|
|
9
8
|
export declare class LibroRawCellView extends LibroEditorCellView {
|
|
9
|
+
protected readonly lirboContextKey: LirboContextKey;
|
|
10
10
|
model: LibroRawCellModel;
|
|
11
11
|
view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
viewManager: ViewManager;
|
|
13
13
|
codeEditorManager: CodeEditorManager;
|
|
14
14
|
editorView?: CodeEditorView;
|
|
15
|
-
protected editorViewReadyDeferred: Deferred<void>;
|
|
16
|
-
get editorReady(): Promise<void>;
|
|
17
15
|
constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, codeEditorManager: CodeEditorManager);
|
|
18
16
|
onViewMount(): void;
|
|
19
17
|
protected getEditorOption(): CodeEditorViewOptions;
|
|
@@ -21,6 +19,7 @@ export declare class LibroRawCellView extends LibroEditorCellView {
|
|
|
21
19
|
protected afterEditorReady(): Promise<void>;
|
|
22
20
|
shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
|
|
23
21
|
blur: () => void;
|
|
22
|
+
protected focusEditor(): void;
|
|
24
23
|
focus: (toEdit: boolean) => void;
|
|
25
24
|
}
|
|
26
25
|
//# 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;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,
|
|
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;AAC/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"}
|
package/es/raw-cell-view.js
CHANGED
|
@@ -1,5 +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, _class, _class2, _descriptor;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2;
|
|
3
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
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
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); }); }; }
|
|
@@ -22,9 +22,8 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
|
|
|
22
22
|
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
23
23
|
|
|
24
24
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
25
|
-
import { CellService, LibroEditorCellView } from '@difizen/libro-core';
|
|
25
|
+
import { CellService, LibroEditorCellView, LirboContextKey } from '@difizen/libro-core';
|
|
26
26
|
import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
|
|
27
|
-
import { Deferred } from '@difizen/mana-app';
|
|
28
27
|
import { view, ViewInstance, ViewManager, ViewOption, ViewRender } from '@difizen/mana-app';
|
|
29
28
|
import { inject, transient } from '@difizen/mana-app';
|
|
30
29
|
import React, { useEffect } from 'react';
|
|
@@ -55,46 +54,24 @@ var CodeEditorViewComponent = /*#__PURE__*/React.forwardRef(function CodeEditorV
|
|
|
55
54
|
children: /*#__PURE__*/_jsx(CellEditorMemo, {})
|
|
56
55
|
});
|
|
57
56
|
});
|
|
58
|
-
export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec3 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
|
|
57
|
+
export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec3 = inject(LirboContextKey), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
|
|
59
58
|
_inherits(LibroRawCellView, _LibroEditorCellView);
|
|
60
59
|
var _super = _createSuper(LibroRawCellView);
|
|
61
60
|
function LibroRawCellView(options, cellService, viewManager, codeEditorManager) {
|
|
62
61
|
var _this;
|
|
63
62
|
_classCallCheck(this, LibroRawCellView);
|
|
64
63
|
_this = _super.call(this, options, cellService);
|
|
64
|
+
_initializerDefineProperty(_this, "lirboContextKey", _descriptor, _assertThisInitialized(_this));
|
|
65
65
|
_this.view = CodeEditorViewComponent;
|
|
66
66
|
_this.viewManager = void 0;
|
|
67
67
|
_this.codeEditorManager = void 0;
|
|
68
|
-
_initializerDefineProperty(_this, "editorView",
|
|
69
|
-
_this.editorViewReadyDeferred = new Deferred();
|
|
68
|
+
_initializerDefineProperty(_this, "editorView", _descriptor2, _assertThisInitialized(_this));
|
|
70
69
|
_this.blur = function () {
|
|
71
70
|
//
|
|
72
71
|
};
|
|
73
72
|
_this.focus = function (toEdit) {
|
|
74
73
|
if (toEdit) {
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (!_this.editorView) {
|
|
79
|
-
_this.editorReady.then(function () {
|
|
80
|
-
var _this$editorView;
|
|
81
|
-
(_this$editorView = _this.editorView) === null || _this$editorView === void 0 || _this$editorView.editorReady.then(function () {
|
|
82
|
-
var _this$editorView2, _this$editorView3;
|
|
83
|
-
if ((_this$editorView2 = _this.editorView) !== null && _this$editorView2 !== void 0 && _this$editorView2.editor.hasFocus()) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
(_this$editorView3 = _this.editorView) === null || _this$editorView3 === void 0 || _this$editorView3.editor.focus();
|
|
87
|
-
return;
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}).catch(console.error);
|
|
91
|
-
} else {
|
|
92
|
-
var _this$editorView4, _this$editorView5;
|
|
93
|
-
if ((_this$editorView4 = _this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.editor.hasFocus()) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
(_this$editorView5 = _this.editorView) === null || _this$editorView5 === void 0 || _this$editorView5.editor.focus();
|
|
97
|
-
}
|
|
74
|
+
_this.focusEditor();
|
|
98
75
|
} else {
|
|
99
76
|
var _this$container, _this$container2;
|
|
100
77
|
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)) {
|
|
@@ -113,11 +90,6 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
113
90
|
LibroRawCellView = inject(CellService)(LibroRawCellView, undefined, 1) || LibroRawCellView;
|
|
114
91
|
LibroRawCellView = inject(ViewOption)(LibroRawCellView, undefined, 0) || LibroRawCellView;
|
|
115
92
|
_createClass(LibroRawCellView, [{
|
|
116
|
-
key: "editorReady",
|
|
117
|
-
get: function get() {
|
|
118
|
-
return this.editorViewReadyDeferred.promise;
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
93
|
key: "onViewMount",
|
|
122
94
|
value: function onViewMount() {
|
|
123
95
|
var _this$parent$model$ac;
|
|
@@ -131,6 +103,8 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
131
103
|
key: "getEditorOption",
|
|
132
104
|
value: function getEditorOption() {
|
|
133
105
|
var option = {
|
|
106
|
+
uuid: "".concat(this.parent.model.id, "-").concat(this.model.id),
|
|
107
|
+
editorHostId: this.parent.id + this.id,
|
|
134
108
|
model: this.model,
|
|
135
109
|
config: {
|
|
136
110
|
readOnly: this.parent.model.readOnly,
|
|
@@ -159,11 +133,8 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
159
133
|
editorView = _context.sent;
|
|
160
134
|
this.editorView = editorView;
|
|
161
135
|
_context.next = 7;
|
|
162
|
-
return editorView.editorReady;
|
|
163
|
-
case 7:
|
|
164
|
-
_context.next = 9;
|
|
165
136
|
return this.afterEditorReady();
|
|
166
|
-
case
|
|
137
|
+
case 7:
|
|
167
138
|
case "end":
|
|
168
139
|
return _context.stop();
|
|
169
140
|
}
|
|
@@ -203,9 +174,28 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
203
174
|
var _getOrigin;
|
|
204
175
|
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;
|
|
205
176
|
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "focusEditor",
|
|
179
|
+
value: function focusEditor() {
|
|
180
|
+
var _this$editorView, _this$parent$model$ac2;
|
|
181
|
+
//选中cell、编辑模式、非只读时才focus
|
|
182
|
+
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.lirboContextKey.commandModeEnabled === true &&
|
|
183
|
+
// 排除弹窗等情况
|
|
184
|
+
this.parent.model.readOnly === false) {
|
|
185
|
+
var _this$editorView2, _this$editorView3, _this$editorView4;
|
|
186
|
+
(_this$editorView2 = this.editorView) === null || _this$editorView2 === void 0 || _this$editorView2.editor.setOption('styleActiveLine', true);
|
|
187
|
+
(_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 || _this$editorView3.editor.setOption('highlightActiveLineGutter', true);
|
|
188
|
+
(_this$editorView4 = this.editorView) === null || _this$editorView4 === void 0 || _this$editorView4.editor.focus();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
206
191
|
}]);
|
|
207
192
|
return LibroRawCellView;
|
|
208
|
-
}(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "
|
|
193
|
+
}(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "lirboContextKey", [_dec3], {
|
|
194
|
+
configurable: true,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
initializer: null
|
|
198
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorView", [_dec4], {
|
|
209
199
|
configurable: true,
|
|
210
200
|
enumerable: true,
|
|
211
201
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-raw-cell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-code-editor": "^0.1.
|
|
36
|
-
"@difizen/libro-common": "^0.1.
|
|
37
|
-
"@difizen/libro-core": "^0.1.
|
|
35
|
+
"@difizen/libro-code-editor": "^0.1.16",
|
|
36
|
+
"@difizen/libro-common": "^0.1.16",
|
|
37
|
+
"@difizen/libro-core": "^0.1.16",
|
|
38
38
|
"@difizen/mana-app": "latest"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/raw-cell-view.tsx
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
|
|
4
4
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
5
5
|
import type { CellViewOptions } from '@difizen/libro-core';
|
|
6
|
-
import { CellService, LibroEditorCellView } from '@difizen/libro-core';
|
|
6
|
+
import { CellService, LibroEditorCellView, LirboContextKey } from '@difizen/libro-core';
|
|
7
7
|
import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
|
|
8
|
-
import { Deferred } from '@difizen/mana-app';
|
|
9
8
|
import {
|
|
10
9
|
view,
|
|
11
10
|
ViewInstance,
|
|
@@ -44,6 +43,7 @@ const CodeEditorViewComponent = React.forwardRef<HTMLDivElement>(
|
|
|
44
43
|
@transient()
|
|
45
44
|
@view('raw-cell-view')
|
|
46
45
|
export class LibroRawCellView extends LibroEditorCellView {
|
|
46
|
+
@inject(LirboContextKey) protected readonly lirboContextKey: LirboContextKey;
|
|
47
47
|
declare model: LibroRawCellModel;
|
|
48
48
|
override view = CodeEditorViewComponent;
|
|
49
49
|
|
|
@@ -54,12 +54,6 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
54
54
|
@prop()
|
|
55
55
|
editorView?: CodeEditorView;
|
|
56
56
|
|
|
57
|
-
protected editorViewReadyDeferred: Deferred<void> = new Deferred<void>();
|
|
58
|
-
|
|
59
|
-
get editorReady() {
|
|
60
|
-
return this.editorViewReadyDeferred.promise;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
57
|
constructor(
|
|
64
58
|
@inject(ViewOption) options: CellViewOptions,
|
|
65
59
|
@inject(CellService) cellService: CellService,
|
|
@@ -82,6 +76,8 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
82
76
|
|
|
83
77
|
protected getEditorOption(): CodeEditorViewOptions {
|
|
84
78
|
const option: CodeEditorViewOptions = {
|
|
79
|
+
uuid: `${this.parent.model.id}-${this.model.id}`,
|
|
80
|
+
editorHostId: this.parent.id + this.id,
|
|
85
81
|
model: this.model,
|
|
86
82
|
config: {
|
|
87
83
|
readOnly: this.parent.model.readOnly,
|
|
@@ -102,7 +98,6 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
102
98
|
const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
|
|
103
99
|
|
|
104
100
|
this.editorView = editorView;
|
|
105
|
-
await editorView.editorReady;
|
|
106
101
|
await this.afterEditorReady();
|
|
107
102
|
}
|
|
108
103
|
|
|
@@ -124,30 +119,25 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
124
119
|
//
|
|
125
120
|
};
|
|
126
121
|
|
|
122
|
+
protected focusEditor() {
|
|
123
|
+
//选中cell、编辑模式、非只读时才focus
|
|
124
|
+
if (
|
|
125
|
+
this.editorView?.editor &&
|
|
126
|
+
this.editorView.editorStatus === 'ready' &&
|
|
127
|
+
this.parent.model.active?.id === this.id &&
|
|
128
|
+
!this.parent.model.commandMode &&
|
|
129
|
+
this.lirboContextKey.commandModeEnabled === true && // 排除弹窗等情况
|
|
130
|
+
this.parent.model.readOnly === false
|
|
131
|
+
) {
|
|
132
|
+
this.editorView?.editor.setOption('styleActiveLine', true);
|
|
133
|
+
this.editorView?.editor.setOption('highlightActiveLineGutter', true);
|
|
134
|
+
this.editorView?.editor.focus();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
127
138
|
override focus = (toEdit: boolean) => {
|
|
128
139
|
if (toEdit) {
|
|
129
|
-
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (!this.editorView) {
|
|
133
|
-
this.editorReady
|
|
134
|
-
.then(() => {
|
|
135
|
-
this.editorView?.editorReady.then(() => {
|
|
136
|
-
if (this.editorView?.editor.hasFocus()) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this.editorView?.editor.focus();
|
|
140
|
-
return;
|
|
141
|
-
});
|
|
142
|
-
return;
|
|
143
|
-
})
|
|
144
|
-
.catch(console.error);
|
|
145
|
-
} else {
|
|
146
|
-
if (this.editorView?.editor.hasFocus()) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.editorView?.editor.focus();
|
|
150
|
-
}
|
|
140
|
+
this.focusEditor();
|
|
151
141
|
} else {
|
|
152
142
|
if (this.container?.current?.parentElement?.contains(document.activeElement)) {
|
|
153
143
|
return;
|