2.0.1 • Published 8 years ago

get-selection-range-from-elm v2.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

get-selection-range-from-elm

window.getSelection().rangeAt(0) but only if it exists & is within an element

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install get-selection-range-from-elm --save

Usage

import getSelectionRangeFromElm from 'get-selection-range-from-elm';

const range = getSelectionRangeFromElm(document.querySelector('#foo'));

console.log('range is set if selection is within the element #foo');
console.log(range.startContainer);

Tests

npm install
npm test

Dependencies

None

Dev Dependencies

License

MIT

Generated by package-json-to-readme