createReactEditor creates an editor with React, DOM, and clipboard host APIs
installed. Hooks such as useSlateEditor create the same editor shape.
import { createReactEditor } from 'slate-react'
const editor = createReactEditor()
editor.api.dom.focus()Check if the user is currently composing inside the editor.
Check if the editor is focused.
Check if the editor is in read-only mode.
Check if the user is currently composing inside the editor from the DOM bridge.
Check if the DOM editor is focused.
Check if the DOM editor is in read-only mode.
Blur the editor.
Focus the editor.
Clear the native DOM selection and the Slate selection.
Find a key for a Slate node.
Resolve the current path of a Slate node. Returns null when the node is not
mounted in the current editor value.
Assert the current path of a Slate node.
Check if a DOM node is within the editor.
Check if the target is editable and in the editor.
Check if the target can be selected by the editor.
Check if the target is in the editor.
Assert the native DOM element for a Slate node.
Resolve the native DOM element for a Slate node. Returns null when the Slate
node is not mounted.
Assert a native DOM selection point from a Slate point.
Resolve a native DOM selection point from a Slate point. Returns null when the
Slate point is not currently mappable.
Assert a native DOM range from a Slate range.
Resolve a native DOM range from a Slate range. Returns null when the Slate
range is not currently mappable.
Resolve the bounding rect for a Slate range. Returns null when the range is
not currently mappable to mounted DOM.
Assert a Slate node from a native DOM node.
Resolve a Slate node from a native DOM node. Returns null when the DOM node is
not owned by the editor.
Assert the target range from a DOM event.
Resolve the target range from a DOM event. Returns null when the event target
cannot be mapped into the editor.
editor.api.dom.assertSlatePoint(domPoint: DOMPoint, options: { exactMatch: boolean; searchDirection?: 'backward' | 'forward' }): Point
Assert a Slate point from a DOM point.
editor.api.dom.resolveSlatePoint(domPoint: DOMPoint, options: { exactMatch: boolean; searchDirection?: 'backward' | 'forward' }): Point | null
Resolve a Slate point from a DOM point. Returns null when the DOM point is not
currently mappable.
editor.api.dom.assertSlateRange(domRange: DOMRange | DOMStaticRange | DOMSelection, options: { exactMatch: boolean }): Range
Assert a Slate range from a DOM range or selection.
editor.api.dom.resolveSlateRange(domRange: DOMRange | DOMStaticRange | DOMSelection, options: { exactMatch: boolean }): Range | null
Resolve a Slate range from a DOM range or selection. Returns null when the DOM
range is not currently mappable.
Return the document or shadow root that owns the editor.
Return the window that owns the editor.
Check whether a Slate range can currently be mapped to DOM.
Check whether a DOM event target is inside a non-read-only void element.
Insert data from a DataTransfer into the editor. Returns true when Slate or
an extension inserts content.
Slate runs typed clipboard.insertData extension handlers first. A handler that
returns true stops the default import path. When no handler claims the data,
Slate tries an internal Slate fragment for the editor's configured
clipboardFormatKey, then plain text.
Insert Slate fragment data from a DataTransfer. Returns true when fragment
content was inserted.
Insert plain text data from a DataTransfer. Returns true when text content
was inserted.
Write the current selection to a DataTransfer.
Slate writes plain text, HTML, and an internal Slate fragment payload. The
fragment payload uses application/${clipboardFormatKey} and the HTML fallback
is tagged with the same key, so differently configured editors do not blindly
import each other's internal JSON.