[evolution] I#1657 - Composer: Correct empty paragraph detection for removal



commit c61022b00480ba0fe04084d5dd4a17fb98f484c1
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 12 16:13:45 2021 +0200

    I#1657 - Composer: Correct empty paragraph detection for removal
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1657

 data/webkit/e-editor.js | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 9c585c0241..b643f41548 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -3197,6 +3197,16 @@ EvoEditor.maybeRemoveQuotationMark = function(node)
        return true;
 }
 
+EvoEditor.isQuotedElementEmpty = function(node)
+{
+       for (node = node.firstChild; node !== null; node = node.nextSibling) {
+               // the text inside is not empty
+               if (node.nodeType == node.TEXT_NODE && node.nodeValue !== null && node.nodeValue !== "")
+                       return false;
+       }
+       return true;
+}
+
 EvoEditor.removeEmptyElements = function(tagName)
 {
        var nodes, node, ii, didRemove = 0;
@@ -3215,9 +3225,7 @@ EvoEditor.removeEmptyElements = function(tagName)
                    node.firstElementChild.className != "-x-evo-quoted"))
                        continue;
 
-               // the text inside is not empty, possibly on either of the two sides of the quotation mark
-               if ((node.firstChild && (node.firstChild.nodeType == node.TEXT_NODE && 
node.firstChild.nodeValue)) ||
-                   (node.lastChild && !(node.lastChild === node.firstChild) && (node.lastChild.nodeType == 
node.TEXT_NODE && node.lastChild.nodeValue)))
+               if (!EvoEditor.isQuotedElementEmpty(node))
                        continue;
 
                // it's either completely empty or it contains only the quotation mark and nothing else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]