selection-range
get or set the selction range, or cursor position, for contenteditable
Last updated 10 years ago by bmcmahen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install selection-range 
SYNC missed versions from official npm registry.

selection-range

Get or set the selection range, or cursor position. Useful for saving and restoring selections when your are programatically changing the dom.

Installation

$ component install bmcmahen/selection-range
$ npm install selection-range

Usage

var select = require('selection-range');
select(el, { start: 5, end: 25 }); // select range of el from 5 - 25
select(el, { start: 5 }); // set the cursor at 5
var pos = select(el); // get range of selection
// pos.start = start index
// pos.end = end index
// pos.atStart = boolean. true if cursor should appear at start of el
// pos = undefined if no cursor
select(el, pos);

Tests

npm install component-test -g
component test browser

License

MIT

Current Tags

  • 1.1.0                                ...           latest (10 years ago)

4 Versions

  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           12 years ago
  • 0.0.3                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |