From 09938c264990179cf2d6a731688e72cb2a6c7e12 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 10 Oct 2023 19:19:44 -0400 Subject: [PATCH] perf: Avoid recreating transaction when no upload placeholders exist --- shared/editor/lib/uploadPlaceholder.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/editor/lib/uploadPlaceholder.tsx b/shared/editor/lib/uploadPlaceholder.tsx index 26ebb4b39..5bfe3a72a 100644 --- a/shared/editor/lib/uploadPlaceholder.tsx +++ b/shared/editor/lib/uploadPlaceholder.tsx @@ -18,10 +18,11 @@ const uploadPlaceholder = new Plugin({ // See if the transaction adds or removes any placeholders – the placeholder display is // different depending on if we're uploading an image, video or plain file const action = tr.getMeta(this); + const hasDecorations = set.find().length; // Note: We always rebuild the mapping if the transaction comes from this plugin as otherwise // with the default mapping decorations are wiped out when you upload multiple files at a time. - if (isRemoteTransaction(tr) || action) { + if (hasDecorations && (isRemoteTransaction(tr) || action)) { try { mapping = recreateTransform(tr.before, tr.doc, { complexSteps: true,