From 4c39241d3cf799bf3e44d8480da90e22be3a1f3c Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 30 Apr 2025 20:32:24 +0200 Subject: [PATCH] courrier formatting --- components/email/EmailPreview.tsx | 45 +++++++++++----- lib/utils/email-content.ts | 86 ++++++++++++++++++++++++++++--- 2 files changed, 110 insertions(+), 21 deletions(-) diff --git a/components/email/EmailPreview.tsx b/components/email/EmailPreview.tsx index fc4bbc9b..2ce03bcf 100644 --- a/components/email/EmailPreview.tsx +++ b/components/email/EmailPreview.tsx @@ -222,27 +222,46 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
-
+
+ {formattedContent ? ( +
+ ) : ( +
+

This email does not contain any content.

+
+ )} +
+ + {process.env.NODE_ENV === 'development' && ( +
+ Email Debug Info +
+

Email ID: {email.id}

+

Content Type: { + typeof email.content === 'object' && email.content?.html + ? 'HTML' + : 'Plain Text' + }

+

Content Size: { + typeof email.content === 'object' + ? `HTML: ${email.content?.html?.length || 0} chars, Text: ${email.content?.text?.length || 0} chars` + : `${typeof email.content === 'string' ? email.content.length : 0} chars` + }

+
+
+ )}
diff --git a/lib/utils/email-content.ts b/lib/utils/email-content.ts index 0c30aa81..b6ceb09a 100644 --- a/lib/utils/email-content.ts +++ b/lib/utils/email-content.ts @@ -46,22 +46,50 @@ export function formatEmailContent(email: any): string { textContent = ''; } + // Log what we found for debugging + console.log(`Email content detected: isHtml=${isHtml}, contentLength=${content.length}, textLength=${textContent.length}`); + // If we have HTML content, sanitize and standardize it if (isHtml && content) { + // Make sure we have a complete HTML structure + const hasHtmlTag = content.includes('