Skip to content

Add the CSS selector to the selection returned by the EPUB navigator - #817

Draft
mickael-menu wants to merge 1 commit into
developfrom
fix-issue-704
Draft

mickael-menu wants to merge 1 commit into
developfrom
fix-issue-704

Conversation

@mickael-menu

Copy link
Copy Markdown
Member

The Locator returned by SelectableNavigator.currentSelection() in the EPUB navigator now includes the cssSelector of the element containing the selection in its locations, allowing apps to robustly anchor highlights and annotations.

The selector is computed in the JavaScript layer with css-selector-generator (same pattern as findFirstVisibleLocator) from the selection range's common ancestor element, and exposed through the existing Locator.Locations.cssSelector extension. Any cssSelector inherited from the current locator is stripped so the key is never stale. The JS bundles were regenerated with make scripts.

The property name stays cssSelector, consistent with the toolkit's existing conventions, so a future readium/annotations implementation (W3C CssSelector) can map it directly.

Fixes #704

🤖 Generated with Claude Code

The Locator returned by SelectableNavigator.currentSelection() now
includes the cssSelector of the element containing the selection in its
locations, allowing apps to robustly anchor highlights and annotations.
The selector is computed in the JavaScript layer with
css-selector-generator from the selection range's common ancestor
element, and exposed through the existing Locator.Locations.cssSelector
extension. Any cssSelector inherited from the current locator is
stripped so the key is never stale.

Fixes #704

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cssSelector not available for highlights in EPUBs

1 participant