Skip to content

AiCodeEditor Monaco Editor

AiCodeEditor is a high-performance code editor component based on Monaco Editor. It retains the VS Code-level editing experience and is perfectly integrated into source code editing scenarios in AI dialogue flows. It supports multi-language syntax highlighting, autocompletion, and multiple themes.

Basic Usage

Use v-model for two-way binding, and control the size via height.

Language Switching & Readonly

Supports dynamic language switching and readonly mode.

API

Props

PropertyDescriptionTypeDefault
v-model / modelValueCode contentstring''
initialValueInitial code (priority over modelValue for first screen)stringundefined
languageProgramming languagestring'javascript'
readonlyWhether it is read-onlybooleanfalse
themeEditor theme'vs' | 'vs-dark' | 'hc-black''vs-dark'
heightEditor heightstring | number300
minimapWhether to show Minimapbooleanfalse
wordWrapAuto word wrap'on' | 'off' | 'wordWrapColumn' | 'bounded''on'
fontSizeFont sizenumber14
tabSizeTab widthnumber2
autofocusAuto focus on mountbooleantrue
themeOverridesTheme override variablesComponentThemeVarsundefined

Events

Event NameDescriptionParameters
update:modelValueTriggered when code content changes(value: string) => void
changeTriggered when code content changes(value: string) => void
mountTriggered when editor is mounted() => void
disposeTriggered when editor is disposed() => void

Methods

Method NameDescriptionParameters
getEditorGet Monaco editor instance() => IStandaloneCodeEditor
focusSet focus to the editor() => void
setValueSet code content manually(value: string) => void
getValueGet current code content() => string

Released under the MIT License.