UNPKG

get-selection-range-from-elm

Version:

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

57 lines (37 loc) 1.94 kB
# get-selection-range-from-elm window.getSelection().rangeAt(0) but only if it exists & is within an element ## Installation Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already. ```sh npm install get-selection-range-from-elm --save ``` ## Usage ```js 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 ```sh npm install npm test ``` ## Dependencies None ## Dev Dependencies - [babel-cli](https://github.com/babel/babel/tree/master/packages): Babel command line. - [babel-core](https://github.com/babel/babel/tree/master/packages): Babel compiler core. - [babel-preset-es2015](https://github.com/babel/babel/tree/master/packages): Babel preset for all es2015 plugins. - [babel-tape-runner](https://github.com/wavded/babel-tape-runner): Babel + Tape for running your ES Next tests - [babelify](https://github.com/babel/babelify): Babel browserify transform - [browserify](https://github.com/substack/node-browserify): browser-side require() the node way - [devtool](https://github.com/Jam3/devtool): runs Node.js programs through Chromium DevTools - [faucet](https://github.com/substack/faucet): human-readable TAP summarizer - [package-json-to-readme](https://github.com/zeke/package-json-to-readme): Generate a README.md from package.json contents - [semistandard](https://github.com/Flet/semistandard): All the goodness of `feross/standard` with semicolons sprinkled on top. - [snazzy](https://github.com/feross/snazzy): Format JavaScript Standard Style as Stylish (i.e. snazzy) output - [tapava](https://github.com/kesla/tapava): the syntax of ava, run through tape ## License MIT _Generated by [package-json-to-readme](https://github.com/zeke/package-json-to-readme)_