# Read, replace, and undo {#editor-instance}

Source: [Read, replace, and undo | Yurich React editor API reference · Yurich](https://leeyujoo.com/yurich/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()` 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.

[Submit or restore HTML](https://leeyujoo.com/yurich/#save-and-restore-html) · [Editing rules and history](https://leeyujoo.com/yurich/features/history/)
