diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 435ed3d0d..9af93b313 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -307,7 +307,8 @@ export function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDo // Right click is handled separately. const isMiddleClick = evt && "which" in evt && evt.which === 2; 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 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 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/")) { 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 { // Enable protocols supported by CKEditor 5 to be clickable. 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. //@ts-ignore $(document).on("contextmenu", "a", linkContextMenu); -$(document).on("dblclick", "a", (e) => { - e.preventDefault(); - e.stopPropagation(); - - const $link = $(e.target).closest("a"); - - const address = $link.attr("href"); - - if (address && address.startsWith("http")) { - window.open(address, "_blank"); - } -}); +// TODO: Check why the event is not supported. +//@ts-ignore +$(document).on("dblclick", "a", goToLink); $(document).on("mousedown", "a", (e) => { if (e.which === 2) {