avatar
UI
Components
Changelog
LobeHub UI
Antd Components
Lucide Icons
CSSinJS
Ctrl
K
Chat
ChatInputArea
ChatItem
EditableMessage
Data Display
Card
ChatMarkdown
CollapseGroup
Descriptions
Highlighter
JsonViewer
LogViewer
ProCard
RichTextEditor
Status
Table
Tree
Data Entry
CodeEditor
Form
Mentions
MonacoEditor
SelectCard
SliderInput
Feedback
Alert
DragPanel
Drawer
Modal
Notification
General
Breadcrumb
Typography
WaveformIcon
Layout
Divider
Page
Navigation
ButtonGroup
Dropdown
Theme
ConfigProvider
Logo
TTS
useSpeechSynthes
Utils
FormHelper

MonacoEditor

based on @alilc/lowcode-plugin-base-monaco-editor and react-monaco-editor.

import { MonacoEditor } from '@yuntijs/ui';
NPM
UNPKG
BundlePhobia
PackagePhobia
Anvaka Graph
Source
Edit
Previous
Mentions
Next
SelectCard

Resources

Lobe UI-AIGC Components
Lobe Icon-AI / LLM Icon Collection
Lobe Charts-Modern Charts
Lobe TTS-TTS / STT Library

Community

Report Bug
Request Feature

Help

GitHub
Changelog

More Products

🤯 Lobe Chat-AI / LLM Chat Framework
🧸 Lobe Vidol-Virtual Idols for EveryOne
🅰️ Lobe Theme-Stable Diffusion Extension
🌐 Lobe i18n-AI i18next CLI
Copyright © 2022-2026
Made with ☁️ by YuntiJS
LobeHub

Usage

based on @alilc/lowcode-plugin-base-monaco-editor and react-monaco-editor.

Simple usage

JSX
import { MonacoEditor } from '@yuntijs/ui';

export default () => {
  return (
    <MonacoEditor
      defaultValue={`const myEditor = monaco.editor.create(document.getElementById("container"), {
  language: "javascript",
  automaticLayout: true,
});`}
      height={200}
      language="javascript"
      onChange={next => {
        // eslint-disable-next-line no-console
        console.log(next);
      }}
      onFullScreenChange={isFullScreen => {
        console.log(isFullScreen);
      }}
      supportFullScreen={true}
      width={740}
    />
  );
};

Markdown

Specify monaco version to 0.19.3

Diff Editor

Multi Model Saving Scrolling States

Tabs

Playground

BaseMonacoEditor

DiffMonacoEditor

APIs

  • width width of editor. Defaults to 100%.

  • height height of editor. Defaults to 100%.

  • value value of the auto created model in the editor.

  • original value of the original model in the diff editor.

  • defaultValue the initial value of the auto created model in the editor.

  • language the initial language of the auto created model in the editor.

  • theme the theme of the editor. The default is vs or vs-dark, which will automatically change with the antd theme according to the antd theme, also supports vs-dark, hc-light, hc-black. If you specify this field, this theme will be fixed.

  • readOnly Should the editor be read only. See also domReadOnly. Defaults to false.

  • lineNumbers Control the rendering of line numbers. If it is a function, it will be invoked when rendering a line number and the return value will be rendered. Otherwise, if it is a truthy, line numbers will be rendered normally (equivalent of using an identity function). Otherwise, line numbers will not be rendered. Defaults to on.

  • wordWrap

  • options refer to Monaco interface IStandaloneEditorConstructionOptions, diff editor see IStandaloneDiffEditorConstructionOptions

  • path path of the current model, useful when creating a multi-model editor

  • requireConfig config passing to require, can be used to upgrade monaco-editor.

  • overrideServices refer to Monaco Interface IEditorOverrideServices. It depends on Monaco's internal implementations and may change over time, check github issue for more details.

  • onChange(input, event) an event emitted when the content of the current model has changed.

  • onFullScreenChange(isFullScreen) an event emitted when the full-screen of the current model has changed.

  • editorWillMount(monaco) an event emitted before the editor mounted (similar to componentWillMount of React).

  • editorDidMount(editor, monaco) an event emitted when the editor has been mounted (similar to componentDidMount of React).

  • editorWillUnmount(editor, monaco) an event emitted before the editor unmount (similar to componentWillUnmount of React).

All props

basic props

NameDescriptionTypeDefault
readOnlyShould the editor be read only. See also domReadOnly. Defaults to false.boolean--
lineNumbersControl the rendering of line numbers. Defaults to on.on|off|relative|interval|(lineNumber:number)=>string--
wordWrapControl the wrapping of the editor. Defaults to off."off"|"on"|"wordWrapColumn"|"bounded"--
contextmenuEnable custom contextmenu. Defaults to true.boolean--
minimapEnabledEnable the rendering of the minimap. Defaults to false.boolean--
versionControl the version of monaco-editor be loaded. Defaults to 0.45.0string--
onChangeAn event emitted when the content of the current model has changed.(input:string,event:any)=>void--
variantVariants of Editor, Defaults to outlined."outlined"|"borderless"|"filled"|"underlined"--
options[Monaco editor options](https://microsoft.github.io/monaco-editor/){}--
editorDidMountcallback after monaco's loaded and after editor's loaded(monaco:typeof import("/node_modules/monaco-editor/esm/vs/editor/editor.api"),editor:import("/src/MonacoEditor/base/helper").IEditorInstance)=>void--
editorWillMountcallback after monaco's loaded and before editor's loaded(monaco:typeof import("/node_modules/monaco-editor/esm/vs/editor/editor.api"))=>void--
pathpath of the current model, useful when creating a multi-model editorstring--
saveViewStatewhether to save the models' view states between model changes or notboolean--
languagelanguage of the editor @see https://microsoft.github.io/monaco-editor/ for available languagesstring--
themetheme of the editorany--
requireConfig[config passing to require](https://github.com/suren-atoyan/monaco-react#loader-config), can be used to upgrade monaco-editor{}--
valuevalue, controlledstring--
defaultValuedefaultValue for creating model, uncontrolledstring--
classNameclassName of wrapperstring--
widthwidth of wrappernumber|string--
heightheight of wrappernumber|string--
enableOutlinewhether to enable outline of wrapper or notboolean--
stylestyle of wrapper{}--
enhancers--EditorEnhancer[]--
placeholder--string--
typeOnly for BaseMonacoEditor."single"|"diff"--
supportFullScreenIs show fullscreen buttonboolean--

more props

NameDescriptionTypeDefault
onChange--(input:string,event:import("/node_modules/monaco-editor/esm/vs/editor/editor.api").editor.IModelContentChangedEvent)=>void--
supportFullScreen--boolean--
onFullScreenChange--(isFullScreen:boolean)=>void--
original--string--
options[Monaco editor options](https://microsoft.github.io/monaco-editor/){}--
editorDidMountcallback after monaco's loaded and after editor's loaded(monaco:typeof import("/node_modules/monaco-editor/esm/vs/editor/editor.api"),editor:import("/src/MonacoEditor/base/helper").IEditorInstance)=>void--
editorWillMountcallback after monaco's loaded and before editor's loaded(monaco:typeof import("/node_modules/monaco-editor/esm/vs/editor/editor.api"))=>void--
pathpath of the current model, useful when creating a multi-model editorstring--
saveViewStatewhether to save the models' view states between model changes or notboolean--
languagelanguage of the editor @see https://microsoft.github.io/monaco-editor/ for available languagesstring--
themetheme of the editorany--
requireConfig[config passing to require](https://github.com/suren-atoyan/monaco-react#loader-config), can be used to upgrade monaco-editor{}--
valuevalue, controlledstring--
defaultValuedefaultValue for creating model, uncontrolledstring--
classNameclassName of wrapperstring--
widthwidth of wrappernumber|string--
heightheight of wrappernumber|string--
enableOutlinewhether to enable outline of wrapper or notboolean--
stylestyle of wrapper{}--
enhancers--EditorEnhancer[]--
placeholder--string--
inlineViewRender the differences in one editor. Defaults to off, render the differences in two side-by-side editors"off"|"on"|"auto"--
test1
test2
test3