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

Editor: solve conflict between Jetpack blocks' @wordpress/editor dependencies and Block-based Widgets Editor #20357

Open
1 of 2 tasks
jeherve opened this issue Jul 14, 2021 · 4 comments
Labels
[Block] Gathering Tweetstorms [Block] Slideshow [Block] VideoPress [Extension] Likes [Extension] Publicize Block editor plugin [Feature] Sharing Post sharing, sharing buttons [Feature] WordPress.com Block Editor [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended

Comments

@jeherve
Copy link
Member

jeherve commented Jul 14, 2021

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

  1. Start with a site using WordPress 5.8 RC
  2. Ensure that your site is connected to WordPress.com.
  3. Now go to Appearance > Widgets; it generates the following notice:
Notice: wp_enqueue_script() was called incorrectly. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets). Please see Debugging in WordPress for more information. (This message was added in version 5.8.0.) in wp-includes/functions.php on line 5535

We have different things to address here:



  • Address @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:

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.

  • Since all our blocks and extensions are part of one big bundle, it also includes blocks and extensions that really do not make sense (and in this case output a warning) in the widget editor, such as sharing.
  • At the same point, some of our blocks really would make sense in that context.

How should we approach this?

@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Pri] Normal [Feature] WordPress.com Block Editor labels Jul 14, 2021
@jeherve jeherve added this to the jetpack/9.9.1 milestone Jul 14, 2021
jeherve added a commit that referenced this issue Jul 14, 2021
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.
@jeherve jeherve changed the title WordPress.com Block Editor: solve conflict with Block-based Widgets Editor Editor: solve conflict between Jetpack blocks' @wordpress/editor` dependencies and Block-based Widgets Editor Jul 14, 2021
@jeherve jeherve added [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Block] Gathering Tweetstorms [Extension] Likes [Block] Publicize [Feature] Sharing Post sharing, sharing buttons [Block] Slideshow [Block] VideoPress labels Jul 14, 2021
@jeherve jeherve removed their assignment Jul 14, 2021
@jeherve jeherve changed the title Editor: solve conflict between Jetpack blocks' @wordpress/editor` dependencies and Block-based Widgets Editor Editor: solve conflict between Jetpack blocks' @wordpress/editor dependencies and Block-based Widgets Editor Jul 14, 2021
@jeherve
Copy link
Member Author

jeherve commented Jul 14, 2021

I'm not quite sure how to approach that problem at this point.

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.

@jeherve
Copy link
Member Author

jeherve commented Jul 14, 2021

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.

Based on this idea, I opened #20362, which leverages an existing block bundle of ours, currently in use on P2.

sdixon194 pushed a commit that referenced this issue Jul 14, 2021
… 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.
jwebbdev pushed a commit that referenced this issue Jul 14, 2021
…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.
@jeherve jeherve reopened this Jul 15, 2021
@sdixon194 sdixon194 modified the milestones: jetpack/9.9.1, jetpack/10.0 Jul 20, 2021
@jeherve jeherve added [Extension] Publicize Block editor plugin and removed [Block] Publicize labels Sep 15, 2021
@jeherve jeherve removed this from the jetpack/10.3 milestone Oct 21, 2021
anomiex added a commit that referenced this issue Nov 16, 2021
anomiex added a commit that referenced this issue Nov 16, 2021
…"" (#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.
pablinos added a commit that referenced this issue May 27, 2022
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.
pablinos added a commit that referenced this issue May 30, 2022
…es (#24545)

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.
jeherve added a commit that referenced this issue Jan 5, 2023
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.
@jeherve
Copy link
Member Author

jeherve commented Jan 5, 2023

I've opened this issue on the Gutenberg side to see if there is something that could help there:
WordPress/gutenberg#46900

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.

@danielbachhuber
Copy link
Contributor

Here's another side effect of this problem: Automattic/wp-calypso#66474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gathering Tweetstorms [Block] Slideshow [Block] VideoPress [Extension] Likes [Extension] Publicize Block editor plugin [Feature] Sharing Post sharing, sharing buttons [Feature] WordPress.com Block Editor [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended
Projects
No open projects
Status: Blocked/On Hold
Development

Successfully merging a pull request may close this issue.

4 participants