From 2cb180b7b0031bd269d20eb8750c0d4c5434df3d Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 25 Apr 2025 22:09:31 +0200 Subject: [PATCH] panel 2 courier api restore --- components/ComposeEmail.tsx | 48 +++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx index 64586e5a..7f64eb14 100644 --- a/components/ComposeEmail.tsx +++ b/components/ComposeEmail.tsx @@ -169,38 +169,50 @@ export default function ComposeEmail({ subject: decoded.subject }); - let formattedContent = ''; - + // Create the email container with header information + let emailHeader = ''; if (type === 'forward') { - // EXACTLY MATCH THE FORMAT USED IN PANEL 3 (from ReplyContent in app/courrier/page.tsx) - formattedContent = ` -
+ emailHeader = ` +

---------- Forwarded message ---------

From: ${decoded.from || ''}

Date: ${formatDate(decoded.date ? new Date(decoded.date) : null)}

Subject: ${decoded.subject || ''}

To: ${decoded.to || ''}

-
- ${decoded.html || `
${decoded.text || ''}
`}
`; } else { - formattedContent = ` -
+ emailHeader = ` +

On ${formatDate(decoded.date ? new Date(decoded.date) : null)}, ${decoded.from || ''} wrote:

-
- ${decoded.html || `
${decoded.text || ''}
`} -
`; } - + + // Get the proper content with minimal sanitization to preserve structure + let emailContent = ''; + if (decoded.html) { + // Preserve the HTML structure with minimal cleaning + emailContent = DOMPurify.sanitize(decoded.html, { + ADD_TAGS: ['style', 'meta'], + ADD_ATTR: ['class', 'id', 'style', 'align', 'border', 'cellpadding', 'cellspacing', 'width', 'height'], + KEEP_CONTENT: true, + WHOLE_DOCUMENT: false + }); + } else if (decoded.text) { + emailContent = `
${decoded.text}
`; + } else { + emailContent = '
No content available
'; + } + // Set the content in the compose area with proper structure - const sanitizedContent = DOMPurify.sanitize(formattedContent); const wrappedContent = `

- ${sanitizedContent} + ${emailHeader} +
`; @@ -220,14 +232,14 @@ export default function ComposeEmail({ } // After setting the HTML content, add event listeners for scrolling - const messageContents = composeBodyRef.current.querySelectorAll('.message-content, .forwarded-message, .quoted-message'); + const messageContents = composeBodyRef.current.querySelectorAll('.email-content'); messageContents.forEach(container => { // Make sure the container is properly styled for scrolling - (container as HTMLElement).style.maxHeight = '300px'; + (container as HTMLElement).style.maxHeight = '400px'; (container as HTMLElement).style.overflowY = 'auto'; (container as HTMLElement).style.border = '1px solid #e5e7eb'; (container as HTMLElement).style.borderRadius = '4px'; - (container as HTMLElement).style.padding = '10px'; + (container as HTMLElement).style.padding = '15px'; // Ensure wheel events are properly handled if (!(container as HTMLElement).hasAttribute('data-scroll-handler-attached')) {