- Issue created by @loze
- π¨π¦Canada drclaw
I think it needs to be done in javascript with wp.blocks.unregisterBlockStyle(). Although, as mentioned on that documentation page, there can be a bit of a race condition if your script tries to unregister a style before it's registered. Even using
wp.domReady()
I still needed a timeout to ensure the unregistration happened after the style was registered. Probably, we need to use a different event for Drupal Gutenberg but I don't know what that is.In the meantime, if you can handle the timeout, here's wha that looks like:
wp.domReady( () => { setTimeout(() => { // Remove the rounded style from the core/image block. wp.blocks.unregisterBlockStyle( 'core/image', 'rounded' ); }, 1000); } );
- πΊπΈUnited States loze Los Angeles
Thanks.
I was able to do this following the register-filters.jsx example in the gutenberg_starter theme, which seems to do the trick.
((Drupal, wp) => { const {t} = Drupal; const {hooks, blockEditor} = wp; const {addFilter} = hooks; const {BlockControls} = blockEditor; /** * This filter will alter image block by removing its styles. */ addFilter( 'blocks.registerBlockType', 'MYTHEME/remove-image-block-styles', (settings, name) => { if (name === "core/image") { return { ...settings, styles: [] }; } else { return settings; } }, ); })(Drupal, wp);
- π¨π¦Canada drclaw
Ah beauty! That's good to know - thanks for reporting back π
- Status changed to Fixed
6 months ago 1:41pm 24 May 2024 - π΅πΉPortugal marcofernandes
I'm glad the starter theme is helping, that's what it was made for π
Automatically closed - issue fixed for 2 weeks with no activity.