diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 81e2ff646..1819e0bf5 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -365,8 +365,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { icon: "iconOpen", accelerator: window.siyuan.config.keymap.editor.general.openBy.custom + "/" + window.siyuan.languages.click, click() { - checkFold(refBlockId, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(refBlockId, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id: refBlockId, @@ -397,8 +399,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { icon: "iconLayoutRight", accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/⌥" + window.siyuan.languages.click, click() { - checkFold(refBlockId, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(refBlockId, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id: refBlockId, @@ -414,8 +418,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { icon: "iconLayoutBottom", accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + "⇧" + window.siyuan.languages.click, click() { - checkFold(refBlockId, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(refBlockId, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id: refBlockId, diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 328aae9ab..9927de267 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -2072,9 +2072,11 @@ export class WYSIWYG { } else if (aElement) { refBlockId = aLink.substring(16, 38); } - checkFold(refBlockId, (zoomIn, action) => { + checkFold(refBlockId, (zoomIn, action, isRoot) => { // 块引用跳转后需要短暂高亮目标块 https://github.com/siyuan-note/siyuan/issues/11542 - action.push(Constants.CB_GET_HL); + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } /// #if MOBILE openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); activeBlur(); diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index ecdad4e38..3f1565ade 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -638,7 +638,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (getSelectionPosition(nodeElement, range).top - protyle.wysiwyg.element.getBoundingClientRect().top < 40 || nodeElement.classList.contains("av")) { if (protyle.title && protyle.title.editElement && (protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" || - protyle.contentElement.scrollTop === 0)) { + protyle.contentElement.scrollTop === 0)) { protyle.title.editElement.focus(); } else { protyle.contentElement.scrollTop = 0; @@ -1525,8 +1525,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (refElement) { const id = refElement.getAttribute("data-id"); if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) { - checkFold(id, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(id, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id, @@ -1552,8 +1554,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { event.stopPropagation(); return true; } else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) { - checkFold(id, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(id, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id, @@ -1566,8 +1570,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { event.stopPropagation(); return true; } else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBottom.custom, event)) { - checkFold(id, (zoomIn, action) => { - action.push(Constants.CB_GET_HL); + checkFold(id, (zoomIn, action, isRoot) => { + if (!isRoot) { + action.push(Constants.CB_GET_HL); + } openFileById({ app: protyle.app, id, diff --git a/app/src/util/noRelyPCFunction.ts b/app/src/util/noRelyPCFunction.ts index 8dca97207..819e4debc 100644 --- a/app/src/util/noRelyPCFunction.ts +++ b/app/src/util/noRelyPCFunction.ts @@ -12,7 +12,7 @@ export const renameTag = (labelName: string) => {
`, - width: isMobile() ? "92vw": "520px", + width: isMobile() ? "92vw" : "520px", }); dialog.element.setAttribute("data-key", Constants.DIALOG_RENAMETAG); const btnsElement = dialog.element.querySelectorAll(".b3-button"); @@ -34,11 +34,13 @@ export const getWorkspaceName = () => { return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, ""); }; -export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[]) => void) => { +export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[], isRoot: boolean) => void) => { if (!id) { return; } fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { - cb(foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]); + cb(foldResponse.data.isFolded, + foldResponse.data.isFolded ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL], + foldResponse.data.isRoot); }); };