Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hatemhosny/monaco-editor-esm-cdn

ESM build of Monaco Editor which can be loaded from CDNs.
https://github.com/hatemhosny/monaco-editor-esm-cdn

Last synced: about 1 month ago
JSON representation

ESM build of Monaco Editor which can be loaded from CDNs.

Awesome Lists containing this project

README

        

# monaco-editor-esm-cdn

This is an ESM build of Monaco Editor which can be loaded from CDN.

## Usage

The editor is bundled as ESM. It can be used like this:

[try in LiveCodes](https://livecodes.io/?x=id/dgzkpnfzzbq)

```html

import { monaco } from "https://cdn.jsdelivr.net/npm/monaco-editor-esm-cdn/monaco.js";

monaco.editor.create(document.getElementById("container"), {
value: `function x() {\n\tconsole.log("Hello world!");\n}`,
language: "javascript",
});

```

Alternatively, options can be specified, by using the `loadMonaco` function:

```js
import { loadMonaco } from "https://cdn.jsdelivr.net/npm/monaco-editor-esm-cdn/load-monaco.js";

const baseUrl = "https://cdn.jsdelivr.net/npm/monaco-editor-esm-cdn/dist/";
const monaco = await loadMonaco({ baseUrl, injectStyles: false });
```

## Build

```bash
npm run build
```

## License

MIT License