@difizen/libro-cofine-textmate 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.
@@ -1,6 +1,7 @@
1
1
  import { EditorHandlerContribution } from '@difizen/libro-cofine-editor-core';
2
2
  import type { Contribution } from '@difizen/mana-app';
3
3
  import { Disposable, DisposableCollection } from '@difizen/mana-app';
4
+ import * as monaco from '@difizen/monaco-editor-core';
4
5
  import { MonacoGrammarRegistry, OnigurumaPromise } from './monaco-grammar-registry.js';
5
6
  import { MonacoThemeRegistry } from './monaco-theme-registry.js';
6
7
  import { LanguageGrammarDefinitionContribution } from './textmate-contribution.js';
@@ -15,7 +16,7 @@ export declare class MonacoTextmateService implements EditorHandlerContribution
15
16
  protected readonly onigasmPromise: OnigurumaPromise;
16
17
  protected readonly monacoThemeRegistry: MonacoThemeRegistry;
17
18
  beforeCreate(): void;
18
- afterCreate(): void;
19
+ afterCreate(editor: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor): void;
19
20
  canHandle(): boolean;
20
21
  dispose(): void;
21
22
  initialize(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"monaco-textmate-service.d.ts","sourceRoot":"","sources":["../src/monaco-textmate-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,UAAU,EACV,oBAAoB,EAIrB,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAEL,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAEL,qCAAqC,EACtC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE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O,CAAC,IAAI,CAAC;IAoEhB,SAAS,CAAC,eAAe,CACvB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EAET,GACA,UAAU;CAqBd"}
@@ -68,8 +68,16 @@ export var MonacoTextmateService = (_dec = singleton({
68
68
  }
69
69
  }, {
70
70
  key: "afterCreate",
71
- value: function afterCreate() {
72
- //
71
+ value: function afterCreate(editor) {
72
+ var _getModel;
73
+ var toDispose = new DisposableCollection(Disposable.create(function () {
74
+ /* mark as not disposed */
75
+ }));
76
+ // 激活语言必须在创建编辑器实例后
77
+ var lang = (_getModel = editor.getModel()) === null || _getModel === void 0 ? void 0 : _getModel.getLanguageId();
78
+ if (lang) {
79
+ this.doActivateLanguage(lang, toDispose);
80
+ }
73
81
  }
74
82
  }, {
75
83
  key: "canHandle",
@@ -252,6 +260,14 @@ export var MonacoTextmateService = (_dec = singleton({
252
260
  });
253
261
  }
254
262
  }
263
+ // dont work
264
+ // return monaco.editor.onDidCreateEditor((editor) => {
265
+ // if (editor.getModel()?.getLanguageId() === language) {
266
+ // cb();
267
+ // }
268
+ // });
269
+
270
+ // triggered on model create, too early if we create model before editor
255
271
  return monaco.languages.onLanguage(language, cb);
256
272
  }
257
273
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-cofine-textmate",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -33,14 +33,14 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@difizen/libro-cofine-editor-core": "^0.1.13",
36
+ "@difizen/libro-cofine-editor-core": "^0.1.15",
37
37
  "@difizen/mana-app": "latest",
38
38
  "fast-plist": "^0.1.2",
39
39
  "vscode-oniguruma": "^1.5.1",
40
40
  "vscode-textmate": "^9.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@difizen/monaco-editor-core": "latest",
43
+ "@difizen/monaco-editor-core": "0.39.4",
44
44
  "@types/debug": "^4.1.6"
45
45
  },
46
46
  "scripts": {
@@ -53,8 +53,21 @@ export class MonacoTextmateService implements EditorHandlerContribution {
53
53
  beforeCreate() {
54
54
  this.initialize();
55
55
  }
56
- afterCreate() {
57
- //
56
+ afterCreate(
57
+ editor: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor,
58
+ ) {
59
+ const toDispose = new DisposableCollection(
60
+ Disposable.create(() => {
61
+ /* mark as not disposed */
62
+ }),
63
+ );
64
+ // 激活语言必须在创建编辑器实例后
65
+ const lang = (editor as monaco.editor.IStandaloneCodeEditor)
66
+ .getModel()
67
+ ?.getLanguageId();
68
+ if (lang) {
69
+ this.doActivateLanguage(lang, toDispose);
70
+ }
58
71
  }
59
72
  canHandle() {
60
73
  return true;
@@ -215,6 +228,14 @@ export class MonacoTextmateService implements EditorHandlerContribution {
215
228
  });
216
229
  }
217
230
  }
231
+ // dont work
232
+ // return monaco.editor.onDidCreateEditor((editor) => {
233
+ // if (editor.getModel()?.getLanguageId() === language) {
234
+ // cb();
235
+ // }
236
+ // });
237
+
238
+ // triggered on model create, too early if we create model before editor
218
239
  return monaco.languages.onLanguage(language, cb);
219
240
  }
220
241
  }