WP 5 how to add_editor_style for both tinyMCE and Gutenberg

Before Gutenberg blocks we used to add editor styles by using

add_editor_style( array( 'path/to/editor-style.css', 'whatever.css' ) );

Now we have Gutenberg editor whose stylesheet is also loaded by using the same function.

What if we want to keep stylesheet for both of them? I ask because there are plugins which allow users to disable Gutenberg. Obviously it's not possible to do something like:

 add_editor_style( array( 'editor-style-mce.css', 'editor-style-gutenberg.css' ) );

To make things more complicated for developers, there's an option to use classic editor as a Gutenberg block. It looks like we have to check for Gutenberg availability on after_setup_theme action and load proper editor stylesheet respectively but we can't do much when classic editor is used as Gutenberg block.

Is there anyone capable to provide any kind of solution?

Topic block-editor add-editor-style editor Wordpress

Category Web


You need to call add_theme_support( 'editor-styles' ) in the after_setup_theme hook.

More information

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.