Skip to content

About

Monaco Editor Builds for ESM

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Latest commit

 

History

131 Commits

Folders and files

Repository files navigation

Monaco-Editor-ES

GitHub Tag NPM Weekly Downloads JSR Weekly Downloads JSR Score Release Status Release Status

Installation

npm i @vanillaes/monaco-editor-es

Usage

Step 1 - Import the script and styles

import * as monaco from '../node_modules/@vanillaes/monaco-editor-es/dist/editor.main.js'
import sheet from '../node_modules/@vanillaes/monaco-editor-es/dist/editor.main.css' with { type: "css" }
document.adoptedStyleSheets = [sheet]

Step 2 - Define where the workers are located

const workersDir = new URL('../node_modules/@vanillaes/monaco-editor-es/dist/workers/', import.meta.url)
self.MonacoEnvironment = {
  getWorkerUrl: function (moduleId, label) {
    switch (label) {
      case 'css':
      case 'less':
      case 'scss':
        return `${workersDir}/css.worker.js`
      case 'html':
      case 'handlebars':
      case 'razor':
        return `${workersDir}/html.worker.js`
      case 'javascript':
      case 'typescript':
        return `${workersDir}/ts.worker.js`
      case 'json':
        return `${workersDir}/json.worker.js`
      default:
        return `${workersDir}/editor.worker.js`
    }
  }
}

Step 3 - Create the MonacoEditor

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

For more info on Monaco Editor see the Official Documentation

About

Monaco Editor Builds for ESM

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages