From 71cc875f57cb6d11bc5c7c09ea225913b042c56e Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 26 Apr 2025 14:39:04 +0200 Subject: [PATCH] courrier clean 2 --- components/email/ComposeEmail.tsx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/components/email/ComposeEmail.tsx b/components/email/ComposeEmail.tsx index 7e35123c..70d514b4 100644 --- a/components/email/ComposeEmail.tsx +++ b/components/email/ComposeEmail.tsx @@ -409,7 +409,12 @@ export default function ComposeEmail(props: ComposeEmailAllProps) { // Use the most complete version of content available contentHtml = DOMPurify.sanitize( initialEmail.content || initialEmail.html || - `
${initialEmail.text || ''}
` + `
${initialEmail.text || ''}
`, + { + ADD_ATTR: ['style', 'class'], + ALLOW_DATA_ATTR: true, + USE_PROFILES: { html: true } + } ); } @@ -507,7 +512,8 @@ export default function ComposeEmail(props: ComposeEmailAllProps) { const content = editorRef.current.innerHTML; setUserMessage(content); - // Combine user message with original content for the full email + // Preserve the exact original content formatting by keeping it separate + // This ensures nested forwards maintain their structure const combined = `
${content}
${originalContent}`; setBody(combined); } @@ -654,7 +660,7 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
)} @@ -787,7 +793,8 @@ function LegacyAdapter({ return null; } - // Create a minimal EmailMessage object with the necessary fields + // For forwarded content, we need to preserve all the original formatting + // The composeBody already contains the formatted message with headers return { id: 'temp-id', messageId: '', @@ -795,6 +802,7 @@ function LegacyAdapter({ from: [{ name: '', address: '' }], to: [{ name: '', address: '' }], date: new Date(), + // Always use the full composeBody to ensure nested forwards are preserved content: composeBody, html: composeBody, hasAttachments: false @@ -820,7 +828,18 @@ function LegacyAdapter({ onCancel?.(); setShowCompose(false); }} - onSend={async (emailData) => { + onSend={async (emailData: { + to: string; + cc?: string; + bcc?: string; + subject: string; + body: string; + attachments?: Array<{ + name: string; + content: string; + type: string; + }>; + }) => { // Update legacy state before sending setComposeTo(emailData.to); if (emailData.cc) setComposeCc(emailData.cc);