Skip to content

API ​

Props ​

名称类型默认值说明
modelValuestring''编辑器内容。
triggerCharactersstring[][]额外触发补全的字符。
customKeywordsstring[][]自定义 SQL 补全关键字。
databaseOptionsDatabaseOption[][]库、表、字段补全数据。
widthnumber | string0编辑器宽度。数字表示 px;百分比基于父容器宽度计算;为 0 时使用父容器宽度。
heightnumber | string100编辑器高度。数字表示 px;百分比基于父容器高度计算。
monacoEditorOptionIStandaloneEditorConstructionOptions{}Monaco 原生配置。
monacoEditorTheme'vs' | 'vs-dark' | 'hc-black''vs'Monaco 主题。

事件 ​

名称参数说明
update:modelValuestring编辑器内容变化时触发。
editor-readymonaco.editor.IStandaloneCodeEditorMonaco 实例创建完成时触发。
focus—编辑器获得焦点时触发。
blur—编辑器失去焦点时触发。
cursor-changemonaco.editor.ICursorPositionChangedEvent光标位置变化时触发。
selection-changemonaco.editor.ICursorSelectionChangedEvent选区变化时触发。

暴露方法 ​

名称说明
initEditor初始化编辑器实例。
resetEditor清空编辑器内容。
insertText在光标位置插入文本。
getSelectedText获取当前选中文本。
replaceSelectedText替换当前选中文本。
replaceText替换编辑器全部内容。
getEditor获取原生 IStandaloneCodeEditor 实例,未初始化时为 null。

基于 MIT 协议发布。