Selection
Selection across pages
Selecting texts across pages is only possible within the same document frame. Typically for several pages of a same spine item (eg: epub long chapter). This is unfortunately not possible when pages are separated document frames. This is because selections are scoped per frames.
This is a limitation that is close to impossible to solve because having a document frame per item is how the reading system can display each document in their own sandbox, with their own styles, scripts etc. That would require a radical change of implementation at its core and as far as we now this is not currently possible.
Multiple selections
It is possible for the user to do multiple selection if he decides to select texts in different document frame. Currently, the selection
API will only return the last selection. This is technically possible to return all current selection but is currently not implemented.
API
selection.selection$
selection.selection$
Emits the current selection
selection.selectionStart$
selection.selectionStart$
Emits when the user start a selection
selection.selectionEnd$
selection.selectionEnd$
Emits when the user ends a selection
selection.selectionOver$
selection.selectionOver$
Emits when user releases the pointer after a selection
selection.lastSelectionOnPointerDown$
selection.lastSelectionOnPointerDown$
Useful to know about the selection state before a pointerdown event. For example if you want to prevent certain action on click if user is discarding a selection. A good example is delaying the opening of a reader menu by discarding the current selection before toggling the menu.
selection.getSelection()
selection.getSelection()
Return the current selection synchronously.
selection.createOrderedRangeFromSelection()
selection.createOrderedRangeFromSelection()
Create and return an ordered range from a selection. This will sort out the start and end node automatically. This range can be safely used to generate CFI or other manipulations.
Last updated
Was this helpful?