-
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
Fix: Remove editor usage from media blocks. #15548
Fix: Remove editor usage from media blocks. #15548
Conversation
What about Gallery block? It uses |
I personally don't like this pattern in the current shape as I anticipate that it's going to be copied to 3rd party blocks even though we prefix the method with |
All the blocks changed in this PR had the same change. The gallery bock is a different case, so I will try to address it in a different PR.
I think an option is to remove __experimental prefix. Another option is to add the behavior of uploading temporary URLs to MediaPlaceholder or to a new component part of block-editor, so blocks will not have a need to call a mediaUpload function directly. |
This |
It is also important to note that while import { mediaUpload } from '@wordpress/editor'; does not contain any experimental flag, third-party blocks may use this option instead of something similar to what I did in this PR (that contains the experimental flag), and if that's the case, we may have a problem as these blocks will not work on the widget screen. |
By that time, both the widget screen and this API won't be considered experimental I think |
What about using this __experimentalMediaUpload setting in our own blocks, is it something we are ok with for now? Or should we try to abstract this call inside a new component or inside MediaPlaceholder? |
I was saying, I'm ok with us using it. For third party blocks, The experimental APIs are documented clearly, why this one should be an exception. |
It’s fine to merge it as a stopgap solution but it would be nice to address it before WordPress 5.3 release. I think that the biggest downside of this approach is that it introduces a lot of complexity which would be nice to hide for plugin developers as @jorgefilipecosta mentioned thus making it an implementation detail. |
c7338ee
to
e405fb6
Compare
This PR was updated, and now we are also addressing the gallery case, this makes the gallery way of handling file drops in line with the approach used by all other blocks. |
|
||
export default withNotices( AudioEdit ); | ||
export default compose( [ | ||
withSelect( ( select ) => { |
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.
What about useSelect
;)
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.
Hi @youknowriad I did not use useSelect because these are class components (where hooks could not be used), and most of the cases already had a withSelect usage. I guess if there are some benefits of the usage of the hook, we can create specific PR's with a refactor to hooks before the next block change.
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.
Makes sense
It looks like with this change, the only other parts where we use the "core/editor" store or the editor package in the block library are:
|
Description
Blocks should not use editor module directly and the editor module may not available in all edition environments (e.g. in the widget screen).
This PR makes sure the mediUpload function used in the image, audio, video, and file blocks is the one provided in the block-editor settings instead of being the one from wordpress/editor.
How has this been tested?
I tried to insert all the changed blocks by dragging files in the editor and I verified thigs worked as expected.