Hey, as I was again twiddling with ResolvePos, I noticed that ProseMirror Reference manual (as well as end
I suppose) never point to the node pos at the given depth but inside it.
For example in https://prosemirror.net/ if I resolve the pos within the second paragraph view.state.doc.resolve(30).start(2)
returns 18
which sure enough, using nodeAt
resolves into the text node using view.state.doc.nodeAt(18)
. However, if I use view.state.doc.resolve(30).start(1)
this returns 17
which still resolves to the same text node. And moreover, using view.state.doc.resolve(30).start(0)
returns 0
, the start of the document which is kinda pointless since does that ever change?
Is this correct? Shouldn’t start & end work differently and return the actual positions of the nodes at said depth?
EDIT: Oh I see. before
& after
were the methods I was looking for. Hmm well I would deprecate the start & end as IMO there should be just one good way of doing this. Kinda confusing. And it seems with before
using before(0)
just throws an error which seems kinda clunky to have to if
this myself but I digress.