diff --git a/docs/reference-guides/data/data-core-edit-post.md b/docs/reference-guides/data/data-core-edit-post.md index 0401734597d248..e5dd8917e6167c 100644 --- a/docs/reference-guides/data/data-core-edit-post.md +++ b/docs/reference-guides/data/data-core-edit-post.md @@ -328,6 +328,10 @@ _Returns_ - `boolean`: Whether the metaboxes are being saved. +### showMetaBoxes + +Undocumented declaration. + ## Actions @@ -522,6 +526,10 @@ _Parameters_ - _feature_ `string`: Feature name. +### toggleMetaBoxes + +Undocumented declaration. + ### togglePinnedPluginItem Triggers an action object used to toggle a plugin name flag. diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index b7e42d0217eefc..9b4d0a6e0ebf1d 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -18,9 +18,9 @@ import { privateApis as editorPrivateApis, } from '@wordpress/editor'; import { useEffect, useRef, useState } from '@wordpress/element'; -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -import { next, previous } from '@wordpress/icons'; +import { next, previous, box } from '@wordpress/icons'; import { PinnedItems } from '@wordpress/interface'; import { useViewportMatch } from '@wordpress/compose'; import { @@ -63,6 +63,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { isTextEditor, hasBlockSelection, hasActiveMetaboxes, + showMetaBoxes, hasFixedToolbar, isPublishSidebarOpened, showIconLabels, @@ -76,6 +77,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { hasBlockSelection: !! select( blockEditorStore ).getBlockSelectionStart(), hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), + showMetaBoxes: select( editPostStore ).showMetaBoxes(), hasHistory: !! select( editorStore ).getEditorSettings() .onNavigateToPreviousEntityRecord, @@ -85,6 +87,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { showIconLabels: getPreference( 'core', 'showIconLabels' ), }; }, [] ); + const { toggleMetaBoxes } = useDispatch( editPostStore ); const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] = useState( true ); @@ -187,6 +190,16 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { setEntitiesSavedStatesCallback } /> + { hasActiveMetaboxes && ( +