HananoshikaYomaru / obsidian-run

Generate markdown from dataview query and javascript.
https://yomaru.dev
MIT License
34 stars 2 forks source link

Feature Request: Allow variables defined in one "run block" to be used in all subsequent "run blocks" -- page-level scoping #7

Closed StefanoRausch closed 11 months ago

StefanoRausch commented 1 year ago

See start of the discussion in https://github.com/HananoshikaYomaru/obsidian-run/issues/6.

I would like to be able to define the following -- simple example:

%% start run 01

~~~js
const modal = app.plugins.plugins.modalforms.api
const obs = await self.require.import("[[user.script.obsidian.delay-until-synced.mjs]]")
const timer = 1000
~~~

%%

and to re-use the variables in a following run block:

%% start run 02

~~~js
obs.delayUntilSynced(timer, () => {
    const data = modal.openForm("test-form")
    console.log(data)
}, {omit: ["name"]})

%%

The idea is to consolidate all variable declarations in one place for easier management.

Furthermore, if I would have to call the openForm modal function in another run block, I currently have to re-declare the access to the API -- an additional step I would like to avoid.

The icing on the cake would be that any run block could use any page-level (scoped) variables wherever they are declared.

HananoshikaYomaru commented 1 year ago

OK. Interesting. This basically make the whole doc a jupyter notebook. I am not sure about I want to do this because this is not easy. And not what I want this plugin to go.

HananoshikaYomaru commented 1 year ago
CleanShot 2023-10-03 at 09 23 39@2x
StefanoRausch commented 1 year ago

Fair enough and thanks for looking into it.