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

Vanessa7c1f7a8280b9
diff --git a/app/src/boot/globalEvent/command/protyle.ts b/app/src/boot/globalEvent/command/protyle.ts
index daa781811c..b38142c337 100644
--- a/app/src/boot/globalEvent/command/protyle.ts
+++ b/app/src/boot/globalEvent/command/protyle.ts
@@ -1,6 +1,8 @@
import {hasClosestBlock} from "../../../protyle/util/hasClosest";
import {getTopAloneElement} from "../../../protyle/wysiwyg/getBlock";
import {enterBack, zoomOut} from "../../../menus/protyle";
+import {openFileById} from "../../../editor/util";
+import {Constants} from "../../../constants";
export const onlyProtyleCommand = (options: {
command: string,
@@ -17,7 +19,16 @@ export const onlyProtyleCommand = (options: {
topNodeElement.nextElementSibling?.classList.contains("list") && topNodeElement.previousElementSibling.classList.contains("protyle-action")) {
topNodeElement = topNodeElement.parentElement;
}
- zoomOut({protyle: options.protyle, id: topNodeElement.getAttribute("data-node-id")});
+ const id = topNodeElement.getAttribute("data-node-id")
+ if (options.protyle.options.backlinkData) {
+ openFileById({
+ app: options.protyle.app,
+ id,
+ action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
+ });
+ } else {
+ zoomOut({protyle: options.protyle, id});
+ }
return true;
}
if (options.command === "enterBack") {
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 269c59fed9..52fade93d9 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -60,6 +60,7 @@ import {avContextmenu, duplicateCompletely} from "../render/av/action";
import {getPlainText} from "../util/paste";
import {addEditorToDatabase} from "../render/av/addToDatabase";
import {processClonePHElement} from "../render/util";
+import {openFileById} from "../../editor/util";
export class Gutter {
public element: HTMLElement;
@@ -67,13 +68,16 @@ export class Gutter {
constructor(protyle: IProtyle) {
if (isMac()) {
- this.gutterTip = window.siyuan.languages.gutterTip;
+ this.gutterTip = window.siyuan.languages.gutterTip.replace("⌥→", updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom));
} else {
this.gutterTip = window.siyuan.languages.gutterTip.replace("⌥→", updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom))
.replace("⌘↑", updateHotkeyTip(window.siyuan.config.keymap.editor.general.collapse.custom))
.replace("⌥⌘A", updateHotkeyTip(window.siyuan.config.keymap.editor.general.attr.custom))
.replace(/⌘/g, "Ctrl+").replace(/⌥/g, "Alt+").replace(/⇧/g, "Shift+").replace(/⌃/g, "Ctrl+");
}
+ if (protyle.options.backlinkData) {
+ this.gutterTip = this.gutterTip.replace(window.siyuan.languages.enter, window.siyuan.languages.openBy)
+ }
this.element = document.createElement("div");
this.element.className = "protyle-gutters";
this.element.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
@@ -305,7 +309,15 @@ export class Gutter {
return;
}
if (isOnlyMeta(event)) {
- zoomOut({protyle, id});
+ if (protyle.options.backlinkData) {
+ openFileById({
+ app: protyle.app,
+ id,
+ action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
+ });
+ } else {
+ zoomOut({protyle, id});
+ }
} else if (event.altKey) {
let foldElement: Element;
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {
@@ -1695,6 +1707,19 @@ export class Gutter {
enterBack(protyle, id);
}
}).element);
+ } else {
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "enter",
+ accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom)}/${updateHotkeyTip("⌘" + window.siyuan.languages.click)}`,
+ label: window.siyuan.languages.openBy,
+ click: () => {
+ openFileById({
+ app: protyle.app,
+ id,
+ action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
+ });
+ }
+ }).element);
}
if (!protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({