johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.33k stars 290 forks source link

Show note icon if the highlight contains note #1094

Open azzamsa opened 1 year ago

azzamsa commented 1 year ago

Is your feature request related to a problem? Please describe.

I can't tell if a highlight contains a note or not.

Describe the solution you'd like

Show a note icon around the highlight. The image below is from Lithium android app. image

Describe alternatives you've considered

Additional context

johnfactotum commented 10 months ago

Ideally it should be displayed in the margins to avoid obstructing the text.

Another issue is that it probably needs to be aware of the visible viewport so that in paginated mode, highlights that span multiple pages would have the icon on all pages. Edit: on second thought, maybe it'd be enough to show it at either the start or end of the highlight; showing it on each page is a bit weird as it would seem like there are multiple notes for the highlight.

So considering these two points, I think it'd probably make sense to have the renderer export a list of rects for the pages. Then it should be relatively straight forward to calculate the desired positions for the icons.

There are a couple remaining issues with this. The first is whether or how to handle collisions when you have multiple highlights on the same line. The second is whether or how to handle pointer events. Currently events are only handled if you click inside the rects of the highlighted text, rather than the hightlights themselves.