fix rtl and ltr text in new message
This commit is contained in:
@@ -47,11 +47,15 @@ const EmailEditor: FC<EmailEditorProps> = ({
|
||||
line-height: 1.6;
|
||||
min-height: 120px;
|
||||
}
|
||||
.ql-editor p {
|
||||
.ql-editor p, .ql-editor div, .ql-editor span {
|
||||
unicode-bidi: plaintext;
|
||||
text-align: start;
|
||||
direction: auto;
|
||||
}
|
||||
.ql-editor br + * {
|
||||
direction: auto;
|
||||
unicode-bidi: plaintext;
|
||||
}
|
||||
.ql-editor.ql-blank::before {
|
||||
direction: rtl;
|
||||
text-align: right;
|
||||
|
||||
@@ -9,6 +9,7 @@ import { SendEmailDto, EmailAttachmentDto } from "@/pages/received/types/Types";
|
||||
import { useUpdateDraft, useSendDraft } from "@/pages/draft/hooks/useDraftData";
|
||||
import { toast } from "@/components/Toast";
|
||||
import { useEmailSuggestions } from "./useEmailSuggestions";
|
||||
import { detectTextDirection } from "@/helpers/utils";
|
||||
|
||||
export const useNewMessage = () => {
|
||||
const {
|
||||
@@ -143,13 +144,13 @@ export const useNewMessage = () => {
|
||||
try {
|
||||
let messageId = "";
|
||||
if (isEditingDraft) {
|
||||
const contentString = ensureString(content);
|
||||
const textDirection = detectTextDirection(contentString);
|
||||
const draftUpdateData = {
|
||||
to: parseEmailAddresses(toEmails),
|
||||
subject,
|
||||
html: `<div dir="auto" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${ensureString(
|
||||
content
|
||||
)}</div>`,
|
||||
text: ensureString(content).replace(/<[^>]*>/g, ""),
|
||||
html: `<div dir="${textDirection}" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${contentString}</div>`,
|
||||
text: contentString.replace(/<[^>]*>/g, ""),
|
||||
...(attachments.length > 0 && { attachments }),
|
||||
};
|
||||
|
||||
@@ -172,9 +173,7 @@ export const useNewMessage = () => {
|
||||
messageId: editingDraftId.toString(),
|
||||
draftData: {
|
||||
...draftUpdateData,
|
||||
html: `<div dir="auto" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${ensureString(
|
||||
content
|
||||
)}</div>`,
|
||||
html: `<div dir="${textDirection}" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${contentString}</div>`,
|
||||
isDraft: true,
|
||||
uploadOnly: true,
|
||||
},
|
||||
@@ -196,14 +195,14 @@ export const useNewMessage = () => {
|
||||
setEditingDraftId(null);
|
||||
return true;
|
||||
} else {
|
||||
const contentString = ensureString(content);
|
||||
const textDirection = detectTextDirection(contentString);
|
||||
const emailData: SendEmailDto = {
|
||||
from: { address: userEmail || "sender@example.com" },
|
||||
to: parseEmailAddresses(toEmails),
|
||||
subject,
|
||||
html: `<div dir="auto" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${ensureString(
|
||||
content
|
||||
)}</div>`,
|
||||
text: ensureString(content).replace(/<[^>]*>/g, ""),
|
||||
html: `<div dir="${textDirection}" style="text-align: start; unicode-bidi: plaintext; font-family: 'Irancell', 'Vazirmatn', sans-serif;">${contentString}</div>`,
|
||||
text: contentString.replace(/<[^>]*>/g, ""),
|
||||
...(attachments.length > 0 && { attachments }),
|
||||
...(isDraft && { isDraft: true, uploadOnly: true }),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user