@makeswift/runtime 0.11.2 → 0.11.3

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 +2 -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
package/dist/main.cjs.js CHANGED
@@ -12,12 +12,14 @@ require("corporate-ipsum");
12
12
  require("slate");
13
13
  require("uuid");
14
14
  require("escape-html");
15
+ require("slate-hyperscript");
16
+ require("parse5");
17
+ require("is-hotkey");
18
+ require("react/jsx-runtime");
15
19
  require("react");
16
20
  require("@emotion/css");
17
21
  require("@emotion/serialize");
18
22
  require("@emotion/utils");
19
- require("react/jsx-runtime");
20
- require("is-hotkey");
21
23
  exports.ActionTypes = actions.ActionTypes;
22
24
  exports.builderPointerMove = actions.builderPointerMove;
23
25
  exports.changeApiResource = actions.changeApiResource;
@@ -1 +1 @@
1
- {"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/main.es.js CHANGED
@@ -10,10 +10,12 @@ import "corporate-ipsum";
10
10
  import "slate";
11
11
  import "uuid";
12
12
  import "escape-html";
13
+ import "slate-hyperscript";
14
+ import "parse5";
15
+ import "is-hotkey";
16
+ import "react/jsx-runtime";
13
17
  import "react";
14
18
  import "@emotion/css";
15
19
  import "@emotion/serialize";
16
20
  import "@emotion/utils";
17
- import "react/jsx-runtime";
18
- import "is-hotkey";
19
21
  //# sourceMappingURL=main.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
package/dist/next.cjs.js CHANGED
@@ -16,10 +16,12 @@ require("corporate-ipsum");
16
16
  require("slate");
17
17
  require("uuid");
18
18
  require("escape-html");
19
+ require("slate-hyperscript");
20
+ require("parse5");
21
+ require("is-hotkey");
19
22
  require("@emotion/css");
20
23
  require("@emotion/serialize");
21
24
  require("@emotion/utils");
22
- require("is-hotkey");
23
25
  require("./number.cjs.js");
24
26
  require("./combobox.cjs.js");
25
27
  require("use-sync-external-store/shim");
@@ -1 +1 @@
1
- {"version":3,"file":"next.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"next.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/next.es.js CHANGED
@@ -14,10 +14,12 @@ import "corporate-ipsum";
14
14
  import "slate";
15
15
  import "uuid";
16
16
  import "escape-html";
17
+ import "slate-hyperscript";
18
+ import "parse5";
19
+ import "is-hotkey";
17
20
  import "@emotion/css";
18
21
  import "@emotion/serialize";
19
22
  import "@emotion/utils";
20
- import "is-hotkey";
21
23
  import "./number.es.js";
22
24
  import "./combobox.es.js";
23
25
  import "use-sync-external-store/shim";
@@ -1 +1 @@
1
- {"version":3,"file":"next.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"next.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -11,12 +11,14 @@ require("corporate-ipsum");
11
11
  require("slate");
12
12
  require("uuid");
13
13
  require("escape-html");
14
+ require("slate-hyperscript");
15
+ require("parse5");
16
+ require("is-hotkey");
17
+ require("react/jsx-runtime");
14
18
  require("react");
15
19
  require("@emotion/css");
16
20
  require("@emotion/serialize");
17
21
  require("@emotion/utils");
18
- require("react/jsx-runtime");
19
- require("is-hotkey");
20
22
  exports.Introspection = reactPage.introspection;
21
23
  exports.Props = reactPage.descriptors;
22
24
  exports.RichTextPropControllerMessageType = reactPage.RichTextPropControllerMessageType;
@@ -1 +1 @@
1
- {"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"prop-controllers.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,10 +9,12 @@ import "corporate-ipsum";
9
9
  import "slate";
10
10
  import "uuid";
11
11
  import "escape-html";
12
+ import "slate-hyperscript";
13
+ import "parse5";
14
+ import "is-hotkey";
15
+ import "react/jsx-runtime";
12
16
  import "react";
13
17
  import "@emotion/css";
14
18
  import "@emotion/serialize";
15
19
  import "@emotion/utils";
16
- import "react/jsx-runtime";
17
- import "is-hotkey";
18
20
  //# sourceMappingURL=prop-controllers.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"prop-controllers.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -44,20 +44,22 @@ var ipsum = require("corporate-ipsum");
44
44
  var slate = require("slate");
45
45
  var uuid = require("uuid");
46
46
  var escapeHtml = require("escape-html");
47
+ var slateHyperscript = require("slate-hyperscript");
48
+ var parse5 = require("parse5");
49
+ var isHotkey = require("is-hotkey");
50
+ var jsxRuntime = require("react/jsx-runtime");
47
51
  var React = require("react");
48
52
  var css = require("@emotion/css");
49
53
  var serialize = require("@emotion/serialize");
50
54
  var utils = require("@emotion/utils");
51
- var jsxRuntime = require("react/jsx-runtime");
52
- var isHotkey = require("is-hotkey");
53
55
  function _interopDefaultLegacy(e) {
54
56
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
55
57
  }
56
58
  var thunk__default = /* @__PURE__ */ _interopDefaultLegacy(thunk);
57
59
  var ipsum__default = /* @__PURE__ */ _interopDefaultLegacy(ipsum);
58
60
  var escapeHtml__default = /* @__PURE__ */ _interopDefaultLegacy(escapeHtml);
59
- var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
60
61
  var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
62
+ var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
61
63
  const ComponentIcon = {
62
64
  Billing: "billing",
63
65
  Bolt: "bolt",
@@ -573,6 +575,11 @@ function GapY(options = {}) {
573
575
  function Grid(options = {}) {
574
576
  return { type: Types.Grid, options };
575
577
  }
578
+ function mergeGridPropControllerTranslatedData(data, context) {
579
+ return __spreadProps(__spreadValues({}, data), {
580
+ elements: data.elements.map((element) => context.mergeTranslatedData(element))
581
+ });
582
+ }
576
583
  function Image$1(options = {}) {
577
584
  return { type: Types.Image, version: 1, options };
578
585
  }
@@ -726,6 +733,7 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
726
733
  GapX,
727
734
  GapY,
728
735
  Grid,
736
+ mergeGridPropControllerTranslatedData,
729
737
  Image: Image$1,
730
738
  Images,
731
739
  Link: Link$1,
@@ -1063,6 +1071,13 @@ function getListPageIds(definition2, value) {
1063
1071
  function getListTranslatableData(definition2, data) {
1064
1072
  return Object.fromEntries(data.map((item) => [item.id, getTranslatableData(definition2.config.type, item.value)]));
1065
1073
  }
1074
+ function mergeListTranslatedData(definition2, data, translatedData, context) {
1075
+ return data.map((item) => {
1076
+ return __spreadProps(__spreadValues({}, item), {
1077
+ value: mergeTranslatedData(definition2.config.type, item.value, translatedData[item.id], context)
1078
+ });
1079
+ });
1080
+ }
1066
1081
  const ShapeControlType = "makeswift::controls::shape";
1067
1082
  function Shape(config) {
1068
1083
  return { type: ShapeControlType, config };
@@ -1142,6 +1157,12 @@ function getShapeTranslatableData(definition2, data) {
1142
1157
  getTranslatableData(definition22, data[key])
1143
1158
  ]));
1144
1159
  }
1160
+ function mergeShapeTranslatedData(definition2, data, translatedData, context) {
1161
+ return Object.fromEntries(Object.entries(definition2.config.type).map(([key, definition22]) => [
1162
+ key,
1163
+ mergeTranslatedData(definition22, data.key, translatedData[key], context)
1164
+ ]));
1165
+ }
1145
1166
  const TextAreaControlType = "makeswift::controls::text-area";
1146
1167
  function TextArea(config = {}) {
1147
1168
  return { type: TextAreaControlType, config };
@@ -1194,6 +1215,11 @@ function mergeSlotData(base = { columns: [], elements: [] }, override = { column
1194
1215
  });
1195
1216
  return { columns: mergedColumns, elements: mergedElements };
1196
1217
  }
1218
+ function mergeSlotControlTranslatedData(data, context) {
1219
+ return __spreadProps(__spreadValues({}, data), {
1220
+ elements: data.elements.map((element) => context.mergeTranslatedData(element))
1221
+ });
1222
+ }
1197
1223
  function copy$e(descriptor, value, context) {
1198
1224
  if (value == null)
1199
1225
  return value;
@@ -2374,7 +2400,7 @@ const ElementUtils = {
2374
2400
  return slate.Element.isElement(node) && (this.isRootBlock(node) || slate.Element.isElementType(node, BlockType.ListItem) || slate.Element.isElementType(node, BlockType.ListItemChild));
2375
2401
  },
2376
2402
  isInline(node) {
2377
- return slate.Element.isElementType(node, InlineType.Code) || slate.Element.isElementType(node, InlineType.Link) || slate.Element.isElementType(node, InlineType.SubScript) || slate.Element.isElementType(node, InlineType.SuperScript);
2403
+ return slate.Element.isElement(node) && (slate.Element.isElementType(node, InlineType.Code) || slate.Element.isElementType(node, InlineType.Link) || slate.Element.isElementType(node, InlineType.SubScript) || slate.Element.isElementType(node, InlineType.SuperScript));
2378
2404
  },
2379
2405
  isConvertibleToListTextNode(node) {
2380
2406
  return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
@@ -3949,40 +3975,132 @@ function copyRichTextV2Data(data, context) {
3949
3975
  });
3950
3976
  }
3951
3977
  }
3952
- function hashTranslationString(s) {
3953
- let hash = 0;
3954
- for (let i = 0, len = s.length; i < len; i++) {
3955
- let chr = s.charCodeAt(i);
3956
- hash = (hash << 5) - hash + chr;
3957
- hash |= 0;
3978
+ function pathToString(path) {
3979
+ return path.join(":");
3980
+ }
3981
+ function stringToPath(s) {
3982
+ return s.split(":").map((a) => parseInt(a));
3983
+ }
3984
+ function getDescendantTranslatableData(descendant, path) {
3985
+ if (slate.Text.isText(descendant)) {
3986
+ return {};
3987
+ }
3988
+ switch (descendant.type) {
3989
+ case BlockType.UnorderedList:
3990
+ case BlockType.OrderedList:
3991
+ case BlockType.ListItem:
3992
+ return descendant.children.reduce((acc, d, j) => __spreadValues(__spreadValues({}, acc), getDescendantTranslatableData(d, [...path, j])), {});
3993
+ default:
3994
+ const text = getInlineOrTextTranslatableData(descendant);
3995
+ if (text == null)
3996
+ return {};
3997
+ return { [pathToString(path)]: text };
3958
3998
  }
3959
- return hash.toString();
3960
3999
  }
3961
- function getRichTextV2TranslatableDescendant(definition2, descendant) {
4000
+ function getInlineOrTextTranslatableData(descendant, path = []) {
3962
4001
  if (slate.Text.isText(descendant)) {
3963
4002
  let string = escapeHtml__default["default"](descendant.text);
3964
- return string;
4003
+ if (string === "")
4004
+ return null;
4005
+ return `<span key="${pathToString(path)}">${string}</span>`;
3965
4006
  }
3966
- const children = descendant.children.map((child) => getRichTextV2TranslatableDescendant(definition2, child)).join("");
4007
+ const children = descendant.children.map((child, i) => getInlineOrTextTranslatableData(child, [...path, i])).join("");
4008
+ if (children === "")
4009
+ return null;
3967
4010
  switch (descendant.type) {
3968
4011
  case InlineType.Link:
3969
- return `<a>${children}</a>`;
3970
- case InlineType.Link:
3971
- return `<sup>${children}</sup>`;
3972
- case InlineType.Link:
3973
- return `<sub>${children}</sub>`;
3974
- case InlineType.Link:
3975
- return `<code>${children}</code>`;
4012
+ return `<a key="${pathToString(path)}">${children}</a>`;
4013
+ case InlineType.SuperScript:
4014
+ return `<sup key="${pathToString(path)}">${children}</sup>`;
4015
+ case InlineType.SubScript:
4016
+ return `<sub key="${pathToString(path)}">${children}</sub>`;
4017
+ case InlineType.Code:
4018
+ return `<code key="${pathToString(path)}">${children}</code>`;
3976
4019
  default:
3977
4020
  return children;
3978
4021
  }
3979
4022
  }
3980
- function getRichTextV2TranslatableData(definition2, data) {
3981
- return data.descendants.reduce((acc, descendant) => {
3982
- const value = getRichTextV2TranslatableDescendant(definition2, descendant);
3983
- const key = hashTranslationString(value);
3984
- return __spreadProps(__spreadValues({}, acc), { [key]: value });
3985
- }, {});
4023
+ function getRichTextV2TranslatableData(data) {
4024
+ return data.descendants.reduce((acc, descendant, i) => __spreadValues(__spreadValues({}, acc), getDescendantTranslatableData(descendant, [i])), {});
4025
+ }
4026
+ function deserializeTranslationHtmlString(el, translationKey) {
4027
+ var _a, _b;
4028
+ if (el.nodeName === "#document-fragment") {
4029
+ const children = Array.from(el.childNodes).map((element) => deserializeTranslationHtmlString(element)).flat();
4030
+ if (children.length === 0) {
4031
+ children.push(slateHyperscript.jsx("text", {}, ""));
4032
+ }
4033
+ return children;
4034
+ } else if (el.nodeName === "#text" && "value" in el) {
4035
+ return [slateHyperscript.jsx("text", { translationKey: translationKey != null ? translationKey : void 0 }, el.value)];
4036
+ } else if ("namespaceURI" in el) {
4037
+ const translationKey2 = (_b = (_a = el.attrs.find((a) => a.name === "key")) == null ? void 0 : _a.value) != null ? _b : void 0;
4038
+ const children = Array.from(el.childNodes).map((element) => deserializeTranslationHtmlString(element, translationKey2)).flat();
4039
+ if (children.length === 0) {
4040
+ children.push(slateHyperscript.jsx("text", {}, ""));
4041
+ }
4042
+ switch (el.nodeName) {
4043
+ case "code":
4044
+ return [slateHyperscript.jsx("element", { type: InlineType.Code, translationKey: translationKey2 }, children)];
4045
+ case "sub":
4046
+ return [slateHyperscript.jsx("element", { type: InlineType.SubScript, translationKey: translationKey2 }, children)];
4047
+ case "sup":
4048
+ return [slateHyperscript.jsx("element", { type: InlineType.SuperScript, translationKey: translationKey2 }, children)];
4049
+ case "a":
4050
+ return [slateHyperscript.jsx("element", { type: InlineType.Link, translationKey: translationKey2 }, children)];
4051
+ default:
4052
+ return children;
4053
+ }
4054
+ }
4055
+ return [];
4056
+ }
4057
+ function mergeRichTextV2TranslatedData(definition2, data, translatedData) {
4058
+ var _a;
4059
+ const plugins = ((_a = definition2 == null ? void 0 : definition2.config) == null ? void 0 : _a.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin()];
4060
+ const sourceEditor = plugins.reduceRight((editor, plugin) => {
4061
+ var _a2, _b;
4062
+ return (_b = (_a2 = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a2.call(plugin, editor)) != null ? _b : editor;
4063
+ }, slate.createEditor());
4064
+ const targetEditor = plugins.reduceRight((editor, plugin) => {
4065
+ var _a2, _b;
4066
+ return (_b = (_a2 = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a2.call(plugin, editor)) != null ? _b : editor;
4067
+ }, slate.createEditor());
4068
+ sourceEditor.children = data.descendants;
4069
+ Object.entries(translatedData).reverse().forEach(([blockStringPath, htmlString]) => {
4070
+ var _c2;
4071
+ const blockPath = stringToPath(blockStringPath);
4072
+ if (blockPath.length === 0)
4073
+ return;
4074
+ const html = parse5.parseFragment(htmlString);
4075
+ const inlineDescendants = deserializeTranslationHtmlString(html);
4076
+ targetEditor.children = [{ type: BlockType.Default, children: inlineDescendants }];
4077
+ slate.Editor.normalize(targetEditor, { force: true });
4078
+ for (const [descendant, absolutePathToTargetNode] of slate.Node.descendants(targetEditor)) {
4079
+ if (!slate.Text.isText(descendant) && !ElementUtils.isInline(descendant) || descendant.translationKey == null || descendant.translationKey === "") {
4080
+ continue;
4081
+ }
4082
+ const relativePathToSourceNode = stringToPath(descendant.translationKey);
4083
+ const absolutePathToSourceNode = [...blockPath, ...relativePathToSourceNode];
4084
+ const [sourceNode] = slate.Editor.node(sourceEditor, absolutePathToSourceNode);
4085
+ if (slate.Text.isText(sourceNode) && slate.Text.isText(descendant)) {
4086
+ const _a2 = sourceNode, { translationKey, text } = _a2, rest = __objRest(_a2, ["translationKey", "text"]);
4087
+ slate.Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode });
4088
+ slate.Transforms.unsetNodes(targetEditor, "translationKey", { at: absolutePathToTargetNode });
4089
+ } else if (ElementUtils.isInline(sourceNode) && ElementUtils.isInline(descendant)) {
4090
+ const _b = sourceNode, { translationKey, children } = _b, rest = __objRest(_b, ["translationKey", "children"]);
4091
+ slate.Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode });
4092
+ slate.Transforms.unsetNodes(targetEditor, "translationKey", { at: absolutePathToTargetNode });
4093
+ }
4094
+ }
4095
+ const translatedChildren = (_c2 = targetEditor.children.at(0)) == null ? void 0 : _c2.children;
4096
+ slate.Editor.withoutNormalizing(sourceEditor, () => {
4097
+ Array.from(slate.Node.children(sourceEditor, blockPath)).reverse().forEach(([_, path]) => {
4098
+ slate.Transforms.removeNodes(sourceEditor, { at: path });
4099
+ });
4100
+ slate.Transforms.insertNodes(sourceEditor, translatedChildren, { at: [...blockPath, 0] });
4101
+ });
4102
+ });
4103
+ return __spreadProps(__spreadValues({}, data), { descendants: sourceEditor.children });
3986
4104
  }
3987
4105
  function copy(definition2, value, context) {
3988
4106
  switch (definition2.type) {
@@ -4038,7 +4156,10 @@ function getTranslatableData(definition2, data) {
4038
4156
  case TextAreaControlType:
4039
4157
  return data;
4040
4158
  case RichTextV2ControlType:
4041
- return getRichTextV2TranslatableData(definition2, data);
4159
+ const richTextData = data;
4160
+ if (isRichTextV1Data(richTextData))
4161
+ return null;
4162
+ return getRichTextV2TranslatableData(richTextData);
4042
4163
  case ListControlType:
4043
4164
  return getListTranslatableData(definition2, data);
4044
4165
  case ShapeControlType:
@@ -4047,6 +4168,35 @@ function getTranslatableData(definition2, data) {
4047
4168
  return null;
4048
4169
  }
4049
4170
  }
4171
+ function mergeTranslatedData(definition2, data, translatedData, context) {
4172
+ switch (definition2.type) {
4173
+ case Types.TextInput:
4174
+ case Types.TextArea:
4175
+ case TextInputControlType:
4176
+ case TextAreaControlType:
4177
+ if (translatedData == null)
4178
+ return data;
4179
+ return translatedData;
4180
+ case Types.Grid:
4181
+ return mergeGridPropControllerTranslatedData(data, context);
4182
+ case SlotControlType:
4183
+ return mergeSlotControlTranslatedData(data, context);
4184
+ case RichTextV2ControlType:
4185
+ if (translatedData == null)
4186
+ return data;
4187
+ return mergeRichTextV2TranslatedData(definition2, data, translatedData);
4188
+ case ListControlType:
4189
+ if (translatedData == null)
4190
+ return data;
4191
+ return mergeListTranslatedData(definition2, data, translatedData, context);
4192
+ case ShapeControlType:
4193
+ if (translatedData == null)
4194
+ return data;
4195
+ return mergeShapeTranslatedData(definition2, data, translatedData, context);
4196
+ default:
4197
+ return data;
4198
+ }
4199
+ }
4050
4200
  const StyleV2ControlType = "makeswift::controls::style-v2";
4051
4201
  const unstable_useStyleV2ClassName = useStyle;
4052
4202
  function unstable_StyleV2(config) {
@@ -4722,6 +4872,30 @@ function getElementTreeTranslatableData(state, elementTree) {
4722
4872
  }
4723
4873
  return translatableData;
4724
4874
  }
4875
+ function mergeElementTreeTranslatedData(state, elementTree, translatedData) {
4876
+ function merge2(state2, translatedData2) {
4877
+ return function(node) {
4878
+ if (isElementReference(node))
4879
+ return node;
4880
+ const elementDescriptors = getPropControllerDescriptors(state2);
4881
+ const descriptors2 = elementDescriptors.get(node.type);
4882
+ if (descriptors2 == null) {
4883
+ throw new Error(`Can't merge element of type "${node.type}" because it has no descriptors`);
4884
+ }
4885
+ const context = {
4886
+ translatedData: translatedData2,
4887
+ mergeTranslatedData: merge2(state2, translatedData2)
4888
+ };
4889
+ const props = {};
4890
+ for (const propName of Object.keys(descriptors2)) {
4891
+ const descriptor = descriptors2[propName];
4892
+ props[propName] = mergeTranslatedData(descriptor, node.props[propName], translatedData2[`${node.key}:${propName}`], context);
4893
+ }
4894
+ return __spreadProps(__spreadValues({}, node), { props });
4895
+ };
4896
+ }
4897
+ return merge2(state, translatedData)(elementTree);
4898
+ }
4725
4899
  function getIsInBuilder(state) {
4726
4900
  return state.isInBuilder;
4727
4901
  }
@@ -4920,7 +5094,12 @@ exports.isNonNullable = isNonNullable;
4920
5094
  exports.isPropControllersHandle = isPropControllersHandle;
4921
5095
  exports.isRichTextV1Data = isRichTextV1Data;
4922
5096
  exports.merge = merge;
5097
+ exports.mergeElementTreeTranslatedData = mergeElementTreeTranslatedData;
5098
+ exports.mergeListTranslatedData = mergeListTranslatedData;
5099
+ exports.mergeShapeTranslatedData = mergeShapeTranslatedData;
5100
+ exports.mergeSlotControlTranslatedData = mergeSlotControlTranslatedData;
4923
5101
  exports.mergeSlotData = mergeSlotData;
5102
+ exports.mergeTranslatedData = mergeTranslatedData;
4924
5103
  exports.onChange = onChange$1;
4925
5104
  exports.onKeyDown = onKeyDown;
4926
5105
  exports.reducer = reducer$7;