nothingislost / obsidian-hover-editor

Transform the Page Preview hover into a working editor instance
MIT License
543 stars 21 forks source link

Popover window auto size #243

Closed scheminger closed 11 months ago

scheminger commented 11 months ago

It would be really nice if the window would decrease in size, depending on how much text the target note has. E.g. I have a couple of notes with less than 3 sentence and the window is just to big for them. Would be cool, if the window decreases so the text fits perfectly. In addition one should be able to specify a maximum and minimum size.

pjeby commented 11 months ago

A hover editor is a regular Obsidian tab that happens to float. Obsidian tabs can contain graphs, canvases, PDFs, Kanban boards, Excalidraw drawings, audios, videos, and lots of other things -- many of which don't even have a concept of "how much text" or "how big is the thing being shown". (Canvases, graphs, and Excalidraw are zoomable, for example, and Kanban boards size themselves to the area they're given.)

And for markdown text, both of the standard ways for it to be shown (reading and editing modes), there is actually no "size" either: Obsidian implements them using a virtual DOM that only renders the visible part of the text. So there is no way to know how big the window should be without deep integration with Obsidian's rendering code for those things. And it would have to be dynamic, because once the hover editor is open, you can click links and go to different files, so it would need to constantly resize, or else you're stuck with a weird size window. (And that's not counting the part where you can actually split a hover editor to show multiple tabs .)

All in all, this idea would not be practical to implement within Obsidian's current architecture or Hover Editor's feature set.

scheminger commented 11 months ago

Thank you for the elaborate answer, that makes sense!