5.0.0 • Published 4 years ago

dom-anchor-text-position v5.0.0

Weekly downloads
2,356
License
MIT
Repository
github
Last release
4 years ago

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.

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.

5.0.0

4 years ago

4.0.0

7 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.1.0

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

1.0.0-beta.2

9 years ago

1.0.0-beta.1

9 years ago

1.0.0-alpha.2

9 years ago

1.0.0-alpha.1

9 years ago