sr-npm 1.7.1254 → 1.7.1255

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.
@@ -330,12 +330,15 @@ function createEmptyParagraph(id) {
330
330
  };
331
331
  }
332
332
 
333
- // Adds empty paragraph after each paragraph node if HTML contains <p> tags
333
+ // Adds empty paragraph nodes between consecutive paragraphs and before lists
334
334
  function addEmptyParagraphsBetweenConsecutive(html, richContent) {
335
335
  if (!richContent || !richContent.nodes) return richContent;
336
336
 
337
- const hasParagraphs = /<p[^>]*>.*?<\/p>/i.test(html);
338
- if (!hasParagraphs) return richContent;
337
+ const hasConsecutiveParagraphs = /<\/p>\s*<p/i.test(html);
338
+ const hasParagraphBeforeList = /<\/p>\s*<ul/i.test(html);
339
+ const hasParagraphAfterList = /<\/ul>\s*<p/i.test(html);
340
+
341
+ if (!hasConsecutiveParagraphs && !hasParagraphBeforeList && !hasParagraphAfterList) return richContent;
339
342
 
340
343
  const nodes = richContent.nodes;
341
344
  const newNodes = [];
@@ -347,9 +350,20 @@ function addEmptyParagraphsBetweenConsecutive(html, richContent) {
347
350
 
348
351
  newNodes.push(currentNode);
349
352
 
350
- // Add empty paragraph after each paragraph if there's something after it
351
353
  if (currentNode.type === 'PARAGRAPH' && nextNode) {
352
- newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
354
+ // Add empty paragraph between consecutive paragraphs
355
+ if (hasConsecutiveParagraphs && nextNode.type === 'PARAGRAPH') {
356
+ newNodes.push(createEmptyParagraph(`empty_consecutive_${nodeIdCounter++}`));
357
+ }
358
+ // Add empty paragraph before list
359
+ if (hasParagraphBeforeList && nextNode.type === 'BULLETED_LIST') {
360
+ newNodes.push(createEmptyParagraph(`empty_before_list_${nodeIdCounter++}`));
361
+ }
362
+ }
363
+
364
+ // Add empty paragraph after list
365
+ if (hasParagraphAfterList && currentNode.type === 'BULLETED_LIST' && nextNode && nextNode.type === 'PARAGRAPH') {
366
+ newNodes.push(createEmptyParagraph(`empty_after_list_${nodeIdCounter++}`));
353
367
  }
354
368
  }
355
369
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.1254",
3
+ "version": "1.7.1255",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {