From ecff1bc3b76ec793610550d257f01a331bc897e8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 20 Jun 2022 22:31:54 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5248 --- app/src/protyle/util/selection.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index f3c169c46..398072b39 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -412,8 +412,13 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar } else if (type === "NodeBlockQueryEmbed" && element.lastElementChild.previousElementSibling) { range.selectNodeContents(element.lastElementChild.previousElementSibling); setRange = true; - } else if (["NodeMathBlock", "NodeHTMLBlock"].includes(type) && element.lastElementChild.previousElementSibling?.lastElementChild) { - range.selectNodeContents(element.lastElementChild.previousElementSibling.lastElementChild); + } else if (["NodeMathBlock", "NodeHTMLBlock"].includes(type)) { + // https://ld246.com/article/1655714737572 + if (element.lastElementChild.previousElementSibling?.lastElementChild) { + range.selectNodeContents(element.lastElementChild.previousElementSibling.lastElementChild); + } else if (element.lastElementChild.previousElementSibling) { + range.selectNodeContents(element.lastElementChild.previousElementSibling); + } setRange = true; } else if (type === "NodeIFrame" || type === "NodeWidget") { range.setStart(element, 0);