The browser DOM Selection API provides properties showing what node and offset a selection begins at (Selection.anchorNode
and Selection.anchorOffset
), and what node and offset the selection ends at (Selection.focusNode
and Selection.focusOffset
). In some of my selection handling methods, I need to normalize these values to a consistent direction. It got me wondering, in what situations would the direction of a selection matter? It's not for handling RTL languages; users arbitrarily select in either direction in any language.
I asked the question on the ProseMirror support board.There are common behaviors that make use of the directionality of a DOM selection: