ConversationWebView: Fix plain text emails sometimes being too wide

Using `whitespace: pre-wrap` to format plain text email sometimes
causes additional width to be allocated by the plain text blocks that
then does not get used due to the constraints on the HTML element.
The allocated space remains however and hence an un-needed horizontal
scrollbar appears.

Using `break-spaces` instead seems to help since it allows breaks after
a space character, leading to the additional space not otherwise being
allocated.
This commit is contained in:
Michael Gratton 2020-10-17 13:45:23 +11:00
parent 0e783de5bf
commit ec3057daf7
6 changed files with 6 additions and 6 deletions

View file

@ -59,7 +59,7 @@ private class Geary.RFC822.FilterBlockquotes : GMime.Filter {
if (!initial_element) {
// We set the style explicitly so it will be set in HTML emails. We also give it a
// class so users can customize the style in the viewer.
insert_string("<div class=\"plaintext\" style=\"white-space: pre-wrap;\">", ref out_index);
insert_string("<div class=\"plaintext\" style=\"white-space: break-spaces;\">", ref out_index);
initial_element = true;
}

View file

@ -15,7 +15,7 @@ class Geary.RFC822.MessageTest : TestCase {
private const string BASIC_MULTIPART_TNEF = "basic-multipart-tnef.eml";
private const string HTML_CONVERSION_TEMPLATE =
"<div class=\"plaintext\" style=\"white-space: pre-wrap;\">%s</div>";
"<div class=\"plaintext\" style=\"white-space: break-spaces;\">%s</div>";
private const string BASIC_PLAIN_BODY = """This is the first line.

View file

@ -60,6 +60,6 @@ blockquote {
}
pre {
white-space: pre-wrap;
white-space: break-spaces;
margin: 0;
}

View file

@ -264,7 +264,7 @@ ComposerPageState.prototype = {
},
tabOut: function() {
document.execCommand(
"inserthtml", false, "<span style='white-space: pre-wrap'>\t</span>"
"inserthtml", false, "<span style='white-space: break-spaces'>\t</span>"
);
},
tabIn: function() {

View file

@ -77,7 +77,7 @@ blockquote {
}
pre {
white-space: pre-wrap;
white-space: break-spaces;
}
/**

View file

@ -213,7 +213,7 @@ ConversationPageState.prototype = {
if (ConversationPageState.isDescendantOf(
ancestor, "DIV", "plaintext", false)) {
dummy.classList.add("plaintext");
dummy.setAttribute("style", "white-space: pre-wrap;");
dummy.setAttribute("style", "white-space: break-spaces;");
includeDummy = true;
}
dummy.appendChild(range.cloneContents());