EditorOptions
初始化配置、默认行为与各子配置的职责。
让文档进入你的工作流
import type { EditorOptions } from "@musecanto/editor-kit";基础字段
| 字段 | 类型 | 默认 / 说明 |
|---|---|---|
el | string 或 HTMLElement | 必填,找不到容器抛错 |
content | string | HTML 或 JSON 字符串,异步内容优先 |
documentId | string | 可选稳定身份 |
editable | boolean | 默认 true |
ui.locale | string | 默认 en,支持 zh 与 BCP 47 归一化 |
ui.messages | DeepPartial<EditorMessages> | 文案覆盖 |
emojibaseUrl | string | Emoji 数据集根地址 |
hostLayoutAutoSize | boolean | 默认 true |
plugins | EditorPlugin[] | 每次创建新实例 |
生命周期
| 字段 | 签名 |
|---|---|
onCreate | (editor: EditorInstance) => void |
onUpdate | (editor: EditorInstance) => void |
onDestroy | () => void |
ui.layout
| 字段 | 默认 / 说明 |
|---|---|
showLeftSidebar | true,目录 |
showRightSidebar | true,右侧栏 |
rightSidebar.hiddenPanels | readonly string[],按 key 隐藏项 |
ui.classNames
可选字符串字段:
| 字段 | 区域 |
|---|---|
container | 最外层 |
toolbarContainer | 工具栏外层 |
toolbar | 工具栏 |
editorContainer | 内容外层 |
mainContainer | 主内容 |
metaContainer | 元数据 |
editorCore | 编辑核心 |
editor | 可编辑区域 |
bubbleMenu | 气泡菜单 |
autoSave
| 字段 | 签名 / 说明 |
|---|---|
onFetch | (signal?: AbortSignal) => Promise<{ content: string }> |
onSaveContent | (json: string) => Promise<void> |
debounceMs | 默认 1000ms |
fetchTimeoutMs | 正文拉取超时,默认无 |
onFetchError | (error: Error, retry: () => void) => void |
onStatusChange | (status: SaveStatus) => void |
onFetchStatusChange | (status: FetchStatus) => void |
SaveStatus 包含 idle、saving、saved、error;FetchStatus 包含 idle、fetching、success、error。类型不表示每次都会触发全部状态。
meta
| 字段 | 签名 / 说明 |
|---|---|
showSection | 默认 true,顶部 UI |
onFetchMeta | () => Promise<EditorMeta> |
onSaveMeta | (meta: EditorMeta) => Promise<void> |
onMetaChange | 元数据变化通知 |
内置可选字段:name、description、contentStr、emojiInfo、coverInfo。可通过 module augmentation 扩展。
features.image / attachment / cover
| 字段 | 用途 |
|---|---|
proxyUrl | 相对媒体地址前缀 |
onUpload(file, onProgress?) | 异步上传;进度 { progress: number } |
cover.presetImages | 封面预设地址列表 |
图片返回 { src, alt, ... },附件返回 { src, name, size, type, ... },封面返回 { url }。见 上传指南。
notifications
| 字段 | 默认 / 说明 |
|---|---|
builtinToaster | true,是否挂载内置容器 |
enabled | true,是否调用 toast 展示 |
toast | 宿主 adapter,提供 success / error |
onNotify | 接收 { type, title, description? } |
features.codeBlock
Partial<CodeBlockShikiOptions>,包括基础代码块选项及 defaultTheme、cdn。cdn: false 禁用额外加载。见 代码高亮。
以安装版本类型为准
升级时同步所有发布包并运行类型检查。不要把文档示例的 props 当成 SDK 配置。