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

Vanessa1c0732eae1db
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index d0037622d5..2a5395a31a 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -43,6 +43,7 @@ import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";
import {renameTag} from "../util/noRelyPCFunction";
import {hideElements} from "../protyle/ui/hideElements";
import {emitOpenMenu} from "../plugin/EventBus";
+import {openMobileFileById} from "../mobile/editor";
export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement) => {
const nodeElement = hasClosestBlock(refElement);
@@ -531,6 +532,25 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
}
};
+export const enterBack = (protyle: IProtyle, id: string) => {
+ if (!protyle.block.showAll) {
+ const ids = protyle.path.split("/");
+ if (ids.length > 2) {
+ /// #if MOBILE
+ openMobileFileById(protyle.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
+ /// #else
+ openFileById({
+ app: protyle.app,
+ id: ids[ids.length - 2],
+ action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
+ });
+ /// #endif
+ }
+ } else {
+ zoomOut({protyle, id: protyle.block.parent2ID, focusId: id});
+ }
+}
+
export const zoomOut = (options: {
protyle: IProtyle,
id: string,
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 3e42678f0e..6dfb187145 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -1,6 +1,6 @@
import {hasClosestBlock, hasClosestByAttribute, hasClosestByMatchTag, hasClosestByTag} from "../util/hasClosest";
import {getIconByType} from "../../editor/getIcon";
-import {iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
+import {enterBack, iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
import {MenuItem} from "../../menus/Menu";
import {copySubMenu, openAttr, openWechatNotify} from "../../menus/commonMenuItem";
import {copyPlainText, updateHotkeyTip, writeText} from "../util/compatibility";
@@ -1427,22 +1427,7 @@ export class Gutter {
accelerator: window.siyuan.config.keymap.general.enterBack.custom,
label: window.siyuan.languages.enterBack,
click: () => {
- if (!protyle.block.showAll) {
- const ids = protyle.path.split("/");
- if (ids.length > 2) {
- /// #if MOBILE
- openMobileFileById(protyle.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
- /// #else
- openFileById({
- app: protyle.app,
- id: ids[ids.length - 2],
- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
- });
- /// #endif
- }
- } else {
- zoomOut({protyle, id: protyle.block.parent2ID, focusId: id});
- }
+ enterBack(protyle, id);
}
}).element);
}
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index e2732a5384..c32b3c0fdb 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -21,7 +21,7 @@ import {isLocalPath, pathPosix} from "../../util/pathName";
import {genEmptyElement} from "../../block/util";
import {previewImage} from "../preview/image";
import {
- contentMenu,
+ contentMenu, enterBack,
fileAnnotationRefMenu,
imgMenu,
linkMenu,
@@ -1933,6 +1933,7 @@ export class WYSIWYG {
clientY: event.clientY
});
} else if (actionElement.parentElement.classList.contains("li")) {
+ const actionId = actionElement.parentElement.getAttribute("data-node-id")
if (event.altKey && !protyle.disabled) {
// 展开/折叠当前层级的所有列表项
if (actionElement.parentElement.parentElement.classList.contains("protyle-wysiwyg")) {
@@ -1964,7 +1965,7 @@ export class WYSIWYG {
} else if (event.shiftKey && !protyle.disabled) {
openAttr(actionElement.parentElement);
} else if (ctrlIsPressed) {
- zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});
+ zoomOut({protyle, id: actionId});
} else {
if (actionElement.classList.contains("protyle-action--task")) {
if (!protyle.disabled) {
@@ -1977,10 +1978,14 @@ export class WYSIWYG {
actionElement.parentElement.classList.add("protyle-task--done");
}
actionElement.parentElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html);
+ updateTransaction(protyle, actionId, actionElement.parentElement.outerHTML, html);
}
} else {
- zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});
+ if (protyle.block.id === actionId) {
+ enterBack(protyle, actionId);
+ } else {
+ zoomOut({protyle, id: actionId});
+ }
}
}
}
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 28abe17669..8b4467c71b 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -52,7 +52,7 @@ import {
goHome,
upSelect
} from "./commonHotkey";
-import {fileAnnotationRefMenu, linkMenu, refMenu, setFold, tagMenu, zoomOut} from "../../menus/protyle";
+import {enterBack, fileAnnotationRefMenu, linkMenu, refMenu, setFold, tagMenu, zoomOut} from "../../menus/protyle";
import {removeEmbed} from "./removeEmbed";
import {openAttr} from "../../menus/commonMenuItem";
import {Constants} from "../../constants";
@@ -445,18 +445,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {
- if (!protyle.block.showAll) {
- const ids = protyle.path.split("/");
- if (ids.length > 2) {
- openFileById({
- app: protyle.app,
- id: ids[ids.length - 2],
- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
- });
- }
- } else {
- zoomOut({protyle, id: protyle.block.parent2ID, focusId: nodeElement.getAttribute("data-node-id")});
- }
+ enterBack(protyle, nodeElement.getAttribute("data-node-id"));
event.preventDefault();
event.stopPropagation();
return;