CodinGame / monaco-editor-wrapper

MIT License
43 stars 4 forks source link

@codingame/monaco-editor-wrapper · monthly downloads npm version PRs welcome

Synopsis

Monaco editor wrapper uses and configures monaco-vscode-api for you

It also includes some tools allowing to add some missing features to monaco-editor:

Installation

npm install @codingame/monaco-editor-wrapper

Usage

Simple usage

You need to call the exposed initialize function, and wait for the returned promise.

You will then be able to interact with the monaco-editor api (by importing monaco-editor) OR the VSCode api (by importing vscode)

Model creation

Instead of using monaco.editor.createModel, it is recommended to use monaco.editor.createModelReference to create models.

It makes it possible for the VSCode service to reference that file by it's reference without breaking (for instance when following file links in source code using LSP).

Optional features

By default, only a minimal set of features is registered (vscode extensions, editor/model services, languages, textmate, dialogs, configuration/keybindings, snippets, accessibility...)

There are some optional features that can be enabled by importing a specific export:

Those feature can be used in the workbench feature is enabled:

Embed language IntelliSense

By default, monaco-editor contains worker to achieve IntelliSense in CSS, SCSS, JavaScript, TypeScript, JSON and HTML.

It's not possible to use them with this lib. However they can be replaced by the corresponding VSCode extension.

To enable them, install and import for following packages:

You also need to import @codingame/monaco-editor-wrapper/features/extensionHostWorker to allows the VSCode extensions to run in a webworker.

Additional apis

User configuration

This library exposed some functions to manage the user global configuration: