nl_tokens: Returns { start end } where start is the character / codepoint index of ( anchorNode anchorOffset ) within the textContent of outerNode and end is the index of ( focusNode focusOffset ) .
pl_tokens: function getModernOffsetsFromPoints ( outerNode , anchorNode , anchorOffset , focusNode$$1 , focusOffset ) { var length = 0 ; var start = - 1 ; var end = - 1 ; var indexWithinAnchor = 0 ; var indexWithinFocus = 0 ; var node = outerNode ; var parentNode = null ; outer : while ( true ) { var next = null ; while ( true ) { if ( node === anchorNode && ( anchorOffset === 0 || node . nodeType === TEXT_NODE ) ) { start = length + anchorOffset ; } if ( node === focusNode$$1 && ( focusOffset === 0 || node . nodeType === TEXT_NODE ) ) { end = length + focusOffset ; } if ( node . nodeType === TEXT_NODE ) { length += node . nodeValue . length ; } if ( ( <mask> = node . firstChild ) === null ) { break ; } // Moving from `node` to its first child `next`. parentNode = node ; node = next ; } while ( true ) { if ( node === outerNode ) { // If `outerNode` has children, this is always the second time visiting // it. If it has no children, this is still the first loop, and the only // valid selection is anchorNode and focusNode both equal to this node // and both offsets 0, in which case we will have handled above. break outer ; } if ( parentNode === anchorNode && ++ indexWithinAnchor === anchorOffset ) { start = length ; } if ( parentNode === focusNode$$1 && ++ indexWithinFocus === focusOffset ) { end = length ; } if ( ( next = node . nextSibling ) !== null ) { break ; } node = parentNode ; parentNode = node . parentNode ; } // Moving from `node` to its next sibling `next`. node = next ; } if ( start === - 1 || end === - 1 ) { // This should never happen. (Would happen if the anchor/focus nodes aren't // actually inside the passed-in node.) return null ; } return { start : start , end : end } ; }