nothingislost / obsidian-query-control

An experimental Obsidian plugin that adds controls to embedded queries
MIT License
278 stars 16 forks source link

Render markdown #2

Closed liamcain closed 2 years ago

liamcain commented 2 years ago

How difficult do you think it would be to render each section as markdown too? That’s my main frustration with search query blocks. It’s definitely pretty out of scope for this plugin but I feel like you might be up for the challenge.

nothingislost commented 2 years ago

haha :) are you nerd sniping me via github issue? I'll think about this :)

nothingislost commented 2 years ago

This needs a lot more work but...

html-results

liamcain commented 2 years ago

Omg, it's glorious!

jaroet commented 2 years ago

That looks nice ... I saw a mention by Licat on the Discord that preview formatting of search results and backlinks also is on the todo list. But this already looks great.

Just wander, is it only showing the block/paragraph with the tag in this case. I guess so because you briefly see a Tasks heading in the GIF. That would be great. And does that also work with none list (so paragraph's)

nothingislost commented 2 years ago

Making some progress on this:

search-results-checkbox

liamcain commented 2 years ago

oh wow, the checkboxes are interactive 😍 this is officially scope creep on top of scope creep. Mind pushing your branch up even if it's super messy? Would love to play around and maybe help out

ryanjamurphy commented 2 years ago

@nothingislost you are going to blow minds with this

nothingislost commented 2 years ago

oh wow, the checkboxes are interactive 😍 this is officially scope creep on top of scope creep. Mind pushing your branch up even if it's super messy? Would love to play around and maybe help out

@liamcain I pushed the latest code but have not yet made a release. There's still more work to do so if you're going to play around with this, I would recommend doing it in a sandbox vault.

The methodology being used to do this is best described by the term "extreme monkey patching" :) Much of what I'm modifying are deeply nested classes that are not anywhere close to being in the official API. I have to intercept multiple different classes and patch their behavior. As a result, it is going to be very difficult to understand what is going on in the code base.

I've added a few comments to the top of main.js explaining what's going on and I've typed out most of the undocumented classes in obsidian.d.ts.

The main problem right now is getting the infinity scroller to scroll search results properly. Currently, the height measurement of the rendered markdown results isn't working properly. As a result, when you go to scroll through a large list of results, the scrolling is janky and jumps all over the place.

liamcain commented 2 years ago

Wow, looking at the code I feel guilty for having even suggested the feature 😅 It's simultaneously super impressive and super janky.

Not to mention all the edge cases like mangling the query blocks to avoid the recursive rendering...

Still messing around with it a bit but this CSS snippet fixes the weird spacing:

.search-result-file-match { white-space: normal; }
nothingislost commented 2 years ago

Oops, didn't commit the updated styles.css. I haven't done a ton of work on styling but there are a few updates in that file now.

nothingislost commented 2 years ago

Pushed some new code that stabilizes the scrolling behavior. Getting closer.

Edit: Also, since I have some lurkers on this issue, if you are going to try and build and test this yourself, please do so in a sandbox vault. This code hasn't been turned into an official release yet for a reason :)

nothingislost commented 2 years ago

I've pushed v0.3.0 which has the render markdown capability. The plugin has been renamed so you may need to uninstall the old version if you had it installed previously.

liamcain commented 2 years ago

omg omg omg. Okay playing with it now!! Just did my first search and it was magical though.

liamcain commented 2 years ago

Okay, the more I play with it, the more I kinda hope that Licat sherlocks this and puts it into core 🙈 . It's really, really awesome and makes both Search and query blocks feel that more powerful. So many nice touches too, like interactive checkboxes, making links clickable (vs having the whole item swallow the event).

Seriously amazing! Gotta tell everyone about this