@difizen/libro-code-editor 0.2.10 → 0.2.11
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-info-manager.d.ts +4 -3
- package/es/code-editor-info-manager.d.ts.map +1 -1
- package/es/code-editor-manager.d.ts +2 -1
- package/es/code-editor-manager.d.ts.map +1 -1
- package/es/code-editor-view.d.ts +2 -2
- package/es/code-editor-view.d.ts.map +1 -1
- package/es/code-editor-view.js +11 -4
- package/package.json +2 -2
- package/src/code-editor-info-manager.ts +2 -2
- package/src/code-editor-manager.ts +1 -1
- package/src/code-editor-view.tsx +6 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
1
2
|
export declare class CodeEditorInfoManager {
|
|
2
|
-
editorHostRefMap: Map<string,
|
|
3
|
+
editorHostRefMap: Map<string, React.RefObject<HTMLDivElement>>;
|
|
3
4
|
constructor();
|
|
4
|
-
setEditorHostRef(id: string, ref:
|
|
5
|
-
getEditorHostRef(id: string):
|
|
5
|
+
setEditorHostRef(id: string, ref: React.RefObject<HTMLDivElement>): void;
|
|
6
|
+
getEditorHostRef(id: string): import("react").RefObject<HTMLDivElement> | undefined;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=code-editor-info-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor-info-manager.d.ts","sourceRoot":"","sources":["../src/code-editor-info-manager.ts"],"names":[],"mappings":"AAEA,qBACa,qBAAqB;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"code-editor-info-manager.d.ts","sourceRoot":"","sources":["../src/code-editor-info-manager.ts"],"names":[],"mappings":";AAEA,qBACa,qBAAqB;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;;IAM/D,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IAQjE,gBAAgB,CAAC,EAAE,EAAE,MAAM;CAM5B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
1
2
|
import type { Contribution } from '@difizen/mana-app';
|
|
2
3
|
import { ViewManager } from '@difizen/mana-app';
|
|
3
4
|
import { CodeEditorInfoManager } from './code-editor-info-manager.js';
|
|
@@ -13,7 +14,7 @@ export declare class CodeEditorManager {
|
|
|
13
14
|
protected codeEditorInfoManager: CodeEditorInfoManager;
|
|
14
15
|
protected readonly codeEditorSettings: CodeEditorSettings;
|
|
15
16
|
protected stateCache: Map<string, EditorState>;
|
|
16
|
-
setEditorHostRef(id: string, ref:
|
|
17
|
+
setEditorHostRef(id: string, ref: React.RefObject<HTMLDivElement>): void;
|
|
17
18
|
protected findCodeEditorProvider(model: IModel): CodeEditorContribution<any>;
|
|
18
19
|
/**
|
|
19
20
|
* 获取默认配置
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor-manager.d.ts","sourceRoot":"","sources":["../src/code-editor-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAY,WAAW,EAA8B,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,cAAc,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IAC1D,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IACtF,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAa;IAE3D,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IAIjE,SAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM;IAS9C;;;;OAIG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM;IAIpC;;;;OAIG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO3B,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;CAgBpF"}
|
package/es/code-editor-view.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class CodeEditorView extends BaseView {
|
|
|
19
19
|
protected classlist: string[];
|
|
20
20
|
protected options: CodeEditorViewOptions;
|
|
21
21
|
protected modalChangeEmitter: Emitter<any>;
|
|
22
|
-
protected editorHostRef:
|
|
22
|
+
protected editorHostRef: React.RefObject<HTMLDivElement> | null | undefined;
|
|
23
23
|
get onModalChange(): import("@difizen/mana-app").Event<any>;
|
|
24
24
|
/**
|
|
25
25
|
* Get the editor wrapped by the widget.
|
|
@@ -38,7 +38,7 @@ export declare class CodeEditorView extends BaseView {
|
|
|
38
38
|
* Construct a new code editor widget.
|
|
39
39
|
*/
|
|
40
40
|
constructor(options: CodeEditorViewOptions, codeEditorInfoManager: CodeEditorInfoManager);
|
|
41
|
-
protected getEditorHost():
|
|
41
|
+
protected getEditorHost(): import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
42
42
|
onViewMount(): Promise<void>;
|
|
43
43
|
removeChildNodes: (parent: any) => void;
|
|
44
44
|
onViewUnmount: () => void;
|
|
@@ -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,kBAAkB,eAAiB;IAE7C,SAAS,CAAC,aAAa,EAAE,GAAG,CAAC;
|
|
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;AAC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
CHANGED
|
@@ -222,7 +222,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
222
222
|
key: "onViewMount",
|
|
223
223
|
value: function () {
|
|
224
224
|
var _onViewMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
225
|
-
var
|
|
225
|
+
var _this$editorHostRef3,
|
|
226
|
+
_this2 = this;
|
|
226
227
|
var state, settings, cursorPosition, selections, prevState;
|
|
227
228
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
228
229
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -236,8 +237,8 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
236
237
|
state = _context.sent;
|
|
237
238
|
settings = this.codeEditorSettings.getUserEditorSettings();
|
|
238
239
|
this.editorHostRef = this.getEditorHost();
|
|
239
|
-
if (!(this.editorHostRef.current && this.options.factory)) {
|
|
240
|
-
_context.next =
|
|
240
|
+
if (!((_this$editorHostRef3 = this.editorHostRef) !== null && _this$editorHostRef3 !== void 0 && _this$editorHostRef3.current && this.options.factory)) {
|
|
241
|
+
_context.next = 25;
|
|
241
242
|
break;
|
|
242
243
|
}
|
|
243
244
|
this.editor = this.options.factory(_objectSpread(_objectSpread({}, this.options), {}, {
|
|
@@ -273,6 +274,12 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
273
274
|
if (this.options.autoFocus) {
|
|
274
275
|
this.editor.focus();
|
|
275
276
|
}
|
|
277
|
+
if (this.editorHostRef.current) {
|
|
278
|
+
_context.next = 19;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return _context.abrupt("return");
|
|
282
|
+
case 19:
|
|
276
283
|
this.editorHostRef.current.addEventListener('focus', this.onViewActive);
|
|
277
284
|
this.editorHostRef.current.addEventListener('dragenter', this._evtDragEnter);
|
|
278
285
|
this.editorHostRef.current.addEventListener('dragleave', this._evtDragLeave);
|
|
@@ -281,7 +288,7 @@ export var CodeEditorView = (_dec = transient(), _dec2 = view('code-editor-view'
|
|
|
281
288
|
this.toDispose.push(this.codeEditorSettings.onCodeEditorSettingsChange(function (e) {
|
|
282
289
|
_this2.editor.setOption(e.key, e.value);
|
|
283
290
|
}));
|
|
284
|
-
case
|
|
291
|
+
case 25:
|
|
285
292
|
case "end":
|
|
286
293
|
return _context.stop();
|
|
287
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-code-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@difizen/mana-app": "latest",
|
|
36
36
|
"@difizen/mana-l10n": "latest",
|
|
37
|
-
"@difizen/libro-common": "^0.2.
|
|
37
|
+
"@difizen/libro-common": "^0.2.11",
|
|
38
38
|
"uuid": "^9.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -2,13 +2,13 @@ import { singleton } from '@difizen/mana-app';
|
|
|
2
2
|
|
|
3
3
|
@singleton()
|
|
4
4
|
export class CodeEditorInfoManager {
|
|
5
|
-
editorHostRefMap: Map<string,
|
|
5
|
+
editorHostRefMap: Map<string, React.RefObject<HTMLDivElement>>;
|
|
6
6
|
|
|
7
7
|
constructor() {
|
|
8
8
|
this.editorHostRefMap = new Map();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
setEditorHostRef(id: string, ref:
|
|
11
|
+
setEditorHostRef(id: string, ref: React.RefObject<HTMLDivElement>) {
|
|
12
12
|
if (!this.editorHostRefMap) {
|
|
13
13
|
this.editorHostRefMap = new Map();
|
|
14
14
|
}
|
|
@@ -18,7 +18,7 @@ export class CodeEditorManager {
|
|
|
18
18
|
@inject(CodeEditorSettings) protected readonly codeEditorSettings: CodeEditorSettings;
|
|
19
19
|
protected stateCache: Map<string, EditorState> = new Map();
|
|
20
20
|
|
|
21
|
-
setEditorHostRef(id: string, ref:
|
|
21
|
+
setEditorHostRef(id: string, ref: React.RefObject<HTMLDivElement>) {
|
|
22
22
|
this.codeEditorInfoManager.setEditorHostRef(id, ref);
|
|
23
23
|
}
|
|
24
24
|
|
package/src/code-editor-view.tsx
CHANGED
|
@@ -73,7 +73,7 @@ export class CodeEditorView extends BaseView {
|
|
|
73
73
|
|
|
74
74
|
protected modalChangeEmitter = new Emitter();
|
|
75
75
|
|
|
76
|
-
protected editorHostRef:
|
|
76
|
+
protected editorHostRef: React.RefObject<HTMLDivElement> | null | undefined;
|
|
77
77
|
|
|
78
78
|
get onModalChange() {
|
|
79
79
|
return this.modalChangeEmitter.event;
|
|
@@ -123,7 +123,7 @@ export class CodeEditorView extends BaseView {
|
|
|
123
123
|
|
|
124
124
|
this.editorHostRef = this.getEditorHost();
|
|
125
125
|
|
|
126
|
-
if (this.editorHostRef
|
|
126
|
+
if (this.editorHostRef?.current && this.options.factory) {
|
|
127
127
|
this.editor = this.options.factory(
|
|
128
128
|
{
|
|
129
129
|
...this.options,
|
|
@@ -160,6 +160,10 @@ export class CodeEditorView extends BaseView {
|
|
|
160
160
|
this.editor.focus();
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
if (!this.editorHostRef.current) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
163
167
|
this.editorHostRef.current.addEventListener('focus', this.onViewActive);
|
|
164
168
|
this.editorHostRef.current.addEventListener('dragenter', this._evtDragEnter);
|
|
165
169
|
this.editorHostRef.current.addEventListener('dragleave', this._evtDragLeave);
|