项目作者: vanillaes

项目描述 :
Monaco Editor Builds for ESM
高级语言: JavaScript
项目地址: git://github.com/vanillaes/monaco-editor-es.git
创建时间: 2020-07-01T16:08:43Z
项目社区:https://github.com/vanillaes/monaco-editor-es

开源协议:MIT License

下载


Monaco-Editor-ES


GitHub Tags
NPM Release
Release Status

Discord

Installation

  1. npm i monaco-editor-es

Usage

Step 1 - Import the script

  1. import '../node_modules/monaco-editor-es/editor.main.js'

Step 2 - Define where the workers are located

  1. const workersDir = new URL('../node_modules/monaco-editor-es/workers/', import.meta.url)
  2. self.MonacoEnvironment = {
  3. getWorkerUrl: function (moduleId, label) {
  4. switch(label) {
  5. case 'json':
  6. return `${workersDir}json.worker.js`
  7. case 'css':
  8. return `${workersDir}css.worker.js`
  9. case 'html':
  10. return `${workersDir}html.worker.js`
  11. case 'typescript':
  12. case 'javascript':
  13. return `${workersDir}ts.worker.js`
  14. default:
  15. return `${workersDir}editor.worker.js`
  16. }
  17. }
  18. }

Step 3 - Create the MonacoEditor

  1. monaco.editor.create(document.getElementById('#editor'), {
  2. language: 'javascript,
  3. theme: 'vs-dark'
  4. })

For more info on Monaco Editor see the Official Documentation