Two caret coordinates share one ProseMirror position?

I noticed today that two caret coordinates can share a single position in the editor.

(See demo here: Watch prosemirror-two-caret-coordinates-one-position | Streamable) - You can see that the selected position is listed in the bottom-left.

On one hand this is sensible, but on the other hand, I wonder if there’s a way I can differentiate between them given that they share a position, and so that view.getCoordsAtPos and view.getPosAtCoords could not be used to glean more information here.

Based on some quick testing, I think plain contentEditable insert a   in these cases and I guess (thankfully) ProseMirror masks this, but in this single case it’s less of a blessing. Is there any approach to differentiate them that I’m overlooking?

Right, a line wrap will cause the position of the wrap to be ‘split’ among two lines. This is not really avoidable (and I’m not sure what you mean by inserting an nbsp—the same phenomenon exists in plain contentEditable, there’s not much non-breaking spaces can change about it unless you want to disable line wrapping entirely). ProseMirror does not support addresing a specific side of a position.

1 Like