You shouldn’t use node values like that—they don’t uniquely identify a position in the document. Use offsets whenever you need to indicate document positions, and you won’t have this problem.
If I want to insert a column after the second column, what’s the best way? I’m also studying the source code of prosemirror-tables, but I can’t understand it. Please give me some advice
Find the position, in each row, after the first column, and insert the cells there. If you have a table table that you know is at position tablePos, you could do something like
table.forEach((row, offset) => {
let rowPos = tablePos + 1 + offset
let insertPos = rowPos + row.firstChild.nodeSize
// Do something with insertPos
})