From 3707d6aaa80699c203a2e58f68eaa106ef5af16d Mon Sep 17 00:00:00 2001 From: noname Date: Sun, 27 Jun 2021 17:59:02 +0200 Subject: [PATCH] #34 - Ability to work only with TextPositionSelector and without TextQuoteSelector - Calculate length from offsets instead of from quote --- src/highlighter/Highlighter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/highlighter/Highlighter.js b/src/highlighter/Highlighter.js index 9b992d1..4b1ecf9 100644 --- a/src/highlighter/Highlighter.js +++ b/src/highlighter/Highlighter.js @@ -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)); } }