ドキュメント

文書の取得、置換、取り消し

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 は文書全体を置換し、既定では取り消し履歴を 1 件追加します。{ history: false } で履歴を消去します。初回マウント前の呼び出しは初期内容を設定します。

history は取り消しとやり直しを操作します。subscribe は内容、選択、履歴の更新を通知し、購読解除関数を返します。el は初回マウント前は null です。

HTML の送信と復元 · 編集と履歴