monaco-react

Monaco Editor for React - use the monaco-editor in any React application wi...

README

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



Monaco Editor for React · use the monaco-editor inany React application without needing to usewebpack (or rollup/parcel/etc) configuration files / plugins



:zap: multi-model editor is already supported; enjoy it :tada:

:tada: version v4 is here - to see what's new in the new version and how to migrate from v3, please read this doc (also, if you need the old versionREADME, it's here)

:tada: the new section Development / Playground has been created - now you can run the playground and play with the internals of the library

:tada: it's already integrated with @monaco-editor/loader



Synopsis


Monaco editor wrapper for easy/one-line integration with any React application without needing to use webpack (or any other module bundler) configuration files / plugins. It can be used with apps generated by create-react-app, create-snowpack-app, vite, Next.js or any other app generators - you don't need to eject or rewire them. You can use it even from CDN without bundlers

Motivation


The monaco-editor is a well-known web technology based code editor that powers VS Code. This library handles the setup process of themonaco-editor and provides a clean API to interact with monaco from any React environment

Demo


Documentation


  [editor instance](#editor-instance)
  [monaco instance](#monaco-instance)
  [useMonaco](#usemonaco)
  [loader/config](#loader-config)
  [onValidate](#onvalidate)
  Notes
    [For electron users](#for-electron-users)
    [For Next.js users](#for-nextjs-users)
  [Editor](#editor)
  [Diff Editor](#diffeditor)

Installation


  1. ``` sh
  2. npm install @monaco-editor/react
  3. ```

or

  1. ``` sh
  2. yarn add @monaco-editor/react
  3. ```

or you can use CDN. Here is an example

NOTE: For TypeScript type definitions, this package uses the monaco-editor package as a peer dependency. So, if you need types and don't already have the monaco-editor package installed, you will need to do so

Introduction


Besides types, the library exports Editorand DiffEditor components, as well as the loader utility and the useMonaco hook:

  1. ``` js
  2. import Editor, { DiffEditor, useMonaco, loader } from "@monaco-editor/react";
  3. ```

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:

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   return (
  7.    <Editor
  8.      height="90vh"
  9.      defaultLanguage="javascript"
  10.      defaultValue="// some comment"
  11.    />
  12.   );
  13. }

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


Extended example

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   function handleEditorChange(value, event) {
  7.     // here is the current value
  8.   }

  9.   function handleEditorDidMount(editor, monaco) {
  10.     console.log("onMount: the editor instance:", editor);
  11.     console.log("onMount: the monaco instance:", monaco)
  12.   }

  13.   function handleEditorWillMount(monaco) {
  14.     console.log("beforeMount: the monaco instance:", monaco);
  15.   }

  16.   function handleEditorValidation(markers) {
  17.     // model markers
  18.     // markers.forEach(marker => console.log('onValidate:', marker.message));
  19.   }

  20.   return (
  21.     <Editor
  22.       height="90vh"
  23.       defaultLanguage="javascript"
  24.       defaultValue="// some comment"
  25.       onChange={handleEditorChange}
  26.       onMount={handleEditorDidMount}
  27.       beforeMount={handleEditorWillMount}
  28.       onValidate={handleEditorValidation}
  29.     />
  30.   );
  31. }

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



Get value


There are two options to get the current value:

1) get the current model value from the editor instance

  1. ``` js
  2. import React, { useRef } from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   const editorRef = useRef(null);

  7.   function handleEditorDidMount(editor, monaco) {
  8.     editorRef.current = editor;
  9.   }
  10.   
  11.   function showValue() {
  12.     alert(editorRef.current.getValue());
  13.   }

  14.   return (
  15.    <>
  16.      <button onClick={showValue}>Show value</button>
  17.      <Editor
  18.        height="90vh"
  19.        defaultLanguage="javascript"
  20.        defaultValue="// some comment"
  21.        onMount={handleEditorDidMount}
  22.      />
  23.    </>
  24.   );
  25. }

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


2) get the current model value via onChange prop

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   function handleEditorChange(value, event) {
  7.     console.log("here is the current model value:", value);
  8.   }

  9.   return (
  10.    <Editor
  11.      height="90vh"
  12.      defaultLanguage="javascript"
  13.      defaultValue="// some comment"
  14.      onChange={handleEditorChange}
  15.    />
  16.   );
  17. }

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


(get the `DiffEditor` values via `editor` instance)

  1. ``` js
  2. import React, { useRef } from "react";
  3. import ReactDOM from "react-dom";

  4. import { DiffEditor } from "@monaco-editor/react";

  5. function App() {
  6.   const diffEditorRef = useRef(null);

  7.   function handleEditorDidMount(editor, monaco) {
  8.     diffEditorRef.current = editor;
  9.   }

  10.   function showOriginalValue() {
  11.     alert(diffEditorRef.current.getOriginalEditor().getValue());
  12.   }

  13.   function showModifiedValue() {
  14.     alert(diffEditorRef.current.getModifiedEditor().getValue());
  15.   }

  16.   return (
  17.     <>
  18.       <button onClick={showOriginalValue}>show original value</button>
  19.       <button onClick={showModifiedValue}>show modified value</button>
  20.       <DiffEditor
  21.         height="90vh"
  22.         language="javascript"
  23.         original="// the original code"
  24.         modified="// the modified code"
  25.         onMount={handleEditorDidMount}
  26.       />
  27.     </>
  28.   );
  29. }

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



editor instance


The editor instance is exposed from the onMount prop as a first parameter, the second is the monaco instance

  1. ``` js
  2. import React, { useRef } from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   const editorRef = useRef(null);

  7.   function handleEditorDidMount(editor, monaco) {
  8.     // here is the editor instance
  9.     // you can store it in `useRef` for further usage
  10.     editorRef.current = editor;
  11.   }

  12.   return (
  13.     <Editor
  14.       height="90vh"
  15.       defaultLanguage="javascript"
  16.       defaultValue="// some comment"
  17.       onMount={handleEditorDidMount}
  18.     />
  19.   );
  20. }

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


monaco instance


There are three options to get the monaco instance:

1) via onMount/beforeMount

  1. ``` js
  2. import React, { useRef } from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   const monacoRef = useRef(null);

  7.   function handleEditorWillMount(monaco) {
  8.     // here is the monaco instance
  9.     // do something before editor is mounted
  10.     monaco.languages.typescript.javascriptDefaults.setEagerModelSync(true);
  11.   }

  12.   function handleEditorDidMount(editor, monaco) {
  13.     // here is another way to get monaco instance
  14.     // you can also store it in `useRef` for further usage
  15.     monacoRef.current = editor;
  16.   }

  17.   return (
  18.     <Editor
  19.       height="90vh"
  20.       defaultLanguage="javascript"
  21.       defaultValue="// some comment"
  22.       beforeMount={handleEditorWillMount}
  23.       onMount={handleEditorDidMount}
  24.     />
  25.   );
  26. }

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


2) via loader utility

  1. ``` js
  2. import { loader } from "@monaco-editor/react";

  3. loader.init().then(monaco => console.log("here is the monaco instance:", monaco));
  4. ```


3) via useMonaco hook

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor, { useMonaco } from "@monaco-editor/react";

  5. function App() {
  6.   const monaco = useMonaco();
  7.   
  8.   useEffect(() => {
  9.     if (monaco) {
  10.       console.log("here is the monaco instance:", monaco);
  11.     }
  12.   }, [monaco]);

  13.   return (
  14.     <Editor
  15.       height="90vh"
  16.       defaultValue="// some comment"
  17.       defaultLanguage="javascript"
  18.     />
  19.   );
  20. }

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


useMonaco


useMonaco is a React hook that returns the instance of the monaco. But there is an important note that should be considered: the initialization process is being handled by the loader utility (the reference of @monaco-editor/loader): that process is being done asynchronously and only once. So, if the first initiator of the initialization isuseMonaco hook, the first returned value will be null, due to its asynchronous installation. Just check the returned value of useMonaco

  1. ``` js
  2. import React, { useEffect } from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor, { useMonaco } from "@monaco-editor/react";

  5. function App() {
  6.   const monaco = useMonaco();
  7.   
  8.   useEffect(() => {
  9.     // do conditional chaining
  10.     monaco?.languages.typescript.javascriptDefaults.setEagerModelSync(true);
  11.     // or make sure that it exists by other ways
  12.     if (monaco) {
  13.       console.log("here is the monaco instance:", monaco);
  14.     }
  15.   }, [monaco]);

  16.   return (
  17.     <Editor
  18.       height="90vh"
  19.       defaultValue="// some comment"
  20.       defaultLanguage="javascript"
  21.     />
  22.   );
  23. }

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


loader-config


The library exports (named) the utility called loader. Basically, it's the reference of @monaco-editor/loader. By default,monaco files are being downloaded from CDN. There is an ability to change this behavior, and other things concerning the AMD loader of monaco. We have a default config file that you can modify by the way shown below:

  1. ``` js
  2. import { loader } from "@monaco-editor/react";

  3. // you can change the source of the monaco files
  4. loader.config({ paths: { vs: "..." } });

  5. // you can configure the locales
  6. loader.config({ "vs/nls": { availableLanguages: { "*": "de" } } });

  7. // or
  8. loader.config({
  9.   paths: {
  10.     vs: "...",
  11.   },
  12.   "vs/nls" : {
  13.     availableLanguages: {
  14.       "*": "de",
  15.     },
  16.   },
  17. });
  18. ```

use monaco-editor as an npm package

Starting from version v4.4.0 it's possible to use monaco-editor as an npm package; import it from node_modules and include monaco sources into your bundle (instead of using CDN). To make it work you can do the following:

  1. ``` js
  2. import * as monaco from "monaco-editor";
  3. import { loader } from "@monaco-editor/react";

  4. loader.config({ monaco });

  5. // ...
  6. ```

NOTE: you should be aware that this may require additional webpack plugins, like monaco-editor-webpack-plugin or it may be impossible to use in apps generated by CRA without ejecting them.

If you use Vite, you need to do this:

  1. ``` js
  2. import { loader } from "@monaco-editor/react";

  3. import * as monaco from "monaco-editor";
  4. import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker"
  5. import jsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker"
  6. import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker"
  7. import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker"
  8. import tsWorker from "monaco-editor/esm/vs/language/typescript/ts.worker?worker"

  9. self.MonacoEnvironment = {
  10.   getWorker(_, label) {
  11.     if (label === "json") {
  12.       return new jsonWorker()
  13.     }
  14.     if (label === "css" || label === "scss" || label === "less") {
  15.       return new cssWorker()
  16.     }
  17.     if (label === "html" || label === "handlebars" || label === "razor") {
  18.       return new htmlWorker()
  19.     }
  20.     if (label === "typescript" || label === "javascript") {
  21.       return new tsWorker()
  22.     }
  23.     return new editorWorker()
  24.   }
  25. }

  26. loader.config({ monaco });

  27. loader.init().then(/* ... */);
  28. ```


NOTE: your passed object will be deeply merged with the default one

Multi-model editor


When you render the Editor component, a default model is being created. It's important to mention that when you change the language or value props, they affect the same model that has been auto-created at the mount of the component. In most cases it's okay, but the developers face problems when they want to implement a multi-model editor to support tabs/files like in IDEs. And previously to handle multiple models they had to do it manually and out of the component. Now, the multi-model API is supported :tada: Let's check how it works. There are three parameters to create a model - value, language and path (monaco.editor.createModel(value, language, monaco.Uri.parse(path))). You can consider last one (path) as an identifier for the model. The Editor component, now, has a path prop. When you specify a path prop, the Editor component checks if it has a model by that path or not. If yes, the existing model will be shown, otherwise, a new one will be created (and stored). Using this technique you can correspond your files with paths, and create a fully multi-model editor. You can open your file, do some changes, choose another file, and when you come back to the first one the previous model will be shown with the whole view state, text selection, undo stack, scroll position, etc. (simple demo)

Here is a simple example: let's imagine we have a JSON like representation of some file structure, something like this:

  1. ``` js
  2. const files = {
  3.   "script.js": {
  4.     name: "script.js",
  5.     language: "javascript",
  6.     value: someJSCodeExample,
  7.   },
  8.   "style.css": {
  9.     name: "style.css",
  10.     language: "css",
  11.     value: someCSSCodeExample,
  12.   },
  13.   "index.html": {
  14.     name: "index.html",
  15.     language: "html",
  16.     value: someHTMLCodeExample,
  17.   },
  18. }
  19. ```

And here is our simple multi-model editor implementation:

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   const [fileName, setFileName] = useState("script.js");

  7.   const file = files[fileName];

  8.   return (
  9.     <>
  10.       <button disabled={fileName === "script.js"} onClick={() => setFileName("script.js")}>script.js</button>
  11.       <button disabled={fileName === "style.css"} onClick={() => setFileName("style.css")}>style.css</button>
  12.       <button disabled={fileName === "index.html"} onClick={() => setFileName("index.html")}>index.html</button>
  13.       <Editor
  14.         height="80vh"
  15.         theme="vs-dark"
  16.         path={file.name}
  17.         defaultLanguage={file.language}
  18.         defaultValue={file.value}
  19.       />
  20.     </>
  21.   );
  22. }

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

The properties:

- defaultValue
- defaultLanguage
- defaultPath
- value
- language
- path
- saveViewState

will give you more flexibility in working with a multi-model editor.

NOTE

defaultValue, defaultLanguage, and defaultPath are being considered only during a new model creation

value, language, and path are being tracked the whole time

saveViewState is an indicator whether to save the models' view states between model changes or not


onValidate


onValidate is an additional property. An event is emitted when the content of the current model is changed and the current model markers are ready. It will be fired with the current model markers

  1. ``` js
  2. import React from "react";
  3. import ReactDOM from "react-dom";

  4. import Editor from "@monaco-editor/react";

  5. function App() {
  6.   function handleEditorValidation(markers) {
  7.     // model markers
  8.     markers.forEach(marker => console.log("onValidate:", marker.message));
  9.   }

  10.   return (
  11.     <Editor
  12.       height="90vh"
  13.       defaultLanguage="javascript"
  14.       defaultValue="// let's write some broken code 😈"
  15.       onValidate={handleEditorValidation}
  16.     />
  17.   );
  18. }

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


It's important to mention that according to monaco-editor, the whole supported languages are divided into two groups:

1) languages that have rich IntelliSense and validation

- TypeScript
- JavaScript
- CSS
- LESS
- SCSS
- JSON
- HTML

2) languages with only basic syntax colorization

- XML
- PHP
- C#
- C++
- Razor
- Markdown
- Diff
- Java
- VB
- CoffeeScript
- Handlebars
- Batch
- Pug
- F#
- Lua
- Powershell
- Python
- Ruby
- SASS
- R
- Objective-C

As you can guess, onValidate prop will work only with the languages from the first group

Notes


For electron users

As a usual React component, this one also works fine with an electron-react environment, without need to have a webpack configuration or other extra things. But there are several cases that developers usually face to and sometimes it can be confusing. Here they are:

1) You see loading screen stuck
Usually, it's because your environment doesn't allow you to load external sources. By default, it loads monaco sources from CDN. You can see the default configuration. But sure you can change that behavior; the library is fully configurable. Read about it here. So, if you want to download it from your local files, you can do it like this:

  1. ``` js
  2. import { loader } from "@monaco-editor/react";

  3. loader.config({ paths: { vs: "../path-to-monaco" } });
  4. ```

2) Based on your electron environment it can be required to have an absolute URL
The utility function taken from here can help you to achieve that. Let's imagine you havemonaco-editor package installed and you want to load monaco from the node_modules rather than from CDN: in that case, you can write something like this:

  1. ``` js
  2. function ensureFirstBackSlash(str) {
  3.     return str.length > 0 && str.charAt(0) !== "/"
  4.         ? "/" + str
  5.         : str;
  6. }

  7. function uriFromPath(_path) {
  8.     const pathName = path.resolve(_path).replace(/\\/g, "/");
  9.     return encodeURI("file://" + ensureFirstBackSlash(pathName));
  10. }

  11. loader.config({
  12.   paths: {
  13.     vs: uriFromPath(
  14.       path.join(__dirname, "../node_modules/monaco-editor/min/vs")
  15.     )
  16.   }
  17. });
  18. ```

There were several issues about this topic that can be helpful too - 1 2 3 4

And if you use electron with monaco and react and have faced an issue different than the above-discribed ones, please let us know to make this section more helpful

For Next.js users

Like other React components, this one also works with Next.js without a hitch. The part of the source that should be pre-parsed is optimized for server-side rendering, so, in usual cases, it will work fine, but if you want to have access, for example, to [monaco instance](https://github.com/suren-atoyan/monaco-react#monaco-instance) you should be aware that it wants to access the document object, and it requires browser environment. Basically you just need to avoid running that part out of browser environment, there are several ways to do that. The one is described here

And if you use monaco with Next.js and have faced an issue different than the above-described one, please let us know to make this section more helpful

Create your own editor


Under the hood this library uses @monaco-editor/loader that provides a utility calledloader. The loader utility is a collection of functions that are being used to setup monaco editor into your browser. loader.init()  handles the whole initialization process and returns the instance of the monaco - loader.init().then(monaco => console.log("here is the monaco instance:", monaco)). The Editor component uses this utility, gains access to monaco instance and creates the editor. Here is the implementation of theEditor component. You can use the same technique to create your own Editor. You can just import the loader utility, access to monaco instance, and create your own editor with your own custom logic. The shortest way to do it:

  1. ``` js
  2. import loader from "@monaco-editor/loader";

  3. loader.init().then(monaco => {
  4.   const wrapper = document.getElementById("root");
  5.   wrapper.style.height = "100vh";
  6.   const properties = {
  7.     value: "function hello() {\n\talert(\"Hello world!\");\n}",
  8.     language:  "javascript",
  9.   }
  10.   
  11.   monaco.editor.create(wrapper,  properties);
  12. });
  13. ```

That's all. You can wrap it into a React component, or Vue, or Angular or leave it as vanilla one or whatever you want; it's written in pure js


Development-Playground


It's always important to have a place, where you can play with the internals of the library. The playground is a minimal React app that directly uses the sources of the library. So, if you are going to open a PR, or want to check something, or just want to try the freshest state of the library, you can run the playground and enjoy it

- clone the repository

  1. ``` sh
  2. git clone https://github.com/suren-atoyan/monaco-react.git
  3. ```

- go to the library folder

  1. ``` sh
  2. cd monaco-react
  3. ```

- install the library's dependencies

  1. ``` sh
  2. npm install # yarn
  3. ```

- go to the playground

  1. ``` sh
  2. cd playground
  3. ```

- install the playground's dependencies

  1. ``` sh
  2. npm install # yarn
  3. ```

- and run the playground

  1. ``` sh
  2. npm run dev # yarn dev
  3. ```

    monaco-react
    ├── playground
    │   ├── src/      # playground sources
    ├── src/          # library sources
    └── ...

If you want to change something in the library, go to monaco-react/src/..., the library will be automatically re-built and the playground will use the latest build

Props


Editor


| Name   |      Type      |  Default |  Description |
|:----------|:-------------|:------|:------|
| defaultValue | string || Default value of the current model |
| defaultLanguage | string || Default language of the current model |
| defaultPath | string || Default path of the current model. Will be passed as the third argument to .createModel method - monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath)) |
| value | string || Value of the current model |
| language | enum: ... | | Language of the current model (all languages that are supported by monaco-editor) |
| path | string || Path of the current model. Will be passed as the third argument to .createModel method - monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath)) |
| theme | enum: "light" \| "vs-dark" | "light" | The theme for the monaco. Available options "vs-dark" \| "light". Define new themes by monaco.editor.defineTheme |
| line | number |  | The line to jump on it |
| loading | React Node | "Loading..." | The loading screen before the editor will be mounted
| options | object | {} | IStandaloneEditorConstructionOptions |
| overrideServices | object | {} | IEditorOverrideServices |
| saveViewState | boolean | true | Indicator whether to save the models' view states between model changes or not |
| keepCurrentModel | boolean | false | Indicator whether to dispose the current model when the Editor is unmounted or not |
| width | union: number \| string | "100%" | Width of the editor wrapper |
| height | union: number \| string | "100%" | Height of the editor wrapper |
| className | string || Class name for the editor container |
| wrapperProps | object | {} | Props applied to the wrapper element |
| beforeMount | func | noop | **Signature: function(monaco: Monaco) => void**
An event is emitted before the editor is mounted. It gets the `monaco` instance as a first argument|| onMount | func | noop | **Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void**
An event is emitted when the editor is mounted. It gets the `editor` instance as a first argument and the `monaco` instance as a second|| onChange | func || **Signature: function(value: string \| undefined, ev: monaco.editor.IModelContentChangedEvent) => void**
An event is emitted when the content of the current model is changed|| onValidate | func | noop | **Signature: function(markers: monaco.editor.IMarker[]) => void**
An event is emitted when the content of the current model is changed and the current model markers are ready|

DiffEditor


| Name   |      Type      |  Default |  Description |
|:----------|:-------------|:------|:------|
| original | string || The original source (left one) value |
| modified | string || The modified source (right one) value |
| language | enum: ... | | Language for the both models - original and modified (all languages that are supported by monaco-editor) |
| originalLanguage | enum: ... | | This prop gives you the opportunity to specify the language of the original source separately, otherwise, it will get the value of the language property |
| modifiedLanguage | enum: ... | | This prop gives you the opportunity to specify the language of the modified source separately, otherwise, it will get the value of language property |
| originalModelPath | string || Path for the "original" model. Will be passed as a third argument to .createModel method - monaco.editor.createModel(..., ..., monaco.Uri.parse(originalModelPath)) |
| modifiedModelPath | string || Path for the "modified" model. Will be passed as a third argument to .createModel method - monaco.editor.createModel(..., ..., monaco.Uri.parse(modifiedModelPath)) |
| keepCurrentOriginalModel | boolean | false | Indicator whether to dispose the current original model when the DiffEditor is unmounted or not |
| keepCurrentModifiedModel | boolean | false | Indicator whether to dispose the current modified model when the DiffEditor is unmounted or not |
| theme | enum: "light" \| "vs-dark" | "light" | The theme for the monaco. Available options "vs-dark" \| "light". Define new themes by monaco.editor.defineTheme |
| line | number |  | The line to jump on it |
| loading | React Node | "Loading..." | The loading screen before the editor will be mounted
| options | object | {} | IDiffEditorConstructionOptions |
| width | union: number \| string | "100%" | Width of the editor wrapper |
| height | union: number \| string | "100%" | Height of the editor wrapper |
| className | string || Class name for the editor container |
| wrapperProps | object | {} | Props applied to the wrapper element |
| beforeMount | func | noop | **Signature: function(monaco: Monaco) => void**
An event is emitted before the editor mounted. It gets the `monaco` instance as a first argument|| onMount | func | noop | **Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void**
An event is emitted when the editor is mounted. It gets the `editor` instance as a first argument and the `monaco` instance as a second|

License