courrier clean 2$
This commit is contained in:
parent
b14b03877c
commit
1add54f457
@ -173,6 +173,7 @@ function EmailContent({ email }: { email: Email }) {
|
|||||||
<div
|
<div
|
||||||
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||||
dangerouslySetInnerHTML={{ __html: sanitizedHtml }}
|
dangerouslySetInnerHTML={{ __html: sanitizedHtml }}
|
||||||
|
dir="auto"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
setDebugInfo('Rendered fetched HTML content with centralized formatter');
|
setDebugInfo('Rendered fetched HTML content with centralized formatter');
|
||||||
@ -204,6 +205,7 @@ function EmailContent({ email }: { email: Email }) {
|
|||||||
<div
|
<div
|
||||||
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||||
dangerouslySetInnerHTML={{ __html: sanitizedHtml }}
|
dangerouslySetInnerHTML={{ __html: sanitizedHtml }}
|
||||||
|
dir="auto"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
setDebugInfo('Rendered existing HTML content with centralized formatter');
|
setDebugInfo('Rendered existing HTML content with centralized formatter');
|
||||||
@ -217,13 +219,14 @@ function EmailContent({ email }: { email: Email }) {
|
|||||||
<div
|
<div
|
||||||
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||||
dangerouslySetInnerHTML={{ __html: cleanedContent }}
|
dangerouslySetInnerHTML={{ __html: cleanedContent }}
|
||||||
|
dir="auto"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
setDebugInfo('Rendered content as HTML using centralized formatter');
|
setDebugInfo('Rendered content as HTML using centralized formatter');
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, render as plain text
|
// Otherwise, render as plain text
|
||||||
setContent(
|
setContent(
|
||||||
<div className="email-content whitespace-pre-wrap">
|
<div className="email-content whitespace-pre-wrap" dir="auto">
|
||||||
{cleanedContent}
|
{cleanedContent}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -426,7 +429,7 @@ function ReplyContent({ email, type }: { email: Email; type: 'reply' | 'reply-al
|
|||||||
return <div className="text-red-500">{error}</div>;
|
return <div className="text-red-500">{error}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div dangerouslySetInnerHTML={{ __html: content }} />;
|
return <div dangerouslySetInnerHTML={{ __html: content }} dir="auto" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function EmailPreview({ email }: { email: Email }) {
|
function EmailPreview({ email }: { email: Email }) {
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
* It provides consistent handling of email content, sanitization, and text direction.
|
* It provides consistent handling of email content, sanitization, and text direction.
|
||||||
*
|
*
|
||||||
* All code that needs to format email content should import from this file.
|
* All code that needs to format email content should import from this file.
|
||||||
* Text direction is standardized to LTR (left-to-right) for consistency.
|
* Text direction is preserved based on content language for proper RTL/LTR display.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
@ -107,14 +107,14 @@ export function formatEmailDate(date: Date | string | undefined): string {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitize HTML content before processing or displaying
|
* Sanitize HTML content before processing or displaying
|
||||||
* This ensures the content is properly formatted for LTR display
|
* This ensures the content is properly sanitized while preserving text direction
|
||||||
* @param content HTML content to sanitize
|
* @param content HTML content to sanitize
|
||||||
* @returns Sanitized HTML with LTR formatting
|
* @returns Sanitized HTML with preserved text direction
|
||||||
*/
|
*/
|
||||||
export function sanitizeHtml(content: string): string {
|
export function sanitizeHtml(content: string): string {
|
||||||
if (!content) return '';
|
if (!content) return '';
|
||||||
|
|
||||||
// Sanitize the HTML using our configured DOMPurify with LTR enforced
|
// Sanitize the HTML using our configured DOMPurify with text direction preserved
|
||||||
return DOMPurify.sanitize(content);
|
return DOMPurify.sanitize(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user