import { Ancestor, ExtendedType, Location, Node, NodeEntry, Operation, Path, PathRef, Point, PointRef, Range, RangeRef, Span, Text } from '..'; import { Element } from './element'; import { Descendant } from './node'; import { LeafEdge, MaximizeMode, RangeDirection, SelectionMode, TextDirection, TextUnit, TextUnitAdjustment } from './types'; export declare type BaseSelection = Range | null; export declare type Selection = ExtendedType<'Selection', BaseSelection>; export declare type EditorMarks = Omit; /** * 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. */ export interface BaseEditor { children: Descendant[]; selection: Selection; operations: Operation[]; marks: EditorMarks | null; isInline: (element: Element) => boolean; isVoid: (element: Element) => boolean; markableVoid: (element: Element) => boolean; normalizeNode: (entry: NodeEntry, options?: { operation?: Operation; }) => void; onChange: (options?: { operation?: Operation; }) => void; addMark: (key: string, value: any) => void; apply: (operation: Operation) => void; deleteBackward: (unit: TextUnit) => void; deleteForward: (unit: TextUnit) => void; deleteFragment: (direction?: TextDirection) => void; getFragment: () => Descendant[]; insertBreak: () => void; insertSoftBreak: () => void; insertFragment: (fragment: Node[]) => void; insertNode: (node: Node) => void; insertText: (text: string) => void; removeMark: (key: string) => void; getDirtyPaths: (operation: Operation) => Path[]; shouldNormalize: ({ iteration, dirtyPaths, operation, }: { iteration: number; initialDirtyPathsLength: number; dirtyPaths: Path[]; operation?: Operation; }) => boolean; } export declare type Editor = ExtendedType<'Editor', BaseEditor>; export interface EditorAboveOptions { at?: Location; match?: NodeMatch; mode?: MaximizeMode; voids?: boolean; } export interface EditorAfterOptions { distance?: number; unit?: TextUnitAdjustment; voids?: boolean; } export interface EditorBeforeOptions { distance?: number; unit?: TextUnitAdjustment; voids?: boolean; } export interface EditorDirectedDeletionOptions { unit?: TextUnit; } export interface EditorFragmentDeletionOptions { direction?: TextDirection; } export interface EditorLeafOptions { depth?: number; edge?: LeafEdge; } export interface EditorLevelsOptions { at?: Location; match?: NodeMatch; reverse?: boolean; voids?: boolean; } export interface EditorNextOptions { at?: Location; match?: NodeMatch; mode?: SelectionMode; voids?: boolean; } export interface EditorNodeOptions { depth?: number; edge?: LeafEdge; } export interface EditorNodesOptions { at?: Location | Span; match?: NodeMatch; mode?: SelectionMode; universal?: boolean; reverse?: boolean; voids?: boolean; } export interface EditorNormalizeOptions { force?: boolean; operation?: Operation; } export interface EditorParentOptions { depth?: number; edge?: LeafEdge; } export interface EditorPathOptions { depth?: number; edge?: LeafEdge; } export interface EditorPathRefOptions { affinity?: TextDirection | null; } export interface EditorPointOptions { edge?: LeafEdge; } export interface EditorPointRefOptions { affinity?: TextDirection | null; } export interface EditorPositionsOptions { at?: Location; unit?: TextUnitAdjustment; reverse?: boolean; voids?: boolean; } export interface EditorPreviousOptions { at?: Location; match?: NodeMatch; mode?: SelectionMode; voids?: boolean; } export interface EditorRangeRefOptions { affinity?: RangeDirection | null; } export interface EditorStringOptions { voids?: boolean; } export interface EditorUnhangRangeOptions { voids?: boolean; } export interface EditorVoidOptions { at?: Location; mode?: MaximizeMode; voids?: boolean; } export interface EditorInterface { above: (editor: Editor, options?: EditorAboveOptions) => NodeEntry | undefined; addMark: (editor: Editor, key: string, value: any) => void; after: (editor: Editor, at: Location, options?: EditorAfterOptions) => Point | undefined; before: (editor: Editor, at: Location, options?: EditorBeforeOptions) => Point | undefined; deleteBackward: (editor: Editor, options?: EditorDirectedDeletionOptions) => void; deleteForward: (editor: Editor, options?: EditorDirectedDeletionOptions) => void; deleteFragment: (editor: Editor, options?: EditorFragmentDeletionOptions) => void; edges: (editor: Editor, at: Location) => [Point, Point]; end: (editor: Editor, at: Location) => Point; first: (editor: Editor, at: Location) => NodeEntry; fragment: (editor: Editor, at: Location) => Descendant[]; hasBlocks: (editor: Editor, element: Element) => boolean; hasInlines: (editor: Editor, element: Element) => boolean; hasPath: (editor: Editor, path: Path) => boolean; hasTexts: (editor: Editor, element: Element) => boolean; insertBreak: (editor: Editor) => void; insertSoftBreak: (editor: Editor) => void; insertFragment: (editor: Editor, fragment: Node[]) => void; insertNode: (editor: Editor, node: Node) => void; insertText: (editor: Editor, text: string) => void; isBlock: (editor: Editor, value: Element) => boolean; isEditor: (value: any) => value is Editor; isEnd: (editor: Editor, point: Point, at: Location) => boolean; isEdge: (editor: Editor, point: Point, at: Location) => boolean; isEmpty: (editor: Editor, element: Element) => boolean; isInline: (editor: Editor, value: Element) => boolean; isNormalizing: (editor: Editor) => boolean; isStart: (editor: Editor, point: Point, at: Location) => boolean; isVoid: (editor: Editor, value: Element) => boolean; last: (editor: Editor, at: Location) => NodeEntry; leaf: (editor: Editor, at: Location, options?: EditorLeafOptions) => NodeEntry; levels: (editor: Editor, options?: EditorLevelsOptions) => Generator, void, undefined>; marks: (editor: Editor) => Omit | null; next: (editor: Editor, options?: EditorNextOptions) => NodeEntry | undefined; node: (editor: Editor, at: Location, options?: EditorNodeOptions) => NodeEntry; nodes: (editor: Editor, options?: EditorNodesOptions) => Generator, void, undefined>; normalize: (editor: Editor, options?: EditorNormalizeOptions) => void; parent: (editor: Editor, at: Location, options?: EditorParentOptions) => NodeEntry; path: (editor: Editor, at: Location, options?: EditorPathOptions) => Path; pathRef: (editor: Editor, path: Path, options?: EditorPathRefOptions) => PathRef; pathRefs: (editor: Editor) => Set; point: (editor: Editor, at: Location, options?: EditorPointOptions) => Point; pointRef: (editor: Editor, point: Point, options?: EditorPointRefOptions) => PointRef; pointRefs: (editor: Editor) => Set; positions: (editor: Editor, options?: EditorPositionsOptions) => Generator; previous: (editor: Editor, options?: EditorPreviousOptions) => NodeEntry | undefined; range: (editor: Editor, at: Location, to?: Location) => Range; rangeRef: (editor: Editor, range: Range, options?: EditorRangeRefOptions) => RangeRef; rangeRefs: (editor: Editor) => Set; removeMark: (editor: Editor, key: string) => void; setNormalizing: (editor: Editor, isNormalizing: boolean) => void; start: (editor: Editor, at: Location) => Point; string: (editor: Editor, at: Location, options?: EditorStringOptions) => string; unhangRange: (editor: Editor, range: Range, options?: EditorUnhangRangeOptions) => Range; void: (editor: Editor, options?: EditorVoidOptions) => NodeEntry | undefined; withoutNormalizing: (editor: Editor, fn: () => void) => void; } export declare const Editor: EditorInterface; /** * A helper type for narrowing matched nodes with a predicate. */ export declare type NodeMatch = ((node: Node, path: Path) => node is T) | ((node: Node, path: Path) => boolean); export declare type PropsCompare = (prop: Partial, node: Partial) => boolean; export declare type PropsMerge = (prop: Partial, node: Partial) => object; //# sourceMappingURL=editor.d.ts.map