1 | import { ExtendedType, Node, Path, Range } from '..';
|
2 | export type BaseInsertNodeOperation = {
|
3 | type: 'insert_node';
|
4 | path: Path;
|
5 | node: Node;
|
6 | };
|
7 | export type InsertNodeOperation = ExtendedType<'InsertNodeOperation', BaseInsertNodeOperation>;
|
8 | export type BaseInsertTextOperation = {
|
9 | type: 'insert_text';
|
10 | path: Path;
|
11 | offset: number;
|
12 | text: string;
|
13 | };
|
14 | export type InsertTextOperation = ExtendedType<'InsertTextOperation', BaseInsertTextOperation>;
|
15 | export type BaseMergeNodeOperation = {
|
16 | type: 'merge_node';
|
17 | path: Path;
|
18 | position: number;
|
19 | properties: Partial<Node>;
|
20 | };
|
21 | export type MergeNodeOperation = ExtendedType<'MergeNodeOperation', BaseMergeNodeOperation>;
|
22 | export type BaseMoveNodeOperation = {
|
23 | type: 'move_node';
|
24 | path: Path;
|
25 | newPath: Path;
|
26 | };
|
27 | export type MoveNodeOperation = ExtendedType<'MoveNodeOperation', BaseMoveNodeOperation>;
|
28 | export type BaseRemoveNodeOperation = {
|
29 | type: 'remove_node';
|
30 | path: Path;
|
31 | node: Node;
|
32 | };
|
33 | export type RemoveNodeOperation = ExtendedType<'RemoveNodeOperation', BaseRemoveNodeOperation>;
|
34 | export type BaseRemoveTextOperation = {
|
35 | type: 'remove_text';
|
36 | path: Path;
|
37 | offset: number;
|
38 | text: string;
|
39 | };
|
40 | export type RemoveTextOperation = ExtendedType<'RemoveTextOperation', BaseRemoveTextOperation>;
|
41 | export type BaseSetNodeOperation = {
|
42 | type: 'set_node';
|
43 | path: Path;
|
44 | properties: Partial<Node>;
|
45 | newProperties: Partial<Node>;
|
46 | };
|
47 | export type SetNodeOperation = ExtendedType<'SetNodeOperation', BaseSetNodeOperation>;
|
48 | export 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 | };
|
61 | export type SetSelectionOperation = ExtendedType<'SetSelectionOperation', BaseSetSelectionOperation>;
|
62 | export type BaseSplitNodeOperation = {
|
63 | type: 'split_node';
|
64 | path: Path;
|
65 | position: number;
|
66 | properties: Partial<Node>;
|
67 | };
|
68 | export type SplitNodeOperation = ExtendedType<'SplitNodeOperation', BaseSplitNodeOperation>;
|
69 | export type NodeOperation = InsertNodeOperation | MergeNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation | SplitNodeOperation;
|
70 | export type SelectionOperation = SetSelectionOperation;
|
71 | export type TextOperation = InsertTextOperation | RemoveTextOperation;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | export type BaseOperation = NodeOperation | SelectionOperation | TextOperation;
|
79 | export type Operation = ExtendedType<'Operation', BaseOperation>;
|
80 | export interface OperationInterface {
|
81 | |
82 |
|
83 |
|
84 | isNodeOperation: (value: any) => value is NodeOperation;
|
85 | |
86 |
|
87 |
|
88 | isOperation: (value: any) => value is Operation;
|
89 | |
90 |
|
91 |
|
92 | isOperationList: (value: any) => value is Operation[];
|
93 | |
94 |
|
95 |
|
96 | isSelectionOperation: (value: any) => value is SelectionOperation;
|
97 | |
98 |
|
99 |
|
100 | isTextOperation: (value: any) => value is TextOperation;
|
101 | |
102 |
|
103 |
|
104 |
|
105 | inverse: (op: Operation) => Operation;
|
106 | }
|
107 | export declare const Operation: OperationInterface;
|
108 |
|
\ | No newline at end of file |