courrier clean 2$
This commit is contained in:
parent
96cf29b98b
commit
88020ccfe5
@ -186,9 +186,15 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
|||||||
setEmailContent(content);
|
setEmailContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Focus editor after initializing
|
// Focus editor after initializing content
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (editorRef.current) {
|
// For new messages, focus the textarea
|
||||||
|
if (!type || type === 'new') {
|
||||||
|
const textarea = document.querySelector('textarea');
|
||||||
|
textarea?.focus();
|
||||||
|
}
|
||||||
|
// For replies/forwards, focus the contentEditable div
|
||||||
|
else if (['reply', 'reply-all', 'forward'].includes(type) && editorRef.current) {
|
||||||
editorRef.current.focus();
|
editorRef.current.focus();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -288,6 +294,11 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
|||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add a handler for textarea changes
|
||||||
|
const handleTextareaChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
|
setEmailContent(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
const handleSend = async () => {
|
const handleSend = async () => {
|
||||||
if (!to) {
|
if (!to) {
|
||||||
@ -298,12 +309,18 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
|||||||
try {
|
try {
|
||||||
setSending(true);
|
setSending(true);
|
||||||
|
|
||||||
|
// For new emails, emailContent is already set via onChange
|
||||||
|
// For replies/forwards, we need to get content from editorRef
|
||||||
|
const finalContent = type === 'new'
|
||||||
|
? emailContent
|
||||||
|
: editorRef.current?.innerHTML || emailContent;
|
||||||
|
|
||||||
await onSend({
|
await onSend({
|
||||||
to,
|
to,
|
||||||
cc: cc || undefined,
|
cc: cc || undefined,
|
||||||
bcc: bcc || undefined,
|
bcc: bcc || undefined,
|
||||||
subject,
|
subject,
|
||||||
body: emailContent,
|
body: finalContent,
|
||||||
attachments
|
attachments
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -411,21 +428,39 @@ export default function ComposeEmail(props: ComposeEmailAllProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Email Body Editor - using same approach as Input components */}
|
{/* Email Body Editor - different approach based on type */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<label htmlFor="body" className="text-sm font-medium">Message</label>
|
<label htmlFor="body" className="text-sm font-medium">Message</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="border rounded-md overflow-hidden">
|
{/* For new emails, use textarea for better text direction */}
|
||||||
<textarea
|
{type === 'new' ? (
|
||||||
value={emailContent}
|
<div className="border rounded-md overflow-hidden">
|
||||||
onChange={(e) => setEmailContent(e.target.value)}
|
<textarea
|
||||||
className="w-full p-4 min-h-[300px] focus:outline-none resize-none"
|
value={emailContent}
|
||||||
placeholder="Write your message here..."
|
onChange={handleTextareaChange}
|
||||||
disabled={sending}
|
className="w-full p-4 min-h-[300px] focus:outline-none resize-none"
|
||||||
/>
|
placeholder="Write your message here..."
|
||||||
</div>
|
disabled={sending}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
/* For replies and forwards, use contentEditable to preserve formatting */
|
||||||
|
<div className="border rounded-md overflow-hidden">
|
||||||
|
<div
|
||||||
|
ref={editorRef}
|
||||||
|
contentEditable={!sending}
|
||||||
|
className="w-full p-4 min-h-[300px] focus:outline-none"
|
||||||
|
onInput={handleEditorInput}
|
||||||
|
dangerouslySetInnerHTML={{ __html: emailContent }}
|
||||||
|
dir="auto"
|
||||||
|
style={{
|
||||||
|
textAlign: 'initial',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Attachments section */}
|
{/* Attachments section */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user