-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Package] Block editor/packages/block-editor/packages/block-editor[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
Description
In the Site Editor, Block CSS should be included without needing to use wp-block as a CSS selector in the built stylesheet, it should be included in the iframe by virtue of it being registered through enqueue_block_assets.
My suggestion would be to add to enqueue_block_assets a data-attr/some "block asset" identifier to just scan for instead, because whether or not the right selectors are in the stylesheet shouldn't be the sole criteria for including it in the FSE.
Step-by-step reproduction instructions
- Build a bunch of blocks with separate editor and generic stylesheets
- Don't use ".wp-block" as the main classname/selector for your custom blocks.
- Go into FSE and use your custom blocks
- Observe that their styles are not included inside the iframe.
Screenshots, screen recording, code snippet
Specifically this section:
https://github.com/WordPress/gutenberg/blob/0a6a23b213c4fe9e3b337c8b71fa87bbf82c4496/packages/block-editor/src/components/iframe/index.js
function matchFromRules( _cssRules ) {
return Array.from( _cssRules ).find(
( {
selectorText,
conditionText,
cssRules: __cssRules,
} ) => {
// If the rule is conditional then it will not have selector text.
// Recurse into child CSS ruleset to determine selector eligibility.
if ( conditionText ) {
return matchFromRules( __cssRules );
}
return (
selectorText &&
( selectorText.includes(
`.${ BODY_CLASS_NAME }`
) ||
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
);
}
);
}
const isMatch = matchFromRules( cssRules );
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Package] Block editor/packages/block-editor/packages/block-editor[Type] EnhancementA suggestion for improvement.A suggestion for improvement.