From 474dd1396319994422f3becafd465ff81b9c6715 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 26 Dec 2025 18:37:09 -0500 Subject: [PATCH] fix: Improve internal link handling and error logging in menu plugin --- main.js | 14 +++++++++++++- manifest.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 9ed08fd..7cfde18 100644 --- a/main.js +++ b/main.js @@ -204,7 +204,19 @@ var MenuPlugin = class extends import_obsidian.Plugin { a.style.cursor = "pointer"; a.addEventListener("click", (e) => { e.preventDefault(); - this.app.workspace.openLinkText(href, ctx.sourcePath, false); + let sourcePath = ctx == null ? void 0 : 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(/^\[(.*)\]\((.*)\)$/); diff --git a/manifest.json b/manifest.json index 9988dcd..c06e3cb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "menu-plugin", "name": "Obsidian Menus", - "version": "1.4", + "version": "1.4.1", "minAppVersion": "0.15.0", "description": "Create custom menus using code blocks with links and CSS styling.", "author": "Olivier Legendre",