[evolution/wip/mcrha/webkit-jsc-api] e-editor.js: Correct selection placement after Paste Quoted at the end of the document



commit 852c65f14f102401ce191beb87efbe9751d71d2e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 16 14:32:32 2020 +0200

    e-editor.js: Correct selection placement after Paste Quoted at the end of the document
    
    And fix a related exception later in the code.

 data/webkit/e-editor.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index d590a337cc..e85a6dcbb5 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -5040,9 +5040,14 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
 
                                                if (content.nextSibling)
                                                        
document.getSelection().setPosition(content.nextSibling, 0);
-                                               else if (content.lastChild)
-                                                       
document.getSelection().setPosition(content.lastChild, 0);
-                                               else
+                                               else if (content.lastChild) {
+                                                       node = content.lastChild;
+
+                                                       while (node.lastChild)
+                                                               node = node.lastChild;
+
+                                                       document.getSelection().setPosition(node, 
node.nodeType == node.TEXT_NODE ? node.nodeValue.length : 0);
+                                               } else
                                                        document.getSelection().setPosition(content, 0);
 
                                                if (anchorNode.nodeType == anchorNode.ELEMENT_NODE && 
anchorNode.parentElement &&
@@ -5051,7 +5056,7 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                                } else {
                                                        anchorNode = parentBlock.nextSibling.nextSibling;
 
-                                                       if (anchorNode.nodeType == anchorNode.ELEMENT_NODE && 
anchorNode.parentElement &&
+                                                       if (anchorNode && anchorNode.nodeType == 
anchorNode.ELEMENT_NODE && anchorNode.parentElement &&
                                                            EvoEditor.isEmptyParagraph(anchorNode)) {
                                                                anchorNode.remove();
                                                        }


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