代码编辑器

CodeMirrorEditor浏览器模块

真实 CodeMirror 实例展示示例代码;编辑与快捷键只作用于本地预览,不执行 SQL 或运行器任务。

预览

正在加载真实组件…
本地演示,内容不会保存

属性

名称类型默认值说明
containerIdstring必填已挂载的代码编辑器容器 ID。
optionsEditorOptions默认配置语言、主题、初始代码及回调。

用法

libs/codemirror-editor/src/index.ts
TypeScript
// host:宿主组件经 NodeRef 拿到的容器元素。
const editor = window.CodeMirrorEditor.create(host);
editor.setValue("print('Hello, Yggdrasil')");
editor.setLanguage('python');
// 宿主卸载时销毁实例。
editor.destroy();