diff --git a/shared/editor/commands/insertFiles.ts b/shared/editor/commands/insertFiles.ts index e3db080d5..3982fe73d 100644 --- a/shared/editor/commands/insertFiles.ts +++ b/shared/editor/commands/insertFiles.ts @@ -83,15 +83,13 @@ const insertFiles = function ( }); view.dispatch(tr); } else if (!attachmentPlaceholdersSet) { - const $pos = tr.doc.resolve(pos); const attachmentsToUpload = filesToUpload.filter( (i) => i.isImage === false ); view.dispatch( - view.state.tr.replaceWith( - $pos.pos, - $pos.pos + ($pos.nodeAfter?.nodeSize || 0), + tr.insert( + pos, attachmentsToUpload.map((attachment) => schema.nodes.attachment.create({ id: attachment.id,