The template file should be something like the following and be in the src/js directory:
wp.domReady( () => {
const unregisterBlockStyle = wp.blocks.unregisterBlockStyle;
const registerBlockStyle = wp.blocks.registerBlockStyle;
// Remove some block styles
// unregisterBlockStyle( 'core/button', 'fill' );
// Add custom styles to blocks
/*
registerBlockStyle( 'core/paragraph', [
{
name: 'default',
label: 'Default',
isDefault: true,
},
{
name: 'cta',
label: 'Call to Action',
},
]);
*/
});
The block style script also needs to be enqueued in the inc/block-editor.php file:
wp_enqueue_script(
'sabino-editor',
get_stylesheet_directory_uri() . '/js/JS_FILE.js',
array( 'wp-blocks', 'wp-dom' ),
time(),
true
);
The template file should be something like the following and be in the src/js directory:
The block style script also needs to be enqueued in the inc/block-editor.php file: