You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preset controls need the preset CSS variables in scope #26511
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended
These definitions end up attached to the user-facing UI tools. The problem is that these tools aren't part of the editor canvas (wrapper by the .editor-styles-wrapper class), so the CSS Custom Properties aren't defined, hence it doesn't work. See what would happen in this case:
This is because, both in the post-editor and the site-editor, the global styles are prefixed by the editor wrapper, hence its scope doesn't reach the UI controls.
In the post editor, we pass the styles via the styles key of settings, so they are processed (added the .editor-styles-wrapper) as if they were theme styles. In the site editor, we add the wrapper ourselves.
Presets defined at any level (global, but also core/paragraph, etc) create CSS Custom Properties. For them to be in the scope of the UI controls they have to be outside the editor wrapper.
One thing we can do to fix this is to separate how we embed styles and presets in the HTML document: the presets are always enqueued by the server as an inline stylesheet (no style rule mangling in the client) and the styles continue to work as they are now (processed by the client, as to only affect the editor canvas).
So, we'd have:
/* inline stylesheet enqueued by the server for the presets */:root{/* global context */--wp--preset--color--primary:'value';--wp--preset--color--secondary:'value';}p{/* core/paragraph context */--wp--preset--color--primary:'value';--wp--preset--color--secondary:'value';}
/* inline stylesheet created by the editor (post-editor, site-editor) for the styles */.editor-styles-wrapper{/* global context */background-color:'value';}.editor-styles-wrapperp{/* core/paragraph context */background-color:'value';}
Hi @nosolosw, I think the path you are suggesting is correct. We should not make presets and custom variables inside editor-styles-wrapper. This includes the preset classes. The code that generates the presets on the client should also reflect that and not generate the presets inside the .editor-styles-wrapper tag.
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended
Activity
oandregal commentedon Oct 27, 2020
Some thinking out loud:
In the post editor, we pass the styles via the
styleskey of settings, so they are processed (added the.editor-styles-wrapper) as if they were theme styles. In the site editor, we add the wrapper ourselves.Presets defined at any level (global, but also core/paragraph, etc) create CSS Custom Properties. For them to be in the scope of the UI controls they have to be outside the editor wrapper.
One thing we can do to fix this is to separate how we embed styles and presets in the HTML document: the presets are always enqueued by the server as an inline stylesheet (no style rule mangling in the client) and the styles continue to work as they are now (processed by the client, as to only affect the editor canvas).
So, we'd have:
cc @jorgefilipecosta in case you have any thoughts.
jorgefilipecosta commentedon Oct 28, 2020
Hi @nosolosw, I think the path you are suggesting is correct. We should not make presets and custom variables inside editor-styles-wrapper. This includes the preset classes. The code that generates the presets on the client should also reflect that and not generate the presets inside the .editor-styles-wrapper tag.