fix: optimize htmlToPlainText function using DOMParser

This commit is contained in:
Linus Rath
2026-04-02 17:32:53 +02:00
parent 2d17ca71e3
commit 9d8c6044e3
+2 -3
View File
@@ -34,9 +34,8 @@ import { RichTextEditor } from "@/components/email/rich-text-editor";
/** Strip HTML tags and decode entities to get a plain-text version */ /** Strip HTML tags and decode entities to get a plain-text version */
function htmlToPlainText(html: string): string { function htmlToPlainText(html: string): string {
const tmp = document.createElement('div'); const doc = new DOMParser().parseFromString(html, 'text/html');
tmp.innerHTML = html; return doc.body.textContent || '';
return tmp.textContent || tmp.innerText || '';
} }
export interface ComposerDraftData { export interface ComposerDraftData {