-
Notifications
You must be signed in to change notification settings - Fork 798
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
Editor: solve conflict between Jetpack blocks' @wordpress/editor dependencies and Block-based Widgets Editor #20357
Comments
Fixes #20357 Since the WordPress.com Block editor relies on wp-editor, and since that dependency cannot be used in the widget editor (see https://core.trac.wordpress.org/changeset/51393 ), let's not load the WordPress.com editor scripts in the widget editor.
One potential approach I can think of would be to split our bundle in two: one that is meant to be used in the widget editor, and the other that is meant to be used in the post editor. That doesn't seem like the perfect solution for performance though. I'm also not sure how we could automatically define whether a block is meant to be used in one context or the other. |
Based on this idea, I opened #20362, which leverages an existing block bundle of ours, currently in use on P2. |
… Block-based Widgets Editor (#20358) Fixes #20357 Since the WordPress.com Block editor relies on wp-editor, and since that dependency cannot be used in the widget editor (see https://core.trac.wordpress.org/changeset/51393 ), let's not load the WordPress.com editor scripts in the widget editor.
…dgets Editor (#20358) Fixes #20357 Since the WordPress.com Block editor relies on wp-editor, and since that dependency cannot be used in the widget editor (see https://core.trac.wordpress.org/changeset/51393 ), let's not load the WordPress.com editor scripts in the widget editor.
…"" (#21763) The new `Assets::register_script` wrapper worked great. In fact, a bit too good: it picked up a style dependency that was missing from the editor JS, which broke the Widget Editor and the Site Editor because that dependency is specifically not supposed to be loaded there (see #20357). This reverts #21760 and adds a hack around the way that #20357 made things break with the new wrapper.
There's a bug #20357 that means if code is loaded that relies on the `@wordpress/editor` or `@wordpress/edit-post` packages, then it crashes the Site Editor. This change checks the post type being editted and whether it supports Publicize. If it doesn't, we skip loading the JS code.
Fixes #28184 1. We do not need Blaze in the site editor, since we cannot promote specific posts from there. 2. The Blaze panel relies on @wordpress/editor, which we cannot use in the site editor or the widget editor. 3. When we enqueue the Blaze panel in the site editor or the widget editor, we run into this issue: #20357. This causes Fatal errors just like the one we experienced and worked around in #21763. To solve this issue, we switch to using the admin_enqueue_scripts hook to decide whether when to enqueue our script. It allows us to conditionally enqueue the file based on the page we're on, which is something the enqueue_block_editor_assets hook does not allow yet.
I've opened this issue on the Gutenberg side to see if there is something that could help there: It's worth noting that it wouldn't necessarily help us with the big Jetpack bundle since our bundle currently includes multiple blocks, some good for the site editor, others not. But it may help with standalone blocks / plugins, like the one introduced in #28062. |
Here's another side effect of this problem: Automattic/wp-calypso#66474 |
WordPress 5.8 introduces a new Block-based Widgets Editor, and both our block bundle and the WordPress.com Block Editor conflicts with it at the moment.
Steps to reproduce the issue
We have different things to address here:
@wordpress/editor
dependencies in our own blocks.Jetpack's block bundle (also loaded on WordPress.com Simple) has some blocks and extensions that rely on
@wordpress/editor
:jetpack/projects/plugins/jetpack/extensions/blocks/gathering-tweetstorms/editor.js
Line 5 in 41fe374
jetpack/projects/plugins/jetpack/extensions/blocks/gathering-tweetstorms/use-gather-tweetstorm.js
Line 30 in e13487d
mediaUpload
from the package to upload media in the Slideshow, Video, and Tiled Gallery blocks.However, that
@wordpress/editor
package cannot be used in the new block-based widget editor, since we're not in a post editor.For this reason, Core started outputting a
_doing_it_wrong()
notice for folks using that package in the block-based widget editor.I'm not quite sure how to approach that problem at this point.
How should we approach this?
The text was updated successfully, but these errors were encountered: