range-limit

Limit a DOM Range to a bounding Node.

Usage no npm install needed!

<script type="module">
  import rangeLimit from 'https://cdn.skypack.dev/range-limit';
</script>

README

Range Limit

Build Status Coverage Status npm

This module exposes a single function, limit(range, bounds), that limits the Range to the contents of bounds, a Node.

Example

var limit = require('range-limit');
var article = document.getElementsByTagName('article');
var range = window.getSelection().getRangeAt(0);
limit(range, article);