# Crie um editor {#use-editor}

Source: [Crie um editor | Referência da API do editor Yurich para React · Yurich](https://leeyujoo.com/yurich/pt-br/api/use-editor/)

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

Package version: `0.1.2`

```ts
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` é obrigatório. `initialValue` define o HTML inicial e é lido uma vez. `historyLimit` tem padrão de 100 etapas. `sanitize` tem padrão `true` e controla a limpeza do HTML de saída.

`onChange` entrega HTML e `onChangeJSON` entrega JSON. Há no máximo uma notificação por quadro. Com `{ history: false }`, até o mesmo HTML pode disparar o callback.
