From 18cb15b22f601d8d15a21d17ba34995daf2ffb88 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 26 Dec 2025 18:35:29 -0500 Subject: [PATCH] fix desktop problem --- main.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index b34016b..02e65a7 100644 --- a/main.ts +++ b/main.ts @@ -213,7 +213,19 @@ export default class MenuPlugin extends Plugin { a.style.cursor = 'pointer'; a.addEventListener('click', (e) => { e.preventDefault(); - this.app.workspace.openLinkText(href, ctx.sourcePath, false); + let sourcePath = ctx?.sourcePath; + if (!sourcePath) { + const activeFile = this.app.workspace.getActiveFile(); + sourcePath = activeFile ? activeFile.path : ''; + if (!sourcePath) { + console.error('[obsidian-menus] Could not determine sourcePath for internal link:', href); + } + } + try { + this.app.workspace.openLinkText(href, sourcePath, false); + } catch (err) { + console.error('[obsidian-menus] Failed to open internal link:', href, err); + } }); } else if (link.match(/^\[.*\]\(.*\)$/)) { const match = link.match(/^\[(.*)\]\((.*)\)$/);