mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 21:44:31 +01:00
commit
39dacafa82
@ -307,7 +307,8 @@ export function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDo
|
|||||||
// Right click is handled separately.
|
// Right click is handled separately.
|
||||||
const isMiddleClick = evt && "which" in evt && evt.which === 2;
|
const isMiddleClick = evt && "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 isDoubleClick = isLeftClick && evt?.type === "dblclick";
|
||||||
|
const openInNewTab = (isLeftClick && ctrlKey) || isDoubleClick || isMiddleClick || targetIsBlank;
|
||||||
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
|
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
|
||||||
const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey;
|
const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey;
|
||||||
|
|
||||||
@ -328,16 +329,18 @@ export function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDo
|
|||||||
const withinEditLink = $link?.hasClass("ck-link-actions__preview");
|
const withinEditLink = $link?.hasClass("ck-link-actions__preview");
|
||||||
const outsideOfCKEditor = !$link || $link.closest("[contenteditable]").length === 0;
|
const outsideOfCKEditor = !$link || $link.closest("[contenteditable]").length === 0;
|
||||||
|
|
||||||
if (openInNewTab || (withinEditLink && (isLeftClick || isMiddleClick)) || (outsideOfCKEditor && (isLeftClick || isMiddleClick))) {
|
if (openInNewTab || openInNewWindow || (isLeftClick && (withinEditLink || outsideOfCKEditor))) {
|
||||||
if (hrefLink.toLowerCase().startsWith("http") || hrefLink.startsWith("api/")) {
|
if (hrefLink.toLowerCase().startsWith("http") || hrefLink.startsWith("api/")) {
|
||||||
window.open(hrefLink, "_blank");
|
window.open(hrefLink, "_blank");
|
||||||
} else if ((hrefLink.toLowerCase().startsWith("file:") || hrefLink.toLowerCase().startsWith("geo:")) && utils.isElectron()) {
|
|
||||||
const electron = utils.dynamicRequire("electron");
|
|
||||||
electron.shell.openPath(hrefLink);
|
|
||||||
} else {
|
} else {
|
||||||
// Enable protocols supported by CKEditor 5 to be clickable.
|
// Enable protocols supported by CKEditor 5 to be clickable.
|
||||||
if (ALLOWED_PROTOCOLS.some((protocol) => hrefLink.toLowerCase().startsWith(protocol + ":"))) {
|
if (ALLOWED_PROTOCOLS.some((protocol) => hrefLink.toLowerCase().startsWith(protocol + ":"))) {
|
||||||
window.open(hrefLink, "_blank");
|
if ( utils.isElectron()) {
|
||||||
|
const electron = utils.dynamicRequire("electron");
|
||||||
|
electron.shell.openExternal(hrefLink);
|
||||||
|
} else {
|
||||||
|
window.open(hrefLink, "_blank");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,18 +476,9 @@ $(document).on("auxclick", "a", goToLink); // to handle the middle button
|
|||||||
// TODO: Check why the event is not supported.
|
// TODO: Check why the event is not supported.
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
$(document).on("contextmenu", "a", linkContextMenu);
|
$(document).on("contextmenu", "a", linkContextMenu);
|
||||||
$(document).on("dblclick", "a", (e) => {
|
// TODO: Check why the event is not supported.
|
||||||
e.preventDefault();
|
//@ts-ignore
|
||||||
e.stopPropagation();
|
$(document).on("dblclick", "a", goToLink);
|
||||||
|
|
||||||
const $link = $(e.target).closest("a");
|
|
||||||
|
|
||||||
const address = $link.attr("href");
|
|
||||||
|
|
||||||
if (address && address.startsWith("http")) {
|
|
||||||
window.open(address, "_blank");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on("mousedown", "a", (e) => {
|
$(document).on("mousedown", "a", (e) => {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user