fix: Improve internal link handling and error logging in menu plugin

This commit is contained in:
2025-12-26 18:37:09 -05:00
parent 18cb15b22f
commit 474dd13963
2 changed files with 14 additions and 2 deletions

14
main.js
View File

@@ -204,7 +204,19 @@ var MenuPlugin = class extends import_obsidian.Plugin {
a.style.cursor = "pointer"; a.style.cursor = "pointer";
a.addEventListener("click", (e) => { a.addEventListener("click", (e) => {
e.preventDefault(); 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(/^\[.*\]\(.*\)$/)) { } else if (link.match(/^\[.*\]\(.*\)$/)) {
const match = link.match(/^\[(.*)\]\((.*)\)$/); const match = link.match(/^\[(.*)\]\((.*)\)$/);

View File

@@ -1,7 +1,7 @@
{ {
"id": "menu-plugin", "id": "menu-plugin",
"name": "Obsidian Menus", "name": "Obsidian Menus",
"version": "1.4", "version": "1.4.1",
"minAppVersion": "0.15.0", "minAppVersion": "0.15.0",
"description": "Create custom menus using code blocks with links and CSS styling.", "description": "Create custom menus using code blocks with links and CSS styling.",
"author": "Olivier Legendre", "author": "Olivier Legendre",