From 7b297a5ed7c04139a75282fc942b9c8f8ddf2b12 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 12 Apr 2025 11:08:02 +0300 Subject: [PATCH] feat(link): support target=_blank for URLs --- src/public/app/services/link.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts index df511f2c7..138df7221 100644 --- a/src/public/app/services/link.ts +++ b/src/public/app/services/link.ts @@ -280,11 +280,15 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent const ctrlKey = utils.isCtrlKey(evt); const isLeftClick = "which" in evt && evt.which === 1; const isMiddleClick = "which" in evt && evt.which === 2; - const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick; + const targetIsBlank = ($link?.attr("target") === "_blank"); + const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank; if (notePath) { if (openInNewTab) { - appContext.tabManager.openTabWithNoteWithHoisting(notePath, { viewScope }); + appContext.tabManager.openTabWithNoteWithHoisting(notePath, { + activate: targetIsBlank, + viewScope + }); } else if (isLeftClick) { const ntxId = $(evt.target as any) .closest("[data-ntx-id]")