From 84a2e5380caaae749a172fad18fd1ea0f93a8714 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 23 Jun 2022 15:55:42 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5267 --- app/src/protyle/util/selection.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 398072b39..07b88bc96 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -409,12 +409,17 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar if (type === "NodeThematicBreak") { range.selectNodeContents(element.firstElementChild); setRange = true; - } else if (type === "NodeBlockQueryEmbed" && element.lastElementChild.previousElementSibling) { - range.selectNodeContents(element.lastElementChild.previousElementSibling); + } else if (type === "NodeBlockQueryEmbed") { + if (element.lastElementChild.previousElementSibling) { + range.selectNodeContents(element.lastElementChild.previousElementSibling); + } else { + // https://github.com/siyuan-note/siyuan/issues/5267 + range.selectNodeContents(element); + } setRange = true; } else if (["NodeMathBlock", "NodeHTMLBlock"].includes(type)) { - // https://ld246.com/article/1655714737572 if (element.lastElementChild.previousElementSibling?.lastElementChild) { + // https://ld246.com/article/1655714737572 range.selectNodeContents(element.lastElementChild.previousElementSibling.lastElementChild); } else if (element.lastElementChild.previousElementSibling) { range.selectNodeContents(element.lastElementChild.previousElementSibling);