fix: optimize htmlToPlainText function using DOMParser
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user