mProjectsCode / obsidian-js-engine-plugin

https://www.moritzjung.dev/obsidian-js-engine-plugin-docs/
GNU General Public License v3.0
73 stars 5 forks source link

Is there a way to determine a path from which JS Engine snippet executes? #15

Closed martyn0ff closed 4 months ago

martyn0ff commented 4 months ago

I am looking for a way to reliably get the location of a file where JS Engine's snippet is executed. Is there a way to do so? app.workspace.getActiveFile() can be unreliable when we have multiple tabs with JS Engine open and we reload Obsidian. That would cause all such tabs to have same active file, which is technically correct, but throws off all my scripts. Granted reloading Obsidian is something that doesn't occur often, but when it is necessary, it makes a mess.

mProjectsCode commented 4 months ago

context.file.path

martyn0ff commented 4 months ago

That works nicely, thank you!