Mismatch between docs and actual class structure

I’m trying to deduce if the current selection is within a specific node. To do that I first calculate the nodeRange using the following code:

const nodeRange = state.selection.$from.blockRange(

Now, If I console.log this I can see a path field, which I can access with:


$from in the above case if of class ResolvedPos (https://prosemirror.net/docs/ref/#model.ResolvedPos). But in the documentation the path field is not present (nor in the typescript declarations).

So, is this even a reliable field to use or we should avoid it? It could definitely help me with my initial objective to see if the current selection falls within a single node (e.g. a bulleted list). Also, is there a more easy/elegant way to achieve this?

Just for reference I ended up using the following code to achieve my goal.

const {
    selection: { from, to },
  } = state;

  doc.nodesBetween(from, to, (node) => {
    ...my logic here

Things that aren’t documented are private. So yeah, try not to use them since there are no stability guarantees for them.

1 Like