Skip to content

Function: useEditor() ​

ts
function useEditor(options): Editor;

Create an editor for the lifetime of the component.

  • The editor is created once. content and label are read on creation only; use editor.setContent() to replace the document later.
  • editable is applied whenever it changes.
  • onChange, onFocus and onBlur always call the latest callback.
  • The editor is destroyed when the component unmounts.

Parameters ​

ParameterType
optionsUseEditorOptions

Returns ​

Editor

Example ​

tsx
const editor = useEditor({ extensions, content: initial, label: 'Article text' })
return <EditorContent editor={editor} />