monaco-editor/samples/electron-esm-webpack/index.js

25 lines
708 B
JavaScript
Raw Normal View History

2018-03-14 23:37:11 +08:00
import * as monaco from 'monaco-editor';
self.MonacoEnvironment = {
getWorkerUrl: function (moduleId, label) {
if (label === 'json') {
return './json.worker.bundle.js';
}
if (label === 'css' || label === 'scss' || label === 'less') {
2018-03-14 23:37:11 +08:00
return './css.worker.bundle.js';
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
2018-03-14 23:37:11 +08:00
return './html.worker.bundle.js';
}
if (label === 'typescript' || label === 'javascript') {
return './ts.worker.bundle.js';
}
return './editor.worker.bundle.js';
}
2020-09-02 23:35:10 +08:00
};
2018-03-14 23:37:11 +08:00
monaco.editor.create(document.getElementById('container'), {
2020-09-02 23:35:10 +08:00
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
2018-03-14 23:37:11 +08:00
language: 'javascript'
});