This commit is contained in:
parent
41e6c78bdb
commit
fe925964d5
3 changed files with 14 additions and 15 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue