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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.1
    2
  • 2.0.0
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i get-selection-range-from-elm

Weekly Downloads

2

Version

2.0.1

License

MIT

Last publish

Collaborators

  • ellell
  • iefserge
  • kesla