@difizen/libro-code-editor 0.3.47 → 0.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/code-editor-view.d.ts.map +1 -1
- package/es/code-editor-view.js +18 -10
- package/package.json +2 -2
- package/src/code-editor-view.tsx +10 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor-view.d.ts","sourceRoot":"","sources":["../src/code-editor-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,OAAO,EACP,QAAQ,EACR,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,kBAAkB,EAElB,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,eAAO,MAAM,gBAAgB,+HAI5B,CAAC;AAuBF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAEjE;;GAEG;AACH,qBAEa,cAAe,SAAQ,QAAQ;IACpB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAEtF,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAElE,qBAAqB,EAAE,qBAAqB,CAAC;IAEpC,IAAI,gIAAoB;IAEjC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAEnC,SAAS,CAAC,OAAO,EAAE,qBAAqB,CAAC;IAEzC,SAAS,CAAC,kBAA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;IACH,SAAS,CAAC,QAAQ,IAAI,IAAI;IAM1B,QAAQ,CAAC,SAAS,EAAE,MAAM;IAI1B,WAAW,CAAC,SAAS,EAAE,MAAM;IAO7B;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAwBtC;;OAEG;IACH,SAAS,CAAC,aAAa,UAAW,SAAS,KAAG,IAAI,CAWhD;IAEF;;OAEG;IACH,SAAS,CAAC,aAAa,UAAW,SAAS,KAAG,IAAI,CAWhD;IAEF;;OAEG;IACH,SAAS,CAAC,YAAY,UAAW,SAAS,KAAG,IAAI,CAa/C;IAEF;;OAEG;IACH,SAAS,CAAC,QAAQ,UAAW,SAAS,KAAG,IAAI,CA+B3C;CACH;AAED;;GAEG;AACH;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa;IACjF;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAE5B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAEvC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/es/code-editor-view.js
CHANGED
|
@@ -84,8 +84,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
_this.onViewUnmount = function () {
|
|
87
|
-
var _this$editorHostRef2;
|
|
88
|
-
if (_this.editor.hasFocus()) {
|
|
87
|
+
var _this$editor, _this$editor2, _this$editorHostRef2;
|
|
88
|
+
if ((_this$editor = _this.editor) !== null && _this$editor !== void 0 && _this$editor.hasFocus()) {
|
|
89
89
|
var _this$editorHostRef;
|
|
90
90
|
// 保存编辑器状态
|
|
91
91
|
var editorState = _this.editor.getState();
|
|
@@ -94,7 +94,7 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
94
94
|
_this.editorHostRef = _this.getEditorHost();
|
|
95
95
|
(_this$editorHostRef = _this.editorHostRef) === null || _this$editorHostRef === void 0 || (_this$editorHostRef = _this$editorHostRef.current) === null || _this$editorHostRef === void 0 || _this$editorHostRef.focus();
|
|
96
96
|
}
|
|
97
|
-
_this.editor.dispose();
|
|
97
|
+
(_this$editor2 = _this.editor) === null || _this$editor2 === void 0 || _this$editor2.dispose();
|
|
98
98
|
var prevState = _this.editorStatus;
|
|
99
99
|
_this.editorStatus = 'disposed';
|
|
100
100
|
_this.editorStatusChangeEmitter.fire({
|
|
@@ -112,13 +112,15 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
_this.onViewActive = function () {
|
|
115
|
-
_this
|
|
115
|
+
var _this$editor3;
|
|
116
|
+
(_this$editor3 = _this.editor) === null || _this$editor3 === void 0 || _this$editor3.focus();
|
|
116
117
|
};
|
|
117
118
|
/**
|
|
118
119
|
* Handle the `'lm-dragenter'` event for the widget.
|
|
119
120
|
*/
|
|
120
121
|
_this._evtDragEnter = function (event) {
|
|
121
|
-
|
|
122
|
+
var _this$editor4;
|
|
123
|
+
if (((_this$editor4 = _this.editor) === null || _this$editor4 === void 0 ? void 0 : _this$editor4.getOption('readOnly')) === true) {
|
|
122
124
|
return;
|
|
123
125
|
}
|
|
124
126
|
var data = findTextData(event);
|
|
@@ -302,8 +304,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
302
304
|
}, {
|
|
303
305
|
key: "onViewResize",
|
|
304
306
|
value: function onViewResize() {
|
|
305
|
-
var _this$
|
|
306
|
-
(_this$
|
|
307
|
+
var _this$editor5;
|
|
308
|
+
(_this$editor5 = this.editor) === null || _this$editor5 === void 0 || _this$editor5.resizeToFit();
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
/**
|
|
@@ -312,7 +314,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
312
314
|
}, {
|
|
313
315
|
key: "model",
|
|
314
316
|
get: function get() {
|
|
315
|
-
|
|
317
|
+
var _this$editor6;
|
|
318
|
+
return ((_this$editor6 = this.editor) === null || _this$editor6 === void 0 ? void 0 : _this$editor6.model) || this.options.model;
|
|
316
319
|
}
|
|
317
320
|
|
|
318
321
|
/**
|
|
@@ -321,11 +324,12 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
321
324
|
}, {
|
|
322
325
|
key: "dispose",
|
|
323
326
|
value: function dispose() {
|
|
327
|
+
var _this$editor7;
|
|
324
328
|
if (this.isDisposed) {
|
|
325
329
|
return;
|
|
326
330
|
}
|
|
327
331
|
_get(_getPrototypeOf(CodeEditorView.prototype), "dispose", this).call(this);
|
|
328
|
-
this.editor.dispose();
|
|
332
|
+
(_this$editor7 = this.editor) === null || _this$editor7 === void 0 || _this$editor7.dispose();
|
|
329
333
|
}
|
|
330
334
|
}, {
|
|
331
335
|
key: "onResize",
|
|
@@ -335,7 +339,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
335
339
|
*/
|
|
336
340
|
function onResize() {
|
|
337
341
|
if (this.isVisible) {
|
|
338
|
-
|
|
342
|
+
var _this$editor8;
|
|
343
|
+
(_this$editor8 = this.editor) === null || _this$editor8 === void 0 || _this$editor8.resizeToFit();
|
|
339
344
|
}
|
|
340
345
|
}
|
|
341
346
|
}, {
|
|
@@ -358,6 +363,9 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
358
363
|
}, {
|
|
359
364
|
key: "_onSelectionsChanged",
|
|
360
365
|
value: function _onSelectionsChanged() {
|
|
366
|
+
if (!this.editor) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
361
369
|
var _this$editor$getSelec = this.editor.getSelection(),
|
|
362
370
|
start = _this$editor$getSelec.start,
|
|
363
371
|
end = _this$editor$getSelec.end;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-code-editor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-common": "^0.3.
|
|
35
|
+
"@difizen/libro-common": "^0.3.49",
|
|
36
36
|
"@difizen/mana-app": "latest",
|
|
37
37
|
"@difizen/mana-l10n": "latest",
|
|
38
38
|
"uuid": "^9.0.1"
|
package/src/code-editor-view.tsx
CHANGED
|
@@ -185,7 +185,7 @@ export class CodeEditorView extends BaseView {
|
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
override onViewUnmount = () => {
|
|
188
|
-
if (this.editor
|
|
188
|
+
if (this.editor?.hasFocus()) {
|
|
189
189
|
// 保存编辑器状态
|
|
190
190
|
const editorState = this.editor.getState();
|
|
191
191
|
this.codeEditorStateManager.updateEditorState(this.options.uuid, editorState);
|
|
@@ -193,7 +193,7 @@ export class CodeEditorView extends BaseView {
|
|
|
193
193
|
this.editorHostRef = this.getEditorHost();
|
|
194
194
|
this.editorHostRef?.current?.focus();
|
|
195
195
|
}
|
|
196
|
-
this.editor
|
|
196
|
+
this.editor?.dispose();
|
|
197
197
|
|
|
198
198
|
const prevState = this.editorStatus;
|
|
199
199
|
this.editorStatus = 'disposed';
|
|
@@ -219,7 +219,7 @@ export class CodeEditorView extends BaseView {
|
|
|
219
219
|
* Get the model used by the widget.
|
|
220
220
|
*/
|
|
221
221
|
get model(): IModel {
|
|
222
|
-
return this.editor.model;
|
|
222
|
+
return this.editor?.model || this.options.model;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
@@ -230,11 +230,11 @@ export class CodeEditorView extends BaseView {
|
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
super.dispose();
|
|
233
|
-
this.editor
|
|
233
|
+
this.editor?.dispose();
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
protected onViewActive = (): void => {
|
|
237
|
-
this.editor
|
|
237
|
+
this.editor?.focus();
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
/**
|
|
@@ -242,7 +242,7 @@ export class CodeEditorView extends BaseView {
|
|
|
242
242
|
*/
|
|
243
243
|
protected onResize(): void {
|
|
244
244
|
if (this.isVisible) {
|
|
245
|
-
this.editor
|
|
245
|
+
this.editor?.resizeToFit();
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -261,6 +261,9 @@ export class CodeEditorView extends BaseView {
|
|
|
261
261
|
* Handle a change in model selections.
|
|
262
262
|
*/
|
|
263
263
|
protected _onSelectionsChanged(): void {
|
|
264
|
+
if (!this.editor) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
264
267
|
const { start, end } = this.editor.getSelection();
|
|
265
268
|
|
|
266
269
|
if (start.column !== end.column || start.line !== end.line) {
|
|
@@ -285,7 +288,7 @@ export class CodeEditorView extends BaseView {
|
|
|
285
288
|
* Handle the `'lm-dragenter'` event for the widget.
|
|
286
289
|
*/
|
|
287
290
|
protected _evtDragEnter = (event: DragEvent): void => {
|
|
288
|
-
if (this.editor
|
|
291
|
+
if (this.editor?.getOption('readOnly') === true) {
|
|
289
292
|
return;
|
|
290
293
|
}
|
|
291
294
|
const data = findTextData(event);
|