Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork26
Monaco Editor component for React.
License
NotificationsYou must be signed in to change notification settings
uiwjs/react-monacoeditor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Monaco Editor component for React. demo @uiwjs.github.io/react-monacoeditor/
npm install @uiw/react-monacoeditor --save
importReactfrom'react';importMonacoEditorfrom'@uiw/react-monacoeditor';exportdefaultfunctionDemo(){return(<MonacoEditorlanguage="html"value="<h1>I ♥ react-monacoeditor</h1>"height="300px"options={{theme:'vs-dark',}}/>);}
importReactfrom'react';import{render}from'react-dom';importMonacoEditorfrom'@uiw/react-monacoeditor';constcode=`import React, { PureComponent } from 'react';import MonacoEditor from '@uiw/react-monacoeditor';export default class App extends PureComponent { render() { return ( <MonacoEditor language="html" value="<h1>I ♥ react-codemirror2</h1>" options={{ selectOnLineNumbers: true, roundedSelection: false, cursorStyle: 'line', automaticLayout: false, theme: 'vs-dark', }} /> ); }}`;classAppextendsReact.Component{constructor(props){super(props);this.state={code:'// type your code...',}}editorDidMount(editor,monaco){console.log('editorDidMount',editor,monaco);editor.focus();}onChange(newValue,e){console.log('onChange',newValue,e);}render(){constoptions={selectOnLineNumbers:true,roundedSelection:false,readOnly:false,cursorStyle:'line',automaticLayout:false,theme:'vs-dark',scrollbar:{// Subtle shadows to the left & top. Defaults to true.useShadows:false,// Render vertical arrows. Defaults to false.verticalHasArrows:true,// Render horizontal arrows. Defaults to false.horizontalHasArrows:true,// Render vertical scrollbar.// Accepted values: 'auto', 'visible', 'hidden'.// Defaults to 'auto'vertical:'visible',// Render horizontal scrollbar.// Accepted values: 'auto', 'visible', 'hidden'.// Defaults to 'auto'horizontal:'visible',verticalScrollbarSize:17,horizontalScrollbarSize:17,arrowSize:30,},};return(<MonacoEditorheight="500px"language="javascript"editorDidMount={this.editorDidMount.bind(this)}onChange={this.onChange.bind(this)}value={code}options={options}/>);}}render(<App/>,document.getElementById('root'));
Add theMonaco Editor Webpack Loader Pluginmonaco-editor-webpack-plugin to yourwebpack.config.js:
constMonacoWebpackPlugin=require('monaco-editor-webpack-plugin');module.exports={plugins:[newMonacoWebpackPlugin()]};
If you specifyvalue property, the component behaves in controlled mode.Otherwise, it behaves in uncontrolled mode.
widthwidth of editor. Defaults to100%.heightheight of editor. Defaults to100%.valuevalue of the auto created model in the editor.defaultValuethe initial value of the auto created model in the editor.languagethe initial language of the auto created model in the editor.themethe theme of the editorvs,vs-dark,hc-blackoptionsrefer toMonaco interface IEditorConstructionOptions.editorDidMount(editor, monaco)an event emitted when the editor has been mounted (similar tocomponentDidMountof React).onChange(newValue, event)an event emitted when the content of the current model has changed.autoComplete?: (model: monaco.editor.ITextModel, position: monaco.Position) => languages.CompletionItem[];User provided extension function provider for auto-complete.#47
Refer toMonaco interface IEditor.
- @uiw/react-textarea-code-editor: A simple code editor with syntax highlighting.
- @uiw/react-codemirror: CodeMirror component for React. @codemirror
- @uiw/react-markdown-editor: A markdown editor with preview, implemented with React.js and TypeScript.
- @uiw/react-md-editor: A simple markdown editor with preview, implemented with React.js and TypeScript.
- @uiw/react-markdown-preview: React component preview markdown text in web browser.
- Nginx Editor Nginx language for Monaco Editor.
As always, thanks to our amazing contributors!
Made withgithub-action-contributors.
Licensed under the MIT License.
About
Monaco Editor component for React.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
No packages published
Contributors8
Uh oh!
There was an error while loading.Please reload this page.
