[evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Adapt /delete tests and fix found bugs in the new code



commit 372fe8e3012a70324d21b9b2e05d69e6685efd26
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 24 09:58:11 2020 +0100

    test-html-editor-units: Adapt /delete tests and fix found bugs in the new code

 data/webkit/e-editor.js             | 26 +++++++++++++++++++++++++-
 src/e-util/test-html-editor-units.c | 32 ++++++++++++++++----------------
 2 files changed, 41 insertions(+), 17 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index a4d5ce355d..62c80ba83b 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -4620,6 +4620,9 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
 
                if (quote) {
                        content.setAttribute("type", "cite");
+
+                       if (EvoEditor.mode != EvoEditor.MODE_PLAIN_TEXT)
+                               content.setAttribute("style", EvoEditor.BLOCKQUOTE_STYLE);
                }
 
                if (isHTML) {
@@ -4634,10 +4637,31 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                EvoEditor.convertParagraphs(content, quote ? 1 : 0, 
EvoEditor.NORMAL_PARAGRAPH_WIDTH);
                        }
                } else {
-                       content.innerText = text;
+                       var lines = text.split("\n");
+
+                       if (lines.length == 1) {
+                               content.innerText = text;
+                       } else {
+                               var ii;
+
+                               for (ii = 0; ii < lines.length; ii++) {
+                                       var line = lines[ii];
+                                       var divNode = document.createElement("DIV");
+                                       content.appendChild(divNode);
+                                       if (!line.length) {
+                                               divNode.appendChild(document.createElement("BR"));
+                                       } else {
+                                               divNode.innerText = line;
+                                       }
+                               }
+                       }
                }
 
                if (quote) {
+                       if (!isHTML && EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
+                               EvoEditor.convertParagraphs(content, quote ? 1 : 0, 
EvoEditor.NORMAL_PARAGRAPH_WIDTH);
+                       }
+
                        var anchorNode = document.getSelection().anchorNode, intoBody = false;
 
                        if (!content.firstElementChild || (content.firstElementChild.tagName != "DIV" && 
content.firstElementChild.tagName != "P" &&
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index 9983080ee3..277cdd8161 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -5793,14 +5793,14 @@ test_delete_quoted (TestFixture *fixture)
                "undo:test\n"
                "undo:redo:2",
                HTML_PREFIX "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user wrote:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; a</div>"
-               "<div style=\"width: 71ch;\">&gt; b</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "a</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "b</div>"
                "</blockquote>"
                HTML_SUFFIX,
                "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
                "> a\n"
-               "> b"))
+               "> b\n"))
                g_test_fail ();
 }
 
@@ -5824,16 +5824,16 @@ test_delete_after_quoted (TestFixture *fixture)
                E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
 
        if (!test_utils_run_simple_test (fixture,
-               "seq:ddddbb\n",
+               "seq:dddb\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user wrote:</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<pre>&gt; a</pre>"
-               "<pre>&gt; b<br></pre>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "a</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "b</div>"
                "</blockquote>"
                HTML_SUFFIX,
                "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
                "> a\n"
-               "> b"))
+               "> b\n"))
                g_test_fail ();
 }
 
@@ -5853,21 +5853,21 @@ test_delete_quoted_selection (TestFixture *fixture)
                "undo:test\n"
                "undo:redo\n"
                "undo:undo\n"
-               "seq:d\n"
+               "seq:r\n"
                "type:X\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">line 0</div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">"
-               "<div style=\"width: 71ch;\">&gt; line 1</div>"
-               "<div style=\"width: 71ch;\">&gt; <br></div>"
-               "<div style=\"width: 71ch;\">&gt; line 2</div>"
-               "<div style=\"width: 71ch;\">&gt; X</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "X</div>"
                "</blockquote>"
                HTML_SUFFIX,
                "line 0\n"
                "> line 1\n"
                "> \n"
                "> line 2\n"
-               "> X"))
+               "> X\n"))
                g_test_fail ();
 }
 


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