@makeswift/runtime 0.11.2 → 0.11.4

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 (173) hide show
  1. package/dist/Box.cjs.js +4 -2
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +4 -2
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +4 -2
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +4 -2
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +5 -3
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +5 -3
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +3 -1
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +3 -1
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +4 -2
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +4 -2
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +3 -1
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +3 -1
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +3 -1
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +3 -1
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +3 -1
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +3 -1
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +4 -2
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +4 -2
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +3 -1
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +3 -1
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +3 -1
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +4 -2
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +3 -1
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +4 -2
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/ReadOnlyTextV2.cjs.js +3 -1
  50. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  51. package/dist/ReadOnlyTextV2.es.js +4 -2
  52. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  53. package/dist/Root.cjs.js +2 -0
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +2 -0
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +4 -2
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +4 -2
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Video.cjs.js +3 -1
  62. package/dist/Video.cjs.js.map +1 -1
  63. package/dist/Video.es.js +3 -1
  64. package/dist/Video.es.js.map +1 -1
  65. package/dist/builder.cjs.js +4 -2
  66. package/dist/builder.cjs.js.map +1 -1
  67. package/dist/builder.es.js +4 -2
  68. package/dist/builder.es.js.map +1 -1
  69. package/dist/components.cjs.js +4 -2
  70. package/dist/components.cjs.js.map +1 -1
  71. package/dist/components.es.js +4 -2
  72. package/dist/components.es.js.map +1 -1
  73. package/dist/control-serialization.cjs.js +5 -0
  74. package/dist/control-serialization.cjs.js.map +1 -1
  75. package/dist/control-serialization.es.js +5 -0
  76. package/dist/control-serialization.es.js.map +1 -1
  77. package/dist/controls.cjs.js +8 -2
  78. package/dist/controls.cjs.js.map +1 -1
  79. package/dist/controls.es.js +5 -3
  80. package/dist/controls.es.js.map +1 -1
  81. package/dist/index.cjs.js +32 -4
  82. package/dist/index.cjs.js.map +1 -1
  83. package/dist/index.cjs2.js +5 -2
  84. package/dist/index.cjs2.js.map +1 -1
  85. package/dist/index.cjs8.js +3 -1
  86. package/dist/index.cjs8.js.map +1 -1
  87. package/dist/index.cjs9.js +2 -0
  88. package/dist/index.cjs9.js.map +1 -1
  89. package/dist/index.es.js +33 -5
  90. package/dist/index.es.js.map +1 -1
  91. package/dist/index.es2.js +6 -3
  92. package/dist/index.es2.js.map +1 -1
  93. package/dist/index.es5.js +1 -1
  94. package/dist/index.es6.js +1 -1
  95. package/dist/index.es8.js +4 -2
  96. package/dist/index.es8.js.map +1 -1
  97. package/dist/index.es9.js +3 -1
  98. package/dist/index.es9.js.map +1 -1
  99. package/dist/main.cjs.js +4 -2
  100. package/dist/main.cjs.js.map +1 -1
  101. package/dist/main.es.js +4 -2
  102. package/dist/main.es.js.map +1 -1
  103. package/dist/next.cjs.js +3 -1
  104. package/dist/next.cjs.js.map +1 -1
  105. package/dist/next.es.js +3 -1
  106. package/dist/next.es.js.map +1 -1
  107. package/dist/prop-controllers.cjs.js +4 -2
  108. package/dist/prop-controllers.cjs.js.map +1 -1
  109. package/dist/prop-controllers.es.js +4 -2
  110. package/dist/prop-controllers.es.js.map +1 -1
  111. package/dist/react-page.cjs.js +207 -28
  112. package/dist/react-page.cjs.js.map +1 -1
  113. package/dist/react-page.es.js +203 -29
  114. package/dist/react-page.es.js.map +1 -1
  115. package/dist/react.cjs.js +4 -2
  116. package/dist/react.cjs.js.map +1 -1
  117. package/dist/react.es.js +4 -2
  118. package/dist/react.es.js.map +1 -1
  119. package/dist/slate.cjs.js +4 -2
  120. package/dist/slate.cjs.js.map +1 -1
  121. package/dist/slate.es.js +5 -3
  122. package/dist/slate.es.js.map +1 -1
  123. package/dist/toText.cjs.js +5 -0
  124. package/dist/toText.cjs.js.map +1 -1
  125. package/dist/toText.es.js +6 -1
  126. package/dist/toText.es.js.map +1 -1
  127. package/dist/types/src/controls/control.d.ts +2 -1
  128. package/dist/types/src/controls/control.d.ts.map +1 -1
  129. package/dist/types/src/controls/list.d.ts +7 -1
  130. package/dist/types/src/controls/list.d.ts.map +1 -1
  131. package/dist/types/src/controls/rich-text/__test__/dto.test.d.ts +2 -0
  132. package/dist/types/src/controls/rich-text/__test__/dto.test.d.ts.map +1 -0
  133. package/dist/types/src/controls/rich-text/{translation.d.ts → dto.d.ts} +1 -1
  134. package/dist/types/src/controls/rich-text/dto.d.ts.map +1 -0
  135. package/dist/types/src/controls/rich-text/index.d.ts +1 -1
  136. package/dist/types/src/controls/rich-text/index.d.ts.map +1 -1
  137. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/rearranged.d.ts +10 -0
  138. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/rearranged.d.ts.map +1 -0
  139. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/simple.d.ts +20 -0
  140. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/simple.d.ts.map +1 -0
  141. package/dist/types/src/controls/rich-text-v2/__test__/translation.test.d.ts.map +1 -0
  142. package/dist/types/src/controls/rich-text-v2/dto.d.ts +5 -0
  143. package/dist/types/src/controls/rich-text-v2/dto.d.ts.map +1 -0
  144. package/dist/types/src/controls/rich-text-v2/index.d.ts +1 -1
  145. package/dist/types/src/controls/rich-text-v2/index.d.ts.map +1 -1
  146. package/dist/types/src/controls/rich-text-v2/translation.d.ts +4 -4
  147. package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
  148. package/dist/types/src/controls/shape.d.ts +5 -1
  149. package/dist/types/src/controls/shape.d.ts.map +1 -1
  150. package/dist/types/src/controls/slot.d.ts +5 -1
  151. package/dist/types/src/controls/slot.d.ts.map +1 -1
  152. package/dist/types/src/next/api-handler/handlers/merge-translated-data.d.ts +13 -0
  153. package/dist/types/src/next/api-handler/handlers/merge-translated-data.d.ts.map +1 -0
  154. package/dist/types/src/next/api-handler/index.d.ts +5 -2
  155. package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
  156. package/dist/types/src/next/client.d.ts +1 -0
  157. package/dist/types/src/next/client.d.ts.map +1 -1
  158. package/dist/types/src/prop-controllers/descriptors.d.ts +5 -1
  159. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  160. package/dist/types/src/runtimes/react/index.d.ts +2 -0
  161. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  162. package/dist/types/src/slate/types.d.ts +5 -0
  163. package/dist/types/src/slate/types.d.ts.map +1 -1
  164. package/dist/types/src/slate/utils/element.d.ts +1 -1
  165. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  166. package/dist/types/src/state/react-page.d.ts +6 -0
  167. package/dist/types/src/state/react-page.d.ts.map +1 -1
  168. package/package.json +3 -1
  169. package/dist/types/src/controls/rich-text/__test__/translation.test.d.ts.map +0 -1
  170. package/dist/types/src/controls/rich-text/translation.d.ts.map +0 -1
  171. package/dist/types/src/controls/rich-text-v2/translatableData.d.ts +0 -3
  172. package/dist/types/src/controls/rich-text-v2/translatableData.d.ts.map +0 -1
  173. /package/dist/types/src/controls/{rich-text → rich-text-v2}/__test__/translation.test.d.ts +0 -0
@@ -41,15 +41,17 @@ import { A as ActionTypes } from "./actions.es.js";
41
41
  import { findBreakpointOverride, reducer as reducer$9, getInitialState as getInitialState$8 } from "./state/breakpoints.es.js";
42
42
  import { match, P } from "ts-pattern";
43
43
  import ipsum from "corporate-ipsum";
44
- import { Element, Range, Editor, Text, Path, Transforms, Node, Point } from "slate";
44
+ import { Element, Range, Editor, Text, Path, Transforms, Node, Point, createEditor } from "slate";
45
45
  import { v4 } from "uuid";
46
46
  import escapeHtml from "escape-html";
47
+ import { jsx as jsx$1 } from "slate-hyperscript";
48
+ import { parseFragment } from "parse5";
49
+ import isHotkey from "is-hotkey";
50
+ import { jsx, Fragment } from "react/jsx-runtime";
47
51
  import React__default from "react";
48
52
  import { cache, cx } from "@emotion/css";
49
53
  import { serializeStyles } from "@emotion/serialize";
50
54
  import { registerStyles, insertStyles } from "@emotion/utils";
51
- import { jsx, Fragment } from "react/jsx-runtime";
52
- import isHotkey from "is-hotkey";
53
55
  const ComponentIcon = {
54
56
  Billing: "billing",
55
57
  Bolt: "bolt",
@@ -565,6 +567,11 @@ function GapY(options = {}) {
565
567
  function Grid(options = {}) {
566
568
  return { type: Types.Grid, options };
567
569
  }
570
+ function mergeGridPropControllerTranslatedData(data, context) {
571
+ return __spreadProps(__spreadValues({}, data), {
572
+ elements: data.elements.map((element) => context.mergeTranslatedData(element))
573
+ });
574
+ }
568
575
  function Image$1(options = {}) {
569
576
  return { type: Types.Image, version: 1, options };
570
577
  }
@@ -718,6 +725,7 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
718
725
  GapX,
719
726
  GapY,
720
727
  Grid,
728
+ mergeGridPropControllerTranslatedData,
721
729
  Image: Image$1,
722
730
  Images,
723
731
  Link: Link$1,
@@ -1055,6 +1063,13 @@ function getListPageIds(definition2, value) {
1055
1063
  function getListTranslatableData(definition2, data) {
1056
1064
  return Object.fromEntries(data.map((item) => [item.id, getTranslatableData(definition2.config.type, item.value)]));
1057
1065
  }
1066
+ function mergeListTranslatedData(definition2, data, translatedData, context) {
1067
+ return data.map((item) => {
1068
+ return __spreadProps(__spreadValues({}, item), {
1069
+ value: mergeTranslatedData(definition2.config.type, item.value, translatedData[item.id], context)
1070
+ });
1071
+ });
1072
+ }
1058
1073
  const ShapeControlType = "makeswift::controls::shape";
1059
1074
  function Shape(config) {
1060
1075
  return { type: ShapeControlType, config };
@@ -1134,6 +1149,12 @@ function getShapeTranslatableData(definition2, data) {
1134
1149
  getTranslatableData(definition22, data[key])
1135
1150
  ]));
1136
1151
  }
1152
+ function mergeShapeTranslatedData(definition2, data, translatedData, context) {
1153
+ return Object.fromEntries(Object.entries(definition2.config.type).map(([key, definition22]) => [
1154
+ key,
1155
+ mergeTranslatedData(definition22, data.key, translatedData[key], context)
1156
+ ]));
1157
+ }
1137
1158
  const TextAreaControlType = "makeswift::controls::text-area";
1138
1159
  function TextArea(config = {}) {
1139
1160
  return { type: TextAreaControlType, config };
@@ -1186,6 +1207,11 @@ function mergeSlotData(base = { columns: [], elements: [] }, override = { column
1186
1207
  });
1187
1208
  return { columns: mergedColumns, elements: mergedElements };
1188
1209
  }
1210
+ function mergeSlotControlTranslatedData(data, context) {
1211
+ return __spreadProps(__spreadValues({}, data), {
1212
+ elements: data.elements.map((element) => context.mergeTranslatedData(element))
1213
+ });
1214
+ }
1189
1215
  function copy$e(descriptor, value, context) {
1190
1216
  if (value == null)
1191
1217
  return value;
@@ -2366,7 +2392,7 @@ const ElementUtils = {
2366
2392
  return Element.isElement(node) && (this.isRootBlock(node) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
2367
2393
  },
2368
2394
  isInline(node) {
2369
- return Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript);
2395
+ return Element.isElement(node) && (Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript));
2370
2396
  },
2371
2397
  isConvertibleToListTextNode(node) {
2372
2398
  return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
@@ -3941,40 +3967,132 @@ function copyRichTextV2Data(data, context) {
3941
3967
  });
3942
3968
  }
3943
3969
  }
3944
- function hashTranslationString(s) {
3945
- let hash = 0;
3946
- for (let i = 0, len = s.length; i < len; i++) {
3947
- let chr = s.charCodeAt(i);
3948
- hash = (hash << 5) - hash + chr;
3949
- hash |= 0;
3970
+ function pathToString(path) {
3971
+ return path.join(":");
3972
+ }
3973
+ function stringToPath(s) {
3974
+ return s.split(":").map((a) => parseInt(a));
3975
+ }
3976
+ function getDescendantTranslatableData(descendant, path) {
3977
+ if (Text.isText(descendant)) {
3978
+ return {};
3979
+ }
3980
+ switch (descendant.type) {
3981
+ case BlockType.UnorderedList:
3982
+ case BlockType.OrderedList:
3983
+ case BlockType.ListItem:
3984
+ return descendant.children.reduce((acc, d, j) => __spreadValues(__spreadValues({}, acc), getDescendantTranslatableData(d, [...path, j])), {});
3985
+ default:
3986
+ const text = getInlineOrTextTranslatableData(descendant);
3987
+ if (text == null)
3988
+ return {};
3989
+ return { [pathToString(path)]: text };
3950
3990
  }
3951
- return hash.toString();
3952
3991
  }
3953
- function getRichTextV2TranslatableDescendant(definition2, descendant) {
3992
+ function getInlineOrTextTranslatableData(descendant, path = []) {
3954
3993
  if (Text.isText(descendant)) {
3955
3994
  let string = escapeHtml(descendant.text);
3956
- return string;
3995
+ if (string === "")
3996
+ return null;
3997
+ return `<span key="${pathToString(path)}">${string}</span>`;
3957
3998
  }
3958
- const children = descendant.children.map((child) => getRichTextV2TranslatableDescendant(definition2, child)).join("");
3999
+ const children = descendant.children.map((child, i) => getInlineOrTextTranslatableData(child, [...path, i])).join("");
4000
+ if (children === "")
4001
+ return null;
3959
4002
  switch (descendant.type) {
3960
4003
  case InlineType.Link:
3961
- return `<a>${children}</a>`;
3962
- case InlineType.Link:
3963
- return `<sup>${children}</sup>`;
3964
- case InlineType.Link:
3965
- return `<sub>${children}</sub>`;
3966
- case InlineType.Link:
3967
- return `<code>${children}</code>`;
4004
+ return `<a key="${pathToString(path)}">${children}</a>`;
4005
+ case InlineType.SuperScript:
4006
+ return `<sup key="${pathToString(path)}">${children}</sup>`;
4007
+ case InlineType.SubScript:
4008
+ return `<sub key="${pathToString(path)}">${children}</sub>`;
4009
+ case InlineType.Code:
4010
+ return `<code key="${pathToString(path)}">${children}</code>`;
3968
4011
  default:
3969
4012
  return children;
3970
4013
  }
3971
4014
  }
3972
- function getRichTextV2TranslatableData(definition2, data) {
3973
- return data.descendants.reduce((acc, descendant) => {
3974
- const value = getRichTextV2TranslatableDescendant(definition2, descendant);
3975
- const key = hashTranslationString(value);
3976
- return __spreadProps(__spreadValues({}, acc), { [key]: value });
3977
- }, {});
4015
+ function getRichTextV2TranslatableData(data) {
4016
+ return data.descendants.reduce((acc, descendant, i) => __spreadValues(__spreadValues({}, acc), getDescendantTranslatableData(descendant, [i])), {});
4017
+ }
4018
+ function deserializeTranslationHtmlString(el, translationKey) {
4019
+ var _a, _b;
4020
+ if (el.nodeName === "#document-fragment") {
4021
+ const children = Array.from(el.childNodes).map((element) => deserializeTranslationHtmlString(element)).flat();
4022
+ if (children.length === 0) {
4023
+ children.push(jsx$1("text", {}, ""));
4024
+ }
4025
+ return children;
4026
+ } else if (el.nodeName === "#text" && "value" in el) {
4027
+ return [jsx$1("text", { translationKey: translationKey != null ? translationKey : void 0 }, el.value)];
4028
+ } else if ("namespaceURI" in el) {
4029
+ const translationKey2 = (_b = (_a = el.attrs.find((a) => a.name === "key")) == null ? void 0 : _a.value) != null ? _b : void 0;
4030
+ const children = Array.from(el.childNodes).map((element) => deserializeTranslationHtmlString(element, translationKey2)).flat();
4031
+ if (children.length === 0) {
4032
+ children.push(jsx$1("text", {}, ""));
4033
+ }
4034
+ switch (el.nodeName) {
4035
+ case "code":
4036
+ return [jsx$1("element", { type: InlineType.Code, translationKey: translationKey2 }, children)];
4037
+ case "sub":
4038
+ return [jsx$1("element", { type: InlineType.SubScript, translationKey: translationKey2 }, children)];
4039
+ case "sup":
4040
+ return [jsx$1("element", { type: InlineType.SuperScript, translationKey: translationKey2 }, children)];
4041
+ case "a":
4042
+ return [jsx$1("element", { type: InlineType.Link, translationKey: translationKey2 }, children)];
4043
+ default:
4044
+ return children;
4045
+ }
4046
+ }
4047
+ return [];
4048
+ }
4049
+ function mergeRichTextV2TranslatedData(definition2, data, translatedData) {
4050
+ var _a;
4051
+ const plugins = ((_a = definition2 == null ? void 0 : definition2.config) == null ? void 0 : _a.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin()];
4052
+ const sourceEditor = plugins.reduceRight((editor, plugin) => {
4053
+ var _a2, _b;
4054
+ return (_b = (_a2 = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a2.call(plugin, editor)) != null ? _b : editor;
4055
+ }, createEditor());
4056
+ const targetEditor = plugins.reduceRight((editor, plugin) => {
4057
+ var _a2, _b;
4058
+ return (_b = (_a2 = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a2.call(plugin, editor)) != null ? _b : editor;
4059
+ }, createEditor());
4060
+ sourceEditor.children = data.descendants;
4061
+ Object.entries(translatedData).reverse().forEach(([blockStringPath, htmlString]) => {
4062
+ var _c2;
4063
+ const blockPath = stringToPath(blockStringPath);
4064
+ if (blockPath.length === 0)
4065
+ return;
4066
+ const html = parseFragment(htmlString);
4067
+ const inlineDescendants = deserializeTranslationHtmlString(html);
4068
+ targetEditor.children = [{ type: BlockType.Default, children: inlineDescendants }];
4069
+ Editor.normalize(targetEditor, { force: true });
4070
+ for (const [descendant, absolutePathToTargetNode] of Node.descendants(targetEditor)) {
4071
+ if (!Text.isText(descendant) && !ElementUtils.isInline(descendant) || descendant.translationKey == null || descendant.translationKey === "") {
4072
+ continue;
4073
+ }
4074
+ const relativePathToSourceNode = stringToPath(descendant.translationKey);
4075
+ const absolutePathToSourceNode = [...blockPath, ...relativePathToSourceNode];
4076
+ const [sourceNode] = Editor.node(sourceEditor, absolutePathToSourceNode);
4077
+ if (Text.isText(sourceNode) && Text.isText(descendant)) {
4078
+ const _a2 = sourceNode, { translationKey, text } = _a2, rest = __objRest(_a2, ["translationKey", "text"]);
4079
+ Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode });
4080
+ Transforms.unsetNodes(targetEditor, "translationKey", { at: absolutePathToTargetNode });
4081
+ } else if (ElementUtils.isInline(sourceNode) && ElementUtils.isInline(descendant)) {
4082
+ const _b = sourceNode, { translationKey, children } = _b, rest = __objRest(_b, ["translationKey", "children"]);
4083
+ Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode });
4084
+ Transforms.unsetNodes(targetEditor, "translationKey", { at: absolutePathToTargetNode });
4085
+ }
4086
+ }
4087
+ const translatedChildren = (_c2 = targetEditor.children.at(0)) == null ? void 0 : _c2.children;
4088
+ Editor.withoutNormalizing(sourceEditor, () => {
4089
+ Array.from(Node.children(sourceEditor, blockPath)).reverse().forEach(([_, path]) => {
4090
+ Transforms.removeNodes(sourceEditor, { at: path });
4091
+ });
4092
+ Transforms.insertNodes(sourceEditor, translatedChildren, { at: [...blockPath, 0] });
4093
+ });
4094
+ });
4095
+ return __spreadProps(__spreadValues({}, data), { descendants: sourceEditor.children });
3978
4096
  }
3979
4097
  function copy(definition2, value, context) {
3980
4098
  switch (definition2.type) {
@@ -4030,7 +4148,10 @@ function getTranslatableData(definition2, data) {
4030
4148
  case TextAreaControlType:
4031
4149
  return data;
4032
4150
  case RichTextV2ControlType:
4033
- return getRichTextV2TranslatableData(definition2, data);
4151
+ const richTextData = data;
4152
+ if (isRichTextV1Data(richTextData))
4153
+ return null;
4154
+ return getRichTextV2TranslatableData(richTextData);
4034
4155
  case ListControlType:
4035
4156
  return getListTranslatableData(definition2, data);
4036
4157
  case ShapeControlType:
@@ -4039,6 +4160,35 @@ function getTranslatableData(definition2, data) {
4039
4160
  return null;
4040
4161
  }
4041
4162
  }
4163
+ function mergeTranslatedData(definition2, data, translatedData, context) {
4164
+ switch (definition2.type) {
4165
+ case Types.TextInput:
4166
+ case Types.TextArea:
4167
+ case TextInputControlType:
4168
+ case TextAreaControlType:
4169
+ if (translatedData == null)
4170
+ return data;
4171
+ return translatedData;
4172
+ case Types.Grid:
4173
+ return mergeGridPropControllerTranslatedData(data, context);
4174
+ case SlotControlType:
4175
+ return mergeSlotControlTranslatedData(data, context);
4176
+ case RichTextV2ControlType:
4177
+ if (translatedData == null)
4178
+ return data;
4179
+ return mergeRichTextV2TranslatedData(definition2, data, translatedData);
4180
+ case ListControlType:
4181
+ if (translatedData == null)
4182
+ return data;
4183
+ return mergeListTranslatedData(definition2, data, translatedData, context);
4184
+ case ShapeControlType:
4185
+ if (translatedData == null)
4186
+ return data;
4187
+ return mergeShapeTranslatedData(definition2, data, translatedData, context);
4188
+ default:
4189
+ return data;
4190
+ }
4191
+ }
4042
4192
  const StyleV2ControlType = "makeswift::controls::style-v2";
4043
4193
  const unstable_useStyleV2ClassName = useStyle;
4044
4194
  function unstable_StyleV2(config) {
@@ -4714,6 +4864,30 @@ function getElementTreeTranslatableData(state, elementTree) {
4714
4864
  }
4715
4865
  return translatableData;
4716
4866
  }
4867
+ function mergeElementTreeTranslatedData(state, elementTree, translatedData) {
4868
+ function merge2(state2, translatedData2) {
4869
+ return function(node) {
4870
+ if (isElementReference(node))
4871
+ return node;
4872
+ const elementDescriptors = getPropControllerDescriptors(state2);
4873
+ const descriptors2 = elementDescriptors.get(node.type);
4874
+ if (descriptors2 == null) {
4875
+ throw new Error(`Can't merge element of type "${node.type}" because it has no descriptors`);
4876
+ }
4877
+ const context = {
4878
+ translatedData: translatedData2,
4879
+ mergeTranslatedData: merge2(state2, translatedData2)
4880
+ };
4881
+ const props = {};
4882
+ for (const propName of Object.keys(descriptors2)) {
4883
+ const descriptor = descriptors2[propName];
4884
+ props[propName] = mergeTranslatedData(descriptor, node.props[propName], translatedData2[`${node.key}:${propName}`], context);
4885
+ }
4886
+ return __spreadProps(__spreadValues({}, node), { props });
4887
+ };
4888
+ }
4889
+ return merge2(state, translatedData)(elementTree);
4890
+ }
4717
4891
  function getIsInBuilder(state) {
4718
4892
  return state.isInBuilder;
4719
4893
  }
@@ -4736,5 +4910,5 @@ function configureStore({
4736
4910
  breakpoints: getInitialState$8(breakpoints != null ? breakpoints : preloadedState == null ? void 0 : preloadedState.breakpoints)
4737
4911
  }), applyMiddleware(thunk));
4738
4912
  }
4739
- export { getBorderSwatchIds as $, TextStyle as A, Backgrounds as B, ComponentIcon as C, Date as D, ElementID as E, Font as F, GapY as G, ResponsiveLength as H, Images as I, TextArea$1 as J, Table as K, Link$1 as L, Margin as M, Number as N, TableFormFields as O, Padding as P, Image$1 as Q, RichTextPropControllerMessageType as R, Shadows as S, TableFormFieldsMessageType as T, ResponsiveOpacity as U, NavigationLinks as V, Width as W, SocialLinks as X, RichText as Y, Video as Z, useStyle as _, copy$9 as a, getListTranslatableData as a$, getBoxShadowsSwatchIds as a0, getResponsiveColorSwatchIds as a1, StyleControlProperty as a2, ImageControlValueFormat as a3, isPropControllersHandle as a4, isRichTextV1Data as a5, isNonNullable as a6, TypographyControlType as a7, StyleControlType as a8, RichTextV2ControlType as a9, getElementId as aA, getIsInBuilder as aB, getReactComponent as aC, getBuilderEditMode as aD, getIsPreview as aE, getBackgroundsFileIds as aF, getBackgroundsSwatchIds as aG, Color as aH, copyColorData as aI, copy as aJ, merge as aK, getTranslatableData as aL, unstable_IconRadioGroupIcon as aM, unstable_IconRadioGroup as aN, Image as aO, copyImageData as aP, Link as aQ, copyLinkData as aR, List as aS, ListControlMessageType as aT, ListControl as aU, copyListData as aV, getListElementChildren as aW, getListSwatchIds as aX, getListFileIds as aY, getListTypographyIds as aZ, getListPageIds as a_, RichTextControlType as aa, SlotControlType as ab, StyleV2ControlType as ac, ListControlType as ad, ShapeControlType as ae, LinkControlType as af, ImageControlType as ag, IconRadioGroupControlType as ah, ColorControlType as ai, SelectControlType as aj, TextAreaControlType as ak, TextInputControlType as al, getComponentPropControllerDescriptors as am, getPropControllers as an, Types as ao, BorderPropControllerFormat as ap, ShadowsPropControllerFormat as aq, BorderRadiusPropControllerFormat as ar, MarginPropControllerFormat as as, PaddingPropControllerFormat as at, WidthPropControllerFormat as au, configureStore as av, copyElementTree as aw, getBreakpoints as ax, getElementTreeTranslatableData as ay, getDocument as az, copy$8 as b, onChange$1 as b$, Select as b0, Shape as b1, ShapeControlMessageType as b2, ShapeControl as b3, copyShapeData as b4, getShapeElementChildren as b5, getShapeSwatchIds as b6, getShapeTypographyIds as b7, getShapePageIds as b8, getShapeFileIds as b9, RichTextV2Control as bA, richTextV2DataToDescendents as bB, richTextV2DescendentsToData as bC, createRichTextV2Plugin as bD, unstable_Typography as bE, getTypographySwatchIds as bF, getTypographyTypographyIds as bG, TypographyActions as bH, TYPOGRAPHY_KEY as bI, withTypography as bJ, TypographyPlugin as bK, BlockActions as bL, ListActions as bM, onKeyDown as bN, withBlock as bO, BlockPlugin as bP, withInlineMode as bQ, InlineModePlugin as bR, withTextAlign as bS, TextAlignPlugin as bT, RootBlockType as bU, BlockType as bV, InlineType as bW, BlockTextAlignment as bX, withInline as bY, InlinePlugin as bZ, ElementUtils as b_, getShapeTranslatableData as ba, Slot as bb, SlotControlMessageType as bc, SlotControl as bd, copySlotData as be, mergeSlotData as bf, Style as bg, StyleControlMessageType as bh, StyleControl as bi, copyStyleData as bj, unstable_useStyleV2ClassName as bk, unstable_StyleV2 as bl, StyleV2ControlMessageType as bm, StyleV2Control as bn, TextArea as bo, TextInput as bp, copyRichTextData as bq, ObjectType as br, RichTextControlMessageType as bs, RichTextControl as bt, richTextDTOtoSelection as bu, richTextDTOtoDAO as bv, toSelectionDTO as bw, richTextDAOToDTO as bx, RichTextV2Mode as by, RichTextV2ControlMessageType as bz, createDocument as c, getValue$3 as c0, isLinkElement as c1, getInitialState$6 as c2, reducer$7 as c3, getDocument$1 as c4, getComponentsMeta as c5, getComponentPropControllerDescriptors$1 as c6, BuilderEditMode as c7, getDocumentKeysSortedByDepth as c8, getPropController as c9, getPropControllersHandle as ca, getElement as cb, getElementPropControllerDescriptors as cc, createPropController as cd, reducer$6 as ce, reducer$8 as cf, reducer$5 as cg, reducer$4 as ch, reducer$3 as ci, reducer$2 as cj, reducer$1 as ck, getInitialState$1 as cl, descriptors as d, copy$e as e, deepEqual as f, createDocumentReference as g, getPropControllerDescriptors as h, introspection as i, isElementReference as j, getSwatchIds as k, getFileIds as l, getTypographyIds as m, getTableIds as n, getPageIds as o, getElementChildren as p, ResponsiveIconRadioGroup as q, Border as r, BorderRadius as s, GapX as t, ResponsiveSelect as u, ResponsiveNumber as v, Checkbox as w, Grid as x, TextInput$1 as y, ResponsiveColor as z };
4913
+ export { getBorderSwatchIds as $, TextStyle as A, Backgrounds as B, ComponentIcon as C, Date as D, ElementID as E, Font as F, GapY as G, ResponsiveLength as H, Images as I, TextArea$1 as J, Table as K, Link$1 as L, Margin as M, Number as N, TableFormFields as O, Padding as P, Image$1 as Q, RichTextPropControllerMessageType as R, Shadows as S, TableFormFieldsMessageType as T, ResponsiveOpacity as U, NavigationLinks as V, Width as W, SocialLinks as X, RichText as Y, Video as Z, useStyle as _, copy$9 as a, getListTypographyIds as a$, getBoxShadowsSwatchIds as a0, getResponsiveColorSwatchIds as a1, StyleControlProperty as a2, ImageControlValueFormat as a3, isPropControllersHandle as a4, isRichTextV1Data as a5, isNonNullable as a6, TypographyControlType as a7, StyleControlType as a8, RichTextV2ControlType as a9, getDocument as aA, getElementId as aB, getIsInBuilder as aC, getReactComponent as aD, getBuilderEditMode as aE, getIsPreview as aF, getBackgroundsFileIds as aG, getBackgroundsSwatchIds as aH, Color as aI, copyColorData as aJ, copy as aK, merge as aL, getTranslatableData as aM, mergeTranslatedData as aN, unstable_IconRadioGroupIcon as aO, unstable_IconRadioGroup as aP, Image as aQ, copyImageData as aR, Link as aS, copyLinkData as aT, List as aU, ListControlMessageType as aV, ListControl as aW, copyListData as aX, getListElementChildren as aY, getListSwatchIds as aZ, getListFileIds as a_, RichTextControlType as aa, SlotControlType as ab, StyleV2ControlType as ac, ListControlType as ad, ShapeControlType as ae, LinkControlType as af, ImageControlType as ag, IconRadioGroupControlType as ah, ColorControlType as ai, SelectControlType as aj, TextAreaControlType as ak, TextInputControlType as al, getComponentPropControllerDescriptors as am, getPropControllers as an, Types as ao, BorderPropControllerFormat as ap, ShadowsPropControllerFormat as aq, BorderRadiusPropControllerFormat as ar, MarginPropControllerFormat as as, PaddingPropControllerFormat as at, WidthPropControllerFormat as au, configureStore as av, copyElementTree as aw, getBreakpoints as ax, getElementTreeTranslatableData as ay, mergeElementTreeTranslatedData as az, copy$8 as b, InlineType as b$, getListPageIds as b0, getListTranslatableData as b1, mergeListTranslatedData as b2, Select as b3, Shape as b4, ShapeControlMessageType as b5, ShapeControl as b6, copyShapeData as b7, getShapeElementChildren as b8, getShapeSwatchIds as b9, richTextDTOtoDAO as bA, toSelectionDTO as bB, richTextDAOToDTO as bC, RichTextV2Mode as bD, RichTextV2ControlMessageType as bE, RichTextV2Control as bF, richTextV2DataToDescendents as bG, richTextV2DescendentsToData as bH, createRichTextV2Plugin as bI, unstable_Typography as bJ, getTypographySwatchIds as bK, getTypographyTypographyIds as bL, TypographyActions as bM, TYPOGRAPHY_KEY as bN, withTypography as bO, TypographyPlugin as bP, BlockActions as bQ, ListActions as bR, onKeyDown as bS, withBlock as bT, BlockPlugin as bU, withInlineMode as bV, InlineModePlugin as bW, withTextAlign as bX, TextAlignPlugin as bY, RootBlockType as bZ, BlockType as b_, getShapeTypographyIds as ba, getShapePageIds as bb, getShapeFileIds as bc, getShapeTranslatableData as bd, mergeShapeTranslatedData as be, Slot as bf, SlotControlMessageType as bg, SlotControl as bh, copySlotData as bi, mergeSlotData as bj, mergeSlotControlTranslatedData as bk, Style as bl, StyleControlMessageType as bm, StyleControl as bn, copyStyleData as bo, unstable_useStyleV2ClassName as bp, unstable_StyleV2 as bq, StyleV2ControlMessageType as br, StyleV2Control as bs, TextArea as bt, TextInput as bu, copyRichTextData as bv, ObjectType as bw, RichTextControlMessageType as bx, RichTextControl as by, richTextDTOtoSelection as bz, createDocument as c, BlockTextAlignment as c0, withInline as c1, InlinePlugin as c2, ElementUtils as c3, onChange$1 as c4, getValue$3 as c5, isLinkElement as c6, getInitialState$6 as c7, reducer$7 as c8, getDocument$1 as c9, getComponentsMeta as ca, getComponentPropControllerDescriptors$1 as cb, BuilderEditMode as cc, getDocumentKeysSortedByDepth as cd, getPropController as ce, getPropControllersHandle as cf, getElement as cg, getElementPropControllerDescriptors as ch, createPropController as ci, reducer$6 as cj, reducer$8 as ck, reducer$5 as cl, reducer$4 as cm, reducer$3 as cn, reducer$2 as co, reducer$1 as cp, getInitialState$1 as cq, descriptors as d, copy$e as e, deepEqual as f, createDocumentReference as g, getPropControllerDescriptors as h, introspection as i, isElementReference as j, getSwatchIds as k, getFileIds as l, getTypographyIds as m, getTableIds as n, getPageIds as o, getElementChildren as p, ResponsiveIconRadioGroup as q, Border as r, BorderRadius as s, GapX as t, ResponsiveSelect as u, ResponsiveNumber as v, Checkbox as w, Grid as x, TextInput$1 as y, ResponsiveColor as z };
4740
4914
  //# sourceMappingURL=react-page.es.js.map