文档

创建编辑器

declare function useEditor(options: EditorOptions): EditorInstance;

type EditorOptions = {
  extensions: Extension[];
  initialValue?: string;
  onChange?: (html: string) => void;
  onChangeJSON?: (json: DocumentJSON) => void;
  sanitize?: boolean;
  historyLimit?: number;
};

extensions 必填。initialValue 是只读取一次的初始 HTML。historyLimit 默认为 100。sanitize 默认为 true,控制输出 HTML 的清理。

onChange 提供 HTML,onChangeJSON 提供 JSON。每帧最多通知一次。用 { history: false } 加载时,相同的 HTML 也可能触发回调。