At Storyscript, we’re looking at a possible peculiarity with positions in Prosemirror that we’re trying to understand.
I have the following document structure and my caret is at the •:
<div>
<span class="text">
•Text
</span>
</div>
I modified the plugin example for showing selection size to also show the index of “from” & “to”
I was expecting that this position would show as “2” based on the counting algorithm described in the intro guide, but I am seeing “1”.
This seems confusing because I would want to have a distinct position for the position between <div>•<span ...
Is the <div> the outer document container? Positions are counted from the start of the top nodes content, so the top node’s open token doesn’t count (you can’t put your cursor in front of it).
So, it doesn’t make sense that we could have a position in between these two elements. I think I was experiencing issues with the gap cursor it that it would allow me to drop things before that span, which caused me to be confused. We removed the extra span and we’ll go forwards with that!