diff --git a/packages/edit-post/src/components/header/writing-menu/index.js b/packages/edit-post/src/components/header/writing-menu/index.js index de6acf67c19834..26cc6bc5871650 100644 --- a/packages/edit-post/src/components/header/writing-menu/index.js +++ b/packages/edit-post/src/components/header/writing-menu/index.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { useSelect, useDispatch, useRegistry } from '@wordpress/data'; +import { useDispatch, useRegistry } from '@wordpress/data'; import { MenuGroup } from '@wordpress/components'; import { __, _x } from '@wordpress/i18n'; import { useViewportMatch } from '@wordpress/compose'; @@ -10,7 +10,6 @@ import { PreferenceToggleMenuItem, store as preferencesStore, } from '@wordpress/preferences'; -import { store as blockEditorStore } from '@wordpress/block-editor'; /** * Internal dependencies @@ -19,11 +18,6 @@ import { store as postEditorStore } from '../../../store'; function WritingMenu() { const registry = useRegistry(); - const isDistractionFree = useSelect( - ( select ) => - select( blockEditorStore ).getSettings().isDistractionFree, - [] - ); const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } = useDispatch( postEditorStore ); @@ -38,6 +32,10 @@ function WritingMenu() { } ); }; + const turnOffDistractionFree = () => { + setPreference( 'core/edit-post', 'distractionFree', false ); + }; + const isLargeViewport = useViewportMatch( 'medium' ); if ( ! isLargeViewport ) { return null; @@ -47,8 +45,8 @@ function WritingMenu() { + - ); } diff --git a/packages/edit-post/src/components/preferences-modal/index.js b/packages/edit-post/src/components/preferences-modal/index.js index 547e402eadcbb8..833a10fce13c33 100644 --- a/packages/edit-post/src/components/preferences-modal/index.js +++ b/packages/edit-post/src/components/preferences-modal/index.js @@ -76,6 +76,10 @@ export default function EditPostPreferencesModal() { closeGeneralSidebar(); }; + const turnOffDistractionFree = () => { + setPreference( 'core/edit-post', 'distractionFree', false ); + }; + const sections = useMemo( () => [ { @@ -171,6 +175,7 @@ export default function EditPostPreferencesModal() { > - select( preferencesStore ).get( - 'core/edit-site', - 'distractionFree' - ), - [] - ); const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } = useDispatch( siteEditorStore ); @@ -59,6 +51,10 @@ export default function MoreMenu( { showIconLabels } ) { } ); }; + const turnOffDistractionFree = () => { + setPreference( 'core/edit-site', 'distractionFree', false ); + }; + return ( <> - + { + setPreference( 'core/edit-site', 'distractionFree', false ); + }; + const sections = useMemo( () => [ { name: 'general', @@ -76,6 +80,7 @@ export default function EditSitePreferencesModal() { > - ), },