@difizen/libro-cofine-editor-core 0.1.17 → 0.1.19

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 +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,MAAM,CAAC,iBAAiB,CACtB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,GACf,MAAM,CAAC,MAAM,CAAC,UAAU;IAI3B,MAAM,CAAC,kBAAkB,CACvB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,CAAC,qBAAqB;IAItC,MAAM,CAAC,sBAAsB,CAC3B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,CAAC,qBAAqB;IAGtC,UAAU,EAAG,CAAC,CAAC;IACf,KAAK,EAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACjC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__*/function (
36
36
  if (MonacoEnvironment.lazy) {
37
37
  // 资源懒加载场景
38
38
  if (!isDiff) {
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);
39
+ var model = options.model;
40
+ if (!model) {
41
+ if (options.uri) {
42
+ model = monaco.editor.getModel(options.uri);
43
+ }
44
+ }
45
+ if (!model) {
46
+ model = monaco.editor.createModel(options.value || '', options.language, options.uri);
47
+ }
48
+ this.model = model;
41
49
  var language = this.model.getLanguageId();
42
50
  this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
43
51
  model: this.model
@@ -83,8 +91,16 @@ export var E2Editor = (_dec = singleton(), _dec(_class = /*#__PURE__*/function (
83
91
  // create前钩子函数调用
84
92
  this.handleEditorLanguageFeatureBefore(options.language);
85
93
  if (!isDiff) {
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);
94
+ var _model = options.model;
95
+ if (!_model) {
96
+ if (options.uri) {
97
+ _model = monaco.editor.getModel(options.uri);
98
+ }
99
+ }
100
+ if (!_model) {
101
+ _model = monaco.editor.createModel(options.value || '', options.language, options.uri);
102
+ }
103
+ this.model = _model;
88
104
  this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
89
105
  model: this.model
90
106
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-cofine-editor-core",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -33,7 +33,7 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@difizen/libro-cofine-editor-contribution": "^0.1.17",
36
+ "@difizen/libro-cofine-editor-contribution": "^0.1.19",
37
37
  "@difizen/mana-app": "latest",
38
38
  "@difizen/monaco-editor-core": "0.39.4",
39
39
  "debug": "^4.3.2",
package/src/e2-editor.ts CHANGED
@@ -70,9 +70,20 @@ export class E2Editor<
70
70
  if (MonacoEnvironment.lazy) {
71
71
  // 资源懒加载场景
72
72
  if (!isDiff) {
73
- this.model =
74
- options.model ??
75
- monaco.editor.createModel(options.value || '', options.language, options.uri);
73
+ let model = options.model;
74
+ if (!model) {
75
+ if (options.uri) {
76
+ model = monaco.editor.getModel(options.uri);
77
+ }
78
+ }
79
+ if (!model) {
80
+ model = monaco.editor.createModel(
81
+ options.value || '',
82
+ options.language,
83
+ options.uri,
84
+ );
85
+ }
86
+ this.model = model;
76
87
  const language = this.model.getLanguageId();
77
88
  (this as E2Editor<monaco.editor.IStandaloneCodeEditor>).codeEditor =
78
89
  monaco.editor.create(node, { ...options, model: this.model });
@@ -131,9 +142,20 @@ export class E2Editor<
131
142
  this.handleEditorLanguageFeatureBefore(options.language);
132
143
 
133
144
  if (!isDiff) {
134
- this.model =
135
- options.model ??
136
- monaco.editor.createModel(options.value || '', options.language, options.uri);
145
+ let model = options.model;
146
+ if (!model) {
147
+ if (options.uri) {
148
+ model = monaco.editor.getModel(options.uri);
149
+ }
150
+ }
151
+ if (!model) {
152
+ model = monaco.editor.createModel(
153
+ options.value || '',
154
+ options.language,
155
+ options.uri,
156
+ );
157
+ }
158
+ this.model = model;
137
159
  (this as E2Editor<monaco.editor.IStandaloneCodeEditor>).codeEditor =
138
160
  monaco.editor.create(node, { ...options, model: this.model });
139
161
  this.toDispose.push(