-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Decouple "Zooming" from "Composing with Patterns/Sections" #65265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
5a9e7c3
d958a4a
561bbe2
bf254c7
5acebac
e90fa9f
8884052
6a1f268
ee071bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,29 +16,30 @@ import { unlock } from '../../../lock-unlock'; | |
| * @param {string} clientId Block client ID. | ||
| */ | ||
| export function useZoomOutModeExit( { editorMode } ) { | ||
| const { getSettings } = useSelect( blockEditorStore ); | ||
| const { __unstableSetEditorMode } = unlock( | ||
| const { getEditorMode } = useSelect( ( select ) => { | ||
| const { __unstableGetEditorMode } = select( blockEditorStore ); | ||
| return { | ||
| getEditorMode: __unstableGetEditorMode, | ||
| }; | ||
| }, [] ); | ||
|
|
||
| const { __unstableSetEditorMode, setZoomOut } = unlock( | ||
| useDispatch( blockEditorStore ) | ||
| ); | ||
|
|
||
| return useRefEffect( | ||
| ( node ) => { | ||
| if ( editorMode !== 'zoom-out' ) { | ||
| if ( editorMode !== 'compose' ) { | ||
| return; | ||
| } | ||
|
|
||
| function onDoubleClick( event ) { | ||
| if ( ! event.defaultPrevented ) { | ||
| event.preventDefault(); | ||
|
|
||
| const { __experimentalSetIsInserterOpened } = getSettings(); | ||
|
|
||
| if ( | ||
| typeof __experimentalSetIsInserterOpened === 'function' | ||
| ) { | ||
| __experimentalSetIsInserterOpened( false ); | ||
| if ( getEditorMode() === 'compose' ) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we also want to check for being zoomed out here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are zoomed out but not in "compose" mode do we want double click to zoom in to work? |
||
| __unstableSetEditorMode( 'edit' ); | ||
| setZoomOut( false ); | ||
| } | ||
| __unstableSetEditorMode( 'edit' ); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -48,6 +49,6 @@ export function useZoomOutModeExit( { editorMode } ) { | |
| node.removeEventListener( 'dblclick', onDoubleClick ); | ||
| }; | ||
| }, | ||
| [ editorMode, getSettings, __unstableSetEditorMode ] | ||
| [ editorMode, __unstableSetEditorMode ] | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,11 @@ import { | |
| import { __ } from '@wordpress/i18n'; | ||
| import { useSelect, useDispatch } from '@wordpress/data'; | ||
| import { forwardRef } from '@wordpress/element'; | ||
| import { Icon, edit as editIcon } from '@wordpress/icons'; | ||
| import { | ||
| Icon, | ||
| edit as editIcon, | ||
| blockTable as composeIcon, | ||
| } from '@wordpress/icons'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
|
|
@@ -30,6 +34,13 @@ const selectIcon = ( | |
| </SVG> | ||
| ); | ||
|
|
||
| // write an icon map of mode => icon | ||
| const ICON_MAPPING = { | ||
| edit: editIcon, | ||
| navigation: selectIcon, | ||
| compose: composeIcon, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to show a special icon for compose or just alias to the "edit" icon? |
||
| }; | ||
|
|
||
| function ToolSelector( props, ref ) { | ||
| const mode = useSelect( | ||
| ( select ) => select( blockEditorStore ).__unstableGetEditorMode(), | ||
|
|
@@ -45,7 +56,7 @@ function ToolSelector( props, ref ) { | |
| __next40pxDefaultSize={ false } | ||
| { ...props } | ||
| ref={ ref } | ||
| icon={ mode === 'navigation' ? selectIcon : editIcon } | ||
| icon={ ICON_MAPPING[ mode ] } | ||
| aria-expanded={ isOpen } | ||
| aria-haspopup="true" | ||
| onClick={ onToggle } | ||
|
|
@@ -58,9 +69,7 @@ function ToolSelector( props, ref ) { | |
| <> | ||
| <NavigableMenu role="menu" aria-label={ __( 'Tools' ) }> | ||
| <MenuItemsChoice | ||
| value={ | ||
| mode === 'navigation' ? 'navigation' : 'edit' | ||
| } | ||
| value={ mode } | ||
| onSelect={ __unstableSetEditorMode } | ||
| choices={ [ | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to resolve this one