courrier refactor rebuild preview

This commit is contained in:
alma 2025-04-27 00:40:58 +02:00
parent cb3e119a5d
commit bb97f9b364
2 changed files with 50 additions and 6 deletions

View File

@ -187,3 +187,40 @@
margin-bottom: 15px;
}
/* Special classes used in the email formatting functions */
.email-content-display .reply-body {
width: 100%;
direction: rtl;
text-align: right;
font-family: Arial, sans-serif;
}
.email-content-display .quote-header {
color: #555;
font-size: 13px;
margin: 20px 0 10px 0;
font-weight: 500;
}
.email-content-display .quoted-content {
font-size: 13px;
direction: rtl;
text-align: right;
}
.email-content-display .email-original-content {
margin-top: 10px;
padding-top: 10px;
text-align: right;
direction: rtl;
}
/* Fix styles for the content in both preview and compose */
.email-content-display[contenteditable="false"] {
/* Same styles as contentEditable=true to ensure consistency */
white-space: pre-wrap;
word-break: break-word;
direction: rtl;
text-align: right;
}

View File

@ -126,14 +126,21 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
// Get the raw content directly
const rawContent = email.content || email.html || email.text || '';
// Now use the same content that would be shown in a reply
// This is exactly what ComposeEmail shows
const { content } = formatReplyEmail(formatterEmail, 'reply');
// First try to use the raw content, but apply the same styling
const formattedWithStyles = `
<div style="min-height: 20px;" dir="rtl">
<div class="reply-body">
<div class="email-original-content" dir="rtl">
${rawContent}
</div>
</div>
</div>
`;
console.log("Formatted content for display:", content.substring(0, 200));
console.log("Formatted content for display");
// Use the formatted content that includes the proper structure
setFormattedContent(content);
// Use the formatted content with proper structure
setFormattedContent(formattedWithStyles);
} catch (error) {
console.error('Error formatting email content:', error);
// Fallback to raw content if formatting fails