diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx
index f3280bd7..6cdeaf2a 100644
--- a/components/ComposeEmail.tsx
+++ b/components/ComposeEmail.tsx
@@ -83,45 +83,26 @@ export default function ComposeEmail({
useEffect(() => {
if (composeBodyRef.current && !isInitialized) {
- let content = '';
-
- if (replyTo) {
- // For replies
- content = `
-
-
- On ${new Date(replyTo.date).toLocaleString()}, ${replyTo.from} wrote:
-
-
- ${composeBody}
-
-
- `;
- } else if (forwardFrom) {
- // For forwards
- content = `
-
-
- ---------- Forwarded message ---------
- From: ${forwardFrom.from}
- Date: ${new Date(forwardFrom.date).toLocaleString()}
- Subject: ${forwardFrom.subject}
- To: ${forwardFrom.to}
- ${forwardFrom.cc ? `Cc: ${forwardFrom.cc}
` : ''}
-
-
- ${composeBody}
-
-
- `;
- } else {
- // For new messages
- 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:
+ `}
+
+ ${composeBody}
+
+
+ ` : '';
composeBodyRef.current.innerHTML = content;
setIsInitialized(true);
@@ -135,20 +116,16 @@ export default function ComposeEmail({
range.collapse(true);
sel?.removeAllRanges();
sel?.addRange(range);
- (composeArea as HTMLElement).focus();
}
}
}, [composeBody, replyTo, forwardFrom, isInitialized]);
+ // Modified input handler to work with the single contentEditable area
const handleInput = (e: React.FormEvent