Skip to content

Commit

Permalink
Remove editorMode from blockProps (WordPress#65326)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj authored Oct 1, 2024
1 parent f5378f6 commit 12cd503
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
6 changes: 0 additions & 6 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ function BlockListBlockProvider( props ) {
isBlockBeingDragged,
isDragging,
__unstableHasActiveBlockOverlayActive,
__unstableGetEditorMode,
getSelectedBlocksInitialCaretPosition,
} = unlock( select( blockEditorStore ) );
const blockWithoutAttributes =
Expand Down Expand Up @@ -680,8 +679,6 @@ function BlockListBlockProvider( props ) {
blocksWithSameName.length &&
blocksWithSameName[ 0 ] !== clientId;

const editorMode = __unstableGetEditorMode();

return {
...previewContext,
mode: getBlockMode( clientId ),
Expand All @@ -708,7 +705,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 @@ -755,7 +751,6 @@ function BlockListBlockProvider( props ) {
themeSupportsLayout,
isTemporarilyEditingAsBlocks,
blockEditingMode,
editorMode,
mayDisplayControls,
mayDisplayParentControls,
index,
Expand Down Expand Up @@ -808,7 +803,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 @@ -85,7 +85,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
name,
blockApiVersion,
blockTitle,
editorMode,
isSelected,
isSubtreeDisabled,
hasOverlay,
Expand Down Expand Up @@ -113,7 +112,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
useBlockRefProvider( clientId ),
useFocusHandler( clientId ),
useEventHandlers( { clientId, isSelected } ),
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 12cd503

Please sign in to comment.