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



commit cafd419d4184aa233a5023d77d84aea33d64523e
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 24 15:44:48 2020 +0100

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

 data/webkit/e-editor.js                     | 122 ++++++++++++++++++++++++--
 src/e-util/test-html-editor-units-bugs.c    |   4 -
 src/e-util/test-html-editor-units.c         | 128 +++++++++++-----------------
 src/modules/webkit-editor/e-webkit-editor.c |   4 +-
 4 files changed, 168 insertions(+), 90 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 62c80ba83b..3337a965e3 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -1529,11 +1529,78 @@ EvoEditor.Indent = function(increment)
        }
 }
 
+EvoEditor.applyDivNormalize = function(record, isUndo)
+{
+       var element = EvoSelection.FindElementByPath(document.body, record.path);
+
+       if (!element)
+               throw "EvoEditor.applyDivNormalize: Path not found";
+
+       var value;
+
+       if (isUndo)
+               value = record.beforeValue;
+       else
+               value = record.afterValue;
+
+       if (record.isWidthStyle) {
+               element.style.width = value;
+               EvoEditor.removeEmptyStyleAttribute(element);
+       } else {
+               element.innerHTML = value;
+       }
+}
+
 EvoEditor.InsertHTML = function(opType, html)
 {
-       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_GROUP, opType, null, null, 
EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE | EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
+       EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_GROUP, opType);
        try {
                document.execCommand("insertHTML", false, html);
+
+               var node, list, ii;
+
+               list = document.body.getElementsByTagName("DIV");
+
+               for (ii = 0; ii < list.length; ii++) {
+                       var node = list[ii], beforeValue;
+
+                       if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
+                               beforeValue = node.style.width;
+                               EvoEditor.maybeUpdateParagraphWidth(node);
+
+                               if (node.style.width != beforeValue) {
+                                       var record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, 
opType + "::divWidths", node, node, EvoEditor.CLAIM_CONTENT_FLAG_NONE);
+                                       try {
+                                               if (record) {
+                                                       record.path = 
EvoSelection.GetChildPath(document.body, node);
+                                                       record.beforeValue = beforeValue;
+                                                       record.afterValue = node.style.width;
+                                                       record.isWidthStyle = true;
+                                                       record.apply = EvoEditor.applyDivNormalize;
+                                               }
+                                       } finally {
+                                               EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, opType 
+ "::divWidths");
+                                       }
+                               }
+                       }
+
+                       if (!node.firstChild) {
+                               var record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, opType + 
"::divBR", node, node, EvoEditor.CLAIM_CONTENT_FLAG_NONE);
+                               try {
+                                       beforeValue = node.innerHTML;
+                                       node.appendChild(document.createElement("BR"));
+
+                                       if (record) {
+                                               record.path = EvoSelection.GetChildPath(document.body, node);
+                                               record.beforeValue = beforeValue;
+                                               record.afterValue = node.innerHTML;
+                                               record.apply = EvoEditor.applyDivNormalize;
+                                       }
+                               } finally {
+                                       EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, opType + 
"::divBR");
+                               }
+                       }
+               }
        } finally {
                EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_GROUP, opType);
                EvoEditor.maybeUpdateFormattingState(EvoEditor.FORCE_MAYBE);
@@ -2280,8 +2347,7 @@ EvoEditor.SetFontName = function(name)
        // to workaround https://bugs.webkit.org/show_bug.cgi?id=204622
        bodyFontFamily = document.body.style.fontFamily;
 
-       record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_GROUP, "SetFontName", null, null,
-               EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE | EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
+       record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_GROUP, "SetFontName");
        try {
                if (!document.getSelection().isCollapsed && bodyFontFamily)
                        document.body.style.fontFamily = "";
@@ -4633,8 +4699,37 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                content.removeChild(content.firstElementChild);
                        }
 
+                       // convert P into DIV
+                       var node = content.firstChild, next;
+
+                       while (node) {
+                               var removeNode = false;
+
+                               if (node.nodeType == node.ELEMENT_NODE && node.tagName == "P") {
+                                       removeNode = true;
+
+                                       if (node.tagName == "P") {
+                                               var div = document.createElement("DIV");
+                                               EvoEditor.moveNodeContent(node, div);
+                                               node.parentElement.insertBefore(div, node.nextSibling);
+                                       } else {
+                                               EvoEditor.moveNodeContent(node);
+                                       }
+                               }
+
+                               next = EvoEditor.getNextNodeInHierarchy(node, content);
+
+                               if (removeNode)
+                                       node.parentElement.removeChild(node);
+
+                               node = next;
+                       }
+
                        if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
                                EvoEditor.convertParagraphs(content, quote ? 1 : 0, 
EvoEditor.NORMAL_PARAGRAPH_WIDTH);
+                               content.innerText = EvoConvert.ToPlainText(content, 
EvoEditor.NORMAL_PARAGRAPH_WIDTH);
+                       } else {
+                               EvoEditor.convertParagraphs(content, quote ? 1 : 0, -1);
                        }
                } else {
                        var lines = text.split("\n");
@@ -4645,9 +4740,10 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                var ii;
 
                                for (ii = 0; ii < lines.length; ii++) {
-                                       var line = lines[ii];
-                                       var divNode = document.createElement("DIV");
+                                       var line = lines[ii], divNode = document.createElement("DIV");
+
                                        content.appendChild(divNode);
+
                                        if (!line.length) {
                                                divNode.appendChild(document.createElement("BR"));
                                        } else {
@@ -4658,9 +4754,8 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                }
 
                if (quote) {
-                       if (!isHTML && EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT) {
-                               EvoEditor.convertParagraphs(content, quote ? 1 : 0, 
EvoEditor.NORMAL_PARAGRAPH_WIDTH);
-                       }
+                       if (!isHTML)
+                               EvoEditor.convertParagraphs(content, quote ? 1 : 0, EvoEditor.mode == 
EvoEditor.MODE_PLAIN_TEXT ? EvoEditor.NORMAL_PARAGRAPH_WIDTH : -1);
 
                        var anchorNode = document.getSelection().anchorNode, intoBody = false;
 
@@ -4760,6 +4855,14 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                                    (anchorNode.tagName == "DIV" || anchorNode.tagName == "P" 
|| anchorNode.tagName == "PRE") &&
                                                    (!anchorNode.children.length || 
(anchorNode.children.length == 1 && anchorNode.children[0].tagName == "BR"))) {
                                                        anchorNode.parentElement.removeChild(anchorNode);
+                                               } else {
+                                                       anchorNode = parentBlock.nextSibling.nextSibling;
+
+                                                       if (anchorNode.nodeType == anchorNode.ELEMENT_NODE && 
anchorNode.parentElement &&
+                                                           (anchorNode.tagName == "DIV" || 
anchorNode.tagName == "P" || anchorNode.tagName == "PRE") &&
+                                                           (!anchorNode.children.length || 
(anchorNode.children.length == 1 && anchorNode.children[0].tagName == "BR"))) {
+                                                               
anchorNode.parentElement.removeChild(anchorNode);
+                                                       }
                                                }
                                        } finally {
                                                EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, 
"InsertContent::text");
@@ -4774,10 +4877,13 @@ EvoEditor.InsertContent = function(text, isHTML, quote)
                                        EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE | 
EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML);
                                try {
                                        document.body.insertAdjacentElement("afterbegin", content);
+                                       EvoEditor.maybeUpdateParagraphWidth(content);
                                } finally {
                                        EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, 
"InsertContent::text");
                                }
                        }
+               } else if (EvoEditor.IsBlockNode(content.firstChild)) {
+                       EvoEditor.InsertHTML("InsertContent::text", content.innerHTML);
                } else {
                        EvoEditor.InsertHTML("InsertContent::text", content.outerHTML);
                }
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index ae6901e20b..10b2e9ed69 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -25,9 +25,6 @@
 static void
 test_bug_726548 (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-#if 0
        gboolean success;
        gchar *text;
        const gchar *expected_plain =
@@ -64,7 +61,6 @@ test_bug_726548 (TestFixture *fixture)
        } else {
                g_free (text);
        }
-#endif
 }
 
 static void
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index 277cdd8161..f64d0a0b27 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -4198,7 +4198,7 @@ test_paste_singleline_html2html (TestFixture *fixture)
                "action:paste\n"
                "type: text after\n",
                HTML_PREFIX "<div>text before some <b>bold</b> text text after</div>" HTML_SUFFIX,
-               "text before some bold text text after"))
+               "text before some bold text text after\n"))
                g_test_fail ();
 }
 
@@ -4213,7 +4213,7 @@ test_paste_singleline_html2plain (TestFixture *fixture)
                "action:paste\n"
                "type: text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before some bold text text after</div>" 
HTML_SUFFIX,
-               "text before some bold text text after"))
+               "text before some bold text text after\n"))
                g_test_fail ();
 }
 
@@ -4228,7 +4228,7 @@ test_paste_singleline_plain2html (TestFixture *fixture)
                "action:paste\n"
                "type: text after\n",
                HTML_PREFIX "<div>text before some plain text text after</div>" HTML_SUFFIX,
-               "text before some plain text text after"))
+               "text before some plain text text after\n"))
                g_test_fail ();
 }
 
@@ -4243,28 +4243,23 @@ test_paste_singleline_plain2plain (TestFixture *fixture)
                "action:paste\n"
                "type: text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before some plain text text after</div>" 
HTML_SUFFIX,
-               "text before some plain text text after"))
+               "text before some plain text text after\n"))
                g_test_fail ();
 }
 
 static void
 test_paste_multiline_html2html (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-
-#if 0
-       test_utils_set_clipboard_text ("<html><body><b>bold</b> text<br><i>italic</i> 
text<br><u>underline</u> text<br></body></html>", TRUE);
+       test_utils_set_clipboard_text ("<html><body><b>bold</b> text<br><i>italic</i> 
text<br><u>underline</u> text<br>.</body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
                "mode:html\n"
                "type:text before \n"
                "action:paste\n"
                "type:text after\n",
-               HTML_PREFIX "<div>text before <b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div>text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               HTML_PREFIX "<div>text before <b>bold</b> text</div><div><i>italic</i> 
text<br><u>underline</u> text<br>.text after</div>" HTML_SUFFIX,
+               "text before bold text\nitalic text\nunderline text\n.text after\n"))
                g_test_fail ();
-#endif
 }
 
 static void
@@ -4278,31 +4273,25 @@ test_paste_multiline_html2plain (TestFixture *fixture)
                "action:paste\n"
                "type:\\ntext after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before bold text</div>"
-               "<div style=\"width: 71ch;\">italic text</div>"
-               "<div style=\"width: 71ch;\">underline text</div>"
+               "<div style=\"width: 71ch;\">italic text<br>underline text</div>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               "text before bold text\nitalic text\nunderline text\ntext after\n"))
                g_test_fail ();
 }
 
 static void
 test_paste_multiline_div_html2html (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-
-#if 0
-       test_utils_set_clipboard_text ("<html><body><div><b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div></div></body></html>", TRUE);
+       test_utils_set_clipboard_text ("<html><body><div><b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div>.</div></body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
                "mode:html\n"
                "type:text before \n"
                "action:paste\n"
                "type:text after\n",
-               HTML_PREFIX "<div>text before <b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div>text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               HTML_PREFIX "<div>text before <b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div>.text after</div>" HTML_SUFFIX,
+               "text before bold text\nitalic text\nunderline text\n.text after\n"))
                g_test_fail ();
-#endif
 }
 
 static void
@@ -4316,21 +4305,16 @@ test_paste_multiline_div_html2plain (TestFixture *fixture)
                "action:paste\n"
                "type:\\ntext after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before bold text</div>"
-               "<div style=\"width: 71ch;\">italic text</div>"
-               "<div style=\"width: 71ch;\">underline text</div>"
+               "<div style=\"width: 71ch;\">italic text<br>underline text<br></div>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               "text before bold text\nitalic text\nunderline text\ntext after\n"))
                g_test_fail ();
 }
 
 static void
 test_paste_multiline_p_html2html (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-
-#if 0
-       test_utils_set_clipboard_text ("<html><body><div><b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div></div></body></html>", TRUE);
+       test_utils_set_clipboard_text ("<html><body><p><b>bold</b> text</p><p><i>italic</i> 
text</p><p><u>underline</u> text</p><p><br></p></body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
                "mode:html\n"
@@ -4338,15 +4322,14 @@ test_paste_multiline_p_html2html (TestFixture *fixture)
                "action:paste\n"
                "type:text after\n",
                HTML_PREFIX "<div>text before <b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div><div>text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               "text before bold text\nitalic text\nunderline text\ntext after\n"))
                g_test_fail ();
-#endif
 }
 
 static void
 test_paste_multiline_p_html2plain (TestFixture *fixture)
 {
-       test_utils_set_clipboard_text ("<html><body><div><b>bold</b> text</div><div><i>italic</i> 
text</div><div><u>underline</u> text</div></body></html>", TRUE);
+       test_utils_set_clipboard_text ("<html><body><p><b>bold</b> text</p><p><i>italic</i> 
text</p><p><u>underline</u> text</p></body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
                "mode:plain\n"
@@ -4354,10 +4337,9 @@ test_paste_multiline_p_html2plain (TestFixture *fixture)
                "action:paste\n"
                "type:\\ntext after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before bold text</div>"
-               "<div style=\"width: 71ch;\">italic text</div>"
-               "<div style=\"width: 71ch;\">underline text</div>"
+               "<div style=\"width: 71ch;\">italic text<br>underline text<br></div>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before bold text\nitalic text\nunderline text\ntext after"))
+               "text before bold text\nitalic text\nunderline text\ntext after\n"))
                g_test_fail ();
 }
 
@@ -4372,7 +4354,7 @@ test_paste_multiline_plain2html (TestFixture *fixture)
                "action:paste\n"
                "type:text after\n",
                HTML_PREFIX "<div>text before line 1</div><div>line 2</div><div>line 3</div><div>text 
after</div>" HTML_SUFFIX,
-               "text before line 1\nline 2\nline 3\ntext after"))
+               "text before line 1\nline 2\nline 3\ntext after\n"))
                g_test_fail ();
 }
 
@@ -4390,7 +4372,7 @@ test_paste_multiline_plain2plain (TestFixture *fixture)
                "<div style=\"width: 71ch;\">line 2</div>"
                "<div style=\"width: 71ch;\">line 3</div>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before line 1\nline 2\nline 3\ntext after"))
+               "text before line 1\nline 2\nline 3\ntext after\n"))
                g_test_fail ();
 }
 
@@ -4410,7 +4392,7 @@ test_paste_quoted_singleline_html2html (TestFixture *fixture)
                "<div>text after</div>" HTML_SUFFIX,
                "text before \n"
                "> some bold text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
 }
 
@@ -4426,11 +4408,13 @@ test_paste_quoted_singleline_html2plain (TestFixture *fixture)
                "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before </div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div style=\"width: 71ch;\">&gt; some 
<b>bold</b> text</div></blockquote>"
+               "<blockquote type=\"cite\">"
+                       "<div>" QUOTE_SPAN (QUOTE_CHR) "some bold text</div>"
+               "</blockquote>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before \n"
+               "text before\n"
                "> some bold text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
 }
 
@@ -4450,7 +4434,7 @@ test_paste_quoted_singleline_plain2html (TestFixture *fixture)
                "<div>text after</div>" HTML_SUFFIX,
                "text before \n"
                "> some plain text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
 }
 
@@ -4466,50 +4450,41 @@ test_paste_quoted_singleline_plain2plain (TestFixture *fixture)
                "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before </div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div style=\"width: 71ch;\">&gt; some plain 
text</div></blockquote>"
+               "<blockquote type=\"cite\"><div>" QUOTE_SPAN (QUOTE_CHR) "some plain text</div></blockquote>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before \n"
+               "text before\n"
                "> some plain text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
 }
 
 static void
 test_paste_quoted_multiline_html2html (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-
-#if 0
        test_utils_set_clipboard_text ("<html><body><b>bold</b> text<br><i>italic</i> 
text<br><u>underline</u> text<br></body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
                "mode:html\n"
                "type:text before \n"
                "action:paste-quote\n"
-               "seq:b\n" /* stop quotting */
+               "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div>text before </div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE ">&gt; <b>bold</b> text</div>"
-               "<div>&gt; <i>italic</i> text</div>"
-               "<div>&gt; <u>underline</u> text</div></blockquote>"
+               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div><b>bold</b> text<br>"
+               "<i>italic</i> text<br>"
+               "<u>underline</u> text<br></div></blockquote>"
                "<div>text after</div>" HTML_SUFFIX,
                "text before \n"
                "> bold text\n"
                "> italic text\n"
                "> underline text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
-#endif
 }
 
 static void
 test_paste_quoted_multiline_html2plain (TestFixture *fixture)
 {
-       /* This test is known to fail, skip it. */
-       printf ("SKIPPED ");
-
-#if 0
        test_utils_set_clipboard_text ("<html><body><b>bold</b> text<br><i>italic</i> 
text<br><u>underline</u> text</body></html>", TRUE);
 
        if (!test_utils_run_simple_test (fixture,
@@ -4519,17 +4494,16 @@ test_paste_quoted_multiline_html2plain (TestFixture *fixture)
                "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before </div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div>&gt; bold text</div>"
-               "<div style=\"width: 71ch;\">&gt; italic text</div>"
-               "<div style=\"width: 71ch;\">&gt; underline text</div></blockquote>"
-               "<div style=\"width: 71ch;\">&gt; text after</div>" HTML_SUFFIX,
-               "text before \n"
+               "<blockquote type=\"cite\"><div>" QUOTE_SPAN (QUOTE_CHR) "bold text<br>"
+               QUOTE_SPAN (QUOTE_CHR) "italic text<br>"
+               QUOTE_SPAN (QUOTE_CHR) "underline text</div></blockquote>"
+               "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
+               "text before\n"
                "> bold text\n"
                "> italic text\n"
                "> underline text\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
-#endif
 }
 
 static void
@@ -4541,18 +4515,20 @@ test_paste_quoted_multiline_plain2html (TestFixture *fixture)
                "mode:html\n"
                "type:text before \n"
                "action:paste-quote\n"
-               "seq:b\n" /* stop quotting */
+               "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div>text before </div>"
                "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div>line 1</div>"
                "<div>line 2</div>"
-               "<div>line 3</div></blockquote>"
+               "<div>line 3</div>"
+               "<div><br></div></blockquote>"
                "<div>text after</div>" HTML_SUFFIX,
                "text before \n"
                "> line 1\n"
                "> line 2\n"
                "> line 3\n"
-               "text after"))
+               "> \n"
+               "text after\n"))
                g_test_fail ();
 }
 
@@ -4568,15 +4544,15 @@ test_paste_quoted_multiline_plain2plain (TestFixture *fixture)
                "type:\\n\n" /* stop quotting */
                "type:text after\n",
                HTML_PREFIX "<div style=\"width: 71ch;\">text before </div>"
-               "<blockquote type=\"cite\" " BLOCKQUOTE_STYLE "><div style=\"width: 71ch;\">&gt; line 1</div>"
-               "<div style=\"width: 71ch;\">&gt; line 2</div>"
-               "<div style=\"width: 71ch;\">&gt; line 3</div></blockquote>"
+               "<blockquote type=\"cite\"><div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "line 3</div></blockquote>"
                "<div style=\"width: 71ch;\">text after</div>" HTML_SUFFIX,
-               "text before \n"
+               "text before\n"
                "> line 1\n"
                "> line 2\n"
                "> line 3\n"
-               "text after"))
+               "text after\n"))
                g_test_fail ();
 }
 
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 932768636f..a3a6bde44f 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -2047,8 +2047,8 @@ webkit_editor_insert_content (EContentEditor *editor,
        } else if (!(flags & E_CONTENT_EDITOR_INSERT_CONVERT) &&
                   !(flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL)) {
                e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
-                       "EvoEditor.InsertHTML(%s, %s);",
-                       "InsertHTML", content);
+                       "EvoEditor.InsertContent(%s, %x, %x);",
+                       content, (flags & E_CONTENT_EDITOR_INSERT_TEXT_HTML) != 0, FALSE);
        } else {
                g_warning ("%s: Unsupported flags combination (0x%x)", G_STRFUNC, flags);
        }


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