@makeswift/runtime 0.7.6 → 0.7.8

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 (280) hide show
  1. package/dist/Box.cjs.js +2 -1
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -1
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +2 -1
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -1
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +2 -1
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -1
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +2 -1
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +2 -1
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +2 -1
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -1
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +2 -1
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +2 -1
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +3 -2
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +3 -2
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +2 -1
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +2 -1
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +2 -1
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +3 -2
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +2 -1
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +2 -1
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +29 -1
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +33 -4
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +185 -154
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +182 -154
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/Root.cjs.js +2 -1
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +2 -1
  52. package/dist/Root.es.js.map +1 -1
  53. package/dist/SocialLinks.cjs.js +2 -1
  54. package/dist/SocialLinks.cjs.js.map +1 -1
  55. package/dist/SocialLinks.es.js +2 -1
  56. package/dist/SocialLinks.es.js.map +1 -1
  57. package/dist/Text.cjs.js +3 -2
  58. package/dist/Text.cjs.js.map +1 -1
  59. package/dist/Text.es.js +3 -2
  60. package/dist/Text.es.js.map +1 -1
  61. package/dist/Video.cjs.js +2 -1
  62. package/dist/Video.cjs.js.map +1 -1
  63. package/dist/Video.es.js +2 -1
  64. package/dist/Video.es.js.map +1 -1
  65. package/dist/actions.cjs.js +1 -0
  66. package/dist/actions.cjs.js.map +1 -1
  67. package/dist/actions.es.js +1 -1
  68. package/dist/builder.cjs.js +2 -1
  69. package/dist/builder.cjs.js.map +1 -1
  70. package/dist/builder.es.js +2 -1
  71. package/dist/builder.es.js.map +1 -1
  72. package/dist/compare.cjs.js +126 -0
  73. package/dist/compare.cjs.js.map +1 -0
  74. package/dist/compare.es.js +124 -0
  75. package/dist/compare.es.js.map +1 -0
  76. package/dist/components.cjs.js +2 -1
  77. package/dist/components.cjs.js.map +1 -1
  78. package/dist/components.es.js +2 -1
  79. package/dist/components.es.js.map +1 -1
  80. package/dist/constants.cjs.js +4 -3
  81. package/dist/constants.cjs.js.map +1 -1
  82. package/dist/constants.es.js +3 -2
  83. package/dist/constants.es.js.map +1 -1
  84. package/dist/control-serialization.cjs.js +136 -108
  85. package/dist/control-serialization.cjs.js.map +1 -1
  86. package/dist/control-serialization.es.js +31 -2
  87. package/dist/control-serialization.es.js.map +1 -1
  88. package/dist/controls.cjs.js +27 -11
  89. package/dist/controls.cjs.js.map +1 -1
  90. package/dist/controls.es.js +4 -2
  91. package/dist/controls.es.js.map +1 -1
  92. package/dist/index.cjs.js +137 -116
  93. package/dist/index.cjs.js.map +1 -1
  94. package/dist/index.cjs2.js +2 -0
  95. package/dist/index.cjs2.js.map +1 -1
  96. package/dist/index.cjs5.js +2 -1
  97. package/dist/index.cjs5.js.map +1 -1
  98. package/dist/index.cjs6.js +663 -96
  99. package/dist/index.cjs6.js.map +1 -1
  100. package/dist/index.es.js +111 -90
  101. package/dist/index.es.js.map +1 -1
  102. package/dist/index.es2.js +2 -0
  103. package/dist/index.es2.js.map +1 -1
  104. package/dist/index.es5.js +2 -1
  105. package/dist/index.es5.js.map +1 -1
  106. package/dist/index.es6.js +657 -95
  107. package/dist/index.es6.js.map +1 -1
  108. package/dist/main.cjs.js +2 -1
  109. package/dist/main.cjs.js.map +1 -1
  110. package/dist/main.es.js +2 -1
  111. package/dist/main.es.js.map +1 -1
  112. package/dist/next.cjs.js +2 -1
  113. package/dist/next.cjs.js.map +1 -1
  114. package/dist/next.es.js +2 -1
  115. package/dist/next.es.js.map +1 -1
  116. package/dist/prop-controllers.cjs.js +2 -0
  117. package/dist/prop-controllers.cjs.js.map +1 -1
  118. package/dist/prop-controllers.es.js +3 -1
  119. package/dist/prop-controllers.es.js.map +1 -1
  120. package/dist/react.cjs.js +2 -1
  121. package/dist/react.cjs.js.map +1 -1
  122. package/dist/react.es.js +2 -1
  123. package/dist/react.es.js.map +1 -1
  124. package/dist/rich-text.cjs.js +1393 -29
  125. package/dist/rich-text.cjs.js.map +1 -1
  126. package/dist/rich-text.es.js +1371 -29
  127. package/dist/rich-text.es.js.map +1 -1
  128. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  129. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  130. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts +13 -0
  131. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts.map +1 -0
  132. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts +3 -0
  133. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts.map +1 -0
  134. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts +2 -0
  135. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts.map +1 -0
  136. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts +3 -0
  137. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts.map +1 -0
  138. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts +4 -0
  139. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts.map +1 -0
  140. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts +6 -0
  141. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts.map +1 -0
  142. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts +8 -0
  143. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts.map +1 -0
  144. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts +4 -0
  145. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts.map +1 -0
  146. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts +7 -0
  147. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts.map +1 -0
  148. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts +26 -0
  149. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts.map +1 -0
  150. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts +3 -0
  151. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts.map +1 -0
  152. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts +5 -0
  153. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts.map +1 -0
  154. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts +5 -0
  155. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts.map +1 -0
  156. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts +8 -0
  157. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts.map +1 -0
  158. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts +3 -0
  159. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts.map +1 -0
  160. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts +3 -0
  161. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts.map +1 -0
  162. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts +3 -0
  163. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts.map +1 -0
  164. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts +48 -0
  165. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts.map +1 -0
  166. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts +3 -0
  167. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts.map +1 -0
  168. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts +21 -0
  169. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts.map +1 -0
  170. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts +3 -0
  171. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts.map +1 -0
  172. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts +2 -0
  173. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts.map +1 -0
  174. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts +3 -0
  175. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts.map +1 -0
  176. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts +3 -0
  177. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts.map +1 -0
  178. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts +13 -0
  179. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -0
  180. package/dist/types/src/components/builtin/Text/EditableText/index.d.ts +4 -0
  181. package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +1 -0
  182. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts +8 -0
  183. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
  184. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +16 -0
  185. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  186. package/dist/types/src/components/builtin/Text/Text.d.ts +1 -1
  187. package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
  188. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +8 -0
  189. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -0
  190. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts +4 -0
  191. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +1 -0
  192. package/dist/types/src/components/builtin/Text/components/Element/index.d.ts +2 -0
  193. package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +1 -0
  194. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +8 -0
  195. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -0
  196. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts +3 -0
  197. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +1 -0
  198. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +4 -0
  199. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -0
  200. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts +27 -0
  201. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts.map +1 -0
  202. package/dist/types/src/components/builtin/Text/components/index.d.ts +3 -0
  203. package/dist/types/src/components/builtin/Text/components/index.d.ts.map +1 -0
  204. package/dist/types/src/components/utils/types.d.ts +1 -1
  205. package/dist/types/src/components/utils/types.d.ts.map +1 -1
  206. package/dist/types/src/controls/control.d.ts +2 -1
  207. package/dist/types/src/controls/control.d.ts.map +1 -1
  208. package/dist/types/src/controls/list.d.ts +20 -0
  209. package/dist/types/src/controls/list.d.ts.map +1 -1
  210. package/dist/types/src/controls/rich-text/compare.d.ts +5 -0
  211. package/dist/types/src/controls/rich-text/compare.d.ts.map +1 -0
  212. package/dist/types/src/controls/rich-text/compare.test.d.ts +2 -0
  213. package/dist/types/src/controls/rich-text/compare.test.d.ts.map +1 -0
  214. package/dist/types/src/controls/rich-text/dto-types.d.ts +131 -0
  215. package/dist/types/src/controls/rich-text/dto-types.d.ts.map +1 -0
  216. package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts +3 -0
  217. package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts.map +1 -0
  218. package/dist/types/src/controls/rich-text/fixtures/index.d.ts +4 -0
  219. package/dist/types/src/controls/rich-text/fixtures/index.d.ts.map +1 -0
  220. package/dist/types/src/controls/rich-text/fixtures/list.d.ts +3 -0
  221. package/dist/types/src/controls/rich-text/fixtures/list.d.ts.map +1 -0
  222. package/dist/types/src/controls/rich-text/fixtures/typography.d.ts +3 -0
  223. package/dist/types/src/controls/rich-text/fixtures/typography.d.ts.map +1 -0
  224. package/dist/types/src/controls/rich-text/index.d.ts +6 -0
  225. package/dist/types/src/controls/rich-text/index.d.ts.map +1 -0
  226. package/dist/types/src/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +8 -10
  227. package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -0
  228. package/dist/types/src/controls/rich-text/translation.d.ts +8 -0
  229. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -0
  230. package/dist/types/src/controls/rich-text/translation.test.d.ts +2 -0
  231. package/dist/types/src/controls/rich-text/translation.test.d.ts.map +1 -0
  232. package/dist/types/src/controls/rich-text/types.d.ts +134 -0
  233. package/dist/types/src/controls/rich-text/types.d.ts.map +1 -0
  234. package/dist/types/src/controls/shape.d.ts +21 -0
  235. package/dist/types/src/controls/shape.d.ts.map +1 -1
  236. package/dist/types/src/prop-controllers/descriptors.d.ts +2 -3
  237. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  238. package/dist/types/src/prop-controllers/instances.d.ts +6 -8
  239. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  240. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  241. package/dist/types/src/runtimes/react/controls/control.d.ts +6 -3
  242. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  243. package/dist/types/src/runtimes/react/controls/list.d.ts +3 -2
  244. package/dist/types/src/runtimes/react/controls/list.d.ts.map +1 -1
  245. package/dist/types/src/runtimes/react/controls/shape.d.ts +3 -2
  246. package/dist/types/src/runtimes/react/controls/shape.d.ts.map +1 -1
  247. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  248. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  249. package/dist/typography.cjs.js +146 -0
  250. package/dist/typography.cjs.js.map +1 -0
  251. package/dist/typography.es.js +143 -0
  252. package/dist/typography.es.js.map +1 -0
  253. package/package.json +7 -10
  254. package/dist/EditableText.cjs.js +0 -381
  255. package/dist/EditableText.cjs.js.map +0 -1
  256. package/dist/EditableText.es.js +0 -374
  257. package/dist/EditableText.es.js.map +0 -1
  258. package/dist/control.cjs.js +0 -437
  259. package/dist/control.cjs.js.map +0 -1
  260. package/dist/control.es.js +0 -426
  261. package/dist/control.es.js.map +0 -1
  262. package/dist/types/src/components/builtin/Text/EditableText.d.ts +0 -16
  263. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +0 -1
  264. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts +0 -10
  265. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts.map +0 -1
  266. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts +0 -25
  267. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts.map +0 -1
  268. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts +0 -10
  269. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts.map +0 -1
  270. package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts +0 -5
  271. package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts.map +0 -1
  272. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts +0 -3
  273. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts.map +0 -1
  274. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts +0 -3
  275. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts.map +0 -1
  276. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts +0 -3
  277. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts.map +0 -1
  278. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts +0 -3
  279. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts.map +0 -1
  280. package/dist/types/src/controls/rich-text.d.ts.map +0 -1
@@ -21,7 +21,10 @@ var __publicField = (obj, key, value) => {
21
21
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
22
  return value;
23
23
  };
24
+ const import_meta = {};
24
25
  import { A as ActionTypes } from "./actions.es.js";
26
+ import { Transforms, Editor } from "slate";
27
+ import { ReactEditor } from "slate-react";
25
28
  const BuilderEditMode = {
26
29
  BUILD: "build",
27
30
  CONTENT: "content",
@@ -115,6 +118,122 @@ function copyStyleData(value, context) {
115
118
  }
116
119
  return __spreadProps(__spreadValues({}, value), { border: copyResponsiveBorder(value.border) });
117
120
  }
121
+ if (import_meta.vitest) {
122
+ const { describe, test, expect } = import_meta.vitest;
123
+ describe.concurrent("style copy", () => {
124
+ test("colors are replaced", () => {
125
+ const value = {
126
+ width: [
127
+ {
128
+ value: {
129
+ unit: "px",
130
+ value: 100
131
+ },
132
+ deviceId: "desktop"
133
+ }
134
+ ],
135
+ border: [
136
+ {
137
+ value: {
138
+ borderTop: {
139
+ color: {
140
+ alpha: 1,
141
+ swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
142
+ },
143
+ style: "solid",
144
+ width: 9
145
+ },
146
+ borderLeft: {
147
+ color: {
148
+ alpha: 1,
149
+ swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
150
+ },
151
+ style: "solid",
152
+ width: 9
153
+ },
154
+ borderRight: {
155
+ color: {
156
+ alpha: 1,
157
+ swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
158
+ },
159
+ style: "solid",
160
+ width: 9
161
+ },
162
+ borderBottom: {
163
+ color: {
164
+ alpha: 1,
165
+ swatchId: "U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA=="
166
+ },
167
+ style: "solid",
168
+ width: 9
169
+ }
170
+ },
171
+ deviceId: "desktop"
172
+ }
173
+ ],
174
+ textStyle: [
175
+ {
176
+ value: {
177
+ fontSize: {
178
+ unit: "px",
179
+ value: 46
180
+ },
181
+ fontStyle: [],
182
+ fontFamily: "Oswald",
183
+ fontWeight: 400,
184
+ letterSpacing: 5.2,
185
+ textTransform: []
186
+ },
187
+ deviceId: "desktop"
188
+ }
189
+ ],
190
+ borderRadius: [
191
+ {
192
+ value: {
193
+ borderTopLeftRadius: {
194
+ unit: "px",
195
+ value: 4
196
+ },
197
+ borderTopRightRadius: {
198
+ unit: "px",
199
+ value: 4
200
+ },
201
+ borderBottomLeftRadius: {
202
+ unit: "px",
203
+ value: 4
204
+ },
205
+ borderBottomRightRadius: {
206
+ unit: "px",
207
+ value: 4
208
+ }
209
+ },
210
+ deviceId: "desktop"
211
+ }
212
+ ]
213
+ };
214
+ const expected = JSON.parse(JSON.stringify(value).replaceAll("U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"));
215
+ const replacementContext = {
216
+ elementHtmlIds: /* @__PURE__ */ new Set(),
217
+ elementKeys: /* @__PURE__ */ new Map(),
218
+ swatchIds: /* @__PURE__ */ new Map([
219
+ ["U3dhdGNoOmJjMDkwZWJjLTZkZDUtNDY1NS1hMDY0LTg3ZDAxM2U4YTFhNA==", "testing"]
220
+ ]),
221
+ fileIds: /* @__PURE__ */ new Map(),
222
+ typographyIds: /* @__PURE__ */ new Map(),
223
+ tableIds: /* @__PURE__ */ new Map(),
224
+ tableColumnIds: /* @__PURE__ */ new Map(),
225
+ pageIds: /* @__PURE__ */ new Map(),
226
+ globalElementIds: /* @__PURE__ */ new Map(),
227
+ globalElementData: /* @__PURE__ */ new Map()
228
+ };
229
+ const result = copyStyleData(value, {
230
+ replacementContext,
231
+ copyElement: (node) => node
232
+ });
233
+ expect(result).toMatchObject(expected);
234
+ });
235
+ });
236
+ }
118
237
  const Types = {
119
238
  Backgrounds: "Backgrounds",
120
239
  Border: "Border",
@@ -200,10 +319,10 @@ function Image$1(options = {}) {
200
319
  function Images(options = {}) {
201
320
  return { type: Types.Images, options };
202
321
  }
203
- function Link(options = {}) {
322
+ function Link$1(options = {}) {
204
323
  return { type: Types.Link, options };
205
324
  }
206
- function List(options) {
325
+ function List$1(options) {
207
326
  return { type: Types.List, options };
208
327
  }
209
328
  const MarginPropControllerFormat = {
@@ -257,7 +376,7 @@ function Shadows(options = {}) {
257
376
  return { type: Types.Shadows, options };
258
377
  }
259
378
  Shadows.Format = ShadowsPropControllerFormat;
260
- function Shape(options) {
379
+ function Shape$1(options) {
261
380
  return { type: Types.Shape, options };
262
381
  }
263
382
  function SocialLinks(options = {}) {
@@ -309,8 +428,8 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
309
428
  Grid,
310
429
  Image: Image$1,
311
430
  Images,
312
- Link,
313
- List,
431
+ Link: Link$1,
432
+ List: List$1,
314
433
  MarginPropControllerFormat,
315
434
  Margin,
316
435
  NavigationLinks,
@@ -326,7 +445,7 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
326
445
  RichText: RichText$1,
327
446
  ShadowsPropControllerFormat,
328
447
  Shadows,
329
- Shape,
448
+ Shape: Shape$1,
330
449
  SocialLinks,
331
450
  Table,
332
451
  TableFormFields,
@@ -353,6 +472,84 @@ function copyImageData(value, context) {
353
472
  return value;
354
473
  return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
355
474
  }
475
+ if (import_meta.vitest) {
476
+ const { describe, test, expect } = import_meta.vitest;
477
+ describe.concurrent("image copy", () => {
478
+ test("image is replaced by a one in replacement context", () => {
479
+ const data = "file-id";
480
+ const expected = "testing";
481
+ const replacementContext = {
482
+ elementHtmlIds: /* @__PURE__ */ new Set(),
483
+ elementKeys: /* @__PURE__ */ new Map(),
484
+ swatchIds: /* @__PURE__ */ new Map(),
485
+ fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
486
+ typographyIds: /* @__PURE__ */ new Map(),
487
+ tableIds: /* @__PURE__ */ new Map(),
488
+ tableColumnIds: /* @__PURE__ */ new Map(),
489
+ pageIds: /* @__PURE__ */ new Map(),
490
+ globalElementIds: /* @__PURE__ */ new Map(),
491
+ globalElementData: /* @__PURE__ */ new Map()
492
+ };
493
+ const result = copyImageData(data, {
494
+ replacementContext,
495
+ copyElement: (node) => node
496
+ });
497
+ expect(result).toMatchObject(expected);
498
+ });
499
+ });
500
+ }
501
+ const LinkControlType = "makeswift::controls::link";
502
+ function Link(config = {}) {
503
+ return { type: LinkControlType, config };
504
+ }
505
+ function copyLinkData(value, context) {
506
+ var _a;
507
+ if (value == null)
508
+ return value;
509
+ if (value.type === "OPEN_PAGE") {
510
+ const pageId = value.payload.pageId;
511
+ if (pageId != null) {
512
+ return __spreadProps(__spreadValues({}, value), {
513
+ payload: __spreadProps(__spreadValues({}, value.payload), {
514
+ pageId: (_a = context.replacementContext.pageIds.get(pageId)) != null ? _a : pageId
515
+ })
516
+ });
517
+ }
518
+ }
519
+ return value;
520
+ }
521
+ if (import_meta.vitest) {
522
+ const { describe, test, expect } = import_meta.vitest;
523
+ describe.concurrent("link", () => {
524
+ test("page id is replaced by one in replacement context", () => {
525
+ const data = {
526
+ type: "OPEN_PAGE",
527
+ payload: {
528
+ pageId: "UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=",
529
+ openInNewTab: false
530
+ }
531
+ };
532
+ const expected = JSON.parse(JSON.stringify(data).replace("UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"));
533
+ const replacementContext = {
534
+ elementHtmlIds: /* @__PURE__ */ new Set(),
535
+ elementKeys: /* @__PURE__ */ new Map(),
536
+ swatchIds: /* @__PURE__ */ new Map(),
537
+ pageIds: /* @__PURE__ */ new Map([["UGFnZTpmNTdmMjQ2MS0wMGY3LTQzZWUtYmIwOS03ODdiNTUyYzUyYWQ=", "testing"]]),
538
+ typographyIds: /* @__PURE__ */ new Map(),
539
+ tableIds: /* @__PURE__ */ new Map(),
540
+ tableColumnIds: /* @__PURE__ */ new Map(),
541
+ fileIds: /* @__PURE__ */ new Map(),
542
+ globalElementIds: /* @__PURE__ */ new Map(),
543
+ globalElementData: /* @__PURE__ */ new Map()
544
+ };
545
+ const result = copyLinkData(data, {
546
+ replacementContext,
547
+ copyElement: (node) => node
548
+ });
549
+ expect(result).toMatchObject(expected);
550
+ });
551
+ });
552
+ }
356
553
  const RichTextPropControllerMessageType = {
357
554
  CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
358
555
  INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
@@ -379,19 +576,24 @@ class RichTextPropController extends PropController {
379
576
  __publicField(this, "editor", null);
380
577
  }
381
578
  recv(message) {
382
- var _a, _b;
579
+ if (!this.editor)
580
+ return;
383
581
  switch (message.type) {
384
582
  case RichTextPropControllerMessageType.CHANGE_BUILDER_EDIT_MODE: {
385
583
  switch (message.editMode) {
386
584
  case BuilderEditMode.BUILD:
387
585
  case BuilderEditMode.INTERACT:
388
- (_a = this.editor) == null ? void 0 : _a.deselect().blur();
389
- break;
586
+ ReactEditor.deselect(this.editor);
587
+ ReactEditor.blur(this.editor);
390
588
  }
391
589
  break;
392
590
  }
393
591
  case RichTextPropControllerMessageType.FOCUS: {
394
- (_b = this.editor) == null ? void 0 : _b.focus().moveToRangeOfDocument();
592
+ ReactEditor.focus(this.editor);
593
+ Transforms.select(this.editor, {
594
+ anchor: Editor.start(this.editor, []),
595
+ focus: Editor.end(this.editor, [])
596
+ });
395
597
  break;
396
598
  }
397
599
  }
@@ -400,14 +602,18 @@ class RichTextPropController extends PropController {
400
602
  this.editor = editor;
401
603
  this.send({
402
604
  type: RichTextPropControllerMessageType.INITIALIZE_EDITOR,
403
- value: editor.value.toJSON({ preserveSelection: false })
404
- });
405
- }
406
- onChange(change) {
407
- this.send({
408
- type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,
409
- value: change.value.toJSON({ preserveSelection: true })
605
+ value: richTextDAOToDTO(editor.children, editor.selection)
410
606
  });
607
+ const _onChange = editor.onChange;
608
+ this.editor.onChange = (options) => {
609
+ _onChange(options);
610
+ if ((options == null ? void 0 : options.operation) != null) {
611
+ this.send({
612
+ type: RichTextPropControllerMessageType.CHANGE_EDITOR_VALUE,
613
+ value: richTextDAOToDTO(editor.children, editor.selection)
614
+ });
615
+ }
616
+ };
411
617
  }
412
618
  focus() {
413
619
  this.send({ type: RichTextPropControllerMessageType.FOCUS });
@@ -449,10 +655,108 @@ function createPropController(descriptor, send) {
449
655
  return new SlotControl(send);
450
656
  case RichTextControlType:
451
657
  return new RichTextControl(send);
658
+ case ListControlType:
659
+ return new ListControl(send, descriptor);
660
+ case ShapeControlType:
661
+ return new ShapeControl(send, descriptor);
452
662
  default:
453
663
  return new DefaultPropController(send);
454
664
  }
455
665
  }
666
+ const ListControlType = "makeswift::controls::list";
667
+ function List(config) {
668
+ return { type: ListControlType, config };
669
+ }
670
+ const ListControlMessageType = {
671
+ LIST_CONTROL_ITEM_CONTROL_MESSAGE: "makeswift::controls::list::message::item-control-message"
672
+ };
673
+ class ListControl extends PropController {
674
+ constructor(send, descriptor) {
675
+ super(send);
676
+ __publicField(this, "controls");
677
+ __publicField(this, "descriptor");
678
+ __publicField(this, "send");
679
+ __publicField(this, "setItemsControl", (value) => {
680
+ const controls = /* @__PURE__ */ new Map();
681
+ if (value == null)
682
+ return;
683
+ const shouldUpdate = () => {
684
+ if (value.length !== this.controls.size)
685
+ return true;
686
+ if (!value.every(({ id }) => this.controls.has(id)))
687
+ return true;
688
+ return false;
689
+ };
690
+ if (!shouldUpdate())
691
+ return this.controls;
692
+ value.forEach((item) => {
693
+ const control = createPropController(this.descriptor.config.type, (message) => this.send({
694
+ type: ListControlMessageType.LIST_CONTROL_ITEM_CONTROL_MESSAGE,
695
+ payload: { message, itemId: item.id }
696
+ }));
697
+ controls.set(item.id, control);
698
+ });
699
+ this.controls = controls;
700
+ return this.controls;
701
+ });
702
+ this.descriptor = descriptor;
703
+ this.send = send;
704
+ this.controls = /* @__PURE__ */ new Map();
705
+ }
706
+ recv() {
707
+ }
708
+ }
709
+ function copyListData(definition, value, context) {
710
+ if (value == null)
711
+ return value;
712
+ return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
713
+ value: copy(definition.config.type, item.value, context)
714
+ }));
715
+ }
716
+ const ShapeControlType = "makeswift::controls::shape";
717
+ function Shape(config) {
718
+ return { type: ShapeControlType, config };
719
+ }
720
+ const ShapeControlMessageType = {
721
+ SHAPE_CONTROL_CHILD_CONTROL_MESSAGE: "makeswift::controls::shape::message::child-control-message"
722
+ };
723
+ class ShapeControl extends PropController {
724
+ constructor(send, descriptor) {
725
+ super(send);
726
+ __publicField(this, "controls");
727
+ __publicField(this, "descriptor");
728
+ __publicField(this, "send");
729
+ __publicField(this, "setControls", () => {
730
+ const controls = /* @__PURE__ */ new Map();
731
+ const children = this.descriptor.config.type;
732
+ Object.keys(children).forEach((key) => {
733
+ const control = createPropController(children[key], (message) => this.send({
734
+ type: ShapeControlMessageType.SHAPE_CONTROL_CHILD_CONTROL_MESSAGE,
735
+ payload: { message, key }
736
+ }));
737
+ controls.set(key, control);
738
+ });
739
+ this.controls = controls;
740
+ return this.controls;
741
+ });
742
+ this.descriptor = descriptor;
743
+ this.send = send;
744
+ this.controls = /* @__PURE__ */ new Map();
745
+ this.setControls();
746
+ }
747
+ recv() {
748
+ }
749
+ }
750
+ function copyShapeData(definition, value, context) {
751
+ if (value == null)
752
+ return value;
753
+ const newValue = {};
754
+ for (const [key, itemDefinition] of Object.entries(definition.config.type)) {
755
+ const prop = value[key];
756
+ newValue[key] = copy(itemDefinition, prop, context);
757
+ }
758
+ return newValue;
759
+ }
456
760
  const SlotControlType = "makeswift::controls::slot";
457
761
  function Slot() {
458
762
  return { type: SlotControlType };
@@ -478,6 +782,1034 @@ function copySlotData(value, context) {
478
782
  elements: value.elements.map((element) => context.copyElement(element))
479
783
  });
480
784
  }
785
+ function copy$e(value, context) {
786
+ if (value == null)
787
+ return value;
788
+ return value.map((override) => __spreadProps(__spreadValues({}, override), {
789
+ value: override.value.map((backgroundItem) => {
790
+ var _a, _b;
791
+ switch (backgroundItem.type) {
792
+ case "color":
793
+ return __spreadProps(__spreadValues({}, backgroundItem), {
794
+ payload: backgroundItem.payload === null ? null : __spreadProps(__spreadValues({}, backgroundItem.payload), {
795
+ swatchId: (_a = context.replacementContext.swatchIds.get(backgroundItem.payload.swatchId)) != null ? _a : backgroundItem.payload.swatchId
796
+ })
797
+ });
798
+ case "gradient":
799
+ return __spreadProps(__spreadValues({}, backgroundItem), {
800
+ payload: __spreadProps(__spreadValues({}, backgroundItem.payload), {
801
+ stops: backgroundItem.payload.stops.map((stop) => {
802
+ var _a2;
803
+ return __spreadProps(__spreadValues({}, stop), {
804
+ color: stop.color == null ? null : __spreadProps(__spreadValues({}, stop.color), {
805
+ swatchId: (_a2 = context.replacementContext.swatchIds.get(stop.color.swatchId)) != null ? _a2 : stop.color.swatchId
806
+ })
807
+ });
808
+ })
809
+ })
810
+ });
811
+ case "image":
812
+ return __spreadProps(__spreadValues({}, backgroundItem), {
813
+ payload: __spreadProps(__spreadValues({}, backgroundItem.payload), {
814
+ imageId: (_b = context.replacementContext.fileIds.get(backgroundItem.payload.imageId)) != null ? _b : backgroundItem.payload.imageId
815
+ })
816
+ });
817
+ default:
818
+ return backgroundItem;
819
+ }
820
+ })
821
+ }));
822
+ }
823
+ function copy$d(value, context) {
824
+ if (value == null)
825
+ return void 0;
826
+ return __spreadProps(__spreadValues({}, value), {
827
+ elements: value.elements.map((element) => context.copyElement(element))
828
+ });
829
+ }
830
+ function copy$c(value, context) {
831
+ var _a, _b;
832
+ if (value == null)
833
+ return value;
834
+ switch (value.type) {
835
+ case "OPEN_PAGE": {
836
+ const pageId = value.payload.pageId;
837
+ if (pageId == null)
838
+ return value;
839
+ return __spreadProps(__spreadValues({}, value), {
840
+ payload: __spreadProps(__spreadValues({}, value.payload), {
841
+ pageId: (_a = context.replacementContext.pageIds.get(pageId)) != null ? _a : pageId
842
+ })
843
+ });
844
+ }
845
+ case "SCROLL_TO_ELEMENT": {
846
+ const elementIdConfig = value.payload.elementIdConfig;
847
+ if (elementIdConfig == null)
848
+ return value;
849
+ return __spreadProps(__spreadValues({}, value), {
850
+ payload: __spreadProps(__spreadValues({}, value.payload), {
851
+ elementIdConfig: __spreadProps(__spreadValues({}, elementIdConfig), {
852
+ elementKey: (_b = context.replacementContext.elementKeys.get(elementIdConfig.elementKey)) != null ? _b : elementIdConfig.elementKey
853
+ })
854
+ })
855
+ });
856
+ }
857
+ default:
858
+ return value;
859
+ }
860
+ }
861
+ function copy$b(value, context) {
862
+ if (value == null)
863
+ return value;
864
+ return value.map(copyNavigationLinksPanelItem);
865
+ function copyNavigationLinksPanelItem(item) {
866
+ switch (item.type) {
867
+ case "button":
868
+ case "dropdown": {
869
+ const { color, link } = item.payload;
870
+ return __spreadProps(__spreadValues({}, item), {
871
+ payload: __spreadProps(__spreadValues({}, item.payload), {
872
+ link: link != null ? copy$c(link, context) : void 0,
873
+ color: color != null ? color.map((override) => {
874
+ var _a;
875
+ return __spreadProps(__spreadValues({}, override), {
876
+ value: __spreadProps(__spreadValues({}, override.value), {
877
+ swatchId: (_a = context.replacementContext.swatchIds.get(override.value.swatchId)) != null ? _a : override.value.swatchId
878
+ })
879
+ });
880
+ }) : void 0
881
+ })
882
+ });
883
+ }
884
+ default:
885
+ return item;
886
+ }
887
+ }
888
+ }
889
+ if (import_meta.vitest) {
890
+ const { describe, test, expect } = import_meta.vitest;
891
+ describe.concurrent("navigation-links copy", () => {
892
+ test("replace page id from replacement context", () => {
893
+ const data = [
894
+ {
895
+ id: "e1cf2d04-012a-4481-832a-7b4dda62195e",
896
+ type: "button",
897
+ payload: {
898
+ link: {
899
+ type: "OPEN_PAGE",
900
+ payload: {
901
+ pageId: "UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=",
902
+ openInNewTab: true
903
+ }
904
+ },
905
+ label: "Fellow Page"
906
+ }
907
+ }
908
+ ];
909
+ const expected = JSON.parse(JSON.stringify(data).replace("UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=", "testing"));
910
+ const replacementContext = {
911
+ elementHtmlIds: /* @__PURE__ */ new Set(),
912
+ elementKeys: /* @__PURE__ */ new Map(),
913
+ swatchIds: /* @__PURE__ */ new Map(),
914
+ fileIds: /* @__PURE__ */ new Map(),
915
+ typographyIds: /* @__PURE__ */ new Map(),
916
+ tableIds: /* @__PURE__ */ new Map(),
917
+ tableColumnIds: /* @__PURE__ */ new Map(),
918
+ pageIds: /* @__PURE__ */ new Map([["UGFnZTo2OGMzODZhNC1jYzRkLTQzMzUtYWZiMi05MDdhZGRkYzQ3YTM=", "testing"]]),
919
+ globalElementIds: /* @__PURE__ */ new Map(),
920
+ globalElementData: /* @__PURE__ */ new Map()
921
+ };
922
+ const result = copy$b(data, {
923
+ replacementContext,
924
+ copyElement: (node) => node
925
+ });
926
+ expect(result).toMatchObject(expected);
927
+ });
928
+ });
929
+ }
930
+ function copy$a(value, context) {
931
+ if (value == null)
932
+ return value;
933
+ return value.map((override) => __spreadProps(__spreadValues({}, override), { value: override.value.map(copyShadowItem) }));
934
+ function copyShadowItem(item) {
935
+ var _a;
936
+ const { color } = item.payload;
937
+ if (color == null)
938
+ return item;
939
+ return __spreadProps(__spreadValues({}, item), {
940
+ payload: __spreadProps(__spreadValues({}, item.payload), {
941
+ color: __spreadProps(__spreadValues({}, color), {
942
+ swatchId: (_a = context.replacementContext.swatchIds.get(color.swatchId)) != null ? _a : color.swatchId
943
+ })
944
+ })
945
+ });
946
+ }
947
+ }
948
+ if (import_meta.vitest) {
949
+ const { describe, test, expect } = import_meta.vitest;
950
+ describe.concurrent("shadow copy", () => {
951
+ test("replaces the swatch id", () => {
952
+ const data = [
953
+ {
954
+ value: [
955
+ {
956
+ id: "8575efe6-4d04-4361-b593-e559537c4c3c",
957
+ payload: {
958
+ color: {
959
+ alpha: 1,
960
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
961
+ },
962
+ offsetX: -5,
963
+ offsetY: 8.7,
964
+ blurRadius: 17,
965
+ spreadRadius: 16
966
+ }
967
+ }
968
+ ],
969
+ deviceId: "desktop"
970
+ }
971
+ ];
972
+ const expected = JSON.parse(JSON.stringify(data).replace("U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"));
973
+ const replacementContext = {
974
+ elementHtmlIds: /* @__PURE__ */ new Set(),
975
+ elementKeys: /* @__PURE__ */ new Map(),
976
+ swatchIds: /* @__PURE__ */ new Map([
977
+ ["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"]
978
+ ]),
979
+ fileIds: /* @__PURE__ */ new Map(),
980
+ typographyIds: /* @__PURE__ */ new Map(),
981
+ tableIds: /* @__PURE__ */ new Map(),
982
+ tableColumnIds: /* @__PURE__ */ new Map(),
983
+ pageIds: /* @__PURE__ */ new Map(),
984
+ globalElementIds: /* @__PURE__ */ new Map(),
985
+ globalElementData: /* @__PURE__ */ new Map()
986
+ };
987
+ const result = copy$a(data, {
988
+ replacementContext,
989
+ copyElement: (node) => node
990
+ });
991
+ expect(result).toMatchObject(expected);
992
+ });
993
+ });
994
+ }
995
+ function copy$9(value, context) {
996
+ var _a;
997
+ if (value == null)
998
+ return value;
999
+ return (_a = context.replacementContext.fileIds.get(value)) != null ? _a : value;
1000
+ }
1001
+ if (import_meta.vitest) {
1002
+ const { describe, test, expect } = import_meta.vitest;
1003
+ describe.concurrent("image copy", () => {
1004
+ test("image is replaced by a one in replacement context", () => {
1005
+ const data = "file-id";
1006
+ const expected = JSON.parse(JSON.stringify(data).replace("file-id", "testing"));
1007
+ const replacementContext = {
1008
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1009
+ elementKeys: /* @__PURE__ */ new Map(),
1010
+ swatchIds: /* @__PURE__ */ new Map(),
1011
+ fileIds: /* @__PURE__ */ new Map([["file-id", "testing"]]),
1012
+ typographyIds: /* @__PURE__ */ new Map(),
1013
+ tableIds: /* @__PURE__ */ new Map(),
1014
+ tableColumnIds: /* @__PURE__ */ new Map(),
1015
+ pageIds: /* @__PURE__ */ new Map(),
1016
+ globalElementIds: /* @__PURE__ */ new Map(),
1017
+ globalElementData: /* @__PURE__ */ new Map()
1018
+ };
1019
+ const result = copy$9(data, {
1020
+ replacementContext,
1021
+ copyElement: (node) => node
1022
+ });
1023
+ expect(result).toMatchObject(expected);
1024
+ });
1025
+ });
1026
+ }
1027
+ function copy$8(value, context) {
1028
+ if (value == null)
1029
+ return value;
1030
+ return value.map(copyImagesPanelItem);
1031
+ function copyImagesPanelItem(imagesPanelItem) {
1032
+ var _a;
1033
+ const { file } = imagesPanelItem.props;
1034
+ if (file == null)
1035
+ return imagesPanelItem;
1036
+ return __spreadProps(__spreadValues({}, imagesPanelItem), {
1037
+ props: __spreadProps(__spreadValues({}, imagesPanelItem.props), {
1038
+ file: (_a = context.replacementContext.fileIds.get(file)) != null ? _a : file
1039
+ })
1040
+ });
1041
+ }
1042
+ }
1043
+ if (import_meta.vitest) {
1044
+ const { describe, test, expect } = import_meta.vitest;
1045
+ describe.concurrent("images copy", () => {
1046
+ test("images are replaced by ones in replacement context", () => {
1047
+ const data = [
1048
+ {
1049
+ key: "0ae80f8f-9d4a-43bc-ae7c-007164a19d22",
1050
+ props: {
1051
+ file: "RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM="
1052
+ }
1053
+ },
1054
+ {
1055
+ key: "161674c3-8710-4fd6-90e6-6096c4e9bb88",
1056
+ props: {
1057
+ file: "RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM="
1058
+ }
1059
+ }
1060
+ ];
1061
+ const expected = JSON.parse(JSON.stringify(data).replaceAll("RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM=", "testing"));
1062
+ const replacementContext = {
1063
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1064
+ elementKeys: /* @__PURE__ */ new Map(),
1065
+ swatchIds: /* @__PURE__ */ new Map(),
1066
+ fileIds: /* @__PURE__ */ new Map([["RmlsZTo5ZmU3ZGUzMi1jY2E0LTRkMjktOWVlMC1jNTI2NDYxY2I1YjM=", "testing"]]),
1067
+ typographyIds: /* @__PURE__ */ new Map(),
1068
+ tableIds: /* @__PURE__ */ new Map(),
1069
+ tableColumnIds: /* @__PURE__ */ new Map(),
1070
+ pageIds: /* @__PURE__ */ new Map(),
1071
+ globalElementIds: /* @__PURE__ */ new Map(),
1072
+ globalElementData: /* @__PURE__ */ new Map()
1073
+ };
1074
+ const result = copy$8(data, {
1075
+ replacementContext,
1076
+ copyElement: (node) => node
1077
+ });
1078
+ expect(result).toMatchObject(expected);
1079
+ });
1080
+ });
1081
+ }
1082
+ function copy$7(value, context) {
1083
+ if (value == null)
1084
+ return value;
1085
+ return value.map((override) => __spreadProps(__spreadValues({}, override), { value: copyColorValue(override.value) }));
1086
+ function copyColorValue(colorValue) {
1087
+ var _a;
1088
+ return __spreadProps(__spreadValues({}, colorValue), {
1089
+ swatchId: (_a = context.replacementContext.swatchIds.get(colorValue.swatchId)) != null ? _a : colorValue.swatchId
1090
+ });
1091
+ }
1092
+ }
1093
+ function copy$6(value, context) {
1094
+ if (value == null)
1095
+ return value;
1096
+ return __spreadProps(__spreadValues({}, value), { fields: value.fields.map(copyFormFieldsPanelItem) });
1097
+ function copyFormFieldsPanelItem(item) {
1098
+ var _a;
1099
+ return __spreadProps(__spreadValues({}, item), {
1100
+ tableColumnId: (_a = context.replacementContext.tableColumnIds.get(item.tableColumnId)) != null ? _a : item.tableColumnId
1101
+ });
1102
+ }
1103
+ }
1104
+ if (import_meta.vitest) {
1105
+ const { describe, test, expect } = import_meta.vitest;
1106
+ describe.concurrent("table form fields copy", () => {
1107
+ test("replaces the table column id", () => {
1108
+ const data = {
1109
+ grid: [
1110
+ {
1111
+ value: {
1112
+ count: 12,
1113
+ spans: [[12], [12]]
1114
+ },
1115
+ deviceId: "desktop"
1116
+ }
1117
+ ],
1118
+ fields: [
1119
+ {
1120
+ id: "8c4b3dcb-d9d2-4199-9a66-c35aa39248f0",
1121
+ label: "hello",
1122
+ required: true,
1123
+ tableColumnId: "U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI="
1124
+ }
1125
+ ]
1126
+ };
1127
+ const expected = JSON.parse(JSON.stringify(data).replace("U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI=", "testing"));
1128
+ const replacementContext = {
1129
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1130
+ elementKeys: /* @__PURE__ */ new Map(),
1131
+ swatchIds: /* @__PURE__ */ new Map(),
1132
+ fileIds: /* @__PURE__ */ new Map(),
1133
+ typographyIds: /* @__PURE__ */ new Map(),
1134
+ tableIds: /* @__PURE__ */ new Map(),
1135
+ tableColumnIds: /* @__PURE__ */ new Map([
1136
+ [
1137
+ "U2luZ2xlTGluZVRleHRUYWJsZUNvbHVtbjphMzQ0Yzk3ZC04MTQ0LTRmMzctYjU2My1hODE5OTQ5OGMyYWI=",
1138
+ "testing"
1139
+ ]
1140
+ ]),
1141
+ pageIds: /* @__PURE__ */ new Map(),
1142
+ globalElementIds: /* @__PURE__ */ new Map(),
1143
+ globalElementData: /* @__PURE__ */ new Map()
1144
+ };
1145
+ const result = copy$6(data, {
1146
+ replacementContext,
1147
+ copyElement: (node) => node
1148
+ });
1149
+ expect(result).toMatchObject(expected);
1150
+ });
1151
+ });
1152
+ }
1153
+ function copy$5(value, context) {
1154
+ var _a;
1155
+ if (value == null)
1156
+ return value;
1157
+ return (_a = context.replacementContext.tableIds.get(value)) != null ? _a : value;
1158
+ }
1159
+ if (import_meta.vitest) {
1160
+ const { describe, test, expect } = import_meta.vitest;
1161
+ describe.concurrent("table copy", () => {
1162
+ test("replaces the table id", () => {
1163
+ const data = "VGFibGU6MTM5NDhlYzMtMjgwNS00Nzk0LTliNzctNDJkN2RhNmQxZWEy";
1164
+ const replacementContext = {
1165
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1166
+ elementKeys: /* @__PURE__ */ new Map(),
1167
+ swatchIds: /* @__PURE__ */ new Map(),
1168
+ fileIds: /* @__PURE__ */ new Map(),
1169
+ typographyIds: /* @__PURE__ */ new Map(),
1170
+ tableIds: /* @__PURE__ */ new Map([
1171
+ ["VGFibGU6MTM5NDhlYzMtMjgwNS00Nzk0LTliNzctNDJkN2RhNmQxZWEy", "testing"]
1172
+ ]),
1173
+ tableColumnIds: /* @__PURE__ */ new Map(),
1174
+ pageIds: /* @__PURE__ */ new Map(),
1175
+ globalElementIds: /* @__PURE__ */ new Map(),
1176
+ globalElementData: /* @__PURE__ */ new Map()
1177
+ };
1178
+ const result = copy$5(data, {
1179
+ replacementContext,
1180
+ copyElement: (node) => node
1181
+ });
1182
+ expect(result).toMatch("testing");
1183
+ });
1184
+ });
1185
+ }
1186
+ function copy$4(value, context) {
1187
+ if (value == null)
1188
+ return value;
1189
+ return value.map((override) => __spreadProps(__spreadValues({}, override), { value: copyBorderValue(override.value) }));
1190
+ function copyBorderValue({ borderTop, borderRight, borderBottom, borderLeft }) {
1191
+ return {
1192
+ borderTop: borderTop && copyBorderSide(borderTop),
1193
+ borderRight: borderRight && copyBorderSide(borderRight),
1194
+ borderBottom: borderBottom && copyBorderSide(borderBottom),
1195
+ borderLeft: borderLeft && copyBorderSide(borderLeft)
1196
+ };
1197
+ }
1198
+ function copyBorderSide(borderSide) {
1199
+ var _a;
1200
+ const { color } = borderSide;
1201
+ if (color == null)
1202
+ return borderSide;
1203
+ return __spreadProps(__spreadValues({}, borderSide), {
1204
+ color: __spreadProps(__spreadValues({}, color), {
1205
+ swatchId: (_a = context.replacementContext.swatchIds.get(color.swatchId)) != null ? _a : color.swatchId
1206
+ })
1207
+ });
1208
+ }
1209
+ }
1210
+ if (import_meta.vitest) {
1211
+ const { describe, test, expect } = import_meta.vitest;
1212
+ describe.concurrent("border copy", () => {
1213
+ test("replaces the swatch id", () => {
1214
+ const data = [
1215
+ {
1216
+ value: {
1217
+ borderTop: {
1218
+ color: {
1219
+ alpha: 1,
1220
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
1221
+ },
1222
+ style: "solid",
1223
+ width: 5
1224
+ },
1225
+ borderLeft: {
1226
+ color: {
1227
+ alpha: 1,
1228
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
1229
+ },
1230
+ style: "solid",
1231
+ width: 5
1232
+ },
1233
+ borderRight: {
1234
+ color: {
1235
+ alpha: 1,
1236
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
1237
+ },
1238
+ style: "solid",
1239
+ width: 5
1240
+ },
1241
+ borderBottom: {
1242
+ color: {
1243
+ alpha: 1,
1244
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
1245
+ },
1246
+ style: "solid",
1247
+ width: 5
1248
+ }
1249
+ },
1250
+ deviceId: "desktop"
1251
+ }
1252
+ ];
1253
+ const expected = [
1254
+ {
1255
+ value: {
1256
+ borderTop: {
1257
+ color: {
1258
+ alpha: 1,
1259
+ swatchId: "testing"
1260
+ },
1261
+ style: "solid",
1262
+ width: 5
1263
+ },
1264
+ borderLeft: {
1265
+ color: {
1266
+ alpha: 1,
1267
+ swatchId: "testing"
1268
+ },
1269
+ style: "solid",
1270
+ width: 5
1271
+ },
1272
+ borderRight: {
1273
+ color: {
1274
+ alpha: 1,
1275
+ swatchId: "testing"
1276
+ },
1277
+ style: "solid",
1278
+ width: 5
1279
+ },
1280
+ borderBottom: {
1281
+ color: {
1282
+ alpha: 1,
1283
+ swatchId: "testing"
1284
+ },
1285
+ style: "solid",
1286
+ width: 5
1287
+ }
1288
+ },
1289
+ deviceId: "desktop"
1290
+ }
1291
+ ];
1292
+ const replacementContext = {
1293
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1294
+ elementKeys: /* @__PURE__ */ new Map(),
1295
+ swatchIds: /* @__PURE__ */ new Map([
1296
+ ["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "testing"]
1297
+ ]),
1298
+ fileIds: /* @__PURE__ */ new Map(),
1299
+ typographyIds: /* @__PURE__ */ new Map(),
1300
+ tableIds: /* @__PURE__ */ new Map(),
1301
+ tableColumnIds: /* @__PURE__ */ new Map(),
1302
+ pageIds: /* @__PURE__ */ new Map(),
1303
+ globalElementIds: /* @__PURE__ */ new Map(),
1304
+ globalElementData: /* @__PURE__ */ new Map()
1305
+ };
1306
+ const result = copy$4(data, {
1307
+ replacementContext,
1308
+ copyElement: (node) => node
1309
+ });
1310
+ expect(result).toMatchObject(expected);
1311
+ });
1312
+ });
1313
+ }
1314
+ function copy$3(value, context) {
1315
+ if (value == null)
1316
+ return value;
1317
+ return __spreadProps(__spreadValues({}, value), { document: value.document ? copyNode(value.document) : value.document });
1318
+ function copyNode(node) {
1319
+ var _a;
1320
+ switch (node.object) {
1321
+ case "document":
1322
+ case "block":
1323
+ case "inline":
1324
+ return copyInline(node);
1325
+ case "text":
1326
+ return __spreadProps(__spreadValues({}, node), { marks: (_a = node.marks) == null ? void 0 : _a.map(copyMark) });
1327
+ default:
1328
+ return node;
1329
+ }
1330
+ }
1331
+ function copyInline(inline) {
1332
+ var _a, _b;
1333
+ switch (inline.type) {
1334
+ case "link":
1335
+ return __spreadProps(__spreadValues({}, inline), {
1336
+ nodes: (_a = inline.nodes) == null ? void 0 : _a.map(copyNode),
1337
+ data: inline.data ? copyLinkData2(inline.data) : inline.data
1338
+ });
1339
+ default:
1340
+ return __spreadProps(__spreadValues({}, inline), { nodes: (_b = inline.nodes) == null ? void 0 : _b.map(copyNode) });
1341
+ }
1342
+ }
1343
+ function copyLinkData2(data) {
1344
+ var _a, _b;
1345
+ switch (data.type) {
1346
+ case "OPEN_PAGE": {
1347
+ const pageId = data.payload.pageId;
1348
+ if (pageId == null)
1349
+ return data;
1350
+ return __spreadProps(__spreadValues({}, data), {
1351
+ payload: __spreadProps(__spreadValues({}, data.payload), {
1352
+ pageId: (_a = context.replacementContext.pageIds.get(pageId)) != null ? _a : data.payload.pageId
1353
+ })
1354
+ });
1355
+ }
1356
+ case "SCROLL_TO_ELEMENT": {
1357
+ const elementIdConfig = data.payload.elementIdConfig;
1358
+ if (elementIdConfig == null)
1359
+ return data;
1360
+ return __spreadProps(__spreadValues({}, data), {
1361
+ payload: __spreadProps(__spreadValues({}, data.payload), {
1362
+ elementIdConfig: __spreadProps(__spreadValues({}, elementIdConfig), {
1363
+ elementKey: (_b = context.replacementContext.elementKeys.get(elementIdConfig.elementKey)) != null ? _b : elementIdConfig.elementKey
1364
+ })
1365
+ })
1366
+ });
1367
+ }
1368
+ default:
1369
+ return data;
1370
+ }
1371
+ }
1372
+ function copyMark(mark) {
1373
+ var _a, _b, _c, _d;
1374
+ switch (mark.type) {
1375
+ case "typography": {
1376
+ const typographyId = (_a = mark.data) == null ? void 0 : _a.value.id;
1377
+ return __spreadProps(__spreadValues({}, mark), {
1378
+ data: __spreadProps(__spreadValues({}, mark.data), {
1379
+ value: __spreadProps(__spreadValues({}, (_b = mark.data) == null ? void 0 : _b.value), {
1380
+ id: (_c = context.replacementContext.typographyIds.get(typographyId)) != null ? _c : typographyId,
1381
+ style: (_d = mark.data) == null ? void 0 : _d.value.style.map((override) => {
1382
+ var _a2, _b2, _c2;
1383
+ return __spreadProps(__spreadValues({}, override), {
1384
+ value: __spreadProps(__spreadValues({}, override.value), {
1385
+ color: override.value.color == null ? override.value.color : __spreadProps(__spreadValues({}, override.value.color), {
1386
+ swatchId: (_c2 = context.replacementContext.swatchIds.get((_a2 = override.value.color) == null ? void 0 : _a2.swatchId)) != null ? _c2 : (_b2 = override.value.color) == null ? void 0 : _b2.swatchId
1387
+ })
1388
+ })
1389
+ });
1390
+ })
1391
+ })
1392
+ })
1393
+ });
1394
+ }
1395
+ default:
1396
+ return mark;
1397
+ }
1398
+ }
1399
+ }
1400
+ if (import_meta.vitest) {
1401
+ const { describe, test, expect } = import_meta.vitest;
1402
+ describe.concurrent("rich text copy", () => {
1403
+ test("replaces the swatch id", () => {
1404
+ const data = {
1405
+ object: "value",
1406
+ document: {
1407
+ data: {},
1408
+ nodes: [
1409
+ {
1410
+ data: {},
1411
+ type: "paragraph",
1412
+ nodes: [
1413
+ {
1414
+ text: "Hello world",
1415
+ marks: [
1416
+ {
1417
+ data: {
1418
+ value: {
1419
+ id: "VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=",
1420
+ style: [
1421
+ {
1422
+ value: {
1423
+ color: {
1424
+ alpha: 1,
1425
+ swatchId: "U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg=="
1426
+ },
1427
+ fontSize: {
1428
+ unit: "px",
1429
+ value: 23
1430
+ },
1431
+ lineHeight: 2.5,
1432
+ strikethrough: true
1433
+ },
1434
+ deviceId: "desktop"
1435
+ }
1436
+ ]
1437
+ }
1438
+ },
1439
+ type: "typography",
1440
+ object: "mark"
1441
+ }
1442
+ ],
1443
+ object: "text"
1444
+ }
1445
+ ],
1446
+ object: "block"
1447
+ }
1448
+ ],
1449
+ object: "document"
1450
+ },
1451
+ selection: {
1452
+ focus: {
1453
+ path: [0, 0],
1454
+ object: "point",
1455
+ offset: 0
1456
+ },
1457
+ anchor: {
1458
+ path: [0, 0],
1459
+ object: "point",
1460
+ offset: 0
1461
+ },
1462
+ object: "selection",
1463
+ isFocused: false
1464
+ }
1465
+ };
1466
+ const expected = JSON.parse(JSON.stringify(data).replace("U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "swatch-testing").replace("VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=", "typography-testing"));
1467
+ const replacementContext = {
1468
+ elementHtmlIds: /* @__PURE__ */ new Set(),
1469
+ elementKeys: /* @__PURE__ */ new Map(),
1470
+ swatchIds: /* @__PURE__ */ new Map([
1471
+ ["U3dhdGNoOjgwMmNmZGMyLTc5ZDgtNDkyNy1hMDUwLWE1NmM1M2EzYzE0Mg==", "swatch-testing"]
1472
+ ]),
1473
+ fileIds: /* @__PURE__ */ new Map(),
1474
+ typographyIds: /* @__PURE__ */ new Map([
1475
+ [
1476
+ "VHlwb2dyYXBoeTo5ODE1NWY0Ni1mNmQzLTQ1M2YtODk5OC02ZWY5NzJhNTBlY2U=",
1477
+ "typography-testing"
1478
+ ]
1479
+ ]),
1480
+ tableIds: /* @__PURE__ */ new Map(),
1481
+ tableColumnIds: /* @__PURE__ */ new Map(),
1482
+ pageIds: /* @__PURE__ */ new Map(),
1483
+ globalElementIds: /* @__PURE__ */ new Map(),
1484
+ globalElementData: /* @__PURE__ */ new Map()
1485
+ };
1486
+ const result = copy$3(data, {
1487
+ replacementContext,
1488
+ copyElement: (node) => node
1489
+ });
1490
+ expect(result).toMatchObject(expected);
1491
+ });
1492
+ });
1493
+ }
1494
+ function copy$2(value, context) {
1495
+ if (value == null)
1496
+ return value;
1497
+ if (context.replacementContext.elementHtmlIds.has(value))
1498
+ return void 0;
1499
+ context.replacementContext.elementHtmlIds.add(value);
1500
+ return value;
1501
+ }
1502
+ function copy$1(descriptor, value, context) {
1503
+ switch (descriptor.type) {
1504
+ case "Backgrounds":
1505
+ return copy$e(value, context);
1506
+ case "Grid":
1507
+ return copy$d(value, context);
1508
+ case "NavigationLinks":
1509
+ return copy$b(value, context);
1510
+ case "Link":
1511
+ return copy$c(value, context);
1512
+ case "Shadows":
1513
+ return copy$a(value, context);
1514
+ case "Image":
1515
+ return copy$9(value, context);
1516
+ case "Images":
1517
+ return copy$8(value, context);
1518
+ case "ResponsiveColor":
1519
+ return copy$7(value, context);
1520
+ case "TableFormFields":
1521
+ return copy$6(value, context);
1522
+ case "Table":
1523
+ return copy$5(value, context);
1524
+ case "Border":
1525
+ return copy$4(value, context);
1526
+ case "RichText":
1527
+ return copy$3(value, context);
1528
+ case "ElementID":
1529
+ return copy$2(value, context);
1530
+ default:
1531
+ return value;
1532
+ }
1533
+ }
1534
+ function copyElementReference(value, context) {
1535
+ return context.replacementContext.globalElementIds.get(value) || value;
1536
+ }
1537
+ function copy(definition, value, context) {
1538
+ switch (definition.type) {
1539
+ case Types.Backgrounds:
1540
+ case Types.Grid:
1541
+ case Types.NavigationLinks:
1542
+ case Types.Link:
1543
+ case Types.Shadows:
1544
+ case Types.Image:
1545
+ case Types.Images:
1546
+ case Types.ResponsiveColor:
1547
+ case Types.TableFormFields:
1548
+ case Types.Table:
1549
+ case Types.Border:
1550
+ case Types.RichText:
1551
+ case Types.ElementID:
1552
+ return copy$1(definition, value, context);
1553
+ case ColorControlType:
1554
+ return copyColorData(value, context);
1555
+ case ImageControlType:
1556
+ return copyImageData(value, context);
1557
+ case LinkControlType:
1558
+ return copyLinkData(value, context);
1559
+ case ShapeControlType:
1560
+ return copyShapeData(definition, value, context);
1561
+ case ListControlType:
1562
+ return copyListData(definition, value, context);
1563
+ case StyleControlType:
1564
+ return copyStyleData(value, context);
1565
+ case SlotControlType:
1566
+ return copySlotData(value, context);
1567
+ default:
1568
+ return value;
1569
+ }
1570
+ }
1571
+ const ObjectType = {
1572
+ Value: "value",
1573
+ Text: "text",
1574
+ Inline: "inline",
1575
+ Block: "block",
1576
+ Document: "document",
1577
+ Leaf: "leaf",
1578
+ Selection: "selection",
1579
+ Mark: "mark",
1580
+ Range: "range",
1581
+ Decoration: "decoration",
1582
+ Annotation: "annotation",
1583
+ Point: "point",
1584
+ Operation: "operation"
1585
+ };
1586
+ const TextType = {
1587
+ Typography: "typography",
1588
+ Text: "text"
1589
+ };
1590
+ const BlockType = {
1591
+ Paragraph: "paragraph",
1592
+ Heading1: "heading-one",
1593
+ Heading2: "heading-two",
1594
+ Heading3: "heading-three",
1595
+ Heading4: "heading-four",
1596
+ Heading5: "heading-five",
1597
+ Heading6: "heading-six",
1598
+ BlockQuote: "blockquote",
1599
+ UnorderedList: "unordered-list",
1600
+ OrderedList: "ordered-list",
1601
+ ListItem: "list-item",
1602
+ ListItemChild: "list-item-child"
1603
+ };
1604
+ const InlineType = {
1605
+ Code: "code",
1606
+ SuperScript: "superscript",
1607
+ SubScript: "subscript",
1608
+ Link: "link"
1609
+ };
1610
+ function toTextDAO(node) {
1611
+ var _a, _b, _c, _d;
1612
+ const typographyMark = (_a = node.marks) == null ? void 0 : _a.find((mark) => mark.type === TextType.Typography);
1613
+ if (typographyMark) {
1614
+ return [
1615
+ {
1616
+ text: (_b = node.text) != null ? _b : "",
1617
+ type: TextType.Typography,
1618
+ typography: (_c = typographyMark.data) == null ? void 0 : _c.value
1619
+ }
1620
+ ];
1621
+ }
1622
+ return [
1623
+ {
1624
+ type: TextType.Text,
1625
+ text: (_d = node.text) != null ? _d : ""
1626
+ }
1627
+ ];
1628
+ }
1629
+ function toInlineDAO(node) {
1630
+ var _a, _b, _c, _d;
1631
+ switch (node.type) {
1632
+ case InlineType.Link:
1633
+ return [
1634
+ {
1635
+ children: (_b = (_a = node.nodes) == null ? void 0 : _a.flatMap(toInlineOrTextDAO)) != null ? _b : [],
1636
+ [node.type]: node.data,
1637
+ type: node.type
1638
+ }
1639
+ ];
1640
+ case InlineType.Code:
1641
+ case InlineType.SubScript:
1642
+ case InlineType.SuperScript:
1643
+ return [
1644
+ {
1645
+ children: (_d = (_c = node.nodes) == null ? void 0 : _c.flatMap(toInlineOrTextDAO)) != null ? _d : [],
1646
+ type: node.type
1647
+ }
1648
+ ];
1649
+ default:
1650
+ return [];
1651
+ }
1652
+ }
1653
+ function toInlineOrTextDAO(node) {
1654
+ switch (node.object) {
1655
+ case ObjectType.Inline:
1656
+ return toInlineDAO(node);
1657
+ case ObjectType.Text:
1658
+ return toTextDAO(node);
1659
+ default:
1660
+ return [];
1661
+ }
1662
+ }
1663
+ function toNodeDAO(node) {
1664
+ var _a, _b;
1665
+ switch (node.object) {
1666
+ case ObjectType.Inline:
1667
+ case ObjectType.Text:
1668
+ return toInlineOrTextDAO(node);
1669
+ case ObjectType.Block:
1670
+ return [
1671
+ {
1672
+ type: node.type,
1673
+ textAlign: (node == null ? void 0 : node.data) && "textAlign" in node.data ? node == null ? void 0 : node.data.textAlign : void 0,
1674
+ children: (_b = (_a = node.nodes) == null ? void 0 : _a.flatMap(toNodeDAO)) != null ? _b : []
1675
+ }
1676
+ ];
1677
+ default:
1678
+ return [];
1679
+ }
1680
+ }
1681
+ function richTextDTOtoSelection(data) {
1682
+ var _a, _b, _c, _d;
1683
+ if (((_b = (_a = data.selection) == null ? void 0 : _a.anchor) == null ? void 0 : _b.offset) != null && data.selection.anchor.path != null && ((_d = (_c = data.selection) == null ? void 0 : _c.focus) == null ? void 0 : _d.offset) != null && data.selection.focus.path != null)
1684
+ return {
1685
+ anchor: {
1686
+ offset: data.selection.anchor.offset,
1687
+ path: data.selection.anchor.path
1688
+ },
1689
+ focus: {
1690
+ offset: data.selection.focus.offset,
1691
+ path: data.selection.focus.path
1692
+ }
1693
+ };
1694
+ return null;
1695
+ }
1696
+ function richTextDTOtoDAO(data) {
1697
+ var _a, _b, _c;
1698
+ return (_c = (_b = (_a = data.document) == null ? void 0 : _a.nodes) == null ? void 0 : _b.flatMap(toNodeDAO)) != null ? _c : [];
1699
+ }
1700
+ function toInlineOrTextDTO(node) {
1701
+ switch (node.type) {
1702
+ case TextType.Typography:
1703
+ return [
1704
+ {
1705
+ object: "text",
1706
+ text: node.text,
1707
+ marks: [
1708
+ {
1709
+ data: {
1710
+ value: node.typography
1711
+ },
1712
+ type: "typography",
1713
+ object: "mark"
1714
+ }
1715
+ ]
1716
+ }
1717
+ ];
1718
+ case TextType.Text:
1719
+ return [
1720
+ {
1721
+ text: node.text,
1722
+ object: "text",
1723
+ marks: []
1724
+ }
1725
+ ];
1726
+ case InlineType.Link:
1727
+ return [
1728
+ {
1729
+ object: ObjectType.Inline,
1730
+ nodes: node.children.flatMap(toInlineOrTextDTO),
1731
+ type: node.type,
1732
+ data: node.link
1733
+ }
1734
+ ];
1735
+ case InlineType.Code:
1736
+ case InlineType.SubScript:
1737
+ case InlineType.SuperScript:
1738
+ return [
1739
+ {
1740
+ object: "inline",
1741
+ nodes: node.children.flatMap(toInlineOrTextDTO),
1742
+ type: node.type,
1743
+ data: {}
1744
+ }
1745
+ ];
1746
+ }
1747
+ }
1748
+ function toNodeDTO(node) {
1749
+ var _a, _b;
1750
+ switch (node.type) {
1751
+ case TextType.Typography:
1752
+ case TextType.Text:
1753
+ case InlineType.Link:
1754
+ case InlineType.Code:
1755
+ case InlineType.SubScript:
1756
+ case InlineType.SuperScript:
1757
+ return toInlineOrTextDTO(node);
1758
+ case BlockType.Heading1:
1759
+ case BlockType.Heading2:
1760
+ case BlockType.Heading3:
1761
+ case BlockType.BlockQuote:
1762
+ case BlockType.Paragraph:
1763
+ case BlockType.OrderedList:
1764
+ case BlockType.UnorderedList:
1765
+ case BlockType.ListItem:
1766
+ case BlockType.ListItemChild:
1767
+ return [
1768
+ {
1769
+ type: node.type,
1770
+ data: node.textAlign ? {
1771
+ textAlign: node.textAlign
1772
+ } : {},
1773
+ object: "block",
1774
+ nodes: (_b = (_a = node.children) == null ? void 0 : _a.flatMap(toNodeDTO)) != null ? _b : []
1775
+ }
1776
+ ];
1777
+ default:
1778
+ return [];
1779
+ }
1780
+ }
1781
+ function toSelectionDTO(selection) {
1782
+ if (selection == null)
1783
+ return void 0;
1784
+ return {
1785
+ isFocused: false,
1786
+ marks: void 0,
1787
+ object: "selection",
1788
+ anchor: {
1789
+ offset: selection.anchor.offset,
1790
+ path: selection.anchor.path,
1791
+ object: "point"
1792
+ },
1793
+ focus: {
1794
+ offset: selection.focus.offset,
1795
+ path: selection.focus.path,
1796
+ object: "point"
1797
+ }
1798
+ };
1799
+ }
1800
+ function richTextDAOToDTO(children, selection) {
1801
+ return {
1802
+ document: {
1803
+ data: void 0,
1804
+ nodes: children.flatMap(toNodeDTO),
1805
+ object: "document"
1806
+ },
1807
+ object: "value",
1808
+ selection: toSelectionDTO(selection),
1809
+ annotations: void 0,
1810
+ data: void 0
1811
+ };
1812
+ }
481
1813
  const RichTextControlType = "makeswift::controls::rich-text";
482
1814
  function RichText() {
483
1815
  return { type: RichTextControlType };
@@ -498,18 +1830,24 @@ class RichTextControl extends PropController {
498
1830
  __publicField(this, "editor", null);
499
1831
  }
500
1832
  recv(message) {
501
- var _a, _b;
1833
+ if (!this.editor)
1834
+ return;
502
1835
  switch (message.type) {
503
1836
  case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
504
1837
  switch (message.editMode) {
505
1838
  case BuilderEditMode.BUILD:
506
- (_a = this.editor) == null ? void 0 : _a.deselect().blur();
507
- break;
1839
+ case BuilderEditMode.INTERACT:
1840
+ ReactEditor.deselect(this.editor);
1841
+ ReactEditor.blur(this.editor);
508
1842
  }
509
1843
  break;
510
1844
  }
511
1845
  case RichTextControlMessageType.FOCUS: {
512
- (_b = this.editor) == null ? void 0 : _b.focus().moveToRangeOfDocument();
1846
+ ReactEditor.focus(this.editor);
1847
+ Transforms.select(this.editor, {
1848
+ anchor: Editor.start(this.editor, []),
1849
+ focus: Editor.end(this.editor, [])
1850
+ });
513
1851
  break;
514
1852
  }
515
1853
  }
@@ -518,14 +1856,18 @@ class RichTextControl extends PropController {
518
1856
  this.editor = editor;
519
1857
  this.send({
520
1858
  type: RichTextControlMessageType.INITIALIZE_EDITOR,
521
- value: editor.value.toJSON({ preserveSelection: false })
522
- });
523
- }
524
- onChange(change) {
525
- this.send({
526
- type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
527
- value: change.value.toJSON({ preserveSelection: true })
1859
+ value: richTextDAOToDTO(editor.children, editor.selection)
528
1860
  });
1861
+ const _onChange = editor.onChange;
1862
+ this.editor.onChange = (options) => {
1863
+ _onChange(options);
1864
+ if ((options == null ? void 0 : options.operation) != null) {
1865
+ this.send({
1866
+ type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
1867
+ value: richTextDAOToDTO(editor.children, editor.selection)
1868
+ });
1869
+ }
1870
+ };
529
1871
  }
530
1872
  focus() {
531
1873
  this.send({ type: RichTextControlMessageType.FOCUS });
@@ -543,5 +1885,5 @@ class RichTextControl extends PropController {
543
1885
  this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
544
1886
  }
545
1887
  }
546
- export { WidthPropControllerFormat as $, ResponsiveOpacity as A, Backgrounds as B, ColorControlType as C, Date as D, ElementID as E, Font as F, GapY as G, NavigationLinks as H, ImageControlType as I, SocialLinks as J, RichText$1 as K, Link as L, Margin as M, Number as N, StyleControlProperty as O, Padding as P, ImageControlValueFormat as Q, RichTextPropControllerMessageType as R, SlotControlType as S, Types as T, BorderPropControllerFormat as U, Video as V, Width as W, ShadowsPropControllerFormat as X, BorderRadiusPropControllerFormat as Y, MarginPropControllerFormat as Z, PaddingPropControllerFormat as _, StyleControlType as a, RichTextControlType as a0, Color as a1, Image as a2, Slot as a3, SlotControlMessageType as a4, SlotControl as a5, Style as a6, RichText as a7, RichTextControlMessageType as a8, RichTextControl as a9, BuilderEditMode as aa, createPropController as ab, copyStyleData as b, copySlotData as c, copyImageData as d, copyColorData as e, descriptors as f, TableFormFieldsMessageType as g, ResponsiveIconRadioGroup as h, Border as i, BorderRadius as j, Shadows as k, GapX as l, ResponsiveSelect as m, ResponsiveNumber as n, Checkbox as o, Grid as p, TextInput as q, reducer as r, ResponsiveColor as s, TextStyle as t, Images as u, ResponsiveLength as v, TextArea as w, Table as x, TableFormFields as y, Image$1 as z };
1888
+ export { WidthPropControllerFormat as $, NavigationLinks as A, Backgrounds as B, ColorControlType as C, Date as D, ElementID as E, Font as F, GapY as G, SocialLinks as H, ImageControlType as I, RichText$1 as J, StyleControlProperty as K, ListControlType as L, Margin as M, Number as N, ImageControlValueFormat as O, Padding as P, LinkControlType as Q, RichTextPropControllerMessageType as R, SlotControlType as S, Types as T, BorderPropControllerFormat as U, Video as V, Width as W, ShadowsPropControllerFormat as X, BorderRadiusPropControllerFormat as Y, MarginPropControllerFormat as Z, PaddingPropControllerFormat as _, copy as a, RichTextControlType as a0, StyleControlType as a1, Color as a2, copyColorData as a3, Image as a4, copyImageData as a5, Link as a6, copyLinkData as a7, List as a8, ListControlMessageType as a9, ListControl as aa, copyListData as ab, Shape as ac, ShapeControlMessageType as ad, ShapeControl as ae, copyShapeData as af, Slot as ag, SlotControlMessageType as ah, SlotControl as ai, copySlotData as aj, Style as ak, copyStyleData as al, ObjectType as am, RichText as an, RichTextControlMessageType as ao, RichTextControl as ap, richTextDTOtoSelection as aq, richTextDTOtoDAO as ar, toSelectionDTO as as, richTextDAOToDTO as at, TextType as au, BlockType as av, InlineType as aw, BuilderEditMode as ax, createPropController as ay, TableFormFieldsMessageType as b, copyElementReference as c, descriptors as d, ShapeControlType as e, ResponsiveIconRadioGroup as f, Border as g, BorderRadius as h, Shadows as i, GapX as j, ResponsiveSelect as k, ResponsiveNumber as l, Checkbox as m, Grid as n, TextInput as o, Link$1 as p, ResponsiveColor as q, reducer as r, TextStyle as s, Images as t, ResponsiveLength as u, TextArea as v, Table as w, TableFormFields as x, Image$1 as y, ResponsiveOpacity as z };
547
1889
  //# sourceMappingURL=rich-text.es.js.map