- `;
-
- // Place cursor in the new reply area
- const newReplyArea = composeBodyRef.current.querySelector('#new-reply-area');
- if (newReplyArea) {
- const range = document.createRange();
- const sel = window.getSelection();
- range.setStart(newReplyArea, 0);
- range.collapse(true);
- sel?.removeAllRanges();
- sel?.addRange(range);
- }
- }
- }, [composeBody]);
-
- // Enhanced input handler to prevent text reversal
- const handleInput = (e: React.FormEvent) => {
- if (composeBodyRef.current) {
- // Get the current HTML content
- const fullContent = e.currentTarget.innerHTML;
-
- // Split at the divider to separate new reply from original content
- const parts = fullContent.split('
1) {
- // Extract user-typed content (ensuring it's not reversed)
- const userContent = parts[0];
+ // Only initialize once when empty or first loading
+ if (!composeBody || composeBody.trim() === '') {
+ // Simple structure with one area for new text and one for original
+ composeBodyRef.current.innerHTML = `
+
+