How to insert multi images in a one-time

I have a array of image’s url, I want to insert them to editor in one-time. But now i read the example, the replaceSelectionWith function only accept one node

 run: (state, dispatch) => {
    ... // get url code
    img = schema.nodes.image.createAndFill({ src: url })

How can i use this function or other way to insert multi images

You can’t, but you could wrap them in a slice with new Slice(Fragment.from(imageNodes), 0, 0) and pass that to replaceSelection. Or, alternatively, call replaceSelectionWith once for each node.

1 Like

@marijn Thank you. Your suggestion worked great.

By the way, may i ask for another question that recently I can’t in perfect way to realize it.

It’s alignment.

I have read that topic Implementing alignment. And I use class such as "align-right" to control the alignment like the questioner. But it didn’t seem to work, I don’t know how to wrap the nodes because it not perfect combination with the order_lis and bullet_list. Maybe your suggestion will make me suddenly see the light.

thx again!