Skip to content

Commit

Permalink
Add new mode
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 3, 2024
1 parent 239da89 commit 696c89b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
8 changes: 2 additions & 6 deletions packages/block-editor/src/components/tool-selector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => {
Expand Down Expand Up @@ -75,7 +74,7 @@ function ToolSelector( props, ref ) {
<>
<NavigableMenu role="menu" aria-label={ __( 'Tools' ) }>
<MenuItemsChoice
value={ isSimpleMode ? 'simple' : mode }
value={ mode }
onSelect={ ( newMode ) => {
if ( newMode === 'simple' ) {
const originalLocks = {};
Expand All @@ -94,8 +93,6 @@ function ToolSelector( props, ref ) {
templateLock: 'contentOnly',
}
);
__unstableSetEditorMode( 'edit' );
setIsSimpleMode( true );
} else {
// Restore the original templateLock attributes
blocksWithinMainBlockClientIds.forEach(
Expand All @@ -108,9 +105,8 @@ function ToolSelector( props, ref ) {
} );
}
);
__unstableSetEditorMode( newMode );
setIsSimpleMode( false );
}
__unstableSetEditorMode( newMode );
} }
choices={ [
{
Expand Down
38 changes: 24 additions & 14 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down

0 comments on commit 696c89b

Please sign in to comment.