代码编辑器
CodeMirrorEditor浏览器模块真实 CodeMirror 实例展示示例代码;编辑与快捷键只作用于本地预览,不执行 SQL 或运行器任务。
正在加载真实组件…
本地演示,内容不会保存
属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
containerId | string | 必填 | 已挂载的代码编辑器容器 ID。 |
options | EditorOptions | 默认配置 | 语言、主题、初始代码及回调。 |
用法
libs/codemirror-editor/src/index.ts// host:宿主组件经 NodeRef 拿到的容器元素。
const editor = window.CodeMirrorEditor.create(host);
editor.setValue("print('Hello, Yggdrasil')");
editor.setLanguage('python');
// 宿主卸载时销毁实例。
editor.destroy();