Skip to content

Commit

Permalink
feat: fix monaco editor import language issue #10
Browse files Browse the repository at this point in the history
Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll committed Dec 30, 2023
1 parent 4037828 commit cf963f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
32 changes: 31 additions & 1 deletion src/views/editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,39 @@ const { established } = storeToRefs(connectionStore);
* refer https://github.com/wobsoriano/codeplayground
* https://github.com/wobsoriano/codeplayground/blob/master/src/components/MonacoEditor.vue
*/
self.MonacoEnvironment = {
async getWorker(_, label) {
let worker;
switch (label) {
case 'json':
worker = await import('monaco-editor/esm/vs/language/json/json.worker?worker');
break;
case 'css':
case 'scss':
case 'less':
worker = await import('monaco-editor/esm/vs/language/css/css.worker?worker');
break;
case 'html':
case 'handlebars':
case 'razor':
worker = await import('monaco-editor/esm/vs/language/html/html.worker?worker');
break;
case 'typescript':
case 'javascript':
worker = await import('monaco-editor/esm/vs/language/typescript/ts.worker?worker');
break;
default:
worker = await import('monaco-editor/esm/vs/editor/editor.worker?worker');
}
return new worker.default();
},
};
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
monaco.languages.register({ id: 'search' });
monaco.languages.setMonarchTokensProvider('search', searchTokensProvider);

Check failure on line 64 in src/views/editor/index.vue

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Argument of type '{ defaultToken: string; tokenPostfix: string; keywords: string[]; typeKeywords: string[]; symbols: RegExp; escapes: RegExp; digits: RegExp; octaldigits: RegExp; binarydigits: RegExp; hexdigits: RegExp; tokenizer: { ...; }; }' is not assignable to parameter of type 'IMonarchLanguage | Thenable<IMonarchLanguage>'.

Check failure on line 64 in src/views/editor/index.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Argument of type '{ defaultToken: string; tokenPostfix: string; keywords: string[]; typeKeywords: string[]; symbols: RegExp; escapes: RegExp; digits: RegExp; octaldigits: RegExp; binarydigits: RegExp; hexdigits: RegExp; tokenizer: { ...; }; }' is not assignable to parameter of type 'IMonarchLanguage | Thenable<IMonarchLanguage>'.

Check failure on line 64 in src/views/editor/index.vue

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Argument of type '{ defaultToken: string; tokenPostfix: string; keywords: string[]; typeKeywords: string[]; symbols: RegExp; escapes: RegExp; digits: RegExp; octaldigits: RegExp; binarydigits: RegExp; hexdigits: RegExp; tokenizer: { ...; }; }' is not assignable to parameter of type 'IMonarchLanguage | Thenable<IMonarchLanguage>'.
// https://github.com/tjx666/adobe-devtools/commit/8055d8415ed3ec5996880b3a4ee2db2413a71c61
let displayEditor: Editor | null = null;
let queryEditor: Editor | null = null;
Expand Down
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default defineConfig({
resolve: {
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
'monaco-editor': 'monaco-editor/esm/vs/editor/editor.api.js',
},
},
});

0 comments on commit cf963f2

Please sign in to comment.