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

backward compatibility for add_editor_style() #7913

Closed
joyously opened this issue Jul 12, 2018 · 7 comments
Closed

backward compatibility for add_editor_style() #7913

joyously opened this issue Jul 12, 2018 · 7 comments
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.

Comments

@joyously
Copy link

Problem: thousands of existing themes call add_editor_style()
The current method of supplying styles to the editor is easy and used by thousands of themes. One call to add_editor_style() is all that is needed to make the editor look similar to the front end. Styles for fonts, colors, padding, etc. for HTML elements are the basis for what the theme provides, with the user choosing a lot of those in the Customizer.

Solution
For backward compatibility, the new editor should continue to load styles using add_editor_style().

considerations
Discussions on #4001 indicate that there could be a problem using existing styles because of styles bleeding into the rest of the page, because the old editor loads in an iframe.
Much talk on #5360, but only from the viewpoint of new themes, not old themes.

The consensus in Theme Review is that themes should not create blocks. But they still need to style the page, including in the editor.
@danielbachhuber

@danielbachhuber danielbachhuber added the Backwards Compatibility Issues or PRs that impact backwards compatability label Jul 12, 2018
@danielbachhuber danielbachhuber added the [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. label Jul 12, 2018
@danielbachhuber
Copy link
Member

Thanks @joyously. I'm not sure whether we'll be able to immediately act upon this issue, but it's good to have it open for visibility.

@mtias
Copy link
Member

mtias commented Jul 12, 2018

We won't be loading add_editor_styles from older themes as the expectations are vastly different, and the content is not within the boundaries of an iframe. A theme can load a style on the editor but it has to be a deliberate action as they need to target new elements in different ways.

In general, the way of styling the editor is going to be phased out in favor of styling blocks (through mechanisms like block variants).

@mtias
Copy link
Member

mtias commented Jul 19, 2018

Closing this for now.

@danielbachhuber
Copy link
Member

I'd like to make sure this is documented appropriately.

@danielbachhuber danielbachhuber self-assigned this Jul 19, 2018
@joyously
Copy link
Author

In general, the way of styling the editor is going to be phased out in favor of styling blocks (through mechanisms like block variants).

I think it's a mistake to view the theme styles this way. Themes should not be supplying blocks, and so their styles need to be fairly generic. It makes sense for core blocks to have standard classes similar to alignleft, alignright that the theme would style. Additionally, the theme would be styling the general case of HTML tags and fonts and colors that should make the editor look like the front end looks.
This should still be done with add_editor_style().
This has nothing to do with blocks, and if you can't see that you might be too close to the project.

@danielbachhuber
Copy link
Member

I've documented this in my Gutenberg migration guide https://github.com/danielbachhuber/gutenberg-migration-guide/blob/master/feature-editor-stylesheets.md

Additionally, the theme would be styling the general case of HTML tags and fonts and colors that should make the editor look like the front end looks.
This should still be done with add_editor_style().

For reasons mentioned before, the theme developer would need to first verify their existing editor stylesheet doesn't break Gutenberg. Once they've done so, if they choose to continue to use a global editor stylesheet, they can enqueue it on the enqueue_block_editor_assets action.

function wpdocs_theme_add_editor_styles() {
	wp_enqueue_style( 'my-editor-stylesheet', get_stylesheet_directory_uri() . '/editor-style.css' );
}
add_action( 'enqueue_block_editor_assets', 'wpdocs_theme_add_editor_styles' );

@joyously
Copy link
Author

the theme developer would need to first verify their existing editor stylesheet doesn't break Gutenberg

How is that backward compatible? The new editor should make sure that a theme's styles do not affect the admin page adversely, not the other way around. I'm referring to thousands of existing themes that might be supplying fonts or colors for the editor page. They shouldn't all have to change just because you guys decided to not use an iframe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

No branches or pull requests

3 participants