Skip to content

Dropping or pasting several files only inserts the first one #3212

Closed

Description

@fer2d2

What's broken?

When you drop (or paste) several files into the editor at once, only the first one is uploaded and inserted. The others are silently ignored.

handleFileInsertion keeps a reference to dataTransfer.items and calls items[i].getAsFile() inside the loop, after await editor.uploadFile(...) for the previous file. Browsers only expose drag/clipboard data while the event is being dispatched synchronously; after that the data store is protected and the item list is empty, so by the time the first upload resolves there is nothing left to read.

https://github.com/TypeCellOS/BlockNote/blob/main/packages/core/src/api/clipboard/fromClipboard/handleFileInsertion.ts#L101-L195

What did you expect to happen?

Every dropped/pasted file gets its own block and is uploaded, in order.

Steps to reproduce

  1. Use any editor with uploadFile set (e.g. the "Upload files" example).
  2. Select two images in your file manager and drag them into the editor together.
  3. Only the first image is inserted and uploaded.

It is easier to see with an uploadFile that takes a moment to resolve, which is what any real upload does.

BlockNote version

0.55.0, also on 0.56.0 and current main

Contribution

  • I'd be interested in contributing a fix for this issue

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions