diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 926200eb9..956e9f9e4 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -136,6 +136,14 @@ export const getEditorRange = (element: Element) => { if (getSelection().rangeCount > 0) { range = getSelection().getRangeAt(0); if (element.isSameNode(range.startContainer) || element.contains(range.startContainer)) { + // 有时候点击编辑器头部需要矫正到第一个块中 + if (range.toString() === "" && range.startContainer.nodeType === 1 && range.startOffset === 0 && + (range.startContainer as HTMLElement).classList.contains("protyle-wysiwyg")) { + const focusRange = focusBlock(range.startContainer.firstChild as Element); + if (focusRange) { + return focusRange; + } + } return range; } } diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index e28357db1..f953c47d0 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1180,8 +1180,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { // https://github.com/siyuan-note/siyuan/issues/12989 const cardElement = hasClosestByClassName(range.startContainer, "card__main", true); if (cardElement && document.activeElement && document.activeElement.classList.contains("protyle-wysiwyg")) { - (cardElement.querySelector(".card__action button") as HTMLElement).focus() - hideElements(["select"], protyle); + (cardElement.querySelector(".card__action:not(.fn__none) button") as HTMLElement).focus() + hideElements(["select"], protyle); } } else { if (!protyle.toolbar.element.classList.contains("fn__none") ||