UNPKG

115 kBTypeScriptView Raw
1import * as Immutable from "immutable";
2import { SyntheticEvent } from "react";
3
4export interface Data extends Immutable.Map<any, any> {}
5
6export namespace Data {
7 function create(properties: Immutable.Map<string, any> | { [key: string]: any }): Data;
8 function fromJSON(object: { [key: string]: any }): Data;
9 function fromJS(object: { [key: string]: any }): Data;
10}
11
12export interface RulesByNodeType {
13 [key: string]: Rules;
14}
15
16export interface ObjectAndType {
17 object?: string | undefined;
18 type?: string | undefined;
19}
20
21export interface Rules {
22 data?: {
23 [key: string]: (v: any) => boolean;
24 } | undefined;
25 first?: ObjectAndType | ObjectAndType[] | undefined;
26 isAtomic?: boolean | undefined;
27 isVoid?: boolean | undefined;
28 last?: ObjectAndType | ObjectAndType[] | undefined;
29 marks?:
30 | Array<{
31 type: string | ((type: string) => boolean);
32 }>
33 | undefined;
34 next?: ObjectAndType | ObjectAndType[] | undefined;
35 nodes?:
36 | Array<{
37 min?: number | undefined;
38 max?: number | undefined;
39 match?: ObjectAndType | ObjectAndType[] | undefined;
40 }>
41 | undefined;
42 normalize?: ((editor: Editor, error: SlateError) => void) | undefined;
43 parent?: ObjectAndType | ObjectAndType[] | undefined;
44 text?: RegExp | ((text: string) => boolean) | undefined;
45 previous?: ObjectAndType | ObjectAndType[] | undefined;
46}
47
48export interface SchemaProperties {
49 rules?: Array<{ match: ObjectAndType | ObjectAndType[] } & Rules> | undefined;
50 document?: Rules | undefined;
51 blocks?: RulesByNodeType | undefined;
52 inlines?: RulesByNodeType | undefined;
53 marks?: RulesByNodeType | undefined;
54 annotations?: RulesByNodeType | undefined;
55 decorations?: RulesByNodeType | undefined;
56}
57
58export type Path = Immutable.List<number> | number[] | string;
59export interface ValueProperties {
60 object?: "value" | undefined;
61 annotations?: Immutable.Map<string, Annotation> | { [key: string]: AnnotationJSON } | undefined;
62 data?: Data | { [key: string]: any } | undefined;
63 document?: Document | undefined;
64 selection?: Selection | undefined;
65}
66
67export interface ValueJSON {
68 object?: "value" | undefined;
69 annotations?: { [key: string]: AnnotationJSON } | undefined;
70 data?: { [key: string]: any } | undefined;
71 document?: DocumentJSON | undefined;
72 selection?: SelectionJSON | undefined;
73}
74
75export class Value extends Immutable.Record({}) {
76 object: "value";
77 annotations: Immutable.Map<string, Annotation>;
78 data: Data;
79 document: Document;
80 selection: Selection;
81
82 readonly startBlock: Block;
83 readonly endBlock: Block;
84 readonly anchorBlock: Block;
85 readonly focusBlock: Block;
86 readonly nextBlock: Block;
87 readonly previousBlock: Block;
88
89 readonly startInline: Inline;
90 readonly endInline: Inline;
91 readonly anchorInline: Inline;
92 readonly focusInline: Inline;
93 readonly nextInline: Inline;
94 readonly previousInline: Inline;
95
96 readonly startText: Text;
97 readonly endText: Text;
98 readonly anchorText: Text;
99 readonly focusText: Text;
100 readonly nextText: Text;
101 readonly previousText: Text;
102
103 readonly marks: Immutable.OrderedSet<Mark>;
104 readonly activeMarks: Immutable.OrderedSet<Mark>;
105 readonly blocks: Immutable.List<Block>;
106 readonly fragment: Document;
107 readonly inlines: Immutable.List<Inline>;
108 readonly texts: Immutable.List<Text>;
109
110 static create(properties?: ValueProperties | ValueJSON | Value): Value;
111 static createProperties(attrs: ValueProperties | ValueJSON | Value): ValueProperties;
112 static fromJSON(properties: ValueProperties | ValueJSON): Value;
113 static fromJS(properties: ValueProperties | ValueJSON): Value;
114 static isValue(maybeValue: any): maybeValue is Value;
115
116 toJSON(options?: {
117 preserveAnnotations?: boolean | undefined;
118 preserveData?: boolean | undefined;
119 preserveSelection?: boolean | undefined;
120 }): ValueJSON;
121 toJS(options?: {
122 preserveAnnotations?: boolean | undefined;
123 preserveData?: boolean | undefined;
124 preserveSelection?: boolean | undefined;
125 }): ValueJSON;
126 addAnnotation(annotation: Annotation | AnnotationProperties | AnnotationJSON): Value;
127 addMark(path: Path, mark: MarkProperties | MarkJSON | Mark | string): Value;
128 insertNode(path: Path, node: Node): Value;
129 insertText(
130 path: Path,
131 offset: number,
132 text: string,
133 ): Value;
134 mergeNode(path: Path): Value;
135 moveNode(path: Immutable.List<number>, newPath: Immutable.List<number>, newIndex?: number): Value;
136 removeAnnotation(annotation: Annotation | AnnotationProperties | AnnotationJSON): Value;
137 removeMark(path: Path, mark: MarkProperties | MarkJSON | Mark | string): Value;
138 removeNode(path: Path): Value;
139 removeText(path: Path, offset: number, text: string): Value;
140 setAnnotation(
141 properties: AnnotationProperties | AnnotationJSON | Annotation,
142 newProperties: AnnotationProperties | AnnotationJSON | Annotation,
143 ): Value;
144 setNode(path: Path, properties: NodeProperties): Value;
145 setMark(
146 path: Path,
147 properties: MarkProperties,
148 newProperties: MarkProperties,
149 ): Value;
150 setProperties(properties: ValueProperties): Value;
151 setSelection(
152 properties:
153 | RangeTypeProperties
154 | RangeTypeJSON
155 | RangeType
156 | string,
157 ): Value;
158 splitNode(
159 path: Path,
160 position: number,
161 properties: NodeProperties,
162 ): Value;
163 mapRanges(iterator: (val: Selection | Annotation) => any): Value;
164 mapPoints(iterator: (point: Point) => Point): Value;
165}
166
167export interface DocumentProperties {
168 object?: "document" | undefined;
169 nodes?: Immutable.List<Node> | Node[] | undefined;
170 key?: string | undefined;
171 data?: Data | { [key: string]: any } | undefined;
172}
173
174export interface DocumentJSON {
175 object?: "document" | undefined;
176 nodes?: NodeJSON[] | undefined;
177 key?: string | undefined;
178 data?: { [key: string]: any } | undefined;
179}
180
181export class Document extends BaseNode {
182 object: "document";
183
184 static create(
185 properties:
186 | DocumentProperties
187 | DocumentJSON
188 | Document
189 | Array<NodeJSON | NodeProperties | Node>
190 | Immutable.List<NodeJSON | NodeProperties | Node>,
191 ): Document;
192 static fromJSON(properties: DocumentJSON | DocumentProperties | Document): Document;
193 static fromJS(properties: DocumentJSON | DocumentProperties | Document): Document;
194 static isDocument(maybeDocument: any): maybeDocument is Document;
195
196 toJSON(): DocumentJSON;
197 toJS(): DocumentJSON;
198}
199
200export interface BlockProperties {
201 object?: "block" | undefined;
202 type: string;
203 key?: string | undefined;
204 nodes?: Immutable.List<Block | Text | Inline> | Array<Block | Text | Inline> | undefined;
205 data?: Data | { [key: string]: any } | undefined;
206}
207
208export interface BlockJSON {
209 object?: "block" | undefined;
210 type: string;
211 key?: string | undefined;
212 nodes?: Array<BlockJSON | InlineJSON | TextJSON> | undefined;
213 data?: { [key: string]: any } | undefined;
214}
215
216export class Block extends BaseNode {
217 object: "block";
218 nodes: Immutable.List<Block | Text | Inline>;
219
220 static create(
221 properties:
222 | BlockProperties
223 | BlockJSON
224 | Block
225 | string,
226 ): Block;
227 static createList(
228 array?:
229 | Array<BlockProperties | BlockJSON | Block | string>
230 | Immutable.List<BlockProperties | BlockJSON | Block | string>,
231 ): Immutable.List<Block>;
232 static fromJSON(properties: BlockJSON | BlockProperties | Block): Block;
233 static fromJS(properties: BlockJSON | BlockProperties | Block): Block;
234 static isBlock(maybeBlock: any): maybeBlock is Block;
235 static isBlockList(
236 maybeBlockList: any,
237 ): maybeBlockList is Immutable.List<Block>;
238
239 toJSON(): BlockJSON;
240 toJS(): BlockJSON;
241}
242
243export interface InlineProperties {
244 object?: "inline" | undefined;
245 type: string;
246 key?: string | undefined;
247 nodes?: Immutable.List<Inline | Text> | Array<Inline | Text> | undefined;
248 data?: Data | { [key: string]: any } | undefined;
249}
250
251export interface InlineJSON {
252 object?: "inline" | undefined;
253 type: string;
254 key?: string | undefined;
255 nodes?: Array<InlineJSON | TextJSON> | undefined;
256 data?: { [key: string]: any } | undefined;
257}
258
259export class Inline extends BaseNode {
260 object: "inline";
261 nodes: Immutable.List<Inline | Text>;
262
263 static create(
264 properties:
265 | InlineProperties
266 | InlineJSON
267 | Inline
268 | string,
269 ): Inline;
270 static createList(
271 elements?:
272 | Immutable.List<InlineProperties | InlineJSON | Inline | string>
273 | Array<InlineProperties | InlineJSON | Inline | string>,
274 ): Immutable.List<Inline>;
275 static fromJSON(
276 properties:
277 | InlineProperties
278 | InlineJSON
279 | Inline,
280 ): Inline;
281 static fromJS(
282 properties:
283 | InlineProperties
284 | InlineJSON
285 | Inline,
286 ): Inline;
287 static isInline(maybeInline: any): maybeInline is Inline;
288 static isInlineList(
289 maybeInlineList: any,
290 ): maybeInlineList is Immutable.List<Inline>;
291
292 toJSON(): InlineJSON;
293 toJS(): InlineJSON;
294}
295
296export interface TextProperties {
297 object?: "text" | undefined;
298 key?: string | undefined;
299 text?: string | undefined;
300 marks?: Immutable.Set<Mark> | Mark[] | undefined;
301}
302
303export interface TextJSON {
304 object?: "text" | undefined;
305 key?: string | undefined;
306 text?: string | undefined;
307 marks?: MarkJSON[] | undefined;
308}
309
310export interface LeafAndOffset {
311 startOffset: number;
312 endOffset: number;
313 index: number;
314 leaf: Leaf;
315}
316
317export class Text extends Immutable.Record({}) {
318 object: "text";
319 key: string;
320
321 readonly text: string;
322 readonly marks: Immutable.Set<Mark> | null;
323
324 static create(properties?: TextProperties | TextJSON | Text | string): Text;
325 static createList(
326 elements?:
327 | Array<TextProperties | TextJSON | Text | string>
328 | Immutable.List<TextProperties | TextJSON | Text | string>,
329 ): Immutable.List<Text>;
330 static fromJSON(properties: TextJSON | TextProperties | Text): Text;
331 static fromJS(properties: TextJSON | TextProperties | Text): Text;
332 static isText(maybeText: any): maybeText is Text;
333 static isTextList(maybeTextList: any): maybeTextList is Immutable.List<Text>;
334
335 toJSON(options?: { preserveKeys?: boolean | undefined }): TextJSON;
336 toJS(options?: { preserveKeys?: boolean | undefined }): TextJSON;
337
338 addMark(mark: MarkProperties | MarkJSON | Mark | string): Text;
339 addMarks(
340 marks:
341 | Array<MarkProperties | MarkJSON | Mark | string>
342 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
343 ): Text;
344 getKeysToPathsTable(): { [key: string]: number[] };
345 getLeaves(
346 annotations: Immutable.Map<string, Annotation>,
347 decorations?: Decoration[] | Immutable.List<Decoration>,
348 ): Immutable.List<Leaf>;
349 getFirstText(): Text | null;
350 getLastText(): Text | null;
351 getText(): string;
352 getNode(path: Path): Node | null;
353 getPath(key: Immutable.List<number> | string | Node): Immutable.List<number> | null;
354 hasNode(path: Path): boolean;
355 insertText(index: number, string: string): Text;
356 regenerateKey(): Text;
357 removeMark(mark: MarkProperties | MarkJSON | Mark | string): Text;
358 removeText(index: number, length: number): Text;
359 resolvePath(path: Path, index?: number): Immutable.List<number>;
360 setMark(
361 properties: MarkProperties | MarkJSON | Mark | string,
362 newProperties: MarkProperties,
363 ): Text;
364 splitText(index: number): Text[];
365 mergeText(other: Text): Text;
366 normalize(editor: Editor): () => void | void;
367 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
368 validate(editor: Editor): Error | void;
369}
370
371export interface LeafProperties {
372 object?: "leaf" | undefined;
373 marks?: Immutable.Set<Mark> | Mark[] | undefined;
374 text?: string | undefined;
375}
376
377export interface LeafJSON {
378 object?: "leaf" | undefined;
379 marks?: MarkJSON[] | undefined;
380 text?: string | undefined;
381}
382
383export class Leaf extends Immutable.Record({}) {
384 object: "leaf";
385 marks: Immutable.Set<Mark> | null;
386 text: string;
387
388 static create(properties: LeafProperties | LeafJSON | Leaf): Leaf;
389 static createLeaves(leaves: Immutable.List<Leaf>): Immutable.List<Leaf>;
390 static splitLeaves(
391 leaves: Immutable.List<Leaf>,
392 offset: number,
393 ): Array<Immutable.List<Leaf>>;
394 static createList(
395 attrs?:
396 | Array<LeafProperties | LeafJSON | Leaf>
397 | Immutable.List<LeafProperties | LeafJSON | Leaf>,
398 ): Immutable.List<Leaf>;
399 static fromJSON(properties: LeafJSON | LeafProperties): Leaf;
400 static fromJS(properties: LeafJSON | LeafProperties): Leaf;
401 static isLeaf(maybeLeaf: any): maybeLeaf is Leaf;
402 static isLeafList(
403 maybeLeafList: any,
404 ): maybeLeafList is Immutable.List<Leaf>;
405
406 updateMark(mark: Mark, newMark: Mark): Leaf;
407 addMarks(marks: Immutable.Set<Mark>): Leaf;
408 addMark(mark: Mark): Leaf;
409 removeMark(mark: Mark): Leaf;
410
411 insertText(offset: number, string: string): Leaf;
412
413 toJSON(): LeafJSON;
414 toJS(): LeafJSON;
415}
416
417interface IterableOptions {
418 direction?: string | undefined;
419 downward?: boolean | undefined;
420 upward?: boolean | undefined;
421 includeBlocks?: boolean | undefined;
422 includeDocument?: boolean | undefined;
423 includeInlines?: boolean | undefined;
424 includeRoot?: boolean | undefined;
425 includeTarget?: boolean | undefined;
426 includeTargetAncestors?: boolean | undefined;
427 includeTexts?: boolean | undefined;
428 match?: ((node: Node, path: Immutable.List<number>) => boolean | null) | undefined;
429 range?: RangeProperties | RangeJSON | Range | undefined;
430 path?: Path | undefined;
431}
432
433export namespace NodeFactory {
434 function create(attrs: Node | NodeJSON | NodeProperties): Node;
435 function createList(
436 elements?:
437 | Array<Node | NodeJSON | NodeProperties>
438 | Immutable.List<Node | NodeJSON | NodeProperties>,
439 ): Immutable.List<Node>;
440 function createProperties(
441 attrs?: Block | Inline | string | { type?: string | undefined; data?: object | undefined },
442 ): NodeProperties;
443 function fromJSON(value: { [key: string]: any }): NodeJSON;
444 function fromJS(value: { [key: string]: any }): NodeJSON;
445 function isNode(maybeNode: any): maybeNode is Node;
446 function isNodeList(maybeNodeList: any): maybeNodeList is Immutable.List<Node>;
447}
448
449export type Node = Document | Block | Inline | Text;
450export type NodeJSON = DocumentJSON | BlockJSON | InlineJSON | TextJSON;
451export type NodeProperties =
452 | DocumentProperties
453 | BlockProperties
454 | InlineProperties
455 | TextProperties;
456
457declare class BaseNode extends Immutable.Record({}) {
458 data: Data;
459 type: string;
460 key: string;
461 object: "document" | "block" | "inline" | "text";
462 nodes: Immutable.List<Node>;
463
464 readonly text: string;
465
466 static isNode(maybeNode: any): maybeNode is Node;
467 static isNodeList(
468 maybeNodeList: any,
469 ): maybeNodeList is Immutable.List<Node>;
470 static createProperties(
471 attrs: NodeProperties | string | Node,
472 ): NodeProperties;
473 static fromJSON(value: NodeJSON | NodeProperties | Node): Node;
474 static fromJS(value: NodeJSON | NodeProperties | Node): Node;
475
476 addMark(path: Path, mark: Mark): Node;
477 ancestors(path: Path): Iterable<[Node, Immutable.List<number>]>;
478 blocks(
479 options?: IterableOptions & {
480 onlyLeaves?: boolean | undefined;
481 onlyRoots?: boolean | undefined;
482 onlyTypes?: string[] | undefined;
483 },
484 ): Iterable<[Block, Immutable.List<number>]>;
485 createAnnotation(properties: AnnotationProperties | AnnotationJSON | Annotation): Annotation;
486 createDecoration(properties: DecorationProperties | DecorationJSON | Decoration): Decoration;
487 createIterable(options?: IterableOptions): Iterable<[Node, Immutable.List<number>]>;
488 createPoint(properties: PointProperties | PointJSON | Point): Point;
489 createRange(properties: RangeTypeProperties | RangeTypeJSON | RangeType): Range;
490 createSelection(properties: SelectionProperties | SelectionJSON | Selection | Range): Selection;
491 descendants(options?: IterableOptions): Iterable<[Node, Immutable.List<number>]>;
492 filterDescendants(predicate?: (node: Node, path: Immutable.List<number>) => boolean): Immutable.List<Node>;
493 findDescendant(predicate?: (node: Node, path: Immutable.List<number>) => boolean): Node | null;
494 forEachDescendant(predicate?: (node: Node, path: Immutable.List<number>) => boolean): void;
495 getActiveMarksAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.Set<Mark>;
496 getAncestors(path: Path): Immutable.List<Node> | null;
497 getBlocks(): Immutable.List<Block>;
498 getBlocksByType(type: string): Immutable.List<Block>;
499 getChild(path: Path): Node | null;
500 getClosest(path: Path, predicate: (node: Node, path: Immutable.List<number>) => boolean): Node | null;
501 getClosestBlock(path: Path): Block | null;
502 getClosestInline(path: Path): Inline | null;
503 getClosestVoid(path: Path, editor: Editor): Node | null;
504 getCommonAncestor(a: Path, b: Path): Node | null;
505 getDecorations(editor: Editor): Immutable.List<Decoration>;
506 getDepth(path: Path, startAt?: number): number | null;
507 getDescendant(path: Path): Node | null;
508 getDescendantsAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Node>;
509 getFirstText(): Text | null;
510 getFragmentAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Document;
511 getFurthest(path: Path, predicate?: (node: Node, path: Immutable.List<number>) => boolean): Node | null;
512 getFurthestBlock(path: Path): Block | null;
513 getFurthestChild(path: Path): Node | null;
514 getFurthestInline(path: Path): Inline | null;
515 getInlines(): Immutable.List<Inline>;
516 getInlinesByType(type: string): Immutable.List<Inline>;
517 getInsertMarksAtPoint(point: PointProperties | PointJSON | Point): Immutable.Set<Mark>;
518 getInsertMarksAtRange(range: RangeProperties | RangeJSON | Range): Immutable.Set<Mark>;
519 getKeysToPathsTable(): { [key: string]: number[] };
520 getLastText(): Text | null;
521 getLeafBlocksAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Block>;
522 getLeafInlinesAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Inline>;
523 getNode(path: Path): Node | null;
524 getNodesToPathsMap(): Map<Node, Immutable.List<number>>;
525 getMarks(): Immutable.OrderedSet<Mark>;
526 getMarksAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.OrderedSet<Mark>;
527 getMarksByType(type: string): Immutable.OrderedSet<Mark>;
528 getNextBlock(path: Path): Block | null;
529 getNextNode(path: Path): Node | null;
530 getNextSibling(path: Path): Node | null;
531 getNextText(path: Path): Text | null;
532 getOffset(path: Path): number;
533 getOffsetAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): number;
534 getParent(path: Path): Node | null;
535 getPath(key: Immutable.List<number> | string | Node): Immutable.List<number> | null;
536 getPreviousBlock(path: Path): Block | null;
537 getPreviousNode(path: Path): Node | null;
538 getPreviousSibling(path: Path): Node | null;
539 getPreviousText(path: Path): Text | null;
540 getRootBlocksAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Block>;
541 getRootInlinesAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Inline>;
542 getText(): string;
543 getTextAtOffset(offset: number): Text | null;
544 getTextDirection(): string | null;
545 getTexts(): Immutable.List<Text>;
546 getTextsAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Immutable.List<Text>;
547 hasBlockChildren(): boolean;
548 hasChild(path: Path): boolean;
549 hasInlineChildren(): boolean;
550 hasDescendant(path: Path): boolean;
551 hasNode(path: Path): boolean;
552 hasVoidParent(path: Path, editor: Editor): boolean;
553 inlines(
554 options?: IterableOptions & {
555 onlyLeaves?: boolean | undefined;
556 onlyRoots?: boolean | undefined;
557 onlyTypes?: string[] | undefined;
558 },
559 ): Iterable<[Inline, Immutable.List<number>]>;
560 insertNode(path: Path, node: Node): Node;
561 insertText(
562 path: Path,
563 offset: number,
564 text: string,
565 ): Node;
566 isLeafBlock(): this is Block;
567 isLeafInline(): this is Inline;
568 isInRange(path: Path, range: RangeTypeProperties | RangeTypeJSON | RangeType): boolean;
569 mapChildren(predicate?: (node: Node, index: number, nodes: Immutable.List<Node>) => Node): Node;
570 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
571 mapDescendants(predicate?: (node: Node, index: number, nodes: Immutable.List<Node>) => Node): Node | void;
572 marks(options?: IterableOptions & { onlyTypes: string[] }): Iterable<[Mark, Node, Immutable.List<number>]>;
573 mergeNode(path: Path): Node;
574 moveNode(path: Path, newPath: Path, newIndex?: number): Node;
575 normalize(editor: Editor): () => void | void;
576 regenerateKey(): Node;
577 removeMark(path: Path, mark: Mark): Node;
578 removeNode(path: Path): Node;
579 removeText(path: Path, offset: number, text: string): Node;
580 replaceNode(path: Path, node: Node): Node;
581 resolveAnnotation(annotation: Annotation | AnnotationProperties | AnnotationJSON): Annotation;
582 resolveDecoration(decoration: RangeType | RangeTypeProperties | RangeTypeJSON): Decoration;
583 resolvePath(path: Path, index?: number): Immutable.List<number>;
584 resolvePoint(point: Point | PointProperties | PointJSON): Point;
585 resolveRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Range;
586 resolveSelection(selection: Selection | SelectionProperties | SelectionJSON | Range): Selection;
587 setNode(path: Path, properties: NodeProperties): Node;
588 setMark(
589 path: Path,
590 properties: MarkProperties,
591 newProperties: MarkProperties,
592 ): Node;
593 siblings(path: Path, options?: IterableOptions): Iterable<[Node, Immutable.List<number>]>;
594 splitNode(path: Path, position: number, properties: NodeProperties): Node;
595 texts(options: IterableOptions): Iterable<[Text, Immutable.List<number>]>;
596 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
597 validate(editor: Editor): Error | void;
598
599 /**
600 * Deprecated.
601 */
602
603 getBlocksAtRange(range: RangeProperties | RangeJSON | Range): Immutable.List<Block>;
604 getBlocksAtRangeAsArray(range: RangeProperties | RangeJSON | Range): Block[];
605 getInlinesAtRange(range: RangeProperties | RangeJSON | Range): Immutable.List<Inline>;
606 getInlinesAtRangeAsArray(range: RangeProperties | RangeJSON | Range): Inline[];
607 getNextTextAndPath(path: Path): Text | null;
608 getNextDeepMatchingNodeAndPath(
609 path: Immutable.List<number>,
610 iterator?: () => boolean,
611 ): null | [Node, Immutable.List<number>];
612 getPreviousTextAndPath(path: Path): Text | null;
613 findFirstDescendantAndPath(
614 iterator: (
615 node: Node,
616 path: Immutable.List<number>,
617 nodes: Immutable.List<Node>,
618 ) => boolean,
619 pathToThisNode: Immutable.List<number>,
620 ): [Node, Immutable.List<number>] | null;
621 getPreviousMatchingNodeAndPath(
622 path: Immutable.List<number>,
623 iterator?: (node: Node) => boolean,
624 ): [Node, Immutable.List<number>] | null;
625 getPreviousDeepMatchingNodeAndPath(
626 path: Immutable.List<number>,
627 iterator?: (node: Node) => boolean,
628 ): [Node, Immutable.List<number>] | null;
629 findLastDescendantAndPath(
630 iterator: (
631 node: Node,
632 path: Immutable.List<number>,
633 nodes: Immutable.List<Node>,
634 ) => boolean,
635 pathToThisNode: Immutable.List<number>,
636 ): [Node, Immutable.List<number>] | null;
637 findDescendantAndPath(
638 iterator: (
639 node: Node,
640 path: Immutable.List<number>,
641 nodes: Immutable.List<Node>,
642 ) => boolean,
643 path?: Immutable.List<number>,
644 findLast?: boolean,
645 ): [Node, Immutable.List<number>] | null;
646 forEachDescendantWithPath(
647 iterator: (
648 node: Node,
649 path: Immutable.List<number>,
650 nodes: Immutable.List<Node>,
651 ) => boolean,
652 path?: Immutable.List<number>,
653 findLast?: boolean,
654 ): boolean;
655 getNextMatchingNodeAndPath(
656 path: Immutable.List<number>,
657 iterator?: (node: Node) => boolean,
658 ): [Node, Immutable.List<number>] | null;
659 getSelectionIndexes(range: RangeType, isSelected?: boolean): { start: number; end: number } | boolean | null;
660 getTextsBetweenPositionsAsArray(startPath: Path, endPath: Path): Array<Node | null>;
661 getOrderedMarksBetweenPositions(
662 startPath: Path,
663 startOffset: number,
664 endPath: Path,
665 endOffset: number,
666 ): Immutable.OrderedSet<Mark>;
667 getTextsBetweenPathPositionsAsArray(
668 startPath: Immutable.List<number>,
669 endPath: Immutable.List<number>,
670 ): Array<Node | null>;
671 getFurthestAncestor(path: Path): Node | null;
672 getLeafBlocksAtRangeAsArray(range: Range | RangeProperties | RangeJSON): Block[];
673 getLeafBlocksBetweenPathPositionsAsArray(
674 startPath: Immutable.List<number>,
675 endPath: Immutable.List<number>,
676 ): Block[];
677 getBlocksAsArray(): Block[];
678 getBlocksByTypeAsArray(type: string): Block[];
679 getFurthestOnlyChildAncestor(path: Path): Node | null;
680 getInlinesAsArray(): Inline[];
681 getInlinesByTypeAsArray(type: string): Inline[];
682 getLeafInlinesAtRangeAsArray(range: Range | RangeProperties | RangeJSON): Inline[];
683 getOrderedMarks(): Immutable.OrderedSet<Mark>;
684 getOrderedMarksAtRange(range: RangeProperties | RangeJSON | Range): Immutable.OrderedSet<Mark>;
685 getOrderedMarksByType(type: string): Immutable.OrderedSet<Mark>;
686 getOrderedMarksByTypeAsArray(type: string): Mark[];
687 getMarksAsArray(): Mark[];
688 getRootInlinesAtRangeAsArray(range: RangeProperties | RangeJSON | Range): Inline[];
689 getTextsAsArray(): Text[];
690 getTextsAtRangeAsArray(range: RangeProperties | RangeJSON | Range): Text[];
691 getMarksAtPosition(path: Path, offset: number): Immutable.OrderedSet<Mark>;
692 getNodesAtRange(range: RangeProperties | RangeJSON | Range): boolean;
693 isNodeInRange(path: Path, range: RangeProperties | RangeJSON | Range): boolean;
694
695 /**
696 * Assertion variants.
697 */
698
699 assertChild(path: Path): Node;
700 assertDepth(path: Path, startAt?: number): number;
701 assertDescendant(path: Path): Node;
702 assertNode(path: Path): Node;
703 assertParent(path: Path): Node;
704 assertPath(key: Path): Immutable.List<number>;
705}
706
707export interface MarkProperties {
708 object?: "mark" | undefined;
709 type: string;
710 data?: Data | { [key: string]: any } | undefined;
711}
712
713export interface MarkJSON {
714 object?: "mark" | undefined;
715 type: string;
716 data?: { [key: string]: any } | undefined;
717}
718
719export class Mark extends Immutable.Record({}) {
720 object: "mark";
721 type: string;
722 data: Data;
723
724 static create(properties: MarkProperties | MarkJSON | Mark | string): Mark;
725 static createSet(
726 element?:
727 | Array<MarkProperties | MarkJSON | Mark | string>
728 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
729 ): Immutable.Set<Mark>;
730 static createProperties(attrs: Partial<MarkProperties | MarkJSON | Mark | string>): MarkProperties;
731 static fromJSON(properties: MarkProperties | MarkJSON | Mark): Mark;
732 static fromJS(properties: MarkProperties | MarkJSON | Mark): Mark;
733 static isMark(maybeMark: any): maybeMark is Mark;
734 static isMarkSet(maybeMarkSet: any): maybeMarkSet is Immutable.Set<Mark>;
735
736 toJSON(): MarkJSON;
737 toJS(): MarkJSON;
738}
739
740export interface SelectionProperties {
741 object?: "selection" | undefined;
742 anchor?: Point | undefined;
743 focus?: Point | undefined;
744 isFocused?: boolean | undefined;
745 marks?: Immutable.Set<Mark> | Mark[] | undefined;
746}
747
748export interface SelectionJSON {
749 object?: "selection" | undefined;
750 anchor?: PointJSON | undefined;
751 focus?: PointJSON | undefined;
752 isFocused?: boolean | undefined;
753 marks?: MarkJSON[] | undefined;
754}
755
756export class Selection extends BaseRange {
757 object: "selection";
758 anchor: Point;
759 focus: Point;
760 isFocused: boolean;
761 marks: Immutable.Set<Mark>;
762
763 readonly isBlurred: boolean;
764
765 static create(
766 properties:
767 | RangeTypeProperties
768 | RangeTypeJSON
769 | RangeType,
770 ): Selection;
771 static createProperties(
772 attrs:
773 | RangeTypeProperties
774 | RangeTypeJSON
775 | RangeType
776 | string,
777 ): SelectionProperties;
778 static fromJSON(
779 properties:
780 | RangeTypeProperties
781 | RangeTypeJSON,
782 ): Selection;
783 static fromJS(
784 properties:
785 | RangeTypeProperties
786 | RangeTypeJSON,
787 ): Selection;
788
789 toJSON(): SelectionJSON;
790 toJS(): SelectionJSON;
791
792 isSelection(maybeSelection: any): maybeSelection is Selection;
793 setIsFocused(value: boolean): Selection;
794 setMarks(marks: Immutable.Set<Mark>): Selection;
795 setProperties(
796 properties:
797 | RangeTypeProperties
798 | RangeTypeJSON
799 | RangeType
800 | string,
801 ): Selection;
802}
803
804export interface RangeProperties {
805 object?: "range" | undefined;
806 anchor?: Point | undefined;
807 focus?: Point | undefined;
808}
809
810export interface RangeJSON {
811 object?: "range" | undefined;
812 anchor?: PointJSON | undefined;
813 focus?: PointJSON | undefined;
814}
815
816export class Range extends BaseRange {
817 object: "range";
818 anchor: Point;
819 focus: Point;
820
821 static create(properties: RangeTypeProperties | RangeTypeJSON | RangeType): Range;
822 static createList(
823 elements?:
824 | Array<RangeTypeProperties | RangeTypeJSON | RangeType>
825 | Immutable.List<RangeTypeProperties | RangeTypeJSON | RangeType>,
826 ): Immutable.List<Range>;
827 static createProperties(
828 attrs: RangeTypeProperties | RangeTypeJSON | RangeType,
829 ): RangeProperties;
830 static fromJSON(properties: RangeTypeJSON): Range;
831 static fromJS(properties: RangeTypeJSON): Range;
832 static isRange(maybeRange: any): maybeRange is RangeType;
833
834 toJSON(options?: { preserveKeys?: boolean | undefined }): RangeJSON;
835 toJS(options?: { preserveKeys?: boolean | undefined }): RangeJSON;
836}
837
838export interface DecorationProperties {
839 object?: "decoration" | undefined;
840 anchor?: Point | undefined;
841 focus?: Point | undefined;
842 type?: string | undefined;
843 data?: Data | { [key: string]: any } | undefined;
844}
845
846export interface DecorationJSON {
847 object?: "decoration" | undefined;
848 anchor?: PointJSON | undefined;
849 focus?: PointJSON | undefined;
850 type?: string | undefined;
851 data?: { [key: string]: any } | undefined;
852}
853
854export class Decoration extends BaseRange {
855 object: "decoration";
856 anchor: Point;
857 focus: Point;
858 type: string;
859 data: Data;
860
861 static create(
862 properties:
863 | RangeTypeProperties
864 | RangeTypeJSON
865 | RangeType,
866 ): Decoration;
867 static createList(
868 elements?:
869 | Array<RangeTypeProperties | RangeTypeJSON | RangeType>
870 | Immutable.List<RangeTypeProperties | RangeTypeJSON | RangeType>,
871 ): Immutable.List<Decoration>;
872 static createProperties(
873 attrs: RangeTypeProperties | RangeTypeJSON | RangeType,
874 ): DecorationProperties;
875 static fromJSON(properties: DecorationJSON & { mark?: MarkJSON | undefined }): Decoration;
876 static fromJSON(properties: DecorationJSON & { mark?: MarkJSON | undefined }): Decoration;
877 static isDecoration(maybeDecoration: any): maybeDecoration is Decoration;
878
879 setProperties(properties: RangeTypeProperties | RangeTypeJSON | RangeType): Decoration;
880
881 toJSON(): DecorationJSON;
882 toJS(): DecorationJSON;
883}
884
885export interface AnnotationProperties {
886 object?: "annotation" | undefined;
887 key: string;
888 type: string;
889 data?: Data | { [key: string]: any } | undefined;
890 anchor?: Point | undefined;
891 focus?: Point | undefined;
892}
893
894export interface AnnotationJSON {
895 object?: "annotation" | undefined;
896 key: string;
897 type: string;
898 data?: { [key: string]: any } | undefined;
899 anchor?: PointJSON | undefined;
900 focus?: PointJSON | undefined;
901}
902
903export class Annotation extends BaseRange {
904 object: "annotation";
905 key: string;
906 type: string;
907 data: Data;
908 anchor: Point;
909 focus: Point;
910
911 static create(properties: Annotation | AnnotationProperties | AnnotationJSON): Annotation;
912 static createMap(
913 elements?:
914 | { [key: string]: Annotation | AnnotationProperties | AnnotationJSON }
915 | Immutable.Map<string, Annotation>,
916 ): Immutable.Map<string, Annotation>;
917 static createProperties(
918 attrs: AnnotationProperties | AnnotationJSON | Annotation,
919 ): AnnotationProperties;
920 static fromJSON(properties: AnnotationProperties | AnnotationJSON): Annotation;
921 static fromJS(properties: AnnotationProperties | AnnotationJSON): Annotation;
922 static isAnnotation(maybeAnnotation: any): maybeAnnotation is Annotation;
923
924 toJSON(): AnnotationJSON;
925 toJS(): AnnotationJSON;
926
927 setProperties(properties: AnnotationProperties | AnnotationJSON | Annotation): Annotation;
928}
929
930export type RangeTypeProperties =
931 | RangeProperties
932 | SelectionProperties
933 | DecorationProperties
934 | AnnotationProperties;
935
936export type RangeTypeJSON = RangeJSON | SelectionJSON | DecorationJSON | AnnotationJSON;
937export type RangeType = Range | Selection | Decoration | Annotation;
938
939declare class BaseRange extends Immutable.Record({}) {
940 readonly isCollapsed: boolean;
941 readonly isExpanded: boolean;
942 readonly isBackward: boolean;
943 readonly isForward: boolean;
944 readonly isUnset: boolean;
945 readonly isSet: boolean;
946 readonly start: Point;
947 readonly end: Point;
948
949 flip(): RangeType;
950 moveForward(n?: number): RangeType;
951 moveBackward(n?: number): RangeType;
952
953 moveAnchorBackward(n?: number): RangeType;
954 moveAnchorForward(n?: number): RangeType;
955 moveAnchorTo(path: string | number | Immutable.List<number>, offset?: number): RangeType;
956 moveAnchorToStartOfNode(node: Node): RangeType;
957 moveAnchorToEndOfNode(node: Node): RangeType;
958
959 moveEndBackward(n?: number): RangeType;
960 moveEndForward(n?: number): RangeType;
961 moveEndTo(path: string | number | Immutable.List<number>, offset?: number): RangeType;
962 moveEndToStartOfNode(node: Node): RangeType;
963 moveEndToEndOfNode(node: Node): RangeType;
964
965 moveFocusBackward(n?: number): RangeType;
966 moveFocusForward(n?: number): RangeType;
967 moveFocusTo(path: string | number | Immutable.List<number>, offset?: number): RangeType;
968 moveFocusToStartOfNode(node: Node): RangeType;
969 moveFocusToEndOfNode(node: Node): RangeType;
970
971 moveStartBackward(n?: number): RangeType;
972 moveStartForward(n?: number): RangeType;
973 moveStartTo(path: string | number | Immutable.List<number>, offset?: number): RangeType;
974 moveStartToStartOfNode(node: Node): RangeType;
975 moveStartToEndOfNode(node: Node): RangeType;
976
977 moveToAnchor(): RangeType;
978 moveToEnd(): RangeType;
979 moveToEndOfNode(node: Node): RangeType;
980 moveToFocus(): RangeType;
981 moveToRangeOfNode(start: Node, end?: Node): RangeType;
982 moveToStart(): RangeType;
983 moveToStartOfNode(node: Node): RangeType;
984
985 normalize(node: Node): RangeType;
986
987 setAnchor(anchor: Point): RangeType;
988 setEnd(point: Point): RangeType;
989 setFocus(focus: Point): RangeType;
990 setIsAtomic(value: boolean): RangeType;
991 setIsFocused(value: boolean): RangeType;
992 setMarks(marks: Immutable.Set<Mark>): RangeType;
993 setPoints(values: Point[]): RangeType;
994 updatePoints(updater: (point: Point) => Point): RangeType;
995 setStart(point: Point): RangeType;
996 setProperties(
997 properties: RangeTypeProperties | RangeTypeJSON | RangeType,
998 ): RangeType;
999
1000 toJSON(): RangeTypeJSON;
1001 toJS(): RangeTypeJSON;
1002 toRange(): RangeType;
1003 unset(): RangeType;
1004}
1005
1006export interface PointProperties {
1007 object?: "point" | undefined;
1008 key?: string | undefined;
1009 offset?: number | undefined;
1010 path?: Immutable.List<number> | undefined;
1011}
1012
1013export interface PointJSON {
1014 object?: "point" | undefined;
1015 key?: string | undefined;
1016 offset?: number | undefined;
1017 path?: number[] | undefined;
1018}
1019
1020export class Point extends Immutable.Record({}) {
1021 object: "point";
1022 key: string;
1023 offset: number;
1024 path: Immutable.List<number>;
1025
1026 static create(properties: PointProperties | PointJSON | Point): Point;
1027 static createProperties(properties: PointProperties | PointJSON | Point): Point;
1028 static fromJSON(properties: PointJSON | PointProperties): Point;
1029 static fromJS(properties: PointJSON | PointProperties): Point;
1030 static isPoint(maybePoint: any): maybePoint is Point;
1031
1032 readonly isSet: boolean;
1033 readonly isUnset: boolean;
1034
1035 isAfterPoint(point: Point): boolean;
1036 isAfterRange(range: RangeType): boolean;
1037 isAtEndofRange(range: RangeType): boolean;
1038 isAtStartOfRange(range: RangeType): boolean;
1039 isBeforePoint(point: Point): boolean;
1040 isBeforeRange(range: RangeType): boolean;
1041 isInRange(range: RangeType): boolean;
1042 isAtEndOfNode(node: Node): boolean;
1043 isAtStartOfNode(node: Node): boolean;
1044 isInNode(node: Node): boolean;
1045
1046 moveBackward(n?: number): this;
1047 moveForward(n?: number): this;
1048 moveTo(path: string | number | Immutable.List<number>, offset?: number): this;
1049 moveToStartOfNode(node: Node): this;
1050 moveToEndOfNode(node: Node): this;
1051 normalize(node: Node): this;
1052 setKey(key: string): this;
1053 setOffset(offset: number): this;
1054 setPath(path: Immutable.List<number> | number[]): this;
1055 toJSON(options?: { preserveKeys?: boolean | undefined }): PointJSON;
1056 toJS(options?: { preserveKeys?: boolean | undefined }): PointJSON;
1057 unset(): this;
1058}
1059
1060export type Operation =
1061 | InsertTextOperation
1062 | RemoveTextOperation
1063 | AddMarkOperation
1064 | RemoveMarkOperation
1065 | SetMarkOperation
1066 | AddAnnotationOperation
1067 | RemoveAnnotationOperation
1068 | SetAnnotationOperation
1069 | InsertNodeOperation
1070 | MergeNodeOperation
1071 | MoveNodeOperation
1072 | RemoveNodeOperation
1073 | SetNodeOperation
1074 | SplitNodeOperation
1075 | SetSelectionOperation
1076 | SetValueOperation;
1077
1078export interface OperationProperties {
1079 object?: "operation" | undefined;
1080 type: string;
1081 text?: string | undefined;
1082 target?: number | undefined;
1083 properties?:
1084 | NodeProperties
1085 | ValueProperties
1086 | SelectionProperties
1087 | AnnotationProperties
1088 | undefined;
1089 position?: number | undefined;
1090 path?: Immutable.List<number> | undefined;
1091 offset?: number | undefined;
1092 node?: Node | undefined;
1093 newProperties?:
1094 | NodeProperties
1095 | ValueProperties
1096 | SelectionProperties
1097 | MarkProperties
1098 | AnnotationProperties
1099 | undefined;
1100 newPath?: Immutable.List<number> | undefined;
1101 mark?: Mark | undefined;
1102 data?: Data | { [key: string]: any } | undefined;
1103 annotation?: Annotation | undefined;
1104}
1105
1106export interface OperationJSON {
1107 object?: "operation" | undefined;
1108 type: string;
1109 text?: string | undefined;
1110 target?: number | undefined;
1111 properties?:
1112 | NodeJSON
1113 | ValueJSON
1114 | SelectionJSON
1115 | AnnotationJSON
1116 | undefined;
1117 position?: number | undefined;
1118 path?: number[] | undefined;
1119 offset?: number | undefined;
1120 node?: Node | undefined;
1121 newProperties?:
1122 | NodeJSON
1123 | ValueJSON
1124 | SelectionJSON
1125 | MarkJSON
1126 | AnnotationJSON
1127 | undefined;
1128 newPath?: number[] | undefined;
1129 mark?: MarkJSON | undefined;
1130 data?: { [key: string]: any } | undefined;
1131 annotation?: AnnotationJSON | undefined;
1132}
1133
1134export class BaseOperation extends Immutable.Record({}) {
1135 object: "operation";
1136 type: string;
1137
1138 static create(attrs?: Operation | OperationProperties | OperationJSON): Operation;
1139 static createList():
1140 | Immutable.List<Operation | OperationProperties | OperationJSON>
1141 | Array<Operation | OperationProperties | OperationJSON>;
1142
1143 static fromJSON(object: OperationProperties | OperationJSON): Operation;
1144 static fromJS(object: OperationProperties | OperationJSON): Operation;
1145
1146 static isOperation(maybeOperation: any): maybeOperation is Operation;
1147 static isOperationList(maybeOperationList: any): maybeOperationList is Immutable.List<Operation>;
1148
1149 toJSON(): OperationJSON;
1150
1151 apply(value: Value): Value;
1152 invert(): this;
1153}
1154
1155export class InsertTextOperation extends BaseOperation {
1156 type: "insert_text";
1157 path: Immutable.List<number>;
1158 offset: number;
1159 text: string;
1160 data: Data;
1161}
1162
1163export class RemoveTextOperation extends BaseOperation {
1164 type: "remove_text";
1165 path: Immutable.List<number>;
1166 offset: number;
1167 text: string;
1168 data: Data;
1169}
1170
1171export class AddMarkOperation extends BaseOperation {
1172 type: "add_mark";
1173 path: Immutable.List<number>;
1174 mark: Mark;
1175 data: Data;
1176}
1177
1178export class RemoveMarkOperation extends BaseOperation {
1179 type: "remove_mark";
1180 path: Immutable.List<number>;
1181 mark: Mark;
1182 data: Data;
1183}
1184
1185export class SetMarkOperation extends BaseOperation {
1186 type: "set_mark";
1187 path: Immutable.List<number>;
1188 properties: MarkProperties;
1189 newProperties: MarkProperties;
1190 data: Data;
1191}
1192
1193export class AddAnnotationOperation extends BaseOperation {
1194 type: "add_annotation";
1195 annotation: Annotation;
1196 data: Data;
1197}
1198
1199export class RemoveAnnotationOperation extends BaseOperation {
1200 type: "remove_annotation";
1201 annotation: Annotation;
1202 data: Data;
1203}
1204
1205export class SetAnnotationOperation extends BaseOperation {
1206 type: "set_annotation";
1207 properties: AnnotationProperties;
1208 newProperties: AnnotationProperties;
1209 data: Data;
1210}
1211
1212export class InsertNodeOperation extends BaseOperation {
1213 type: "insert_node";
1214 path: Immutable.List<number>;
1215 node: Node;
1216 data: Data;
1217}
1218
1219export class MergeNodeOperation extends BaseOperation {
1220 type: "merge_node";
1221 path: Immutable.List<number>;
1222 position: number;
1223 properties: NodeProperties;
1224 data: Data;
1225}
1226
1227export class MoveNodeOperation extends BaseOperation {
1228 type: "move_node";
1229 path: Immutable.List<number>;
1230 newPath: Immutable.List<number>;
1231 data: Data;
1232}
1233
1234export class RemoveNodeOperation extends BaseOperation {
1235 type: "remove_node";
1236 path: Immutable.List<number>;
1237 node: Node;
1238 data: Data;
1239}
1240
1241export class SetNodeOperation extends BaseOperation {
1242 type: "set_node";
1243 path: Immutable.List<number>;
1244 properties: NodeProperties;
1245 newProperties: NodeProperties;
1246 data: Data;
1247}
1248
1249export class SplitNodeOperation extends BaseOperation {
1250 type: "split_node";
1251 path: Immutable.List<number>;
1252 position: number;
1253 target: number;
1254 properties: NodeProperties;
1255 data: Data;
1256}
1257
1258export class SetSelectionOperation extends BaseOperation {
1259 type: "set_selection";
1260 properties: SelectionProperties;
1261 newProperties: SelectionProperties;
1262 data: Data;
1263}
1264
1265export class SetValueOperation extends BaseOperation {
1266 type: "set_value";
1267 properties: ValueProperties;
1268 newProperties: ValueProperties;
1269 data: Data;
1270}
1271
1272export type ErrorCode =
1273 | "child_max_invalid"
1274 | "child_min_invalid"
1275 | "child_object_invalid"
1276 | "child_required"
1277 | "child_type_invalid"
1278 | "child_unknown"
1279 | "first_child_object_invalid"
1280 | "first_child_type_invalid"
1281 | "last_child_object_invalid"
1282 | "last_child_type_invalid"
1283 | "next_sibling_object_invalid"
1284 | "next_sibling_type_invalid"
1285 | "node_data_invalid"
1286 | "node_is_void_invalid"
1287 | "node_mark_invalid"
1288 | "node_object_invalid"
1289 | "node_text_invalid"
1290 | "node_type_invalid"
1291 | "parent_object_invalid"
1292 | "parent_type_invalid"
1293 | "previous_sibling_object_invalid"
1294 | "previous_sibling_type_invalid";
1295
1296export class SlateError extends Error {
1297 code: ErrorCode;
1298 [key: string]: any;
1299}
1300
1301export namespace KeyUtils {
1302 function create(key?: string): string;
1303 function setGenerator(func: () => any): void;
1304 function resetGenerator(): void;
1305}
1306
1307export type useMemoization = (enabled: boolean) => void;
1308export type resetMemoization = () => void;
1309
1310export namespace PathUtils {
1311 /**
1312 * Compare paths `path` and `target` to see which is before or after.
1313 */
1314 function compare(
1315 path: Immutable.List<number>,
1316 target: Immutable.List<number>,
1317 ): number | null;
1318
1319 /**
1320 * Create a path from `attrs`.
1321 */
1322 function create(
1323 attrs: Immutable.List<number> | number[],
1324 ): Immutable.List<number>;
1325
1326 /**
1327 * Crop paths `a` and `b` to an equal size, defaulting to the shortest.
1328 */
1329 function crop(
1330 a: Immutable.List<number>,
1331 b: Immutable.List<number>,
1332 size?: number,
1333 ): Array<Immutable.List<number>>;
1334
1335 /**
1336 * Decrement a `path` by `n` at `index`, defaulting to the last index.
1337 */
1338 function decrement(
1339 path: Immutable.List<number>,
1340 n?: number,
1341 index?: number,
1342 ): Immutable.List<number>;
1343
1344 /**
1345 * Get all ancestor paths of the given path.
1346 */
1347 function getAncestors(
1348 path: Immutable.List<number>,
1349 ): Immutable.List<number>;
1350
1351 /**
1352 * Increment a `path` by `n` at `index`, defaulting to the last index.
1353 */
1354 function increment(
1355 path: Immutable.List<number>,
1356 n?: number,
1357 index?: number,
1358 ): Immutable.List<number>;
1359
1360 /**
1361 * Is a `path` above another `target` path?
1362 */
1363 function isAbove(
1364 path: Immutable.List<number>,
1365 target: Immutable.List<number>,
1366 ): boolean;
1367
1368 /**
1369 * Is a `path` after another `target` path in a document?
1370 */
1371 function isAfter(
1372 path: Immutable.List<number>,
1373 target: Immutable.List<number>,
1374 ): boolean;
1375
1376 /**
1377 * Is a `path` before another `target` path in a document?
1378 */
1379 function isBefore(
1380 path: Immutable.List<number>,
1381 target: Immutable.List<number>,
1382 ): boolean;
1383
1384 /**
1385 * Is a `path` equal to another `target` path in a document?
1386 */
1387 function isEqual(
1388 path: Immutable.List<number>,
1389 target: Immutable.List<number>,
1390 ): boolean;
1391
1392 /**
1393 * Is a `path` older than a `target` path? Meaning that it ends as an older
1394 * sibling of one of the indexes in the target.
1395 */
1396 function isOlder(
1397 path: Immutable.List<number>,
1398 target: Immutable.List<number>,
1399 ): boolean;
1400
1401 /**
1402 * Is an `any` object a path?
1403 */
1404 function isPath(
1405 maybePath: any,
1406 ): maybePath is Immutable.List<number> | number[];
1407
1408 /**
1409 * Is a `path` a sibling of a `target` path?
1410 */
1411 function isSibling(
1412 path: Immutable.List<number>,
1413 target: Immutable.List<number>,
1414 ): boolean;
1415
1416 /**
1417 * Is a `path` younger than a `target` path? Meaning that it ends as a younger
1418 * sibling of one of the indexes in the target.
1419 */
1420 function isYounger(
1421 path: Immutable.List<number>,
1422 target: Immutable.List<number>,
1423 ): boolean;
1424
1425 /**
1426 * Lift a `path` to refer to its `n`th ancestor.
1427 */
1428 function lift(
1429 path: Immutable.List<number>,
1430 n?: number,
1431 ): Immutable.List<number>;
1432
1433 /**
1434 * Drop a `path`, returning a relative path from a depth of `n`.
1435 */
1436 function drop(
1437 path: Immutable.List<number>,
1438 n?: number,
1439 ): Immutable.List<number>;
1440
1441 /**
1442 * Get the maximum length of paths `a` and `b`.
1443 */
1444 function max(
1445 a: Immutable.List<number>,
1446 b: Immutable.List<number>,
1447 ): number;
1448
1449 /**
1450 * Get the minimum length of paths `a` and `b`.
1451 */
1452 function min(
1453 a: Immutable.List<number>,
1454 b: Immutable.List<number>,
1455 ): number;
1456
1457 /**
1458 * Get the common ancestor path of path `a` and path `b`.
1459 */
1460 function relate(
1461 a: Immutable.List<number>,
1462 b: Immutable.List<number>,
1463 ): Immutable.List<number>;
1464
1465 /**
1466 * Transform a `path` by an `operation`, adjusting it to stay current.
1467 */
1468 function transform(
1469 path: Immutable.List<number>,
1470 operation: Operation | OperationJSON | OperationProperties,
1471 ): Immutable.List<Immutable.List<number>>;
1472}
1473
1474export interface Command {
1475 type: string;
1476 args: any[];
1477}
1478
1479export interface Query {
1480 type: string;
1481 args: any[];
1482}
1483
1484export type CommandFunc<T extends Controller = Controller> = (editor: T, ...args: any[]) => T;
1485export type QueryFunc<T extends Controller = Controller> = (editor: T, ...args: any[]) => any;
1486
1487export interface Plugin<T extends Controller = Controller> {
1488 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
1489 normalizeNode?: ((node: Node, editor: T, next: () => void) => ((editor: T) => void) | void) | undefined;
1490 onChange?: ((editor: T, next: () => void) => void) | undefined;
1491 onCommand?: ((command: Command, editor: T, next: () => void) => void) | undefined;
1492 onConstruct?: ((editor: T, next: () => void) => void) | undefined;
1493 onQuery?: ((query: Query, editor: T, next: () => void) => void) | undefined;
1494 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
1495 validateNode?: ((node: Node, editor: T, next: () => void) => SlateError | void) | undefined;
1496
1497 commands?: { [name: string]: CommandFunc<T> } | undefined;
1498 queries?: { [name: string]: QueryFunc<T> } | undefined;
1499 schema?: SchemaProperties | undefined;
1500}
1501
1502export interface Plugins<T extends Controller = Controller> extends Array<Plugin<T> | Plugins<T>> {}
1503
1504export interface EditorProperties<T extends Controller = Controller> {
1505 object?: "editor" | undefined;
1506 onChange?: ((change: { operations: Immutable.List<Operation>; value: Value }) => void) | undefined;
1507 plugins?: Plugins<T> | undefined;
1508 readOnly?: boolean | undefined;
1509 value?: Value | undefined;
1510}
1511
1512export interface EditorOptions {
1513 controller?: Controller | undefined;
1514 construct?: boolean | undefined;
1515 normalize?: boolean | undefined;
1516}
1517
1518export class Editor implements Controller {
1519 object: "editor";
1520 controller: Controller;
1521 middleware: object;
1522 onChange: (change: { operations: Immutable.List<Operation>; value: Value }) => void;
1523 operations: Immutable.List<Operation>;
1524 plugins: Array<Plugin<Editor>>;
1525 readOnly: boolean;
1526 value: Value;
1527
1528 constructor(attributes: EditorProperties<Editor>, options?: EditorOptions);
1529
1530 /**
1531 * Synchronously flush the current changes to editor, calling onChange.
1532 * In normal operation you never need to use this method! Reserved for testing.
1533 */
1534 flush(): Editor;
1535
1536 setReadOnly(readOnly: boolean): Editor;
1537
1538 /**
1539 * Set the editor's value state.
1540 * You can optionally provide a normalize option to either for the editor to completely re-normalize the new value based on its schema or not.
1541 * By default, the editor will re-normalize only if the value is not equal to its previously seen value (which it knows was normalized).
1542 */
1543 setValue(value: Value, options?: { normalize: boolean }): Editor;
1544
1545 isEditor(maybeEditor: any): maybeEditor is Editor;
1546
1547 addMark(mark: string | MarkProperties | MarkJSON | Mark): Editor;
1548 addMarks(
1549 mark: Set<string | MarkProperties | MarkJSON | Mark> | Array<string | MarkProperties | MarkJSON | Mark>,
1550 ): Editor;
1551 delete(): Editor;
1552 deleteBackward(n?: number): Editor;
1553 deleteForward(n?: number): Editor;
1554 insertBlock(block: string | Block | BlockProperties | BlockJSON): Editor;
1555 insertFragment(fragment: Document): Editor;
1556 insertInline(inline: string | Inline | InlineProperties | InlineJSON): Editor;
1557 insertText(
1558 text: string,
1559 marks?:
1560 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>
1561 | Array<string | MarkProperties | MarkJSON | Mark>,
1562 ): Editor;
1563 setBlocks(properties: string | Block | BlockProperties | BlockJSON): Editor;
1564 setInlines(properties: string | Inline | InlineProperties): Editor;
1565 splitBlock(depth?: number): Editor;
1566 splitInline(depth: number): Editor;
1567 removeMark(mark: string | MarkProperties | MarkJSON | Mark): Editor;
1568 replaceMark(
1569 mark: string | MarkProperties | MarkJSON | Mark,
1570 newMark: string | MarkProperties | MarkJSON | Mark,
1571 ): Editor;
1572 toggleMark(mark: string | MarkProperties | MarkJSON | Mark): Editor;
1573 unwrapBlock(properties: string | Block | BlockProperties | BlockJSON): Editor;
1574 unwrapInline(properties: string | Inline | InlineProperties | InlineJSON): Editor;
1575 wrapBlock(properties: string | Block | BlockProperties | BlockJSON): Editor;
1576 wrapInline(properties: string | Inline | InlineProperties | InlineJSON): Editor;
1577 wrapText(prefix: string, suffix?: string): Editor;
1578 blur(): Editor;
1579 deselect(): Editor;
1580 flip(): Editor;
1581 focus(): Editor;
1582 moveAnchorBackward(n?: number): Editor;
1583 moveAnchorWordBackward(): Editor;
1584 moveAnchorForward(n?: number): Editor;
1585 moveAnchorWordForward(): Editor;
1586 moveAnchorTo(path: string | number | Immutable.List<number>, offset?: number): Editor;
1587 moveAnchorToEndOfBlock(): Editor;
1588 moveAnchorToEndOfInline(): Editor;
1589 moveAnchorToEndOfDocument(): Editor;
1590 moveAnchorToEndOfNextBlock(): Editor;
1591 moveAnchorToEndOfNextInline(): Editor;
1592 moveAnchorToEndOfNextText(): Editor;
1593 moveAnchorToEndOfNode(node: Block | Document | Inline | Text): Editor;
1594 moveAnchorToEndOfPreviousBlock(): Editor;
1595 moveAnchorToEndOfPreviousInline(): Editor;
1596 moveAnchorToEndOfPreviousText(): Editor;
1597 moveAnchorToEndOfText(): Editor;
1598 moveAnchorToStartOfBlock(): Editor;
1599 moveAnchorToStartOfDocument(): Editor;
1600 moveAnchorToStartOfInline(): Editor;
1601 moveAnchorToStartOfNextBlock(): Editor;
1602 moveAnchorToStartOfNextInline(): Editor;
1603 moveAnchorToStartOfNextText(): Editor;
1604 moveAnchorToStartOfNode(node: Block | Document | Inline | Text): Editor;
1605 moveAnchorToStartOfPreviousBlock(): Editor;
1606 moveAnchorToStartOfPreviousInline(): Editor;
1607 moveAnchorToStartOfPreviousText(): Editor;
1608 moveAnchorToStartOfText(): Editor;
1609 moveEndBackward(n?: number): Editor;
1610 moveEndForward(n?: number): Editor;
1611 moveEndTo(path: string | number | Immutable.List<number>, offset?: number): Editor;
1612 moveEndToEndOfBlock(): Editor;
1613 moveEndToEndOfDocument(): Editor;
1614 moveEndToEndOfInline(): Editor;
1615 moveEndToEndOfNextBlock(): Editor;
1616 moveEndToEndOfNextInline(): Editor;
1617 moveEndToEndOfNextText(): Editor;
1618 moveEndToEndOfNode(node: Block | Document | Inline | Text): Editor;
1619 moveEndToEndOfPreviousBlock(): Editor;
1620 moveEndToEndOfPreviousInline(): Editor;
1621 moveEndToEndOfPreviousText(): Editor;
1622 moveEndToEndOfText(): Editor;
1623 moveEndToStartOfBlock(): Editor;
1624 moveEndToStartOfDocument(): Editor;
1625 moveEndToStartOfInline(): Editor;
1626 moveEndToStartOfNextBlock(): Editor;
1627 moveEndToStartOfNextInline(): Editor;
1628 moveEndToStartOfNextText(): Editor;
1629 moveEndToStartOfNode(node: Block | Document | Inline | Text): Editor;
1630 moveEndToStartOfPreviousBlock(): Editor;
1631 moveEndToStartOfPreviousInline(): Editor;
1632 moveEndToStartOfPreviousText(): Editor;
1633 moveEndToStartOfText(): Editor;
1634 moveEndWordBackward(): Editor;
1635 moveEndWordForward(): Editor;
1636 moveFocusBackward(n?: number): Editor;
1637 moveFocusForward(n?: number): Editor;
1638 moveFocusTo(path: string | number | Immutable.List<number>, offset?: number): Editor;
1639 moveFocusToEndOfBlock(): Editor;
1640 moveFocusToEndOfDocument(): Editor;
1641 moveFocusToEndOfInline(): Editor;
1642 moveFocusToEndOfNextBlock(): Editor;
1643 moveFocusToEndOfNextInline(): Editor;
1644 moveFocusToEndOfNextText(): Editor;
1645 moveFocusToEndOfNode(node: Block | Document | Inline | Text): Editor;
1646 moveFocusToEndOfPreviousBlock(): Editor;
1647 moveFocusToEndOfPreviousInline(): Editor;
1648 moveFocusToEndOfPreviousText(): Editor;
1649 moveFocusToEndOfText(): Editor;
1650 moveFocusToStartOfBlock(): Editor;
1651 moveFocusToStartOfDocument(): Editor;
1652 moveFocusToStartOfInline(): Editor;
1653 moveFocusToStartOfNextBlock(): Editor;
1654 moveFocusToStartOfNextInline(): Editor;
1655 moveFocusToStartOfNextText(): Editor;
1656 moveFocusToStartOfNode(node: Block | Document | Inline | Text): Editor;
1657 moveFocusToStartOfPreviousBlock(): Editor;
1658 moveFocusToStartOfPreviousInline(): Editor;
1659 moveFocusToStartOfPreviousText(): Editor;
1660 moveFocusToStartOfText(): Editor;
1661 moveFocusWordBackward(): Editor;
1662 moveFocusWordForward(): Editor;
1663 moveStartForward(n?: number): Editor;
1664 moveStartBackward(n?: number): Editor;
1665 moveStartTo(path: string | number | Immutable.List<number>, n?: number): Editor;
1666 moveStartToEndOfBlock(): Editor;
1667 moveStartToEndOfDocument(): Editor;
1668 moveStartToEndOfInline(): Editor;
1669 moveStartToEndOfNextBlock(): Editor;
1670 moveStartToEndOfNextInline(): Editor;
1671 moveStartToEndOfNextText(): Editor;
1672 moveStartToEndOfNode(node: Block | Document | Inline | Text): Editor;
1673 moveStartToEndOfPreviousBlock(): Editor;
1674 moveStartToEndOfPreviousInline(): Editor;
1675 moveStartToEndOfPreviousText(): Editor;
1676 moveStartToEndOfText(): Editor;
1677 moveStartToStartOfBlock(): Editor;
1678 moveStartToStartOfDocument(): Editor;
1679 moveStartToStartOfInline(): Editor;
1680 moveStartToStartOfNextBlock(): Editor;
1681 moveStartToStartOfNextInline(): Editor;
1682 moveStartToStartOfNextText(): Editor;
1683 moveStartToStartOfNode(node: Block | Document | Inline | Text): Editor;
1684 moveStartToStartOfPreviousBlock(): Editor;
1685 moveStartToStartOfPreviousInline(): Editor;
1686 moveStartToStartOfPreviousText(): Editor;
1687 moveStartToStartOfText(): Editor;
1688 moveStartWordForward(): Editor;
1689 moveStartWordBackward(): Editor;
1690 moveBackward(n?: number): Editor;
1691 moveForward(n?: number): Editor;
1692 moveTo(path: string | number | Immutable.List<number>, offset?: number): Editor;
1693 moveToAnchor(): Editor;
1694 moveToFocus(): Editor;
1695 moveToStart(): Editor;
1696 moveToEnd(): Editor;
1697 moveToEndOfBlock(): Editor;
1698 moveToEndOfDocument(): Editor;
1699 moveToEndOfInline(): Editor;
1700 moveToEndOfNextBlock(): Editor;
1701 moveToEndOfNextInline(): Editor;
1702 moveToEndOfNextText(): Editor;
1703 moveToEndOfNode(node: Block | Document | Inline | Text): Editor;
1704 moveToEndOfPreviousBlock(): Editor;
1705 moveToEndOfPreviousInline(): Editor;
1706 moveToEndOfPreviousText(): Editor;
1707 moveToEndOfText(): Editor;
1708 moveToStartOfBlock(): Editor;
1709 moveToStartOfDocument(): Editor;
1710 moveToStartOfInline(): Editor;
1711 moveToStartOfNextBlock(): Editor;
1712 moveToStartOfNextInline(): Editor;
1713 moveToStartOfNextText(): Editor;
1714 moveToStartOfNode(node: Block | Document | Inline | Text): Editor;
1715 moveToStartOfPreviousBlock(): Editor;
1716 moveToStartOfPreviousInline(): Editor;
1717 moveToStartOfPreviousText(): Editor;
1718 moveToStartOfText(): Editor;
1719 moveWordBackward(): Editor;
1720 moveWordForward(): Editor;
1721 moveToRangeOfDocument(): Editor;
1722 moveToRangeOfNode(node: Block | Document | Inline | Text): Editor;
1723 select(
1724 properties: string | RangeTypeProperties | RangeTypeJSON | RangeType,
1725 options?: { snapshot?: boolean | undefined },
1726 ): Editor;
1727 setAnchor(point: Point): void;
1728 setEnd(point: Point): void;
1729 setFocus(point: Point): void;
1730 setStart(point: Point): void;
1731 addMarkAtRange(
1732 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1733 mark: string | MarkProperties | Mark,
1734 ): Editor;
1735 addMarksAtRange(
1736 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1737 marks:
1738 | Array<string | MarkProperties | MarkJSON | Mark>
1739 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>,
1740 ): Editor;
1741 deleteAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1742 deleteCharBackward(): Editor;
1743 deleteCharBackwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1744 deleteLineBackward(): Editor;
1745 deleteLineBackwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1746 deleteWordBackward(): Editor;
1747 deleteWordBackwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1748 deleteBackwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, n?: number): Editor;
1749 deleteCharForward(): Editor;
1750 deleteCharForwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1751 deleteLineForward(): Editor;
1752 deleteLineForwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1753 deleteWordForwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType): Editor;
1754 deleteWordForward(): Editor;
1755 deleteForwardAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, n?: number): Editor;
1756 insertBlockAtRange(
1757 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1758 block: string | Block | BlockProperties | BlockJSON,
1759 ): Editor;
1760 insertFragmentAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, fragment: Document): Editor;
1761 insertInlineAtRange(
1762 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1763 inline: Inline | InlineProperties | InlineJSON,
1764 ): Editor;
1765 insertTextAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, text: string): Editor;
1766 setBlocksAtRange(
1767 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1768 properties: string | Block | BlockProperties | BlockJSON,
1769 ): Editor;
1770 setInlinesAtRange(
1771 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1772 properties: string | Inline | InlineProperties | InlineJSON,
1773 ): Editor;
1774 splitBlockAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, height?: number): Editor;
1775 splitInlineAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, height?: number): Editor;
1776 removeMarkAtRange(
1777 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1778 mark: string | MarkProperties | MarkJSON | Mark,
1779 ): Editor;
1780 toggleMarkAtRange(
1781 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1782 mark: string | MarkProperties | MarkJSON | Mark,
1783 ): Editor;
1784 unwrapBlockAtRange(
1785 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1786 properties: string | Block | BlockProperties | BlockJSON,
1787 ): Editor;
1788 unwrapInlineAtRange(
1789 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1790 properties: string | Inline | InlineProperties | InlineJSON,
1791 ): Editor;
1792 wrapBlockAtRange(
1793 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1794 properties: string | Block | BlockProperties | BlockJSON,
1795 ): Editor;
1796 wrapInlineAtRange(
1797 range: RangeTypeProperties | RangeTypeJSON | RangeType,
1798 properties: string | Inline | InlineProperties | InlineJSON,
1799 ): Editor;
1800 wrapTextAtRange(range: RangeTypeProperties | RangeTypeJSON | RangeType, prefix: string, suffix?: string): Editor;
1801 addMarkByKey(key: string, offset: number, length: number, mark: string | MarkProperties | MarkJSON | Mark): Editor;
1802 addMarkByPath(
1803 path: Immutable.List<number>,
1804 offset: number,
1805 length: number,
1806 mark: string | MarkProperties | MarkJSON | Mark,
1807 ): Editor;
1808 addMarksByPath(
1809 path: Immutable.List<number>,
1810 offset: number,
1811 length: number,
1812 marks:
1813 | Array<string | MarkProperties | MarkJSON | Mark>
1814 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>,
1815 ): Editor;
1816 insertNodeByKey(key: string, index: number, node: Block | Document | Inline | Text): Editor;
1817 insertNodeByPath(path: Immutable.List<number>, index: number, node: Block | Document | Inline | Text): Editor;
1818 insertFragmentByKey(key: string, index: number, fragment: Document): Editor;
1819 insertFragmentByPath(path: Immutable.List<number>, index: number, fragment: Document): Editor;
1820 insertTextByKey(
1821 key: string,
1822 offset: number,
1823 text: string,
1824 marks?:
1825 | Array<string | MarkProperties | MarkJSON | Mark>
1826 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>,
1827 ): Editor;
1828 insertTextByPath(
1829 path: Immutable.List<number>,
1830 offset: number,
1831 text: string,
1832 marks?:
1833 | Array<string | MarkProperties | MarkJSON | Mark>
1834 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>,
1835 ): Editor;
1836 mergeNodeByKey(key: string): Editor;
1837 mergeNodeByPath(path: Immutable.List<number>): Editor;
1838 moveNodeByKey(key: string, newKey: string, newIndex: number): Editor;
1839 moveNodeByPath(path: Immutable.List<number>, newPath: Immutable.List<number>, newIndex: number): Editor;
1840 removeMarkByKey(
1841 key: string,
1842 offset: number,
1843 length: number,
1844 mark: string | MarkProperties | MarkJSON | Mark,
1845 ): Editor;
1846 removeMarkByPath(
1847 path: Immutable.List<number>,
1848 offset: number,
1849 length: number,
1850 mark: string | MarkProperties | MarkJSON | Mark,
1851 ): Editor;
1852 removeAllMarksByKey(key: string): Editor;
1853 removeAllMarksByPath(path: Immutable.List<number>): Editor;
1854 removeMarksByPath(
1855 path: Immutable.List<number>,
1856 offset: number,
1857 length: number,
1858 marks:
1859 | Array<string | MarkProperties | MarkJSON | Mark>
1860 | Immutable.Set<string | MarkProperties | MarkJSON | Mark>,
1861 ): Editor;
1862 removeNodeByKey(key: string): Editor;
1863 removeNodeByPath(path: Immutable.List<number>): Editor;
1864 replaceNodeByKey(key: string, node: Block | Document | Inline | Text): Editor;
1865 replaceNodeByPath(path: Immutable.List<number>, newNode: Block | Document | Inline | Text): Editor;
1866 removeTextByKey(key: string, offset: number, length: number): Editor;
1867 removeTextByPath(path: Immutable.List<number>, offset: number, length: number): Editor;
1868 replaceTextByKey(key: string, node: Block | Document | Inline | Text): Editor;
1869 replaceTextByPath(
1870 path: Immutable.List<number>,
1871 offset: number,
1872 length: number,
1873 text: string,
1874 marks?: Immutable.Set<Mark> | Mark[],
1875 ): Editor;
1876 setMarkByKey(
1877 key: string,
1878 offset: number,
1879 length: number,
1880 properties: string | MarkProperties | MarkJSON | Mark,
1881 newProperties: string | Partial<MarkProperties> | Partial<MarkJSON> | Partial<Mark>,
1882 ): Editor;
1883 setMarkByPath(
1884 path: Immutable.List<number>,
1885 offset: number,
1886 length: number,
1887 properties: string | MarkProperties | MarkJSON | Mark,
1888 newProperties: string | Partial<MarkProperties> | Partial<MarkJSON> | Partial<Mark>,
1889 ): Editor;
1890 setNodeByKey(key: string, properties: string | Partial<BlockProperties> | Partial<InlineProperties>): Editor;
1891 setNodeByPath(path: Immutable.List<number>, newProperties: string | NodeProperties): Editor;
1892 setTextByKey(key: string, text: string, marks: Immutable.Set<Mark>): Editor;
1893 setTextByPath(path: Immutable.List<number>, text: string, marks: Immutable.Set<Mark>): Editor;
1894 splitDescendantsByKey(key: string, textKey: string, textOffset: number): Editor;
1895 splitDescendantsByPath(path: Immutable.List<number>, textPath: Immutable.List<number>, textOffset: number): Editor;
1896 splitNodeByKey(key: string, offset: number): Editor;
1897 splitNodeByPath(path: Immutable.List<number>, position: number, options?: { target?: number | undefined }): Editor;
1898 unwrapInlineByKey(key: string, properties: string | InlineProperties): Editor;
1899 unwrapInlineByPath(path: Path, properties: string | InlineProperties): Editor;
1900 unwrapBlockByKey(key: string, properties: string | BlockProperties): Editor;
1901 unwrapBlockByPath(path: Path, properties: string | BlockProperties): Editor;
1902 unwrapChildrenByKey(key: string): Editor;
1903 unwrapChildrenByPath(path: Immutable.List<number> | number[]): Editor;
1904 unwrapNodeByKey(key: string): Editor;
1905 unwrapNodeByPath(path: Immutable.List<number>): Editor;
1906 wrapInlineByKey(key: string, properties: string | InlineProperties): Editor;
1907 wrapInlineByPath(path: Path, properties: string | InlineProperties): Editor;
1908 wrapBlockByKey(key: string, properties: string | BlockProperties): Editor;
1909 wrapBlockByPath(path: Immutable.List<number>, block: string | Block): Editor;
1910 wrapNodeByKey(key: string, parent: Block | Document | Inline | Text): Editor;
1911 wrapNodeByPath(path: Immutable.List<number>, parent: Block | Document | Inline | Text): Editor;
1912 normalize(): Editor;
1913 withoutNormalizing(fn: () => void): Editor;
1914 withoutSaving(fn: () => void): Editor;
1915 withoutMerging(fn: () => void): Editor;
1916 redo(): Editor;
1917 undo(): Editor;
1918 save(operation: Operation): void;
1919 snapshotSelection(): Editor;
1920 command(type: string | ((...args: any[]) => any), ...args: any[]): Editor;
1921 hasCommand(type: string): boolean;
1922 hasQuery(type: string): boolean;
1923 query(query: string | ((...args: any[]) => any), ...args: any[]): any;
1924 registerCommand(command: string): Editor;
1925 registerQuery(query: string): Editor;
1926 applyOperation(operation: Operation | OperationJSON | OperationProperties): Editor;
1927 run(key: string, ...args: any[]): Editor;
1928 setData(data: Data): Editor;
1929 addAnnotation(annotation: AnnotationProperties | AnnotationJSON | Annotation): Editor;
1930 removeAnnotation(annotation: AnnotationProperties | AnnotationJSON | Annotation): Editor;
1931 setAnnotation(annotation: Annotation, newProperties: AnnotationProperties | AnnotationJSON | Annotation): Editor;
1932}
1933
1934export interface Controller {
1935 // Current Selection Commands //
1936 /**
1937 * Add a mark to the characters in the current selection
1938 */
1939 addMark(mark: MarkProperties | MarkJSON | Mark | string): Controller;
1940 addMarks(
1941 mark:
1942 | Set<MarkProperties | MarkJSON | Mark | string>
1943 | Array<MarkProperties | MarkJSON | Mark | string>,
1944 ): Controller;
1945 /**
1946 * Delete everything in the current selection.
1947 */
1948 delete(): Controller;
1949
1950 /**
1951 * Delete backward n characters at the current cursor.
1952 * If the selection is expanded, behaviour is equivalent to delete()
1953 */
1954 deleteBackward(n?: number): Controller;
1955
1956 /**
1957 * Delete backward n characters at the current cursor.
1958 * If the selection is expanded, behaviour is equivalent to delete()
1959 */
1960 deleteForward(n?: number): Controller;
1961
1962 /**
1963 * Insert a new block at the same level as the current block, splitting the current block to make room if it is non-empty.
1964 * If the selection is expanded, it will be deleted first.
1965 */
1966 insertBlock(block: Block | BlockProperties | BlockJSON | string): Controller;
1967
1968 /**
1969 * Insert a document fragment at the current selection. If the selection is expanded, it will be deleted first.
1970 */
1971 insertFragment(fragment: Document): Controller;
1972
1973 /**
1974 * Insert a new inline at the current cursor position, splitting the text to make room if it is non-empty.
1975 * If the selection is expanded, it will be deleted first.
1976 */
1977 insertInline(inline: Inline | InlineProperties | InlineJSON | string): Controller;
1978
1979 /**
1980 * Insert a string of text at the current selection. If the selection is expanded, it will be deleted first
1981 */
1982 insertText(text: string): Controller;
1983
1984 /**
1985 * Set the properties of the Blocks in the current selection.
1986 * Passing a string will set the blocks' type only.
1987 */
1988 setBlocks(properties: Block | BlockProperties | BlockJSON | string): Controller;
1989
1990 /**
1991 * Set the properties of the Inlines nodes in the current selection.
1992 * Passing a string will set the nodes' type only.
1993 */
1994 setInlines(properties: Inline | InlineProperties | InlineProperties | string): Controller;
1995
1996 /**
1997 * Split the Block in the current selection by depth levels.
1998 * If the selection is expanded, it will be deleted first.
1999 */
2000 splitBlock(depth?: number): Controller;
2001
2002 /**
2003 * Split the Inline node in the current selection by depth levels.
2004 * If the selection is expanded, it will be deleted first
2005 */
2006 splitInline(depth: number): Controller;
2007
2008 /**
2009 * Remove a mark from the characters in the current selection.
2010 * Passing a string will implicitly create a Mark of that type for removal.
2011 */
2012 removeMark(mark: Mark | MarkProperties | MarkJSON | string): Controller;
2013
2014 /**
2015 * Remove a mark from the characters in the current selection.
2016 * Passing a string will implicitly create a Mark of that type.
2017 */
2018 replaceMark(
2019 mark: MarkProperties | MarkJSON | Mark | string,
2020 newMark: MarkProperties | MarkJSON | Mark | string,
2021 ): Controller;
2022
2023 /**
2024 * Add or remove a mark from the characters in the current selection, depending on it already exists on any or not.
2025 * Passing a string will implicitly create a Mark of that type to toggle.
2026 */
2027 toggleMark(mark: MarkProperties | MarkJSON | Mark | string): Controller;
2028
2029 /**
2030 * Unwrap all Block nodes in the current selection that match a type and/or data
2031 */
2032 unwrapBlock(properties: BlockProperties | BlockJSON | Block | string): Controller;
2033
2034 /**
2035 * Unwrap all Inline nodes in the current selection that match a type and/or data
2036 */
2037 unwrapInline(properties: InlineProperties | InlineJSON | Inline | string): Controller;
2038
2039 /**
2040 * Wrap the Block nodes in the current selection with a new Block
2041 */
2042 wrapBlock(properties: BlockProperties | BlockJSON | Block | string): Controller;
2043
2044 /**
2045 * Wrap the Block nodes in the current selection with a new Inline
2046 */
2047 wrapInline(properties: InlineProperties | InlineJSON | Inline | string): Controller;
2048
2049 /**
2050 * Surround the text in the current selection with prefix and suffix strings.
2051 * If the suffix is ommitted, the prefix will be used instead.
2052 */
2053 wrapText(prefix: string, suffix?: string): Controller;
2054
2055 // Selection Commands //
2056 /**
2057 * Blur the current selection
2058 */
2059 blur(): Controller;
2060
2061 /**
2062 * Unset the selection
2063 */
2064 deselect(): Controller;
2065
2066 /**
2067 * Flip the selection
2068 */
2069 flip(): Controller;
2070
2071 /**
2072 * Focus the current selection
2073 */
2074 focus(): Controller;
2075
2076 /**
2077 * Move the anchor of the current selection backward n characters
2078 */
2079 moveAnchorBackward(n?: number): Controller;
2080 moveAnchorWordBackward(): Controller;
2081 /**
2082 * Move the anchor of the current selection forward n characters
2083 */
2084 moveAnchorForward(n?: number): Controller;
2085 moveAnchorWordForward(): Controller;
2086 /**
2087 * Move the anchor of the current selection to a new path and offset
2088 */
2089 moveAnchorTo(path: string | number | Immutable.List<number>, offset?: number): Controller;
2090 /**
2091 * Move the anchor of the current selection to the end of the closest block parent.
2092 */
2093 moveAnchorToEndOfBlock(): Controller;
2094 /**
2095 * Move the anchor of the current selection to the end of the closest inline parent.
2096 */
2097 moveAnchorToEndOfInline(): Controller;
2098 /**
2099 * Move the anchor of the current selection to the end of the document.
2100 */
2101 moveAnchorToEndOfDocument(): Controller;
2102 /**
2103 * Move the anchor of the current selection to the end of the next block.
2104 */
2105 moveAnchorToEndOfNextBlock(): Controller;
2106 /**
2107 * Move the anchor of the current selection to the end of the next inline.
2108 */
2109 moveAnchorToEndOfNextInline(): Controller;
2110 /**
2111 * Move the anchor of the current selection to the end of the next text.
2112 */
2113 moveAnchorToEndOfNextText(): Controller;
2114 /**
2115 * Move the anchor of the current selection to the end of the provided node.
2116 */
2117 moveAnchorToEndOfNode(node: Node): Controller;
2118 /**
2119 * Move the anchor of the current selection to the end of the previous block.
2120 */
2121 moveAnchorToEndOfPreviousBlock(): Controller;
2122 /**
2123 * Move the anchor of the current selection to the end of the previous inline.
2124 */
2125 moveAnchorToEndOfPreviousInline(): Controller;
2126 /**
2127 * Move the anchor of the current selection to the end of the previous text.
2128 */
2129 moveAnchorToEndOfPreviousText(): Controller;
2130 /**
2131 * Move the anchor of the current selection to the end of the current text node.
2132 */
2133 moveAnchorToEndOfText(): Controller;
2134 /**
2135 * Move the anchor of the current selection to the start of the closest block parent.
2136 */
2137 moveAnchorToStartOfBlock(): Controller;
2138 /**
2139 * Move the anchor of the current selection to the start of the document.
2140 */
2141 moveAnchorToStartOfDocument(): Controller;
2142 /**
2143 * Move the anchor of the current selection to the start of the closest inline parent.
2144 */
2145 moveAnchorToStartOfInline(): Controller;
2146 /**
2147 * Move the anchor of the current selection to the start of the next block.
2148 */
2149 moveAnchorToStartOfNextBlock(): Controller;
2150 /**
2151 * Move the anchor of the current selection to the start of the next inline.
2152 */
2153 moveAnchorToStartOfNextInline(): Controller;
2154 /**
2155 * Move the anchor of the current selection to the start of the next text node.
2156 */
2157 moveAnchorToStartOfNextText(): Controller;
2158 /**
2159 * Move the anchor of the current selection to the start of the provided node.
2160 */
2161 moveAnchorToStartOfNode(node: Node): Controller;
2162 /**
2163 * Move the anchor of the current selection to the start of the previous block.
2164 */
2165 moveAnchorToStartOfPreviousBlock(): Controller;
2166 /**
2167 * Move the anchor of the current selection to the start of the previous inline.
2168 */
2169 moveAnchorToStartOfPreviousInline(): Controller;
2170 /**
2171 * Move the anchor of the current selection to the start of the previous text node.
2172 */
2173 moveAnchorToStartOfPreviousText(): Controller;
2174 /**
2175 * Move the anchor of the current selection to the start of the current text node.
2176 */
2177 moveAnchorToStartOfText(): Controller;
2178
2179 /**
2180 * Move the end of the selection backward n characters
2181 */
2182 moveEndBackward(n?: number): Controller;
2183 /**
2184 * Move the end of the selection foward n characters
2185 */
2186 moveEndForward(n?: number): Controller;
2187
2188 /**
2189 * Move the end of the selection to a new path and offset
2190 */
2191 moveEndTo(path: string | number | Immutable.List<number>, offset?: number): Controller;
2192 /**
2193 * Move the end of the current selection to the end of the closest block parent.
2194 */
2195 moveEndToEndOfBlock(): Controller;
2196 /**
2197 * Move the end of the current selection to the end of the document.
2198 */
2199 moveEndToEndOfDocument(): Controller;
2200 /**
2201 * Move the end of the current selection to the end of the closest inline parent.
2202 */
2203 moveEndToEndOfInline(): Controller;
2204 /**
2205 * Move the anchor of the current selection to the end of the next block.
2206 */
2207 moveEndToEndOfNextBlock(): Controller;
2208 /**
2209 * Move the end of the current selection to the end of the next inline.
2210 */
2211 moveEndToEndOfNextInline(): Controller;
2212 /**
2213 * Move the end of the current selection to the end of the next text.
2214 */
2215 moveEndToEndOfNextText(): Controller;
2216 /**
2217 * Move the end of the current selection to the end of the provided node.
2218 */
2219 moveEndToEndOfNode(node: Node): Controller;
2220 /**
2221 * Move the end of the current selection to the end of the previous block.
2222 */
2223 moveEndToEndOfPreviousBlock(): Controller;
2224 /**
2225 * Move the end of the current selection to the end of the previous inline.
2226 */
2227 moveEndToEndOfPreviousInline(): Controller;
2228 /**
2229 * Move the commandable of the current selection to the end of the previous text.
2230 */
2231 moveEndToEndOfPreviousText(): Controller;
2232 /**
2233 * Move the end of the current selection to the end of the current text node.
2234 */
2235 moveEndToEndOfText(): Controller;
2236 /**
2237 * Move the end of the current selection to the start of the closest block parent.
2238 */
2239 moveEndToStartOfBlock(): Controller;
2240 /**
2241 * Move the end of the current selection to the start of the document.
2242 */
2243 moveEndToStartOfDocument(): Controller;
2244 /**
2245 * Move the end of the current selection to the start of the closest inline parent.
2246 */
2247 moveEndToStartOfInline(): Controller;
2248 /**
2249 * Move the end of the current selection to the start of the next block.
2250 */
2251 moveEndToStartOfNextBlock(): Controller;
2252 /**
2253 * Move the end of the current selection to the start of the next inline.
2254 */
2255 moveEndToStartOfNextInline(): Controller;
2256 /**
2257 * Move the end of the current selection to the start of the next text node.
2258 */
2259 moveEndToStartOfNextText(): Controller;
2260 /**
2261 * Move the end of the current selection to the start of the provided node.
2262 */
2263 moveEndToStartOfNode(node: Node): Controller;
2264 /**
2265 * Move the end of the current selection to the start of the previous block.
2266 */
2267 moveEndToStartOfPreviousBlock(): Controller;
2268 /**
2269 * Move the end of the current selection to the start of the previous inline.
2270 */
2271 moveEndToStartOfPreviousInline(): Controller;
2272 /**
2273 * Move the end of the current selection to the start of the previous text node.
2274 */
2275 moveEndToStartOfPreviousText(): Controller;
2276 /**
2277 * Move the end of the current selection to the start of the current text node.
2278 */
2279 moveEndToStartOfText(): Controller;
2280 moveEndWordBackward(): Controller;
2281 moveEndWordForward(): Controller;
2282 /**
2283 * Move the focus of the current selection backward n characters
2284 */
2285 moveFocusBackward(n?: number): Controller;
2286 /**
2287 * Move the focus of the current selection forward n characters
2288 */
2289 moveFocusForward(n?: number): Controller;
2290 /**
2291 * Move the focus of the current selection to a new path and offset
2292 */
2293 moveFocusTo(path: string | number | Immutable.List<number>, offset?: number): Controller;
2294 /**
2295 * Move the focus of the current selection to the end of the closest block parent.
2296 */
2297 moveFocusToEndOfBlock(): Controller;
2298 /**
2299 * Move the focus of the current selection to the end of the document.
2300 */
2301 moveFocusToEndOfDocument(): Controller;
2302 /**
2303 * Move the focus of the current selection to the end of the closest inline parent.
2304 */
2305 moveFocusToEndOfInline(): Controller;
2306 /**
2307 * Move the focus of the current selection to the end of the next block.
2308 */
2309 moveFocusToEndOfNextBlock(): Controller;
2310 /**
2311 * Move the focus of the current selection to the end of the next inline.
2312 */
2313 moveFocusToEndOfNextInline(): Controller;
2314 /**
2315 * Move the focus of the current selection to the end of the next text.
2316 */
2317 moveFocusToEndOfNextText(): Controller;
2318 /**
2319 * Move the focus of the current selection to the end of the provided node.
2320 */
2321 moveFocusToEndOfNode(node: Node): Controller;
2322 /**
2323 * Move the focus of the current selection to the end of the previous block.
2324 */
2325 moveFocusToEndOfPreviousBlock(): Controller;
2326 /**
2327 * Move the focus of the current selection to the end of the previous inline.
2328 */
2329 moveFocusToEndOfPreviousInline(): Controller;
2330 /**
2331 * Move the focus of the current selection to the end of the previous text.
2332 */
2333 moveFocusToEndOfPreviousText(): Controller;
2334 /**
2335 * Move the focus of the current selection to the end of the current text node.
2336 */
2337 moveFocusToEndOfText(): Controller;
2338 /**
2339 * Move the focus of the current selection to the start of the closest block parent.
2340 */
2341 moveFocusToStartOfBlock(): Controller;
2342 /**
2343 * Move the focus of the current selection to the start of the document.
2344 */
2345 moveFocusToStartOfDocument(): Controller;
2346 /**
2347 * Move the focus of the current selection to the start of the closest inline parent.
2348 */
2349 moveFocusToStartOfInline(): Controller;
2350 /**
2351 * Move the focus of the current selection to the start of the next block.
2352 */
2353 moveFocusToStartOfNextBlock(): Controller;
2354 /**
2355 * Move the focus of the current selection to the start of the next inline.
2356 */
2357 moveFocusToStartOfNextInline(): Controller;
2358 /**
2359 * Move the focus of the current selection to the start of the next text node.
2360 */
2361 moveFocusToStartOfNextText(): Controller;
2362 /**
2363 * Move the focus of the current selection to the start of the provided node.
2364 */
2365 moveFocusToStartOfNode(node: Node): Controller;
2366 /**
2367 * Move the focus of the current selection to the start of the previous block.
2368 */
2369 moveFocusToStartOfPreviousBlock(): Controller;
2370 /**
2371 * Move the focus of the current selection to the start of the previous inline.
2372 */
2373 moveFocusToStartOfPreviousInline(): Controller;
2374 /**
2375 * Move the focus of the current selection to the start of the previous text node.
2376 */
2377 moveFocusToStartOfPreviousText(): Controller;
2378 /**
2379 * Move the focus of the current selection to the start of the current text node.
2380 */
2381 moveFocusToStartOfText(): Controller;
2382 moveFocusWordBackward(): Controller;
2383 moveFocusWordForward(): Controller;
2384 /**
2385 * Move the start of the current selection backward n characters
2386 */
2387 moveStartForward(n?: number): Controller;
2388 /**
2389 * Move the start of the current selection forward n characters
2390 */
2391 moveStartBackward(n?: number): Controller;
2392 /**
2393 * Move the start of the current selection to a new path and offset
2394 */
2395 moveStartTo(path: string | number | Immutable.List<number>, n?: number): Controller;
2396 /**
2397 * Move the start of the current selection to the end of the closest block parent.
2398 */
2399 moveStartToEndOfBlock(): Controller;
2400 /**
2401 * Move the start of the current selection to the end of the document.
2402 */
2403 moveStartToEndOfDocument(): Controller;
2404 /**
2405 * Move the start of the current selection to the end of the closest inline parent.
2406 */
2407 moveStartToEndOfInline(): Controller;
2408 /**
2409 * Move the start of the current selection to the end of the next block.
2410 */
2411 moveStartToEndOfNextBlock(): Controller;
2412 /**
2413 * Move the start of the current selection to the end of the next inline.
2414 */
2415 moveStartToEndOfNextInline(): Controller;
2416 /**
2417 * Move the start of the current selection to the end of the next text.
2418 */
2419 moveStartToEndOfNextText(): Controller;
2420 /**
2421 * Move the start of the current selection to the end of the provided node.
2422 */
2423 moveStartToEndOfNode(node: Node): Controller;
2424 /**
2425 * Move the start of the current selection to the end of the previous block.
2426 */
2427 moveStartToEndOfPreviousBlock(): Controller;
2428 /**
2429 * Move the start of the current selection to the end of the previous inline.
2430 */
2431 moveStartToEndOfPreviousInline(): Controller;
2432 /**
2433 * Move the start of the current selection to the end of the previous text.
2434 */
2435 moveStartToEndOfPreviousText(): Controller;
2436 /**
2437 * Move the start of the current selection to the end of the current text node.
2438 */
2439 moveStartToEndOfText(): Controller;
2440 /**
2441 * Move the start of the current selection to the start of the closest block parent.
2442 */
2443 moveStartToStartOfBlock(): Controller;
2444 /**
2445 * Move the start of the current selection to the start of the document.
2446 */
2447 moveStartToStartOfDocument(): Controller;
2448 /**
2449 * Move the start of the current selection to the start of the closest inline parent.
2450 */
2451 moveStartToStartOfInline(): Controller;
2452 /**
2453 * Move the start of the current selection to the start of the next block.
2454 */
2455 moveStartToStartOfNextBlock(): Controller;
2456 /**
2457 * Move the start of the current selection to the start of the next inline.
2458 */
2459 moveStartToStartOfNextInline(): Controller;
2460 /**
2461 * Move the start of the current selection to the start of the next text node.
2462 */
2463 moveStartToStartOfNextText(): Controller;
2464 /**
2465 * Move the start of the current selection to the start of the provided node.
2466 */
2467 moveStartToStartOfNode(node: Node): Controller;
2468 /**
2469 * Move the start of the current selection to the start of the previous block.
2470 */
2471 moveStartToStartOfPreviousBlock(): Controller;
2472 /**
2473 * Move the start of the current selection to the start of the previous inline.
2474 */
2475 moveStartToStartOfPreviousInline(): Controller;
2476 /**
2477 * Move the start of the current selection to the start of the previous text node.
2478 */
2479 moveStartToStartOfPreviousText(): Controller;
2480 /**
2481 * Move the start of the current selection to the start of the current text node.
2482 */
2483 moveStartToStartOfText(): Controller;
2484 moveStartWordForward(): Controller;
2485 moveStartWordBackward(): Controller;
2486 /**
2487 * Move the anchor and focus of the selection backward n characters.
2488 */
2489 moveBackward(n?: number): Controller;
2490 /**
2491 * Move the anchor and focus of the selection forward n characters.
2492 */
2493 moveForward(n?: number): Controller;
2494 /**
2495 * Collapse the current selection at the provided new path and offset.
2496 */
2497 moveTo(path: string | number | Immutable.List<number>, offset?: number): Controller;
2498 /**
2499 * Collapse the current selection at the anchor.
2500 */
2501 moveToAnchor(): Controller;
2502 /**
2503 * Collapse the current selection at the focus.
2504 */
2505 moveToFocus(): Controller;
2506 /**
2507 * Collapse the current selection at the start.
2508 */
2509 moveToStart(): Controller;
2510 /**
2511 * Collapse the current selection at the end.
2512 */
2513 moveToEnd(): Controller;
2514 /**
2515 * Collapse the current selection at the end of the closest block parent.
2516 */
2517 moveToEndOfBlock(): Controller;
2518 /**
2519 * Collapse the current selection at the end of the document.
2520 */
2521 moveToEndOfDocument(): Controller;
2522 /**
2523 * Collapse the current selection at the end of the closest inline parent.
2524 */
2525 moveToEndOfInline(): Controller;
2526 /**
2527 * Collapse the current selection at the end of the next block.
2528 */
2529 moveToEndOfNextBlock(): Controller;
2530 /**
2531 * Collapse the current selection at the end of the inline.
2532 */
2533 moveToEndOfNextInline(): Controller;
2534 /**
2535 * Collapse the current selection at the end of the next text node.
2536 */
2537 moveToEndOfNextText(): Controller;
2538 /**
2539 * Collapse the current selection at the end of the provided node.
2540 */
2541 moveToEndOfNode(node: Node): Controller;
2542 /**
2543 * Collapse the current selection at the end of the previous block.
2544 */
2545 moveToEndOfPreviousBlock(): Controller;
2546 /**
2547 * Collapse the current selection at the end of the previous inline.
2548 */
2549 moveToEndOfPreviousInline(): Controller;
2550 /**
2551 * Collapse the current selection at the end of the previous text node.
2552 */
2553 moveToEndOfPreviousText(): Controller;
2554 /**
2555 * Collapse the current selection at the end of the current text node.
2556 */
2557 moveToEndOfText(): Controller;
2558 /**
2559 * Collapse the current selection at the start of the nearest block parent.
2560 */
2561 moveToStartOfBlock(): Controller;
2562 /**
2563 * Collapse the current selection at the start of the document.
2564 */
2565 moveToStartOfDocument(): Controller;
2566 /**
2567 * Collapse the current selection at the start of the nearest inline parent.
2568 */
2569 moveToStartOfInline(): Controller;
2570 /**
2571 * Collapse the current selection at the start of the next block.
2572 */
2573 moveToStartOfNextBlock(): Controller;
2574 /**
2575 * Collapse the current selection at the start of the next inline.
2576 */
2577 moveToStartOfNextInline(): Controller;
2578 /**
2579 * Collapse the current selection at the start of the next text node.
2580 */
2581 moveToStartOfNextText(): Controller;
2582 /**
2583 * Collapse the current selection at the start of the provided node.
2584 */
2585 moveToStartOfNode(node: Node): Controller;
2586 /**
2587 * Collapse the current selection at the start of the previous block.
2588 */
2589 moveToStartOfPreviousBlock(): Controller;
2590 /**
2591 * Collapse the current selection at the start of the previous inline.
2592 */
2593 moveToStartOfPreviousInline(): Controller;
2594 /**
2595 * Collapse the current selection at the start of the previous text node.
2596 */
2597 moveToStartOfPreviousText(): Controller;
2598 /**
2599 * Collapse the current selection at the start of the current text node.
2600 */
2601 moveToStartOfText(): Controller;
2602 moveWordBackward(): Controller;
2603 moveWordForward(): Controller;
2604 /**
2605 * Move the current selection's anchor to the start of the document and its focus to the end of it, selecting everything.
2606 */
2607 moveToRangeOfDocument(): Controller;
2608 /**
2609 * Move the current selection's anchor to the start of the provided node and its focus to the end of it.
2610 */
2611 moveToRangeOfNode(node: Node): Controller;
2612 /**
2613 * Merge the current selection with the provided properties
2614 */
2615 select(
2616 properties:
2617 | RangeTypeProperties
2618 | RangeTypeJSON
2619 | RangeType
2620 | string,
2621 options?: { snapshot?: boolean | undefined },
2622 ): Controller;
2623 setAnchor(point: Point): void;
2624 setEnd(point: Point): void;
2625 setFocus(point: Point): void;
2626 setStart(point: Point): void;
2627
2628 // Document Range Commands //
2629
2630 /**
2631 * Add a mark to the characters in the range.
2632 * Passing a string as `mark` will implicitly create a mark with that `type`
2633 */
2634 addMarkAtRange(
2635 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2636 mark: Mark | MarkProperties | string,
2637 ): Controller;
2638 addMarksAtRange(
2639 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2640 marks:
2641 | Array<MarkProperties | MarkJSON | Mark | string>
2642 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
2643 ): Controller;
2644 /**
2645 * Delete everything in the range
2646 */
2647 deleteAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2648 /**
2649 * Delete backward one character
2650 */
2651 deleteCharBackward(): Controller;
2652 /**
2653 * Delete backward until the char boundary at a range
2654 */
2655 deleteCharBackwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2656 /**
2657 * Delete backward one line
2658 */
2659 deleteLineBackward(): Controller;
2660 /**
2661 * Delete backward until the line boundary at a range
2662 */
2663 deleteLineBackwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2664 /**
2665 * Delete backward one word.
2666 */
2667 deleteWordBackward(): Controller;
2668 /**
2669 * Delete backward until the word boundary at a range
2670 */
2671 deleteWordBackwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2672 /**
2673 * Delete backward n characters at a range
2674 */
2675 deleteBackwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON, n?: number): Controller;
2676 /**
2677 * Delete forward one character
2678 */
2679 deleteCharForward(): Controller;
2680 /**
2681 * Delete forward until the char boundary at a range
2682 */
2683 deleteCharForwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2684 /**
2685 * Delete forward one line
2686 */
2687 deleteLineForward(): Controller;
2688 /**
2689 * Delete forward until the line boundary at a range
2690 */
2691 deleteLineForwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2692 /**
2693 * Delete forward until the word boundary at a range
2694 */
2695 deleteWordForwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON): Controller;
2696 /**
2697 * Delete forward one word
2698 */
2699 deleteWordForward(): Controller;
2700 /**
2701 * Delete forward n characters at a range
2702 */
2703 deleteForwardAtRange(range: RangeType | RangeTypeProperties | RangeTypeJSON, n?: number): Controller;
2704 /**
2705 * Insert a block node at range, splitting text to make room if it is non-empty.
2706 * If the range is expanded, it will be deleted first.
2707 */
2708 insertBlockAtRange(
2709 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2710 block: Block | BlockProperties | BlockJSON | string,
2711 ): Controller;
2712 /**
2713 * Insert a document fragment at a range, if the range is expanded, it will be deleted first.
2714 */
2715 insertFragmentAtRange(
2716 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2717 fragment: Document,
2718 ): Controller;
2719 /**
2720 * Insert a new inline at range, splitting text to make room if it is non-empty.
2721 * If the range is expanded, it will be deleted first.
2722 */
2723 insertInlineAtRange(
2724 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2725 inline: Inline | InlineJSON | InlineProperties,
2726 ): Controller;
2727 /**
2728 * Insert text at range. If the range is expanded it will be deleted first
2729 */
2730 insertTextAtRange(
2731 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2732 text: string,
2733 ): Controller;
2734 /**
2735 * Set the properties of the block nodes in a range.
2736 * Passing a string will set the nodes' type only
2737 */
2738 setBlocksAtRange(
2739 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2740 properties: Block | BlockJSON | BlockProperties | string,
2741 ): Controller;
2742 /**
2743 * Set the properties of the inline nodes in a range.
2744 * Passing a string will set the nodes' type only
2745 */
2746 setInlinesAtRange(
2747 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2748 properties: InlineProperties | InlineJSON | Inline | string,
2749 ): Controller;
2750 /**
2751 * Split the block nodes at a `range`, to optional `height`.
2752 */
2753 splitBlockAtRange(
2754 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2755 height?: number,
2756 ): Controller;
2757 /**
2758 * Split the inline nodes at a `range`, to optional `height`.
2759 */
2760 splitInlineAtRange(
2761 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2762 height?: number,
2763 ): Controller;
2764 /**
2765 * Remove a mark from characters in the range. Passing a string will
2766 * implicitly create a mark of that type for deletion.
2767 */
2768 removeMarkAtRange(
2769 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2770 mark: Mark | MarkProperties | MarkJSON | string,
2771 ): Controller;
2772 /**
2773 * Add or remove a mark from characters in the range. Passing a string will
2774 * implicitly create a mark of that type for deletion.
2775 */
2776 toggleMarkAtRange(
2777 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2778 mark: Mark | MarkProperties | MarkJSON | string,
2779 ): Controller;
2780 /**
2781 * Unwrap all block nodes in a range that match properties
2782 */
2783 unwrapBlockAtRange(
2784 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2785 properties: BlockProperties | BlockJSON | Block | string,
2786 ): Controller;
2787 /**
2788 * Unwrap all inline nodes in a range that match properties
2789 */
2790 unwrapInlineAtRange(
2791 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2792 properties: InlineProperties | InlineJSON | Inline | string,
2793 ): Controller;
2794 /**
2795 * wrap all block nodes in a range with a new block node with the provided properties
2796 */
2797 wrapBlockAtRange(
2798 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2799 properties: BlockProperties | BlockJSON | Block | string,
2800 ): Controller;
2801 /**
2802 * wrap all inline nodes in a range with a new inline node with the provided properties
2803 */
2804 wrapInlineAtRange(
2805 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2806 properties: InlineProperties | InlineJSON | Inline | string,
2807 ): Controller;
2808 /**
2809 * Surround the text in a range with a prefix and suffix. If the suffix is ommitted,
2810 * the prefix will be used instead.
2811 */
2812 wrapTextAtRange(
2813 range: RangeType | RangeTypeProperties | RangeTypeJSON,
2814 prefix: string,
2815 suffix?: string,
2816 ): Controller;
2817
2818 // Node commands //
2819 /**
2820 * Add a mark to length characters starting at an offset in a node by key
2821 */
2822 addMarkByKey(
2823 key: string,
2824 offset: number,
2825 length: number,
2826 mark: MarkProperties | MarkJSON | Mark | string,
2827 ): Controller;
2828 /**
2829 * Add a mark to length characters starting at an offset in a node by path
2830 */
2831 addMarkByPath(
2832 path: Immutable.List<number>,
2833 offset: number,
2834 length: number,
2835 mark: MarkProperties | MarkJSON | Mark | string,
2836 ): Controller;
2837 addMarksByPath(
2838 path: Immutable.List<number>,
2839 offset: number,
2840 length: number,
2841 marks:
2842 | Array<MarkProperties | MarkJSON | Mark | string>
2843 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
2844 ): Controller;
2845 /**
2846 * Insert a node at index inside a parent node by key
2847 */
2848 insertNodeByKey(key: string, index: number, node: Node): Controller;
2849 /**
2850 * Insert a node at index inside a parent node by apth
2851 */
2852 insertNodeByPath(path: Immutable.List<number>, index: number, node: Node): Controller;
2853 /**
2854 * Insert a document fragment at index inside a parent node by key
2855 */
2856 insertFragmentByKey(key: string, index: number, fragment: Document): Controller;
2857 /**
2858 * Insert a document fragment at index inside a parent node by path
2859 */
2860 insertFragmentByPath(path: Immutable.List<number>, index: number, fragment: Document): Controller;
2861 /**
2862 * Insert text at an offset in a text node by its key with optional marks
2863 */
2864 insertTextByKey(
2865 key: string,
2866 offset: number,
2867 text: string,
2868 marks?:
2869 | Array<MarkProperties | MarkJSON | Mark | string>
2870 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
2871 ): Controller;
2872 /**
2873 * Insert text at an offset in a text node by its path with optional marks
2874 */
2875 insertTextByPath(
2876 path: Immutable.List<number>,
2877 offset: number,
2878 text: string,
2879 marks?:
2880 | Array<MarkProperties | MarkJSON | Mark | string>
2881 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
2882 ): Controller;
2883 /**
2884 * Merge a node by its key with its previous sibling
2885 */
2886 mergeNodeByKey(key: string): Controller;
2887 /**
2888 * Merge a node by its path with its previous sibling
2889 */
2890 mergeNodeByPath(path: Immutable.List<number>): Controller;
2891 /**
2892 * Move a node by its key to a new parent node with with newkey at newindex
2893 */
2894 moveNodeByKey(key: string, newKey: string, newIndex: number): Controller;
2895 /**
2896 * Move a node by its path to a new parent node with with newpath at newindex
2897 */
2898 moveNodeByPath(
2899 path: Immutable.List<number>,
2900 newPath: Immutable.List<number>,
2901 newIndex: number,
2902 ): Controller;
2903 /**
2904 * Remove a mark from length characters starting at an offset in a node by key
2905 */
2906 removeMarkByKey(
2907 key: string,
2908 offset: number,
2909 length: number,
2910 mark: MarkProperties | MarkJSON | Mark | string,
2911 ): Controller;
2912 /**
2913 * Remove a mark from length characters starting at an offset in a node by path
2914 */
2915 removeMarkByPath(
2916 path: Immutable.List<number>,
2917 offset: number,
2918 length: number,
2919 mark: MarkProperties | MarkJSON | Mark | string,
2920 ): Controller;
2921 /**
2922 * Remove all `marks` from node by `key`.
2923 */
2924 removeAllMarksByKey(key: string): Controller;
2925 /**
2926 * Remove all `marks` from node by `path`.
2927 */
2928 removeAllMarksByPath(path: Immutable.List<number>): Controller;
2929 removeMarksByPath(
2930 path: Immutable.List<number>,
2931 offset: number,
2932 length: number,
2933 marks:
2934 | Array<MarkProperties | MarkJSON | Mark | string>
2935 | Immutable.Set<MarkProperties | MarkJSON | Mark | string>,
2936 ): Controller;
2937 /**
2938 * Remove a node from the document by its key
2939 */
2940 removeNodeByKey(key: string): Controller;
2941 /**
2942 * Remove a node from the document by its path
2943 */
2944 removeNodeByPath(path: Immutable.List<number>): Controller;
2945 /**
2946 * Replace a node in the document with a new node by key
2947 */
2948 replaceNodeByKey(key: string, node: Node): Controller;
2949 /**
2950 * Replace a node in the document with a new node by path
2951 */
2952 replaceNodeByPath(path: Immutable.List<number>, newNode: Node): Controller;
2953 /**
2954 * Remove length characters of text starting at an offset in a node by key
2955 */
2956 removeTextByKey(key: string, offset: number, length: number): Controller;
2957 /**
2958 * Remove length characters of text starting at an offset in a node by path
2959 */
2960 removeTextByPath(path: Immutable.List<number>, offset: number, length: number): Controller;
2961 /**
2962 * Set a dictionary of newProperties on a mark by its key.
2963 */
2964 /**
2965 * Replace a length of text at offset with new text and optional marks by key
2966 */
2967 replaceTextByKey(key: string, node: Node): Controller;
2968 /**
2969 * Replace a length of text at offset with new text and optional marks by path
2970 */
2971 replaceTextByPath(
2972 path: Immutable.List<number>,
2973 offset: number,
2974 length: number,
2975 text: string,
2976 marks?: Immutable.Set<Mark> | Mark[],
2977 ): Controller;
2978 /**
2979 * Remove length characters of text starting at an offset in a node by key
2980 */
2981 setMarkByKey(
2982 key: string,
2983 offset: number,
2984 length: number,
2985 properties: MarkProperties | MarkJSON | Mark | string,
2986 newProperties: Partial<MarkProperties | MarkJSON | Mark | string>,
2987 ): Controller;
2988 /**
2989 * Set a dictionary of newProperties on a mark by its path.
2990 */
2991 setMarkByPath(
2992 path: Immutable.List<number>,
2993 offset: number,
2994 length: number,
2995 properties: MarkProperties | MarkJSON | Mark | string,
2996 newProperties: Partial<MarkProperties | MarkJSON | Mark | string>,
2997 ): Controller;
2998 /**
2999 * Set a dictionary of properties on a node by its key.
3000 */
3001 setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Controller;
3002 /**
3003 * Set a dictionary of properties on a node by its key.
3004 */
3005 setNodeByPath(path: Immutable.List<number>, newProperties: NodeProperties | InlineProperties | string): Controller;
3006 /**
3007 * Insert `text` at `offset` in node by `key`.
3008 */
3009 setTextByKey(key: string, text: string, marks: Immutable.Set<Mark>): Controller;
3010 /**
3011 * Insert `text` at `offset` in node by `path`.
3012 */
3013 setTextByPath(path: Immutable.List<number>, text: string, marks: Immutable.Set<Mark>): Controller;
3014 /**
3015 * Split a node deeply down the tree by `key`, `textKey` and `textOffset`.
3016 */
3017 splitDescendantsByKey(key: string, textKey: string, textOffset: number): Controller;
3018 /**
3019 * Split a node deeply down the tree by `path`, `textPath` and `textOffset`.
3020 */
3021 splitDescendantsByPath(
3022 path: Immutable.List<number>,
3023 textPath: Immutable.List<number>,
3024 textOffset: number,
3025 ): Controller;
3026
3027 /**
3028 * Split a node by its key at an offset
3029 */
3030 splitNodeByKey(key: string, offset: number): Controller;
3031 /**
3032 * Split a node by its path at an offset
3033 */
3034 splitNodeByPath(
3035 path: Immutable.List<number>,
3036 position: number,
3037 options?: { target?: number | undefined },
3038 ): Controller;
3039 /**
3040 * Unwrap all inner content of an inline node by its key that match properties
3041 */
3042 unwrapInlineByKey(key: string, properties: InlineProperties | string): Controller;
3043 /**
3044 * Unwrap all inner content of an inline node by its path that match properties
3045 */
3046 unwrapInlineByPath(path: Path, properties: InlineProperties | string): Controller;
3047 /**
3048 * Unwrap all inner content of a block node by its key that match properties
3049 */
3050 unwrapBlockByKey(key: string, properties: BlockProperties | string): Controller;
3051 /**
3052 * Unwrap all inner content of a block node by its path that match properties
3053 */
3054 unwrapBlockByPath(path: Path, properties: BlockProperties | string): Controller;
3055 /**
3056 * Unwrap all of the children of a node by its key.
3057 */
3058 unwrapChildrenByKey(key: string): Controller;
3059 /**
3060 * Unwrap all of the children of a node, by removing the node and replacing it
3061 * with the children in the tree.
3062 */
3063 unwrapChildrenByPath(path: Immutable.List<number> | number[]): Controller;
3064 /**
3065 * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split.
3066 * If the node is an only child, it will replace the parent
3067 */
3068 unwrapNodeByKey(key: string): Controller;
3069 /**
3070 * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split.
3071 * If the node is an only child, it will replace the parent
3072 */
3073 unwrapNodeByPath(path: Immutable.List<number>): Controller;
3074 /**
3075 * Wrap the given node by key in an Inline node that matches properties.
3076 */
3077 wrapInlineByKey(key: string, properties: InlineProperties | string): Controller;
3078 /**
3079 * Wrap the given node by path in an Inline node that matches properties.
3080 */
3081 wrapInlineByPath(path: Path, properties: InlineProperties | string): Controller;
3082 /**
3083 * Wrap the given node by key in a block node that matches properties.
3084 */
3085 wrapBlockByKey(key: string, properties: BlockProperties | string): Controller;
3086 /**
3087 * Wrap the given node by path in a block node that matches properties.
3088 */
3089 wrapBlockByPath(path: Immutable.List<number>, block: Block | string): Controller;
3090 /**
3091 * Wrap the node with the specified key with the parent node, this will clear all children of the parent.
3092 */
3093 wrapNodeByKey(key: string, parent: Node): Controller;
3094 /**
3095 * Wrap the node with the specified key with the parent node, this will clear all children of the parent.
3096 */
3097 wrapNodeByPath(path: Immutable.List<number>, parent: Node): Controller;
3098
3099 // Miscellaneous Commands //
3100 /**
3101 * Normalizes the document with the value's schema. Run automatically unless manually disabled.
3102 * Use it sparingly and strategically, as it can be very expensive.
3103 */
3104 normalize(): Controller;
3105 /**
3106 * Calls the provided function with the current commandable as the first argument.
3107 * Normalization does not occur while the function is executing and is deferred to execute immediately after completion.
3108 *
3109 * This allows for sequence change operations to not be interrupted by normalization
3110 */
3111 withoutNormalizing(fn: () => void): Controller;
3112 /**
3113 * By default all operations are saved to the commandable's history. If you have
3114 * changes that you don't want to show up in history, use this function.
3115 */
3116 withoutSaving(fn: () => void): void;
3117 /**
3118 * Usually all command operations are merged into a single save point in history,
3119 * if more control is desired, create single save points using this function.
3120 */
3121 withoutMerging(fn: () => void): void;
3122
3123 // History Commands //
3124 /**
3125 * Move forward one step in the history
3126 */
3127 redo(): Controller;
3128 /**
3129 * Move backward one step in the history
3130 */
3131 undo(): Controller;
3132 /**
3133 * Save an `operation` into the history.
3134 */
3135 save(operation: Operation): void;
3136 /**
3137 * Snapshot the current selection for undo purposes.
3138 */
3139 snapshotSelection(): Controller;
3140 command(type: string | ((...args: any[]) => any), ...args: any[]): Controller;
3141 /**
3142 * Check if a command by type has been registered.
3143 */
3144 hasCommand(type: string): boolean;
3145 /**
3146 * Check if a query by type has been registered.
3147 */
3148 hasQuery(type: string): boolean;
3149 query(query: string | ((...args: any[]) => any), ...args: any[]): any;
3150 /**
3151 * Add a new command by type to the controller. This will make the command available as a top-level method on the controller
3152 */
3153 registerCommand(command: string): Controller;
3154 /**
3155 * Add a new query by type to the controller. This will make the query available as a top-level method on the controller.
3156 */
3157 registerQuery(query: string): Controller;
3158 /**
3159 * Apply an `operation` to the controller, updating its value.
3160 */
3161 applyOperation(operation: Operation | OperationJSON | OperationProperties): Controller;
3162 /**
3163 * Run the middleware stack by key with args, returning its result.
3164 * In normal operation you never need to use this method! Reserved for testing.
3165 */
3166 run(key: string, ...args: any[]): Controller;
3167 /**
3168 * Set data
3169 */
3170 setData(data: Data): Controller;
3171 /**
3172 * Add annotation
3173 */
3174 addAnnotation(annotation: Annotation | AnnotationProperties | AnnotationJSON): Controller;
3175 /**
3176 * Remove annotation
3177 */
3178 removeAnnotation(annotation: Annotation | AnnotationProperties | AnnotationJSON): Controller;
3179 /**
3180 * Set annotation
3181 */
3182 setAnnotation(
3183 annotation: Annotation,
3184 newProperties: AnnotationProperties | AnnotationJSON | Annotation,
3185 ): Controller;
3186}
3187
3188export {};
3189
\No newline at end of file