courrier clean 2

This commit is contained in:
alma 2025-04-26 14:39:04 +02:00
parent 34d2aed721
commit 71cc875f57

View File

@ -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 ||
`<pre style="white-space: pre-wrap;">${initialEmail.text || ''}</pre>`
`<pre style="white-space: pre-wrap;">${initialEmail.text || ''}</pre>`,
{
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 = `<div class="user-message" style="direction: ${isRTL ? 'rtl' : 'ltr'}; text-align: ${isRTL ? 'right' : 'left'};">${content}</div>${originalContent}`;
setBody(combined);
}
@ -654,7 +660,7 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
<div
className="p-4 bg-gray-50 text-sm original-content"
dangerouslySetInnerHTML={{ __html: originalContent }}
style={{ opacity: 0.85 }}
style={{ opacity: 1.0 }}
/>
</div>
)}
@ -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);