From b1dcfe68451ce4b2c45efe316364c0022476b7ba Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 1 Aug 2022 11:30:43 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E9=81=87=E5=88=B0=20br=20=E6=97=B6?= =?UTF-8?q?=E5=85=A8=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/util/selection.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 30ef60014..aafc0e0a1 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -52,21 +52,22 @@ export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range) firstChild = firstChild.firstChild; } } - let lastChild = editElement.lastChild; + let lastChild = editElement.lastChild as HTMLElement; while (lastChild) { if (lastChild.nodeType === 3) { if (lastChild.textContent !== "") { range.setEnd(lastChild, lastChild.textContent.length); break; } - lastChild = lastChild.previousSibling; + lastChild = lastChild.previousSibling as HTMLElement; } else { - if ((lastChild as HTMLElement).classList.contains("render-node") || - (lastChild as HTMLElement).classList.contains("img")) { + if (lastChild.classList.contains("render-node") || + lastChild.classList.contains("img") || + lastChild.tagName === "BR") { range.setEndAfter(lastChild); break; } - lastChild = lastChild.lastChild; + lastChild = lastChild.lastChild as HTMLElement; } } protyle.toolbar.render(protyle, range);