For all client websites that I build I strip the WordPress admin down to the bare minimum as to reduce the burden and learning curve for my clients. This includes things like removing the Posts menu item if posts are not used on the site, and every meta box which aren't being used.
One big issue I'm struggling with Gutenberg at the moment in terms of extensibility, is that there's a bunch of inspector controls which I don't need, thus increasing said burden. A good example of this is the core/paragraph block, as that has a bunch of options allowing you to recreate a Geocities website where you can set inline background & font colours and whacky text sizes.
As there is currently no API or filter to remove the controls, I've had to resort to a bunch of sophistically CSS to simply display: none the Text Settings panel and recreate the options I want.
An idea for an API would be to wrap each control which gets rendered in the Text Settings panel inside a keyed array, where the value is the control component which gets rendered.
Using core/gallery as an example, due to it only having 3 controls currently, something like this:
let controls = {
setColumnsNumber: <RangeControl
label={ __( 'Columns' ) }
value={ columns }
onChange={ this.setColumnsNumber }
min={ 1 }
max={ Math.min( MAX_COLUMNS, images.length ) }
/>,
imageCrop: <ToggleControl
label={ __( 'Crop Images' ) }
checked={ !! imageCrop }
onChange={ this.toggleImageCrop }
/>,
linkTo: <SelectControl
label={ __( 'Link to' ) }
value={ linkTo }
onChange={ this.setLinkTo }
options={ linkOptions }
/>,
};
controls = applyFilters( 'blocks.inspectorControls', controls, this );
Then with such a pattern in place, one can easily remove controls as they desire. Assuming lodash is being used, this filter would remove the setColumnsNumber and imageCrop controls:
function removeGalleryControls( controls, block ) {
if ( 'core/gallery' == block.props.name ) {
return omit( controls, [ 'setColumnsNumber', 'imageCrop' ] );
}
return controls;
}
addFilter( 'blocks.inspectorControls', 'remove-gallery-controls', removeGalleryControls );
This filter would update the Columns control by changing the maximum range, and updating its label:
function replaceGalleryControl( controls, block ) {
if ( 'core/gallery' == block.props.name ) {
const { columns } = block.props.attributes
controls.setColumnsNumber = <RangeControl
label={ __( 'New Label!' ) }
value={ columns }
onChange={ block.setColumnsNumber }
min={ 1 }
max={ 3 }
/>;
}
return controls;
}
addFilter( 'blocks.inspectorControls', 'replace-gallery-control', replaceGalleryControl );
And obviously reordering the controls along with adding additional ones should be quite evident at this point. Also it's easier to globally add controls to more than 1 block at a time which is an added advantage.
It's possible that there might be a cleaner or more React-like approach which allows for such extensibility, however I do believe it's quite a critical pain point prior to Gutenberg shipping.
For all client websites that I build I strip the WordPress admin down to the bare minimum as to reduce the burden and learning curve for my clients. This includes things like removing the Posts menu item if posts are not used on the site, and every meta box which aren't being used.
One big issue I'm struggling with Gutenberg at the moment in terms of extensibility, is that there's a bunch of inspector controls which I don't need, thus increasing said burden. A good example of this is the
core/paragraphblock, as that has a bunch of options allowing you to recreate a Geocities website where you can set inline background & font colours and whacky text sizes.As there is currently no API or filter to remove the controls, I've had to resort to a bunch of sophistically CSS to simply
display: nonethe Text Settings panel and recreate the options I want.An idea for an API would be to wrap each control which gets rendered in the Text Settings panel inside a keyed array, where the value is the control component which gets rendered.
Using
core/galleryas an example, due to it only having 3 controls currently, something like this:Then with such a pattern in place, one can easily remove controls as they desire. Assuming lodash is being used, this filter would remove the setColumnsNumber and imageCrop controls:
This filter would update the Columns control by changing the maximum range, and updating its label:
And obviously reordering the controls along with adding additional ones should be quite evident at this point. Also it's easier to globally add controls to more than 1 block at a time which is an added advantage.
It's possible that there might be a cleaner or more React-like approach which allows for such extensibility, however I do believe it's quite a critical pain point prior to Gutenberg shipping.