courrier clean 2

This commit is contained in:
alma 2025-04-26 14:41:40 +02:00
parent 71cc875f57
commit 090e703214

View File

@ -269,15 +269,10 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
setSubject(formattedEmail.subject);
// Split the formatted body to separate user's message area from quoted content
// Make the entire content editable, just like with forwarded emails
const bodyContent = formattedEmail.body;
setUserMessage(bodyContent);
setBody(bodyContent);
// Set the original content for the quoted part
const quoteMatch = bodyContent.match(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/i);
if (quoteMatch && quoteMatch[0]) {
setOriginalContent(quoteMatch[0]);
}
}
// Focus editor after initializing
@ -418,12 +413,12 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
);
}
// Store the complete forwarded content in state
const forwardedContent = `${headerHtml}<div class="forwarded-content">${contentHtml}</div>`;
setOriginalContent(forwardedContent);
// In forwarding, we'll make the entire content editable, not just the user message area
const completeContent = `<br/>${headerHtml}<div class="forwarded-content" style="color: #333;">${contentHtml}</div>`;
// Set the complete body
setBody(`<div class="user-message"></div>${forwardedContent}`);
// Don't separate original content, allow editing the entire body
setUserMessage(completeContent);
setBody(completeContent);
} catch (error) {
console.error('Error formatting forwarded email:', error);
@ -510,12 +505,11 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
const handleEditorInput = (e: React.FormEvent<HTMLDivElement>) => {
if (editorRef.current) {
const content = editorRef.current.innerHTML;
setUserMessage(content);
// 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);
// For forwarded messages, the entire content is now editable
// No need to separate user message from original content
setUserMessage(content);
setBody(content);
}
};
@ -639,7 +633,7 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
{/* Email editor with clear separation between user message and original content */}
<div className="border rounded-md overflow-hidden">
{/* User's message input area */}
{/* Combined editable area that includes both user message and original content */}
<div
ref={editorRef}
contentEditable={!sending}
@ -649,21 +643,8 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
direction: isRTL ? 'rtl' : 'ltr',
textAlign: isRTL ? 'right' : 'left'
}}
dangerouslySetInnerHTML={type !== 'new' ? { __html: body } : undefined}
/>
{/* Original content display with visual separation - only shown for replies/forwards */}
{type !== 'new' && originalContent && (
<div className="border-t pt-2">
<div className="px-4 py-2 bg-gray-50 text-xs font-medium text-gray-500">
{type === 'forward' ? 'Forwarded content' : 'Original message'}
</div>
<div
className="p-4 bg-gray-50 text-sm original-content"
dangerouslySetInnerHTML={{ __html: originalContent }}
style={{ opacity: 1.0 }}
/>
</div>
)}
</div>
</div>