From 935b1a3f76365c29251f5eed015dc07dbfd09c7e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 12 May 2024 21:47:50 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/11362 --- app/src/protyle/util/selection.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 7f0f280b9..a9410f299 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -588,6 +588,13 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar lastNode = hasPreviousSibling(cursorElement.lastChild) as HTMLElement; } if (lastNode && lastNode.textContent.endsWith("\n")) { + // https://github.com/siyuan-note/siyuan/issues/11362 + if (lastNode.nodeType === 1) { + lastNode = lastNode.lastChild; + while (lastNode && lastNode.textContent.indexOf("\n") === -1) { + lastNode = lastNode.previousSibling; + } + } range = getEditorRange(cursorElement); range.setStart(lastNode, lastNode.textContent.length - 1); focusHljs = true;