blacksmithgu / obsidian-dataview

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

Inline field styling in live preview mode #1058

Open colin-p-hill opened 2 years ago

colin-p-hill commented 2 years ago

Is your feature request related to a problem? Please describe. I virtually never use Reading View, preferring Live Preview. Except quick references like MOCs, I don't often open a note without wanting to edit it. It's therefore important to me that styling features work in Live Preview. Without styling, inline fields don't call much attention to themselves, and I find their readability impeded.

Describe the solution you'd like Styling of inline fields in Live Preview similar to what we get with Reading View.

Describe alternatives you've considered I've considered making heavier use of Reading View, but I haven't found a way to switch between reading and editing in an ergonomic way. I typically use vim bindings to move around, which doesn't work in Reading View.

AB1908 commented 2 years ago

Fellow vimmer! I've wanted a vimium-like for reading view but no dice.

Anyhow, you could potentially reuse DV's CSS snippets as a custom snippet but I think that depends on how the codemirror processor handles inline DV fields. I'll let blacksmithgu comment on this.

colin-p-hill commented 2 years ago

Yeah, I may wind up looking into custom CSS snippets, but I find those a bit painful to work with, so I thought it would be reasonable as a feature request.

blacksmithgu commented 2 years ago

As far as I am aware, this has to be done as a CodeMirror extension. I haven't tried doing it yet because it seems quite complicated! The reference documentation is here (https://codemirror.net/6/docs/ref/#view.Decoration%5Ereplace)... if anyone has even a vague clue about how to do this in Obsidian it would be greatly appreciated.

jaroet commented 2 years ago

I came here for kind of a +1 message but it seems there is already some progress on this issue.

Looks to be rather complex which is a pity as this would be an extremely nice change. Unfortunately I am no programmer but if ever gets somewhere and testers are needed I will be available.

RyotaUshio commented 1 year ago

It's finally here in v0.5.60!

So I assume this issue can now be closed.

vruyr commented 1 year ago

This is excellent news! Thank you!

The fields also render in Source Mode too, which I think they shouldn't.

image
vruyr commented 1 year ago

Also date time fields are not formatted according to the settings.

Live Preview:

image

Reading Mode:

image
RyotaUshio commented 1 year ago

@vruyr Thanks for letting me know. It was fixed in 0.5.61.