in src/plugin/fieldViews/RepeaterFieldView.ts [148:171]
public removeChildAt(index: number) {
if (index < 0 || index > this.node.childCount - 1) {
console.error(
`Cannot remove at index ${index}: index out of range. Minimum 0, Maximum ${
this.node.childCount - 1
}`
);
return;
}
if (this.node.childCount === this.minChildren) {
return;
}
const tr = this.outerView.state.tr;
const nodeToRemove = this.node.child(index);
const startOfNodeToRemove = this.getStartOfChildNode(
this.node,
index,
this.getPos(),
this.offset
);
const endOfNodeToRemove = startOfNodeToRemove + nodeToRemove.nodeSize;
tr.deleteRange(startOfNodeToRemove, endOfNodeToRemove);
this.outerView.dispatch(tr);
}