From 015e2079bdf66a660b14136de29fcb13e01c9241 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 24 Jan 2023 14:35:41 +0800 Subject: [PATCH] Update block editor store to make the block interface API properly experimental --- packages/block-editor/src/store/actions.js | 22 ------------------- packages/block-editor/src/store/index.js | 6 +++++ .../block-editor/src/store/private-actions.js | 21 ++++++++++++++++++ .../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, 39 insertions(+), 35 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 e1c88c2bd99b4..0b8da600e6454 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -1263,28 +1263,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. * diff --git a/packages/block-editor/src/store/index.js b/packages/block-editor/src/store/index.js index baa14b94ca9ad..edbc58608f3e1 100644 --- a/packages/block-editor/src/store/index.js +++ b/packages/block-editor/src/store/index.js @@ -8,8 +8,11 @@ import { createReduxStore, register } from '@wordpress/data'; */ import reducer from './reducer'; import * as selectors from './selectors'; +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'; /** * Block editor data store configuration. @@ -33,3 +36,6 @@ export const store = createReduxStore( STORE_NAME, { } ); register( store ); + +unlock( store ).registerPrivateActions( privateActions ); +unlock( store ).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..72cd2df3e34f6 --- /dev/null +++ b/packages/block-editor/src/store/private-actions.js @@ -0,0 +1,21 @@ +/** + * 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 38e9548e5a634..8330dc4049898 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1262,17 +1262,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. *