From fbe4f7840751e35fef7b4ee9748c6f22d99d343e Mon Sep 17 00:00:00 2001 From: aaandreeew <114206308+aaandreeew@users.noreply.github.com> Date: Wed, 1 Apr 2026 03:03:12 +1000 Subject: [PATCH 1/2] Prevent links opening twice in new tab in reading view Fixes issue where ctrl+click or middle-click on a link while in reading view would cause the link to be opened twice in two new tabs. --- main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.ts b/main.ts index 504d3f0..291c51f 100644 --- a/main.ts +++ b/main.ts @@ -1740,6 +1740,9 @@ export default class VirtualFooterPlugin extends Plugin { * @param component The Obsidian Component associated with this content, for event registration. */ public attachInternalLinkHandlers(container: HTMLElement, sourcePath: string, component: Component): void { + // If in reading view, do nothing, as the default behavior is fine + if (container.closest(".markdown-reading-view")) return; + // Handle left-click on internal links and external file links component.registerDomEvent(container, 'click', (event: MouseEvent) => { if (event.button !== 0) return; // Only handle left-clicks From cb80745a3068b6f51e0a62d5bae56d5e7a9ee01b Mon Sep 17 00:00:00 2001 From: aaandreeew <114206308+aaandreeew@users.noreply.github.com> Date: Wed, 1 Apr 2026 03:05:23 +1000 Subject: [PATCH 2/2] Make middle-click on external files consistent Makes middle-click on external file links in both live preview and soure mode consistent between virtual content and default obsidian behaviour. This is a simple copy of the same code which only applied to ctrl+click on external file links. --- main.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.ts b/main.ts index 291c51f..88bc812 100644 --- a/main.ts +++ b/main.ts @@ -1778,6 +1778,14 @@ export default class VirtualFooterPlugin extends Plugin { if (href) { this.app.workspace.openLinkText(href, sourcePath, true); // Always open in new pane for middle-click } + return; + } + + // Handle external file links which don't work natively in Live Preview injected content + const externalLink = target.closest('a.external-link') as HTMLAnchorElement; + if (externalLink && externalLink.href.startsWith('file:')) { + event.preventDefault(); + window.open(externalLink.href); } }); }