6.0.4 • Published 1 day ago

@codingame/monaco-editor-react v6.0.4

Weekly downloads
-
License
-
Repository
github
Last release
1 day ago

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

Synopsis

This library uses https://github.com/CodinGame/monaco-editor-wrapper

Please refer to this documentation

Installation

npm install @codingame/monaco-editor-react 

Usage

Simple usage

Here is an example of a simple integration of monaco editor with a React project. You just need to import and render the Editor component:

import React from "react";
import ReactDOM from "react-dom";

import Editor from "@codingame/monaco-editor-react";

function App() {
  const [value, setValue] = useState('// some comment');
  return (
   <Editor
     height="auto"
     programmingLanguage="javascript"
     value={value}
     onChange={setValue}
   />
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Models management

When you render the MonacoEditor component, there is 2 modes for the model management:

  • if the model already exists, it will be reused and not disposed at the end
  • if the model doesn't exist, it will be created and disposed at the end

This way, the editor is plug-and-play for simple use cases but it allows you to create your models before, use them in the editor and dispose them when you don't need them anymore

Differences with monaco-react

  • This library outputs some dynamic import and rely on webpack to handle them
  • The model management is different, either you manage your models by hands or let the editor create and destroy them
  • no onValidate: can be done directly with monaco.editor.onDidChangeMarkers
  • no theme prop: the theme can be changed using monaco.editor.setTheme
  • To get the editor instance, use ref instead of handleEditorDidMount
  • There is no useMonaco, you can just use the exported monaco: import { monaco }, Editor from "@codingame/monaco-editor-react";
6.0.4

1 day ago

6.0.3

16 days ago

6.0.2

24 days ago

6.0.1

27 days ago

6.0.0

2 months ago

5.2.2

3 months ago

5.1.3

3 months ago

5.2.1

3 months ago

5.1.2

3 months ago

5.2.0

3 months ago

5.1.1

3 months ago

5.1.0

3 months ago

5.0.0

3 months ago

5.0.0-next.1

10 months ago

5.0.0-next.0

11 months ago

4.0.9

1 year ago

4.0.8

1 year ago

4.0.7

1 year ago

4.0.5

1 year ago

4.0.6

1 year ago

4.0.4

1 year ago

4.0.3

1 year ago

4.0.2

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.0.2

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.2.0

2 years ago

1.3.3

2 years ago

1.5.0

2 years ago

1.3.2

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago