courrier preview

This commit is contained in:
alma 2025-05-01 16:25:56 +02:00
parent 1dbf66cdec
commit f9244f5a20

View File

@ -667,4 +667,34 @@ export function formatEmailForReplyOrForward(
} else {
return formatReplyEmail(email, type as 'reply' | 'reply-all');
}
}
// First check if Quill is fully initialized and ready
if (quillRef.current &&
quillRef.current.format &&
typeof quillRef.current.format === 'function' &&
quillRef.current.root &&
quillRef.current.root.innerHTML &&
quillRef.current.root.innerHTML.trim().length > 0) {
// Wrap formatting operations in try/catch to prevent errors from crashing the app
try {
// Delay the formatting to ensure Quill is fully ready
setTimeout(() => {
if (quillRef.current) {
// Set the direction for the content
quillRef.current.format('direction', direction);
if (direction === 'rtl') {
quillRef.current.format('align', 'right');
}
// Set selection to beginning
quillRef.current.setSelection(0, 0);
}
}, 100);
} catch (formatError) {
console.error('Error applying formatting:', formatError);
// Continue without formatting if there's an error
}
}