-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Provide some editor defaults for themes that do not provide any editor styles #35737
Conversation
Size Change: -6 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
return hasThemeStyles && settings.styles?.length | ||
? settings.styles | ||
: settings.defaultEditorStyles; | ||
return hasThemeStyles && settings.styles?.length ? settings.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.
This seems to remove the "default theme styles" from themes when they uncheck "use theme styles", right?
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.
I'm not sure I understand this code very well :) Specifically, the role of hasThemeStyles
and where that comes from.
This is what I understand:
- Add default editor styles applied to themes without theme.json and without editor styles #34439 added some default styles for themes that didn't have any. That was added in the client and relied on
settings.styles
being empty. - Enqueue preset styles for all themes in the editor #35424 made
settings.styles
to always have something (the core presets), hence it broke the changes introduced in 34439. - This PR tries to add again the default styles but it does it in the server (see) instead of the client as 34439 did.
I have an alternative PR to this one that still adds the default styles in the client but passes a flag to ignore the ones we add for core presets. See #35736 However, I thought this one was a better approach. I certainly don't have the full picture yet, though.
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.
When you go the "preferences" of the block editor, you can disable "theme styles", when disabled (for any theme), the default editor styles should be used.
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.
Oh, so there are a couple of cases here: the theme does not provide any style or the user deactivates theme styles. 🤔
If the theme styles depend on a user's action we need to be able to load different styles in the client. This PR doesn't make much sense then. I'll close this and focus on #35736
Fixes #35730
Follow up to #35424 and #34439
Alternative to #35736
In Gutenberg 11.5, we added some defaults for themes that didn't enqueue any editor styles, see #34439
In Gutenberg 11.7, we made every theme to have some styles in the editor: we provided at least the core presets. See #35424 As an unintended side effect of this change, there are no themes that don't provide editor styles anymore, hence we didn't provide any editor defaults for them.
This PR adds back some defaults for themes that don't provide any editor styles.