[evolution] I#1424 - Composer: Paragraph format change should preserve BLOCKQUOTE



commit 529117f0e60603d22fb7b8a6b749935565a13444
Author: Milan Crha <mcrha redhat com>
Date:   Fri Mar 19 12:01:35 2021 +0100

    I#1424 - Composer: Paragraph format change should preserve BLOCKQUOTE
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1424

 data/webkit/e-editor.js                  |   6 +-
 src/e-util/test-html-editor-units-bugs.c | 123 +++++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+), 1 deletion(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 1ddca5ce80..21585088d7 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -1040,10 +1040,14 @@ EvoEditor.SetBlockFormat = function(format)
                targetElement : null,
                selectionUpdater : null,
 
-               flat : true,
+               flat : false,
                onlyBlockElements : true,
 
                exec : function(parent, element) {
+                       // do not change blockquote elements
+                       if (element.tagName == "BLOCKQUOTE")
+                               return true;
+
                        var newElement;
 
                        if (this.toSet.tagName != "LI" && (element.tagName == "UL" || element.tagName == 
"OL")) {
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index 528eba5afa..bf496442f7 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -2539,6 +2539,127 @@ test_issue_1159 (TestFixture *fixture)
                g_test_fail ();
 }
 
+static void
+test_issue_1424_level1 (TestFixture *fixture)
+{
+       if (!test_utils_process_commands (fixture,
+               "mode:plain\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><div>a</div>"
+               "<div>b</div>"
+               "<div>c</div>"
+               "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:C\n"
+               "type:a\n"
+               "seq:c\n"
+               "action:style-preformat\n",
+               HTML_PREFIX "<pre>Credits:</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "a</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "b</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "c</pre>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> a\n"
+               "> b\n"
+               "> c\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       if (!test_utils_run_simple_test (fixture,
+               "action:style-normal\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "a</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "b</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "c</div>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> a\n"
+               "> b\n"
+               "> c\n")) {
+               g_test_fail ();
+               return;
+       }
+}
+
+static void
+test_issue_1424_level2 (TestFixture *fixture)
+{
+       if (!test_utils_process_commands (fixture,
+               "mode:plain\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><div>a</div>"
+               "<blockquote type=\"cite\">"
+               "<div>b</div>"
+               "<div>c</div>"
+               "</blockquote>"
+               "<div>d</div>"
+               "<span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:C\n"
+               "type:a\n"
+               "seq:c\n"
+               "action:style-preformat\n",
+               HTML_PREFIX "<pre>Credits:</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "a</pre>"
+               "<blockquote type=\"cite\">"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "b</pre>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "c</pre>"
+               "</blockquote>"
+               "<pre>" QUOTE_SPAN (QUOTE_CHR) "d</pre>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> a\n"
+               "> > b\n"
+               "> > c\n"
+               "> d\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       if (!test_utils_run_simple_test (fixture,
+               "action:style-normal\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "a</div>"
+               "<blockquote type=\"cite\">"
+               "<div>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "b</div>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR QUOTE_CHR) "c</div>"
+               "</blockquote>"
+               "<div>" QUOTE_SPAN (QUOTE_CHR) "d</div>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> a\n"
+               "> > b\n"
+               "> > c\n"
+               "> d\n")) {
+               g_test_fail ();
+               return;
+       }
+}
+
 void
 test_add_html_editor_bug_tests (void)
 {
@@ -2583,4 +2704,6 @@ test_add_html_editor_bug_tests (void)
        test_utils_add_test ("/issue/1391", test_issue_1391);
        test_utils_add_test ("/issue/1394", test_issue_1394);
        test_utils_add_test ("/issue/1159", test_issue_1159);
+       test_utils_add_test ("/issue/1424-level1", test_issue_1424_level1);
+       test_utils_add_test ("/issue/1424-level2", test_issue_1424_level2);
 }


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