Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/12989

Vanessa84d78485837c
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 926200eb90..956e9f9e47 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 e28357db1a..f953c47d08 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") ||