From 975afd36276d975cffd48b14d63c85f09d478e41 Mon Sep 17 00:00:00 2001 From: Yves Goergen Date: Wed, 21 Aug 2024 04:38:54 +0200 Subject: [PATCH] Fix spacing and font size of inserted headers (#164) * Fix spacing and font size of inserted headers - Added missing empty line between reply headers and reply body - Aligned line space before and after headers for reply and forward - Removed wrong font-size style from inserted content - Simplified CSS length units * Review comments - Removed unused code - Brought back unnecessary CSS units on zero lengths - Brought back initially unset styles that don't change anything --- modules/compose.mjs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/compose.mjs b/modules/compose.mjs index 6788e15..46211ab 100644 --- a/modules/compose.mjs +++ b/modules/compose.mjs @@ -15,7 +15,7 @@ import * as rwhI18n from './headers-i18n.mjs'; import * as rwhAccounts from './accounts.mjs'; import * as rwhUtils from './utils.mjs'; -const positionBeforeBegin = 'beforebegin'; +const positionBeforeEnd = 'beforeend'; const positionAfterBegin = 'afterbegin'; const fwdHdrLookupString = '-------- '; const plainTextFirstChars = '> '; @@ -176,7 +176,9 @@ class ReplyWithHeader { // put back the cleaned up
tags as-is if (this.isReply) { - div.insertAdjacentElement(positionAfterBegin, this._createElement('br')); + // Originally, there's no
after the (unindented) cite prefix. + // With the table style, it looks better with an extra empty line (like everybody else has it). + div.insertAdjacentElement(positionBeforeEnd, this._createElement('br')); // blockquote if (await rwhSettings.isCleanAllBlockQuoteColor()) { // all @@ -192,7 +194,15 @@ class ReplyWithHeader { if (this.isForward) { let mozForwardContainer = this._getByClassName('moz-forward-container'); this._cleanNodesUpToClassName(mozForwardContainer, targetNodeClassName); - mozForwardContainer.insertAdjacentElement(positionAfterBegin, this._createElement('br')); + + // Insert 2
before the headers to make it look like a reply does. + mozForwardContainer.insertAdjacentElement(positionAfterBegin, this._createElement('br')); + mozForwardContainer.insertAdjacentElement(positionAfterBegin, this._createElement('br')); + + // There are 2
originally, but none for reply mode. + // We add one for replies, so let's remove one for forwards to make it even. + let nextBr = mozForwardContainer.querySelector("div.moz-email-headers-table + br"); + nextBr?.remove(); } return { @@ -282,12 +292,12 @@ class ReplyWithHeader { } if (headers[hdrKey]) { - rwhHeaders += '

' + lbl + ' ' + headers[hdrKey] + '

'; + rwhHeaders += '

' + lbl + ' ' + headers[hdrKey] + '

'; } }, this); rwhHeaders += await this._handleAllHeadersFlow(false, true); - rwhHeaders += '
'; + rwhHeaders += ''; return rwhHeaders; } @@ -481,7 +491,7 @@ class ReplyWithHeader { } else { let rwhHeaders = ''; for (let [key, value] of Object.entries(remainingHeaders)) { - rwhHeaders += '

' + rwhHeaders += '

' + rwhUtils.toPartialCanonicalFormat(key) + ': ' + value + '

'; } return rwhHeaders;