diff --git a/apps/web/src/components/input/rich-input-whitespace.ts b/apps/web/src/components/input/rich-input-whitespace.ts index 27fd94be8..c8490d428 100644 --- a/apps/web/src/components/input/rich-input-whitespace.ts +++ b/apps/web/src/components/input/rich-input-whitespace.ts @@ -53,8 +53,7 @@ const isPreservableTextBlock = (node: ProseMirrorNode) => // Mark real text blocks before ProseMirror collapses their whitespace. Containers // that its parser turns into paragraphs need the same explicit block boundary. const markPastedHtml = (html: string) => { - const root = document.createElement("div"); - root.innerHTML = html; + const root = new DOMParser().parseFromString(html, "text/html").body; const blockTags = /^(P|H[1-6]|DIV|BLOCKQUOTE|UL|OL|LI|PRE|HR|TABLE)$/; const normalize = (container: HTMLElement) => { let paragraph: HTMLParagraphElement | undefined; diff --git a/packages/pdf/src/templates/shared/rich-text-html.test.ts b/packages/pdf/src/templates/shared/rich-text-html.test.ts index f5f041b8f..2f2ca3b68 100644 --- a/packages/pdf/src/templates/shared/rich-text-html.test.ts +++ b/packages/pdf/src/templates/shared/rich-text-html.test.ts @@ -28,7 +28,7 @@ describe("normalizeRichTextHtml", () => { it("does not reinterpret marked RTL line breaks as pseudo-bullet lists", () => { const html = '
- First
- Second
- First
- Second
\u200f - First
- Second