-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Paste: reuse file transforms for file pasting #45891
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +15 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
df52970
to
5288158
Compare
I just gave it a quick test from the angle of the Gallery/Image paste side and this change doesn't affect anything there at all - the Gallery block ignores pastes as it does in trunk at the moment, only drag and drop works (would be nice to enable paste at some point), and the Image block only accepts image file pastes ... but pasting elsewhere in canvas works for video file as advertised. |
Ah nice, I didn't know that. Yes, let's enable that in a separate PR. I don't want to overcomplicate this one right now. |
27a8cc8
to
08cff36
Compare
@glendaviesnz Could you test again with Gallery and review the changes to the gallery block? We made some changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Pasting images with the gallery block placeholder selected now adds those images to the gallery, and all other gallery functions seem to work as expected.
Pasting non-image files onto the gallery placeholder replaces the gallery block with the relevant block type, eg. video or file block. This is different to the behaviour when dragging and dropping invalid file types onto the placeholder, in which case they are rejected with a message about invalid file type. It would be good if the behaviour was the same in both cases, but I don't have an opinion about which would be preferred, and I don't think it should hold up this PR.
All the other pasting worked as expected for me with these changes, ie. single and multiple image, video or pdf files pasted in the canvas created the relevant blocks.
* Paste: reuse file transforms for file pasting * Make sure files is defined * paste multiple file types * fix for gallery block * Make sure gallery block settings sync Co-authored-by: ntsekouras <ntsekouras@outlook.com>
What?
Fixes #45408.
Don't know why this hasn't come up before. Guess no one tried to paste videos or audio before?! 😄
My only concern with this (and for dropping files) is that it assumes all the files will be off the same block type. That should be fixed...
Requesting some reviews here of people that have previously worked on adding the transforms for dropping files.
Why?
Currently it's not possible to paste anything but image files.
How?
This PR reuses the
files
transforms that we already have on blocks for file pasting also, instead of creating some HTML with blob URLs to run through the raw handler.Testing Instructions
Copy a video and paste it in Gutenberg.
Screenshots or screencast