slate
- Version 0.112.0
- Published
- 2.12 MB
- 3 dependencies
- MIT license
Install
npm i slate
yarn add slate
pnpm add slate
Overview
A completely customizable framework for building rich text editors.
Index
Variables
- above
- addMark
- after
- apply
- before
- collapse
- deleteBackward
- deleteForward
- deleteFragment
- deleteText
- deselect
- edges
- Editor
- Element
- elementReadOnly
- end
- first
- fragment
- getDirtyPaths
- getFragment
- getVoid
- hasBlocks
- hasInlines
- hasPath
- hasTexts
- insertBreak
- insertFragment
- insertNode
- insertNodes
- insertSoftBreak
- insertText
- isBlock
- isEdge
- isEditor
- isEmpty
- isEnd
- isNormalizing
- isStart
- last
- leaf
- liftNodes
- Location
- marks
- mergeNodes
- move
- moveNodes
- next
- node
- Node
- normalize
- normalizeNode
- Operation
- parent
- path
- Path
- pathRef
- PathRef
- pathRefs
- point
- Point
- pointRef
- PointRef
- pointRefs
- previous
- range
- Range
- rangeRef
- RangeRef
- rangeRefs
- removeMark
- removeNodes
- Scrubber
- select
- setNodes
- setNormalizing
- setPoint
- setSelection
- shouldMergeNodesRemovePrevNode
- shouldNormalize
- Span
- splitNodes
- start
- string
- Text
- Transforms
- unhangRange
- unsetNodes
- unwrapNodes
- withoutNormalizing
- wrapNodes
Functions
Interfaces
BaseEditor
- above
- addMark
- after
- apply
- before
- children
- collapse
- delete
- deleteBackward
- deleteForward
- deleteFragment
- deselect
- edges
- elementReadOnly
- end
- first
- fragment
- getDirtyPaths
- getFragment
- getMarks
- hasBlocks
- hasInlines
- hasPath
- hasTexts
- insertBreak
- insertFragment
- insertNode
- insertNodes
- insertSoftBreak
- insertText
- isBlock
- isEdge
- isElementReadOnly
- isEmpty
- isEnd
- isInline
- isNormalizing
- isSelectable
- isStart
- isVoid
- last
- leaf
- levels
- liftNodes
- markableVoid
- marks
- mergeNodes
- move
- moveNodes
- next
- node
- nodes
- normalize
- normalizeNode
- onChange
- operations
- parent
- path
- pathRef
- pathRefs
- point
- pointRef
- pointRefs
- positions
- previous
- range
- rangeRef
- rangeRefs
- removeMark
- removeNodes
- select
- selection
- setNodes
- setNormalizing
- setPoint
- setSelection
- shouldMergeNodesRemovePrevNode
- shouldNormalize
- splitNodes
- start
- string
- unhangRange
- unsetNodes
- unwrapNodes
- void
- withoutNormalizing
- wrapNodes
EditorInterface
- above
- addMark
- after
- before
- deleteBackward
- deleteForward
- deleteFragment
- edges
- elementReadOnly
- end
- first
- fragment
- hasBlocks
- hasInlines
- hasPath
- hasTexts
- insertBreak
- insertFragment
- insertNode
- insertSoftBreak
- insertText
- isBlock
- isEdge
- isEditor
- isElementReadOnly
- isEmpty
- isEnd
- isInline
- isNormalizing
- isSelectable
- isStart
- isVoid
- last
- leaf
- levels
- marks
- next
- node
- nodes
- normalize
- parent
- path
- pathRef
- pathRefs
- point
- pointRef
- pointRefs
- positions
- previous
- range
- rangeRef
- rangeRefs
- removeMark
- setNormalizing
- shouldMergeNodesRemovePrevNode
- start
- string
- unhangRange
- void
- withoutNormalizing
Type Aliases
- Ancestor
- BaseInsertNodeOperation
- BaseInsertTextOperation
- BaseMergeNodeOperation
- BaseMoveNodeOperation
- BaseNode
- BaseOperation
- BaseRemoveNodeOperation
- BaseRemoveTextOperation
- BaseSelection
- BaseSetNodeOperation
- BaseSetSelectionOperation
- BaseSplitNodeOperation
- DecoratedRange
- Descendant
- Editor
- EditorMarks
- Element
- ElementEntry
- ExtendedType
- InsertNodeOperation
- InsertTextOperation
- LeafEdge
- Location
- MaximizeMode
- MergeNodeOperation
- MoveNodeOperation
- MoveUnit
- Node
- NodeEntry
- NodeMatch
- NodeOperation
- NodeProps
- Operation
- Path
- Point
- PointEntry
- PropsCompare
- PropsMerge
- Range
- RangeDirection
- RangeMode
- RemoveNodeOperation
- RemoveTextOperation
- Scrubber
- Selection
- SelectionEdge
- SelectionMode
- SelectionOperation
- SetNodeOperation
- SetSelectionOperation
- Span
- SplitNodeOperation
- Text
- TextDirection
- TextOperation
- TextUnit
- TextUnitAdjustment
Variables
variable above
const above: <T extends Ancestor>( editor: BaseEditor, options?: EditorAboveOptions<T>) => NodeEntry<T>;
variable addMark
const addMark: (editor: BaseEditor, key: string, value: any) => void;
variable after
const after: ( editor: BaseEditor, at: Location, options?: EditorAfterOptions) => BasePoint;
variable apply
const apply: WithEditorFirstArg<(operation: BaseOperation) => void>;
variable before
const before: ( editor: BaseEditor, at: Location, options?: EditorBeforeOptions) => BasePoint;
variable collapse
const collapse: (editor: BaseEditor, options?: SelectionCollapseOptions) => void;
variable deleteBackward
const deleteBackward: WithEditorFirstArg<(unit: TextUnit) => void>;
variable deleteForward
const deleteForward: WithEditorFirstArg<(unit: TextUnit) => void>;
variable deleteFragment
const deleteFragment: ( editor: BaseEditor, options?: EditorFragmentDeletionOptions) => void;
variable deleteText
const deleteText: (editor: BaseEditor, options?: TextDeleteOptions) => void;
variable deselect
const deselect: (editor: BaseEditor) => void;
variable edges
const edges: (editor: BaseEditor, at: Location) => [BasePoint, BasePoint];
variable Editor
const Editor: EditorInterface;
variable Element
const Element: ElementInterface;
variable elementReadOnly
const elementReadOnly: ( editor: BaseEditor, options?: EditorElementReadOnlyOptions) => NodeEntry<BaseElement>;
variable end
const end: (editor: BaseEditor, at: Location) => BasePoint;
variable first
const first: (editor: BaseEditor, at: Location) => NodeEntry<Node>;
variable fragment
const fragment: (editor: BaseEditor, at: Location) => Descendant[];
variable getDirtyPaths
const getDirtyPaths: WithEditorFirstArg<(operation: BaseOperation) => Path[]>;
Get the "dirty" paths generated from an operation.
variable getFragment
const getFragment: WithEditorFirstArg<() => Descendant[]>;
variable getVoid
const getVoid: ( editor: BaseEditor, options?: EditorVoidOptions) => NodeEntry<BaseElement>;
variable hasBlocks
const hasBlocks: (editor: BaseEditor, element: BaseElement) => boolean;
variable hasInlines
const hasInlines: (editor: BaseEditor, element: BaseElement) => boolean;
variable hasPath
const hasPath: (editor: BaseEditor, path: Path) => boolean;
variable hasTexts
const hasTexts: (editor: BaseEditor, element: BaseElement) => boolean;
variable insertBreak
const insertBreak: (editor: BaseEditor) => void;
variable insertFragment
const insertFragment: ( editor: BaseEditor, fragment: Node[], options?: TextInsertFragmentOptions) => void;
variable insertNode
const insertNode: <T extends Node>( editor: BaseEditor, node: Node, options?: NodeInsertNodesOptions<T>) => void;
variable insertNodes
const insertNodes: <T extends Node>( editor: BaseEditor, nodes: Node | Node[], options?: NodeInsertNodesOptions<T>) => void;
variable insertSoftBreak
const insertSoftBreak: (editor: BaseEditor) => void;
variable insertText
const insertText: ( editor: BaseEditor, text: string, options?: TextInsertTextOptions) => void;
variable isBlock
const isBlock: (editor: BaseEditor, value: BaseElement) => boolean;
variable isEdge
const isEdge: (editor: BaseEditor, point: BasePoint, at: Location) => boolean;
variable isEditor
const isEditor: (value: any) => value is BaseEditor;
variable isEmpty
const isEmpty: (editor: BaseEditor, element: BaseElement) => boolean;
variable isEnd
const isEnd: (editor: BaseEditor, point: BasePoint, at: Location) => boolean;
variable isNormalizing
const isNormalizing: (editor: BaseEditor) => boolean;
variable isStart
const isStart: (editor: BaseEditor, point: BasePoint, at: Location) => boolean;
variable last
const last: (editor: BaseEditor, at: Location) => NodeEntry<Node>;
variable leaf
const leaf: ( editor: BaseEditor, at: Location, options?: EditorLeafOptions) => NodeEntry<BaseText>;
variable liftNodes
const liftNodes: <T extends Node>( editor: BaseEditor, options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; voids?: boolean; }) => void;
variable Location
const Location: LocationInterface;
variable marks
const marks: (editor: BaseEditor) => Omit<BaseText, 'text'>;
variable mergeNodes
const mergeNodes: <T extends Node>( editor: BaseEditor, options?: { at?: Location; match?: NodeMatch<T>; mode?: RangeMode; hanging?: boolean; voids?: boolean; }) => void;
variable move
const move: (editor: BaseEditor, options?: SelectionMoveOptions) => void;
variable moveNodes
const moveNodes: <T extends Node>( editor: BaseEditor, options: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; to: Path; voids?: boolean; }) => void;
variable next
const next: <T extends Descendant>( editor: BaseEditor, options?: EditorNextOptions<T>) => NodeEntry<T>;
variable node
const node: ( editor: BaseEditor, at: Location, options?: EditorNodeOptions) => NodeEntry<Node>;
variable Node
const Node: NodeInterface;
variable normalize
const normalize: (editor: BaseEditor, options?: EditorNormalizeOptions) => void;
variable normalizeNode
const normalizeNode: WithEditorFirstArg< (entry: NodeEntry<Node>, options?: { operation?: BaseOperation }) => void>;
variable Operation
const Operation: OperationInterface;
variable parent
const parent: ( editor: BaseEditor, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
variable path
const path: (editor: BaseEditor, at: Location, options?: EditorPathOptions) => Path;
variable Path
const Path: PathInterface;
variable pathRef
const pathRef: ( editor: BaseEditor, path: Path, options?: EditorPathRefOptions) => PathRef;
variable PathRef
const PathRef: PathRefInterface;
variable pathRefs
const pathRefs: (editor: BaseEditor) => Set<PathRef>;
variable point
const point: ( editor: BaseEditor, at: Location, options?: EditorPointOptions) => BasePoint;
variable Point
const Point: PointInterface;
variable pointRef
const pointRef: ( editor: BaseEditor, point: BasePoint, options?: EditorPointRefOptions) => PointRef;
variable PointRef
const PointRef: PointRefInterface;
variable pointRefs
const pointRefs: (editor: BaseEditor) => Set<PointRef>;
variable previous
const previous: <T extends Node>( editor: BaseEditor, options?: EditorPreviousOptions<T>) => NodeEntry<T>;
variable range
const range: (editor: BaseEditor, at: Location, to?: Location) => BaseRange;
variable Range
const Range: RangeInterface;
variable rangeRef
const rangeRef: ( editor: BaseEditor, range: BaseRange, options?: EditorRangeRefOptions) => RangeRef;
variable RangeRef
const RangeRef: RangeRefInterface;
variable rangeRefs
const rangeRefs: (editor: BaseEditor) => Set<RangeRef>;
variable removeMark
const removeMark: (editor: BaseEditor, key: string) => void;
variable removeNodes
const removeNodes: <T extends Node>( editor: BaseEditor, options?: { at?: Location; match?: NodeMatch<T>; mode?: RangeMode; hanging?: boolean; voids?: boolean; }) => void;
variable Scrubber
const Scrubber: ScrubberInterface;
This interface implements a stringify() function, which is used by Slate internally when generating exceptions containing end user data. Developers using Slate may call Scrubber.setScrubber() to alter the behavior of this stringify() function.
For example, to prevent the cleartext logging of 'text' fields within Nodes:
import { Scrubber } from 'slate'; Scrubber.setScrubber((key, val) => { if (key === 'text') return '...scrubbed...' return val });
variable select
const select: (editor: BaseEditor, target: Location) => void;
variable setNodes
const setNodes: <T extends Node>( editor: BaseEditor, props: Partial<T>, options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; hanging?: boolean; split?: boolean; voids?: boolean; compare?: PropsCompare; merge?: PropsMerge; }) => void;
variable setNormalizing
const setNormalizing: (editor: BaseEditor, isNormalizing: boolean) => void;
variable setPoint
const setPoint: ( editor: BaseEditor, props: Partial<BasePoint>, options?: SelectionSetPointOptions) => void;
variable setSelection
const setSelection: (editor: BaseEditor, props: Partial<BaseRange>) => void;
variable shouldMergeNodesRemovePrevNode
const shouldMergeNodesRemovePrevNode: ( editor: BaseEditor, prevNodeEntry: NodeEntry<Node>, curNodeEntry: NodeEntry<Node>) => boolean;
variable shouldNormalize
const shouldNormalize: WithEditorFirstArg< ({ iteration, dirtyPaths, operation, }: { iteration: number; initialDirtyPathsLength: number; dirtyPaths: Path[]; operation?: BaseOperation; }) => boolean>;
variable Span
const Span: SpanInterface;
variable splitNodes
const splitNodes: <T extends Node>( editor: BaseEditor, options?: { at?: Location; match?: NodeMatch<T>; mode?: RangeMode; always?: boolean; height?: number; voids?: boolean; }) => void;
variable start
const start: (editor: BaseEditor, at: Location) => BasePoint;
variable string
const string: ( editor: BaseEditor, at: Location, options?: EditorStringOptions) => string;
variable Text
const Text: TextInterface;
variable Transforms
const Transforms: GeneralTransforms & NodeTransforms & SelectionTransforms & TextTransforms;
variable unhangRange
const unhangRange: ( editor: BaseEditor, range: BaseRange, options?: EditorUnhangRangeOptions) => BaseRange;
variable unsetNodes
const unsetNodes: <T extends Node>( editor: BaseEditor, props: string | string[], options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; hanging?: boolean; split?: boolean; voids?: boolean; }) => void;
variable unwrapNodes
const unwrapNodes: <T extends Node>( editor: BaseEditor, options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; split?: boolean; voids?: boolean; }) => void;
variable withoutNormalizing
const withoutNormalizing: (editor: BaseEditor, fn: () => void) => void;
variable wrapNodes
const wrapNodes: <T extends Node>( editor: BaseEditor, element: BaseElement, options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; split?: boolean; voids?: boolean; }) => void;
Functions
function createEditor
createEditor: () => Editor;
Create a new Slate
Editor
object.
function levels
levels: <T extends Node>( editor: Editor, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
function nodes
nodes: <T extends Node>( editor: Editor, options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
function positions
positions: ( editor: Editor, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
Interfaces
interface BaseEditor
interface BaseEditor {}
The
Editor
interface stores all the state of a Slate editor. It is extended by plugins that wish to add their own helpers and implement new behaviors.
property above
above: <T extends Ancestor>( options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
property addMark
addMark: OmitFirstArg<typeof Editor.addMark>;
property after
after: OmitFirstArg<typeof Editor.after>;
property apply
apply: (operation: Operation) => void;
property before
before: OmitFirstArg<typeof Editor.before>;
property children
children: Descendant[];
property collapse
collapse: OmitFirstArg<typeof Transforms.collapse>;
property delete
delete: OmitFirstArg<typeof Transforms.delete>;
property deleteBackward
deleteBackward: (unit: TextUnit) => void;
property deleteForward
deleteForward: (unit: TextUnit) => void;
property deleteFragment
deleteFragment: OmitFirstArg<typeof Editor.deleteFragment>;
property deselect
deselect: OmitFirstArg<typeof Transforms.deselect>;
property edges
edges: OmitFirstArg<typeof Editor.edges>;
property elementReadOnly
elementReadOnly: OmitFirstArg<typeof Editor.elementReadOnly>;
property end
end: OmitFirstArg<typeof Editor.end>;
property first
first: OmitFirstArg<typeof Editor.first>;
property fragment
fragment: OmitFirstArg<typeof Editor.fragment>;
property getDirtyPaths
getDirtyPaths: (operation: Operation) => Path[];
property getFragment
getFragment: () => Descendant[];
property getMarks
getMarks: OmitFirstArg<typeof Editor.marks>;
property hasBlocks
hasBlocks: OmitFirstArg<typeof Editor.hasBlocks>;
property hasInlines
hasInlines: OmitFirstArg<typeof Editor.hasInlines>;
property hasPath
hasPath: OmitFirstArg<typeof Editor.hasPath>;
property hasTexts
hasTexts: OmitFirstArg<typeof Editor.hasTexts>;
property insertBreak
insertBreak: OmitFirstArg<typeof Editor.insertBreak>;
property insertFragment
insertFragment: OmitFirstArg<typeof Transforms.insertFragment>;
property insertNode
insertNode: OmitFirstArg<typeof Editor.insertNode>;
property insertNodes
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>;
property insertSoftBreak
insertSoftBreak: OmitFirstArg<typeof Editor.insertSoftBreak>;
property insertText
insertText: OmitFirstArg<typeof Transforms.insertText>;
property isBlock
isBlock: OmitFirstArg<typeof Editor.isBlock>;
property isEdge
isEdge: OmitFirstArg<typeof Editor.isEdge>;
property isElementReadOnly
isElementReadOnly: (element: Element) => boolean;
property isEmpty
isEmpty: OmitFirstArg<typeof Editor.isEmpty>;
property isEnd
isEnd: OmitFirstArg<typeof Editor.isEnd>;
property isInline
isInline: OmitFirstArg<typeof Editor.isInline>;
property isNormalizing
isNormalizing: OmitFirstArg<typeof Editor.isNormalizing>;
property isSelectable
isSelectable: (element: Element) => boolean;
property isStart
isStart: OmitFirstArg<typeof Editor.isStart>;
property isVoid
isVoid: OmitFirstArg<typeof Editor.isVoid>;
property last
last: OmitFirstArg<typeof Editor.last>;
property leaf
leaf: OmitFirstArg<typeof Editor.leaf>;
property levels
levels: <T extends Node>( options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
property liftNodes
liftNodes: OmitFirstArg<typeof Transforms.liftNodes>;
property markableVoid
markableVoid: (element: Element) => boolean;
property marks
marks: EditorMarks | null;
property mergeNodes
mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>;
property move
move: OmitFirstArg<typeof Transforms.move>;
property moveNodes
moveNodes: OmitFirstArg<typeof Transforms.moveNodes>;
property next
next: <T extends Descendant>( options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
property node
node: OmitFirstArg<typeof Editor.node>;
property nodes
nodes: <T extends Node>( options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
property normalize
normalize: OmitFirstArg<typeof Editor.normalize>;
property normalizeNode
normalizeNode: ( entry: NodeEntry, options?: { operation?: Operation; }) => void;
property onChange
onChange: (options?: { operation?: Operation }) => void;
property operations
operations: Operation[];
property parent
parent: OmitFirstArg<typeof Editor.parent>;
property path
path: OmitFirstArg<typeof Editor.path>;
property pathRef
pathRef: OmitFirstArg<typeof Editor.pathRef>;
property pathRefs
pathRefs: OmitFirstArg<typeof Editor.pathRefs>;
property point
point: OmitFirstArg<typeof Editor.point>;
property pointRef
pointRef: OmitFirstArg<typeof Editor.pointRef>;
property pointRefs
pointRefs: OmitFirstArg<typeof Editor.pointRefs>;
property positions
positions: OmitFirstArg<typeof Editor.positions>;
property previous
previous: <T extends Node>( options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
property range
range: OmitFirstArg<typeof Editor.range>;
property rangeRef
rangeRef: OmitFirstArg<typeof Editor.rangeRef>;
property rangeRefs
rangeRefs: OmitFirstArg<typeof Editor.rangeRefs>;
property removeMark
removeMark: OmitFirstArg<typeof Editor.removeMark>;
property removeNodes
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>;
property select
select: OmitFirstArg<typeof Transforms.select>;
property selection
selection: Selection;
property setNodes
setNodes: <T extends Node>( props: Partial<T>, options?: { at?: Location; match?: NodeMatch<T>; mode?: MaximizeMode; hanging?: boolean; split?: boolean; voids?: boolean; compare?: PropsCompare; merge?: PropsMerge; }) => void;
property setNormalizing
setNormalizing: OmitFirstArg<typeof Editor.setNormalizing>;
property setPoint
setPoint: OmitFirstArg<typeof Transforms.setPoint>;
property setSelection
setSelection: OmitFirstArg<typeof Transforms.setSelection>;
property shouldMergeNodesRemovePrevNode
shouldMergeNodesRemovePrevNode: OmitFirstArg< typeof Editor.shouldMergeNodesRemovePrevNode>;
property shouldNormalize
shouldNormalize: ({ iteration, dirtyPaths, operation,}: { iteration: number; initialDirtyPathsLength: number; dirtyPaths: Path[]; operation?: Operation;}) => boolean;
property splitNodes
splitNodes: OmitFirstArg<typeof Transforms.splitNodes>;
property start
start: OmitFirstArg<typeof Editor.start>;
property string
string: OmitFirstArg<typeof Editor.string>;
property unhangRange
unhangRange: OmitFirstArg<typeof Editor.unhangRange>;
property unsetNodes
unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>;
property unwrapNodes
unwrapNodes: OmitFirstArg<typeof Transforms.unwrapNodes>;
property void
void: OmitFirstArg<typeof Editor.void>;
property withoutNormalizing
withoutNormalizing: OmitFirstArg<typeof Editor.withoutNormalizing>;
property wrapNodes
wrapNodes: OmitFirstArg<typeof Transforms.wrapNodes>;
interface BaseElement
interface BaseElement {}
Element
objects are a type of node in a Slate document that contain other element nodes or text nodes. They can be either "blocks" or "inlines" depending on the Slate editor's configuration.
property children
children: Descendant[];
interface BasePoint
interface BasePoint {}
Point
objects refer to a specific location in a text node in a Slate document. Its path refers to the location of the node in the tree, and its offset refers to the distance into the node's string of text. Points can only refer toText
nodes.
interface BaseRange
interface BaseRange {}
Range
objects are a set of points that refer to a specific span of a Slate document. They can define a span inside a single node or a can span across multiple nodes.
interface BaseText
interface BaseText {}
Text
objects represent the nodes that contain the actual text content of a Slate document along with any formatting properties. They are always leaf nodes in the document tree as they cannot contain any children.
property text
text: string;
interface CustomTypes
interface CustomTypes {}
index signature
[key: string]: unknown;
interface EditorAboveOptions
interface EditorAboveOptions<T extends Ancestor> {}
interface EditorAfterOptions
interface EditorAfterOptions {}
interface EditorBeforeOptions
interface EditorBeforeOptions {}
interface EditorDirectedDeletionOptions
interface EditorDirectedDeletionOptions {}
property unit
unit?: TextUnit;
interface EditorElementReadOnlyOptions
interface EditorElementReadOnlyOptions {}
interface EditorFragmentDeletionOptions
interface EditorFragmentDeletionOptions {}
property direction
direction?: TextDirection;
interface EditorInterface
interface EditorInterface {}
property above
above: <T extends Ancestor>( editor: Editor, options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
Get the ancestor above a location in the document.
property addMark
addMark: (editor: Editor, key: string, value: any) => void;
Add a custom property to the leaf text nodes in the current selection.
If the selection is currently collapsed, the marks will be added to the
editor.marks
property instead, and applied when text is inserted next.
property after
after: ( editor: Editor, at: Location, options?: EditorAfterOptions) => Point | undefined;
Get the point after a location.
property before
before: ( editor: Editor, at: Location, options?: EditorBeforeOptions) => Point | undefined;
Get the point before a location.
property deleteBackward
deleteBackward: ( editor: Editor, options?: EditorDirectedDeletionOptions) => void;
Delete content in the editor backward from the current selection.
property deleteForward
deleteForward: (editor: Editor, options?: EditorDirectedDeletionOptions) => void;
Delete content in the editor forward from the current selection.
property deleteFragment
deleteFragment: ( editor: Editor, options?: EditorFragmentDeletionOptions) => void;
Delete the content in the current selection.
property edges
edges: (editor: Editor, at: Location) => [Point, Point];
Get the start and end points of a location.
property elementReadOnly
elementReadOnly: ( editor: Editor, options?: EditorElementReadOnlyOptions) => NodeEntry<Element> | undefined;
Match a read-only element in the current branch of the editor.
property end
end: (editor: Editor, at: Location) => Point;
Get the end point of a location.
property first
first: (editor: Editor, at: Location) => NodeEntry;
Get the first node at a location.
property fragment
fragment: (editor: Editor, at: Location) => Descendant[];
Get the fragment at a location.
property hasBlocks
hasBlocks: (editor: Editor, element: Element) => boolean;
Check if a node has block children.
property hasInlines
hasInlines: (editor: Editor, element: Element) => boolean;
Check if a node has inline and text children.
property hasPath
hasPath: (editor: Editor, path: Path) => boolean;
property hasTexts
hasTexts: (editor: Editor, element: Element) => boolean;
Check if a node has text children.
property insertBreak
insertBreak: (editor: Editor) => void;
Insert a block break at the current selection.
If the selection is currently expanded, it will be deleted first.
property insertFragment
insertFragment: ( editor: Editor, fragment: Node[], options?: TextInsertFragmentOptions) => void;
Inserts a fragment at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
property insertNode
insertNode: <T extends Node>( editor: Editor, node: Node, options?: NodeInsertNodesOptions<T>) => void;
Atomically inserts
nodes
at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
property insertSoftBreak
insertSoftBreak: (editor: Editor) => void;
Insert a soft break at the current selection.
If the selection is currently expanded, it will be deleted first.
property insertText
insertText: ( editor: Editor, text: string, options?: TextInsertTextOptions) => void;
Insert a string of text at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
property isBlock
isBlock: (editor: Editor, value: Element) => boolean;
Check if a value is a block
Element
object.
property isEdge
isEdge: (editor: Editor, point: Point, at: Location) => boolean;
Check if a point is an edge of a location.
property isEditor
isEditor: (value: any) => value is Editor;
Check if a value is an
Editor
object.
property isElementReadOnly
isElementReadOnly: (editor: Editor, element: Element) => boolean;
Check if a value is a read-only
Element
object.
property isEmpty
isEmpty: (editor: Editor, element: Element) => boolean;
Check if an element is empty, accounting for void nodes.
property isEnd
isEnd: (editor: Editor, point: Point, at: Location) => boolean;
Check if a point is the end point of a location.
property isInline
isInline: (editor: Editor, value: Element) => boolean;
Check if a value is an inline
Element
object.
property isNormalizing
isNormalizing: (editor: Editor) => boolean;
Check if the editor is currently normalizing after each operation.
property isSelectable
isSelectable: (editor: Editor, element: Element) => boolean;
Check if a value is a selectable
Element
object.
property isStart
isStart: (editor: Editor, point: Point, at: Location) => boolean;
Check if a point is the start point of a location.
property isVoid
isVoid: (editor: Editor, value: Element) => boolean;
Check if a value is a void
Element
object.
property last
last: (editor: Editor, at: Location) => NodeEntry;
Get the last node at a location.
property leaf
leaf: ( editor: Editor, at: Location, options?: EditorLeafOptions) => NodeEntry<Text>;
Get the leaf text node at a location.
property levels
levels: <T extends Node>( editor: Editor, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
Iterate through all of the levels at a location.
property marks
marks: (editor: Editor) => Omit<Text, 'text'> | null;
Get the marks that would be added to text at the current selection.
property next
next: <T extends Descendant>( editor: Editor, options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
Get the matching node in the branch of the document after a location.
property node
node: (editor: Editor, at: Location, options?: EditorNodeOptions) => NodeEntry;
Get the node at a location.
property nodes
nodes: <T extends Node>( editor: Editor, options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
Iterate through all of the nodes in the Editor.
property normalize
normalize: (editor: Editor, options?: EditorNormalizeOptions) => void;
Normalize any dirty objects in the editor.
property parent
parent: ( editor: Editor, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
Get the parent node of a location.
property path
path: (editor: Editor, at: Location, options?: EditorPathOptions) => Path;
Get the path of a location.
property pathRef
pathRef: (editor: Editor, path: Path, options?: EditorPathRefOptions) => PathRef;
Create a mutable ref for a
Path
object, which will stay in sync as new operations are applied to the editor.
property pathRefs
pathRefs: (editor: Editor) => Set<PathRef>;
Get the set of currently tracked path refs of the editor.
property point
point: (editor: Editor, at: Location, options?: EditorPointOptions) => Point;
Get the start or end point of a location.
property pointRef
pointRef: ( editor: Editor, point: Point, options?: EditorPointRefOptions) => PointRef;
Create a mutable ref for a
Point
object, which will stay in sync as new operations are applied to the editor.
property pointRefs
pointRefs: (editor: Editor) => Set<PointRef>;
Get the set of currently tracked point refs of the editor.
property positions
positions: ( editor: Editor, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
Return all the positions in
at
range where aPoint
can be placed.By default, moves forward by individual offsets at a time, but the
unit
option can be used to to move by character, word, line, or block.The
reverse
option can be used to change iteration direction.Note: By default void nodes are treated as a single point and iteration will not happen inside their content unless you pass in true for the
voids
option, then iteration will occur.
property previous
previous: <T extends Node>( editor: Editor, options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
Get the matching node in the branch of the document before a location.
property range
range: (editor: Editor, at: Location, to?: Location) => Range;
Get a range of a location.
property rangeRef
rangeRef: ( editor: Editor, range: Range, options?: EditorRangeRefOptions) => RangeRef;
Create a mutable ref for a
Range
object, which will stay in sync as new operations are applied to the editor.
property rangeRefs
rangeRefs: (editor: Editor) => Set<RangeRef>;
Get the set of currently tracked range refs of the editor.
property removeMark
removeMark: (editor: Editor, key: string) => void;
Remove a custom property from all of the leaf text nodes in the current selection.
If the selection is currently collapsed, the removal will be stored on
editor.marks
and applied to the text inserted next.
property setNormalizing
setNormalizing: (editor: Editor, isNormalizing: boolean) => void;
Manually set if the editor should currently be normalizing.
Note: Using this incorrectly can leave the editor in an invalid state.
property shouldMergeNodesRemovePrevNode
shouldMergeNodesRemovePrevNode: ( editor: Editor, prevNodeEntry: NodeEntry, curNodeEntry: NodeEntry) => boolean;
Call a function, Determine whether or not remove the previous node when merge.
property start
start: (editor: Editor, at: Location) => Point;
Get the start point of a location.
property string
string: (editor: Editor, at: Location, options?: EditorStringOptions) => string;
Get the text string content of a location.
Note: by default the text of void nodes is considered to be an empty string, regardless of content, unless you pass in true for the voids option
property unhangRange
unhangRange: ( editor: Editor, range: Range, options?: EditorUnhangRangeOptions) => Range;
Convert a range into a non-hanging one.
property void
void: ( editor: Editor, options?: EditorVoidOptions) => NodeEntry<Element> | undefined;
Match a void node in the current branch of the editor.
property withoutNormalizing
withoutNormalizing: (editor: Editor, fn: () => void) => void;
Call a function, deferring normalization until after it completes.
interface EditorLeafOptions
interface EditorLeafOptions {}
interface EditorLevelsOptions
interface EditorLevelsOptions<T extends Node> {}
interface EditorNextOptions
interface EditorNextOptions<T extends Descendant> {}
interface EditorNodeOptions
interface EditorNodeOptions {}
interface EditorNodesOptions
interface EditorNodesOptions<T extends Node> {}
interface EditorNormalizeOptions
interface EditorNormalizeOptions {}
interface EditorParentOptions
interface EditorParentOptions {}
interface EditorPathOptions
interface EditorPathOptions {}
interface EditorPathRefOptions
interface EditorPathRefOptions {}
property affinity
affinity?: TextDirection | null;
interface EditorPointOptions
interface EditorPointOptions {}
property edge
edge?: LeafEdge;
interface EditorPointRefOptions
interface EditorPointRefOptions {}
property affinity
affinity?: TextDirection | null;
interface EditorPositionsOptions
interface EditorPositionsOptions {}
property at
at?: Location;
property ignoreNonSelectable
ignoreNonSelectable?: boolean;
property reverse
reverse?: boolean;
property unit
unit?: TextUnitAdjustment;
property voids
voids?: boolean;
interface EditorPreviousOptions
interface EditorPreviousOptions<T extends Node> {}
interface EditorRangeRefOptions
interface EditorRangeRefOptions {}
property affinity
affinity?: RangeDirection | null;
interface EditorStringOptions
interface EditorStringOptions {}
property voids
voids?: boolean;
interface EditorUnhangRangeOptions
interface EditorUnhangRangeOptions {}
property voids
voids?: boolean;
interface EditorVoidOptions
interface EditorVoidOptions {}
interface ElementInterface
interface ElementInterface {}
property isAncestor
isAncestor: (value: any) => value is Ancestor;
Check if a value implements the 'Ancestor' interface.
property isElement
isElement: (value: any) => value is Element;
Check if a value implements the
Element
interface.
property isElementList
isElementList: (value: any) => value is Element[];
Check if a value is an array of
Element
objects.
property isElementProps
isElementProps: (props: any) => props is Partial<Element>;
Check if a set of props is a partial of Element.
property isElementType
isElementType: <T extends Element>( value: any, elementVal: string, elementKey?: string) => value is T;
Check if a value implements the
Element
interface and has elementKey with selected value. Default it check totype
key value
property matches
matches: (element: Element, props: Partial<Element>) => boolean;
Check if an element matches set of properties.
Note: this checks custom properties, and it does not ensure that any children are equivalent.
interface LocationInterface
interface LocationInterface {}
property isLocation
isLocation: (value: any) => value is Location;
Check if a value implements the
Location
interface.
interface NodeAncestorsOptions
interface NodeAncestorsOptions {}
property reverse
reverse?: boolean;
interface NodeChildrenOptions
interface NodeChildrenOptions {}
property reverse
reverse?: boolean;
interface NodeDescendantsOptions
interface NodeDescendantsOptions {}
interface NodeElementsOptions
interface NodeElementsOptions {}
interface NodeInterface
interface NodeInterface {}
property ancestor
ancestor: (root: Node, path: Path) => Ancestor;
Get the node at a specific path, asserting that it's an ancestor node.
property ancestors
ancestors: ( root: Node, path: Path, options?: NodeAncestorsOptions) => Generator<NodeEntry<Ancestor>, void, undefined>;
Return a generator of all the ancestor nodes above a specific path.
By default the order is top-down, from highest to lowest ancestor in the tree, but you can pass the
reverse: true
option to go bottom-up.
property child
child: (root: Node, index: number) => Descendant;
Get the child of a node at a specific index.
property children
children: ( root: Node, path: Path, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
Iterate over the children of a node at a specific path.
property common
common: (root: Node, path: Path, another: Path) => NodeEntry;
Get an entry for the common ancesetor node of two paths.
property descendant
descendant: (root: Node, path: Path) => Descendant;
Get the node at a specific path, asserting that it's a descendant node.
property descendants
descendants: ( root: Node, options?: NodeDescendantsOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
Return a generator of all the descendant node entries inside a root node.
property elements
elements: ( root: Node, options?: NodeElementsOptions) => Generator<ElementEntry, void, undefined>;
Return a generator of all the element nodes inside a root node. Each iteration will return an
ElementEntry
tuple consisting of[Element, Path]
. If the root node is an element it will be included in the iteration as well.
property extractProps
extractProps: (node: Node) => NodeProps;
Extract props from a Node.
property first
first: (root: Node, path: Path) => NodeEntry;
Get the first node entry in a root node from a path.
property fragment
fragment: (root: Node, range: Range) => Descendant[];
Get the sliced fragment represented by a range inside a root node.
property get
get: (root: Node, path: Path) => Node;
Get the descendant node referred to by a specific path. If the path is an empty array, it refers to the root node itself.
property getIf
getIf: (root: Node, path: Path) => Node | undefined;
Similar to get, but returns undefined if the node does not exist.
property has
has: (root: Node, path: Path) => boolean;
Check if a descendant node exists at a specific path.
property isNode
isNode: (value: any) => value is Node;
Check if a value implements the
Node
interface.
property isNodeList
isNodeList: (value: any) => value is Node[];
Check if a value is a list of
Node
objects.
property last
last: (root: Node, path: Path) => NodeEntry;
Get the last node entry in a root node from a path.
property leaf
leaf: (root: Node, path: Path) => Text;
Get the node at a specific path, ensuring it's a leaf text node.
property levels
levels: ( root: Node, path: Path, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
Return a generator of the in a branch of the tree, from a specific path.
By default the order is top-down, from highest to lowest node in the tree, but you can pass the
reverse: true
option to go bottom-up.
property matches
matches: (node: Node, props: Partial<Node>) => boolean;
Check if a node matches a set of props.
property nodes
nodes: ( root: Node, options?: NodeNodesOptions) => Generator<NodeEntry, void, undefined>;
Return a generator of all the node entries of a root node. Each entry is returned as a
[Node, Path]
tuple, with the path referring to the node's position inside the root node.
property parent
parent: (root: Node, path: Path) => Ancestor;
Get the parent of a node at a specific path.
property string
string: (node: Node) => string;
Get the concatenated text string of a node's content.
Note that this will not include spaces or line breaks between block nodes. It is not a user-facing string, but a string for performing offset-related computations for a node.
property texts
texts: ( root: Node, options?: NodeTextsOptions) => Generator<NodeEntry<Text>, void, undefined>;
Return a generator of all leaf text nodes in a root node.
interface NodeLevelsOptions
interface NodeLevelsOptions {}
property reverse
reverse?: boolean;
interface NodeNodesOptions
interface NodeNodesOptions {}
interface NodeTextsOptions
interface NodeTextsOptions {}
interface OperationInterface
interface OperationInterface {}
property inverse
inverse: (op: Operation) => Operation;
Invert an operation, returning a new operation that will exactly undo the original when applied.
property isNodeOperation
isNodeOperation: (value: any) => value is NodeOperation;
Check if a value is a
NodeOperation
object.
property isOperation
isOperation: (value: any) => value is Operation;
Check if a value is an
Operation
object.
property isOperationList
isOperationList: (value: any) => value is Operation[];
Check if a value is a list of
Operation
objects.
property isSelectionOperation
isSelectionOperation: (value: any) => value is SelectionOperation;
Check if a value is a
SelectionOperation
object.
property isTextOperation
isTextOperation: (value: any) => value is TextOperation;
Check if a value is a
TextOperation
object.
interface PathAncestorsOptions
interface PathAncestorsOptions {}
property reverse
reverse?: boolean;
interface PathInterface
interface PathInterface {}
property ancestors
ancestors: (path: Path, options?: PathAncestorsOptions) => Path[];
Get a list of ancestor paths for a given path.
The paths are sorted from shallowest to deepest ancestor. However, if the
reverse: true
option is passed, they are reversed.
property common
common: (path: Path, another: Path) => Path;
Get the common ancestor path of two paths.
property compare
compare: (path: Path, another: Path) => -1 | 0 | 1;
Compare a path to another, returning an integer indicating whether the path was before, at, or after the other.
Note: Two paths of unequal length can still receive a
0
result if one is directly above or below the other. If you want exact matching, use [[Path.equals]] instead.
property endsAfter
endsAfter: (path: Path, another: Path) => boolean;
Check if a path ends after one of the indexes in another.
property endsAt
endsAt: (path: Path, another: Path) => boolean;
Check if a path ends at one of the indexes in another.
property endsBefore
endsBefore: (path: Path, another: Path) => boolean;
Check if a path ends before one of the indexes in another.
property equals
equals: (path: Path, another: Path) => boolean;
Check if a path is exactly equal to another.
property hasPrevious
hasPrevious: (path: Path) => boolean;
Check if the path of previous sibling node exists
property isAfter
isAfter: (path: Path, another: Path) => boolean;
Check if a path is after another.
property isAncestor
isAncestor: (path: Path, another: Path) => boolean;
Check if a path is an ancestor of another.
property isBefore
isBefore: (path: Path, another: Path) => boolean;
Check if a path is before another.
property isChild
isChild: (path: Path, another: Path) => boolean;
Check if a path is a child of another.
property isCommon
isCommon: (path: Path, another: Path) => boolean;
Check if a path is equal to or an ancestor of another.
property isDescendant
isDescendant: (path: Path, another: Path) => boolean;
Check if a path is a descendant of another.
property isParent
isParent: (path: Path, another: Path) => boolean;
Check if a path is the parent of another.
property isPath
isPath: (value: any) => value is Path;
Check is a value implements the
Path
interface.
property isSibling
isSibling: (path: Path, another: Path) => boolean;
Check if a path is a sibling of another.
property levels
levels: (path: Path, options?: PathLevelsOptions) => Path[];
Get a list of paths at every level down to a path. Note: this is the same as
Path.ancestors
, but including the path itself.The paths are sorted from shallowest to deepest. However, if the `reverse: true` option is passed, they are reversed.
property next
next: (path: Path) => Path;
Given a path, get the path to the next sibling node.
property operationCanTransformPath
operationCanTransformPath: ( operation: Operation) => operation is | InsertNodeOperation | RemoveNodeOperation | MergeNodeOperation | SplitNodeOperation | MoveNodeOperation;
Returns whether this operation can affect paths or not. Used as an optimization when updating dirty paths during normalization
NOTE: This *must* be kept in sync with the implementation of 'transform' below
property parent
parent: (path: Path) => Path;
Given a path, return a new path referring to the parent node above it.
property previous
previous: (path: Path) => Path;
Given a path, get the path to the previous sibling node.
property relative
relative: (path: Path, ancestor: Path) => Path;
Get a path relative to an ancestor.
property transform
transform: ( path: Path, operation: Operation, options?: PathTransformOptions) => Path | null;
Transform a path by an operation.
interface PathLevelsOptions
interface PathLevelsOptions {}
property reverse
reverse?: boolean;
interface PathRef
interface PathRef {}
PathRef
objects keep a specific path in a document synced over time as new operations are applied to the editor. You can access theircurrent
property at any time for the up-to-date path value.
interface PathRefInterface
interface PathRefInterface {}
property transform
transform: (ref: PathRef, op: Operation) => void;
Transform the path ref's current value by an operation.
interface PathTransformOptions
interface PathTransformOptions {}
property affinity
affinity?: TextDirection | null;
interface PointInterface
interface PointInterface {}
property compare
compare: (point: Point, another: Point) => -1 | 0 | 1;
Compare a point to another, returning an integer indicating whether the point was before, at, or after the other.
property equals
equals: (point: Point, another: Point) => boolean;
Check if a point is exactly equal to another.
property isAfter
isAfter: (point: Point, another: Point) => boolean;
Check if a point is after another.
property isBefore
isBefore: (point: Point, another: Point) => boolean;
Check if a point is before another.
property isPoint
isPoint: (value: any) => value is Point;
Check if a value implements the
Point
interface.
property transform
transform: ( point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
Transform a point by an operation.
interface PointRef
interface PointRef {}
PointRef
objects keep a specific point in a document synced over time as new operations are applied to the editor. You can access theircurrent
property at any time for the up-to-date point value.
interface PointRefInterface
interface PointRefInterface {}
property transform
transform: (ref: PointRef, op: Operation) => void;
Transform the point ref's current value by an operation.
interface PointTransformOptions
interface PointTransformOptions {}
property affinity
affinity?: TextDirection | null;
interface RangeEdgesOptions
interface RangeEdgesOptions {}
property reverse
reverse?: boolean;
interface RangeInterface
interface RangeInterface {}
property edges
edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
Get the start and end points of a range, in the order in which they appear in the document.
property end
end: (range: Range) => Point;
Get the end point of a range.
property equals
equals: (range: Range, another: Range) => boolean;
Check if a range is exactly equal to another.
property includes
includes: (range: Range, target: Path | Point | Range) => boolean;
Check if a range includes a path, a point or part of another range.
property intersection
intersection: (range: Range, another: Range) => Range | null;
Get the intersection of a range with another.
property isBackward
isBackward: (range: Range) => boolean;
Check if a range is backward, meaning that its anchor point appears in the document _after_ its focus point.
property isCollapsed
isCollapsed: (range: Range) => boolean;
Check if a range is collapsed, meaning that both its anchor and focus points refer to the exact same position in the document.
property isExpanded
isExpanded: (range: Range) => boolean;
Check if a range is expanded.
This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
property isForward
isForward: (range: Range) => boolean;
Check if a range is forward.
This is the opposite of [[Range.isBackward]] and is provided for legibility.
property isRange
isRange: (value: any) => value is Range;
Check if a value implements the [[Range]] interface.
property points
points: (range: Range) => Generator<PointEntry, void, undefined>;
Iterate through all of the point entries in a range.
property start
start: (range: Range) => Point;
Get the start point of a range.
property surrounds
surrounds: (range: Range, target: Range) => boolean;
Check if a range includes another range.
property transform
transform: ( range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
Transform a range by an operation.
interface RangeRef
interface RangeRef {}
RangeRef
objects keep a specific range in a document synced over time as new operations are applied to the editor. You can access theircurrent
property at any time for the up-to-date range value.
interface RangeRefInterface
interface RangeRefInterface {}
property transform
transform: (ref: RangeRef, op: Operation) => void;
Transform the range ref's current value by an operation.
interface RangeTransformOptions
interface RangeTransformOptions {}
property affinity
affinity?: RangeDirection | null;
interface ScrubberInterface
interface ScrubberInterface {}
method setScrubber
setScrubber: (scrubber: Scrubber | undefined) => void;
method stringify
stringify: (value: any) => string;
interface SpanInterface
interface SpanInterface {}
property isSpan
isSpan: (value: any) => value is Span;
Check if a value implements the
Span
interface.
interface TextEqualsOptions
interface TextEqualsOptions {}
property loose
loose?: boolean;
interface TextInterface
interface TextInterface {}
property decorations
decorations: (node: Text, decorations: DecoratedRange[]) => Text[];
Get the leaves for a text node given decorations.
property equals
equals: (text: Text, another: Text, options?: TextEqualsOptions) => boolean;
Check if two text nodes are equal.
When loose is set, the text is not compared. This is used to check whether sibling text nodes can be merged.
property isText
isText: (value: any) => value is Text;
Check if a value implements the
Text
interface.
property isTextList
isTextList: (value: any) => value is Text[];
Check if a value is a list of
Text
objects.
property isTextProps
isTextProps: (props: any) => props is Partial<Text>;
Check if some props are a partial of Text.
property matches
matches: (text: Text, props: Partial<Text>) => boolean;
Check if an text matches set of properties.
Note: this is for matching custom properties, and it does not ensure that the
text
property are two nodes equal.
Type Aliases
type Ancestor
type Ancestor = Editor | Element;
The
Ancestor
union type represents nodes that are ancestors in the tree. It is returned as a convenience in certain cases to narrow a value further than the more genericNode
union.
type BaseInsertNodeOperation
type BaseInsertNodeOperation = { type: 'insert_node'; path: Path; node: Node;};
type BaseInsertTextOperation
type BaseInsertTextOperation = { type: 'insert_text'; path: Path; offset: number; text: string;};
type BaseMergeNodeOperation
type BaseMergeNodeOperation = { type: 'merge_node'; path: Path; position: number; properties: Partial<Node>;};
type BaseMoveNodeOperation
type BaseMoveNodeOperation = { type: 'move_node'; path: Path; newPath: Path;};
type BaseNode
type BaseNode = Editor | Element | Text;
The
Node
union type represents all of the different types of nodes that occur in a Slate document tree.
type BaseOperation
type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
Operation
objects define the low-level instructions that Slate editors use to apply changes to their internal state. Representing all changes as operations is what allows Slate editors to easily implement history, collaboration, and other features.
type BaseRemoveNodeOperation
type BaseRemoveNodeOperation = { type: 'remove_node'; path: Path; node: Node;};
type BaseRemoveTextOperation
type BaseRemoveTextOperation = { type: 'remove_text'; path: Path; offset: number; text: string;};
type BaseSelection
type BaseSelection = Range | null;
type BaseSetNodeOperation
type BaseSetNodeOperation = { type: 'set_node'; path: Path; properties: Partial<Node>; newProperties: Partial<Node>;};
type BaseSetSelectionOperation
type BaseSetSelectionOperation = | { type: 'set_selection'; properties: null; newProperties: Range; } | { type: 'set_selection'; properties: Partial<Range>; newProperties: Partial<Range>; } | { type: 'set_selection'; properties: Range; newProperties: null; };
type BaseSplitNodeOperation
type BaseSplitNodeOperation = { type: 'split_node'; path: Path; position: number; properties: Partial<Node>;};
type DecoratedRange
type DecoratedRange = Range & { /** * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used. * It is useful for overlapping decorations with the same key but different values. */ merge?: (leaf: Text, decoration: object) => void;};
type Descendant
type Descendant = Element | Text;
The
Descendant
union type represents nodes that are descendants in the tree. It is returned as a convenience in certain cases to narrow a value further than the more genericNode
union.
type Editor
type Editor = ExtendedType<'Editor', BaseEditor>;
type EditorMarks
type EditorMarks = Omit<Text, 'text'>;
type Element
type Element = ExtendedType<'Element', BaseElement>;
type ElementEntry
type ElementEntry = [Element, Path];
ElementEntry
objects refer to anElement
and thePath
where it can be found inside a root node.
type ExtendedType
type ExtendedType<K extends ExtendableTypes, B> = unknown extends CustomTypes[K] ? B : CustomTypes[K];
type InsertNodeOperation
type InsertNodeOperation = ExtendedType< 'InsertNodeOperation', BaseInsertNodeOperation>;
type InsertTextOperation
type InsertTextOperation = ExtendedType< 'InsertTextOperation', BaseInsertTextOperation>;
type LeafEdge
type LeafEdge = 'start' | 'end';
type Location
type Location = Path | Point | Range;
The
Location
interface is a union of the ways to refer to a specific location in a Slate document: paths, points or ranges.Methods will often accept a
Location
instead of requiring only aPath
,Point
orRange
. This eliminates the need for developers to manage converting between the different interfaces in their own code base.
type MaximizeMode
type MaximizeMode = RangeMode | 'all';
type MergeNodeOperation
type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
type MoveNodeOperation
type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
type MoveUnit
type MoveUnit = 'offset' | 'character' | 'word' | 'line';
type Node
type Node = Editor | Element | Text;
type NodeEntry
type NodeEntry<T extends Node = Node> = [T, Path];
NodeEntry
objects are returned when iterating over the nodes in a Slate document tree. They consist of the node and itsPath
relative to the root node in the document.
type NodeMatch
type NodeMatch<T extends Node> = | ((node: Node, path: Path) => node is T) | ((node: Node, path: Path) => boolean);
A helper type for narrowing matched nodes with a predicate.
type NodeOperation
type NodeOperation = | InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
type NodeProps
type NodeProps = | Omit<Editor, 'children'> | Omit<Element, 'children'> | Omit<Text, 'text'>;
Convenience type for returning the props of a node.
type Operation
type Operation = ExtendedType<'Operation', BaseOperation>;
type Path
type Path = number[];
Path
arrays are a list of indexes that describe a node's exact position in a Slate node tree. Although they are usually relative to the rootEditor
object, they can be relative to anyNode
object.
type Point
type Point = ExtendedType<'Point', BasePoint>;
type PointEntry
type PointEntry = [Point, 'anchor' | 'focus'];
PointEntry
objects are returned when iterating overPoint
objects that belong to a range.
type PropsCompare
type PropsCompare = (prop: Partial<Node>, node: Partial<Node>) => boolean;
type PropsMerge
type PropsMerge = (prop: Partial<Node>, node: Partial<Node>) => object;
type Range
type Range = ExtendedType<'Range', BaseRange>;
type RangeDirection
type RangeDirection = TextDirection | 'outward' | 'inward';
type RangeMode
type RangeMode = 'highest' | 'lowest';
type RemoveNodeOperation
type RemoveNodeOperation = ExtendedType< 'RemoveNodeOperation', BaseRemoveNodeOperation>;
type RemoveTextOperation
type RemoveTextOperation = ExtendedType< 'RemoveTextOperation', BaseRemoveTextOperation>;
type Scrubber
type Scrubber = (key: string, value: unknown) => unknown;
type Selection
type Selection = ExtendedType<'Selection', BaseSelection>;
type SelectionEdge
type SelectionEdge = 'anchor' | 'focus' | 'start' | 'end';
type SelectionMode
type SelectionMode = 'all' | 'highest' | 'lowest';
type SelectionOperation
type SelectionOperation = SetSelectionOperation;
type SetNodeOperation
type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
type SetSelectionOperation
type SetSelectionOperation = ExtendedType< 'SetSelectionOperation', BaseSetSelectionOperation>;
type Span
type Span = [Path, Path];
The
Span
interface is a low-level way to refer to locations in nodes without usingPoint
which requires leaf text nodes to be present.
type SplitNodeOperation
type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
type Text
type Text = ExtendedType<'Text', BaseText>;
type TextDirection
type TextDirection = 'forward' | 'backward';
type TextOperation
type TextOperation = InsertTextOperation | RemoveTextOperation;
type TextUnit
type TextUnit = 'character' | 'word' | 'line' | 'block';
type TextUnitAdjustment
type TextUnitAdjustment = TextUnit | 'offset';
Package Files (96)
- dist/core/apply.d.ts
- dist/core/get-dirty-paths.d.ts
- dist/core/get-fragment.d.ts
- dist/core/normalize-node.d.ts
- dist/core/should-normalize.d.ts
- dist/create-editor.d.ts
- dist/editor/above.d.ts
- dist/editor/add-mark.d.ts
- dist/editor/after.d.ts
- dist/editor/before.d.ts
- dist/editor/delete-backward.d.ts
- dist/editor/delete-forward.d.ts
- dist/editor/delete-fragment.d.ts
- dist/editor/edges.d.ts
- dist/editor/element-read-only.d.ts
- dist/editor/end.d.ts
- dist/editor/first.d.ts
- dist/editor/fragment.d.ts
- dist/editor/get-void.d.ts
- dist/editor/has-blocks.d.ts
- dist/editor/has-inlines.d.ts
- dist/editor/has-path.d.ts
- dist/editor/has-texts.d.ts
- dist/editor/insert-break.d.ts
- dist/editor/insert-node.d.ts
- dist/editor/insert-soft-break.d.ts
- dist/editor/insert-text.d.ts
- dist/editor/is-block.d.ts
- dist/editor/is-edge.d.ts
- dist/editor/is-editor.d.ts
- dist/editor/is-empty.d.ts
- dist/editor/is-end.d.ts
- dist/editor/is-normalizing.d.ts
- dist/editor/is-start.d.ts
- dist/editor/last.d.ts
- dist/editor/leaf.d.ts
- dist/editor/levels.d.ts
- dist/editor/marks.d.ts
- dist/editor/next.d.ts
- dist/editor/node.d.ts
- dist/editor/nodes.d.ts
- dist/editor/normalize.d.ts
- dist/editor/parent.d.ts
- dist/editor/path-ref.d.ts
- dist/editor/path-refs.d.ts
- dist/editor/path.d.ts
- dist/editor/point-ref.d.ts
- dist/editor/point-refs.d.ts
- dist/editor/point.d.ts
- dist/editor/positions.d.ts
- dist/editor/previous.d.ts
- dist/editor/range-ref.d.ts
- dist/editor/range-refs.d.ts
- dist/editor/range.d.ts
- dist/editor/remove-mark.d.ts
- dist/editor/set-normalizing.d.ts
- dist/editor/should-merge-nodes-remove-prev-node.d.ts
- dist/editor/start.d.ts
- dist/editor/string.d.ts
- dist/editor/unhang-range.d.ts
- dist/editor/without-normalizing.d.ts
- dist/index.d.ts
- dist/interfaces/editor.d.ts
- dist/interfaces/element.d.ts
- dist/interfaces/location.d.ts
- dist/interfaces/node.d.ts
- dist/interfaces/operation.d.ts
- dist/interfaces/path-ref.d.ts
- dist/interfaces/path.d.ts
- dist/interfaces/point-ref.d.ts
- dist/interfaces/point.d.ts
- dist/interfaces/range-ref.d.ts
- dist/interfaces/range.d.ts
- dist/interfaces/scrubber.d.ts
- dist/interfaces/text.d.ts
- dist/interfaces/transforms/index.d.ts
- dist/transforms-node/insert-nodes.d.ts
- dist/transforms-node/lift-nodes.d.ts
- dist/transforms-node/merge-nodes.d.ts
- dist/transforms-node/move-nodes.d.ts
- dist/transforms-node/remove-nodes.d.ts
- dist/transforms-node/set-nodes.d.ts
- dist/transforms-node/split-nodes.d.ts
- dist/transforms-node/unset-nodes.d.ts
- dist/transforms-node/unwrap-nodes.d.ts
- dist/transforms-node/wrap-nodes.d.ts
- dist/transforms-selection/collapse.d.ts
- dist/transforms-selection/deselect.d.ts
- dist/transforms-selection/move.d.ts
- dist/transforms-selection/select.d.ts
- dist/transforms-selection/set-point.d.ts
- dist/transforms-selection/set-selection.d.ts
- dist/transforms-text/delete-text.d.ts
- dist/transforms-text/insert-fragment.d.ts
- dist/types/custom-types.d.ts
- dist/types/types.d.ts
Dependencies (3)
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/slate
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/slate)
- HTML<a href="https://www.jsdocs.io/package/slate"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 8862 ms. - Missing or incorrect documentation? Open an issue for this package.