Skip to content

Commit e46e271

Browse files
committed
Merge branch 'develop' into fix/annotation-vs-sdt-node-import-check
2 parents 06f0fee + 92a22d1 commit e46e271

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

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

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ function translateList(params) {
815815
* 1. Final doc (keep paragraph field content inside list item)
816816
* 2. Not final doc (keep w:sdt node, process its content)
817817
*/
818-
let nodesToFlatten = [];
819818
if (Array.isArray(outputNode) && params.isFinalDoc) {
820819
const parsedElements = [];
821820
outputNode?.forEach((node, index) => {
@@ -838,16 +837,24 @@ function translateList(params) {
838837
}
839838

840839
/** Case 2: Process w:sdt content */
840+
let nodesToFlatten = [];
841841
const sdtNodes = outputNode.elements?.filter((n) => n.name === 'w:sdt');
842842
if (sdtNodes && sdtNodes.length > 0) {
843843
nodesToFlatten = sdtNodes;
844844
nodesToFlatten?.forEach((sdtNode) => {
845845
const sdtContent = sdtNode.elements.find((n) => n.name === 'w:sdtContent');
846-
if (sdtContent && sdtContent.elements) {
846+
const foundRun = sdtContent.elements?.find((el) => el.name === 'w:r'); // this is a regular text field.
847+
if (sdtContent && sdtContent.elements && !foundRun) {
847848
const parsedElements = [];
848849
sdtContent.elements.forEach((element, index) => {
850+
if (element.name === 'w:rPr' && element.elements?.length) {
851+
parsedElements.push(element);
852+
}
853+
849854
const runs = element.elements?.filter((n) => n.name === 'w:r');
850-
parsedElements.push(...runs);
855+
if (runs && runs.length) {
856+
parsedElements.push(...runs);
857+
}
851858

852859
if (element.name === 'w:p' && index < sdtContent.elements.length - 1) {
853860
parsedElements.push({

0 commit comments

Comments
 (0)