Git Product home page Git Product logo

dom-anchor-text-position's Introduction

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.

dom-anchor-text-position's People

Contributors

tilgovi avatar robertknight avatar akprasad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.