sr-npm 1.7.1263 → 1.7.1264
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.
|
@@ -139,8 +139,10 @@ async function htmlRichContentConverter(sections,richContentConverterToken,jobNa
|
|
|
139
139
|
);
|
|
140
140
|
if (response.ok) {
|
|
141
141
|
const data = await response.json();
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
// Fix list items with nested paragraphs (causes line breaks after bold text)
|
|
143
|
+
const flattenedContent = flattenListItems(data.richContent.richContent);
|
|
144
|
+
// const richContentWithSpacing=addSpacingToRichContent(cleanedHtml,flattenedContent);
|
|
145
|
+
const richContentWithSpacing=addEmptyParagraphsBetweenConsecutive(cleanedHtml,flattenedContent,jobName);
|
|
144
146
|
richContentObject[sectionTitle] = richContentWithSpacing
|
|
145
147
|
}
|
|
146
148
|
else {
|
|
@@ -332,6 +334,42 @@ function createEmptyParagraph(id) {
|
|
|
332
334
|
};
|
|
333
335
|
}
|
|
334
336
|
|
|
337
|
+
// Flattens LIST_ITEM nodes by removing nested PARAGRAPH wrappers
|
|
338
|
+
// Fixes Wix converter bug where bold text + regular text in <li> creates line breaks
|
|
339
|
+
function flattenListItems(richContent) {
|
|
340
|
+
if (!richContent || !richContent.nodes) return richContent;
|
|
341
|
+
|
|
342
|
+
const processNode = (node) => {
|
|
343
|
+
if (node.type === 'BULLETED_LIST' || node.type === 'ORDERED_LIST') {
|
|
344
|
+
return {
|
|
345
|
+
...node,
|
|
346
|
+
nodes: node.nodes.map(listItem => {
|
|
347
|
+
if (listItem.type !== 'LIST_ITEM') return listItem;
|
|
348
|
+
|
|
349
|
+
// Flatten: extract TEXT nodes from nested PARAGRAPHs
|
|
350
|
+
const flattenedChildren = [];
|
|
351
|
+
for (const child of listItem.nodes) {
|
|
352
|
+
if (child.type === 'PARAGRAPH' && child.nodes) {
|
|
353
|
+
// Pull TEXT nodes out of the PARAGRAPH
|
|
354
|
+
flattenedChildren.push(...child.nodes);
|
|
355
|
+
} else {
|
|
356
|
+
flattenedChildren.push(child);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return { ...listItem, nodes: flattenedChildren };
|
|
361
|
+
})
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
return node;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
...richContent,
|
|
369
|
+
nodes: richContent.nodes.map(processNode)
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
335
373
|
// Adds empty paragraph nodes between consecutive paragraphs and before lists
|
|
336
374
|
function addEmptyParagraphsBetweenConsecutive(html, richContent,jobName) {
|
|
337
375
|
console.log("jobName is : ",jobName);
|