build fix

This commit is contained in:
alma 2025-05-05 17:57:14 +02:00
parent 41185d8586
commit 27a729f986

View File

@ -61,4 +61,34 @@ export function applyTextDirection(htmlContent: string, textContent?: string): s
// Otherwise, wrap the content with a direction-aware container
return `<div class="email-content" dir="${direction}">${htmlContent}</div>`;
}
/**
* Process content to determine direction and return direction-enhanced HTML
*
* @param content Content to process (HTML or plain text)
* @returns Object containing processed HTML and detected direction
*/
export function processContentWithDirection(content: string | undefined): { html: string; direction: 'ltr' | 'rtl' } {
if (!content) {
return { html: '', direction: 'ltr' };
}
// Extract text from the content for direction detection
const textContent = content.replace(/<[^>]*>/g, '')
.replace(/&nbsp;/g, ' ')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&');
// Detect the direction of the text
const direction = detectTextDirection(textContent);
// Apply the direction to the HTML content
const directionEnhancedHtml = applyTextDirection(content, textContent);
return {
html: directionEnhancedHtml,
direction
};
}