Skip to content

Commit

Permalink
Remove existing control from document tools
Browse files Browse the repository at this point in the history
  • Loading branch information
richtabor committed Jan 24, 2024
1 parent 59f26de commit 54e7cb5
Showing 1 changed file with 4 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
/**
* WordPress dependencies
*/
import { useViewportMatch } from '@wordpress/compose';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { chevronUpDown } from '@wordpress/icons';
import { Button, ToolbarItem } from '@wordpress/components';
import {
store as editorStore,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { privateApis as editorPrivateApis } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -20,50 +13,19 @@ import { unlock } from '../../../lock-unlock';

const { DocumentTools: EditorDocumentTools } = unlock( editorPrivateApis );

export default function DocumentTools( {
blockEditorMode,
hasFixedToolbar,
isDistractionFree,
} ) {
export default function DocumentTools() {
const { isVisualMode } = useSelect( ( select ) => {
const { getEditorMode } = select( editSiteStore );

return {
isVisualMode: getEditorMode() === 'visual',
};
}, [] );
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
const { setDeviceType } = useDispatch( editorStore );
const isLargeViewport = useViewportMatch( 'medium' );
const isZoomedOutViewExperimentEnabled =
window?.__experimentalEnableZoomedOutView && isVisualMode;
const isZoomedOutView = blockEditorMode === 'zoom-out';

return (
<EditorDocumentTools
disableBlockTools={ ! isVisualMode }
listViewLabel={ __( 'List View' ) }
>
{ isZoomedOutViewExperimentEnabled &&
isLargeViewport &&
! isDistractionFree &&
! hasFixedToolbar && (
<ToolbarItem
as={ Button }
className="edit-site-header-edit-mode__zoom-out-view-toggle"
icon={ chevronUpDown }
isPressed={ isZoomedOutView }
/* translators: button label text should, if possible, be under 16 characters. */
label={ __( 'Zoom-out View' ) }
onClick={ () => {
setDeviceType( 'Desktop' );
__unstableSetEditorMode(
isZoomedOutView ? 'edit' : 'zoom-out'
);
} }
size="compact"
/>
) }
</EditorDocumentTools>
/>
);
}

0 comments on commit 54e7cb5

Please sign in to comment.