mirror of
https://github.com/annimon/obsidian-timelive.git
synced 2026-07-22 05:45:09 +00:00
Open internal links in new tab on ctrl/meta clicks
This commit is contained in:
parent
fdcce0223a
commit
2448fe82ad
1 changed files with 14 additions and 1 deletions
|
|
@ -24,9 +24,22 @@ export class InternalLinkProcessor implements DOMProcessor {
|
|||
if (!href) return;
|
||||
link.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
this.app.workspace.openLinkText(href, ctx.sourcePath);
|
||||
const newTab = this.shouldOpenInNewTab(e);
|
||||
this.app.workspace.openLinkText(href, ctx.sourcePath, newTab);
|
||||
});
|
||||
});
|
||||
return element;
|
||||
}
|
||||
|
||||
private shouldOpenInNewTab(e: Event): boolean {
|
||||
if (
|
||||
e instanceof PointerEvent ||
|
||||
e instanceof MouseEvent ||
|
||||
e instanceof TouchEvent ||
|
||||
e instanceof KeyboardEvent
|
||||
) {
|
||||
return (e.ctrlKey || e.metaKey);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue