Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ The state controls for blocks in the block inspector and Global Styles let users

```php
function example_disable_block_states_editing( $settings ) {
$settings[ 'blockStatesEnabled' ] = false;
$settings[ 'blockStatesEditingEnabled' ] = false;

return $settings;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/filters/editor-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function example_disable_responsive_editing( $settings ) {

### Restrict block states editing

The `blockStatesEnabled` setting, which defaults to `true`, controls whether state controls for blocks are available in the block inspector and Global Styles. When it is `false`, those controls are not rendered, so users cannot apply block styles to states from those UIs. Viewport state controls are unaffected and remain controlled by `responsiveEditingEnabled`. State styles already saved in `theme.json`, in Global Styles, or in a block's `style` attribute are unaffected.
The `blockStatesEditingEnabled` setting, which defaults to `true`, controls whether state controls for blocks are available in the block inspector and Global Styles. When it is `false`, those controls are not rendered, so users cannot apply block styles to states from those UIs. Viewport state controls are unaffected and remain controlled by `responsiveEditingEnabled`. State styles already saved in `theme.json`, in Global Styles, or in a block's `style` attribute are unaffected.

```php
add_filter( 'block_editor_settings_all', 'example_disable_block_states_editing' );

function example_disable_block_states_editing( $settings ) {
$settings['blockStatesEnabled'] = false;
$settings['blockStatesEditingEnabled'] = false;
return $settings;
}
```
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Inspector controls in the standard block-supports panels (Typography, Dimensions, Border, Color, Background, Filters) now reflect the value a block inherits from Global Styles when no local override is set. Inherited controls show that value at rest (as a placeholder, preselected option, or resolved value) and mark the label with a dotted underline; setting a local override reveals a reset affordance that clears the override back to the inherited value ([#77894](https://github.com/WordPress/gutenberg/pull/77894)).
- Inherited Global Styles now resolve per-level heading element styles for the heading-family blocks (`core/heading`, `core/site-title`, `core/post-title`, `core/query-title`, `core/comments-title`, `core/term-name`, `core/site-tagline`, `core/accordion-heading`), so inspector controls reflect values set on a specific heading level (`styles.elements.h1`–`h6`) in addition to the shared `heading` element. A block rendered at level 0 (a paragraph) folds no heading element styles; `core/accordion-heading` has no level-0 state and takes its level from the parent Accordion's block context ([#80495](https://github.com/WordPress/gutenberg/pull/80495)).
- Inherited Global Styles now resolve the `link` element (`styles.elements.link`) for whole-block link blocks — those that render as a link — so their inspector controls reflect inherited link styles, mirroring the `button` element treatment for `core/button`. Covers `core/read-more`, `core/loginout`, `core/post-navigation-link`, `core/query-pagination-next`, `core/query-pagination-previous`, `core/query-pagination-numbers`, `core/comments-pagination-next`, `core/comments-pagination-previous`, `core/comments-pagination-numbers`, `core/comment-edit-link`, `core/comment-reply-link`, and `core/post-comments-link` [#80607](https://github.com/WordPress/gutenberg/pull/80607)).
- Add support for the `blockStatesEnabled` editor setting, which hides state controls for blocks when set to `false` ([#80956](https://github.com/WordPress/gutenberg/pull/80956)).
- Add support for the `blockStatesEditingEnabled` editor setting, which hides state controls for blocks when set to `false` ([#80956](https://github.com/WordPress/gutenberg/pull/80956), [#81058](https://github.com/WordPress/gutenberg/pull/81058)).

### Internal

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ _Properties_
- _titlePlaceholder_ `string`: Empty title placeholder
- _canLockBlocks_ `boolean`: Whether the user can manage Block Lock state
- _codeEditingEnabled_ `boolean`: Whether or not the user can switch to the code editor
- _blockStatesEnabled_ `boolean`: Whether or not block style states editing is enabled
- _blockStatesEditingEnabled_ `boolean`: Whether or not block style states editing is enabled
- _generateAnchors_ `boolean`: Enable/Disable auto anchor generation for Heading blocks
- _enableOpenverseMediaCategory_ `boolean`: Enable/Disable the Openverse media category in the inserter.
- _clearBlockSelection_ `boolean`: Whether the block editor should clear selection on mousedown when a block is not clicked.
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function BlockInspector() {
selectedBlockStyleState,
showStateOnCanvas,
isResponsiveEditing,
blockStatesEnabled,
blockStatesEditingEnabled,
} = useSelect( ( select ) => {
const {
getSettings,
Expand Down Expand Up @@ -231,7 +231,7 @@ function BlockInspector() {
_renderedBlockClientId
),
isResponsiveEditing: _isResponsiveEditing(),
blockStatesEnabled: getSettings().blockStatesEnabled,
blockStatesEditingEnabled: getSettings().blockStatesEditingEnabled,
};
}, [] );

Expand Down Expand Up @@ -367,7 +367,7 @@ function BlockInspector() {
selectedBlockStyleState={ selectedBlockStyleState }
showStateOnCanvas={ showStateOnCanvas }
isResponsiveEditing={ isResponsiveEditing }
blockStatesEnabled={ blockStatesEnabled }
blockStatesEditingEnabled={ blockStatesEditingEnabled }
isBlockStyleStateSelected={ isBlockStyleStateSelected }
/>
</BlockInspectorSingleBlockWrapper>
Expand Down Expand Up @@ -424,7 +424,7 @@ const BlockInspectorSingleBlock = ( {
selectedBlockStyleState,
showStateOnCanvas,
isResponsiveEditing,
blockStatesEnabled = true,
blockStatesEditingEnabled = true,
} ) => {
const listViewRef = useRef( null );
const hasMultipleTabs = availableTabs?.length > 1;
Expand Down Expand Up @@ -473,7 +473,7 @@ const BlockInspectorSingleBlock = ( {
clientId={ renderedBlockClientId }
controls={
blockEditingMode === 'default' &&
blockStatesEnabled && (
blockStatesEditingEnabled && (
<BlockStatesControl
name={ blockName }
value={ selectedBlockStyleState }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const PREFERENCES_DEFAULTS = {
* @property {string} titlePlaceholder Empty title placeholder
* @property {boolean} canLockBlocks Whether the user can manage Block Lock state
* @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
* @property {boolean} blockStatesEnabled Whether or not block style states editing is enabled
* @property {boolean} blockStatesEditingEnabled Whether or not block style states editing is enabled
* @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
* @property {boolean} enableOpenverseMediaCategory Enable/Disable the Openverse media category in the inserter.
* @property {boolean} clearBlockSelection Whether the block editor should clear selection on mousedown when a block is not clicked.
Expand Down Expand Up @@ -159,7 +159,7 @@ export const SETTINGS_DEFAULTS = {
canLockBlocks: true,

// Allows to disable the block-level style states interface.
blockStatesEnabled: true,
blockStatesEditingEnabled: true,

// Whether the user can edit custom CSS (requires edit_css capability).
// Defaults to false for safety - PHP passes true when user has capability.
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- The "Apply globally" control now opens a review modal so you can choose which of a block's modified styles are pushed to Global Styles, showing each style's current and new value ([#79839](https://github.com/WordPress/gutenberg/pull/79839)).
- Add a `responsiveEditingEnabled` editor setting, defaulting to `true`, which hides the "Responsive styles" option in the View menu and the viewport state control in Global Styles when set to `false` ([#80814](https://github.com/WordPress/gutenberg/pull/80814)).
- Add a `blockStatesEnabled` editor setting, defaulting to `true`, which hides state controls for blocks in the block inspector and Global Styles when set to `false` ([#80956](https://github.com/WordPress/gutenberg/pull/80956)).
- Add a `blockStatesEditingEnabled` editor setting, defaulting to `true`, which hides state controls for blocks in the block inspector and Global Styles when set to `false` ([#80956](https://github.com/WordPress/gutenberg/pull/80956), [#81058](https://github.com/WordPress/gutenberg/pull/81058)).

### Bug Fixes

Expand Down
9 changes: 5 additions & 4 deletions packages/editor/src/components/global-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function useServerData( settings ) {
settings?.__experimentalDiscussionSettings;
const fontLibraryEnabled = settings?.fontLibraryEnabled ?? true;
const responsiveEditingEnabled = settings?.responsiveEditingEnabled ?? true;
const blockStatesEnabled = settings?.blockStatesEnabled ?? true;
const blockStatesEditingEnabled =
settings?.blockStatesEditingEnabled ?? true;

const mediaUploadHandler = useSelect( ( select ) => {
const { canUser } = select( coreStore );
Expand Down Expand Up @@ -79,7 +80,7 @@ function useServerData( settings ) {
serverSettings,
fontLibraryEnabled,
responsiveEditingEnabled,
blockStatesEnabled,
blockStatesEditingEnabled,
};
}

Expand All @@ -101,7 +102,7 @@ export default function GlobalStylesUIWrapper( {
serverSettings,
fontLibraryEnabled,
responsiveEditingEnabled,
blockStatesEnabled,
blockStatesEditingEnabled,
} = useServerData( settings );

// Show loading state while data is being fetched
Expand All @@ -124,7 +125,7 @@ export default function GlobalStylesUIWrapper( {
showResponsiveStateControls={
showResponsiveStateControls && responsiveEditingEnabled
}
showBlockStateControls={ blockStatesEnabled }
showBlockStateControls={ blockStatesEditingEnabled }
/>
<GlobalStylesBlockLink
path={ path }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const BLOCK_EDITOR_SETTINGS = [
'__experimentalGlobalStylesBaseStyles',
'allImageSizes',
'alignWide',
'blockStatesEnabled',
'blockStatesEditingEnabled',
'blockInspectorTabs',
'maxUploadFileSize',
'allowedMimeTypes',
Expand Down
36 changes: 18 additions & 18 deletions packages/editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';
/**
* The default post editor settings.
*
* @property {boolean|Array} allowedBlockTypes Allowed block types
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
* @property {boolean} responsiveEditingEnabled Whether responsive (per-viewport) style editing is enabled or not
* @property {boolean} blockStatesEnabled Whether block style states editing is enabled or not
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
* @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
* true = the user has opted to show the Custom Fields panel at the bottom of the editor.
* false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
* undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
* @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
* @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
* @property {Array?} availableTemplates The available post templates
* @property {boolean} disablePostFormats Whether or not the post formats are disabled
* @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
* @property {number} maxUploadFileSize Maximum upload file size
* @property {boolean} supportsLayout Whether the editor supports layouts.
* @property {boolean|Array} allowedBlockTypes Allowed block types
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
* @property {boolean} responsiveEditingEnabled Whether responsive (per-viewport) style editing is enabled or not
* @property {boolean} blockStatesEditingEnabled Whether block style states editing is enabled or not
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
* @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
* true = the user has opted to show the Custom Fields panel at the bottom of the editor.
* false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
* undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
* @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
* @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
* @property {Array?} availableTemplates The available post templates
* @property {boolean} disablePostFormats Whether or not the post formats are disabled
* @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
* @property {number} maxUploadFileSize Maximum upload file size
* @property {boolean} supportsLayout Whether the editor supports layouts.
*/
export const EDITOR_SETTINGS_DEFAULTS = {
...SETTINGS_DEFAULTS,

richEditingEnabled: true,
codeEditingEnabled: true,
responsiveEditingEnabled: true,
blockStatesEnabled: true,
blockStatesEditingEnabled: true,
fontLibraryEnabled: true,
enableCustomFields: undefined,
defaultRenderingMode: 'post-only',
Expand Down
Loading