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

Styles: add Editor Styles support #9008

Merged
merged 17 commits into from
Sep 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the editor styles support opt-in
  • Loading branch information
youknowriad committed Sep 4, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit aae8dc033bc7b0922e27a1ef16268ff6fce00e54
10 changes: 8 additions & 2 deletions docs/extensibility/theme-support.md
Original file line number Diff line number Diff line change
@@ -177,12 +177,18 @@ This flag will make sure users are only able to choose colors from the `editor-c

## Editor styles

Gutenberg supports the theme's [editor styles](https://codex.wordpress.org/Editor_Style). These styles are applied differently from the classic editor.
Gutenberg supports the theme's [editor styles](https://codex.wordpress.org/Editor_Style). This support is opt-in because these styles are applied differently from the classic editor.

- In the classic editor, the stylesheet is applied as is in the iframe of the post content editor.
- Since Gutenberg doesn't make use of iFrames, this is not possible. Instead Gutenberg wrap all the provided styles with `.editor-block-list__block` to avoid leaking styles outside the editor's content area.

This technique should allow the editor styles to work properly in both editors in most cases.
This technique should allow the editor styles to work properly in both editors in most cases.

Enabling editor styles support is done using:

```php
add_theme_support( 'editor-styles' );
```

Alternatively, a theme can provide a stylesheet that will change the editor's appearance entirely. You can use this to change colors, fonts, and any other visual aspect of the editor.

2 changes: 1 addition & 1 deletion docs/reference/faq.md
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ Other features, like the new _wide_ and _full-wide_ alignment options, will simp

## How will editor styles work?

Refular editor styles will work as is in most casees and themes can also load extra stylesheets by using the following hook:
Refular editor styles are opt-in and will work as is in most cases. Themes can also load extra stylesheets by using the following hook:

```php
function gutenbergtheme_editor_styles() {
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
@@ -1403,7 +1403,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
// Editor Styles.
global $editor_styles;
$styles = array();
if ( $editor_styles ) {
if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
foreach ( $editor_styles as $style ) {
if ( filter_var( $style, FILTER_VALIDATE_URL ) ) {
$styles[] = array(