Skip to content

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

:bug: Avoid opening the keyboard from mobile scrollbar buttons https://github.com/siyuan-note/siyuan/issues/19034

Daniel7f5dd5a1810e
diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts
index b606c6dccf..5f39d84670 100644
--- a/app/src/protyle/scroll/index.ts
+++ b/app/src/protyle/scroll/index.ts
@@ -118,9 +118,9 @@ export class Scroll {
this.parentElement.addEventListener("click", (event) => {
const target = event.target as HTMLElement;
if (hasClosestByClassName(target, "protyle-scroll__up")) {
- goHome(protyle);
+ goHome(protyle, false);
} else if (hasClosestByClassName(target, "protyle-scroll__down")) {
- goEnd(protyle);
+ goEnd(protyle, false);
} else if (target.classList.contains("b3-slider")) {
this.setIndex(protyle);
}
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index 4891444ac2..b615c7b6b6 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -431,11 +431,13 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
scrollCenter(protyle);
};
-export const goHome = (protyle: IProtyle) => {
+export const goHome = (protyle: IProtyle, focusEditor = true) => {
if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-index") === "0" ||
protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" ||
protyle.options.backlinkData) {
- focusBlock(protyle.wysiwyg.element.firstElementChild);
+ if (focusEditor) {
+ focusBlock(protyle.wysiwyg.element.firstElementChild);
+ }
protyle.contentElement.scrollTop = 0;
protyle.scroll.lastScrollTop = 1;
} else {
@@ -448,12 +450,17 @@ export const goHome = (protyle: IProtyle) => {
getDocParam.notebook = protyle.notebookId;
}
fetchPost("/api/filetree/getDoc", getDocParam, getResponse => {
- onGet({data: getResponse, protyle, action: [Constants.CB_GET_FOCUS]});
+ onGet({
+ data: getResponse,
+ protyle,
+ action: [Constants.CB_GET_FOCUS],
+ suppressFocus: !focusEditor,
+ });
});
}
};
-export const goEnd = (protyle: IProtyle) => {
+export const goEnd = (protyle: IProtyle, focusEditor = true) => {
if (!protyle.scroll.element.classList.contains("fn__none") &&
protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2") {
const getDocParam: IObject = {
@@ -469,15 +476,20 @@ export const goEnd = (protyle: IProtyle) => {
data: getResponse,
protyle,
action: [Constants.CB_GET_FOCUS],
+ suppressFocus: !focusEditor,
afterCB() {
- focusBlock(protyle.wysiwyg.element.lastElementChild, undefined, false);
+ if (focusEditor) {
+ focusBlock(protyle.wysiwyg.element.lastElementChild, undefined, false);
+ }
}
});
});
} else {
protyle.contentElement.scrollTop = protyle.contentElement.scrollHeight;
protyle.scroll.lastScrollTop = protyle.contentElement.scrollTop;
- focusBlock(protyle.wysiwyg.element.lastElementChild, undefined, false);
+ if (focusEditor) {
+ focusBlock(protyle.wysiwyg.element.lastElementChild, undefined, false);
+ }
}
};