Browse Source

chore: monaco editor worker loading

pull/7230/head
Pranav C 1 year ago
parent
commit
c352564a43
  1. 18
      packages/nc-gui/plugins/monaco.ts

18
packages/nc-gui/plugins/monaco.ts

@ -0,0 +1,18 @@
import 'monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution'
import 'monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution'
import EditorWorkerUrl from 'monaco-editor/esm/vs/editor/editor.worker?worker&url'
import TsWorkerUrl from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker&url'
import JsonWorkerUrl from 'monaco-editor/esm/vs/language/json/json.worker?worker&url'
import { initWorker } from '#imports'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
window.MonacoEnvironment = {
getWorker(_: string, label: string) {
if (label === 'typescript' || label === 'javascript') return initWorker(TsWorkerUrl)
if (label === 'json') return initWorker(JsonWorkerUrl)
return initWorker(EditorWorkerUrl)
},
}
Loading…
Cancel
Save