@codingame/monaco-editor-wrapper 2.1.2 → 2.2.0
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/dist/configuration/index.d.ts +5 -2
- package/dist/features/htmlContribution.js +20 -11
- package/dist/index.js +11 -8
- package/dist/main.js +33 -27
- package/package.json +3 -2
- package/stats.html +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor';
|
|
2
|
-
|
|
2
|
+
import { IConfigurationChangeEvent } from 'vscode/services';
|
|
3
|
+
import * as vscode from 'vscode';
|
|
4
|
+
import { updateUserConfiguration } from 'vscode/service-override/configuration';
|
|
5
|
+
export declare function onConfigurationChanged(listener: (e: IConfigurationChangeEvent) => void): vscode.Disposable;
|
|
3
6
|
export declare function getConfiguration<C = Partial<monaco.editor.IEditorOptions>>(language?: string, section?: string): C | undefined;
|
|
4
|
-
export
|
|
7
|
+
export { updateUserConfiguration };
|
|
5
8
|
export declare function registerConfigurations(configurations: monaco.extra.IConfigurationNode[], validate?: boolean): void;
|
|
6
9
|
export declare function registerDefaultConfigurations(defaultConfigurations: monaco.extra.IStringDictionary<unknown>[]): void;
|
|
@@ -2,6 +2,8 @@ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
|
2
2
|
import 'monaco-editor/esm/vs/language/html/monaco.contribution';
|
|
3
3
|
import { r as registerConfigurations, g as getConfiguration, o as onConfigurationChanged } from '../index.js';
|
|
4
4
|
import { r as registerWorkerLoader } from '../worker.js';
|
|
5
|
+
import 'vscode/services';
|
|
6
|
+
import 'vscode/service-override/configuration';
|
|
5
7
|
|
|
6
8
|
const workerLoader = async () => (await import(
|
|
7
9
|
/* webpackChunkName: "MonacoHtmlWorker" */
|
|
@@ -30,11 +32,15 @@ registerConfigurations([{
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}]);
|
|
33
|
-
let autoClosingTags =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
let autoClosingTags = false;
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
// In a timeout so the service can be overriden
|
|
38
|
+
autoClosingTags = getConfiguration(undefined, 'html.autoClosingTags');
|
|
39
|
+
onConfigurationChanged(e => {
|
|
40
|
+
if (e.affectsConfiguration('html.autoClosingTags')) {
|
|
41
|
+
autoClosingTags = getConfiguration(undefined, 'html.autoClosingTags');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
38
44
|
});
|
|
39
45
|
|
|
40
46
|
function autoCloseHtmlTags(editor) {
|
|
@@ -101,14 +107,17 @@ function autoCloseHtmlTags(editor) {
|
|
|
101
107
|
return disposableStore;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
// In a timeout so the service can be overriden
|
|
112
|
+
const codeEditors = monaco.extra.StandaloneServices.get(monaco.extra.ICodeEditorService).listCodeEditors();
|
|
105
113
|
|
|
106
|
-
for (const editor of codeEditors) {
|
|
107
|
-
|
|
108
|
-
}
|
|
114
|
+
for (const editor of codeEditors) {
|
|
115
|
+
autoCloseHtmlTags(editor);
|
|
116
|
+
}
|
|
109
117
|
|
|
110
|
-
monaco.editor.onDidCreateEditor(editor => {
|
|
111
|
-
|
|
118
|
+
monaco.editor.onDidCreateEditor(editor => {
|
|
119
|
+
autoCloseHtmlTags(editor);
|
|
120
|
+
});
|
|
112
121
|
});
|
|
113
122
|
/**
|
|
114
123
|
* End autoclosing html tags
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
+
import { IConfigurationService } from 'vscode/services';
|
|
3
|
+
import 'vscode/service-override/configuration';
|
|
2
4
|
|
|
3
5
|
var configurationDefaults = {
|
|
4
6
|
"[go]": {
|
|
@@ -1222,23 +1224,24 @@ configurationRegistry.registerDefaultConfigurations([{
|
|
|
1222
1224
|
'editor.codeLens': false,
|
|
1223
1225
|
'editor.fontSize': 12,
|
|
1224
1226
|
'editor.maxTokenizationLineLength': 1000,
|
|
1225
|
-
'editor.quickSuggestions': false
|
|
1227
|
+
'editor.quickSuggestions': false,
|
|
1228
|
+
'files.eol': '\n'
|
|
1226
1229
|
}
|
|
1227
1230
|
}]);
|
|
1228
1231
|
configurationRegistry.registerDefaultConfigurations([{
|
|
1229
1232
|
overrides: extensions.configurationDefaults
|
|
1230
1233
|
}]);
|
|
1231
|
-
|
|
1232
|
-
const
|
|
1234
|
+
function onConfigurationChanged(listener) {
|
|
1235
|
+
const configurationService = monaco.extra.StandaloneServices.get(IConfigurationService);
|
|
1236
|
+
return configurationService.onDidChangeConfiguration(listener);
|
|
1237
|
+
}
|
|
1233
1238
|
function getConfiguration(language) {
|
|
1234
1239
|
let section = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'editor';
|
|
1235
|
-
|
|
1240
|
+
const configurationService = monaco.extra.StandaloneServices.get(IConfigurationService);
|
|
1241
|
+
return configurationService.getValue(section, {
|
|
1236
1242
|
overrideIdentifier: language
|
|
1237
1243
|
});
|
|
1238
1244
|
}
|
|
1239
|
-
function updateUserConfiguration(configurationJson) {
|
|
1240
|
-
simpleConfigurationService.updateUserConfiguration(configurationJson);
|
|
1241
|
-
}
|
|
1242
1245
|
function registerConfigurations(configurations, validate) {
|
|
1243
1246
|
configurationRegistry.registerConfigurations(configurations, validate);
|
|
1244
1247
|
}
|
|
@@ -1248,4 +1251,4 @@ function registerDefaultConfigurations(defaultConfigurations) {
|
|
|
1248
1251
|
})));
|
|
1249
1252
|
}
|
|
1250
1253
|
|
|
1251
|
-
export { registerDefaultConfigurations as a, extensions as e, getConfiguration as g, onConfigurationChanged as o, registerConfigurations as r
|
|
1254
|
+
export { registerDefaultConfigurations as a, extensions as e, getConfiguration as g, onConfigurationChanged as o, registerConfigurations as r };
|
package/dist/main.js
CHANGED
|
@@ -4,10 +4,13 @@ import { _ as _objectSpread2, a as _defineProperty } from './_rollupPluginBabelH
|
|
|
4
4
|
import onigFile from 'vscode-oniguruma/release/onig.wasm';
|
|
5
5
|
import { loadWASM, createOnigScanner, createOnigString } from 'vscode-oniguruma';
|
|
6
6
|
import { e as extensions, g as getConfiguration$1, o as onConfigurationChanged } from './index.js';
|
|
7
|
-
export { g as getConfiguration, o as onConfigurationChanged, r as registerConfigurations, a as registerDefaultConfigurations
|
|
7
|
+
export { g as getConfiguration, o as onConfigurationChanged, r as registerConfigurations, a as registerDefaultConfigurations } from './index.js';
|
|
8
8
|
import getModelEditorServiceOverride from 'vscode/service-override/modelEditor';
|
|
9
9
|
import getMessageServiceOverride from 'vscode/service-override/messages';
|
|
10
|
+
import getConfigurationServiceOverride from 'vscode/service-override/configuration';
|
|
11
|
+
export { updateUserConfiguration } from 'vscode/service-override/configuration';
|
|
10
12
|
import './worker.js';
|
|
13
|
+
import { createConfiguredEditor } from 'vscode/monaco';
|
|
11
14
|
import 'monaco-editor/esm/vs/editor/editor.all';
|
|
12
15
|
import 'monaco-editor/esm/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp';
|
|
13
16
|
import 'monaco-editor/esm/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard';
|
|
@@ -18,6 +21,7 @@ import 'monaco-editor/esm/vs/editor/standalone/browser/quickAccess/standaloneGot
|
|
|
18
21
|
import 'monaco-editor/esm/vs/editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess';
|
|
19
22
|
import 'monaco-editor/esm/vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch';
|
|
20
23
|
import * as shiftCommand from 'monaco-editor/esm/vs/editor/common/commands/shiftCommand';
|
|
24
|
+
import 'vscode/services';
|
|
21
25
|
|
|
22
26
|
function _mergeNamespaces(n, m) {
|
|
23
27
|
m.forEach(function (e) {
|
|
@@ -1852,11 +1856,10 @@ function getOrCreateGrammarFactory() {
|
|
|
1852
1856
|
return textMateGrammarFactory;
|
|
1853
1857
|
}
|
|
1854
1858
|
|
|
1855
|
-
const languageService$2 = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
1856
|
-
|
|
1857
1859
|
async function createTextMateTokensProvider(languageId) {
|
|
1860
|
+
const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
1858
1861
|
const grammarFactory = getOrCreateGrammarFactory();
|
|
1859
|
-
const encodedLanguageId = languageService
|
|
1862
|
+
const encodedLanguageId = languageService.languageIdCodec.encodeLanguageId(languageId);
|
|
1860
1863
|
|
|
1861
1864
|
if (!grammarFactory.has(languageId)) {
|
|
1862
1865
|
return null;
|
|
@@ -1875,7 +1878,7 @@ async function createTextMateTokensProvider(languageId) {
|
|
|
1875
1878
|
const tokenization = new monaco$2.extra.TMTokenization(grammar, initialState, containsEmbeddedLanguages);
|
|
1876
1879
|
tokenization.onDidEncounterLanguage(encodedLanguageId => {
|
|
1877
1880
|
// Force monaco to load this language and trigger the global `onDidEncounterLanguage`
|
|
1878
|
-
languageService
|
|
1881
|
+
languageService.createById(languageService.languageIdCodec.decodeLanguageId(encodedLanguageId));
|
|
1879
1882
|
});
|
|
1880
1883
|
return new CGTMTokenizationSupport(languageId, encodedLanguageId, tokenization, grammar);
|
|
1881
1884
|
}
|
|
@@ -4108,9 +4111,12 @@ class SimpleSnippetService {
|
|
|
4108
4111
|
|
|
4109
4112
|
}
|
|
4110
4113
|
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
monaco$2.extra.
|
|
4114
|
+
setTimeout(() => {
|
|
4115
|
+
// In a timeout so the service can be overriden
|
|
4116
|
+
const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
4117
|
+
const languageConfigurationService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageConfigurationService);
|
|
4118
|
+
monaco$2.extra.setSnippetSuggestSupport(new monaco$2.extra.SnippetCompletionProvider(languageService, new SimpleSnippetService(), languageConfigurationService));
|
|
4119
|
+
});
|
|
4114
4120
|
|
|
4115
4121
|
/* Add custom blocks parsing (for tech.io):
|
|
4116
4122
|
// { [autofold]
|
|
@@ -4153,7 +4159,6 @@ for (const [languageId, aliases] of Object.entries(customAliases)) {
|
|
|
4153
4159
|
});
|
|
4154
4160
|
}
|
|
4155
4161
|
|
|
4156
|
-
const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
4157
4162
|
const languagesIds = Array.from(new Set([...Object.keys(languageLoader), ...textMateLanguages.map(rawLanguage => rawLanguage.id)]));
|
|
4158
4163
|
|
|
4159
4164
|
for (const textMateLanguage of textMateLanguages) {
|
|
@@ -4218,19 +4223,24 @@ async function loadLanguageConfiguration(languageId) {
|
|
|
4218
4223
|
}
|
|
4219
4224
|
}
|
|
4220
4225
|
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4226
|
+
setTimeout(() => {
|
|
4227
|
+
// In a timeout so the service can be overriden
|
|
4228
|
+
const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
4229
|
+
languageService.onDidEncounterLanguage(async languageId => {
|
|
4230
|
+
if (languageId === 'plaintext') {
|
|
4231
|
+
return;
|
|
4232
|
+
}
|
|
4225
4233
|
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4234
|
+
loadLanguageConfiguration(languageId).catch(error => {
|
|
4235
|
+
monaco$2.errorHandler.onUnexpectedError(new Error("Unable to load language configuration for language ".concat(languageId), {
|
|
4236
|
+
cause: error
|
|
4237
|
+
}));
|
|
4238
|
+
});
|
|
4230
4239
|
});
|
|
4231
4240
|
});
|
|
4232
4241
|
|
|
4233
4242
|
function getMonacoLanguage(languageOrModeId) {
|
|
4243
|
+
const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
|
|
4234
4244
|
const modeId = languageService.getLanguageIdByLanguageName(languageOrModeId.toLowerCase());
|
|
4235
4245
|
|
|
4236
4246
|
if (modeId != null) {
|
|
@@ -4626,24 +4636,20 @@ class EditorOpenHandlerRegistry {
|
|
|
4626
4636
|
}
|
|
4627
4637
|
|
|
4628
4638
|
const editorOpenHandlerRegistry = new EditorOpenHandlerRegistry();
|
|
4629
|
-
monaco$2.extra.StandaloneServices.initialize(_objectSpread2(_objectSpread2({}, getModelEditorServiceOverride((model, input, sideBySide) => {
|
|
4639
|
+
monaco$2.extra.StandaloneServices.initialize(_objectSpread2(_objectSpread2(_objectSpread2({}, getModelEditorServiceOverride((model, input, sideBySide) => {
|
|
4630
4640
|
return editorOpenHandlerRegistry.openCodeEditor(model, input, sideBySide);
|
|
4631
|
-
})), getMessageServiceOverride(document.body))); // Disable high contrast autodetection because it fallbacks on the hc-black no matter what
|
|
4632
|
-
|
|
4633
|
-
monaco$2.extra.StandaloneServices.get(monaco$2.editor.IStandaloneThemeService).setAutoDetectHighContrast(false); // Force EOL to be '\n' even on Windows
|
|
4641
|
+
})), getMessageServiceOverride(document.body)), getConfigurationServiceOverride())); // Disable high contrast autodetection because it fallbacks on the hc-black no matter what
|
|
4634
4642
|
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
monaco$2.
|
|
4638
|
-
cause: error
|
|
4639
|
-
}));
|
|
4643
|
+
setTimeout(() => {
|
|
4644
|
+
// In a timeout so the service can be overriden
|
|
4645
|
+
monaco$2.extra.StandaloneServices.get(monaco$2.editor.IStandaloneThemeService).setAutoDetectHighContrast(false);
|
|
4640
4646
|
});
|
|
4641
4647
|
monaco$2.errorHandler.setUnexpectedErrorHandler(error => {
|
|
4642
4648
|
console.warn('Unexpected error', error);
|
|
4643
4649
|
});
|
|
4644
4650
|
|
|
4645
4651
|
function createEditor(domElement, options) {
|
|
4646
|
-
const editor =
|
|
4652
|
+
const editor = createConfiguredEditor(domElement, options);
|
|
4647
4653
|
setup(editor);
|
|
4648
4654
|
return editor;
|
|
4649
4655
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-editor-wrapper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Enhanced Monaco editor with TextMate grammars and more",
|
|
6
6
|
"scripts": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"monaco-editor": "npm:@codingame/monaco-editor@^0.33.6",
|
|
69
|
-
"vscode": "npm:@codingame/monaco-vscode-api@~1.67.
|
|
69
|
+
"vscode": "npm:@codingame/monaco-vscode-api@~1.67.19",
|
|
70
70
|
"vscode-oniguruma": "^1.6.2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"@types/js-yaml": "^4.0.5",
|
|
89
89
|
"@types/node": "16.11.7",
|
|
90
90
|
"@types/rollup-plugin-node-builtins": "^2.1.2",
|
|
91
|
+
"@types/vscode": "~1.67.0",
|
|
91
92
|
"@typescript-eslint/eslint-plugin": "5.27.1",
|
|
92
93
|
"@typescript-eslint/parser": "5.27.1",
|
|
93
94
|
"conventional-changelog-conventionalcommits": "^4.6.3",
|