mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-03 22:30:51 +08:00
feat(link): support target=_blank for URLs
This commit is contained in:
parent
e2f327c180
commit
7b297a5ed7
@ -280,11 +280,15 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent
|
|||||||
const ctrlKey = utils.isCtrlKey(evt);
|
const ctrlKey = utils.isCtrlKey(evt);
|
||||||
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 openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick;
|
const targetIsBlank = ($link?.attr("target") === "_blank");
|
||||||
|
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
if (openInNewTab) {
|
if (openInNewTab) {
|
||||||
appContext.tabManager.openTabWithNoteWithHoisting(notePath, { viewScope });
|
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
|
||||||
|
activate: targetIsBlank,
|
||||||
|
viewScope
|
||||||
|
});
|
||||||
} else if (isLeftClick) {
|
} else if (isLeftClick) {
|
||||||
const ntxId = $(evt.target as any)
|
const ntxId = $(evt.target as any)
|
||||||
.closest("[data-ntx-id]")
|
.closest("[data-ntx-id]")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user