mail page rest

This commit is contained in:
alma 2025-04-21 15:13:56 +02:00
parent 3702908cdf
commit 269b971ac6

View File

@ -874,9 +874,31 @@ export default function CourrierPage() {
return ( return (
<div> <div>
{/* Display HTML content if available, otherwise fallback to text */} {/* Display HTML content if available, otherwise fallback to text */}
<div dangerouslySetInnerHTML={{ {parsed.html ? (
__html: parsed.html || parsed.text || decodeMimeContent(selectedEmail.body) <div
}} /> className="prose prose-sm sm:prose lg:prose-lg xl:prose-xl dark:prose-invert max-w-none"
dangerouslySetInnerHTML={{
__html: parsed.html
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
.replace(/<base[^>]*>/gi, '')
.replace(/<meta[^>]*>/gi, '')
.replace(/<link[^>]*>/gi, '')
.replace(/<title[^>]*>[\s\S]*?<\/title>/gi, '')
.replace(/<head[^>]*>[\s\S]*?<\/head>/gi, '')
.replace(/<body[^>]*>/gi, '')
.replace(/<\/body>/gi, '')
.replace(/<html[^>]*>/gi, '')
.replace(/<\/html>/gi, '')
}}
/>
) : (
<div className="whitespace-pre-wrap font-sans text-base leading-relaxed">
{(parsed.text || '').split('\n').map((line, i) => (
<p key={i} className="mb-2">{line}</p>
))}
</div>
)}
{/* Display attachments if present */} {/* Display attachments if present */}
{parsed.attachments && parsed.attachments.length > 0 && ( {parsed.attachments && parsed.attachments.length > 0 && (
@ -898,7 +920,7 @@ export default function CourrierPage() {
); );
} catch (e) { } catch (e) {
console.error('Error parsing email:', e); console.error('Error parsing email:', e);
return selectedEmail.body; return <div className="text-gray-500">Error displaying email content</div>;
} }
})()} })()}
</div> </div>