1.0.3 • Published 8 years ago

dom-range-diff v1.0.3

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
8 years ago

dom-range-diff

a micro function to provide the difference between two DOM Ranges.

Usage

use es6 syntax

import domRangeDiff from 'dom-range-diff';

var array = [];

window.addEventListener('mouseup', function(e) {
  /* if some text is selected save the range */
  if (!window.getSelection().isCollapsed) {
    array.push(window.getSelection().getRangeAt(0));

    /* when two ranges were selected, extract the difference between the first and the second, then apply it */
    if(array.length === 2) {
      window.getSelection().removeAllRanges();
      domRangeDiff(array[0], array[1]).map(range => {
        window.getSelection().addRange(range);
      });
      array = [];
    }
  }
});
1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago