gerhardsletten / react-reader

An ePub-reader for React, powered by Epub.js
https://react-reader.metabits.no
Apache License 2.0
721 stars 132 forks source link

clickable highlights #176

Closed escottgoodwin closed 5 months ago

escottgoodwin commented 6 months ago

Is there a way to make selected text highlights clickable (with hand pointer)?

Adding a highlight with rendition.annotations.add doesn't seem to make it clickable.

Ideally, i'd like to click the highlight and then get the cfiRange.

The original epubjs had something like this, but I could never figure out how it worked.

Any highlight added with annotations.add was never clickable. You could remove it and there would be a yellow highlight underneath that was clickable. But then annotations.remove wouldn't remove the yellow highlight.

For rendition.on - is there a trigger besides 'selected' or 'click' that only fires for clicks on highlights? I discovered a annotator.on("highlightClick") but annotator object didn't exist in the object as it was in example.

Is there a list of all events for rendition.on?

gerhardsletten commented 5 months ago

@escottgoodwin The cb param for rendition.annotations.add seems to be added as an event listner for the annotations-element

https://github.com/futurepress/epub.js/blob/f09089cf77c55427bfdac7e0a4fa130e373a19c8/src/annotations.js#L34