@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.
Files changed (210) hide show
  1. package/README.md +79 -0
  2. package/dist/constants/condition.d.ts +4513 -0
  3. package/dist/constants/condition.d.ts.map +1 -0
  4. package/dist/constants/condition.js +150 -0
  5. package/dist/constants/condition.js.map +1 -0
  6. package/dist/core/apply.d.ts +3 -0
  7. package/dist/core/apply.d.ts.map +1 -0
  8. package/dist/core/apply.js +41 -0
  9. package/dist/core/apply.js.map +1 -0
  10. package/dist/core/batch-dirty-paths.d.ts +4 -0
  11. package/dist/core/batch-dirty-paths.d.ts.map +1 -0
  12. package/dist/core/batch-dirty-paths.js +7 -0
  13. package/dist/core/batch-dirty-paths.js.map +1 -0
  14. package/dist/core/get-dirty-paths.d.ts +4 -0
  15. package/dist/core/get-dirty-paths.d.ts.map +1 -0
  16. package/dist/core/get-dirty-paths.js +45 -0
  17. package/dist/core/get-dirty-paths.js.map +1 -0
  18. package/dist/core/index.d.ts +5 -0
  19. package/dist/core/index.d.ts.map +1 -0
  20. package/dist/core/normalize-node.d.ts +4 -0
  21. package/dist/core/normalize-node.d.ts.map +1 -0
  22. package/dist/core/normalize-node.js +16 -0
  23. package/dist/core/normalize-node.js.map +1 -0
  24. package/dist/core/should-normalize.d.ts +4 -0
  25. package/dist/core/should-normalize.d.ts.map +1 -0
  26. package/dist/core/should-normalize.js +10 -0
  27. package/dist/core/should-normalize.js.map +1 -0
  28. package/dist/core/update-dirty-paths.d.ts +3 -0
  29. package/dist/core/update-dirty-paths.d.ts.map +1 -0
  30. package/dist/core/update-dirty-paths.js +37 -0
  31. package/dist/core/update-dirty-paths.js.map +1 -0
  32. package/dist/create-editor.d.ts +3 -0
  33. package/dist/create-editor.d.ts.map +1 -0
  34. package/dist/create-editor.js +102 -0
  35. package/dist/create-editor.js.map +1 -0
  36. package/dist/editor/index.d.ts +11 -0
  37. package/dist/editor/index.d.ts.map +1 -0
  38. package/dist/editor/is-editor.d.ts +3 -0
  39. package/dist/editor/is-editor.d.ts.map +1 -0
  40. package/dist/editor/is-editor.js +17 -0
  41. package/dist/editor/is-editor.js.map +1 -0
  42. package/dist/editor/is-normalizing.d.ts +3 -0
  43. package/dist/editor/is-normalizing.d.ts.map +1 -0
  44. package/dist/editor/is-normalizing.js +9 -0
  45. package/dist/editor/is-normalizing.js.map +1 -0
  46. package/dist/editor/node.d.ts +3 -0
  47. package/dist/editor/node.d.ts.map +1 -0
  48. package/dist/editor/node.js +11 -0
  49. package/dist/editor/node.js.map +1 -0
  50. package/dist/editor/nodes.d.ts +4 -0
  51. package/dist/editor/nodes.d.ts.map +1 -0
  52. package/dist/editor/nodes.js +63 -0
  53. package/dist/editor/nodes.js.map +1 -0
  54. package/dist/editor/normalize.d.ts +3 -0
  55. package/dist/editor/normalize.d.ts.map +1 -0
  56. package/dist/editor/normalize.js +54 -0
  57. package/dist/editor/normalize.js.map +1 -0
  58. package/dist/editor/path-refs.d.ts +3 -0
  59. package/dist/editor/path-refs.d.ts.map +1 -0
  60. package/dist/editor/path-refs.js +13 -0
  61. package/dist/editor/path-refs.js.map +1 -0
  62. package/dist/editor/pathRef.d.ts +3 -0
  63. package/dist/editor/pathRef.d.ts.map +1 -0
  64. package/dist/editor/pathRef.js +25 -0
  65. package/dist/editor/pathRef.js.map +1 -0
  66. package/dist/editor/set-active-context.d.ts +3 -0
  67. package/dist/editor/set-active-context.d.ts.map +1 -0
  68. package/dist/editor/set-active-context.js +10 -0
  69. package/dist/editor/set-active-context.js.map +1 -0
  70. package/dist/editor/set-normalizing.d.ts +3 -0
  71. package/dist/editor/set-normalizing.d.ts.map +1 -0
  72. package/dist/editor/set-normalizing.js +8 -0
  73. package/dist/editor/set-normalizing.js.map +1 -0
  74. package/dist/editor/unsaved-changes.d.ts +4 -0
  75. package/dist/editor/unsaved-changes.d.ts.map +1 -0
  76. package/dist/editor/unsaved-changes.js +11 -0
  77. package/dist/editor/unsaved-changes.js.map +1 -0
  78. package/dist/editor/without-normalizing.d.ts +3 -0
  79. package/dist/editor/without-normalizing.d.ts.map +1 -0
  80. package/dist/editor/without-normalizing.js +19 -0
  81. package/dist/editor/without-normalizing.js.map +1 -0
  82. package/dist/index.d.ts +5190 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +36 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/interfaces/editor.d.ts +103 -0
  87. package/dist/interfaces/editor.d.ts.map +1 -0
  88. package/dist/interfaces/editor.js +43 -0
  89. package/dist/interfaces/editor.js.map +1 -0
  90. package/dist/interfaces/get-default-node-styles.d.ts +3 -0
  91. package/dist/interfaces/get-default-node-styles.d.ts.map +1 -0
  92. package/dist/interfaces/get-default-node-styles.js +9 -0
  93. package/dist/interfaces/get-default-node-styles.js.map +1 -0
  94. package/dist/interfaces/index.d.ts +7 -0
  95. package/dist/interfaces/index.d.ts.map +1 -0
  96. package/dist/interfaces/node.d.ts +182 -0
  97. package/dist/interfaces/node.d.ts.map +1 -0
  98. package/dist/interfaces/node.js +158 -0
  99. package/dist/interfaces/node.js.map +1 -0
  100. package/dist/interfaces/operation.d.ts +86 -0
  101. package/dist/interfaces/operation.d.ts.map +1 -0
  102. package/dist/interfaces/operation.js +117 -0
  103. package/dist/interfaces/operation.js.map +1 -0
  104. package/dist/interfaces/path-ref.d.ts +15 -0
  105. package/dist/interfaces/path-ref.d.ts.map +1 -0
  106. package/dist/interfaces/path-ref.js +18 -0
  107. package/dist/interfaces/path-ref.js.map +1 -0
  108. package/dist/interfaces/path.d.ts +56 -0
  109. package/dist/interfaces/path.d.ts.map +1 -0
  110. package/dist/interfaces/path.js +205 -0
  111. package/dist/interfaces/path.js.map +1 -0
  112. package/dist/interfaces/transforms/general.d.ts +9 -0
  113. package/dist/interfaces/transforms/general.d.ts.map +1 -0
  114. package/dist/interfaces/transforms/general.js +125 -0
  115. package/dist/interfaces/transforms/general.js.map +1 -0
  116. package/dist/interfaces/transforms/index.d.ts +4 -0
  117. package/dist/interfaces/transforms/index.d.ts.map +1 -0
  118. package/dist/interfaces/transforms/index.js +10 -0
  119. package/dist/interfaces/transforms/index.js.map +1 -0
  120. package/dist/interfaces/transforms/node.d.ts +107 -0
  121. package/dist/interfaces/transforms/node.d.ts.map +1 -0
  122. package/dist/interfaces/transforms/node.js +50 -0
  123. package/dist/interfaces/transforms/node.js.map +1 -0
  124. package/dist/transforms-node/index.d.ts +15 -0
  125. package/dist/transforms-node/index.d.ts.map +1 -0
  126. package/dist/transforms-node/insert-nodes.d.ts +3 -0
  127. package/dist/transforms-node/insert-nodes.d.ts.map +1 -0
  128. package/dist/transforms-node/insert-nodes.js +45 -0
  129. package/dist/transforms-node/insert-nodes.js.map +1 -0
  130. package/dist/transforms-node/insert-slot.d.ts +3 -0
  131. package/dist/transforms-node/insert-slot.d.ts.map +1 -0
  132. package/dist/transforms-node/insert-slot.js +18 -0
  133. package/dist/transforms-node/insert-slot.js.map +1 -0
  134. package/dist/transforms-node/lift-nodes.d.ts +3 -0
  135. package/dist/transforms-node/lift-nodes.d.ts.map +1 -0
  136. package/dist/transforms-node/lift-nodes.js +38 -0
  137. package/dist/transforms-node/lift-nodes.js.map +1 -0
  138. package/dist/transforms-node/move-nodes.d.ts +3 -0
  139. package/dist/transforms-node/move-nodes.d.ts.map +1 -0
  140. package/dist/transforms-node/move-nodes.js +21 -0
  141. package/dist/transforms-node/move-nodes.js.map +1 -0
  142. package/dist/transforms-node/remove-nodes.d.ts +3 -0
  143. package/dist/transforms-node/remove-nodes.d.ts.map +1 -0
  144. package/dist/transforms-node/remove-nodes.js +20 -0
  145. package/dist/transforms-node/remove-nodes.js.map +1 -0
  146. package/dist/transforms-node/set-classes.d.ts +3 -0
  147. package/dist/transforms-node/set-classes.d.ts.map +1 -0
  148. package/dist/transforms-node/set-classes.js +48 -0
  149. package/dist/transforms-node/set-classes.js.map +1 -0
  150. package/dist/transforms-node/set-nodes.d.ts +3 -0
  151. package/dist/transforms-node/set-nodes.d.ts.map +1 -0
  152. package/dist/transforms-node/set-nodes.js +50 -0
  153. package/dist/transforms-node/set-nodes.js.map +1 -0
  154. package/dist/transforms-node/set-props.d.ts +3 -0
  155. package/dist/transforms-node/set-props.d.ts.map +1 -0
  156. package/dist/transforms-node/set-props.js +74 -0
  157. package/dist/transforms-node/set-props.js.map +1 -0
  158. package/dist/transforms-node/set-responsive-styles.d.ts +3 -0
  159. package/dist/transforms-node/set-responsive-styles.d.ts.map +1 -0
  160. package/dist/transforms-node/set-responsive-styles.js +41 -0
  161. package/dist/transforms-node/set-responsive-styles.js.map +1 -0
  162. package/dist/transforms-node/set-selection.d.ts +3 -0
  163. package/dist/transforms-node/set-selection.d.ts.map +1 -0
  164. package/dist/transforms-node/set-selection.js +21 -0
  165. package/dist/transforms-node/set-selection.js.map +1 -0
  166. package/dist/transforms-node/unset-classes.d.ts +3 -0
  167. package/dist/transforms-node/unset-classes.d.ts.map +1 -0
  168. package/dist/transforms-node/unset-classes.js +32 -0
  169. package/dist/transforms-node/unset-classes.js.map +1 -0
  170. package/dist/transforms-node/unset-props.d.ts +3 -0
  171. package/dist/transforms-node/unset-props.d.ts.map +1 -0
  172. package/dist/transforms-node/unset-props.js +35 -0
  173. package/dist/transforms-node/unset-props.js.map +1 -0
  174. package/dist/transforms-node/unset-responsive-styles.d.ts +3 -0
  175. package/dist/transforms-node/unset-responsive-styles.d.ts.map +1 -0
  176. package/dist/transforms-node/unset-responsive-styles.js +38 -0
  177. package/dist/transforms-node/unset-responsive-styles.js.map +1 -0
  178. package/dist/transforms-node/unwrap-nodes.d.ts +3 -0
  179. package/dist/transforms-node/unwrap-nodes.d.ts.map +1 -0
  180. package/dist/transforms-node/unwrap-nodes.js +19 -0
  181. package/dist/transforms-node/unwrap-nodes.js.map +1 -0
  182. package/dist/transforms-node/wrap-nodes.d.ts +3 -0
  183. package/dist/transforms-node/wrap-nodes.d.ts.map +1 -0
  184. package/dist/transforms-node/wrap-nodes.js +23 -0
  185. package/dist/transforms-node/wrap-nodes.js.map +1 -0
  186. package/dist/types/condition-types.d.ts +70 -0
  187. package/dist/types/condition-types.d.ts.map +1 -0
  188. package/dist/types/custom-types.d.ts +10 -0
  189. package/dist/types/custom-types.d.ts.map +1 -0
  190. package/dist/types/index.d.ts +4 -0
  191. package/dist/types/index.d.ts.map +1 -0
  192. package/dist/types/types.d.ts +12 -0
  193. package/dist/types/types.d.ts.map +1 -0
  194. package/dist/utils/index.d.ts +2 -0
  195. package/dist/utils/index.d.ts.map +1 -0
  196. package/dist/utils/index.js +6 -0
  197. package/dist/utils/index.js.map +1 -0
  198. package/dist/utils/is-plain-object.d.ts +9 -0
  199. package/dist/utils/is-plain-object.d.ts.map +1 -0
  200. package/dist/utils/is-plain-object.js +32 -0
  201. package/dist/utils/is-plain-object.js.map +1 -0
  202. package/dist/utils/match-path.d.ts +5 -0
  203. package/dist/utils/match-path.d.ts.map +1 -0
  204. package/dist/utils/types.d.ts +3 -0
  205. package/dist/utils/types.d.ts.map +1 -0
  206. package/dist/utils/weak-maps.d.ts +8 -0
  207. package/dist/utils/weak-maps.d.ts.map +1 -0
  208. package/dist/utils/weak-maps.js +9 -0
  209. package/dist/utils/weak-maps.js.map +1 -0
  210. package/package.json +52 -0
@@ -0,0 +1,125 @@
1
+ import { createDraft, finishDraft, isDraft } from 'immer';
2
+ import { Node } from '../node.js';
3
+ import { Path } from '../path.js';
4
+
5
+ const applyToDraft = (editor, selection, op) => {
6
+ switch (op.type) {
7
+ case "insert_node": {
8
+ const { path, node } = op;
9
+ const parent = Node.parent(editor, path);
10
+ const [slot, index] = path[path.length - 1];
11
+ if (index > parent.slots[slot].length) {
12
+ throw new Error(`Cannot apply an "insert_node" operation at path [${path}] because the destination is past the end of the node.`);
13
+ }
14
+ parent.slots[slot].splice(index, 0, node);
15
+ if (selection) {
16
+ selection = Path.transform(selection, op);
17
+ }
18
+ break;
19
+ }
20
+ case "move_node": {
21
+ const { path, newPath } = op;
22
+ if (Path.isAncestor(path, newPath)) {
23
+ throw new Error(`Cannot move a path [${path}] to new path [${newPath}] because the destination is inside itself.`);
24
+ }
25
+ const node = Node.get(editor, path);
26
+ const parent = Node.parent(editor, path);
27
+ const [slot, index] = path[path.length - 1];
28
+ // This is tricky, but since the `path` and `newPath` both refer to
29
+ // the same snapshot in time, there's a mismatch. After either
30
+ // removing the original position, the second step's path can be out
31
+ // of date. So instead of using the `op.newPath` directly, we
32
+ // transform `op.path` to ascertain what the `newPath` would be after
33
+ // the operation was applied.
34
+ parent.slots[slot].splice(index, 1);
35
+ const truePath = Path.transform(path, op);
36
+ const newParent = Node.get(editor, Path.parent(truePath));
37
+ const [newSlot, newIndex] = truePath[truePath.length - 1];
38
+ newParent.slots[newSlot].splice(newIndex, 0, node);
39
+ if (selection) {
40
+ selection = Path.transform(selection, op);
41
+ }
42
+ break;
43
+ }
44
+ case "remove_node": {
45
+ const { path } = op;
46
+ const [slot, index] = path[path.length - 1];
47
+ const parent = Node.parent(editor, path);
48
+ parent.slots[slot].splice(index, 1);
49
+ if (selection) {
50
+ const result = Path.transform(selection, op);
51
+ // if selection is not removed then update it with the new path
52
+ if (selection != null && result != null) {
53
+ selection = result;
54
+ }
55
+ else {
56
+ // prefer prev path for selection if available if not then select next path else select parent path else null
57
+ if (Path.hasPrevious(path)) {
58
+ selection = Path.previous(path);
59
+ }
60
+ else if (Node.has(editor, Path.next(path))) {
61
+ selection = path;
62
+ }
63
+ else if (Path.parent(path).length > 0) {
64
+ selection = Path.parent(path);
65
+ }
66
+ else {
67
+ selection = null;
68
+ }
69
+ }
70
+ }
71
+ break;
72
+ }
73
+ // TODO: Since we have a defined structure, we can ensure that only the valid attributes could be allowed like UID, type or responsiveStyles.
74
+ case "set_node": {
75
+ // TODO: @RavenColEvol, can we check if we need the properties. If not, let's remove it.
76
+ const { path, newProperties } = op;
77
+ const node = Node.get(editor, path);
78
+ for (const key in newProperties) {
79
+ const value = newProperties[key];
80
+ if (value == null) {
81
+ delete node[key];
82
+ }
83
+ else {
84
+ node[key] = value;
85
+ }
86
+ }
87
+ break;
88
+ }
89
+ case "set_selection": {
90
+ const { path } = op;
91
+ selection = path;
92
+ break;
93
+ }
94
+ case "set_active_context_path": {
95
+ const { path } = op;
96
+ editor.activeContextPath = path;
97
+ break;
98
+ }
99
+ }
100
+ return selection;
101
+ };
102
+ const GeneralTransforms = {
103
+ transform(editor, op) {
104
+ editor.slots = createDraft(editor.slots);
105
+ let selection = editor.selection && createDraft(editor.selection);
106
+ try {
107
+ selection = applyToDraft(editor, selection, op);
108
+ }
109
+ finally {
110
+ editor.slots = finishDraft(editor.slots);
111
+ if (selection) {
112
+ editor.selection = isDraft(selection)
113
+ ? finishDraft(selection)
114
+ : selection;
115
+ }
116
+ else {
117
+ editor.selection = null;
118
+ }
119
+ }
120
+ return editor;
121
+ },
122
+ };
123
+
124
+ export { GeneralTransforms };
125
+ //# sourceMappingURL=general.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.js","sources":["../../../src/interfaces/transforms/general.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA,MAAM,YAAY,GAAG,CACnB,MAAc,EACd,SAAsB,EACtB,EAAa,KACX;AACF,IAAA,QAAQ,EAAE,CAAC,IAAI;QACb,KAAK,aAAa,EAAE;AAClB,YAAA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;AACxC,YAAA,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAE3C,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACrC,gBAAA,MAAM,IAAI,KAAK,CACb,oDAAoD,IAAI,CAAA,sDAAA,CAAwD,CACjH;YACH;AAEA,YAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAA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
+ export declare const Transforms: GeneralTransforms & NodeTransforms;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,UAAU,EAAE,iBAAiB,GAAG,cAG5C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { GeneralTransforms } from './general.js';
2
+ import { NodeTransforms } from './node.js';
3
+
4
+ const Transforms = {
5
+ ...GeneralTransforms,
6
+ ...NodeTransforms,
7
+ };
8
+
9
+ export { Transforms };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/interfaces/transforms/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGO,MAAM,UAAU,GAAuC;AAC5D,IAAA,GAAG,iBAAiB;AACpB,IAAA,GAAG,cAAc;;;;;"}
@@ -0,0 +1,107 @@
1
+ import { Properties } from "csstype";
2
+ import { NodeMatch, PropsCompare, PropsMerge } from "../editor";
3
+ import { Editor, Node, NodeProp, Path } from "../index";
4
+ export interface NodeInsertNodesOptions<T extends Node> {
5
+ at?: Path;
6
+ match?: NodeMatch<T>;
7
+ select?: boolean;
8
+ }
9
+ export interface NodeTransforms {
10
+ /**
11
+ * Insert nodes in the editor
12
+ * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.
13
+ */
14
+ insertNodes: <T extends Node>(editor: Editor, nodes: Node | Node[], options?: NodeInsertNodesOptions<T>) => void;
15
+ /**
16
+ * Move the nodes at a location to a new location.
17
+ */
18
+ moveNodes: (editor: Editor, options: {
19
+ at?: Path;
20
+ to: Path;
21
+ }) => void;
22
+ /**
23
+ * Move the nodes at a location to a new location.
24
+ */
25
+ unwrapNodes: (editor: Editor, slotUid: string, options: {
26
+ at?: Path;
27
+ }) => void;
28
+ wrapNodes: (editor: Editor, container: Node,
29
+ /**
30
+ * The slot uid inside the container to wrap
31
+ */
32
+ slotUid: string, options?: {
33
+ at?: Path;
34
+ }) => void;
35
+ liftNodes: (editor: Editor, slotUid: string, options?: {
36
+ at?: Path;
37
+ }) => void;
38
+ /**
39
+ * Remove the nodes at a specific location in the document.
40
+ */
41
+ removeNodes: <T extends Node>(editor: Editor, options?: {
42
+ at?: Path;
43
+ match?: NodeMatch<T>;
44
+ }) => void;
45
+ /**
46
+ * Set new properties on the nodes at a location.
47
+ */
48
+ setNodes: <T extends Node>(editor: Editor, props: Partial<T> & {
49
+ [key: string]: unknown;
50
+ }, options?: {
51
+ at?: Path;
52
+ match?: NodeMatch<T>;
53
+ compare?: PropsCompare;
54
+ merge?: PropsMerge;
55
+ allowAllProp?: boolean;
56
+ }) => void;
57
+ setResponsiveStyles: (editor: Editor,
58
+ /**
59
+ * Which group should we apply the styles to. It is used when we have multiple
60
+ * styles group for a single component. It will be `default` if the developer
61
+ * did not explictly set the styles group during component registration.
62
+ */
63
+ styleGroup: string, breakpoint: string, style: Properties, options?: {
64
+ at?: Path;
65
+ }) => void;
66
+ unsetResponsiveStyles: (editor: Editor,
67
+ /**
68
+ * Which group should we apply the styles to. It is used when we have multiple
69
+ * styles group for a single component. It will be `default` if the developer
70
+ * did not explictly set the styles group during component registration.
71
+ */
72
+ styleGroup: string, breakpoint: string, style: keyof Properties | (keyof Properties)[], options?: {
73
+ at?: Path;
74
+ }) => void;
75
+ setClasses: (editor: Editor,
76
+ /**
77
+ * Which group should we apply the styles to. It is used when we have multiple
78
+ * styles group for a single component. It will be `default` if the developer
79
+ * did not explictly set the styles group during component registration.
80
+ */
81
+ styleGroup: string, className: string, options?: {
82
+ at?: Path;
83
+ }) => void;
84
+ unsetClasses: (editor: Editor,
85
+ /**
86
+ * Which group should we apply the styles to. It is used when we have multiple
87
+ * styles group for a single component. It will be `default` if the developer
88
+ * did not explictly set the styles group during component registration.
89
+ */
90
+ styleGroup: string, className: string, options?: {
91
+ at?: Path;
92
+ }) => void;
93
+ setProp: (editor: Editor, propPath: string, prop: Partial<NodeProp>, nodes: Node[], options?: {
94
+ at?: Path;
95
+ }) => void;
96
+ unsetProp: (editor: Editor, propPath: string, options?: {
97
+ at?: Path;
98
+ }) => void;
99
+ setSelection(editor: Editor, options: {
100
+ at?: Path;
101
+ }): void;
102
+ insertSlot: (editor: Editor, slotPropUID: string, nodes: Node[], options?: {
103
+ at?: Path;
104
+ }) => void;
105
+ }
106
+ export declare const NodeTransforms: NodeTransforms;
107
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,IAAI;IACpD,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,WAAW,EAAE,CAAC,CAAC,SAAS,IAAI,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAChC,IAAI,CAAC;IAEV;;OAEG;IACH,SAAS,EAAE,CACT,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QACP,EAAE,CAAC,EAAE,IAAI,CAAC;QACV,EAAE,EAAE,IAAI,CAAC;K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E,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,IAAI,CAAC;KACX,KACE,IAAI,CAAC;CACX;AAED,eAAO,MAAM,cAAc,EAAE,cAsD5B,CAAC"}
@@ -0,0 +1,50 @@
1
+ const NodeTransforms = {
2
+ insertNodes(editor, nodes, options) {
3
+ editor.insertNodes(nodes, options);
4
+ },
5
+ moveNodes(editor, options) {
6
+ editor.moveNodes(options);
7
+ },
8
+ removeNodes(editor, options) {
9
+ editor.removeNodes(options);
10
+ },
11
+ setNodes(editor, props, options) {
12
+ editor.setNodes(props, options);
13
+ },
14
+ setSelection(editor, options) {
15
+ editor.setSelection(options);
16
+ },
17
+ unwrapNodes(editor, slotUid, options) {
18
+ editor.unwrapNodes(slotUid, options);
19
+ },
20
+ wrapNodes(editor, element, slotUid, options) {
21
+ editor.wrapNodes(element, slotUid, options);
22
+ },
23
+ liftNodes(editor, slotUid, options) {
24
+ editor.liftNodes(slotUid, options);
25
+ },
26
+ setResponsiveStyles(editor, ...args) {
27
+ editor.setResponsiveStyles(...args);
28
+ },
29
+ unsetResponsiveStyles(editor, ...args) {
30
+ editor.unsetResponsiveStyles(...args);
31
+ },
32
+ setClasses(editor, ...args) {
33
+ editor.setClasses(...args);
34
+ },
35
+ unsetClasses(editor, ...args) {
36
+ editor.unsetClasses(...args);
37
+ },
38
+ setProp(editor, propPath, prop, nodes, options) {
39
+ editor.setProp(propPath, prop, nodes, options);
40
+ },
41
+ unsetProp(editor, propPath, options) {
42
+ editor.unsetProp(propPath, options);
43
+ },
44
+ insertSlot(editor, slotPropUID, nodes, options) {
45
+ editor.insertSlot(slotPropUID, nodes, options);
46
+ },
47
+ };
48
+
49
+ export { NodeTransforms };
50
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sources":["../../../src/interfaces/transforms/node.ts"],"sourcesContent":[null],"names":[],"mapp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AAC,GAAG,IAAI,CAAC;IACvC,CAAC;AAED,IAAA,UAAU,CAAC,MAAM,EAAE,GAAG,IAAI,EAAA;AACxB,QAAA,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAC5B,CAAC;AAED,IAAA,YAAY,CAAC,MAAM,EAAE,GAAG,IAAI,EAAA;AAC1B,QAAA,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAA;QAC5C,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;IAChD,CAAC;AAED,IAAA,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAA;AACjC,QAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IACrC,CAAC;AAED,IAAA,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAA;QAC5C,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC;IAChD,CAAC;;;;;"}
@@ -0,0 +1,15 @@
1
+ export * from "./insert-nodes";
2
+ export * from "./move-nodes";
3
+ export * from "./remove-nodes";
4
+ export * from "./set-nodes";
5
+ export * from "./set-selection";
6
+ export * from "./unwrap-nodes";
7
+ export * from "./wrap-nodes";
8
+ export * from "./lift-nodes";
9
+ export * from "./set-responsive-styles";
10
+ export * from "./unset-responsive-styles";
11
+ export * from "./set-props";
12
+ export * from "./set-classes";
13
+ export * from "./set-nodes";
14
+ export * from "./unset-props";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms-node/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const insertNodes: NodeTransforms["insertNodes"];
3
+ //# sourceMappingURL=insert-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-nodes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/insert-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI/D,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,aAAa,CAgDrD,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { Node } from '../interfaces/node.js';
2
+ import { Path } from '../interfaces/path.js';
3
+ import { Editor } from '../interfaces/editor.js';
4
+ import { Transforms } from '../interfaces/transforms/index.js';
5
+
6
+ const insertNodes = (editor, nodes, options = {}) => {
7
+ Editor.withoutNormalizing(editor, () => {
8
+ let { at, select } = options;
9
+ if (!at) {
10
+ if (!editor.selection)
11
+ return;
12
+ at = editor.selection;
13
+ // TODO: @RavenColEvol, can you review this line?
14
+ if (select === false) {
15
+ select = true;
16
+ }
17
+ }
18
+ if (select == null) {
19
+ select = false;
20
+ }
21
+ if (Node.isNode(nodes)) {
22
+ nodes = [nodes];
23
+ }
24
+ if (nodes.length === 0) {
25
+ return;
26
+ }
27
+ const parentPath = Path.parent(at);
28
+ const slot = at[at.length - 1][0];
29
+ let index = at[at.length - 1][1];
30
+ for (const node of nodes) {
31
+ const path = parentPath.concat([[slot, index]]);
32
+ index++;
33
+ editor.apply({ type: "insert_node", path, node });
34
+ at = path;
35
+ }
36
+ if (select) {
37
+ Transforms.setSelection(editor, {
38
+ at: at,
39
+ });
40
+ }
41
+ });
42
+ };
43
+
44
+ export { insertNodes };
45
+ //# sourceMappingURL=insert-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-nodes.js","sources":["../../src/transforms-node/insert-nodes.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAIO,MAAM,WAAW,GAAkC,CACxD,MAAM,EACN,KAAK,EACL,OAAO,GAAG,EAAE,KACV;AACF,IAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAK;AACrC,QAAA,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO;QAE5B,IAAI,CAAC,EAAE,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,SAAS;gBAAE;AAEvB,YAAA,EAAE,GAAG,MAAM,CAAC,SAAS;;AAErB,YAAA,IAAI,MAAM,KAAK,KAAK,EAAE;gBACpB,MAAM,GAAG,IAAI;YACf;QACF;AAEA,QAAA,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,MAAM,GAAG,KAAK;QAChB;AAEA,QAAA,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AACtB,YAAA,KAAK,GAAG,CAAC,KAAK,CAAC;QACjB;AAEA,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB;QACF;QAEA,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAClC,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,QAAA,IAAI,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhC,QAAA,KAAK,MAAM,IAAI,IAAI,KAAe,EAAE;AAClC,YAAA,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/C,YAAA,KAAK,EAAE;AAEP,YAAA,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACjD,EAAE,GAAG,IAAI;QACX;QAEA,IAAI,MAAM,EAAE;AACV,YAAA,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE;AAC9B,gBAAA,EAAE,EAAE,EAAE;AACP,aAAA,CAAC;QACJ;AACF,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const insertSlot: NodeTransforms["insertSlot"];
3
+ //# sourceMappingURL=insert-slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-slot.d.ts","sourceRoot":"","sources":["../../src/transforms-node/insert-slot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,YAAY,CAoBnD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import 'uuid';
2
+ import 'lodash-es';
3
+ import { Transforms } from '../interfaces/transforms/index.js';
4
+ import { generateUID } from '../utils/index.js';
5
+
6
+ const insertSlot = (editor, slotPropUID, nodes, options = {}) => {
7
+ const { at = editor.selection } = options;
8
+ if (!at) {
9
+ return;
10
+ }
11
+ Transforms.setProp(editor, slotPropUID, {
12
+ type: "slot",
13
+ slot: generateUID(),
14
+ }, nodes, options);
15
+ };
16
+
17
+ export { insertSlot };
18
+ //# sourceMappingURL=insert-slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-slot.js","sources":["../../src/transforms-node/insert-slot.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAIO,MAAM,UAAU,GAAiC,CACtD,MAAM,EACN,WAAW,EACX,KAAK,EACL,OAAO,GAAG,EAAE,KACV;IACF,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;IACzC,IAAI,CAAC,EAAE,EAAE;QACP;IACF;AACA,IAAA,UAAU,CAAC,OAAO,CAChB,MAAM,EACN,WAAW,EACX;AACE,QAAA,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,WAAW,EAAE;AACpB,KAAA,EACD,KAAK,EACL,OAAO,CACR;AACH;;;;"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const liftNodes: NodeTransforms["liftNodes"];
3
+ //# sourceMappingURL=lift-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift-nodes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/lift-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,WAAW,CAqCjD,CAAC"}
@@ -0,0 +1,38 @@
1
+ import 'uuid';
2
+ import { Path } from '../interfaces/path.js';
3
+ import { Editor } from '../interfaces/editor.js';
4
+ import { Transforms } from '../interfaces/transforms/index.js';
5
+
6
+ // currently it will only lift a single node as we don't have matching for multiple nodes
7
+ const liftNodes = (editor, slotUid, options = {}) => {
8
+ Editor.withoutNormalizing(editor, () => {
9
+ const { at = editor.selection } = options;
10
+ if (!at) {
11
+ return;
12
+ }
13
+ const pathRef = Editor.pathRef(editor, at);
14
+ const path = pathRef.unref();
15
+ if (path.length < 2) {
16
+ throw new Error(`Cannot lift node at a path [${path}] because it has a depth of less than \`2\`.`);
17
+ }
18
+ const parentNodeEntry = Editor.node(editor, Path.parent(path));
19
+ const [parent, parentPath] = parentNodeEntry;
20
+ const [slotId, index] = path[path.length - 1];
21
+ const { length } = parent["slots"][slotId];
22
+ if (length === 1) {
23
+ const toPath = Path.next(parentPath);
24
+ Transforms.moveNodes(editor, { at: path, to: toPath });
25
+ Transforms.removeNodes(editor, { at: parentPath });
26
+ }
27
+ else if (index === 0) {
28
+ Transforms.moveNodes(editor, { at: path, to: parentPath });
29
+ }
30
+ else if (index === length - 1) {
31
+ const toPath = Path.next(parentPath);
32
+ Transforms.moveNodes(editor, { at: path, to: toPath });
33
+ }
34
+ });
35
+ };
36
+
37
+ export { liftNodes };
38
+ //# sourceMappingURL=lift-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift-nodes.js","sources":["../../src/transforms-node/lift-nodes.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAIA;AACO,MAAM,SAAS,GAAgC,CACpD,MAAM,EACN,OAAO,EACP,OAAO,GAAG,EAAE,KACV;AACF,IAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAK;QACrC,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;QAEzC,IAAI,CAAC,EAAE,EAAE;YACP;QACF;QAEA,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;AAC1C,QAAA,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAG;AAE7B,QAAA,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;AACnB,YAAA,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,CAAA,4CAAA,CAA8C,CAClF;QACH;AAEA,QAAA,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC9D,QAAA,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,eAAsC;AACnE,QAAA,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AAE1C,QAAA,IAAI,MAAM,KAAK,CAAC,EAAE;YAChB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;AACpC,YAAA,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;YACtD,UAAU,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;QACpD;AAAO,aAAA,IAAI,KAAK,KAAK,CAAC,EAAE;AACtB,YAAA,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;QAC5D;AAAO,aAAA,IAAI,KAAK,KAAK,MAAM,GAAG,CAAC,EAAE;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;AACpC,YAAA,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;QACxD;AACF,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const moveNodes: NodeTransforms["moveNodes"];
3
+ //# sourceMappingURL=move-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-nodes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/move-nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,WAAW,CAYjD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import 'uuid';
2
+ import 'lodash-es';
3
+ import { Editor } from '../interfaces/editor.js';
4
+ import 'immer';
5
+
6
+ const moveNodes = (editor, options) => {
7
+ Editor.withoutNormalizing(editor, () => {
8
+ const { to, at = editor.selection } = options;
9
+ if (!at) {
10
+ return;
11
+ }
12
+ const path = at;
13
+ const newPath = to;
14
+ if (path.length !== 0) {
15
+ editor.apply({ type: "move_node", path, newPath });
16
+ }
17
+ });
18
+ };
19
+
20
+ export { moveNodes };
21
+ //# sourceMappingURL=move-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-nodes.js","sources":["../../src/transforms-node/move-nodes.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;MAGa,SAAS,GAAgC,CAAC,MAAM,EAAE,OAAO,KAAI;AACxE,IAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAK;QACrC,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;QAC7C,IAAI,CAAC,EAAE,EAAE;YACP;QACF;QACA,MAAM,IAAI,GAAG,EAAE;QACf,MAAM,OAAO,GAAG,EAAE;AAClB,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,YAAA,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACpD;AACF,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const removeNodes: NodeTransforms["removeNodes"];
3
+ //# sourceMappingURL=remove-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-nodes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/remove-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,aAAa,CAerD,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Node } from '../interfaces/node.js';
2
+ import 'lodash-es';
3
+ import { Editor } from '../interfaces/editor.js';
4
+ import 'immer';
5
+
6
+ const removeNodes = (editor, options = {}) => {
7
+ Editor.withoutNormalizing(editor, () => {
8
+ const { at = editor.selection } = options;
9
+ if (!at) {
10
+ return;
11
+ }
12
+ const path = at;
13
+ //TODO: unref all path refs related to delete path
14
+ const node = Node.get(editor, path);
15
+ editor.apply({ type: "remove_node", path, node });
16
+ });
17
+ };
18
+
19
+ export { removeNodes };
20
+ //# sourceMappingURL=remove-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-nodes.js","sources":["../../src/transforms-node/remove-nodes.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAGO,MAAM,WAAW,GAAkC,CACxD,MAAM,EACN,OAAO,GAAG,EAAE,KACV;AACF,IAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAK;QACrC,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;QAEzC,IAAI,CAAC,EAAE,EAAE;YACP;QACF;QACA,MAAM,IAAI,GAAG,EAAE;;QAEf,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACnC,QAAA,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACnD,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const setClasses: NodeTransforms["setClasses"];
3
+ //# sourceMappingURL=set-classes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-classes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/set-classes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,YAAY,CAyDnD,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { cloneDeep } from 'lodash-es';
2
+ import { Node } from '../interfaces/node.js';
3
+ import { produce } from 'immer';
4
+ import { getDefaultNodeStyles } from '../interfaces/get-default-node-styles.js';
5
+
6
+ const setClasses = (editor, styleGroup, className, options = {}) => {
7
+ const { at = editor.selection } = options;
8
+ if (!at) {
9
+ return;
10
+ }
11
+ if (!styleGroup) {
12
+ throw new Error("The style group is required to set the class!");
13
+ }
14
+ editor.setNodes({ styles: {} }, {
15
+ ...options,
16
+ merge: (prevStyles) => {
17
+ return produce(prevStyles, (draft) => {
18
+ // We update the responsive styles for the given style group
19
+ draft[styleGroup] = {
20
+ // We keep the existing classes and responsive styles, if any. Else, we initialize them.
21
+ ...(draft[styleGroup] || getDefaultNodeStyles()),
22
+ // We take the union of the existing classes and the new class
23
+ classes: Array.from(new Set([...(draft[styleGroup]?.classes || []), className])),
24
+ };
25
+ return draft;
26
+ });
27
+ },
28
+ });
29
+ const node = Node.get(editor, at);
30
+ const styles = node.styles[styleGroup] ?? getDefaultNodeStyles();
31
+ const updatedClasses = Array.from(new Set([...styles.classes, className]));
32
+ const updatedStyles = {
33
+ ...cloneDeep(node.styles),
34
+ [styleGroup]: {
35
+ ...cloneDeep(styles),
36
+ classes: updatedClasses,
37
+ },
38
+ };
39
+ editor.apply({
40
+ type: "set_node",
41
+ properties: node.props,
42
+ newProperties: { styles: updatedStyles },
43
+ path: at,
44
+ });
45
+ };
46
+
47
+ export { setClasses };
48
+ //# sourceMappingURL=set-classes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-classes.js","sources":["../../src/transforms-node/set-classes.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMO,MAAM,UAAU,GAAiC,CACtD,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,GAAG,EAAE,KACV;IACF,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;IAEzC,IAAI,CAAC,EAAE,EAAE;QACP;IACF;IAEA,IAAI,CAAC,UAAU,EAAE;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC;IAClE;IAE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,3 @@
1
+ import { NodeTransforms } from "../interfaces/transforms/node";
2
+ export declare const setNodes: NodeTransforms["setNodes"];
3
+ //# sourceMappingURL=set-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-nodes.d.ts","sourceRoot":"","sources":["../../src/transforms-node/set-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,UAAU,CAkD/C,CAAC"}