courrier refactor rebuild preview

This commit is contained in:
alma 2025-04-27 00:28:10 +02:00
parent 3c4151335b
commit 9970c7b4c9

View File

@ -9,11 +9,9 @@ import { sanitizeHtml } from '@/lib/utils/email-formatter';
import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { AvatarImage } from '@/components/ui/avatar'; import { AvatarImage } from '@/components/ui/avatar';
import { Card } from '@/components/ui/card'; import { Card } from '@/components/ui/card';
import { formatDate } from '@/lib/date';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { CalendarIcon, PaperclipIcon } from 'lucide-react'; import { CalendarIcon, PaperclipIcon } from 'lucide-react';
import Link from 'next/link'; import Link from 'next/link';
import { formatEmailContent } from '@/lib/email-formatter';
interface EmailAddress { interface EmailAddress {
name: string; name: string;
@ -121,8 +119,8 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
const sender = email.from && email.from.length > 0 ? email.from[0] : undefined; const sender = email.from && email.from.length > 0 ? email.from[0] : undefined;
// Format email content for display // Use sanitizeHtml directly, matching the approach in ComposeEmail
const formattedContent = formatEmailContent(email.content, 'preview'); const sanitizedContent = sanitizeHtml(email.content || email.html || email.text || '');
return ( return (
<Card className="flex flex-col h-full overflow-hidden border-0 shadow-none"> <Card className="flex flex-col h-full overflow-hidden border-0 shadow-none">
@ -212,10 +210,12 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
)} )}
style={{ style={{
overflowWrap: 'break-word', overflowWrap: 'break-word',
wordBreak: 'break-word' wordBreak: 'break-word',
textAlign: 'right'
}} }}
dir="rtl"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: formattedContent __html: sanitizedContent
}} }}
/> />
) : ( ) : (