Overview
ThecreateEditor function is the primary entry point for creating a ProseKit editor. It takes an extension and optional configuration, returning an Editor instance that can be mounted to the DOM.
Function Signature
Parameters
Configuration options for the editor
The extension to use when creating the editor. This defines the schema, commands, nodes, and marks available in the editor.
The starting document to use when creating the editor. Can be:
- A ProseMirror node JSON object
- An HTML string
- A DOM element instance
A JSON object representing the starting selection. Only used when
defaultContent is also provided.Return Value
An Editor instance with the following key properties and methods:
Whether the editor is currently mounted to the DOM
The underlying ProseMirror EditorView instance
The editor’s ProseMirror schema
The editor’s current state
Whether the editor is currently focused
All command actions defined by the editor’s extension
All node actions defined by the editor’s extension
All mark actions defined by the editor’s extension
Editor Methods
mount()
null or undefined to unmount.
unmount()
mount(null).
focus()
blur()
use()
setContent()
getDocJSON()
getDocHTML()
exec()
true if successfully executed, otherwise false.
canExec()
true if it can be executed, otherwise false.
Examples
Basic Usage
With Default Content
Using Multiple Extensions
Accessing Editor State
Type Safety
ThecreateEditor function is fully type-safe. The returned Editor instance will have properly typed commands, nodes, and marks based on the extension you provide.
See Also
- union - Combine multiple extensions
- Extension Definition - Creating custom extensions
- Commands - Available command APIs