expand-selection

Add matching text to the current DOM selection

Usage no npm install needed!

<script type="module">
  import expandSelection from 'https://cdn.skypack.dev/expand-selection';
</script>

README

npm

expand-selection

Dependency Status

Add matching text to the current DOM selection.

API

expandSelection(string, [opts])

expandSelection([selection], [opts])

Searches document for string or selection.toString() and selects matching ranges.

selection defaults to window.getSelection().

Returns Selection object.

opts.clear

Clears current selection before updating. Defaults to false.

opts.ignoreCase

Whether to ignore case while attempting a match in a string. Defaults to false.

Install

npm install expand-selection

License

MIT