Skip to content

Commit

Permalink
Backport "Remove editorMode from blockProps (#65326)" to wp/6.7(#66057)
Browse files Browse the repository at this point in the history
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 1ae3f5f commit 53d7179
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
3 changes: 0 additions & 3 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ function BlockListBlockProvider( props ) {
) && hasSelectedInnerBlock( clientId ),
blockApiVersion: blockType?.apiVersion || 1,
blockTitle: match?.title || blockType?.title,
editorMode,
isSubtreeDisabled:
blockEditingMode === 'disabled' &&
isBlockSubtreeDisabled( clientId ),
Expand Down Expand Up @@ -766,7 +765,6 @@ function BlockListBlockProvider( props ) {
themeSupportsLayout,
isTemporarilyEditingAsBlocks,
blockEditingMode,
editorMode,
mayDisplayControls,
mayDisplayParentControls,
index,
Expand Down Expand Up @@ -821,7 +819,6 @@ function BlockListBlockProvider( props ) {
hasOverlay,
initialPosition,
blockEditingMode,
editorMode,
isHighlighted,
isMultiSelected,
isPartiallySelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
name,
blockApiVersion,
blockTitle,
editorMode,
isSelected,
isSubtreeDisabled,
hasOverlay,
Expand Down Expand Up @@ -117,7 +116,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
useFocusHandler( clientId ),
useEventHandlers( { clientId, isSelected } ),
useNavModeExit( clientId ),
useZoomOutModeExit( { editorMode } ),
useZoomOutModeExit(),
useIsHovered( { clientId } ),
useIntersectionObserver(),
useMovingAnimation( { triggerAnimationOnChange: index, clientId } ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ import { unlock } from '../../../lock-unlock';

/**
* Allows Zoom Out mode to be exited by double clicking in the selected block.
*
* @param {string} clientId Block client ID.
*/
export function useZoomOutModeExit( { editorMode } ) {
const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
export function useZoomOutModeExit() {
const { getSettings, isZoomOut, __unstableGetEditorMode } = unlock(
useSelect( blockEditorStore )
);

const { __unstableSetEditorMode, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);

return useRefEffect(
( node ) => {
// In "compose" mode.
const composeMode = editorMode === 'zoom-out' && isZoomOut();
function onDoubleClick( event ) {
// In "compose" mode.
const composeMode =
__unstableGetEditorMode() === 'zoom-out' && isZoomOut();

if ( ! composeMode ) {
return;
}
if ( ! composeMode ) {
return;
}

function onDoubleClick( event ) {
if ( ! event.defaultPrevented ) {
event.preventDefault();

Expand All @@ -52,6 +54,12 @@ export function useZoomOutModeExit( { editorMode } ) {
node.removeEventListener( 'dblclick', onDoubleClick );
};
},
[ editorMode, getSettings, __unstableSetEditorMode ]
[
getSettings,
__unstableSetEditorMode,
__unstableGetEditorMode,
isZoomOut,
resetZoomLevel,
]
);
}

0 comments on commit 53d7179

Please sign in to comment.