From 6498f7ca65e0c746df4e97c778786fd88357c862 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 1 May 2025 20:40:00 +0200 Subject: [PATCH] courrier preview --- components/email/ComposeEmail.tsx | 106 +++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/components/email/ComposeEmail.tsx b/components/email/ComposeEmail.tsx index 5366bf19..17cfcacc 100644 --- a/components/email/ComposeEmail.tsx +++ b/components/email/ComposeEmail.tsx @@ -317,12 +317,39 @@ export default function ComposeEmail(props: ComposeEmailProps) { setSending(true); try { + // Generate the final email content + let finalContent = emailContent; + + // For reply or forward, combine the user's new content with the quoted content + if (type === 'reply' || type === 'reply-all' || type === 'forward') { + // Get the new content from the editor + const editorContent = document.querySelector('.ql-editor')?.innerHTML || ''; + + // Get the original header (either reply or forward header) + const headerContent = type === 'forward' + ? emailContent.split(']*>([\s\S]*?)<\/blockquote>/i); + const quotedContent = quotedMatch ? quotedMatch[0] : ''; + + // Combine them + finalContent = ` +
+ ${editorContent} +
+ ${headerContent} + ${quotedContent} + `; + } + await onSend({ to, cc: cc || undefined, bcc: bcc || undefined, subject, - body: emailContent, + body: finalContent, fromAccount: selectedAccount?.id, attachments }); @@ -483,14 +510,75 @@ export default function ComposeEmail(props: ComposeEmailProps) { {/* Message Body */} - + {(type === 'forward' || type === 'reply' || type === 'reply-all') ? ( +
+ {/* Editable area for user's reply */} +
+ +
+ + {/* Read-only display of original email with professional formatting */} +
+ {type === 'reply' || type === 'reply-all' ? ( +
+ {/* Get the reply header from the email content */} + {initialEmail && ( +
+ )} +
+ ) : type === 'forward' ? ( +
+ {/* Get the forward header from the email content */} + {initialEmail && ( +
+ )} +
+ ) : null} + + {/* Display the original content with the same quality as Panel 3 */} +
+ {initialEmail && initialEmail.content && ( + + )} +
+
+ + {/* Hidden field to store the complete content for sending */} + +
+ ) : ( + // Regular editor for new emails + + )} {/* Attachments */} {attachments.length > 0 && (