1
0

index.js 708 B

123456789101112131415161718192021222324
  1. import * as monaco from 'monaco-editor';
  2. self.MonacoEnvironment = {
  3. getWorkerUrl: function (moduleId, label) {
  4. if (label === 'json') {
  5. return './json.worker.bundle.js';
  6. }
  7. if (label === 'css' || label === 'scss' || label === 'less') {
  8. return './css.worker.bundle.js';
  9. }
  10. if (label === 'html' || label === 'handlebars' || label === 'razor') {
  11. return './html.worker.bundle.js';
  12. }
  13. if (label === 'typescript' || label === 'javascript') {
  14. return './ts.worker.bundle.js';
  15. }
  16. return './editor.worker.bundle.js';
  17. }
  18. };
  19. monaco.editor.create(document.getElementById('container'), {
  20. value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
  21. language: 'javascript'
  22. });