Overview
TheuseEditor composable is the primary way to create and manage a Tiptap editor instance in Vue 3 applications. It automatically handles the editor lifecycle, creating the editor on component mount and destroying it on unmount.
Signature
Parameters
Configuration options for the editor. Accepts all standard EditorOptions from
@tiptap/core.Common options include:content- Initial content for the editorextensions- Array of Tiptap extensions to useeditable- Whether the editor is editableautofocus- Auto-focus behavioreditorProps- ProseMirror editor propsonUpdate- Callback fired when content changesonCreate- Callback fired when editor is createdonDestroy- Callback fired when editor is destroyed
Return Value
Returns a shallow ref containing theEditor instance. The ref will be undefined until the component is mounted, at which point it will contain the initialized editor.
Type: Ref<Editor | undefined>
Lifecycle
- onMounted: Creates the editor instance with the provided options
- onBeforeUnmount: Clones the editor’s DOM node to preserve content, then destroys the editor instance
Examples
Basic Usage
With Event Handlers
With Editable Control
Accessing Editor Methods
Notes
- The editor ref uses Vue’s
shallowReffor optimal performance - The editor is automatically destroyed when the component unmounts, with DOM content preservation
- Always check if
editor.valueexists before calling methods, as it’s undefined before mount - The returned ref is reactive and can be watched or used in computed properties
See Also
- EditorContent - Component for rendering the editor
- Editor - Core editor API reference
- EditorOptions - Full list of editor configuration options