Skip to main content

Overview

The useEditor 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

Partial<EditorOptions>
default:"{}"
Configuration options for the editor. Accepts all standard EditorOptions from @tiptap/core.Common options include:
  • content - Initial content for the editor
  • extensions - Array of Tiptap extensions to use
  • editable - Whether the editor is editable
  • autofocus - Auto-focus behavior
  • editorProps - ProseMirror editor props
  • onUpdate - Callback fired when content changes
  • onCreate - Callback fired when editor is created
  • onDestroy - Callback fired when editor is destroyed

Return Value

Returns a shallow ref containing the Editor 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 shallowRef for optimal performance
  • The editor is automatically destroyed when the component unmounts, with DOM content preservation
  • Always check if editor.value exists 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