I’m building and editor that allows uploading multiple files at the same time. It’s based on: ProseMirror upload example However that example allows to upload only one image at a time. I found that I can not replace placeholders one by one, because after the first replacement all placeholders are gone. I managed to add uploaded images before placeholders list by doing:
const found = this.props.findPlaceholder(view.state, id)
if (!found) return
const pos = found.from
// Otherwise, insert it at the placeholder's position, and remove
// the placeholder
view.dispatch(
view.state.tr
.insert(
pos - 1,
schema.nodes.image.create({
src: url,
file: response,
})
)
.setMeta(this, { remove: { id } })
)
However, when there’s a text right before insertion image will be inserted before the last letter of that text. How can I add an image right before placeholders but after any node that’s also before placeholders? Also how could I approach replacing the exact placeholder that was changed, so that for example images 1 and 3 are loaded and 2 is loading so it should show placeholder between two images?