From cfd984d0aabb98e8905356929fafaa95b57dcfaf Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 21 Apr 2025 21:07:03 +0200 Subject: [PATCH] mail page fix design --- app/courrier/page.tsx | 46 ++++++++++++++++++++++++++----------- components/ComposeEmail.tsx | 7 +++--- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 07349d7f..b1647b2e 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -370,11 +370,20 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward' = 'r decodedContent = convertCharset(partBody, partHeaderInfo.charset); } + // Preserve the original MIME structure if (partHeaderInfo.contentType.includes('text/html')) { - content = decodedContent; + content = ` +
+ ${decodedContent} +
+ `; break; } else if (partHeaderInfo.contentType.includes('text/plain') && !content) { - content = decodedContent; + content = ` +
+
${decodedContent}
+
+ `; } } catch (error) { console.error('Error decoding email part:', error); @@ -383,43 +392,54 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward' = 'r } else { // Handle simple email try { + let decodedBody = ''; if (headerInfo.encoding === 'base64') { - content = decodeBase64(body, headerInfo.charset); + decodedBody = decodeBase64(body, headerInfo.charset); } else if (headerInfo.encoding === 'quoted-printable') { - content = decodeQuotedPrintable(body, headerInfo.charset); + decodedBody = decodeQuotedPrintable(body, headerInfo.charset); } else { - content = convertCharset(body, headerInfo.charset); + decodedBody = convertCharset(body, headerInfo.charset); } + + content = ` +
+ ${headerInfo.contentType.includes('text/html') ? decodedBody : `
${decodedBody}
`} +
+ `; } catch (error) { console.error('Error decoding email body:', error); content = body; } } - // Clean and sanitize HTML content + // Clean and sanitize HTML content while preserving structure content = cleanHtml(content); - // Format the reply/forward content + // Format the reply/forward content with proper structure and direction let formattedContent = ''; if (type === 'forward') { formattedContent = ` -
-
+ `; } else { formattedContent = ` -
-
+ `; diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx index dc0863c0..fba828e2 100644 --- a/components/ComposeEmail.tsx +++ b/components/ComposeEmail.tsx @@ -258,20 +258,19 @@ export default function ComposeEmail({ )} {/* Message Body */} -
+