Documentation

Create an editor

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 is required. initialValue is the starting HTML and is read once. The default historyLimit is 100 undo steps. sanitize defaults to true and controls HTML from getHTML() and onChange.

onChange returns HTML and onChangeJSON returns structured data. Changes are reported at most once per animation frame. Replacing the document with { history: false } can notify even if the HTML is unchanged.