I’m fairly new to Gutenberg. I want a means by which blocks can be inserted within a group, but the user has no means of modifying the group attributes, other than the background colour.
I’m comfortable with using wp.blockEditor.InnerBlocks to insert blocks within another block, and have been trying to create some wrapper for this with the functionality I want.
However, creating a new group block or a group block variation does not work, as wp.blockEditor.InnerBlocks automatically uses the core/group functionality, so the user still gets all the group functionality and options.
The only solution I can think of is to modify the core/group block to strip out all unwanted options – presumably by setting “support” options to “false”…
However, I’ve spent hours trying and can’t get anything to have any effect. For example, I’ve tried:
wp.domReady(() => {
const { addFilter } = wp.hooks;
const { assign } = lodash;
const modifyGroupBlockSettings = (settings, name) => {
if (name === 'core/group') {
settings.supports = assign({}, settings.supports, {
align: ['full'],
anchor: false,
ariaLabel: false,
background: true,
color: false,
dimensions: false,
interactivity: false,
layout: false,
position: false,
spacing: false,
typography: false,
});
}
return settings;
};
addFilter(
'blocks.registerBlockType',
'custom-block-settings/modify-group-block-settings',
modifyGroupBlockSettings
);
});
What’s the correct way to remove support options from an existing block? Is there another way I can achieve the effect I want?