mime change

This commit is contained in:
alma 2025-04-24 17:12:24 +02:00
parent ea2193ed9a
commit 591966284d

View File

@ -83,26 +83,39 @@ export default function ComposeEmail({
useEffect(() => { useEffect(() => {
if (composeBodyRef.current && !isInitialized) { if (composeBodyRef.current && !isInitialized) {
// Initialize the content structure with both new reply area and original content in a single contentEditable div let content = '';
const content = replyTo || forwardFrom ? `
<div class="compose-area" contenteditable="true">${initialBody || ''}</div> if (replyTo || forwardFrom) {
<div class="quoted-content" contenteditable="false"> // Get the original email content
${forwardFrom ? ` const originalContent = replyTo?.body || forwardFrom?.body || '';
---------- Forwarded message ---------<br/>
From: ${forwardFrom.from}<br/> // Create the reply/forward structure
Date: ${new Date(forwardFrom.date).toLocaleString()}<br/> content = `
Subject: ${forwardFrom.subject}<br/> <div class="compose-area" contenteditable="true" style="min-height: 100px; padding: 10px; border: 1px solid #e5e7eb; border-radius: 4px; margin-bottom: 20px;"></div>
To: ${forwardFrom.to}<br/> <div class="quoted-content" contenteditable="false" style="color: #6b7280; font-size: 0.875rem;">
${forwardFrom.cc ? `Cc: ${forwardFrom.cc}<br/>` : ''} ${forwardFrom ? `
<br/> <div style="margin-bottom: 10px;">
` : ` ---------- Forwarded message ---------<br/>
On ${new Date(replyTo?.date || '').toLocaleString()}, ${replyTo?.from} wrote:<br/> From: ${forwardFrom.from}<br/>
`} Date: ${new Date(forwardFrom.date).toLocaleString()}<br/>
<blockquote style="margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204,204,204); padding-left: 1ex;"> Subject: ${forwardFrom.subject}<br/>
${composeBody} To: ${forwardFrom.to}<br/>
</blockquote> ${forwardFrom.cc ? `Cc: ${forwardFrom.cc}<br/>` : ''}
</div> </div>
` : `<div class="compose-area" contenteditable="true">${initialBody || ''}</div>`; ` : `
<div style="margin-bottom: 10px;">
On ${new Date(replyTo?.date || '').toLocaleString()}, ${replyTo?.from} wrote:
</div>
`}
<blockquote style="margin: 0; padding-left: 1em; border-left: 2px solid #e5e7eb;">
${originalContent}
</blockquote>
</div>
`;
} else {
// For new messages
content = `<div class="compose-area" contenteditable="true" style="min-height: 100px; padding: 10px; border: 1px solid #e5e7eb; border-radius: 4px;"></div>`;
}
composeBodyRef.current.innerHTML = content; composeBodyRef.current.innerHTML = content;
setIsInitialized(true); setIsInitialized(true);
@ -119,7 +132,7 @@ export default function ComposeEmail({
(composeArea as HTMLElement).focus(); (composeArea as HTMLElement).focus();
} }
} }
}, [composeBody, replyTo, forwardFrom, isInitialized, initialBody]); }, [composeBody, replyTo, forwardFrom, isInitialized]);
// Modified input handler to work with the single contentEditable area // Modified input handler to work with the single contentEditable area
const handleInput = (e: React.FormEvent<HTMLDivElement>) => { const handleInput = (e: React.FormEvent<HTMLDivElement>) => {