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
FSE script into iframe insertion needs to be less restrictive on how it determines whether to include a stylesheet #42509
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.
Just want to clarify, the exact problem I was experiencing is also the result of my naming of the stylesheets themselves.
the inline section here https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/iframe/index.js#L107 seems to be doing a simple find-replace for "css" within the stylesheet ID, which breaks when you include "css" somewhere in the enqueue handle yourself. so inline stylesheets i was adding weren't showing up either.
either way you can't progress to that specific bug without including wp-block in your main stylesheet somewhere (i've just slapped it in with a dummy variable) ala: .wp-block {--nothing: none}
this pretty much circumvents the problem above, and not naming your enqueued assets with "css" somewhere in there also helps.
Same here. Adobe Fonts/Typekit renders properly on the front-end. But the Block Editor ignores the enqueued CSS file across all browsers (Mac), and Network Inspector confirms no font files are loading.
Thanks for clarifying here. Switched to enqueue_block_assets and can confirm the desired assets are loading in the Site Editor as expected. This includes Adobe Fonts/Typekit CSS files.
Activity
albanyacademy commentedon Sep 15, 2022
Just want to clarify, the exact problem I was experiencing is also the result of my naming of the stylesheets themselves.
the inline section here https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/iframe/index.js#L107 seems to be doing a simple find-replace for "css" within the stylesheet ID, which breaks when you include "css" somewhere in the enqueue handle yourself. so inline stylesheets i was adding weren't showing up either.
either way you can't progress to that specific bug without including wp-block in your main stylesheet somewhere (i've just slapped it in with a dummy variable) ala:
.wp-block {--nothing: none}this pretty much circumvents the problem above, and not naming your enqueued assets with "css" somewhere in there also helps.
albanyacademy commentedon Nov 10, 2022
Update: this is also failing to load custom third party stylesheets, like Google fonts or Typekit. Kinda pressing.
spacedragn commentedon Jan 19, 2023
Same here. Adobe Fonts/Typekit renders properly on the front-end. But the Block Editor ignores the enqueued CSS file across all browsers (Mac), and Network Inspector confirms no font files are loading.
This plugin loads Typekit via API, which temporarily solved my issue. You can also load Typekit via JS as a potential workaround.
ellatrix commentedon Aug 18, 2023
Hi!
The
wp-blockselector detection is a back compatibility script, in case the stylesheets are not added to the iframe correctly.We've done lots of work in WP 6.3 to make sure that there are always ways to add stylesheets to the iframe without the compatibility script. Since #49655, you can use the
enqueue_block_assetsto enqueue assets for the iframe, so your problem should be fixed. Also see this dev note for more information: https://make.wordpress.org/core/2023/07/18/miscellaneous-editor-changes-in-wordpress-6-3/#post-editor-iframedspacedragn commentedon Aug 18, 2023
Thanks for clarifying here. Switched to
enqueue_block_assetsand can confirm the desired assets are loading in the Site Editor as expected. This includes Adobe Fonts/Typekit CSS files.albanyacademy commentedon Aug 18, 2023
YESSS thank you!