courrier clean 2
This commit is contained in:
parent
195f8b7115
commit
c325d3cdf7
@ -86,6 +86,13 @@ export default function ComposeEmail({
|
|||||||
}: ComposeEmailProps) {
|
}: ComposeEmailProps) {
|
||||||
const [isSending, setIsSending] = useState(false);
|
const [isSending, setIsSending] = useState(false);
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const contentEditableRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [useRichEditor, setUseRichEditor] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// When forwarding or replying, use rich editor
|
||||||
|
setUseRichEditor(!!replyTo || !!forwardFrom);
|
||||||
|
}, [replyTo, forwardFrom]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Initialize reply if replyTo is provided
|
// Initialize reply if replyTo is provided
|
||||||
@ -172,6 +179,13 @@ export default function ComposeEmail({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle contentEditable input changes
|
||||||
|
const handleContentEditableChange = () => {
|
||||||
|
if (contentEditableRef.current) {
|
||||||
|
setComposeBody(contentEditableRef.current.innerHTML);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Compose Email Modal */}
|
{/* Compose Email Modal */}
|
||||||
@ -276,16 +290,28 @@ export default function ComposeEmail({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Message Body */}
|
{/* Message Body - conditionally render either rich editor or textarea */}
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="message" className="block text-sm font-medium text-gray-700">Message</Label>
|
<Label htmlFor="message" className="block text-sm font-medium text-gray-700">Message</Label>
|
||||||
<Textarea
|
|
||||||
id="message"
|
{useRichEditor ? (
|
||||||
value={composeBody}
|
<div
|
||||||
onChange={(e) => setComposeBody(e.target.value)}
|
ref={contentEditableRef}
|
||||||
placeholder="Write your message..."
|
contentEditable
|
||||||
className="w-full mt-1 min-h-[200px] bg-white border-gray-300 text-gray-900 resize-none"
|
className="w-full mt-1 min-h-[200px] p-3 bg-white border border-gray-300 rounded-md overflow-auto text-gray-900"
|
||||||
/>
|
style={{ direction: 'ltr' }}
|
||||||
|
dangerouslySetInnerHTML={{ __html: composeBody }}
|
||||||
|
onInput={handleContentEditableChange}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Textarea
|
||||||
|
id="message"
|
||||||
|
value={composeBody}
|
||||||
|
onChange={(e) => setComposeBody(e.target.value)}
|
||||||
|
placeholder="Write your message..."
|
||||||
|
className="w-full mt-1 min-h-[200px] bg-white border-gray-300 text-gray-900 resize-none"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user