-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update the editor styles wrapper to avoid specificity issues #10956
Conversation
Looks good. I tested with two themes containing editor styles for Gutenberg and found no major issues with mapping I also tested styling the editor page title, which works well with Gutenberg UI styling also appears unaffected. The only thing that broke for me was these rules designed to set wide and full block widths: body[data-align="wide"] {
max-width: 1092px !important;
}
body[data-align="full"] {
max-width: none !important;
} Which now maps to this, and have no effect on block width: .editor-styles-wrapper[data-align="wide"] {
max-width: 1092px !important;
}
.editor-styles-wrapper[data-align="full"] {
max-width: none !important;
} But this is easily fixed by doing this instead: body .editor-block-list__block[data-align="wide"] {
max-width: 1092px;
}
body .editor-block-list__block[data-align="full"] {
max-width: none;
} Which looks like what we might want to update this section of the guidebook to once this PR is merged; the wide and full styles there will no longer work, as they're mapped to |
Thanks @nickcernis for the tests. Glad it worked so far. A thought I have is trying to support settings widths like that: .wp-block {
max-width: 600px
}
.wp-block[data-align="wide"] {
max-width: 1092px;
}
.wp-block[data-align="full"] {
max-width: none;
} and instead of doing advanced rules rewriting just apply the
I think it will bring clarity and simplify the process a lot. No magic => better understanding of how things work from theme authors. (in addition to supporting the legacy $content_width) cc @jasmussen |
Yes, that reads much more clearly in terms of the intent. It would be nice to avoid using |
This seems great to me. I think the next step is potentially running more CSS through this mechanism, such as the block library styles (where some of the CSS might be less specific and thus not apply because it doesn't account for the |
Ok, I went ahead and pushed this proposal #10956 (comment) Let me know what you think. If all goes well, I'll make sure to update the docs accordingly. |
Great to see a preponderance of red :) |
This is looking good! I was able to move all of our Twenty Nineteen styles back into the default stylesheet. 👏 🎉 Just a couple notes:
|
@kjellr Glad it worked well 👍
I think this can be improved. There's a lot of places where we can improve specificity and this is one of them. Maybe we should create a new label "Editor Styles" and create discrete issues to track these quick wins.
Unfortunately, this is not possible, there are some technical concerns in the editor view forcing us to have an extra "div" around blocks. |
5cd8e7a
to
6908f13
Compare
A followup to #22. This PR removes our secondary `style-editor-frame.css` file, and consolidates all of our editor styles into `style-editor.css`. Initially, the standard editor stylesheet was limited in scope to individual blocks, which meant we were unable to style the general alignment of the page, as well as items like the page title and default appender. The scope of `style-editor.css` is being expanded in WordPress/gutenberg#10956 , so we're now able to style those elements in a single stylesheet. Some minor style tweaks were necessary to make our original styles work in this context, but for the most part this is identical to #22.
I updated the docs, I removed the old way of theming the editor. (cc @jasmussen ) This PR should be ready for a final review. |
@youknowriad This definitely makes sense as the path going forward! Will |
@chrisvanpatten 🤔 I don't mind keeping it for some advanced use-cases where you want to style outside of the box, I think. |
Just an FYI I'm planning to give this a proper review in the next 24 hours (maaaaybe tonight?) while also converting a client project from the old enqueue hook to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good, just a few documentation things.
One general note is that I got pretty tripped up by the add_theme_support('editor-styles');
bit. I was confused because add_editor_style
calls add_theme_support('editor-style');
in the function. I didn't notice the difference between editor-styles
and editor-style
.
I hope my documentation change made it a little clearer that the extra add_theme_support
call is necessary :)
In practice, this was really nice once I figured that out. Excited to see it land!
My same suggestion also applies from up the thread, that we use this method to wrap the block library styles as well, so editor styles and block styles operate at the same level of selector specificity. That could be done in a separate PR but I think it's essential that block styles and editor styles are as similarly-scoped as possible. |
I'd definitely keep |
@samikeijonen Out of curiosity is there a reason you're going with that method instead of |
@chrisvanpatten I use |
@chrisvanpatten Mostly because I'm a control freak:) And with |
|
||
```php | ||
add_theme_support( 'editor-styles' ); | ||
add_theme_support('editor-styles'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the removal of spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s my fault. I code in PSR-2 and forgot to adjust in my comment. I’ll make a note to fix it.
Not sure if this is best addressed with the button-preview classes or the |
Related #10067
This PR updates the wrapper of the editor styles to the container of the post content. This means:
This could have an impact on the UI (regressions in movers or things like that). I haven't caught any bug yet though. I'd appreciate some help testing this with themes providing Gutenberg editor styles or not. Thanks