There is no position before the top-level node

<figure-container>
	<figure-list>
		
		<item>
			<image>插图1</image>
			<caption>caption1</caption>
		</item>

		<item>
			<image>插图2</image>
			<caption>插图2</caption>
		</item>

	</figure-list>
</figure-container>

when i delete node:

What’s wrong?

delete node code, in image node


delete_node(){


    let {state} = this.view;

    let {tr} = state;

    let pos = this.getPos();

    let {$from, $to, $head, from} = state.selection;

    let c_pos = tr.doc.resolve(pos+1);

    // parentNode is figure-list node 
    let parentNode = c_pos.node(-2);
    let parentPos = c_pos.start(-2);

   //FigureListMap records the pos mapping of each item

    let figureListMap = new FigureListMap({
        listNode: parentNode,
        listPos: parentPos,
    });


    let currentInfo = figureListMap.get_current_map(pos - 1);

    // i want to delete item node
    tr.delete(currentInfo.pos, currentInfo.pos + currentInfo.size);

    let selc = TextSelection.near(tr.doc.resolve(pos), -1);

    tr.setSelection( selc );

    this.view.dispatch(tr);

},


Something is calling ResolvedPos.before on depth 0, which isn’t meaningful. I can’t tell exactly how that is happening, from the info you provide.

Maybe I deleted all the nodes, and there was no available selection, so failed.

That’s why only deleting the last one and report an error


<block>
	<paragraph>aa</paragraph>
</block>
<figure-container>
	<figure-list>
		<item>
			<image>插图1</image>
			<caption>caption1</caption>
		</item>

		<item>
			<image>插图2</image>
			<caption>插图2</caption>
		</item>

		<item>
			<image>插图3</image>
			<caption>插图3</caption>
		</item>-->


	</figure-list>
</figure-container>

In this way, no mistake will be reported, but I still have doubts about it