index.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import * as monaco from '../../../out/monaco-editor/esm/vs/editor/editor.main';
  6. import editorWorker from '../../../out/monaco-editor/esm/vs/editor/editor.worker?worker';
  7. import jsonWorker from '../../../out/monaco-editor/esm/vs/language/json/json.worker?worker';
  8. import cssWorker from '../../../out/monaco-editor/esm/vs/language/css/css.worker?worker';
  9. import htmlWorker from '../../../out/monaco-editor/esm/vs/language/html/html.worker?worker';
  10. import tsWorker from '../../../out/monaco-editor/esm/vs/language/typescript/ts.worker?worker';
  11. self.MonacoEnvironment = {
  12. getWorker(moduleId, label) {
  13. if (label === 'json') {
  14. return new jsonWorker();
  15. }
  16. if (label === 'css' || label === 'scss' || label === 'less') {
  17. return new cssWorker();
  18. }
  19. if (label === 'html' || label === 'handlebars' || label === 'razor') {
  20. return new htmlWorker();
  21. }
  22. if (label === 'typescript' || label === 'javascript') {
  23. return new tsWorker();
  24. }
  25. return new editorWorker();
  26. }
  27. };
  28. window.monacoAPI = monaco;