From 6ad6c87033dc0a274a9cabf59487393c41896550 Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 16 Apr 2025 19:10:31 +0200 Subject: [PATCH] Neah version mail design fix 7 bis ? --- app/mail/page.tsx | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/app/mail/page.tsx b/app/mail/page.tsx index e4d0c8e..dc4268a 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -1149,8 +1149,42 @@ export default function MailPage() { const getReplyBody = () => { const date = new Date(selectedEmail.date); const formattedDate = date.toLocaleString(); + + // Parse the original email content + const parsed = parseFullEmail(selectedEmail.body); + let originalContent = ''; + + // Get the content from either HTML or text part + if (parsed.html) { + // Convert HTML to plain text for the reply + originalContent = parsed.html + .replace(/]*>[\s\S]*?<\/style>/gi, '') // Remove style tags + .replace(/]*>[\s\S]*?<\/script>/gi, '') // Remove script tags + .replace(/<[^>]+>/g, '') // Remove HTML tags + .replace(/ |‌|»|«|>/g, ' ') // Convert HTML entities to spaces + .replace(/^\s+$/gm, '') // Remove lines with only whitespace + .replace(/\n{3,}/g, '\n\n') // Normalize multiple line breaks + .trim(); + } else if (parsed.text) { + originalContent = parsed.text.trim(); + } else { + // Fallback to raw body if parsing fails + originalContent = selectedEmail.body + .replace(/<[^>]+>/g, '') + .trim(); + } + + // Format the reply const separator = '\n\n------------ Original Message ------------\n'; - return `${separator}On ${formattedDate}, ${selectedEmail.from} wrote:\n${selectedEmail.body}`; + const header = `On ${formattedDate}, ${selectedEmail.from} wrote:\n`; + + // Indent the original content + const indentedContent = originalContent + .split('\n') + .map(line => `> ${line}`) + .join('\n'); + + return `${separator}${header}${indentedContent}`; }; // Open compose modal with reply details