From 8de9ec8234a79ed80734474459f89d9d5175f69f Mon Sep 17 00:00:00 2001 From: Hossein Date: Tue, 24 Aug 2021 09:20:24 -0400 Subject: [PATCH] fix image paste messing with content stuffz (#1075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jesús Espino Co-authored-by: Mattermod --- webapp/src/components/cardDetail/imagePaste.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/cardDetail/imagePaste.tsx b/webapp/src/components/cardDetail/imagePaste.tsx index 6c12ec167..d6d740a00 100644 --- a/webapp/src/components/cardDetail/imagePaste.tsx +++ b/webapp/src/components/cardDetail/imagePaste.tsx @@ -11,6 +11,11 @@ export default function useImagePaste(cardId: string, contentOrder: Array { let newImage: File|null = null const uploads: Promise[] = [] + + if (!items.length) { + return + } + for (const item of items) { newImage = item if (newImage?.type.indexOf('image/') === 0) { @@ -30,10 +35,13 @@ export default function useImagePaste(cardId: string, contentOrder: Array b.id)) + mutator.performAsUndoGroup(async () => { await mutator.insertBlocks(blocksToInsert, 'pasted images') - const newContentOrder = [...contentOrder, ...blocksToInsert.map((b: ImageBlock) => b.id)] - return mutator.changeCardContentOrder(cardId, contentOrder, newContentOrder, 'paste image') + await mutator.changeCardContentOrder(cardId, contentOrder, newContentOrder, 'paste image') }) }, [cardId, contentOrder, rootId]) @@ -58,5 +66,5 @@ export default function useImagePaste(cardId: string, contentOrder: Array