selection-update
Computing input selection updates on external file changes, as if we used browser managed undo and redo.
API
/** * Calculate the selection update for the given * current and new input values. * * @param * @param * @param * * @return */;
Usage
var selectionUpdate = ; /** * Update input with new value. * @param * @param */ { var newSelection; // only retrieve and restore input, if the element // is currently active if documentactiveElement === $input // get the current selection and pass it in as {start, end} newSelection = ; // apply new value, will naturally send selection to input end $inputvalue = value; if newSelection // set new {start, end} selection on input ; }
License
MIT