-
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
Classic Editor fails to load in Visual edit #4678
Comments
Wouldn't this break all blocks which enqueue for the actual Gutenberg editor screen? |
No, see the table that I have created in bobbingwide/oik-block#8 These blocks are enqueued in response to |
I've revisited this issue with an update to the Text Widget part of the problem. When responding to
When responding to
But when the scripts are defined using register_block_type
and the script has been registered with dependencies on The fix for this is either to not register scripts that have these dependencies
Comments appreciated. |
@bobbingwide Could you boil this down to a minimal reproducible case? I'm trying to reproduce unsuccessfully, registering a block during |
@aduth Just to confirm that the Classic editor loads but the Text widget doesn't. Have you tried that part of the problem? |
Yes, I tried using the Text Widget and it loaded okay in my minimal example. Here's the code I have in its entirety: <?php
/*
* Plugin Name: Demo Block
*/
function demo_block_init() {
wp_register_script(
'demo-block',
plugins_url( 'demo-block.js', __FILE__ ),
[ 'wp-blocks', 'wp-element' ]
);
register_block_type( 'demo/demo-block', array(
'editor_script' => 'demo-block',
) );
}
add_action( 'init', 'demo_block_init' ); (Tried both |
Your code fails for me when it's register_block_type with 'script' => 'demo-block'. Still getting the same console messages as in #4678 (comment) |
@bobbingwide Is this still an issue? |
Issue Overview
If an extension plugin responds to
enqueue_block_assets
and it enqueues its own script, with dependencies on Gutenberg's scripts, then this can break the Classic Editor in Visual mode.Steps to Reproduce (for bugs)
enqueue_block_assets
using code similar to below.Expected Behavior
You should be able to toggle between the Text and Visual editor modes without failure.
Current Behavior
You can merrily edit in Text mode, but attempting to switch to Visual will lead to an empty TinyMCE window with no icons. Once this has happened it's very difficult to get back to Text without deactivating a plugin or two.
Possible Solution
When using the Classic Editor there should be no need for Gutenberg blocks.
The
classic-editor
parameter is passed in the request and is available from$_GET
.A new test is required to avoid invoking
enqueue_block_assets
.As a workaround, for my plugin, I added the test to my own action hook function.
Screenshots / Video
Related Issues and/or PRs
This was originally raised as Scenario 3 in #4672.
Todos
The text was updated successfully, but these errors were encountered: