I have an image block with the following schema:
export const IMAGE_NODE_SPEC: NodeSpec = {
...
atom: true,
toDOM: () => {
return ['img'];
},
...
};
When I try to delete the above image block, prosemirror doesn’t seem to give me the correct node index:
const view = new EditorView(editorRef.current, {
...
dispatchTransaction: (transaction) => {
const { steps, doc } = transaction;
if (steps[0] instanceof ReplaceStep) {
const indexOfDeletingNode = doc.resolve(steps[0].from).index(0);
// indexOfDeletingNode becomes larger than doc.childCount
console.log(indexOfDeletingNode, doc.childCount);
}
...
view.updateState(newState);
},
...
});
Am I doing something wrong?