Neah version mail design fix 7 bis ?

This commit is contained in:
alma 2025-04-16 19:10:31 +02:00
parent bb57ada490
commit 6ad6c87033

View File

@ -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(/<style[^>]*>[\s\S]*?<\/style>/gi, '') // Remove style tags
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '') // Remove script tags
.replace(/<[^>]+>/g, '') // Remove HTML tags
.replace(/&nbsp;|&zwnj;|&raquo;|&laquo;|&gt;/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