Read, replace, and undo
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() returns HTML and getJSON() returns a DocumentJSON tree. setHTML replaces the whole document and creates an undo step by default. Use { history: false } when loading another document to clear history. Before the first mount, setHTML sets the starting content.
history moves between undo and redo steps. subscribe listens for content, selection, and history changes and returns a function to unsubscribe. el is the editable element and is null before its first mount.