fix desktop problem
This commit is contained in:
14
main.ts
14
main.ts
@@ -213,7 +213,19 @@ export default class MenuPlugin extends 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?.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(/^\[(.*)\]\((.*)\)$/);
|
||||||
|
|||||||
Reference in New Issue
Block a user