문서

에디터 만들기

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이며 getHTML()과 onChange로 내보내는 HTML을 정리합니다.

onChange는 HTML을, onChangeJSON은 JSON을 전달합니다. 변경은 프레임당 최대 한 번 보고합니다. { history: false }로 불러올 때는 HTML이 같아도 콜백이 호출될 수 있습니다.