From 696c89b562dd13127b3f2b62674f33c70abc43f5 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 3 Sep 2024 15:57:29 +0100 Subject: [PATCH] Add new mode --- .../src/components/tool-selector/index.js | 8 +--- packages/block-editor/src/store/actions.js | 38 ++++++++++++------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/block-editor/src/components/tool-selector/index.js b/packages/block-editor/src/components/tool-selector/index.js index 0a51fbd4325f73..b8b46d17c6d7bf 100644 --- a/packages/block-editor/src/components/tool-selector/index.js +++ b/packages/block-editor/src/components/tool-selector/index.js @@ -31,7 +31,6 @@ const selectIcon = ( ); function ToolSelector( props, ref ) { - const [ isSimpleMode, setIsSimpleMode ] = useState( false ); const [ originalTemplateLocks, setOriginalTemplateLocks ] = useState( {} ); const { mode, blocksWithinMainBlockClientIds, getBlockAttributes } = useSelect( ( select ) => { @@ -75,7 +74,7 @@ function ToolSelector( props, ref ) { <> { if ( newMode === 'simple' ) { const originalLocks = {}; @@ -94,8 +93,6 @@ function ToolSelector( props, ref ) { templateLock: 'contentOnly', } ); - __unstableSetEditorMode( 'edit' ); - setIsSimpleMode( true ); } else { // Restore the original templateLock attributes blocksWithinMainBlockClientIds.forEach( @@ -108,9 +105,8 @@ function ToolSelector( props, ref ) { } ); } ); - __unstableSetEditorMode( newMode ); - setIsSimpleMode( false ); } + __unstableSetEditorMode( newMode ); } } choices={ [ { diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index ebd310b3de9d3f..46bc147f69f2a9 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -1714,20 +1714,30 @@ export const __unstableSetEditorMode = dispatch( { type: 'SET_EDITOR_MODE', mode } ); - if ( mode === 'navigation' ) { - speak( - __( - 'You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.' - ) - ); - } else if ( mode === 'edit' ) { - speak( - __( - 'You are currently in edit mode. To return to the navigation mode, press Escape.' - ) - ); - } else if ( mode === 'zoom-out' ) { - speak( __( 'You are currently in zoom-out mode.' ) ); + switch ( mode ) { + case 'navigation': + speak( + __( + 'You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.' + ) + ); + break; + case 'edit': + speak( + __( + 'You are currently in edit mode. To return to the navigation mode, press Escape.' + ) + ); + break; + case 'zoom-out': + speak( __( 'You are currently in zoom-out mode.' ) ); + break; + case 'simple': + speak( __( 'You are currently in simple editing mode.' ) ); + break; + default: + // Optional: handle other cases or do nothing + break; } };