@uniformdev/tms-sdk 19.154.1-alpha.26 → 19.154.1-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -16,7 +16,6 @@ type TranslationPayload = {
16
16
  id: string;
17
17
  slug: string | null | undefined;
18
18
  };
19
- overrideModifiedTargetLocale: boolean;
20
19
  };
21
20
  components: {
22
21
  [componentId: string]: ComponentTranslationPayload | undefined;
@@ -36,7 +35,7 @@ type CollectTranslationPayloadResult = {
36
35
  errorKind?: 'unknown' | 'invalid-args' | 'entity-source-locale-missing';
37
36
  errorText?: string;
38
37
  };
39
- declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, overrideModifiedTargetLocale, }: {
38
+ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, }: {
40
39
  uniformProjectId: string;
41
40
  uniformSourceLocale: string;
42
41
  uniformTargetLocale: string;
@@ -44,10 +43,6 @@ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocal
44
43
  targetLang: string;
45
44
  entity: RootComponentInstance | EntryData;
46
45
  entityType: EntityType;
47
- /**
48
- * Ignore modified content in target locales and collect all supported parameters for translation
49
- */
50
- overrideModifiedTargetLocale: boolean;
51
46
  }) => CollectTranslationPayloadResult;
52
47
 
53
48
  declare const getCompositionForTranslation: ({ canvasClient, compositionId, releaseId, state, }: {
@@ -113,16 +108,14 @@ declare const mergeTranslationToUniform: ({ canvasClient, contentClient, transla
113
108
  entityId?: string | undefined;
114
109
  }>;
115
110
 
116
- declare const translateComposition: ({ composition, translationPayload, overrideModifiedTargetLocale, }: {
111
+ declare const translateComposition: ({ composition, translationPayload, }: {
117
112
  composition: CompositionGetResponse;
118
113
  translationPayload: TranslationPayload;
119
- overrideModifiedTargetLocale: boolean;
120
114
  }) => EntityTranslationResult<CompositionGetResponse>;
121
115
 
122
- declare const translateEntry: ({ entry, translationPayload, overrideModifiedTargetLocale, }: {
116
+ declare const translateEntry: ({ entry, translationPayload, }: {
123
117
  entry: Entry;
124
118
  translationPayload: TranslationPayload;
125
- overrideModifiedTargetLocale: boolean;
126
119
  }) => EntityTranslationResult<Entry>;
127
120
 
128
121
  export { type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
package/dist/index.d.ts CHANGED
@@ -16,7 +16,6 @@ type TranslationPayload = {
16
16
  id: string;
17
17
  slug: string | null | undefined;
18
18
  };
19
- overrideModifiedTargetLocale: boolean;
20
19
  };
21
20
  components: {
22
21
  [componentId: string]: ComponentTranslationPayload | undefined;
@@ -36,7 +35,7 @@ type CollectTranslationPayloadResult = {
36
35
  errorKind?: 'unknown' | 'invalid-args' | 'entity-source-locale-missing';
37
36
  errorText?: string;
38
37
  };
39
- declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, overrideModifiedTargetLocale, }: {
38
+ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, }: {
40
39
  uniformProjectId: string;
41
40
  uniformSourceLocale: string;
42
41
  uniformTargetLocale: string;
@@ -44,10 +43,6 @@ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocal
44
43
  targetLang: string;
45
44
  entity: RootComponentInstance | EntryData;
46
45
  entityType: EntityType;
47
- /**
48
- * Ignore modified content in target locales and collect all supported parameters for translation
49
- */
50
- overrideModifiedTargetLocale: boolean;
51
46
  }) => CollectTranslationPayloadResult;
52
47
 
53
48
  declare const getCompositionForTranslation: ({ canvasClient, compositionId, releaseId, state, }: {
@@ -113,16 +108,14 @@ declare const mergeTranslationToUniform: ({ canvasClient, contentClient, transla
113
108
  entityId?: string | undefined;
114
109
  }>;
115
110
 
116
- declare const translateComposition: ({ composition, translationPayload, overrideModifiedTargetLocale, }: {
111
+ declare const translateComposition: ({ composition, translationPayload, }: {
117
112
  composition: CompositionGetResponse;
118
113
  translationPayload: TranslationPayload;
119
- overrideModifiedTargetLocale: boolean;
120
114
  }) => EntityTranslationResult<CompositionGetResponse>;
121
115
 
122
- declare const translateEntry: ({ entry, translationPayload, overrideModifiedTargetLocale, }: {
116
+ declare const translateEntry: ({ entry, translationPayload, }: {
123
117
  entry: Entry;
124
118
  translationPayload: TranslationPayload;
125
- overrideModifiedTargetLocale: boolean;
126
119
  }) => EntityTranslationResult<Entry>;
127
120
 
128
121
  export { type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  bindVariables,
4
4
  walkNodeTree as walkNodeTree2
5
5
  } from "@uniformdev/canvas";
6
- import { isRichTextValue, isRichTextValueConsideredEmpty as isRichTextValueConsideredEmpty2 } from "@uniformdev/richtext";
6
+ import { isRichTextValue as isRichTextValue2, isRichTextValueConsideredEmpty as isRichTextValueConsideredEmpty2 } from "@uniformdev/richtext";
7
7
 
8
8
  // src/constants.ts
9
9
  var TRANSLATION_PAYLOAD_SOURCE_KEY = "source";
@@ -14,12 +14,213 @@ var SUPPORTED_PARAM_TYPES = {
14
14
  richText: "richText"
15
15
  };
16
16
 
17
+ // src/richText/renderAsTranslatableXml.ts
18
+ import { getRichTextTagsFromTextFormat, isRichTextNodeType } from "@uniformdev/richtext";
19
+ var REF_ATTRIBUTE_NAME = "ref";
20
+ function renderAsTranslatableXml(root) {
21
+ if (!root) {
22
+ return null;
23
+ }
24
+ const result = {
25
+ attributes: [],
26
+ xmlParts: []
27
+ };
28
+ renderXmlNode(result, root);
29
+ const metadata = result.attributes.reduce((result2, current, index) => {
30
+ result2[String(index)] = {
31
+ attrs: current
32
+ };
33
+ return result2;
34
+ }, {});
35
+ return {
36
+ metadata,
37
+ xml: result.xmlParts.join("")
38
+ };
39
+ }
40
+ var IGNORE_ATTRS = ["type", "children", "text"];
41
+ function renderXmlNode(context, node) {
42
+ if (!node) {
43
+ return;
44
+ }
45
+ const base64Props = getPropsAsBase64(node, IGNORE_ATTRS);
46
+ let refKey = context.attributes.findIndex((x) => x === base64Props);
47
+ if (refKey == -1) {
48
+ context.attributes.push(base64Props);
49
+ refKey = context.attributes.length - 1;
50
+ }
51
+ context.xmlParts.push(`<${node.type} ${REF_ATTRIBUTE_NAME}="${refKey}"`);
52
+ const metaAttrsString = getNodeMetaAttributesString(node);
53
+ if (metaAttrsString) {
54
+ context.xmlParts.push(" " + metaAttrsString);
55
+ }
56
+ context.xmlParts.push(">");
57
+ if (isRichTextNodeType(node, "text")) {
58
+ context.xmlParts.push(node.text);
59
+ } else if (Array.isArray(node.children) && node.children.length) {
60
+ node.children.forEach((child) => {
61
+ renderXmlNode(context, child);
62
+ });
63
+ }
64
+ context.xmlParts.push(`</${node.type}>`);
65
+ }
66
+ var getPropsAsBase64 = (node, ignoreProps) => {
67
+ const props = {};
68
+ Object.keys(node).forEach((key) => {
69
+ if (!ignoreProps.includes(key)) {
70
+ props[key] = node[key];
71
+ }
72
+ });
73
+ return btoa(JSON.stringify(props));
74
+ };
75
+ var getNodeMetaAttributesString = (node) => {
76
+ const metadata = {};
77
+ if (isRichTextNodeType(node, "text")) {
78
+ const formatTags = getRichTextTagsFromTextFormat(node.format);
79
+ if (formatTags.length) {
80
+ metadata["format"] = formatTags.join(" ");
81
+ }
82
+ } else if (isRichTextNodeType(node, "heading")) {
83
+ if (node.tag) {
84
+ metadata["tag"] = node.tag;
85
+ }
86
+ } else if (isRichTextNodeType(node, "paragraph")) {
87
+ if (node.format) {
88
+ metadata["format"] = node.format;
89
+ }
90
+ } else if (isRichTextNodeType(node, "list")) {
91
+ if (node.tag) {
92
+ metadata["tag"] = node.tag;
93
+ }
94
+ } else if (isRichTextNodeType(node, "listitem")) {
95
+ metadata["value"] = String(node.value);
96
+ }
97
+ if (!Object.keys(metadata).length) {
98
+ return "";
99
+ }
100
+ const result = [];
101
+ Object.entries(metadata).forEach(([key, value]) => {
102
+ result.push(`${key}="${value}"`);
103
+ });
104
+ return result.join(" ");
105
+ };
106
+
17
107
  // src/translationHelpers.ts
18
108
  import {
19
109
  walkNodeTree
20
110
  } from "@uniformdev/canvas";
21
111
  import { isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
22
112
  import { dequal } from "dequal/lite";
113
+
114
+ // src/richText/parseTranslatableXml.ts
115
+ import { isRichTextValue } from "@uniformdev/richtext";
116
+ import { XMLParser } from "fast-xml-parser";
117
+ var ATTR_NAME_PREFIX = "@_";
118
+ var ATTRIBUTES_SUBNODE_NAME = ":@";
119
+ var IGNORE_PROPS_PREFIX = [ATTR_NAME_PREFIX, ATTRIBUTES_SUBNODE_NAME, "#"];
120
+ var parseTranslatableXml = ({ xml, metadata }) => {
121
+ const parser = new XMLParser({
122
+ ignoreDeclaration: true,
123
+ ignorePiTags: true,
124
+ ignoreAttributes: false,
125
+ preserveOrder: true,
126
+ trimValues: false,
127
+ attributeNamePrefix: ATTR_NAME_PREFIX
128
+ });
129
+ const rawObj = parser.parse(xml);
130
+ const result = processParseObject(rawObj, {
131
+ metadata,
132
+ nodeTypes: []
133
+ });
134
+ return result;
135
+ };
136
+ var processParseObject = (rawObj, context) => {
137
+ const result = visitAndTransformNode(rawObj, context);
138
+ const root = Array.isArray(result) ? result.at(0) : result;
139
+ if (root && root.type === "root") {
140
+ const value = { root };
141
+ if (isRichTextValue(value)) {
142
+ return value;
143
+ }
144
+ }
145
+ return null;
146
+ };
147
+ var visitAndTransformNode = (node, context) => {
148
+ if (Array.isArray(node)) {
149
+ return node.map((x) => visitAndTransformNode(x, context)).filter((node2) => !!node2);
150
+ } else if (typeof node === "object" && node !== null) {
151
+ const type = Object.keys(node).find(
152
+ (key) => !IGNORE_PROPS_PREFIX.some((prefix) => key.startsWith(prefix))
153
+ );
154
+ if (!type) {
155
+ return null;
156
+ }
157
+ const transformed = {};
158
+ transformed["type"] = type;
159
+ const propsFromRef = restorePropsFromRef(node, context);
160
+ Object.entries(propsFromRef).forEach(([key, value]) => {
161
+ transformed[key] = value;
162
+ });
163
+ if (type === "text") {
164
+ const nestedNode = node[type];
165
+ const nestedNodeAsArray = Array.isArray(nestedNode) ? nestedNode : [nestedNode];
166
+ const firstChild = nestedNodeAsArray.at(0);
167
+ const text = firstChild == null ? void 0 : firstChild["#text"];
168
+ transformed["text"] = typeof text === "string" && text ? text : "";
169
+ } else {
170
+ const children = [];
171
+ const nestedNode = node[type];
172
+ if (typeof nestedNode === "object" && nestedNode) {
173
+ const nestedNodeAsArray = Array.isArray(nestedNode) ? nestedNode : [nestedNode];
174
+ nestedNodeAsArray.forEach((currNode) => {
175
+ const transformed2 = visitAndTransformNode(currNode, context);
176
+ if (transformed2) {
177
+ children.push(transformed2);
178
+ }
179
+ });
180
+ }
181
+ if (children.length) {
182
+ transformed["children"] = children;
183
+ }
184
+ }
185
+ return transformed;
186
+ } else {
187
+ return node;
188
+ }
189
+ };
190
+ var restorePropsFromRef = (node, context) => {
191
+ const result = {};
192
+ let uniformRef = node[ATTR_NAME_PREFIX + REF_ATTRIBUTE_NAME];
193
+ if (!uniformRef) {
194
+ const attrsSubNode = node[ATTRIBUTES_SUBNODE_NAME];
195
+ uniformRef = attrsSubNode == null ? void 0 : attrsSubNode[ATTR_NAME_PREFIX + REF_ATTRIBUTE_NAME];
196
+ }
197
+ if (typeof uniformRef === "string" && uniformRef && context.metadata[uniformRef]) {
198
+ const metadata = context.metadata[uniformRef];
199
+ if (metadata.attrs) {
200
+ const decodedProps = JSON.parse(atob(metadata.attrs));
201
+ Object.keys(decodedProps).forEach((key) => {
202
+ result[key] = decodedProps[key];
203
+ });
204
+ }
205
+ }
206
+ return result;
207
+ };
208
+
209
+ // src/richText/types.ts
210
+ var isTranslatableRichTextValue = (value) => {
211
+ if (typeof value !== "object" || !value) {
212
+ return false;
213
+ }
214
+ if (!("xml" in value) || typeof value.xml !== "string") {
215
+ return false;
216
+ }
217
+ if (!("metadata" in value) || typeof value.metadata !== "object" || !value.metadata) {
218
+ return false;
219
+ }
220
+ return true;
221
+ };
222
+
223
+ // src/translationHelpers.ts
23
224
  var MERGE_TRANSLATION_ERRORS = {
24
225
  unknown: "Unknown error",
25
226
  "invalid-args": "Invalid arguments",
@@ -33,7 +234,6 @@ var createErrorResult = (errorKind) => {
33
234
  var processComponentTranslation = ({
34
235
  uniformSourceLocale,
35
236
  uniformTargetLocale,
36
- overrideModifiedTargetLocale,
37
237
  originalNode,
38
238
  translatedComponent
39
239
  }) => {
@@ -53,7 +253,6 @@ var processComponentTranslation = ({
53
253
  const result = processParameterTranslation({
54
254
  uniformSourceLocale,
55
255
  uniformTargetLocale,
56
- overrideModifiedTargetLocale,
57
256
  originalParameter,
58
257
  parameter
59
258
  });
@@ -70,7 +269,6 @@ var processComponentTranslation = ({
70
269
  const result = processOverrideTranslation({
71
270
  uniformSourceLocale,
72
271
  uniformTargetLocale,
73
- overrideModifiedTargetLocale,
74
272
  originalOverride,
75
273
  override
76
274
  });
@@ -83,7 +281,6 @@ var processComponentTranslation = ({
83
281
  var processParameterTranslation = ({
84
282
  uniformSourceLocale,
85
283
  uniformTargetLocale,
86
- overrideModifiedTargetLocale,
87
284
  originalParameter,
88
285
  parameter
89
286
  }) => {
@@ -102,50 +299,48 @@ var processParameterTranslation = ({
102
299
  left: originalParameter.locales[uniformSourceLocale],
103
300
  right: sourceValue
104
301
  });
105
- const isTargetValueUntouched = overrideModifiedTargetLocale || isSameParameterValue({
302
+ const isTargetValueUntouched = isSameParameterValue({
106
303
  parameterType: originalParameter.type,
107
304
  left: originalParameter.locales[uniformTargetLocale],
108
305
  right: originalTargetValue
109
306
  });
110
- if (targetValue && isSourceValueUntouched && isTargetValueUntouched) {
111
- originalParameter.locales[uniformTargetLocale] = targetValue;
112
- return { updated: true };
307
+ if (targetValue !== void 0 && isSourceValueUntouched && isTargetValueUntouched) {
308
+ if (parameter.type == SUPPORTED_PARAM_TYPES.richText && isTranslatableRichTextValue(targetValue)) {
309
+ try {
310
+ const richTextValue = parseTranslatableXml(targetValue);
311
+ originalParameter.locales[uniformTargetLocale] = richTextValue;
312
+ return { updated: true };
313
+ } catch (e) {
314
+ return { updated: false };
315
+ }
316
+ } else if (parameter.type == SUPPORTED_PARAM_TYPES.text) {
317
+ originalParameter.locales[uniformTargetLocale] = targetValue;
318
+ return { updated: true };
319
+ }
113
320
  }
114
321
  return { updated: false };
115
322
  };
116
323
  var processOverrideTranslation = ({
117
324
  uniformSourceLocale,
118
325
  uniformTargetLocale,
119
- overrideModifiedTargetLocale,
120
326
  originalOverride,
121
327
  override
122
328
  }) => {
123
329
  var _a, _b;
124
330
  let updated = false;
125
331
  Object.entries((_a = override.parameters) != null ? _a : {}).forEach(([paramKey, parameter]) => {
126
- var _a2, _b2, _c, _d;
332
+ var _a2;
127
333
  const originalParameter = (_a2 = originalOverride.parameters) == null ? void 0 : _a2[paramKey];
128
- if (!originalParameter || !originalParameter.locales) {
129
- return;
130
- }
131
- if (originalParameter.type !== parameter.type) {
334
+ if (!originalParameter) {
132
335
  return;
133
336
  }
134
- const sourceValue = (_b2 = parameter.locales) == null ? void 0 : _b2[TRANSLATION_PAYLOAD_SOURCE_KEY];
135
- const targetValue = (_c = parameter.locales) == null ? void 0 : _c[TRANSLATION_PAYLOAD_TARGET_KEY];
136
- const originalTargetValue = (_d = parameter.locales) == null ? void 0 : _d[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY];
137
- const isSourceValueUntouched = isSameParameterValue({
138
- parameterType: originalParameter.type,
139
- left: originalParameter.locales[uniformSourceLocale],
140
- right: sourceValue
141
- });
142
- const isTargetValueUntouched = overrideModifiedTargetLocale || isSameParameterValue({
143
- parameterType: originalParameter.type,
144
- left: originalParameter.locales[uniformTargetLocale],
145
- right: originalTargetValue
337
+ const result = processParameterTranslation({
338
+ uniformSourceLocale,
339
+ uniformTargetLocale,
340
+ originalParameter,
341
+ parameter
146
342
  });
147
- if (targetValue && isSourceValueUntouched && isTargetValueUntouched) {
148
- originalParameter.locales[uniformTargetLocale] = targetValue;
343
+ if (result.updated) {
149
344
  updated = true;
150
345
  }
151
346
  });
@@ -178,7 +373,6 @@ var processOverrideTranslation = ({
178
373
  const { updated: isComponentUpdated } = processComponentTranslation({
179
374
  uniformSourceLocale,
180
375
  uniformTargetLocale,
181
- overrideModifiedTargetLocale,
182
376
  originalNode: originalComponent,
183
377
  translatedComponent: component
184
378
  });
@@ -200,8 +394,12 @@ var isSameParameterValue = ({
200
394
  return left === right || !left && !right;
201
395
  break;
202
396
  case SUPPORTED_PARAM_TYPES.richText:
203
- if (isRichTextValueConsideredEmpty(left) && isRichTextValueConsideredEmpty(right)) {
204
- return true;
397
+ try {
398
+ if (isRichTextValueConsideredEmpty(left) && isRichTextValueConsideredEmpty(right)) {
399
+ return true;
400
+ }
401
+ } catch (e) {
402
+ return false;
205
403
  }
206
404
  return dequal(left, right);
207
405
  break;
@@ -236,8 +434,7 @@ var collectTranslationPayload = ({
236
434
  uniformReleaseId,
237
435
  targetLang,
238
436
  entity,
239
- entityType,
240
- overrideModifiedTargetLocale
437
+ entityType
241
438
  }) => {
242
439
  if (!uniformSourceLocale || !uniformTargetLocale || !targetLang || !entity) {
243
440
  return createErrorResult2("invalid-args");
@@ -257,8 +454,7 @@ var collectTranslationPayload = ({
257
454
  entity: {
258
455
  id: entity._id,
259
456
  slug: entity._slug || ""
260
- },
261
- overrideModifiedTargetLocale
457
+ }
262
458
  },
263
459
  components: {}
264
460
  };
@@ -270,7 +466,6 @@ var collectTranslationPayload = ({
270
466
  const { _id, type, parameters, _overrides } = collectFromNode({
271
467
  uniformSourceLocale,
272
468
  uniformTargetLocale,
273
- overrideModifiedTargetLocale,
274
469
  node,
275
470
  deep: false
276
471
  });
@@ -288,7 +483,6 @@ var collectTranslationPayload = ({
288
483
  var collectFromNode = ({
289
484
  uniformSourceLocale,
290
485
  uniformTargetLocale,
291
- overrideModifiedTargetLocale,
292
486
  node,
293
487
  deep
294
488
  }) => {
@@ -305,14 +499,14 @@ var collectFromNode = ({
305
499
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
306
500
  return;
307
501
  }
308
- if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
502
+ if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
309
503
  return;
310
504
  }
311
505
  collectedParameters[paramKey] = {
312
506
  type: param.type,
313
507
  locales: {
314
508
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
315
- [TRANSLATION_PAYLOAD_TARGET_KEY]: sourceLocaleValue,
509
+ [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
316
510
  [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
317
511
  }
318
512
  };
@@ -327,7 +521,6 @@ var collectFromNode = ({
327
521
  const collectedNode = collectFromNode({
328
522
  uniformSourceLocale,
329
523
  uniformTargetLocale,
330
- overrideModifiedTargetLocale,
331
524
  node: slotComponent,
332
525
  deep: true
333
526
  });
@@ -348,7 +541,7 @@ var collectFromNode = ({
348
541
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
349
542
  return;
350
543
  }
351
- if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
544
+ if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
352
545
  return;
353
546
  }
354
547
  (_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
@@ -357,7 +550,7 @@ var collectFromNode = ({
357
550
  type: param.type,
358
551
  locales: {
359
552
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
360
- [TRANSLATION_PAYLOAD_TARGET_KEY]: sourceLocaleValue,
553
+ [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
361
554
  [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
362
555
  }
363
556
  };
@@ -371,7 +564,6 @@ var collectFromNode = ({
371
564
  const collectedNode = collectFromNode({
372
565
  uniformSourceLocale,
373
566
  uniformTargetLocale,
374
- overrideModifiedTargetLocale,
375
567
  node: slotComponent,
376
568
  // keep tree structure for `Slot Sections`
377
569
  // to store whole `override` content in scope of current component
@@ -417,7 +609,7 @@ var canTranslateParameterValue = (parameter, value) => {
417
609
  }
418
610
  return true;
419
611
  } else if (parameter.type === SUPPORTED_PARAM_TYPES.richText) {
420
- return isRichTextValue(value) && !isRichTextValueConsideredEmpty2(value);
612
+ return isRichTextValue2(value) && !isRichTextValueConsideredEmpty2(value);
421
613
  }
422
614
  return false;
423
615
  };
@@ -437,6 +629,16 @@ var isTargetLocaleUntouched = (parameterType, sourceLocaleValue, targetLocaleVal
437
629
  right: targetLocaleValue
438
630
  });
439
631
  };
632
+ var preprocessTargetValue = (parameter, value) => {
633
+ if (parameter.type === SUPPORTED_PARAM_TYPES.richText) {
634
+ try {
635
+ return isRichTextValue2(value) ? renderAsTranslatableXml(value.root) : value;
636
+ } catch (e) {
637
+ return value;
638
+ }
639
+ }
640
+ return value;
641
+ };
440
642
 
441
643
  // src/getCompositionForTranslation.ts
442
644
  import { CANVAS_DRAFT_STATE } from "@uniformdev/canvas";
@@ -496,8 +698,7 @@ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, walkNodeTree as walkNodeTree
496
698
  import { produce } from "immer";
497
699
  var translateComposition = ({
498
700
  composition,
499
- translationPayload,
500
- overrideModifiedTargetLocale
701
+ translationPayload
501
702
  }) => {
502
703
  var _a;
503
704
  if (!composition || !composition.composition || !translationPayload) {
@@ -539,7 +740,6 @@ var translateComposition = ({
539
740
  const { updated: isComponentUpdated } = processComponentTranslation({
540
741
  uniformSourceLocale,
541
742
  uniformTargetLocale,
542
- overrideModifiedTargetLocale,
543
743
  originalNode: component,
544
744
  translatedComponent
545
745
  });
@@ -564,7 +764,6 @@ var mergeCompositionTranslationToUniform = async ({
564
764
  }
565
765
  const entityType = translationPayload.metadata.entityType;
566
766
  const entityId = translationPayload.metadata.entity.id;
567
- const overrideModifiedTargetLocale = translationPayload.metadata.overrideModifiedTargetLocale;
568
767
  if (entityType !== "composition" && entityType !== "componentPattern") {
569
768
  return { translationMerged: false, entityId };
570
769
  }
@@ -580,8 +779,7 @@ var mergeCompositionTranslationToUniform = async ({
580
779
  }
581
780
  const translationResult = translateComposition({
582
781
  composition,
583
- translationPayload,
584
- overrideModifiedTargetLocale
782
+ translationPayload
585
783
  });
586
784
  const { updated, errorKind, errorText, result: translatedComposition } = translationResult;
587
785
  if (translatedComposition && updated && !errorKind) {
@@ -626,8 +824,7 @@ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE5, walkNodeTree as walkNodeTree
626
824
  import { produce as produce2 } from "immer";
627
825
  var translateEntry = ({
628
826
  entry,
629
- translationPayload,
630
- overrideModifiedTargetLocale
827
+ translationPayload
631
828
  }) => {
632
829
  var _a;
633
830
  if (!entry || !translationPayload) {
@@ -669,7 +866,6 @@ var translateEntry = ({
669
866
  const { updated: isComponentUpdated } = processComponentTranslation({
670
867
  uniformSourceLocale,
671
868
  uniformTargetLocale,
672
- overrideModifiedTargetLocale,
673
869
  originalNode: component,
674
870
  translatedComponent
675
871
  });
@@ -694,7 +890,6 @@ var mergeEntryTranslationToUniform = async ({
694
890
  }
695
891
  const entityType = translationPayload.metadata.entityType;
696
892
  const entityId = translationPayload.metadata.entity.id;
697
- const overrideModifiedTargetLocale = translationPayload.metadata.overrideModifiedTargetLocale;
698
893
  if (entityType !== "entry" && entityType !== "entryPattern") {
699
894
  return { translationMerged: false, entityId };
700
895
  }
@@ -710,8 +905,7 @@ var mergeEntryTranslationToUniform = async ({
710
905
  }
711
906
  const translationResult = translateEntry({
712
907
  entry,
713
- translationPayload,
714
- overrideModifiedTargetLocale
908
+ translationPayload
715
909
  });
716
910
  const { updated, errorKind, errorText, result: translatedEntry } = translationResult;
717
911
  if (translatedEntry && updated && !errorKind) {