`;
diff --git a/components/ComposeEmail.tsx b/components/ComposeEmail.tsx
index 418dfc0c..94a038bd 100644
--- a/components/ComposeEmail.tsx
+++ b/components/ComposeEmail.tsx
@@ -56,13 +56,26 @@ export default function ComposeEmail({
useEffect(() => {
if (composeBodyRef.current) {
const decodedContent = decodeComposeContent(composeBody);
- composeBodyRef.current.innerHTML = decodedContent;
+ composeBodyRef.current.innerHTML = decodedContent
+ .replace(/
]*>/g, '
')
+ .replace(/
]*>/g, '
');
}
}, [composeBody]);
const handleInput = (e: React.FormEvent) => {
if (composeBodyRef.current) {
- const encodedContent = encodeComposeContent(composeBodyRef.current.innerHTML);
+ const content = composeBodyRef.current.innerHTML
+ .replace(/
/g, '
')
+ .replace(//g, '
')
+ .replace(/<\/p>/g, '
')
+ .replace(//g, '
')
+ .replace(/<\/div>/g, '
')
+ .replace(/
/g, '')
+ .replace(/<\/span>/g, '');
+
+ const encodedContent = encodeComposeContent(
+ `${content}
`
+ );
setComposeBody(encodedContent);
}
};
@@ -229,6 +242,9 @@ export default function ComposeEmail({
unicodeBidi: 'bidi-override'
}}
dir="ltr"
+ data-gramm="false"
+ data-gramm_editor="false"
+ data-enable-grammarly="false"
/>
diff --git a/lib/compose-mime-decoder.ts b/lib/compose-mime-decoder.ts
index 0185bbca..03f3b9d3 100644
--- a/lib/compose-mime-decoder.ts
+++ b/lib/compose-mime-decoder.ts
@@ -6,10 +6,6 @@
export function decodeComposeContent(content: string): string {
if (!content) return '';
- // Simple text direction detection
- const hasRtlChars = /[\u0591-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC]/.test(content);
- const direction = hasRtlChars ? 'rtl' : 'ltr';
-
// Basic HTML cleaning
let cleaned = content
// Remove script and style tags
@@ -20,11 +16,8 @@ export function decodeComposeContent(content: string): string {
// Remove head and title
.replace(/]*>[\s\S]*?<\/head>/gi, '')
.replace(/
]*>[\s\S]*?<\/title>/gi, '')
- // Preserve body attributes
- .replace(/]*>/gi, (match) => {
- const dir = match.match(/dir=["'](rtl|ltr)["']/i)?.[1] || direction;
- return ``;
- })
+ // Force LTR direction
+ .replace(/]*>/gi, '')
.replace(/<\/body>/gi, '')
// Remove html tags
.replace(/]*>/gi, '')
@@ -64,8 +57,8 @@ export function decodeComposeContent(content: string): string {
.replace(/\s+/g, ' ')
.trim();
- // Wrap in a div with proper direction
- return `
${cleaned}
`;
+ // Wrap in a div with forced LTR direction
+ return `
${cleaned}
`;
}
export function encodeComposeContent(content: string): string {