@difizen/libro-cofine-textmate 0.2.4 → 0.2.6
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":"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;AAC3B,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAOtD,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,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
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;AAC3B,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAOtD,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,OAA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initionContribution } from "./textmate-contribution.js";
|
|
28
28
|
import { TextmateRegistry } from "./textmate-registry.js";
|
|
29
29
|
import { createTextmateTokenizer } from "./textmate-tokenizer.js";
|
|
30
|
+
function isDiffEditor(obj) {
|
|
31
|
+
return 'getOriginalEditor' in obj && typeof obj.getOriginalEditor === 'function' && 'getModifiedEditor' in obj && typeof obj.getModifiedEditor === 'function';
|
|
32
|
+
}
|
|
30
33
|
export var MonacoTextmateService = (_dec = singleton({
|
|
31
34
|
contrib: EditorHandlerContribution
|
|
32
35
|
}), _dec2 = contrib(LanguageGrammarDefinitionContribution), _dec3 = inject(TextmateRegistry), _dec4 = inject(MonacoGrammarRegistry), _dec5 = inject(OnigurumaPromise), _dec6 = inject(MonacoThemeRegistry), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
@@ -69,14 +72,22 @@ export var MonacoTextmateService = (_dec = singleton({
|
|
|
69
72
|
}, {
|
|
70
73
|
key: "afterCreate",
|
|
71
74
|
value: function afterCreate(editor) {
|
|
72
|
-
var _getModel;
|
|
73
75
|
var toDispose = new DisposableCollection(Disposable.create(function () {
|
|
74
76
|
/* mark as not disposed */
|
|
75
77
|
}));
|
|
76
78
|
// 激活语言必须在创建编辑器实例后
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (isDiffEditor(editor)) {
|
|
80
|
+
var _getModel;
|
|
81
|
+
var lang = (_getModel = editor.getModel()) === null || _getModel === void 0 || (_getModel = _getModel.modified) === null || _getModel === void 0 ? void 0 : _getModel.getLanguageId();
|
|
82
|
+
if (lang) {
|
|
83
|
+
this.doActivateLanguage(lang, toDispose);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
var _getModel2;
|
|
87
|
+
var _lang = (_getModel2 = editor.getModel()) === null || _getModel2 === void 0 ? void 0 : _getModel2.getLanguageId();
|
|
88
|
+
if (_lang) {
|
|
89
|
+
this.doActivateLanguage(_lang, toDispose);
|
|
90
|
+
}
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-cofine-textmate",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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-core": "^0.2.
|
|
36
|
+
"@difizen/libro-cofine-editor-core": "^0.2.6",
|
|
37
37
|
"@difizen/mana-app": "latest",
|
|
38
38
|
"fast-plist": "^0.1.2",
|
|
39
39
|
"vscode-oniguruma": "^1.5.1",
|
|
@@ -28,6 +28,15 @@ import { TextmateRegistry } from './textmate-registry.js';
|
|
|
28
28
|
import type { TokenizerOption } from './textmate-tokenizer.js';
|
|
29
29
|
import { createTextmateTokenizer } from './textmate-tokenizer.js';
|
|
30
30
|
|
|
31
|
+
function isDiffEditor(obj: any): obj is monaco.editor.IStandaloneDiffEditor {
|
|
32
|
+
return (
|
|
33
|
+
'getOriginalEditor' in obj &&
|
|
34
|
+
typeof obj.getOriginalEditor === 'function' &&
|
|
35
|
+
'getModifiedEditor' in obj &&
|
|
36
|
+
typeof obj.getModifiedEditor === 'function'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
@singleton({ contrib: EditorHandlerContribution })
|
|
32
41
|
export class MonacoTextmateService implements EditorHandlerContribution {
|
|
33
42
|
protected readonly tokenizerOption: TokenizerOption = {
|
|
@@ -62,11 +71,20 @@ export class MonacoTextmateService implements EditorHandlerContribution {
|
|
|
62
71
|
}),
|
|
63
72
|
);
|
|
64
73
|
// 激活语言必须在创建编辑器实例后
|
|
65
|
-
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
if (isDiffEditor(editor)) {
|
|
75
|
+
const lang = (editor as monaco.editor.IStandaloneDiffEditor)
|
|
76
|
+
.getModel()
|
|
77
|
+
?.modified?.getLanguageId();
|
|
78
|
+
if (lang) {
|
|
79
|
+
this.doActivateLanguage(lang, toDispose);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const lang = (editor as monaco.editor.IStandaloneCodeEditor)
|
|
83
|
+
.getModel()
|
|
84
|
+
?.getLanguageId();
|
|
85
|
+
if (lang) {
|
|
86
|
+
this.doActivateLanguage(lang, toDispose);
|
|
87
|
+
}
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
canHandle() {
|