Replies: 3 comments 3 replies
-
|
Cc'ing @chocolatkey as we know we need helpers (or some kind of API) for highlights and he has more experience than I currently do with this injectable/module. Sorry I have some catching up to do myself as I have not had the opportunity to use it through Thorium Web yet, but as you could see, you are not the only one interested in this right now. I will eventually come back at highlights through read-aloud so it sounds like a good time to collect feature requests and pain points. |
Beta Was this translation helpful? Give feedback.
-
|
Also interested! |
Beta Was this translation helpful? Give feedback.
-
|
Coming back to this after a while of sitting on it. I think 90% of my request could probably be solved with two changes
I'm happy to have a go at implementing the above two changes if you would be up for that! A last, optional change that would make it a lot easier to work with things:
This would make so much more custom functionality possible. For instance, I wanted to add a little bookmark icon next to highlights. This is really quite impossible to do, because the Decoration api only allows you to add highlights. Any custom functionality is extremely limited because there's no real way to find where in the page a certain locator actually is. You can only go there using I can see that this might be against the spirit of your idea to deprecate being able to access the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Semi related to (#170)
Sorry if this seems a bit all over the place, I wanted to make clear what I had considered already!
I would like to be able to click on the highlights/render a button close to them. To do that, I will need to find where the current highlight is, which is quite tricky: what I'm doing at the moment is basically copying how Readium resolves a locator to a range, then finding where the range is on the page. Then I have toyed between rendering a button, or figuring out whether we are inside of a highlight from a point in the page. The latter is obviously not very good for accessibility.
So I have a couple of questions (to avoid an XY problem), from most specific to my goal (click on highlight to do something with it) to least
Are there any plans on providing interactable highlights in the toolkit?
I think the mobile toolkits have something like an
onHighlightTapped. If something like this would be available in thets-toolkit, it would solve my issue (obviously haha)Are there plans to make it possible to retrieve highlights after creating them?
Currently you can do
But afterwards there is no real way of interacting with the highlights again (other than updating/removing them). If I could retrieve the highlight (the
Highlightto be specific, or a reference to the created DOM nodes) by some ID, i would be able to resolve the position of them on the screen, and render buttons etc.I know that the
cFrames"api" will be deprecated at some point, so I doubt this will be the long term way of doing things anyway!Is there an easy way to resolve a
Locatorto aRange?Since I have a reference to a Locator for a highlight (it's necessary to make the highlight), I could figure out where to render a button if I could easily resolve it to a
Range(or similar). I know Readium does this under the hood namelyrangeFromLocatorts-toolkit/navigator-html-injectables/src/helpers/locator.ts
Lines 10 to 69 in 587c788
I basically ended up copying this, but this ends up duplicating a very large amount of code.
I think there might sort of be a way by storing an
locator.locations.otherLocations.domRange, but from what I could find thisRangeobject to aDomRange, and could not find any examples of it!Any obvious solution I missed?
I tried to look for alternatives but couldn't figure out anything else! May have missed it though!
Beta Was this translation helpful? Give feedback.
All reactions