Open oandregal opened 3 years ago
Ran this by Riad and this is the context I've gathered:
layout.contentWidth
and layout.wideSize
which already control the visibility of the alignment controlsI'm not sure we want to do this yet.
From my perspective, the ability to filter the alignment options of blocks via theme.json would be a significant improvement. It currently is the primary thing the blocks.registerBlockType
hook in JS gets used for.
function addWideAlignmentOptions(settings, name) {
if (name !== 'namespace/block-name') {
return settings;
}
return {
...settings,
attributes: {
...settings.attributes,
align: {
'wide',
'full'
},
},
};
}
addFilter(
'blocks.registerBlockType',
'add-wide-alignment-options',
addWideAlignmentOptions,
);
Not having to manually filter the options but instead having a more declarative way of achieving this would reduce a lot of code that by nature is modifying settings at a relatively low level in the block API.
Related https://github.com/WordPress/gutenberg/issues/34316
The align options of blocks can be filtered using the block_type_metadata filter. It'd be easier for themes if they could filter those options via
theme.json
as we do with other settings such asunits
.