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

Vanessa50b2cef6908d
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index 8cee4904c8..56e0765325 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -979,6 +979,8 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
// 仅处理以下快捷键操作
if (!event.ctrlKey && !isCtrl(event) && event.key !== "Escape" && !event.shiftKey && !event.altKey &&
+ Constants.KEYCODELIST[event.keyCode] !== "PageUp" &&
+ Constants.KEYCODELIST[event.keyCode] !== "PageDown" &&
!/^F\d{1,2}$/.test(event.key) && event.key.indexOf("Arrow") === -1 && event.key !== "Enter" && event.key !== "Backspace" && event.key !== "Delete") {
return;
}
diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.ts
index 04f131a7f2..ab08d8c91f 100644
--- a/app/src/boot/globalEvent/searchKeydown.ts
+++ b/app/src/boot/globalEvent/searchKeydown.ts
@@ -14,6 +14,8 @@ import {hasClosestByClassName} from "../../protyle/util/hasClosest";
import {getArticle, inputEvent, replace, toggleReplaceHistory, toggleSearchHistory} from "../../search/util";
import {showFileInFolder} from "../../util/pathName";
import {assetInputEvent, renderPreview, toggleAssetHistory} from "../../search/assets";
+import {initSearchMenu} from "../../menus/search";
+import {writeText} from "../../protyle/util/compatibility";
export const searchKeydown = (app: App, event: KeyboardEvent) => {
if (getSelection().rangeCount === 0) {
@@ -135,24 +137,67 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
}
return false;
}
- if (!isAsset && matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
- const id = currentList.getAttribute("data-node-id");
- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
- openFileById({
- app,
- id,
- position: "right",
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
- (id === currentList.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
- zoomIn: foldResponse.data
+ if (!isAsset) {
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
+ const id = currentList.getAttribute("data-node-id");
+ fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
+ openFileById({
+ app,
+ id,
+ position: "right",
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
+ (id === currentList.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
+ zoomIn: foldResponse.data
+ });
+ if (dialog) {
+ dialog.destroy({focus: "false"});
+ }
});
- if (dialog) {
- dialog.destroy({focus: "false"});
- }
- });
- return true;
+ return true;
+ }
+ const id = currentList.getAttribute("data-node-id")
+ if (matchHotKey("⌘/", event)) {
+ const currentRect = currentList.getBoundingClientRect();
+ initSearchMenu(id).popup({
+ x: currentRect.left + 30,
+ y: currentRect.bottom
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {
+ fetchPost("/api/block/getRefText", {id}, (response) => {
+ writeText(`((${id} '${response.data}'))`);
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom, event)) {
+ writeText(`{{select * from blocks where id='${id}'}}`);
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyProtocol.custom, event)) {
+ writeText(`siyuan://blocks/${id}`);
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom, event)) {
+ fetchPost("/api/block/getRefText", {id}, (response) => {
+ writeText(`[${response.data}](siyuan://blocks/${id})`);
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
+ fetchPost("/api/filetree/getHPathByID", {
+ id
+ }, (response) => {
+ writeText(response.data);
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyID.custom, event)) {
+ writeText(id);
+ return true;
+ }
}
- // TODO https://github.com/siyuan-note/siyuan/issues/9548
+
if (Constants.KEYCODELIST[event.keyCode] === "PageUp") {
if (isAsset) {
if (!assetsElement.querySelector('[data-type="assetPrevious"]').getAttribute("disabled")) {
diff --git a/app/src/menus/search.ts b/app/src/menus/search.ts
index 1cb6bd7fa8..1f0eab4b55 100644
--- a/app/src/menus/search.ts
+++ b/app/src/menus/search.ts
@@ -6,7 +6,7 @@ export const initSearchMenu = (id: string) => {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.copy,
type: "submenu",
- submenu: copySubMenu(id,false)
+ submenu: copySubMenu(id)
}).element);
return window.siyuan.menus.menu;
};