build fix
This commit is contained in:
parent
41185d8586
commit
27a729f986
@ -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(/ /g, ' ')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/&/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
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user