I’ll try to be more descriptive using code and commenting: rp.node() correctly refers to a rowNode(the rowNode initially has a two child colNodes). However when I create the nodeSelection from rp, it’s node property points to the child colNode. When the replace occurs the colNode is replaced rather than the rowNode as intended. Am I misunderstanding something simple about the NodeSelection?
public setRowColCount(update:{position:number,count:number}){
let tr = this.view?.state.tr;
const rp = this.view?.state.doc.resolve(update.position);
if(rp && tr){
let schema=wcSchema;
const oldNode=rp.node(rp.depth);
const nodeSel = new NodeSelection(rp);
const children:Node[]=[];
for(let i = 0;i<update.count;i++){
children.push(schema.nodes['colNode'].create());
}
const oldattrs = oldNode.attrs;
const newRowNode =schema.nodes['rowNode'].create(oldattrs,children);
tr=tr.setSelection(nodeSel).replaceSelectionWith(newRowNode,true);
const newpos = tr.mapping.map(update.position);
this.view?.dispatch(tr)
this.docvalue=this.toHTML();
this.createNodeSetFrom(newpos);
}
}