How to insert paragraphs after pasted images?

I tried inserting them in transformPasted but they’re only inserted inconsistently (only the first paste affected.)

So I tried to move to appendTransaction but it has a different problem where pasting images rapidly leads to a varying number of paragraphs between the images.

I try to insert two paragraphs and move selection to the second so that the next paste will occur on it and overwrite it, such that there will be a single paragraph between the pasted images - but when pasting rapidly there’s usually two such paragraphs there, and sometimes none at all.

When I paste very slowly it’s perfectly reliable - always one paragraph between the images.

I don’t understand why because I’ve never had this seemingly async-like problem before when using appendTransaction.

Am I doing something wrong, or am I making bad assumptions about the safety of appendTransaction?

I’m still wondering if anyone has any suggestions for this.

I tried several approaches and they all have drawbacks, either inconsistency in whether a paragraph is inserted, or inconsistency in how many paragraphs get inserted.