This library offers conversion between a DOM Range
instance and a text
position selector as defined by the Web Annotation Data Model.
For more information on Range
see
the documentation.
For more information on the text position selector see the specification.
To require('dom-anchor-text-position')
:
npm install dom-anchor-text-position
The module exposes only two functions.
Provided with an existing Range
instance this will return an object that
stores the offsets of the beginning and end of the text selected by the range as
measured from the beginning of the root
Node
.
This method returns a Range
object that covers the interval [start, end)
of
the text content of the root
Node
.
If the end is not provided, returns a collapsed range. If the start is not
provided, the default is 0
.
If the start
or end
offsets are outside the range of valid character offsets
within the text content of the root
node, an exception is thrown.