Description
Related: #6023, #6941, #7806. #7931, #8732, #14110 #15450, #18892.
The full story was shared by @youknowriad over a month ago:
https://make.wordpress.org/core/2020/01/23/controlling-the-block-editor/
I'm including the most important bits below:
One of the important use-cases of the block-editor is the possibility to control the experience programmatically. Controlling the experience means allowing agencies and developers to configure or restrict the usage of the different features available in the editor. This has always been one of the priorities while adding features to Gutenberg and it will continue to be.
As shown above, the block editor already provides a big number of APIs to control the experience, but it’s fair to acknowledge a lack of consistency and a few missing APIs (for instance to disable drop caps in Paragraph blocks).
In order to address this, I’m proposing a new block_editor_features hook that looks like this:
// Non-exhaustive representation of the block-editor configuration options. $block_editor_features = array( 'colors' => array( "enabled" => true, "colorPalette" => array(), "allowCustomColors" => true, "gradientPalette" => array(), "allowCustomGradients" => true, ), 'typography' => array( "enabled" => true, "fontSizes" => array(), "allowCustomFontSizes" => true, "allowDropCap" => true, ), ); apply_filters( 'block_editor_features', array $block_editor_features, WP_Post $post );And these would be made available to block authors using a dedicated selector.
const features = wp.data.select( 'core/block-editor' ).getFeatures();In addition to the PHP filter, this configuration can also be made available in the proposed theme.json file.
There is also an expectation to have more grained control over features – to be able to apply customizations on the block type level as well. It's going to be explored as part of this work taking into account many existing issues where such capability was requested.
Tasks
- Make useEditorFeature aware of theme.json block specific configs. useEditorFeature: take block context into account #24416
- Allow defining presets (color, font size and gradients) in theme.json.
- Either create a
usePreset('colors')
hook or consolidate touseEditorFeature('color.preset')
. - Allow enabling/disabling custom colors, custom gradients, custom font sizes in theme.json. Migrate existing theme supports to configure the editor to theme.json configs #24761 Support enabling/disabling custom gradients using theme.json #24964 Allow disabling custom font sizes using theme.json config #25038
- Allow enabling/disabling drop cap support.
- Allow enabling/disabling line-height controls. Allow enabling custom line heights using theme.json #25043
- Allow enabling/disabling and defining custom units. Support custom units on theme.json #25217
- Allow enabling/disabling spacing controls. Enable custom spacing support using theme.json #25141
- Allow enabling/disabling link control support. Support enabling custom link color from theme.json #25148
- Document the APIs.
- Make theme.json stable.
Activity