[evolution] Composer: Incorrect <BR> in quoted line with spaces only
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Composer: Incorrect <BR> in quoted line with spaces only
- Date: Tue, 23 Mar 2021 17:11:10 +0000 (UTC)
commit 9debad14e2af1768d543e796b10090511a56d4d7
Author: Milan Crha <mcrha redhat com>
Date: Tue Mar 23 18:08:35 2021 +0100
Composer: Incorrect <BR> in quoted line with spaces only
Quoted lines with spaces only also added an extra <BR> when converting
from plain text, which leads to doubled quotation marks and misbehavior
when splitting the blockquote with the Enter key.
data/webkit/e-editor.js | 12 ++++---
src/e-util/test-html-editor-units.c | 64 +++++++++++++++++++++++++++++++++++--
2 files changed, 69 insertions(+), 7 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 21585088d7..054d387f41 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -1931,12 +1931,12 @@ EvoEditor.quoteParagraph = function(paragraph, blockquoteLevel, wrapWidth)
paragraph.insertAdjacentHTML("afterbegin", prefixHtml);
}
-EvoEditor.reBlockquotePlainText = function(plainText, usePreTag)
+EvoEditor.reBlockquotePlainText = function(plainText, usePreTag, isPreTag)
{
var lines = plainText.replace(/\&/g, "&").split("\n"), ii, html = "", level = 0;
for (ii = 0; ii < lines.length; ii++) {
- var line = lines[ii], newLevel = 0, skip = 0;
+ var line = lines[ii], newLevel = 0, skip = 0, addedSpaces = false;
// Conversion to Plain Text adds empty line at the end
if (ii + 1 >= lines.length && !line[0])
@@ -1963,13 +1963,14 @@ EvoEditor.reBlockquotePlainText = function(plainText, usePreTag)
while (line[skip] == ' ') {
skip++;
- html += " ";
+ html += (usePreTag ? " " : " ");
+ addedSpaces = true;
}
if (skip)
line = line.substr(skip);
- html += (line[0] ? line.replace(/</g, "<").replace(/>/g, ">") : "<br>");
+ html += (line[0] ? line.replace(/</g, "<").replace(/>/g, ">") : ((addedSpaces &&
(usePreTag || isPreTag)) ? "" : "<br>"));
html += usePreTag ? "</pre>" : "</div>";
}
@@ -2091,7 +2092,8 @@ EvoEditor.convertParagraphs = function(parent, blockquoteLevel, wrapWidth, canCh
if (EvoEditor.mode == EvoEditor.MODE_PLAIN_TEXT && !blockquoteLevel) {
child.innerHTML =
EvoEditor.reBlockquotePlainText(EvoConvert.ToPlainText(child, -1),
(child.firstElementChild && child.firstElementChild.tagName == "PRE"
&& (
- !canChangeQuoteParagraphs ||
!EvoEditor.WRAP_QUOTED_TEXT_IN_REPLIES)));
+ !canChangeQuoteParagraphs || !EvoEditor.WRAP_QUOTED_TEXT_IN_REPLIES)),
+ child.firstElementChild && child.firstElementChild.tagName == "PRE");
}
EvoEditor.convertParagraphs(child, blockquoteLevel + 1, innerWrapWidth,
canChangeQuoteParagraphs);
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index 189d9ec196..551d7878e7 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -4982,6 +4982,8 @@ test_cite_reply_html_to_plain (TestFixture *fixture)
static void
test_cite_reply_plain (TestFixture *fixture)
{
+ test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-wrap-quoted-text-in-replies", TRUE);
+
if (!test_utils_process_commands (fixture,
"mode:plain\n")) {
g_test_fail ();
@@ -4990,7 +4992,11 @@ test_cite_reply_plain (TestFixture *fixture)
test_utils_insert_content (fixture,
"<pre>line 1\n"
+ "\n"
"line 2\n"
+ " \n"
+ "line 3\n"
+ " \n"
"</pre><span class=\"-x-evo-to-body\" data-credits=\"On Today, User wrote:\"></span>"
"<span class=\"-x-evo-cite-body\"></span>",
E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
@@ -5000,10 +5006,64 @@ test_cite_reply_plain (TestFixture *fixture)
HTML_PREFIX "<div style=\"width: 71ch;\">On Today, User wrote:</div>"
"<blockquote type=\"cite\">"
"<div>" QUOTE_SPAN (QUOTE_CHR) "line 1</div>"
- "<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div></blockquote>" HTML_SUFFIX,
+ "<div>" QUOTE_SPAN (QUOTE_CHR) "<br></div>"
+ "<div>" QUOTE_SPAN (QUOTE_CHR) "line 2</div>"
+ "<div>" QUOTE_SPAN (QUOTE_CHR) " </div>"
+ "<div>" QUOTE_SPAN (QUOTE_CHR) "line 3</div>"
+ "<div>" QUOTE_SPAN (QUOTE_CHR) " </div>"
+ "</blockquote>" HTML_SUFFIX,
"On Today, User wrote:\n"
"> line 1\n"
- "> line 2\n"))
+ "> \n"
+ "> line 2\n"
+ "> \n"
+ "> line 3\n"
+ "> \n")) {
+ g_test_fail ();
+ return;
+ }
+
+ test_utils_insert_content (fixture,
+ "<html><head></head><body><div><br></div></body></html>",
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+ test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-wrap-quoted-text-in-replies", FALSE);
+
+ if (!test_utils_process_commands (fixture,
+ "mode:plain\n")) {
+ g_test_fail ();
+ return;
+ }
+
+ test_utils_insert_content (fixture,
+ "<pre>line 1\n"
+ "\n"
+ "line 2\n"
+ " \n"
+ "line 3\n"
+ " \n"
+ "</pre><span class=\"-x-evo-to-body\" data-credits=\"On Today, User wrote:\"></span>"
+ "<span class=\"-x-evo-cite-body\"></span>",
+ E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+ if (!test_utils_run_simple_test (fixture,
+ "",
+ HTML_PREFIX "<div style=\"width: 71ch;\">On Today, User wrote:</div>"
+ "<blockquote type=\"cite\">"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) "line 1</pre>"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) "<br></pre>"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) "line 2</pre>"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) " </pre>"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) "line 3</pre>"
+ "<pre>" QUOTE_SPAN (QUOTE_CHR) " </pre>"
+ "</blockquote>" HTML_SUFFIX,
+ "On Today, User wrote:\n"
+ "> line 1\n"
+ "> \n"
+ "> line 2\n"
+ "> \n"
+ "> line 3\n"
+ "> \n"))
g_test_fail ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]