@difizen/libro-cofine-editor-core 0.1.13 → 0.1.15

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/e2-editor.d.ts CHANGED
@@ -11,6 +11,9 @@ export declare const IsDiff: unique symbol;
11
11
  * E2 Editor
12
12
  */
13
13
  export declare class E2Editor<T extends monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor> {
14
+ static createMonacoModel(value: string, language?: string, uri?: monaco.Uri): monaco.editor.ITextModel;
15
+ static createMonacoEditor(node: HTMLElement, options: Options): monaco.editor.IStandaloneCodeEditor;
16
+ static createMonacoDiffEditor(node: HTMLElement, options: Options): monaco.editor.IStandaloneDiffEditor;
14
17
  codeEditor: T;
15
18
  model: monaco.editor.ITextModel;
16
19
  modified: monaco.editor.ITextModel;
@@ -1 +1 @@
1
- {"version":3,"file":"e2-editor.d.ts","sourceRoot":"","sources":["../../src/e2-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,UAAU,eAAuB,CAAC;AAC/C,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,MAAM,eAAmB,CAAC;AACvC;;GAEG;AAEH,qBACa,QAAQ,CACnB,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB;IAEnF,UAAU,EAAG,CAAC,CAAC;IACf,KAAK,EAAG,MAAM,CAAC,MAAM,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singleton(), _dec(_class = /*#__PURE__*/function (
36
36
  if (MonacoEnvironment.lazy) {
37
37
  // 资源懒加载场景
38
38
  if (!isDiff) {
39
- this.model = monaco.editor.createModel(options.value || '', options.language, options.uri);
39
+ var _options$model;
40
+ this.model = (_options$model = options.model) !== null && _options$model !== void 0 ? _options$model : monaco.editor.createModel(options.value || '', options.language, options.uri);
40
41
  var language = this.model.getLanguageId();
41
42
  this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
42
43
  model: this.model
@@ -82,7 +83,8 @@ export var E2Editor = (_dec = singleton(), _dec(_class = /*#__PURE__*/function (
82
83
  // create前钩子函数调用
83
84
  this.handleEditorLanguageFeatureBefore(options.language);
84
85
  if (!isDiff) {
85
- this.model = monaco.editor.createModel(options.value || '', options.language);
86
+ var _options$model2;
87
+ this.model = (_options$model2 = options.model) !== null && _options$model2 !== void 0 ? _options$model2 : monaco.editor.createModel(options.value || '', options.language, options.uri);
86
88
  this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
87
89
  model: this.model
88
90
  }));
@@ -126,6 +128,21 @@ export var E2Editor = (_dec = singleton(), _dec(_class = /*#__PURE__*/function (
126
128
  this.editorHandlerRegistry.handleAfter(this.language, this.codeEditor);
127
129
  }
128
130
  }
131
+ }], [{
132
+ key: "createMonacoModel",
133
+ value: function createMonacoModel(value, language, uri) {
134
+ return monaco.editor.createModel(value, language, uri);
135
+ }
136
+ }, {
137
+ key: "createMonacoEditor",
138
+ value: function createMonacoEditor(node, options) {
139
+ return monaco.editor.create(node, options);
140
+ }
141
+ }, {
142
+ key: "createMonacoDiffEditor",
143
+ value: function createMonacoDiffEditor(node, options) {
144
+ return monaco.editor.createDiffEditor(node, options);
145
+ }
129
146
  }]);
130
147
  return E2Editor;
131
148
  }()) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-cofine-editor-core",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -33,9 +33,9 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@difizen/libro-cofine-editor-contribution": "^0.1.13",
36
+ "@difizen/libro-cofine-editor-contribution": "^0.1.15",
37
37
  "@difizen/mana-app": "latest",
38
- "@difizen/monaco-editor-core": "latest",
38
+ "@difizen/monaco-editor-core": "0.39.4",
39
39
  "debug": "^4.3.2",
40
40
  "reflect-metadata": "^0.1.13"
41
41
  },
package/src/e2-editor.ts CHANGED
@@ -19,6 +19,27 @@ export const IsDiff = Symbol('IsDiff');
19
19
  export class E2Editor<
20
20
  T extends monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor,
21
21
  > {
22
+ static createMonacoModel(
23
+ value: string,
24
+ language?: string,
25
+ uri?: monaco.Uri,
26
+ ): monaco.editor.ITextModel {
27
+ return monaco.editor.createModel(value, language, uri);
28
+ }
29
+
30
+ static createMonacoEditor(
31
+ node: HTMLElement,
32
+ options: Options,
33
+ ): monaco.editor.IStandaloneCodeEditor {
34
+ return monaco.editor.create(node, options);
35
+ }
36
+
37
+ static createMonacoDiffEditor(
38
+ node: HTMLElement,
39
+ options: Options,
40
+ ): monaco.editor.IStandaloneDiffEditor {
41
+ return monaco.editor.createDiffEditor(node, options);
42
+ }
22
43
  codeEditor!: T;
23
44
  model!: monaco.editor.ITextModel;
24
45
  modified!: monaco.editor.ITextModel;
@@ -49,11 +70,9 @@ export class E2Editor<
49
70
  if (MonacoEnvironment.lazy) {
50
71
  // 资源懒加载场景
51
72
  if (!isDiff) {
52
- this.model = monaco.editor.createModel(
53
- options.value || '',
54
- options.language,
55
- options.uri,
56
- );
73
+ this.model =
74
+ options.model ??
75
+ monaco.editor.createModel(options.value || '', options.language, options.uri);
57
76
  const language = this.model.getLanguageId();
58
77
  (this as E2Editor<monaco.editor.IStandaloneCodeEditor>).codeEditor =
59
78
  monaco.editor.create(node, { ...options, model: this.model });
@@ -112,7 +131,9 @@ export class E2Editor<
112
131
  this.handleEditorLanguageFeatureBefore(options.language);
113
132
 
114
133
  if (!isDiff) {
115
- this.model = monaco.editor.createModel(options.value || '', options.language);
134
+ this.model =
135
+ options.model ??
136
+ monaco.editor.createModel(options.value || '', options.language, options.uri);
116
137
  (this as E2Editor<monaco.editor.IStandaloneCodeEditor>).codeEditor =
117
138
  monaco.editor.create(node, { ...options, model: this.model });
118
139
  this.toDispose.push(