EditableProps
are passed to the <Editable>
component.
The props that get passed to renderPlaceholder
export type RenderPlaceholderProps = {The default placeholder element
export const DefaultPlaceholder: ({ attributes, children, }: RenderPlaceholderProps) => Element = ...The default element renderer.
export const DefaultElement: (props: RenderElementProps) => Element = ...A wrapper around the provider to handle onChange
events, because the editor
is a mutable singleton so it won't ever register as "changed" otherwise.
Get the current editor object from the React context.
@deprecated — Use useSlateStatic instead.
Get the current focused
state of the editor.
Get the current readOnly
state of the editor.
Get the current selected
state of an element.
use redux style selectors to prevent rerendering on every keystroke. Bear in mind rerendering can only prevented if the returned value is a value type or for reference types (e.g. objects and arrays) add a custom equality function.
Example:
const isSelectionActive = useSlateSelector(editor => Boolean(editor.selection));
Get the current slate selection. Only triggers a rerender when the selection actually changes
export const useSlateSelection: () => import("slate").BaseSelection = ...A React and DOM-specific version of the Editor
interface.
Check if the user is currently composing inside the editor.
isComposing(editor: ReactEditor): boolean;Find the path of Slate node.
findPath(editor: ReactEditor, node: import("slate").Node): import("slate").Path;Find the DOM node that implements DocumentOrShadowRoot for the editor.
findDocumentOrShadowRoot(editor: ReactEditor): Document | ShadowRoot;Check if a DOM node is within the editor.
hasDOMNode(editor: ReactEditor, target: Node, options?: {Insert data from a DataTransfer
into the editor.
Insert fragment data from a DataTransfer
into the editor.
Insert text data from a DataTransfer
into the editor.
Sets data from the currently selected fragment on a DataTransfer
.
Find the native DOM element from a Slate node.
toDOMNode(editor: ReactEditor, node: import("slate").Node): HTMLElement;Find a native DOM selection point from a Slate point.
toDOMPoint(editor: ReactEditor, point: import("slate").Point): DOMPoint;Find a native DOM range from a Slate range
.
Notice: the returned range will always be ordinal regardless of the direction of Slate range
due to DOM API limit.
there is no way to create a reverse DOM Range using Range.setStart/setEnd according to https://dom.spec.whatwg.org/#concept-range-bp-set.
Find a Slate node from a native DOM element
.
Get the target range from a DOM event
.
Find a Slate point from a DOM selection's domNode
and domOffset
.
Find a Slate range from a DOM range or selection.
toSlateRange<T_1 extends boolean>(editor: ReactEditor, domRange: Range | StaticRange | Selection, options: {Check if the target is in the editor.
hasTarget(editor: ReactEditor, target: EventTarget | null): target is Node;Check if the target is editable and in the editor.
hasEditableTarget(editor: ReactEditor, target: EventTarget | null): target is Node;Check if the target can be selectable
hasSelectableTarget(editor: ReactEditor, target: EventTarget | null): boolean;Check if the target is inside void and in an non-readonly editor.
isTargetInsideNonReadonlyVoid(editor: ReactEditor, target: EventTarget | null): boolean;Experimental and android specific: Flush all pending diffs and cancel composition at the next possible time.
androidScheduleFlush(editor: import("slate").Editor): void;Experimental and android specific: Get pending diffs
androidPendingDiffs(editor: import("slate").Editor): TextDiff[] | undefined;An auto-incrementing identifier for keys.
A class that keeps track of a key string. We use a full class here because we
want to be able to use them as keys in WeakMap
objects.
withReact
adds React and DOM specific behaviors to the editor.
If you are using TypeScript, you must extend Slate's CustomTypes to use this plugin.
See https://docs.slatejs.org/concepts/11-typescript to learn how.