UNPKG

3.53 kBTypeScriptView Raw
1import { ExtendedType, Node, Path, Range } from '..';
2export declare type BaseInsertNodeOperation = {
3 type: 'insert_node';
4 path: Path;
5 node: Node;
6};
7export declare type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
8export declare type BaseInsertTextOperation = {
9 type: 'insert_text';
10 path: Path;
11 offset: number;
12 text: string;
13};
14export declare type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
15export declare type BaseMergeNodeOperation = {
16 type: 'merge_node';
17 path: Path;
18 position: number;
19 properties: Partial<Node>;
20};
21export declare type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
22export declare type BaseMoveNodeOperation = {
23 type: 'move_node';
24 path: Path;
25 newPath: Path;
26};
27export declare type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
28export declare type BaseRemoveNodeOperation = {
29 type: 'remove_node';
30 path: Path;
31 node: Node;
32};
33export declare type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
34export declare type BaseRemoveTextOperation = {
35 type: 'remove_text';
36 path: Path;
37 offset: number;
38 text: string;
39};
40export declare type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
41export declare type BaseSetNodeOperation = {
42 type: 'set_node';
43 path: Path;
44 properties: Partial<Node>;
45 newProperties: Partial<Node>;
46};
47export declare type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
48export declare type BaseSetSelectionOperation = {
49 type: 'set_selection';
50 properties: null;
51 newProperties: Range;
52} | {
53 type: 'set_selection';
54 properties: Partial<Range>;
55 newProperties: Partial<Range>;
56} | {
57 type: 'set_selection';
58 properties: Range;
59 newProperties: null;
60};
61export declare type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
62export declare type BaseSplitNodeOperation = {
63 type: 'split_node';
64 path: Path;
65 position: number;
66 properties: Partial<Node>;
67};
68export declare type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
69export declare type NodeOperation = InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
70export declare type SelectionOperation = SetSelectionOperation;
71export declare type TextOperation = InsertTextOperation | RemoveTextOperation;
72/**
73 * `Operation` objects define the low-level instructions that Slate editors use
74 * to apply changes to their internal state. Representing all changes as
75 * operations is what allows Slate editors to easily implement history,
76 * collaboration, and other features.
77 */
78export declare type Operation = NodeOperation | SelectionOperation | TextOperation;
79export interface OperationInterface {
80 isNodeOperation: (value: any) => value is NodeOperation;
81 isOperation: (value: any) => value is Operation;
82 isOperationList: (value: any) => value is Operation[];
83 isSelectionOperation: (value: any) => value is SelectionOperation;
84 isTextOperation: (value: any) => value is TextOperation;
85 inverse: (op: Operation) => Operation;
86}
87export declare const Operation: OperationInterface;
88//# sourceMappingURL=operation.d.ts.map
\No newline at end of file