Skip to content

Commit

Permalink
#34 - Ability to work only with TextPositionSelector and without Text…
Browse files Browse the repository at this point in the history
…QuoteSelector

- Calculate length from offsets instead of from quote
  • Loading branch information
noname committed Jun 27, 2021
1 parent f4e54a4 commit 3707d6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/highlighter/Highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ export default class Highlighter {
getAnnotationsRecursive(parent, annotations) : annotations;
},

sortByQuoteLength = function(annotations) {
sortByRangeLength = function(annotations) {
return annotations.sort(function(a, b) {
return a.quote.length - b.quote.length;
return (a.end - a.start) - (b.end - b.start);
});
};

return sortByQuoteLength(getAnnotationsRecursive(element));
return sortByRangeLength(getAnnotationsRecursive(element));
}

}

0 comments on commit 3707d6a

Please sign in to comment.