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

Vanessa9ac2fd017241
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index bdbb0715b3..2200ae78d0 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -34,7 +34,7 @@ import {getDisplayName, getNotebookName, getTopPaths, movePathTo, moveToPath} fr
import {openFileById} from "../../editor/util";
import {getAllDocks, getAllModels, getAllTabs} from "../../layout/getAll";
import {openGlobalSearch} from "../../search/util";
-import {focusBlock, focusByRange} from "../../protyle/util/selection";
+import {focusBlock, focusByOffset, focusByRange, getSelectionOffset} from "../../protyle/util/selection";
import {initFileMenu, initNavigationMenu} from "../../menus/navigation";
import {bindMenuKeydown} from "../../menus/Menu";
import {Dialog} from "../../dialog";
@@ -61,7 +61,7 @@ import {fullscreen} from "../../protyle/breadcrumb/action";
import {openRecentDocs} from "../../business/openRecentDocs";
import {App} from "../../index";
import {commandPanel} from "../../plugin/commandPanel";
-import {toggleDockBar} from "../../layout/dock/util";
+import {openBacklink, openGraph, openOutline, toggleDockBar} from "../../layout/dock/util";
import {workspaceMenu} from "../../menus/workspace";
import {resize} from "../../protyle/util/resize";
import {Search} from "../../search";
@@ -325,6 +325,56 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
if (target.tagName !== "TABLE" && (target.tagName === "INPUT" || target.tagName === "TEXTAREA")) {
return false;
}
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
+ event.preventDefault();
+ if (range) {
+ const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
+ if (refElement) {
+ openBacklink({
+ app: protyle.app,
+ blockId: refElement.dataset.id,
+ });
+ return true;
+ }
+ }
+ openBacklink({
+ app: protyle.app,
+ blockId: protyle.block.id,
+ rootId: protyle.block.rootID,
+ useBlockId: protyle.block.showAll,
+ title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null,
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.graphView.custom, event)) {
+ event.preventDefault();
+ if (range) {
+ const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
+ if (refElement) {
+ openGraph({
+ app: protyle.app,
+ blockId: refElement.dataset.id,
+ });
+ return true;
+ }
+ }
+ openGraph({
+ app: protyle.app,
+ blockId: protyle.block.id,
+ rootId: protyle.block.rootID,
+ useBlockId: protyle.block.showAll,
+ title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null,
+ });
+ return true;
+ }
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.outline.custom, event)) {
+ event.preventDefault();
+ const offset = getSelectionOffset(target);
+ openOutline(protyle);
+ // switchWnd 后,range会被清空,需要重新设置
+ focusByOffset(target, offset.start, offset.end);
+ return true;
+ }
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyPlainText.custom, event)) {
const nodeElement = hasClosestBlock(range.startContainer);
if (!nodeElement) {
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index fd01f0ae49..0632073849 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -66,60 +66,6 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElemen
return true;
}
/// #if !MOBILE
- if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
- event.preventDefault();
- event.stopPropagation();
- if (range) {
- const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
- if (refElement) {
- openBacklink({
- app: protyle.app,
- blockId: refElement.dataset.id,
- });
- return true;
- }
- }
- openBacklink({
- app: protyle.app,
- blockId: protyle.block.id,
- rootId: protyle.block.rootID,
- useBlockId: protyle.block.showAll,
- title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null,
- });
- return true;
- }
- if (matchHotKey(window.siyuan.config.keymap.editor.general.graphView.custom, event)) {
- event.preventDefault();
- event.stopPropagation();
- if (range) {
- const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
- if (refElement) {
- openGraph({
- app: protyle.app,
- blockId: refElement.dataset.id,
- });
- return true;
- }
- }
- openGraph({
- app: protyle.app,
- blockId: protyle.block.id,
- rootId: protyle.block.rootID,
- useBlockId: protyle.block.showAll,
- title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null,
- });
- return true;
- }
- if (matchHotKey(window.siyuan.config.keymap.editor.general.outline.custom, event)) {
- event.preventDefault();
- event.stopPropagation();
- const offset = getSelectionOffset(target);
- openOutline(protyle);
- // switchWnd 后,range会被清空,需要重新设置
- focusByOffset(target, offset.start, offset.end);
- return true;
- }
-
let matchCommand = false;
protyle.app.plugins.find(item => {
item.commands.find(command => {