From eb5600019ab1be0d0cfb0e718f9591819ddf3c7c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 28 Sep 2022 11:35:06 +1000 Subject: [PATCH] Revert "Fix/autofix empty div (#2066)" This reverts commit 892c9f6da83eb9af087b33c7a9a7c6ad792b18fd. Reverting until #2093 can be addressed --- ts/editor/rich-text-input/transform.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ts/editor/rich-text-input/transform.ts b/ts/editor/rich-text-input/transform.ts index a49bf432e..33ce0afb8 100644 --- a/ts/editor/rich-text-input/transform.ts +++ b/ts/editor/rich-text-input/transform.ts @@ -19,7 +19,7 @@ function adjustInputHTML(html: string): string { function adjustInputFragment(fragment: DocumentFragment): void { if (nodeContainsInlineContent(fragment)) { - fragment.append(document.createElement("br")); + fragment.appendChild(document.createElement("br")); } } @@ -35,16 +35,12 @@ export function storedToFragment(storedHTML: string): DocumentFragment { function adjustOutputFragment(fragment: DocumentFragment): void { if ( + fragment.hasChildNodes() && + nodeIsElement(fragment.lastChild!) && nodeContainsInlineContent(fragment) && - fragment.lastChild && - nodeIsElement(fragment.lastChild) && - fragment.lastChild.tagName === "BR" + fragment.lastChild!.tagName === "BR" ) { - fragment.lastChild.remove(); - } - - for (const divElement of fragment.querySelectorAll("div:empty")) { - divElement.remove(); + fragment.lastChild!.remove(); } }