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

Inconsitency to core: theme support feature 'editor-styles' <-> 'editor-style' #12169

Closed
j-hoffmann opened this issue Nov 21, 2018 · 2 comments
Closed
Labels
[Feature] Custom Editor Styles Functionality for adding custom editor styles Needs Technical Feedback Needs testing from a developer perspective. [Type] Developer Documentation Documentation for developers

Comments

@j-hoffmann
Copy link

Describe the bug
When Gutenberg is collecting the styles to be loaded into the editor, theme support for the feature editor-styles determines whether styles from the global variable $editor_styles are loaded in lib/client-assets.php:

if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) ...

When using the core function add_editor_style() to add stylesheets to the $editor_styles global, the function sets theme support for the feature editor-style (note, this time without "s" at the end):

function add_editor_style( $stylesheet = 'editor-style.css' ) {
add_theme_support( 'editor-style' );
[...]
}

The problem is, stylesheets added via add_editor_style() will not get loaded in Gutenberg unless separately setting support for editor-styles (with "s" at the end):

add_theme_support( 'editor-styles' );

To Reproduce
Steps to reproduce the behavior:

  1. Include a stylesheet via add_editor_style()
  2. It will be loaded in classic editor but not in Gutenberg
  3. Apply add_theme_support( 'editor-styles' );
  4. Now the stylesheet also applies to Gutenberg

Expected behavior
add_editor_style() should be enough to apply the stylesheet in both editors, so Gutenberg should be checking current_theme_supports( 'editor-style' ).

Desktop

  • OS: Windows 10
  • Browser Firefox 63

Additional context

  • WordPress 4.9.8
  • Gutenberg 4.5.1
@designsimply designsimply added Needs Technical Feedback Needs testing from a developer perspective. [Feature] Custom Editor Styles Functionality for adding custom editor styles labels Nov 21, 2018
@mkaz
Copy link
Member

mkaz commented Apr 10, 2019

From @joyously in Slack

I'm not sure when this change crept into the Gutenberg doc (Theme section), but it is incorrect. This part https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support/#editor-styles acknowledges that the new way is a little different, and has add_theme_support('editor-styles');. Then this part https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support/#enqueuing-the-editor-style incorrectly associates the new loading and parsing with the old add_editor_style( 'style-editor.css' );. The old one uses add_theme_support('editor-style');. Note that the old one is still available for the old editor and it is singular. The new one for the new editor is plural.

Comments added to commit here: e4fd51c#diff-c14ad3a4c41ef0d7bf709f5ebe52ba64

@mkaz mkaz added the [Type] Developer Documentation Documentation for developers label Apr 10, 2019
@mkaz
Copy link
Member

mkaz commented Apr 11, 2019

Closed in: #14917

@mkaz mkaz closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Custom Editor Styles Functionality for adding custom editor styles Needs Technical Feedback Needs testing from a developer perspective. [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

No branches or pull requests

3 participants