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/18529

Vanessa46d6f2157337
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index c979775985..28a3128b42 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -833,6 +833,14 @@ export const initKeyboardToolbar = () => {
moved = true;
}
});
+ toolbarElement.addEventListener("mousedown", event => {
+ const buttonElement = hasClosestByTag(event.target as HTMLElement, "BUTTON");
+ const type = buttonElement && buttonElement.getAttribute("data-type");
+ if (type === "undo" || type === "redo") {
+ // 保持编辑器焦点,避免异步撤销或重做期间软键盘收起。
+ event.preventDefault();
+ }
+ });
toolbarElement.addEventListener(isInAndroid() || isInHarmony() ? "touchend" : "click", (event) => {
if (moved) {
return;
diff --git a/app/src/protyle/undo/globalUndo.ts b/app/src/protyle/undo/globalUndo.ts
index 1ffc9f2bc1..3ed9f68a03 100644
--- a/app/src/protyle/undo/globalUndo.ts
+++ b/app/src/protyle/undo/globalUndo.ts
@@ -102,25 +102,23 @@ export const initMirror = (rootID: string): Promise<boolean> => {
const applyUndoButtons = (protyle: IProtyle, rootID: string) => {
const state = getMirror(rootID);
- if (protyle.breadcrumb) {
- const parent = protyle.breadcrumb.element.parentElement;
+ const applyState = (parent: ParentNode) => {
const undoElement = parent.querySelector('[data-type="undo"]') as HTMLElement;
const redoElement = parent.querySelector('[data-type="redo"]') as HTMLElement;
- if (undoElement) {
- if (state.canUndo) {
- undoElement.removeAttribute("disabled");
- } else {
- undoElement.setAttribute("disabled", "disabled");
- }
- }
- if (redoElement) {
- if (state.canRedo) {
- redoElement.removeAttribute("disabled");
- } else {
- redoElement.setAttribute("disabled", "disabled");
- }
+ undoElement?.toggleAttribute("disabled", !state.canUndo);
+ redoElement?.toggleAttribute("disabled", !state.canRedo);
+ };
+ if (protyle.breadcrumb) {
+ applyState(protyle.breadcrumb.element.parentElement);
+ }
+ /// #if MOBILE
+ if (getCurrentEditor()?.protyle === protyle && getUndoRootID(protyle, protyle.toolbar?.range) === rootID) {
+ const keyboardToolbar = document.getElementById("keyboardToolbar");
+ if (keyboardToolbar) {
+ applyState(keyboardToolbar);
}
}
+ /// #endif
};
// 刷新指定 protyle 的撤销/重做按钮态;首次进入嵌入源文档时按需初始化其镜像。