文档

读取、替换和撤销

interface EditorInstance {
  getHTML(): string;
  getJSON(): DocumentJSON;
  setHTML(html: string, options?: { history?: boolean }): void;
  readonly history: {
    undo(): void;
    redo(): void;
    canUndo(): boolean;
    canRedo(): boolean;
  };
  subscribe(listener: () => void): () => void;
  readonly el: HTMLElement | null;
}

getHTML() 读取 HTML,getJSON() 返回文档树。setHTML 替换整个文档,默认增加一步撤销。{ history: false } 清空历史。首次挂载前调用将设置初始内容。

history 管理撤销和重做。subscribe 监听内容、选区和历史记录变化,并返回取消订阅函数。首次挂载前 el 为 null。

提交和恢复 HTML · 编辑和历史记录