blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
6.6k stars 391 forks source link

Inline dv.view glitches on reading mode but does not even work in live preview #1372

Open DeutscheGabanna opened 1 year ago

DeutscheGabanna commented 1 year ago

What happened?

Loading meetings_list.js code into an inline block. image

Doesn't work in live preview: image

Does not work like intended in reading mode (shows just title, no embed): image

If you copy the meetings_list.js code from an inline dv.view query into a codeblock directly, it works: image

DQL

No response

JS

let meetings = dv.pages("#meeting").where(c => dv.equal(dv.date(c.held), dv.date(dv.current().file.name)))
if (meetings.length > 0) meetings.forEach(p => dv.paragraph(dv.fileLink(p.file.name, true)))
else dv.paragraph("You haven't added any meetings. A note has to be tagged with #meeting and the `held` parameter has to say: `" + dv.current().file.name + "`")

Dataview Version

0.5.43

Obsidian Version

0.15.9

OS

Windows

DeutscheGabanna commented 1 year ago

Also closely related with this issue: #177

AB1908 commented 1 year ago

Ah Live Preview. Always a joy to work with lol.

blacksmithgu commented 1 year ago

dv.view and embedding inside inline queries is not going to work very well - it renders inside an html span element which the Obsidian embed renderer will refuse to render in.

DeutscheGabanna commented 1 year ago

dv.view and embedding inside inline queries is not going to work very well - it renders inside an html span element which the Obsidian embed renderer will refuse to render in.

How about I make a DJS codeblock for this instead of the inline version? Would that work?

AB1908 commented 1 year ago

It should work that way I think. Try and let us know?

blacksmithgu commented 1 year ago

You should have better luck with a regular codeblock.

DeutscheGabanna commented 1 year ago

No luck, unfortunately. Now the same code pulls completely wrong notes with frontmatter held: 2022-08-23 when I'm running the query from a note called 2022-09-02

KillyMXI commented 10 months ago

This issue mashed two different things in one.

I came here while searching for opened issues about dv.view now working in Live Preview (aka Editing) mode specifically.

Currently, full dataviewjs code blocks work in either mode, and $= inline queries only work in reading mode. This inconsistency is really annoying. I specifically trying to insert computed values inline, so full codeblock is not acceptable. I rarely ever switch to reading mode and need everything working in live preview, so this makes dv.view not available for me.

For my use case I don't care about full HTML in inline queries. If you introduce a separate call like dv.iview() that would expect a plain string returned from my js file - That will work perfectly fine for me.