From 3b95e570e4f5b9eda451c19300f94a7c13843df5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 20 Jan 2021 12:32:44 +0100 Subject: [PATCH] I#1157 - Composer: Quoted text visually changes linewrap after paste Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1157 --- data/webkit/e-editor.js | 17 ++++++--- src/e-util/test-html-editor-units-bugs.c | 45 ++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js index 58916037d7..8cfaaf8a4a 100644 --- a/data/webkit/e-editor.js +++ b/data/webkit/e-editor.js @@ -1088,6 +1088,8 @@ EvoEditor.SetBlockFormat = function(format) if (blockquoteLevel > 0) { var width = -1; + blockquoteLevel--; + if (this.toSet.tagName == "DIV" && blockquoteLevel * 2 < EvoEditor.NORMAL_PARAGRAPH_WIDTH) width = EvoEditor.NORMAL_PARAGRAPH_WIDTH - blockquoteLevel * 2; @@ -1836,14 +1838,15 @@ EvoEditor.quoteParagraphWrap = function(node, lineLength, wrapWidth, prefixHtml) node.remove(); node = next; - var br = document.createElement("BR"); - br.className = "-x-evo-wrap-br"; + // add the prefix and
only if there's still anything to be quoted + if (node.nodeValue.length) { + var br = document.createElement("BR"); + br.className = "-x-evo-wrap-br"; - node.parentElement.insertBefore(br, node); + node.parentElement.insertBefore(br, node); - // add the prefix only if there's still anything to be quoted - if (node.nodeValue.length) br.insertAdjacentHTML("afterend", prefixHtml); + } } offset = 0; @@ -2975,6 +2978,10 @@ EvoEditor.maybeUpdateParagraphWidth = function(topNode) } if (citeLevel * 2 < EvoEditor.NORMAL_PARAGRAPH_WIDTH) { + // to include the '> ' into the line length + if (citeLevel >= 1) + citeLevel--; + topNode.style.width = (EvoEditor.NORMAL_PARAGRAPH_WIDTH - citeLevel * 2) + "ch"; } } diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c index 0920a9a5ae..d38a1247bf 100644 --- a/src/e-util/test-html-editor-units-bugs.c +++ b/src/e-util/test-html-editor-units-bugs.c @@ -2131,9 +2131,9 @@ test_issue_1330 (TestFixture *fixture) "", HTML_PREFIX "
Credits:
" "
" - "
" QUOTE_SPAN (QUOTE_CHR) "123 567 90" WRAP_BR "
" - "
" QUOTE_SPAN (QUOTE_CHR) "2345678901" WRAP_BR "
" - "
" QUOTE_SPAN (QUOTE_CHR) "34 67 9012" WRAP_BR "
" + "
" QUOTE_SPAN (QUOTE_CHR) "123 567 90
" + "
" QUOTE_SPAN (QUOTE_CHR) "2345678901
" + "
" QUOTE_SPAN (QUOTE_CHR) "34 67 9012
" "
" QUOTE_SPAN (QUOTE_CHR) "45678 0 2" WRAP_BR QUOTE_SPAN (QUOTE_CHR) "4 6 8 0
" "
" @@ -2147,6 +2147,44 @@ test_issue_1330 (TestFixture *fixture) g_test_fail (); } +static void +test_issue_1157 (TestFixture *fixture) +{ + test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail", "composer-wrap-quoted-text-in-replies", TRUE); + test_utils_fixture_change_setting_int32 (fixture, "org.gnome.evolution.mail", "composer-word-wrap-length", 12); + + if (!test_utils_process_commands (fixture, + "mode:plain\n")) { + g_test_fail (); + return; + } + + test_utils_insert_content (fixture, + "
123 567 90
" + "
2345678901
" + "" + "", + E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML); + + test_utils_set_clipboard_text ("http://e.c/", FALSE); + + if (!test_utils_run_simple_test (fixture, + "seq:Cecn\n" + "action:paste\n", + HTML_PREFIX "
Credits:
" + "
" + "
" QUOTE_SPAN (QUOTE_CHR) "123 567 90
" + "
" QUOTE_SPAN (QUOTE_CHR) "2345678901
" + "
" + "
http://e.c/
" + HTML_SUFFIX, + "Credits:\n" + "> 123 567 90\n" + "> 2345678901\n" + "http://e.c/\n")) + g_test_fail (); +} + void test_add_html_editor_bug_tests (void) { @@ -2185,4 +2223,5 @@ test_add_html_editor_bug_tests (void) test_utils_add_test ("/issue/913", test_issue_913); test_utils_add_test ("/issue/1214", test_issue_1214); test_utils_add_test ("/issue/1330", test_issue_1330); + test_utils_add_test ("/issue/1157", test_issue_1157); }