1 | import { Ancestor, ExtendedType, Location, Node, NodeEntry, Operation, Path, PathRef, Point, PointRef, Range, RangeRef, Span, Text } from '..';
|
2 | import { Descendant } from './node';
|
3 | import { Element } from './element';
|
4 | export declare type BaseSelection = Range | null;
|
5 | export declare type Selection = ExtendedType<'Selection', BaseSelection>;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export interface BaseEditor {
|
11 | children: Descendant[];
|
12 | selection: Selection;
|
13 | operations: Operation[];
|
14 | marks: Omit<Text, 'text'> | null;
|
15 | isInline: (element: Element) => boolean;
|
16 | isVoid: (element: Element) => boolean;
|
17 | normalizeNode: (entry: NodeEntry) => void;
|
18 | onChange: () => void;
|
19 | addMark: (key: string, value: any) => void;
|
20 | apply: (operation: Operation) => void;
|
21 | deleteBackward: (unit: 'character' | 'word' | 'line' | 'block') => void;
|
22 | deleteForward: (unit: 'character' | 'word' | 'line' | 'block') => void;
|
23 | deleteFragment: (direction?: 'forward' | 'backward') => void;
|
24 | getFragment: () => Descendant[];
|
25 | insertBreak: () => void;
|
26 | insertFragment: (fragment: Node[]) => void;
|
27 | insertNode: (node: Node) => void;
|
28 | insertText: (text: string) => void;
|
29 | removeMark: (key: string) => void;
|
30 | }
|
31 | export declare type Editor = ExtendedType<'Editor', BaseEditor>;
|
32 | export interface EditorInterface {
|
33 | above: <T extends Ancestor>(editor: Editor, options?: {
|
34 | at?: Location;
|
35 | match?: NodeMatch<T>;
|
36 | mode?: 'highest' | 'lowest';
|
37 | voids?: boolean;
|
38 | }) => NodeEntry<T> | undefined;
|
39 | addMark: (editor: Editor, key: string, value: any) => void;
|
40 | after: (editor: Editor, at: Location, options?: {
|
41 | distance?: number;
|
42 | unit?: 'offset' | 'character' | 'word' | 'line' | 'block';
|
43 | voids?: boolean;
|
44 | }) => Point | undefined;
|
45 | before: (editor: Editor, at: Location, options?: {
|
46 | distance?: number;
|
47 | unit?: 'offset' | 'character' | 'word' | 'line' | 'block';
|
48 | voids?: boolean;
|
49 | }) => Point | undefined;
|
50 | deleteBackward: (editor: Editor, options?: {
|
51 | unit?: 'character' | 'word' | 'line' | 'block';
|
52 | }) => void;
|
53 | deleteForward: (editor: Editor, options?: {
|
54 | unit?: 'character' | 'word' | 'line' | 'block';
|
55 | }) => void;
|
56 | deleteFragment: (editor: Editor, options?: {
|
57 | direction?: 'forward' | 'backward';
|
58 | }) => void;
|
59 | edges: (editor: Editor, at: Location) => [Point, Point];
|
60 | end: (editor: Editor, at: Location) => Point;
|
61 | first: (editor: Editor, at: Location) => NodeEntry;
|
62 | fragment: (editor: Editor, at: Location) => Descendant[];
|
63 | hasBlocks: (editor: Editor, element: Element) => boolean;
|
64 | hasInlines: (editor: Editor, element: Element) => boolean;
|
65 | hasPath: (editor: Editor, path: Path) => boolean;
|
66 | hasTexts: (editor: Editor, element: Element) => boolean;
|
67 | insertBreak: (editor: Editor) => void;
|
68 | insertFragment: (editor: Editor, fragment: Node[]) => void;
|
69 | insertNode: (editor: Editor, node: Node) => void;
|
70 | insertText: (editor: Editor, text: string) => void;
|
71 | isBlock: (editor: Editor, value: any) => value is Element;
|
72 | isEditor: (value: any) => value is Editor;
|
73 | isEnd: (editor: Editor, point: Point, at: Location) => boolean;
|
74 | isEdge: (editor: Editor, point: Point, at: Location) => boolean;
|
75 | isEmpty: (editor: Editor, element: Element) => boolean;
|
76 | isInline: (editor: Editor, value: any) => value is Element;
|
77 | isNormalizing: (editor: Editor) => boolean;
|
78 | isStart: (editor: Editor, point: Point, at: Location) => boolean;
|
79 | isVoid: (editor: Editor, value: any) => value is Element;
|
80 | last: (editor: Editor, at: Location) => NodeEntry;
|
81 | leaf: (editor: Editor, at: Location, options?: {
|
82 | depth?: number;
|
83 | edge?: 'start' | 'end';
|
84 | }) => NodeEntry<Text>;
|
85 | levels: <T extends Node>(editor: Editor, options?: {
|
86 | at?: Location;
|
87 | match?: NodeMatch<T>;
|
88 | reverse?: boolean;
|
89 | voids?: boolean;
|
90 | }) => Generator<NodeEntry<T>, void, undefined>;
|
91 | marks: (editor: Editor) => Omit<Text, 'text'> | null;
|
92 | next: <T extends Descendant>(editor: Editor, options?: {
|
93 | at?: Location;
|
94 | match?: NodeMatch<T>;
|
95 | mode?: 'all' | 'highest' | 'lowest';
|
96 | voids?: boolean;
|
97 | }) => NodeEntry<T> | undefined;
|
98 | node: (editor: Editor, at: Location, options?: {
|
99 | depth?: number;
|
100 | edge?: 'start' | 'end';
|
101 | }) => NodeEntry;
|
102 | nodes: <T extends Node>(editor: Editor, options?: {
|
103 | at?: Location | Span;
|
104 | match?: NodeMatch<T>;
|
105 | mode?: 'all' | 'highest' | 'lowest';
|
106 | universal?: boolean;
|
107 | reverse?: boolean;
|
108 | voids?: boolean;
|
109 | }) => Generator<NodeEntry<T>, void, undefined>;
|
110 | normalize: (editor: Editor, options?: {
|
111 | force?: boolean;
|
112 | }) => void;
|
113 | parent: (editor: Editor, at: Location, options?: {
|
114 | depth?: number;
|
115 | edge?: 'start' | 'end';
|
116 | }) => NodeEntry<Ancestor>;
|
117 | path: (editor: Editor, at: Location, options?: {
|
118 | depth?: number;
|
119 | edge?: 'start' | 'end';
|
120 | }) => Path;
|
121 | pathRef: (editor: Editor, path: Path, options?: {
|
122 | affinity?: 'backward' | 'forward' | null;
|
123 | }) => PathRef;
|
124 | pathRefs: (editor: Editor) => Set<PathRef>;
|
125 | point: (editor: Editor, at: Location, options?: {
|
126 | edge?: 'start' | 'end';
|
127 | }) => Point;
|
128 | pointRef: (editor: Editor, point: Point, options?: {
|
129 | affinity?: 'backward' | 'forward' | null;
|
130 | }) => PointRef;
|
131 | pointRefs: (editor: Editor) => Set<PointRef>;
|
132 | positions: (editor: Editor, options?: {
|
133 | at?: Location;
|
134 | unit?: 'offset' | 'character' | 'word' | 'line' | 'block';
|
135 | reverse?: boolean;
|
136 | voids?: boolean;
|
137 | }) => Generator<Point, void, undefined>;
|
138 | previous: <T extends Node>(editor: Editor, options?: {
|
139 | at?: Location;
|
140 | match?: NodeMatch<T>;
|
141 | mode?: 'all' | 'highest' | 'lowest';
|
142 | voids?: boolean;
|
143 | }) => NodeEntry<T> | undefined;
|
144 | range: (editor: Editor, at: Location, to?: Location) => Range;
|
145 | rangeRef: (editor: Editor, range: Range, options?: {
|
146 | affinity?: 'backward' | 'forward' | 'outward' | 'inward' | null;
|
147 | }) => RangeRef;
|
148 | rangeRefs: (editor: Editor) => Set<RangeRef>;
|
149 | removeMark: (editor: Editor, key: string) => void;
|
150 | setNormalizing: (editor: Editor, isNormalizing: boolean) => void;
|
151 | start: (editor: Editor, at: Location) => Point;
|
152 | string: (editor: Editor, at: Location, options?: {
|
153 | voids?: boolean;
|
154 | }) => string;
|
155 | unhangRange: (editor: Editor, range: Range, options?: {
|
156 | voids?: boolean;
|
157 | }) => Range;
|
158 | void: (editor: Editor, options?: {
|
159 | at?: Location;
|
160 | mode?: 'highest' | 'lowest';
|
161 | voids?: boolean;
|
162 | }) => NodeEntry<Element> | undefined;
|
163 | withoutNormalizing: (editor: Editor, fn: () => void) => void;
|
164 | }
|
165 | export declare const Editor: EditorInterface;
|
166 |
|
167 |
|
168 |
|
169 | export declare type NodeMatch<T extends Node> = ((node: Node, path: Path) => node is T) | ((node: Node, path: Path) => boolean);
|
170 | //# sourceMappingURL=editor.d.ts.map |
\ | No newline at end of file |