ResolvePos works unexpected for atom block node

Hi! I want to implement custom drag-handler for each block nodes and it works for block nodes with content, but it doesn’t work for atom block nodes. When I try to get a node under a specific position I get a parent node for atom block nodes instead of this node itself.

let $pos = view.state.doc.resolve(pos);
let node = $pos.node();

But if I add content property it works as expected and returns the block node itself. Does it bug or it is expected? Or maybe I should choose another way to implement my task?

This is expected. .node() gives you the parent node around the position, and leaf nodes have no positions inside of them. But if you have the position before them, you can use ResolvedPos.nodeAfter to get the node (or just directly doc.nodeAt).

1 Like

Got it. Thank you for quick answer.