npm.io
2.1.0 • Published 2 months ago

toggle-selection

Licence
MIT
Version
2.1.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
17

Toggle Selection

Simple module exposing function that deselects current browser selection and returns function that restores selection.

var deselect = require('toggle-selection');
var reselect = deselect(); // remove all selection
// … 
// do something with current selection, text, etc;
// …
reselect(); // restore selection

All credits go to @shvaikalesh.

Example

example recording

Keywords