From 591966284d711ee5d09911fedb47cad1969cb8f6 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 24 Apr 2025 17:12:24 +0200 Subject: [PATCH] mime change --- components/ComposeEmail.tsx | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx index a2eb300d..9ba66c25 100644 --- a/components/ComposeEmail.tsx +++ b/components/ComposeEmail.tsx @@ -83,26 +83,39 @@ export default function ComposeEmail({ useEffect(() => { if (composeBodyRef.current && !isInitialized) { - // Initialize the content structure with both new reply area and original content in a single contentEditable div - const content = replyTo || forwardFrom ? ` -
${initialBody || ''}
-
- ${forwardFrom ? ` - ---------- Forwarded message ---------
- From: ${forwardFrom.from}
- Date: ${new Date(forwardFrom.date).toLocaleString()}
- Subject: ${forwardFrom.subject}
- To: ${forwardFrom.to}
- ${forwardFrom.cc ? `Cc: ${forwardFrom.cc}
` : ''} -
- ` : ` - On ${new Date(replyTo?.date || '').toLocaleString()}, ${replyTo?.from} wrote:
- `} -
- ${composeBody} -
-
- ` : `
${initialBody || ''}
`; + let content = ''; + + if (replyTo || forwardFrom) { + // Get the original email content + const originalContent = replyTo?.body || forwardFrom?.body || ''; + + // Create the reply/forward structure + content = ` +
+
+ ${forwardFrom ? ` +
+ ---------- Forwarded message ---------
+ From: ${forwardFrom.from}
+ Date: ${new Date(forwardFrom.date).toLocaleString()}
+ Subject: ${forwardFrom.subject}
+ To: ${forwardFrom.to}
+ ${forwardFrom.cc ? `Cc: ${forwardFrom.cc}
` : ''} +
+ ` : ` +
+ On ${new Date(replyTo?.date || '').toLocaleString()}, ${replyTo?.from} wrote: +
+ `} +
+ ${originalContent} +
+
+ `; + } else { + // For new messages + content = `
`; + } composeBodyRef.current.innerHTML = content; setIsInitialized(true); @@ -119,7 +132,7 @@ export default function ComposeEmail({ (composeArea as HTMLElement).focus(); } } - }, [composeBody, replyTo, forwardFrom, isInitialized, initialBody]); + }, [composeBody, replyTo, forwardFrom, isInitialized]); // Modified input handler to work with the single contentEditable area const handleInput = (e: React.FormEvent) => {