Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7880

Vanessa4324817ed111
diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts
index 270d962651..9fcdf9a752 100644
--- a/app/src/mobile/editor.ts
+++ b/app/src/mobile/editor.ts
@@ -5,7 +5,6 @@ import {Constants} from "../constants";
import {fetchPost} from "../util/fetch";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import {addLoading} from "../protyle/ui/initUI";
-import {focusBlock} from "../protyle/util/selection";
import {scrollCenter} from "../util/highlightById";
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
import {setEditMode} from "../protyle/util/setEditMode";
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index 076e8dab91..cf9f66a56e 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -5,7 +5,7 @@ import {Constants} from "../../constants";
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
let renderKeyboardToolbarTimeout: number;
-let showKeyboardToolbarUtil = false;
+let showUtil = false;
const getSlashItem = (value: string, icon: string, text: string, focus = "false") => {
let iconHTML;
@@ -145,18 +145,23 @@ const renderSlashMenu = (protyle: IProtyle, toolbarElement: Element) => {
protyle.hint.bindUploadEvent(protyle, utilElement);
};
-const renderKeyboardToolbarUtil = () => {
+const showKeyboardToolbarUtil = (oldScrollTop: number) => {
const toolbarElement = document.getElementById("keyboardToolbar");
const keyboardHeight = (parseInt(toolbarElement.getAttribute("data-keyboardheight")) + 42) + "px";
toolbarElement.style.height = keyboardHeight;
window.siyuan.mobile.editor.protyle.element.style.marginBottom = keyboardHeight;
window.siyuan.menus.menu.remove();
- showKeyboardToolbarUtil = true;
+ showUtil = true;
setTimeout(() => {
- showKeyboardToolbarUtil = false;
+ showUtil = false;
}, 1000);
};
+const hideKeyboardToolbarUtil = () => {
+ document.getElementById("keyboardToolbar").style.height = "";
+ window.siyuan.mobile.editor.protyle.element.style.marginBottom = "42px";
+};
+
const renderKeyboardToolbar = () => {
clearTimeout(renderKeyboardToolbarTimeout);
renderKeyboardToolbarTimeout = window.setTimeout(() => {
@@ -230,11 +235,6 @@ const renderKeyboardToolbar = () => {
}, 620); // 需等待 range 更新
};
-const hideKeyboardToolbarUtil = () => {
- document.getElementById("keyboardToolbar").style.height = "";
- window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
-};
-
export const showKeyboardToolbar = (height: number) => {
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
return;
@@ -251,6 +251,7 @@ export const showKeyboardToolbar = (height: number) => {
!window.siyuan.mobile.editor.protyle.wysiwyg.element.contains(range.startContainer)) {
return;
}
+ window.siyuan.mobile.editor.protyle.element.style.marginBottom = "42px";
setTimeout(() => {
const contentElement = window.siyuan.mobile.editor.protyle.contentElement;
const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;
@@ -266,11 +267,13 @@ export const showKeyboardToolbar = (height: number) => {
};
export const hideKeyboardToolbar = () => {
- if (showKeyboardToolbarUtil) {
+ if (showUtil) {
return;
}
const toolbarElement = document.getElementById("keyboardToolbar");
toolbarElement.classList.add("fn__none");
+ toolbarElement.style.height = "";
+ window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
};
export const activeBlur = () => {
@@ -406,8 +409,9 @@ export const initKeyboardToolbar = () => {
focusByRange(range);
return;
} else if (type === "add") {
+ const oldScrollTop = window.siyuan.mobile.editor.protyle.contentElement.scrollTop;
renderSlashMenu(protyle, toolbarElement);
- renderKeyboardToolbarUtil();
+ showKeyboardToolbarUtil(oldScrollTop);
return;
} else if (type === "more") {
protyle.breadcrumb.showMenu(protyle, {
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index d64b24be80..6f1f6a2efc 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -29,7 +29,7 @@ export class Background {
this.element = document.createElement("div");
this.element.className = "protyle-background";
this.element.innerHTML = `<div class="protyle-background__img">
- <img class="fn__none">
+ <img class="fn__none" style="isMobile()? "200px" : "30vh"">
<div class="protyle-icons">
<span class="protyle-icon protyle-icon--first b3-tooltips b3-tooltips__sw" style="position: relative" aria-label="${window.siyuan.languages.upload}"><input type="file" style="position: absolute;width: 22px;height: 100%;top: 0;left: 0;opacity: .001;overflow: hidden;cursor: pointer;"><svg><use xlink:href="#iconUpload"></use></svg></span>
<span class="protyle-icon b3-tooltips b3-tooltips__sw" data-type="link" aria-label="${window.siyuan.languages.link}"><svg><use xlink:href="#iconLink"></use></svg></span>
@@ -389,7 +389,8 @@ export class Background {
}
if (img) {
- this.element.style.minHeight = "30vh";
+ // 移动端键盘弹起和点击加号需保持滚动高度一致
+ this.element.style.minHeight = isMobile() ? "200px" : "30vh";
} else if (icon) {
this.element.style.minHeight = (this.tagsElement.clientHeight + 56) + "px";
} else if (tags) {