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

Vanessafe925964d539
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 04bd9a3b70..e4ab2f499e 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -696,7 +696,7 @@ export const openBy = (url: string, type: "folder" | "app") => {
/// #endif
};
-export const openLink = (protyle: IProtyle, aLink: string, event: MouseEvent | KeyboardEvent, ctrlIsPressed = false) => {
+export const openLink = (protyle: IProtyle, aLink: string, event?: MouseEvent, ctrlIsPressed = false) => {
let linkAddress = Lute.UnEscapeHTMLStr(aLink);
/// #if MOBILE
openByMobile(linkAddress);
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index f682f9d5ca..b8fe8db432 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -16,8 +16,7 @@ import {
setLastNodeRange,
} from "../util/selection";
import {Constants} from "../../constants";
-import {getSearch, isMobile} from "../../util/functions";
-import {isLocalPath, pathPosix} from "../../util/pathName";
+import {isMobile} from "../../util/functions";
import {genEmptyElement} from "../../block/util";
import {previewDocImage} from "../preview/image";
import {
@@ -2107,17 +2106,7 @@ export class WYSIWYG {
event.preventDefault();
const fileIds = fileElement.getAttribute("data-id").split("/");
const linkAddress = `assets/${fileIds[1]}`;
- /// #if MOBILE
- openByMobile(linkAddress);
- /// #else
- if (ctrlIsPressed) {
- openBy(linkAddress, "folder");
- } else if (event.shiftKey) {
- openBy(linkAddress, "app");
- } else {
- openAsset(protyle.app, linkAddress, fileIds[2], "right");
- }
- /// #endif
+ openLink(protyle, linkAddress, event, ctrlIsPressed);
return;
}
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index e6a4cd8379..dea7472c59 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1582,9 +1582,19 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) {
const aElement = hasClosestByAttribute(range.startContainer, "data-type", "a");
if (aElement) {
- openLink(protyle, aElement.getAttribute("data-href"), event, false);
+ openLink(protyle, aElement.getAttribute("data-href"), undefined, false);
event.preventDefault();
event.stopPropagation();
+ return;
+ }
+ const fileElement = hasClosestByAttribute(range.startContainer, "data-type", "file-annotation-ref");
+ if (fileElement) {
+ const fileIds = fileElement.getAttribute("data-id").split("/");
+ const linkAddress = `assets/${fileIds[1]}`;
+ openLink(protyle, linkAddress, undefined, false);
+ event.preventDefault();
+ event.stopPropagation();
+ return;
}
return;
}