---------- 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}
+
+ ${emailContent}
+
`;
@@ -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')) {