Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file view dependent context #2280

Open
4 tasks
GottZ opened this issue Mar 25, 2024 · 2 comments
Open
4 tasks

file view dependent context #2280

GottZ opened this issue Mar 25, 2024 · 2 comments
Labels
feature-request New feature or request.

Comments

@GottZ
Copy link
Contributor

GottZ commented Mar 25, 2024

image

the above image is the result of this code:

```dataviewjs
const root = dv.component.component.containerEl;
dv.span("def: has context? " + ("ctx" in root ? root.ctx : "no"));
if (!("ctx" in root)) {
	root.ctx = Math.random();
	dv.span("<br>");
	dv.span("setting context to: " + root.ctx);
}
```

```dataviewjs
const root = dv.component.component.containerEl;
dv.span("use: has context? " + ("ctx" in root ? root.ctx : "no"));
```

I'm currently experimenting with view based contexts.
right now, I could detect if I'm either in insert mode or in reading mode too. both have their own contexts.

ToDo's:

  • ensure cleanup when navigating away / providing a event queue for this task
  • reducing the barrier to a minimum.. maybe even adding dv.ctx or something, to have a context for the current document view. (opening the same document twice, would result in two separate contexts)
  • documentation
  • example for the test vault

Why?

well.. I don't like having all the code in one block if I could have many blocks being able to access data defined by the top block.
this would also not only provide access to simple data, but object instances too.
one could literally instanciate an API wrapper at the top and use it in consecutive dataviewjs blocks.

I already have the proof of concept done. I just need to iterate it a little and make it more user friendly.
I'll work on this after sleep. cya tomorrow :)

@GottZ GottZ added the feature-request New feature or request. label Mar 25, 2024
@GottZ GottZ changed the title view dependent context file view dependent context Mar 25, 2024
GottZ added a commit to GottZ/obsidian-dataview that referenced this issue Mar 25, 2024
@holroy
Copy link
Contributor

holroy commented Mar 26, 2024

What would you use this for? And can you use dv.evaluationContext for this?

@GottZ
Copy link
Contributor Author

GottZ commented Mar 26, 2024

What would you use this for? And can you use dv.evaluationContext for this?

that's codeblock scoped. not file scoped.

GottZ added a commit to GottZ/obsidian-dataview that referenced this issue Apr 11, 2024
GottZ added a commit to GottZ/obsidian-dataview that referenced this issue Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants