From fcc89be622daa15ded438cc4d50dbd3315de6762 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 28 Mar 2023 20:47:34 -0400 Subject: [PATCH] fix: File uploads can remove document closeby document content, closes #5097 --- shared/editor/commands/insertFiles.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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,