diff --git a/components/email/EmailContentDisplay.tsx b/components/email/EmailContentDisplay.tsx deleted file mode 100644 index c1e4c54e..00000000 --- a/components/email/EmailContentDisplay.tsx +++ /dev/null @@ -1,181 +0,0 @@ -'use client'; - -import React, { useEffect, useState } from 'react'; -import DOMPurify from 'dompurify'; -import { formatEmailContent } from '@/lib/utils/email-content'; -import { sanitizeHtml } from '@/lib/utils/email-formatter'; - -/** - * Interface for email content types - */ -interface ProcessedContent { - html: string; - text: string; - isHtml: boolean; -} - -/** - * Interface for component props - */ -interface EmailContentDisplayProps { - content: string; - type?: 'html' | 'text' | 'auto'; - isRawEmail?: boolean; - className?: string; -} - -/** - * Parse raw email content into HTML and text parts - * This is a helper function used when processing raw email formats - */ -function parseRawEmail(rawContent: string): { html: string; text: string } { - // Simple parser for demonstration - in production, use a proper MIME parser - const hasHtmlPart = rawContent.includes('/i) || - rawContent.match(/
/i); - - if (htmlMatch) { - htmlPart = htmlMatch[0]; - } else { - // Fallback extraction - const parts = rawContent.split(/(?:--boundary|\r\n\r\n)/); - htmlPart = parts.find(part => - part.includes('Content-Type: text/html') || - part.includes(']+>/g, ' ').replace(/\s+/g, ' ').trim() - }; - } - - return { - html: '', - text: rawContent - }; -} - -/** - * EmailContentDisplay component - displays formatted email content - * with proper security, styling and support for different email formats - */ -const EmailContentDisplay: React.FCThis email does not contain any content.
-This email does not contain any content.
+Email ID: {email.id}
Content Type: { typeof email.content === 'object' && email.content?.html diff --git a/lib/utils/email-content.ts b/lib/utils/email-content.ts index b6ceb09a..56b61adc 100644 --- a/lib/utils/email-content.ts +++ b/lib/utils/email-content.ts @@ -51,12 +51,12 @@ export function formatEmailContent(email: any): string { // If we have HTML content, sanitize and standardize it if (isHtml && content) { - // Make sure we have a complete HTML structure + // CRITICAL FIX: Check for browser environment since DOMParser is browser-only const hasHtmlTag = content.includes(' { + return `src="data:image/png;base64,${p1.replace(/\s+/g, '')}"`; + }); // Check for RTL content and set appropriate direction const rtlLangPattern = /[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/; const containsRtlText = rtlLangPattern.test(textContent); const dirAttribute = containsRtlText ? 'dir="rtl"' : 'dir="ltr"'; - // Wrap the content in standard email container with responsive styling - return ` -
') // Convert multiple newlines to paragraphs
.replace(/
<\/p>/g, '
/g, '
'); // Fix any
combinations
-
- return `
-
${formattedText}
-${formattedText}
Error displaying email content
-${error instanceof Error ? error.message : 'Unknown error'}
-Error displaying email content
${error instanceof Error ? error.message : 'Unknown error'}