From d2fcd1dee688aaf1a0f692b88aabd0d8a939619d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 30 Jul 2023 15:52:08 -0400 Subject: [PATCH] fix: Skip unsupported node types when uploading closes #5544 --- shared/editor/commands/insertFiles.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shared/editor/commands/insertFiles.ts b/shared/editor/commands/insertFiles.ts index 94e4427dd..e1b2715c9 100644 --- a/shared/editor/commands/insertFiles.ts +++ b/shared/editor/commands/insertFiles.ts @@ -75,6 +75,11 @@ const insertFiles = function ( const { tr } = view.state; if (upload.isImage) { + // Skip if the editor does not support images. + if (!view.state.schema.nodes.image) { + continue; + } + // insert a placeholder at this position, or mark an existing file as being // replaced tr.setMeta(uploadPlaceholderPlugin, { @@ -88,6 +93,11 @@ const insertFiles = function ( }); view.dispatch(tr); } else if (!attachmentPlaceholdersSet) { + // Skip if the editor does not support attachments. + if (!view.state.schema.nodes.attachment) { + continue; + } + const attachmentsToUpload = filesToUpload.filter( (i) => i.isImage === false );