fix: preserve HTML signature when sending a quick reply

The quick-reply box built its body with appendPlainTextSignature, which runs
the identity's HTML signature through htmlToPlainText, and sent a text-only
message (htmlBody was undefined). A formatted signature (e.g. <strong>…) was
therefore flattened to plain text in the sent mail, even though it previewed
correctly in the identity editor. The full composer already builds an HTML
signature block; quick reply did not.

Add an appendHtmlSignature helper (mirrors the composer's send-time block) and,
when the sending identity has an HTML signature, send a matching HTML body from
handleQuickReply so the markup is preserved. Text-only identities keep the
plain-text-only behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Phongsaton Untan
2026-05-30 15:12:30 +02:00
committed by Linus Rath
co-authored by Claude Opus 4.8
parent 0879030dc8
commit 196e51e91b
3 changed files with 68 additions and 5 deletions
+29
View File
@@ -124,6 +124,35 @@ export function appendPlainTextSignature(
return `${body}${sep}${plainTextSignature}`;
}
/**
* Append a signature to an HTML body, preserving rich formatting. Used by the
* quick-reply path so an HTML signature keeps its markup instead of being
* flattened to plain text. Mirrors the composer's send-time signature block
* (`buildSignatureHtml` in email-composer.tsx).
*/
export function appendHtmlSignature(
htmlBody: string,
signature?: SignatureSource | null,
options: { separator?: boolean } = {},
): string {
const sep = options.separator === false ? '<br><br>' : '<br><br>-- <br>';
if (signature?.htmlSignature?.trim()) {
return `${htmlBody}${sep}${sanitizeSignatureHtml(signature.htmlSignature)}`;
}
if (signature?.textSignature?.trim()) {
const escaped = signature.textSignature
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\n/g, '<br>');
return `${htmlBody}${sep}${escaped}`;
}
return htmlBody;
}
export function hasMeaningfulHtmlBody(html: string): boolean {
if (!html.trim()) return false;