Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When dragging multiple file types to the editor canvas, detect and insert Image, Video, or File blocks as appropriate #65074

Closed
andrewserong opened this issue Sep 5, 2024 · 0 comments · Fixed by #65144
Assignees
Labels
[Block] File Affects the File Block [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Feature] Drag and Drop Drag and drop functionality when working with blocks [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@andrewserong
Copy link
Contributor

What problem does this address?

Based on discussion in #65030 and related to #64795, when a user drags a mix of file types to the editor canvas or onto an empty Paragraph block, we currently insert all the blocks as File blocks, and a warning about the Gallery block displays:

image

What is your proposed solution?

Instead, as suggested by @swissspidy, let's iterate over the files being dragged, and if there's an image or a video, create the appropriate blocks. Pascal as already implemented a solution for this in the media experiments plugin, so that approach could be borrowed. See: #65030 (comment)

Can't we just make it work? I find these notices very annoying and unnecessary when we could actually make it work.
Here's how I solved it in my project:
https://github.com/swissspidy/media-experiments/blob/b1d0910bec2835158f31e971702393117889055b/packages/editor/src/transforms/index.ts
When you drop e.g. an audio file, image and a video at the same time, it will insert an audio block, image block, and a video block. Anything else could be a file block.

@andrewserong andrewserong added [Type] Enhancement A suggestion for improvement. [Feature] Drag and Drop Drag and drop functionality when working with blocks [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Block] File Affects the File Block labels Sep 5, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] File Affects the File Block [Block] Image Affects the Image Block [Block] Video Affects the Video Block [Feature] Drag and Drop Drag and drop functionality when working with blocks [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
1 participant