courrier clean 2
This commit is contained in:
parent
d607cc54bb
commit
c0153a2aef
@ -357,9 +357,13 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
||||
// This preserves all formatting without trying to parse it
|
||||
|
||||
// Set message parts for the editor
|
||||
setOriginalContent(initialEmail.content || initialEmail.html || initialEmail.text || '');
|
||||
setUserMessage('');
|
||||
setBody('');
|
||||
const content = initialEmail.content || initialEmail.html || initialEmail.text || '';
|
||||
setOriginalContent(content);
|
||||
setUserMessage(''); // Start with empty user message
|
||||
setBody(''); // Will be constructed when sending
|
||||
|
||||
// Log for debugging
|
||||
console.log('Set originalContent:', content.substring(0, 100) + '...');
|
||||
} catch (error) {
|
||||
console.error('Error formatting forwarded email:', error);
|
||||
setBody('<div style="color: #666; font-style: italic;">Error formatting forwarded email content</div>');
|
||||
@ -424,6 +428,36 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
||||
// Toggle original content editing
|
||||
const toggleEditOriginalContent = () => {
|
||||
setEditingOriginalContent(!editingOriginalContent);
|
||||
|
||||
// If we're starting to edit, make sure the content is ready and focused
|
||||
if (!editingOriginalContent) {
|
||||
setTimeout(() => {
|
||||
if (originalContentRef.current) {
|
||||
originalContentRef.current.focus();
|
||||
|
||||
// Place cursor at the beginning
|
||||
const selection = window.getSelection();
|
||||
const range = document.createRange();
|
||||
|
||||
if (originalContentRef.current.firstChild) {
|
||||
range.setStart(originalContentRef.current.firstChild, 0);
|
||||
} else {
|
||||
range.setStart(originalContentRef.current, 0);
|
||||
}
|
||||
range.collapse(true);
|
||||
|
||||
selection?.removeAllRanges();
|
||||
selection?.addRange(range);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
// Handling click on original content even when not in edit mode
|
||||
const handleOriginalContentClick = () => {
|
||||
if (!editingOriginalContent) {
|
||||
toggleEditOriginalContent();
|
||||
}
|
||||
};
|
||||
|
||||
// Modified send handler to combine user message with forwarded content
|
||||
@ -652,14 +686,15 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
||||
<div
|
||||
ref={originalContentRef}
|
||||
contentEditable={true}
|
||||
className="forwarded-content text-sm"
|
||||
className="forwarded-content text-sm outline-none"
|
||||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(originalContent) }}
|
||||
onInput={handleOriginalContentInput}
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className="forwarded-content text-sm"
|
||||
className="forwarded-content text-sm cursor-text"
|
||||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(originalContent) }}
|
||||
onClick={handleOriginalContentClick}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user