get-selection-range-from-elm

2.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i get-selection-range-from-elm

Weekly Downloads

0

Version

2.0.1

License

MIT

Last publish

Collaborators

  • ellell
  • iefserge
  • kesla