浏览代码

fix: remove excess div wrappers (#4528)

* Removing superfluous div wrapping

It seems like standalone text is already wrapped in paragraph elements, so this code seems superfluous. Additionally, it adds div wrappers at every line break as described in #4524

* Fix for newlines and returns

This change skips newlines and returns to focus on unbounded text only.

* misc: fix indentation

* misc: fix indentation (2)

Co-authored-by: Nicolas Giard <github@ngpixel.com>
broxen 3 年之前
父节点
当前提交
12aef93cd6
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      server/modules/rendering/html-core/renderer.js

+ 2 - 2
server/modules/rendering/html-core/renderer.js

@@ -234,11 +234,11 @@ module.exports = {
     })
     })
 
 
     // --------------------------------
     // --------------------------------
-    // Wrap root text nodes
+    // Wrap non-empty root text nodes
     // --------------------------------
     // --------------------------------
 
 
     $('body').contents().toArray().forEach(item => {
     $('body').contents().toArray().forEach(item => {
-      if (item && item.type === 'text' && item.parent.name === 'body') {
+      if (item && item.type === 'text' && item.parent.name === 'body' && item.data !== `\n` && item.data !== `\r`) {
         $(item).wrap('<div></div>')
         $(item).wrap('<div></div>')
       }
       }
     })
     })