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 );