Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

dom-anchor-text-position

4.0.0 • Public • Published

Text Position Anchor

License NPM Package Build Status codecov

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.

Installation

To require('dom-anchor-text-position'):

npm install dom-anchor-text-position

Usage

API Documentation

The module exposes only two functions.

fromRange(root, range)

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.

toRange(root, selector = {start, end})

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.

install

npm i dom-anchor-text-position

Downloadsweekly downloads

296

version

4.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability