Given a page like this:
<p>
<span class="1">Here's some text</span>
<span class="2">that the user</span>
<span class="3">could select.</span>
</p>
If a user selects the whole sentence (from "Here's" to "select."), I want to return "1" and "3".
If a user selects part of the sentence (from "some" in span 1 to "the" in span 2), I want to return "1" and "2".
What's the best approach here?
*Edit - I'm looking for a solution that allows for highlighting multiple pieces of (non-overlapping) text concurrently.
For example: "Here's some text that" and "user could select." - In this case, [[1,2],[2,3]] would be returned.