# 文書の取得、置換、取り消し {#editor-instance}

Source: [文書の取得、置換、取り消し | Yurich React エディターの API リファレンス · Yurich](https://leeyujoo.com/yurich/ja/api/editor-instance/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

```ts
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 の送信と復元](https://leeyujoo.com/yurich/ja/#save-and-restore-html) · [編集と履歴](https://leeyujoo.com/yurich/ja/features/history/)
