From 3be14b4b058a49b035d635650ddfb25e5cac0949 Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Tue, 24 Jan 2023 14:35:41 +0800 Subject: [PATCH 1/6] Update block editor store to make the block interface API properly experimental --- packages/block-editor/src/store/actions.js | 63 +----------------- packages/block-editor/src/store/index.js | 14 ++-- .../block-editor/src/store/private-actions.js | 65 +++++++++++++++++++ .../src/store/private-selectors.js | 10 +++ packages/block-editor/src/store/reducer.js | 4 +- packages/block-editor/src/store/selectors.js | 11 ---- 6 files changed, 85 insertions(+), 82 deletions(-) create mode 100644 packages/block-editor/src/store/private-actions.js create mode 100644 packages/block-editor/src/store/private-selectors.js diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index 766a01a042808..98bdf1bffc78c 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -16,7 +16,6 @@ import { speak } from '@wordpress/a11y'; import { __, _n, sprintf } from '@wordpress/i18n'; import { create, insert, remove, toHTMLString } from '@wordpress/rich-text'; import deprecated from '@wordpress/deprecated'; -import { Platform } from '@wordpress/element'; /** * Internal dependencies @@ -26,6 +25,7 @@ import { retrieveSelectedAttribute, START_OF_SELECTED_AREA, } from '../utils/selection'; +import { __experimentalUpdateSettings } from './private-actions'; /** @typedef {import('../components/use-on-block-drop/types').WPDropOperation} WPDropOperation */ @@ -1264,28 +1264,6 @@ export function toggleBlockMode( clientId ) { }; } -/** - * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be hidden. - * - * @return {Object} Action object. - */ -export function __experimentalHideBlockInterface() { - return { - type: 'HIDE_BLOCK_INTERFACE', - }; -} - -/** - * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be shown. - * - * @return {Object} Action object. - */ -export function __experimentalShowBlockInterface() { - return { - type: 'SHOW_BLOCK_INTERFACE', - }; -} - /** * Returns an action object used in signalling that the user has begun to type. * @@ -1446,45 +1424,6 @@ export function updateSettings( settings ) { return __experimentalUpdateSettings( settings, true ); } -/** - * A list of private/experimental block editor settings that - * should not become a part of the WordPress public API. - * BlockEditorProvider will remove these settings from the - * settings object it receives. - * - * @see https://github.com/WordPress/gutenberg/pull/46131 - */ -const privateSettings = [ 'inserterMediaCategories' ]; - -/** - * Action that updates the block editor settings and - * conditionally preserves the experimental ones. - * - * @param {Object} settings Updated settings - * @param {boolean} stripExperimentalSettings Whether to strip experimental settings. - * @return {Object} Action object - */ -export function __experimentalUpdateSettings( - settings, - stripExperimentalSettings = false -) { - let cleanSettings = settings; - // There are no plugins in the mobile apps, so there is no - // need to strip the experimental settings: - if ( stripExperimentalSettings && Platform.OS === 'web' ) { - cleanSettings = {}; - for ( const key in settings ) { - if ( ! privateSettings.includes( key ) ) { - cleanSettings[ key ] = settings[ key ]; - } - } - } - return { - type: 'UPDATE_SETTINGS', - settings: cleanSettings, - }; -} - /** * Action that signals that a temporary reusable block has been saved * in order to switch its temporary id with the real id. diff --git a/packages/block-editor/src/store/index.js b/packages/block-editor/src/store/index.js index 3a49dbd1ddb76..1cffdf9a389e0 100644 --- a/packages/block-editor/src/store/index.js +++ b/packages/block-editor/src/store/index.js @@ -8,12 +8,12 @@ import { createReduxStore, registerStore } from '@wordpress/data'; */ import reducer from './reducer'; import * as selectors from './selectors'; -import * as allActions from './actions'; +import * as privateActions from './private-actions'; +import * as privateSelectors from './private-selectors'; +import * as actions from './actions'; import { STORE_NAME } from './constants'; import { unlock } from '../experiments'; -const { __experimentalUpdateSettings, ...actions } = allActions; - /** * Block editor data store configuration. * @@ -34,6 +34,8 @@ export const store = createReduxStore( STORE_NAME, { ...storeConfig, persist: [ 'preferences' ], } ); +unlock( store ).registerPrivateActions( privateActions ); +unlock( store ).registerPrivateSelectors( privateSelectors ); // We will be able to use the `register` function once we switch // the "preferences" persistence to use the new preferences package. @@ -41,7 +43,5 @@ const registeredStore = registerStore( STORE_NAME, { ...storeConfig, persist: [ 'preferences' ], } ); - -unlock( registeredStore ).registerPrivateActions( { - __experimentalUpdateSettings, -} ); +unlock( registeredStore ).registerPrivateActions( privateActions ); +unlock( registeredStore ).registerPrivateSelectors( privateSelectors ); diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js new file mode 100644 index 0000000000000..7c92a923a909c --- /dev/null +++ b/packages/block-editor/src/store/private-actions.js @@ -0,0 +1,65 @@ +/** + * WordPress dependencies + */ +import { Platform } from '@wordpress/element'; + +/** + * A list of private/experimental block editor settings that + * should not become a part of the WordPress public API. + * BlockEditorProvider will remove these settings from the + * settings object it receives. + * + * @see https://github.com/WordPress/gutenberg/pull/46131 + */ +const privateSettings = [ '__unstableInserterMediaCategories' ]; + +/** + * Action that updates the block editor settings and + * conditionally preserves the experimental ones. + * + * @param {Object} settings Updated settings + * @param {boolean} stripExperimentalSettings Whether to strip experimental settings. + * @return {Object} Action object + */ +export function __experimentalUpdateSettings( + settings, + stripExperimentalSettings = false +) { + let cleanSettings = settings; + // There are no plugins in the mobile apps, so there is no + // need to strip the experimental settings: + if ( stripExperimentalSettings && Platform.OS === 'web' ) { + cleanSettings = {}; + for ( const key in settings ) { + if ( ! privateSettings.includes( key ) ) { + cleanSettings[ key ] = settings[ key ]; + } + } + } + return { + type: 'UPDATE_SETTINGS', + settings: cleanSettings, + }; +} + +/** + * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be hidden. + * + * @return {Object} Action object. + */ +export function __experimentalHideBlockInterface() { + return { + type: '__experimental_HIDE_BLOCK_INTERFACE', + }; +} + +/** + * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be shown. + * + * @return {Object} Action object. + */ +export function __experimentalShowBlockInterface() { + return { + type: '__experimental_SHOW_BLOCK_INTERFACE', + }; +} diff --git a/packages/block-editor/src/store/private-selectors.js b/packages/block-editor/src/store/private-selectors.js new file mode 100644 index 0000000000000..cd225f7673932 --- /dev/null +++ b/packages/block-editor/src/store/private-selectors.js @@ -0,0 +1,10 @@ +/** + * Returns true if the the block interface should be hidden, or false otherwise. + * + * @param {Object} state Global application state. + * + * @return {boolean} Whether the block toolbar is hidden. + */ +export function __experimentalIsBlockInterfaceHidden( state ) { + return state.isBlockInterfaceHidden; +} diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index 919ca1dceb4e3..ccb84a9f17e2e 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -1197,10 +1197,10 @@ export const blocks = pipe( */ export function isBlockInterfaceHidden( state = false, action ) { switch ( action.type ) { - case 'HIDE_BLOCK_INTERFACE': + case '__experimental_HIDE_BLOCK_INTERFACE': return true; - case 'SHOW_BLOCK_INTERFACE': + case '__experimental_SHOW_BLOCK_INTERFACE': return false; } diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 242d2816febe5..7fe45abdffa04 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1279,17 +1279,6 @@ export function isTyping( state ) { return state.isTyping; } -/** - * Returns true if the the block interface should be hidden, or false otherwise. - * - * @param {Object} state Global application state. - * - * @return {boolean} Whether the block toolbar is hidden. - */ -export function __experimentalIsBlockInterfaceHidden( state ) { - return state.isBlockInterfaceHidden; -} - /** * Returns true if the user is dragging blocks, or false otherwise. * From 83e317f8629ae7c9e86863482b9414413dafee15 Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Tue, 24 Jan 2023 15:22:33 +0800 Subject: [PATCH 2/6] Unlock experimental block interface API before usage --- .../src/components/block-tools/selected-block-popover.js | 3 ++- packages/block-editor/src/hooks/dimensions.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-tools/selected-block-popover.js b/packages/block-editor/src/components/block-tools/selected-block-popover.js index 294813b1f34a1..6572831f24c01 100644 --- a/packages/block-editor/src/components/block-tools/selected-block-popover.js +++ b/packages/block-editor/src/components/block-tools/selected-block-popover.js @@ -21,6 +21,7 @@ import { store as blockEditorStore } from '../../store'; import BlockPopover from '../block-popover'; import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props'; import Inserter from '../inserter'; +import { unlock } from '../../experiments'; function selector( select ) { const { @@ -31,7 +32,7 @@ function selector( select ) { __experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden, getSettings, getLastMultiSelectedBlockClientId, - } = select( blockEditorStore ); + } = unlock( select( blockEditorStore ) ); return { editorMode: __unstableGetEditorMode(), diff --git a/packages/block-editor/src/hooks/dimensions.js b/packages/block-editor/src/hooks/dimensions.js index 7c270ec9bd445..1eb376fc88f63 100644 --- a/packages/block-editor/src/hooks/dimensions.js +++ b/packages/block-editor/src/hooks/dimensions.js @@ -59,6 +59,7 @@ import { } from './child-layout'; import useSetting from '../components/use-setting'; import { store as blockEditorStore } from '../store'; +import { unlock } from '../experiments'; export const DIMENSIONS_SUPPORT_KEY = 'dimensions'; export const SPACING_SUPPORT_KEY = 'spacing'; @@ -70,7 +71,7 @@ function useVisualizerMouseOver() { const { __experimentalHideBlockInterface: hideBlockInterface, __experimentalShowBlockInterface: showBlockInterface, - } = useDispatch( blockEditorStore ); + } = unlock( useDispatch( blockEditorStore ) ); const onMouseOver = ( e ) => { e.stopPropagation(); hideBlockInterface(); From 000469ccb33eb17dbebdd1af95f54c45ac1b1748 Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Fri, 27 Jan 2023 11:38:16 +0800 Subject: [PATCH 3/6] Fix tests --- .../block-editor/src/store/test/actions.js | 18 ------------ .../src/store/test/private-actions.js | 28 +++++++++++++++++++ .../src/store/test/private-selectors.js | 24 ++++++++++++++++ .../block-editor/src/store/test/reducer.js | 4 +-- .../block-editor/src/store/test/selectors.js | 19 ------------- 5 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 packages/block-editor/src/store/test/private-actions.js create mode 100644 packages/block-editor/src/store/test/private-selectors.js diff --git a/packages/block-editor/src/store/test/actions.js b/packages/block-editor/src/store/test/actions.js index 82cf9831f104a..45e432ad8bf3f 100644 --- a/packages/block-editor/src/store/test/actions.js +++ b/packages/block-editor/src/store/test/actions.js @@ -27,7 +27,6 @@ const noop = () => {}; const { clearSelectedBlock, - __experimentalHideBlockInterface: hideBlockInterface, insertBlock, insertBlocks, mergeBlocks, @@ -40,7 +39,6 @@ const { replaceInnerBlocks, resetBlocks, selectBlock, - __experimentalShowBlockInterface: showBlockInterface, showInsertionPoint, startMultiSelect, startTyping, @@ -777,22 +775,6 @@ describe( 'actions', () => { } ); } ); - describe( 'hideBlockInterface', () => { - it( 'should return the HIDE_BLOCK_INTERFACE action', () => { - expect( hideBlockInterface() ).toEqual( { - type: 'HIDE_BLOCK_INTERFACE', - } ); - } ); - } ); - - describe( 'showBlockInterface', () => { - it( 'should return the SHOW_BLOCK_INTERFACE action', () => { - expect( showBlockInterface() ).toEqual( { - type: 'SHOW_BLOCK_INTERFACE', - } ); - } ); - } ); - describe( 'startTyping', () => { it( 'should return the START_TYPING action', () => { expect( startTyping() ).toEqual( { diff --git a/packages/block-editor/src/store/test/private-actions.js b/packages/block-editor/src/store/test/private-actions.js new file mode 100644 index 0000000000000..7c575609622e0 --- /dev/null +++ b/packages/block-editor/src/store/test/private-actions.js @@ -0,0 +1,28 @@ +/** + * External dependencies + */ +/** + * Internal dependencies + */ +import { + __experimentalHideBlockInterface as hideBlockInterface, + __experimentalShowBlockInterface as showBlockInterface, +} from '../private-actions'; + +describe( 'private actions', () => { + describe( 'hideBlockInterface', () => { + it( 'should return the HIDE_BLOCK_INTERFACE action', () => { + expect( hideBlockInterface() ).toEqual( { + type: '__experimental_HIDE_BLOCK_INTERFACE', + } ); + } ); + } ); + + describe( 'showBlockInterface', () => { + it( 'should return the SHOW_BLOCK_INTERFACE action', () => { + expect( showBlockInterface() ).toEqual( { + type: '__experimental_SHOW_BLOCK_INTERFACE', + } ); + } ); + } ); +} ); diff --git a/packages/block-editor/src/store/test/private-selectors.js b/packages/block-editor/src/store/test/private-selectors.js new file mode 100644 index 0000000000000..83a76c54b6f90 --- /dev/null +++ b/packages/block-editor/src/store/test/private-selectors.js @@ -0,0 +1,24 @@ +/** + * Internal dependencies + */ +import { __experimentalIsBlockInterfaceHidden as isBlockInterfaceHidden } from '../private-selectors'; + +describe( 'private selectors', () => { + describe( 'isBlockInterfaceHidden', () => { + it( 'should return the true if toggled true in state', () => { + const state = { + isBlockInterfaceHidden: true, + }; + + expect( isBlockInterfaceHidden( state ) ).toBe( true ); + } ); + + it( 'should return false if toggled false in state', () => { + const state = { + isBlockInterfaceHidden: false, + }; + + expect( isBlockInterfaceHidden( state ) ).toBe( false ); + } ); + } ); +} ); diff --git a/packages/block-editor/src/store/test/reducer.js b/packages/block-editor/src/store/test/reducer.js index 609cbb59c6e54..c3833b4b5c6a6 100644 --- a/packages/block-editor/src/store/test/reducer.js +++ b/packages/block-editor/src/store/test/reducer.js @@ -2410,7 +2410,7 @@ describe( 'state', () => { describe( 'isBlockInterfaceHidden()', () => { it( 'should set the hide block interface flag to true', () => { const state = isBlockInterfaceHidden( false, { - type: 'HIDE_BLOCK_INTERFACE', + type: '__experimental_HIDE_BLOCK_INTERFACE', } ); expect( state ).toBe( true ); @@ -2418,7 +2418,7 @@ describe( 'state', () => { it( 'should set the hide block interface flag to false', () => { const state = isBlockInterfaceHidden( false, { - type: 'SHOW_BLOCK_INTERFACE', + type: '__experimental_SHOW_BLOCK_INTERFACE', } ); expect( state ).toBe( false ); diff --git a/packages/block-editor/src/store/test/selectors.js b/packages/block-editor/src/store/test/selectors.js index 973451e237252..08763c74efcb6 100644 --- a/packages/block-editor/src/store/test/selectors.js +++ b/packages/block-editor/src/store/test/selectors.js @@ -44,7 +44,6 @@ const { isBlockMultiSelected, isFirstMultiSelectedBlock, getBlockMode, - __experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden, isTyping, isDraggingBlocks, getDraggedBlockClientIds, @@ -2259,24 +2258,6 @@ describe( 'selectors', () => { } ); } ); - describe( 'isBlockInterfaceHidden', () => { - it( 'should return the true if toggled true in state', () => { - const state = { - isBlockInterfaceHidden: true, - }; - - expect( isBlockInterfaceHidden( state ) ).toBe( true ); - } ); - - it( 'should return false if toggled false in state', () => { - const state = { - isBlockInterfaceHidden: false, - }; - - expect( isBlockInterfaceHidden( state ) ).toBe( false ); - } ); - } ); - describe( 'isTyping', () => { it( 'should return the isTyping flag if the block is selected', () => { const state = { From 54513eaa87c3a34773da64bcaeaf5f1ddcb24ee5 Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Fri, 27 Jan 2023 11:48:10 +0800 Subject: [PATCH 4/6] Remove __experimental prefix from locked APIs --- .../src/components/block-tools/selected-block-popover.js | 2 +- packages/block-editor/src/hooks/dimensions.js | 7 +++---- packages/block-editor/src/store/private-actions.js | 8 ++++---- packages/block-editor/src/store/private-selectors.js | 2 +- packages/block-editor/src/store/reducer.js | 4 ++-- packages/block-editor/src/store/test/private-actions.js | 9 +++------ .../block-editor/src/store/test/private-selectors.js | 2 +- packages/block-editor/src/store/test/reducer.js | 4 ++-- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/block-editor/src/components/block-tools/selected-block-popover.js b/packages/block-editor/src/components/block-tools/selected-block-popover.js index 6572831f24c01..6ad5b104ca0ea 100644 --- a/packages/block-editor/src/components/block-tools/selected-block-popover.js +++ b/packages/block-editor/src/components/block-tools/selected-block-popover.js @@ -29,7 +29,7 @@ function selector( select ) { isMultiSelecting, hasMultiSelection, isTyping, - __experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden, + isBlockInterfaceHidden, getSettings, getLastMultiSelectedBlockClientId, } = unlock( select( blockEditorStore ) ); diff --git a/packages/block-editor/src/hooks/dimensions.js b/packages/block-editor/src/hooks/dimensions.js index 1eb376fc88f63..df88808617349 100644 --- a/packages/block-editor/src/hooks/dimensions.js +++ b/packages/block-editor/src/hooks/dimensions.js @@ -68,10 +68,9 @@ export const AXIAL_SIDES = [ 'vertical', 'horizontal' ]; function useVisualizerMouseOver() { const [ isMouseOver, setIsMouseOver ] = useState( false ); - const { - __experimentalHideBlockInterface: hideBlockInterface, - __experimentalShowBlockInterface: showBlockInterface, - } = unlock( useDispatch( blockEditorStore ) ); + const { hideBlockInterface, showBlockInterface } = unlock( + useDispatch( blockEditorStore ) + ); const onMouseOver = ( e ) => { e.stopPropagation(); hideBlockInterface(); diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index 7c92a923a909c..6a872fa3c328a 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -47,9 +47,9 @@ export function __experimentalUpdateSettings( * * @return {Object} Action object. */ -export function __experimentalHideBlockInterface() { +export function hideBlockInterface() { return { - type: '__experimental_HIDE_BLOCK_INTERFACE', + type: 'HIDE_BLOCK_INTERFACE', }; } @@ -58,8 +58,8 @@ export function __experimentalHideBlockInterface() { * * @return {Object} Action object. */ -export function __experimentalShowBlockInterface() { +export function showBlockInterface() { return { - type: '__experimental_SHOW_BLOCK_INTERFACE', + type: 'SHOW_BLOCK_INTERFACE', }; } diff --git a/packages/block-editor/src/store/private-selectors.js b/packages/block-editor/src/store/private-selectors.js index cd225f7673932..21984a7415422 100644 --- a/packages/block-editor/src/store/private-selectors.js +++ b/packages/block-editor/src/store/private-selectors.js @@ -5,6 +5,6 @@ * * @return {boolean} Whether the block toolbar is hidden. */ -export function __experimentalIsBlockInterfaceHidden( state ) { +export function isBlockInterfaceHidden( state ) { return state.isBlockInterfaceHidden; } diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index ccb84a9f17e2e..919ca1dceb4e3 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -1197,10 +1197,10 @@ export const blocks = pipe( */ export function isBlockInterfaceHidden( state = false, action ) { switch ( action.type ) { - case '__experimental_HIDE_BLOCK_INTERFACE': + case 'HIDE_BLOCK_INTERFACE': return true; - case '__experimental_SHOW_BLOCK_INTERFACE': + case 'SHOW_BLOCK_INTERFACE': return false; } diff --git a/packages/block-editor/src/store/test/private-actions.js b/packages/block-editor/src/store/test/private-actions.js index 7c575609622e0..ad73b23b582aa 100644 --- a/packages/block-editor/src/store/test/private-actions.js +++ b/packages/block-editor/src/store/test/private-actions.js @@ -4,16 +4,13 @@ /** * Internal dependencies */ -import { - __experimentalHideBlockInterface as hideBlockInterface, - __experimentalShowBlockInterface as showBlockInterface, -} from '../private-actions'; +import { hideBlockInterface, showBlockInterface } from '../private-actions'; describe( 'private actions', () => { describe( 'hideBlockInterface', () => { it( 'should return the HIDE_BLOCK_INTERFACE action', () => { expect( hideBlockInterface() ).toEqual( { - type: '__experimental_HIDE_BLOCK_INTERFACE', + type: 'HIDE_BLOCK_INTERFACE', } ); } ); } ); @@ -21,7 +18,7 @@ describe( 'private actions', () => { describe( 'showBlockInterface', () => { it( 'should return the SHOW_BLOCK_INTERFACE action', () => { expect( showBlockInterface() ).toEqual( { - type: '__experimental_SHOW_BLOCK_INTERFACE', + type: 'SHOW_BLOCK_INTERFACE', } ); } ); } ); diff --git a/packages/block-editor/src/store/test/private-selectors.js b/packages/block-editor/src/store/test/private-selectors.js index 83a76c54b6f90..2c287ceda0f88 100644 --- a/packages/block-editor/src/store/test/private-selectors.js +++ b/packages/block-editor/src/store/test/private-selectors.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import { __experimentalIsBlockInterfaceHidden as isBlockInterfaceHidden } from '../private-selectors'; +import { isBlockInterfaceHidden } from '../private-selectors'; describe( 'private selectors', () => { describe( 'isBlockInterfaceHidden', () => { diff --git a/packages/block-editor/src/store/test/reducer.js b/packages/block-editor/src/store/test/reducer.js index c3833b4b5c6a6..609cbb59c6e54 100644 --- a/packages/block-editor/src/store/test/reducer.js +++ b/packages/block-editor/src/store/test/reducer.js @@ -2410,7 +2410,7 @@ describe( 'state', () => { describe( 'isBlockInterfaceHidden()', () => { it( 'should set the hide block interface flag to true', () => { const state = isBlockInterfaceHidden( false, { - type: '__experimental_HIDE_BLOCK_INTERFACE', + type: 'HIDE_BLOCK_INTERFACE', } ); expect( state ).toBe( true ); @@ -2418,7 +2418,7 @@ describe( 'state', () => { it( 'should set the hide block interface flag to false', () => { const state = isBlockInterfaceHidden( false, { - type: '__experimental_SHOW_BLOCK_INTERFACE', + type: 'SHOW_BLOCK_INTERFACE', } ); expect( state ).toBe( false ); From a69e0d489f357aa51419ec747080698e2a54b36a Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Mon, 30 Jan 2023 12:40:59 +0800 Subject: [PATCH 5/6] Update documentation Co-authored-by: Adam Zielinski <adam@adamziel.com> --- packages/block-editor/src/store/private-actions.js | 4 ++-- packages/block-editor/src/store/private-selectors.js | 2 +- packages/block-editor/src/store/test/private-actions.js | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index 6a872fa3c328a..a2ebae38f4ed2 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -43,7 +43,7 @@ export function __experimentalUpdateSettings( } /** - * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be hidden. + * Hides the block interface (eg. toolbar, outline, etc.) * * @return {Object} Action object. */ @@ -54,7 +54,7 @@ export function hideBlockInterface() { } /** - * Returns an action object used in signalling that the block interface, eg. toolbar, outline, etc. should be shown. + * Shows the block interface (eg. toolbar, outline, etc.) * * @return {Object} Action object. */ diff --git a/packages/block-editor/src/store/private-selectors.js b/packages/block-editor/src/store/private-selectors.js index 21984a7415422..dede6eccccbe5 100644 --- a/packages/block-editor/src/store/private-selectors.js +++ b/packages/block-editor/src/store/private-selectors.js @@ -1,5 +1,5 @@ /** - * Returns true if the the block interface should be hidden, or false otherwise. + * Returns true if the block interface is hidden, or false otherwise. * * @param {Object} state Global application state. * diff --git a/packages/block-editor/src/store/test/private-actions.js b/packages/block-editor/src/store/test/private-actions.js index ad73b23b582aa..c4453547f6ce6 100644 --- a/packages/block-editor/src/store/test/private-actions.js +++ b/packages/block-editor/src/store/test/private-actions.js @@ -1,6 +1,3 @@ -/** - * External dependencies - */ /** * Internal dependencies */ From f9f518874dfc7ab57e339cff5b56f9bf37bd4a44 Mon Sep 17 00:00:00 2001 From: Daniel Richards <daniel.richards@automattic.com> Date: Mon, 30 Jan 2023 17:05:26 +0800 Subject: [PATCH 6/6] Fix incorrect `privateSettings` key --- packages/block-editor/src/store/private-actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index a2ebae38f4ed2..faf227edc0de6 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -11,7 +11,7 @@ import { Platform } from '@wordpress/element'; * * @see https://github.com/WordPress/gutenberg/pull/46131 */ -const privateSettings = [ '__unstableInserterMediaCategories' ]; +const privateSettings = [ 'inserterMediaCategories' ]; /** * Action that updates the block editor settings and