Prechádzať zdrojové kódy

:art: https://github.com/siyuan-note/siyuan/issues/11157

Vanessa 1 rok pred
rodič
commit
fe925964d5

+ 1 - 1
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);

+ 2 - 13
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;
             }
 

+ 11 - 1
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;
         }