recogito / recogito-js

A JavaScript library for text annotation
BSD 3-Clause "New" or "Revised" License
363 stars 42 forks source link

Ability to work only with TextPositionSelector and without TextQuoteSelector #34

Closed reckart closed 3 years ago

reckart commented 3 years ago

I would like to be able to use RecogitoJS without having to send a TextQuoteSelector which would create a lot of unnecessary data between client and server especially for long ranges. If there is a TextPositionSelector, it should be enough. Unfortunately, the current code won't work without a TextQuoteSelector:

Screenshot 2021-06-27 at 16 38 20
rsimon commented 3 years ago

After a brief look, I think the quote is only used in a few places to sort annotations by length. (In order to determine the top-most annotation on click.) This, obviously can be done with TextPosition alone, too.

Would you be up for a pull request on this one?

reckart commented 3 years ago

Incoming...

reckart commented 3 years ago

I did a PR with a quick fix. A better fix would probably be to move fetching the length entirely into the annotation object and then the annotation can use either the position or the quote to calculate the length - depending on what is available - and the code that sorts by length no longer has to worry about how to calculate the length.

rsimon commented 3 years ago

Many thanks! I agree, length would ideally be a property/method of the annotation. But this works well for now :-)