Skip to content

Commit 22e1d8c

Browse files
committed
fixes for long html annotation content
1 parent 059babd commit 22e1d8c

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

  • packages/super-editor/src/core/super-converter

packages/super-editor/src/core/super-converter/exporter.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function translateBodyNode(params) {
121121
attributes[`w:${key}`] = convertedValue;
122122
});
123123
sectPrMargins.attributes = attributes;
124-
};
124+
}
125125

126126
const elements = translateChildNodes(params);
127127
return {
@@ -141,7 +141,7 @@ export function translateParagraphNode(params) {
141141

142142
// Replace current paragraph with content of html annotation
143143
const htmlAnnotationChild = elements.find((element) => element.name === 'htmlAnnotation');
144-
if (elements.length === 1 && htmlAnnotationChild) {
144+
if (htmlAnnotationChild) {
145145
return htmlAnnotationChild.elements;
146146
}
147147

@@ -240,7 +240,7 @@ function generateParagraphProperties(node) {
240240
if (textAlign) {
241241
const textAlignElement = {
242242
name: 'w:jc',
243-
attributes: { 'w:val': textAlign },
243+
attributes: { 'w:val': textAlign === 'justify' ? 'both' : textAlign },
244244
};
245245
pPrElements.push(textAlignElement);
246246
}
@@ -351,10 +351,6 @@ function translateChildNodes(params) {
351351
translatedNode = isolateAnnotations(translatedNode);
352352

353353
if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
354-
else if (translatedNode?.name === 'htmlAnnotation') {
355-
// Unwrap html annotation
356-
translatedNodes.push(...translatedNode.elements[0].elements);
357-
}
358354
else translatedNodes.push(translatedNode);
359355
});
360356

@@ -1356,7 +1352,8 @@ function translateMark(mark) {
13561352
case 'fontFamily':
13571353
value = attrs.fontFamily;
13581354
['w:ascii', 'w:eastAsia', 'w:hAnsi', 'w:cs'].forEach((attr) => {
1359-
markElement.attributes[attr] = value;
1355+
const parsedValue = value.split(', ');
1356+
markElement.attributes[attr] = parsedValue[0] ? parsedValue[0] : value;
13601357
});
13611358
break;
13621359

0 commit comments

Comments
 (0)