I#1157 - Composer: Quoted text visually changes linewrap after paste
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1157
This commit is contained in:
@ -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 <br> 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";
|
||||
}
|
||||
}
|
||||
|
||||
@ -2131,9 +2131,9 @@ test_issue_1330 (TestFixture *fixture)
|
||||
"",
|
||||
HTML_PREFIX "<div style=\"width: 12ch;\">Credits:</div>"
|
||||
"<blockquote type=\"cite\">"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "123 567 90" WRAP_BR "</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "2345678901" WRAP_BR "</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "34 67 9012" WRAP_BR "</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "123 567 90</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "2345678901</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "34 67 9012</div>"
|
||||
"<div>" QUOTE_SPAN (QUOTE_CHR) "45678 0 2" WRAP_BR
|
||||
QUOTE_SPAN (QUOTE_CHR) "4 6 8 0</div>"
|
||||
"</blockquote>"
|
||||
@ -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,
|
||||
"<body><div>123 567 90 <br></div>"
|
||||
"<div>2345678901 <br></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);
|
||||
|
||||
test_utils_set_clipboard_text ("http://e.c/", FALSE);
|
||||
|
||||
if (!test_utils_run_simple_test (fixture,
|
||||
"seq:Cecn\n"
|
||||
"action:paste\n",
|
||||
HTML_PREFIX "<div style=\"width: 12ch;\">Credits:</div>"
|
||||
"<blockquote type=\"cite\">"
|
||||
"<div style=\"width: 12ch;\">" QUOTE_SPAN (QUOTE_CHR) "123 567 90</div>"
|
||||
"<div style=\"width: 12ch;\">" QUOTE_SPAN (QUOTE_CHR) "2345678901</div>"
|
||||
"</blockquote>"
|
||||
"<div style=\"width: 12ch;\"><a href=\"http://e.c/\">http://e.c/</a></div>"
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user