mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-19 10:15:22 +08:00
Shortcut to open link
This commit is contained in:
parent
49bc6e8c91
commit
b7e7196f48
@ -278,15 +278,20 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent
|
|||||||
const { notePath, viewScope } = parseNavigationStateFromUrl(hrefLink);
|
const { notePath, viewScope } = parseNavigationStateFromUrl(hrefLink);
|
||||||
|
|
||||||
const ctrlKey = utils.isCtrlKey(evt);
|
const ctrlKey = utils.isCtrlKey(evt);
|
||||||
|
const shiftKey = evt.shiftKey;
|
||||||
const isLeftClick = "which" in evt && evt.which === 1;
|
const isLeftClick = "which" in evt && evt.which === 1;
|
||||||
const isMiddleClick = "which" in evt && evt.which === 2;
|
const isMiddleClick = "which" in evt && evt.which === 2;
|
||||||
const targetIsBlank = ($link?.attr("target") === "_blank");
|
const targetIsBlank = ($link?.attr("target") === "_blank");
|
||||||
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
|
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
|
||||||
|
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
|
||||||
|
const openInNewWindow = isLeftClick && evt.shiftKey && !ctrlKey;
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
if (openInNewTab) {
|
if (openInNewWindow) {
|
||||||
|
appContext.triggerCommand("openInWindow", { notePath, viewScope });
|
||||||
|
} else if (openInNewTab) {
|
||||||
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
|
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
|
||||||
activate: evt.shiftKey ? true : targetIsBlank,
|
activate: activate ? true : targetIsBlank,
|
||||||
viewScope
|
viewScope
|
||||||
});
|
});
|
||||||
} else if (isLeftClick) {
|
} else if (isLeftClick) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user