How to get absolute position of any node?

Hello, I’m trying to get the absolute positions of table cells in a table so I can change their attributes. I need to do this without selecting the table cells. For example, if someone clicks a table, and then clicks a style button, all the table cells in the table will have their attributes changed. The table is a node, the table rows are nodes, and the table cells are nodes. I’m not in any node view. So, how could I get the absolute position of a node? Thanks.

Resolve those positions with the current editorview document.

You generally should track the node by position from the start. There’s not really any other way to refer to nodes—node objects’ identities aren’t useful in ProseMirror, since they have value semantics and might occur multiple times in a document, and will be copied whenever anything inside them changes.

Thank you. I’ll take a look at that.

Thank you for replying. Hmm, how would I do that? Wouldn’t the node position change as text or any content is added above the table? When I select a node, and I console.log(editor.state.selection) I see a path attribute in the selection object. This path attribute is an array that seems to trace the path from the doc node to the selected node. How is the path calculated? Thanks

Another question is how can I select all the nodes of a table with just code? That might help me too. Thanks

Yes, you will have to map the position as transactions come in.

Create a selection object (if you’re using prosemirror-tables, you probably want a CellSelection, otherwise this sounds like it should be a NodeSelection) and dispatch a transaction that sets that selection.

Thank you so much!