jquery.textSelection: Add 'replaceSelection' method
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 8 Feb 2018 18:30:42 +0000 (19:30 +0100)
committerJforrester <jforrester@wikimedia.org>
Thu, 8 Feb 2018 23:48:04 +0000 (23:48 +0000)
commit384455a5cf526e01452ec12382d9590708a1d52a
tree387dc51daf3ead220ceb8d84d548962efc019db5
parent02a067c0996558bc2d96bf4094bb2e74948fcb71
jquery.textSelection: Add 'replaceSelection' method

replaceSelection is a little brother of encapsulateSelection.
It can't do as much, but tries really hard to do it well.

Alternative textSelection APIs can implement it in an optimized
way if they can more efficiently replace small fragments of the
textfield's contents than the entire thing.

Additionally:
* encapsulateSelection uses replaceSelection internally.
* setContents now also preserves the scroll position.
* setContents is now chainable.

Bug: T185917
Change-Id: I05086ddce2ddd857ff88eba75cfdb6bf877bd924
resources/src/jquery/jquery.textSelection.js