@difizen/libro-cofine-editor-core 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/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);
@@ -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 _class;
2
+ var _MonacoEnvironment;
3
3
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
5
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -256,19 +256,19 @@ export var MonacoEnvironment = /*#__PURE__*/function () {
256
256
  }]);
257
257
  return MonacoEnvironment;
258
258
  }();
259
- _class = MonacoEnvironment;
259
+ _MonacoEnvironment = MonacoEnvironment;
260
260
  MonacoEnvironment.loaders = [];
261
261
  MonacoEnvironment.preLoaders = [];
262
262
  MonacoEnvironment.moduleLoadStart = false;
263
263
  MonacoEnvironment.moduleInitDeferred = new Deferred();
264
264
  MonacoEnvironment.lazy = false;
265
265
  MonacoEnvironment.setContainer = function (container) {
266
- _class.container = container;
266
+ _MonacoEnvironment.container = container;
267
267
  if (!container.isBound(MonacoEnvironmentBound)) {
268
268
  container.register(MonacoEnvironmentBound, {
269
269
  useValue: true
270
270
  });
271
- _class.container.register(MonacoLoaderConfig, {
271
+ _MonacoEnvironment.container.register(MonacoLoaderConfig, {
272
272
  useValue: DefaultLoaderConfig
273
273
  });
274
274
  container.register(MonacoLoader);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-cofine-editor-core",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
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.14",
36
+ "@difizen/libro-cofine-editor-contribution": "^0.1.16",
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(