ドキュメント

エディターを作成する

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 を受け取ります。通知はフレームごとに最大 1 回です。{ history: false } で読み込む場合は同じ HTML でも通知されることがあります。