@contentstack/studio-internal 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/constants/condition.d.ts +4513 -0
- package/dist/constants/condition.d.ts.map +1 -0
- package/dist/constants/condition.js +150 -0
- package/dist/constants/condition.js.map +1 -0
- package/dist/core/apply.d.ts +3 -0
- package/dist/core/apply.d.ts.map +1 -0
- package/dist/core/apply.js +41 -0
- package/dist/core/apply.js.map +1 -0
- package/dist/core/batch-dirty-paths.d.ts +4 -0
- package/dist/core/batch-dirty-paths.d.ts.map +1 -0
- package/dist/core/batch-dirty-paths.js +7 -0
- package/dist/core/batch-dirty-paths.js.map +1 -0
- package/dist/core/get-dirty-paths.d.ts +4 -0
- package/dist/core/get-dirty-paths.d.ts.map +1 -0
- package/dist/core/get-dirty-paths.js +45 -0
- package/dist/core/get-dirty-paths.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/normalize-node.d.ts +4 -0
- package/dist/core/normalize-node.d.ts.map +1 -0
- package/dist/core/normalize-node.js +16 -0
- package/dist/core/normalize-node.js.map +1 -0
- package/dist/core/should-normalize.d.ts +4 -0
- package/dist/core/should-normalize.d.ts.map +1 -0
- package/dist/core/should-normalize.js +10 -0
- package/dist/core/should-normalize.js.map +1 -0
- package/dist/core/update-dirty-paths.d.ts +3 -0
- package/dist/core/update-dirty-paths.d.ts.map +1 -0
- package/dist/core/update-dirty-paths.js +37 -0
- package/dist/core/update-dirty-paths.js.map +1 -0
- package/dist/create-editor.d.ts +3 -0
- package/dist/create-editor.d.ts.map +1 -0
- package/dist/create-editor.js +102 -0
- package/dist/create-editor.js.map +1 -0
- package/dist/editor/index.d.ts +11 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/is-editor.d.ts +3 -0
- package/dist/editor/is-editor.d.ts.map +1 -0
- package/dist/editor/is-editor.js +17 -0
- package/dist/editor/is-editor.js.map +1 -0
- package/dist/editor/is-normalizing.d.ts +3 -0
- package/dist/editor/is-normalizing.d.ts.map +1 -0
- package/dist/editor/is-normalizing.js +9 -0
- package/dist/editor/is-normalizing.js.map +1 -0
- package/dist/editor/node.d.ts +3 -0
- package/dist/editor/node.d.ts.map +1 -0
- package/dist/editor/node.js +11 -0
- package/dist/editor/node.js.map +1 -0
- package/dist/editor/nodes.d.ts +4 -0
- package/dist/editor/nodes.d.ts.map +1 -0
- package/dist/editor/nodes.js +63 -0
- package/dist/editor/nodes.js.map +1 -0
- package/dist/editor/normalize.d.ts +3 -0
- package/dist/editor/normalize.d.ts.map +1 -0
- package/dist/editor/normalize.js +54 -0
- package/dist/editor/normalize.js.map +1 -0
- package/dist/editor/path-refs.d.ts +3 -0
- package/dist/editor/path-refs.d.ts.map +1 -0
- package/dist/editor/path-refs.js +13 -0
- package/dist/editor/path-refs.js.map +1 -0
- package/dist/editor/pathRef.d.ts +3 -0
- package/dist/editor/pathRef.d.ts.map +1 -0
- package/dist/editor/pathRef.js +25 -0
- package/dist/editor/pathRef.js.map +1 -0
- package/dist/editor/set-active-context.d.ts +3 -0
- package/dist/editor/set-active-context.d.ts.map +1 -0
- package/dist/editor/set-active-context.js +10 -0
- package/dist/editor/set-active-context.js.map +1 -0
- package/dist/editor/set-normalizing.d.ts +3 -0
- package/dist/editor/set-normalizing.d.ts.map +1 -0
- package/dist/editor/set-normalizing.js +8 -0
- package/dist/editor/set-normalizing.js.map +1 -0
- package/dist/editor/unsaved-changes.d.ts +4 -0
- package/dist/editor/unsaved-changes.d.ts.map +1 -0
- package/dist/editor/unsaved-changes.js +11 -0
- package/dist/editor/unsaved-changes.js.map +1 -0
- package/dist/editor/without-normalizing.d.ts +3 -0
- package/dist/editor/without-normalizing.d.ts.map +1 -0
- package/dist/editor/without-normalizing.js +19 -0
- package/dist/editor/without-normalizing.js.map +1 -0
- package/dist/index.d.ts +5190 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/editor.d.ts +103 -0
- package/dist/interfaces/editor.d.ts.map +1 -0
- package/dist/interfaces/editor.js +43 -0
- package/dist/interfaces/editor.js.map +1 -0
- package/dist/interfaces/get-default-node-styles.d.ts +3 -0
- package/dist/interfaces/get-default-node-styles.d.ts.map +1 -0
- package/dist/interfaces/get-default-node-styles.js +9 -0
- package/dist/interfaces/get-default-node-styles.js.map +1 -0
- package/dist/interfaces/index.d.ts +7 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/node.d.ts +182 -0
- package/dist/interfaces/node.d.ts.map +1 -0
- package/dist/interfaces/node.js +158 -0
- package/dist/interfaces/node.js.map +1 -0
- package/dist/interfaces/operation.d.ts +86 -0
- package/dist/interfaces/operation.d.ts.map +1 -0
- package/dist/interfaces/operation.js +117 -0
- package/dist/interfaces/operation.js.map +1 -0
- package/dist/interfaces/path-ref.d.ts +15 -0
- package/dist/interfaces/path-ref.d.ts.map +1 -0
- package/dist/interfaces/path-ref.js +18 -0
- package/dist/interfaces/path-ref.js.map +1 -0
- package/dist/interfaces/path.d.ts +56 -0
- package/dist/interfaces/path.d.ts.map +1 -0
- package/dist/interfaces/path.js +205 -0
- package/dist/interfaces/path.js.map +1 -0
- package/dist/interfaces/transforms/general.d.ts +9 -0
- package/dist/interfaces/transforms/general.d.ts.map +1 -0
- package/dist/interfaces/transforms/general.js +125 -0
- package/dist/interfaces/transforms/general.js.map +1 -0
- package/dist/interfaces/transforms/index.d.ts +4 -0
- package/dist/interfaces/transforms/index.d.ts.map +1 -0
- package/dist/interfaces/transforms/index.js +10 -0
- package/dist/interfaces/transforms/index.js.map +1 -0
- package/dist/interfaces/transforms/node.d.ts +107 -0
- package/dist/interfaces/transforms/node.d.ts.map +1 -0
- package/dist/interfaces/transforms/node.js +50 -0
- package/dist/interfaces/transforms/node.js.map +1 -0
- package/dist/transforms-node/index.d.ts +15 -0
- package/dist/transforms-node/index.d.ts.map +1 -0
- package/dist/transforms-node/insert-nodes.d.ts +3 -0
- package/dist/transforms-node/insert-nodes.d.ts.map +1 -0
- package/dist/transforms-node/insert-nodes.js +45 -0
- package/dist/transforms-node/insert-nodes.js.map +1 -0
- package/dist/transforms-node/insert-slot.d.ts +3 -0
- package/dist/transforms-node/insert-slot.d.ts.map +1 -0
- package/dist/transforms-node/insert-slot.js +18 -0
- package/dist/transforms-node/insert-slot.js.map +1 -0
- package/dist/transforms-node/lift-nodes.d.ts +3 -0
- package/dist/transforms-node/lift-nodes.d.ts.map +1 -0
- package/dist/transforms-node/lift-nodes.js +38 -0
- package/dist/transforms-node/lift-nodes.js.map +1 -0
- package/dist/transforms-node/move-nodes.d.ts +3 -0
- package/dist/transforms-node/move-nodes.d.ts.map +1 -0
- package/dist/transforms-node/move-nodes.js +21 -0
- package/dist/transforms-node/move-nodes.js.map +1 -0
- package/dist/transforms-node/remove-nodes.d.ts +3 -0
- package/dist/transforms-node/remove-nodes.d.ts.map +1 -0
- package/dist/transforms-node/remove-nodes.js +20 -0
- package/dist/transforms-node/remove-nodes.js.map +1 -0
- package/dist/transforms-node/set-classes.d.ts +3 -0
- package/dist/transforms-node/set-classes.d.ts.map +1 -0
- package/dist/transforms-node/set-classes.js +48 -0
- package/dist/transforms-node/set-classes.js.map +1 -0
- package/dist/transforms-node/set-nodes.d.ts +3 -0
- package/dist/transforms-node/set-nodes.d.ts.map +1 -0
- package/dist/transforms-node/set-nodes.js +50 -0
- package/dist/transforms-node/set-nodes.js.map +1 -0
- package/dist/transforms-node/set-props.d.ts +3 -0
- package/dist/transforms-node/set-props.d.ts.map +1 -0
- package/dist/transforms-node/set-props.js +74 -0
- package/dist/transforms-node/set-props.js.map +1 -0
- package/dist/transforms-node/set-responsive-styles.d.ts +3 -0
- package/dist/transforms-node/set-responsive-styles.d.ts.map +1 -0
- package/dist/transforms-node/set-responsive-styles.js +41 -0
- package/dist/transforms-node/set-responsive-styles.js.map +1 -0
- package/dist/transforms-node/set-selection.d.ts +3 -0
- package/dist/transforms-node/set-selection.d.ts.map +1 -0
- package/dist/transforms-node/set-selection.js +21 -0
- package/dist/transforms-node/set-selection.js.map +1 -0
- package/dist/transforms-node/unset-classes.d.ts +3 -0
- package/dist/transforms-node/unset-classes.d.ts.map +1 -0
- package/dist/transforms-node/unset-classes.js +32 -0
- package/dist/transforms-node/unset-classes.js.map +1 -0
- package/dist/transforms-node/unset-props.d.ts +3 -0
- package/dist/transforms-node/unset-props.d.ts.map +1 -0
- package/dist/transforms-node/unset-props.js +35 -0
- package/dist/transforms-node/unset-props.js.map +1 -0
- package/dist/transforms-node/unset-responsive-styles.d.ts +3 -0
- package/dist/transforms-node/unset-responsive-styles.d.ts.map +1 -0
- package/dist/transforms-node/unset-responsive-styles.js +38 -0
- package/dist/transforms-node/unset-responsive-styles.js.map +1 -0
- package/dist/transforms-node/unwrap-nodes.d.ts +3 -0
- package/dist/transforms-node/unwrap-nodes.d.ts.map +1 -0
- package/dist/transforms-node/unwrap-nodes.js +19 -0
- package/dist/transforms-node/unwrap-nodes.js.map +1 -0
- package/dist/transforms-node/wrap-nodes.d.ts +3 -0
- package/dist/transforms-node/wrap-nodes.d.ts.map +1 -0
- package/dist/transforms-node/wrap-nodes.js +23 -0
- package/dist/transforms-node/wrap-nodes.js.map +1 -0
- package/dist/types/condition-types.d.ts +70 -0
- package/dist/types/condition-types.d.ts.map +1 -0
- package/dist/types/custom-types.d.ts +10 -0
- package/dist/types/custom-types.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +12 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/is-plain-object.d.ts +9 -0
- package/dist/utils/is-plain-object.d.ts.map +1 -0
- package/dist/utils/is-plain-object.js +32 -0
- package/dist/utils/is-plain-object.js.map +1 -0
- package/dist/utils/match-path.d.ts +5 -0
- package/dist/utils/match-path.d.ts.map +1 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/weak-maps.d.ts +8 -0
- package/dist/utils/weak-maps.d.ts.map +1 -0
- package/dist/utils/weak-maps.js +9 -0
- package/dist/utils/weak-maps.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the utilities for working with operations and not the
|
|
3
|
+
* actual operations themselves.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* If you plan to add more operations, you should add them here.
|
|
7
|
+
* Please ensure your operation are in do-undo pairs.
|
|
8
|
+
* For example, if you have an operation `insert_node`, you should also have
|
|
9
|
+
* an operation `remove_node` that will undo the `set_node` operation.
|
|
10
|
+
* Or, make the operation reversible like `set_node`.
|
|
11
|
+
*/
|
|
12
|
+
import { Descendant, NodeProp, Path } from ".";
|
|
13
|
+
export type InsertNodeOperation = {
|
|
14
|
+
type: "insert_node";
|
|
15
|
+
path: Path;
|
|
16
|
+
node: Descendant;
|
|
17
|
+
};
|
|
18
|
+
export type MoveNodeOperation = {
|
|
19
|
+
type: "move_node";
|
|
20
|
+
path: Path;
|
|
21
|
+
newPath: Path;
|
|
22
|
+
};
|
|
23
|
+
export type RemoveNodeOperation = {
|
|
24
|
+
type: "remove_node";
|
|
25
|
+
path: Path;
|
|
26
|
+
/**
|
|
27
|
+
* We need the node to be able to restore it in the inverse operation.
|
|
28
|
+
*/
|
|
29
|
+
node: Descendant;
|
|
30
|
+
};
|
|
31
|
+
export type SetNodeOperation = {
|
|
32
|
+
type: "set_node";
|
|
33
|
+
path: Path;
|
|
34
|
+
properties: Partial<Descendant>;
|
|
35
|
+
newProperties: Partial<Descendant> & Record<string, any>;
|
|
36
|
+
};
|
|
37
|
+
export type SetSelectionOperation = {
|
|
38
|
+
type: "set_selection";
|
|
39
|
+
path: Path;
|
|
40
|
+
};
|
|
41
|
+
export type SetActiveContextPathOperation = {
|
|
42
|
+
type: "set_active_context_path";
|
|
43
|
+
path: Path | null;
|
|
44
|
+
};
|
|
45
|
+
export type SetPropOperation = {
|
|
46
|
+
type: "set_prop";
|
|
47
|
+
path: Path;
|
|
48
|
+
propPath: string;
|
|
49
|
+
prop: NodeProp;
|
|
50
|
+
nodes: Descendant[];
|
|
51
|
+
};
|
|
52
|
+
export type UnsetPropOperation = {
|
|
53
|
+
type: "unset_prop";
|
|
54
|
+
path: Path;
|
|
55
|
+
propPath: string;
|
|
56
|
+
prop: NodeProp;
|
|
57
|
+
nodes: Descendant[];
|
|
58
|
+
};
|
|
59
|
+
export type NodeOperation = InsertNodeOperation | MoveNodeOperation | RemoveNodeOperation | SetNodeOperation;
|
|
60
|
+
export type SelectionOperation = SetSelectionOperation;
|
|
61
|
+
export type Operation = NodeOperation | SelectionOperation | SetActiveContextPathOperation;
|
|
62
|
+
export interface OperationInterface {
|
|
63
|
+
/**
|
|
64
|
+
* Check if a value is a `NodeOperation` object.
|
|
65
|
+
*/
|
|
66
|
+
isNodeOperation: (value: any) => value is NodeOperation;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a value is an `Operation` object.
|
|
69
|
+
*/
|
|
70
|
+
isOperation: (value: any) => value is Operation;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a value is a list of `Operation` objects.
|
|
73
|
+
*/
|
|
74
|
+
isOperationList: (value: any) => value is Operation[];
|
|
75
|
+
/**
|
|
76
|
+
* Check if a value is a `SelectionOperation` object.
|
|
77
|
+
*/
|
|
78
|
+
isSelectionOperation: (value: any) => value is SelectionOperation;
|
|
79
|
+
/**
|
|
80
|
+
* Invert an operation, returning a new operation that will exactly undo the
|
|
81
|
+
* original when applied.
|
|
82
|
+
*/
|
|
83
|
+
inverse: (op: Operation) => Operation;
|
|
84
|
+
}
|
|
85
|
+
export declare const Operation: OperationInterface;
|
|
86
|
+
//# sourceMappingURL=operation.d.ts.map
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AAE,QAAQ,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,iBAAiB,GACjB,mBAAmB,GACnB,gBAAgB,CAAC;AAErB,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,kBAAkB,GAClB,6BAA6B,CAAC;AAElC,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,aAAa,CAAC;IAExD;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,SAAS,CAAC;IAEhD;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,SAAS,EAAE,CAAC;IAEtD;;OAEG;IACH,oBAAoB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,kBAAkB,CAAC;IAElE;;;OAGG;IACH,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,SAAS,EAAE,kBA4HvB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Node } from './node.js';
|
|
2
|
+
import { isPlainObject } from '../utils/is-plain-object.js';
|
|
3
|
+
import { Path } from './path.js';
|
|
4
|
+
import 'immer';
|
|
5
|
+
|
|
6
|
+
// ***** INFORMATION ABOUT THE MODULE *****
|
|
7
|
+
/**
|
|
8
|
+
* This file contains the utilities for working with operations and not the
|
|
9
|
+
* actual operations themselves.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* If you plan to add more operations, you should add them here.
|
|
13
|
+
* Please ensure your operation are in do-undo pairs.
|
|
14
|
+
* For example, if you have an operation `insert_node`, you should also have
|
|
15
|
+
* an operation `remove_node` that will undo the `set_node` operation.
|
|
16
|
+
* Or, make the operation reversible like `set_node`.
|
|
17
|
+
*/
|
|
18
|
+
const Operation = {
|
|
19
|
+
isNodeOperation(value) {
|
|
20
|
+
return Operation.isOperation(value) && value.type.endsWith("_node");
|
|
21
|
+
},
|
|
22
|
+
isOperation(value) {
|
|
23
|
+
if (!isPlainObject(value)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
switch (value.type) {
|
|
27
|
+
case "insert_node":
|
|
28
|
+
return Path.isPath(value.path) && Node.isNode(value.node);
|
|
29
|
+
case "merge_node":
|
|
30
|
+
return (typeof value.position === "number" &&
|
|
31
|
+
Path.isPath(value.path) &&
|
|
32
|
+
isPlainObject(value.properties));
|
|
33
|
+
case "move_node":
|
|
34
|
+
return Path.isPath(value.path) && Path.isPath(value.newPath);
|
|
35
|
+
case "remove_node":
|
|
36
|
+
return Path.isPath(value.path) && Node.isNode(value.node);
|
|
37
|
+
case "set_node":
|
|
38
|
+
return (Path.isPath(value.path) &&
|
|
39
|
+
isPlainObject(value.properties) &&
|
|
40
|
+
isPlainObject(value.newProperties));
|
|
41
|
+
case "set_selection":
|
|
42
|
+
return Path.isPath(value.path);
|
|
43
|
+
case "set_prop": {
|
|
44
|
+
return (typeof value.propPath === "string" &&
|
|
45
|
+
isPlainObject(value.prop) &&
|
|
46
|
+
Array.isArray(value.nodes) &&
|
|
47
|
+
value.nodes.every(Node.isNode) &&
|
|
48
|
+
Path.isPath(value.path));
|
|
49
|
+
}
|
|
50
|
+
case "unset_prop": {
|
|
51
|
+
return (typeof value.propPath === "string" &&
|
|
52
|
+
isPlainObject(value.prop) &&
|
|
53
|
+
Array.isArray(value.nodes) &&
|
|
54
|
+
value.nodes.every(Node.isNode) &&
|
|
55
|
+
Path.isPath(value.path));
|
|
56
|
+
}
|
|
57
|
+
case "set_active_context": {
|
|
58
|
+
return typeof value.context === "string";
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
isOperationList(value) {
|
|
65
|
+
return (Array.isArray(value) && value.every((val) => Operation.isOperation(val)));
|
|
66
|
+
},
|
|
67
|
+
isSelectionOperation(value) {
|
|
68
|
+
return Operation.isOperation(value) && value.type.endsWith("_selection");
|
|
69
|
+
},
|
|
70
|
+
inverse(op) {
|
|
71
|
+
switch (op.type) {
|
|
72
|
+
case "insert_node": {
|
|
73
|
+
return { ...op, type: "remove_node" };
|
|
74
|
+
}
|
|
75
|
+
case "move_node": {
|
|
76
|
+
const { newPath, path } = op;
|
|
77
|
+
// PERF: in this case the move operation is a no-op anyways.
|
|
78
|
+
if (Path.equals(newPath, path)) {
|
|
79
|
+
return op;
|
|
80
|
+
}
|
|
81
|
+
// If the move happens completely within a single parent the path and
|
|
82
|
+
// newPath are stable with respect to each other.
|
|
83
|
+
if (Path.isSibling(path, newPath)) {
|
|
84
|
+
return { ...op, path: newPath, newPath: path };
|
|
85
|
+
}
|
|
86
|
+
// If the move does not happen within a single parent it is possible
|
|
87
|
+
// for the move to impact the true path to the location where the node
|
|
88
|
+
// was removed from and where it was inserted. We have to adjust for this
|
|
89
|
+
// and find the original path. We can accomplish this (only in non-sibling)
|
|
90
|
+
// moves by looking at the impact of the move operation on the node
|
|
91
|
+
// after the original move path.
|
|
92
|
+
const inversePath = Path.transform(path, op);
|
|
93
|
+
const inverseNewPath = Path.transform(Path.next(path), op);
|
|
94
|
+
return { ...op, path: inversePath, newPath: inverseNewPath };
|
|
95
|
+
}
|
|
96
|
+
case "remove_node": {
|
|
97
|
+
return { ...op, type: "insert_node" };
|
|
98
|
+
}
|
|
99
|
+
case "set_node": {
|
|
100
|
+
const { properties, newProperties } = op;
|
|
101
|
+
return { ...op, properties: newProperties, newProperties: properties };
|
|
102
|
+
}
|
|
103
|
+
case "set_selection": {
|
|
104
|
+
return { ...op };
|
|
105
|
+
}
|
|
106
|
+
case "set_active_context_path": {
|
|
107
|
+
return { ...op };
|
|
108
|
+
}
|
|
109
|
+
default: {
|
|
110
|
+
return op;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { Operation };
|
|
117
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sources":["../../src/interfaces/operation.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;AACA;;;AAGG;AAEH;;;;;;AAMG;AAoGI,MAAM,SAAS,GAAuB;AAC3C,IAAA,eAAe,CAAC,KAAU,EAAA;AACxB,QAAA,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IACrE,CAAC;AAED,IAAA,WAAW,CAAC,KAAU,EAAA;AACpB,QAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;AACzB,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,QAAQ,KAAK,CAAC,IAAI;AAChB,YAAA,KAAK,aAAa;AAChB,gBAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AAC3D,YAAA,KAAK,YAAY;AACf,gBAAA,QACE,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ;AAClC,oBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AACvB,oBAAA,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC;AAEnC,YAAA,KAAK,WAAW;AACd,gBAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,C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AO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;YACvC;YAEA,KAAK,UAAU,EAAE;AACf,gBAAA,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE;AACxC,gBAAA,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE;YACxE;YAEA,KAAK,eAAe,EAAE;AACpB,gBAAA,OAAO,EAAE,GAAG,EAAE,EAAE;YAClB;YAEA,KAAK,yBAAyB,EAAE;AAC9B,gBAAA,OAAO,EAAE,GAAG,EAAE,EAAE;YAClB;YAEA,SAAS;AAEP,gBAAA,OAAO,EAAE;YACX;;IAEJ,CAAC;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Operation } from ".";
|
|
2
|
+
import { Path } from "./path";
|
|
3
|
+
export interface PathRef {
|
|
4
|
+
current: Path | null;
|
|
5
|
+
affinity: "forward" | "backward" | null;
|
|
6
|
+
unref(): Path | null;
|
|
7
|
+
}
|
|
8
|
+
export interface PathRefInterface {
|
|
9
|
+
/**
|
|
10
|
+
* Transform the path ref's current value by an operation.
|
|
11
|
+
*/
|
|
12
|
+
transform: (ref: PathRef, op: Operation) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const PathRef: PathRefInterface;
|
|
15
|
+
//# sourceMappingURL=path-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-ref.d.ts","sourceRoot":"","sources":["../../src/interfaces/path-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,OAAO,EAAE,gBAerB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Path } from './path.js';
|
|
2
|
+
|
|
3
|
+
const PathRef = {
|
|
4
|
+
transform(ref, op) {
|
|
5
|
+
const { current, affinity } = ref;
|
|
6
|
+
if (current == null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const path = Path.transform(current, op, { affinity });
|
|
10
|
+
ref.current = path;
|
|
11
|
+
if (path === null) {
|
|
12
|
+
ref.unref();
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { PathRef };
|
|
18
|
+
//# sourceMappingURL=path-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-ref.js","sources":["../../src/interfaces/path-ref.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAgBO,MAAM,OAAO,GAAqB;IACvC,SAAS,CAAC,GAAY,EAAE,EAAa,EAAA;AACnC,QAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG;AAEjC,QAAA,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB;QACF;AAEA,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACtD,QAAA,GAAG,CAAC,OAAO,GAAG,IAAI;AAElB,QAAA,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,GAAG,CAAC,KAAK,EAAE;QACb;IACF,CAAC;;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TextDirection } from "../types";
|
|
2
|
+
import { InsertNodeOperation, MoveNodeOperation, Operation, RemoveNodeOperation } from "./operation";
|
|
3
|
+
/**
|
|
4
|
+
* All the child nodes belong to a slot. The slot UID represents the slot.
|
|
5
|
+
*/
|
|
6
|
+
export type SlotUid = string;
|
|
7
|
+
/**
|
|
8
|
+
* The index of a node inside a slot. A slot is an array of nodes. The index represents the position of the node inside the slot.
|
|
9
|
+
*/
|
|
10
|
+
export type PathIndex = number;
|
|
11
|
+
/**
|
|
12
|
+
* A path node determines the position of the node. Every node will have a unique path node.
|
|
13
|
+
*/
|
|
14
|
+
export type PathNode = [SlotUid, PathIndex];
|
|
15
|
+
/**
|
|
16
|
+
* The path represents the address of a node from the root node. It is an array of path nodes.
|
|
17
|
+
*/
|
|
18
|
+
export type Path = PathNode[];
|
|
19
|
+
export interface PathTransformOptions {
|
|
20
|
+
affinity?: TextDirection | null;
|
|
21
|
+
}
|
|
22
|
+
export interface PathAncestorsOptions {
|
|
23
|
+
reverse?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface PathLevelsOptions {
|
|
26
|
+
reverse?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PathInterface {
|
|
29
|
+
ancestors: (path: Path, options?: PathAncestorsOptions) => Path[];
|
|
30
|
+
parent: (path: Path) => Path;
|
|
31
|
+
common: (path: Path, another: Path) => Path;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param path The path to compare
|
|
35
|
+
* @param another The path to compare with
|
|
36
|
+
* @returns It returns -1 if the path is before the another path, 0 if they are equal, 1 if the path is after the another path, and null if they are not comparable. The paths are not comparable if they belong to separate slots.
|
|
37
|
+
*/
|
|
38
|
+
compare: (path: Path, another: Path) => -1 | 0 | 1 | null;
|
|
39
|
+
isPath: (value: any) => value is Path;
|
|
40
|
+
previous: (path: Path) => Path;
|
|
41
|
+
equals: (path: Path, another: Path) => boolean;
|
|
42
|
+
hasPrevious: (path: Path) => boolean;
|
|
43
|
+
isSibling: (path: Path, another: Path) => boolean;
|
|
44
|
+
next: (path: Path) => Path;
|
|
45
|
+
transform: (path: Path, operation: Operation, options?: PathTransformOptions) => Path | null;
|
|
46
|
+
isAncestor: (path: Path, another: Path) => boolean;
|
|
47
|
+
endsBefore: (path: Path, another: Path) => boolean;
|
|
48
|
+
levels: (path: Path, options?: PathLevelsOptions) => Path[];
|
|
49
|
+
operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation | MoveNodeOperation;
|
|
50
|
+
isBefore: (path: Path, another: Path) => boolean;
|
|
51
|
+
isAfter: (path: Path, another: Path) => boolean;
|
|
52
|
+
isDescendant: (childPath: Path, parentPath: Path) => boolean;
|
|
53
|
+
relative: (parentPath: Path, childPath: Path) => Path;
|
|
54
|
+
}
|
|
55
|
+
export declare const Path: PathInterface;
|
|
56
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/interfaces/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC5C;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;AAE9B,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EA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E,SAAS,KACjB,SAAS,IACV,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,CAAC;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAC;IACjD,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAC;IAChD,YAAY,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,OAAO,CAAC;IAC7D,QAAQ,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,IAAI,EAAE,aA6PlB,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash-es';
|
|
2
|
+
|
|
3
|
+
const Path = {
|
|
4
|
+
ancestors(path, options = {}) {
|
|
5
|
+
const ancestors = [];
|
|
6
|
+
const { reverse = false } = options;
|
|
7
|
+
for (let i = 0; i < path.length; i++) {
|
|
8
|
+
ancestors.push(path.slice(0, i));
|
|
9
|
+
}
|
|
10
|
+
if (reverse) {
|
|
11
|
+
return ancestors.reverse();
|
|
12
|
+
}
|
|
13
|
+
return ancestors;
|
|
14
|
+
},
|
|
15
|
+
parent(path) {
|
|
16
|
+
return path.length === 0 ? [] : path.slice(0, -1);
|
|
17
|
+
},
|
|
18
|
+
common(path, another) {
|
|
19
|
+
const common = [];
|
|
20
|
+
for (let i = 0; i < path.length && i < another.length; i++) {
|
|
21
|
+
const av = path[i];
|
|
22
|
+
const bv = another[i];
|
|
23
|
+
if (av[0] !== bv[0] || av[1] !== bv[1]) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
common.push(av);
|
|
27
|
+
}
|
|
28
|
+
return common;
|
|
29
|
+
},
|
|
30
|
+
compare(path, another) {
|
|
31
|
+
const min = Math.min(path.length, another.length);
|
|
32
|
+
for (let i = 0; i < min; i++) {
|
|
33
|
+
// Since they belong to different slots, they are not comparable.
|
|
34
|
+
if (path[i][0] !== another[i][0])
|
|
35
|
+
return null;
|
|
36
|
+
if (path[i][1] < another[i][1])
|
|
37
|
+
return -1;
|
|
38
|
+
if (path[i][1] > another[i][1])
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
},
|
|
43
|
+
isPath(value) {
|
|
44
|
+
return (Array.isArray(value) &&
|
|
45
|
+
(value.length === 0 ||
|
|
46
|
+
(typeof value[0][0] === "string" && typeof value[0][1] === "number")));
|
|
47
|
+
},
|
|
48
|
+
previous(path) {
|
|
49
|
+
if (path.length === 0) {
|
|
50
|
+
throw new Error(`Cannot get the previous path of a root path [${path}], because it has no previous index.`);
|
|
51
|
+
}
|
|
52
|
+
const last = path[path.length - 1];
|
|
53
|
+
if (last[1] <= 0) {
|
|
54
|
+
throw new Error(`Cannot get the previous path of a first child path [${path}] because it would result in a negative index.`);
|
|
55
|
+
}
|
|
56
|
+
return path.slice(0, -1).concat([[last[0], last[1] - 1]]);
|
|
57
|
+
},
|
|
58
|
+
hasPrevious(path) {
|
|
59
|
+
return path.length > 0 && path[path.length - 1][1] > 0;
|
|
60
|
+
},
|
|
61
|
+
equals(path, another) {
|
|
62
|
+
return (path.length === another.length &&
|
|
63
|
+
path.every((n, i) => n[0] === another[i][0] && n[1] === another[i][1]));
|
|
64
|
+
},
|
|
65
|
+
isSibling(path, another) {
|
|
66
|
+
if (path.length !== another.length) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const as = path.slice(0, -1);
|
|
70
|
+
const bs = another.slice(0, -1);
|
|
71
|
+
const al = path[path.length - 1];
|
|
72
|
+
const bl = another[another.length - 1];
|
|
73
|
+
return al !== bl && Path.equals(as, bs);
|
|
74
|
+
},
|
|
75
|
+
next(path) {
|
|
76
|
+
if (path.length === 0) {
|
|
77
|
+
throw new Error(`Cannot get the next path of a root path [${path}], because it has no next index.`);
|
|
78
|
+
}
|
|
79
|
+
const last = path[path.length - 1];
|
|
80
|
+
return path.slice(0, -1).concat([[last[0], last[1] + 1]]);
|
|
81
|
+
},
|
|
82
|
+
isAncestor(path, another) {
|
|
83
|
+
return path.length < another.length && Path.compare(path, another) === 0;
|
|
84
|
+
},
|
|
85
|
+
endsBefore(path, another) {
|
|
86
|
+
const i = path.length - 1;
|
|
87
|
+
const as = path.slice(0, i);
|
|
88
|
+
const bs = another.slice(0, i);
|
|
89
|
+
const av = path[i];
|
|
90
|
+
const bv = another[i];
|
|
91
|
+
return Path.equals(as, bs) && av < bv;
|
|
92
|
+
},
|
|
93
|
+
transform(path, operation) {
|
|
94
|
+
if (!path)
|
|
95
|
+
return null;
|
|
96
|
+
// PERF: use destructing instead of immer
|
|
97
|
+
const p = cloneDeep(path);
|
|
98
|
+
// const { affinity = "forward" } = options;
|
|
99
|
+
// PERF: Exit early if the operation is guaranteed not to have an effect.
|
|
100
|
+
if (path.length === 0) {
|
|
101
|
+
return p;
|
|
102
|
+
}
|
|
103
|
+
switch (operation.type) {
|
|
104
|
+
case "insert_node": {
|
|
105
|
+
const { path: op } = operation;
|
|
106
|
+
if (Path.equals(op, p) ||
|
|
107
|
+
Path.endsBefore(op, p) ||
|
|
108
|
+
Path.isAncestor(op, p)) {
|
|
109
|
+
p[op.length - 1][1] += 1;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case "remove_node": {
|
|
114
|
+
const { path: op } = operation;
|
|
115
|
+
if (Path.equals(op, p) || Path.isAncestor(op, p)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
else if (Path.endsBefore(op, p)) {
|
|
119
|
+
p[op.length - 1][1] -= 1;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "move_node": {
|
|
124
|
+
const { path: op, newPath: onp } = operation;
|
|
125
|
+
// If the old and new path are the same, it's a no-op.
|
|
126
|
+
if (Path.equals(op, onp)) {
|
|
127
|
+
return p;
|
|
128
|
+
}
|
|
129
|
+
if (Path.isAncestor(op, p) || Path.equals(op, p)) {
|
|
130
|
+
const copy = cloneDeep(onp);
|
|
131
|
+
if (Path.endsBefore(op, onp) && op.length < onp.length) {
|
|
132
|
+
copy[op.length - 1][1] -= 1;
|
|
133
|
+
}
|
|
134
|
+
return copy.concat(p.slice(op.length));
|
|
135
|
+
}
|
|
136
|
+
else if (Path.isSibling(op, onp) &&
|
|
137
|
+
(Path.isAncestor(onp, p) || Path.equals(onp, p))) {
|
|
138
|
+
if (Path.endsBefore(op, p)) {
|
|
139
|
+
p[op.length - 1][1] -= 1;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
p[op.length - 1][1] += 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (Path.endsBefore(onp, p) ||
|
|
146
|
+
Path.equals(onp, p) ||
|
|
147
|
+
Path.isAncestor(onp, p)) {
|
|
148
|
+
if (Path.endsBefore(op, p)) {
|
|
149
|
+
p[op.length - 1][1] -= 1;
|
|
150
|
+
}
|
|
151
|
+
p[onp.length - 1][1] += 1;
|
|
152
|
+
}
|
|
153
|
+
else if (Path.endsBefore(op, p)) {
|
|
154
|
+
if (Path.equals(onp, p)) {
|
|
155
|
+
p[onp.length - 1][1] += 1;
|
|
156
|
+
}
|
|
157
|
+
p[op.length - 1][1] -= 1;
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return p;
|
|
163
|
+
},
|
|
164
|
+
operationCanTransformPath(operation) {
|
|
165
|
+
switch (operation.type) {
|
|
166
|
+
case "insert_node":
|
|
167
|
+
case "remove_node":
|
|
168
|
+
case "move_node":
|
|
169
|
+
return true;
|
|
170
|
+
default:
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
levels: (path, options = {}) => {
|
|
175
|
+
const { reverse = false } = options;
|
|
176
|
+
const list = [];
|
|
177
|
+
for (let i = 0; i <= path.length; i++) {
|
|
178
|
+
list.push(path.slice(0, i));
|
|
179
|
+
}
|
|
180
|
+
if (reverse) {
|
|
181
|
+
list.reverse();
|
|
182
|
+
}
|
|
183
|
+
return list;
|
|
184
|
+
},
|
|
185
|
+
isBefore(path, another) {
|
|
186
|
+
return Path.compare(path, another) === -1;
|
|
187
|
+
},
|
|
188
|
+
isAfter(path, another) {
|
|
189
|
+
return Path.compare(path, another) === 1;
|
|
190
|
+
},
|
|
191
|
+
isDescendant(childPath, parentPath) {
|
|
192
|
+
if (!childPath || !parentPath) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
return (childPath.length > parentPath.length &&
|
|
196
|
+
Path.compare(childPath, parentPath) === 0);
|
|
197
|
+
},
|
|
198
|
+
relative(parentPath, childPath) {
|
|
199
|
+
// TODO: Handle the case where the child path is not a descendant of the parent path
|
|
200
|
+
return childPath.slice(parentPath.length);
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export { Path };
|
|
205
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sources":["../../src/interfaces/path.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA2EO,MAAM,IAAI,GAAkB;AACjC,IAAA,SAAS,CAAC,IAAU,EAAE,OAAA,GAAgC,EAAE,EAAA;QACtD,MAAM,SAAS,GAAW,EAAE;AAC5B,QAAA,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO;AACnC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACpC,YAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC;QACA,IAAI,OAAO,EAAE;AACX,YAAA,OAAO,SAAS,CAAC,OAAO,EAAE;QAC5B;AACA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YACpC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC;IAE7C,CAAC;IACD,QAAQ,CAAC,UAAgB,EAAE,SAAe,EAAA;;QAExC,OAAO,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;IAC3C,CAAC;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Editor, Operation } from "../index";
|
|
2
|
+
export interface GeneralTransforms {
|
|
3
|
+
/**
|
|
4
|
+
* Transform the editor by an operation.
|
|
5
|
+
*/
|
|
6
|
+
transform: (editor: Editor, op: Operation) => Editor;
|
|
7
|
+
}
|
|
8
|
+
export declare const GeneralTransforms: GeneralTransforms;
|
|
9
|
+
//# sourceMappingURL=general.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/general.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAQ,SAAS,EAAQ,MAAM,UAAU,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC;CACtD;AA6HD,eAAO,MAAM,iBAAiB,EAAE,iBAoB/B,CAAC"}
|