How to find the DOM node's pos

I have a code block, which is something like <pre><code></code></pre>

and now I add a language selector outside editor DOM, then I want to get the code block node’s pos while I’m clicking language option.

but it’s hard to get the pos when I can only access the node’s DOM

( because my selection may not be inside the code block element when I’m clicking the language selector, so I can’t just use state.selection to do that )

@marijn I’ll appreciate everything that you could provide for me. :pray:t2::pray:t2::pray:t2::pray:t2:

Does posAtDOM help?

Yes! I actually found it by myself, but thanks for your reply :sweat_smile::sweat_smile::sweat_smile::sweat_smile: