Skip to content

Commit

Permalink
Pass block object to isUnmodifiedDefaultBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Feb 26, 2024
1 parent 2f9b9c6 commit 82a80cc
Showing 1 changed file with 12 additions and 13 deletions.
Expand Up @@ -34,38 +34,37 @@ export function useShowBlockTools() {
getSelectedBlockClientId() ||
getFirstMultiSelectedBlockClientId();

const { name = '', attributes = {} } = getBlock( clientId ) || {};
const editorMode = __unstableGetEditorMode();
const hasSelectedBlock = clientId && name;
const isEmptyDefaultBlock = isUnmodifiedDefaultBlock( {
name,
attributes,
} );
const _showEmptyBlockSideInserter =
const block = getBlock( clientId );
const hasSelectedBlock = clientId && !! block?.name;
const isEmptyDefaultBlock =
hasSelectedBlock && isUnmodifiedDefaultBlock( block );
const showEmptyBlockSideInserter =
clientId &&
! isTyping() &&
editorMode === 'edit' &&
isUnmodifiedDefaultBlock( { name, attributes } );
isEmptyDefaultBlock;
const maybeShowBreadcrumb =
hasSelectedBlock &&
! hasMultiSelection() &&
( editorMode === 'navigation' || editorMode === 'zoom-out' );
const { hasFixedToolbar } = getSettings();

return {
showEmptyBlockSideInserter: _showEmptyBlockSideInserter,
showEmptyBlockSideInserter,
showBreadcrumb:
! _showEmptyBlockSideInserter && maybeShowBreadcrumb,
! showEmptyBlockSideInserter && maybeShowBreadcrumb,
showBlockToolbarPopover:
hasBlockToolbar &&
! getSettings().hasFixedToolbar &&
! _showEmptyBlockSideInserter &&
! hasFixedToolbar &&
! showEmptyBlockSideInserter &&
hasSelectedBlock &&
! isEmptyDefaultBlock &&
! maybeShowBreadcrumb,
showFixedToolbar:
editorMode !== 'zoom-out' &&
hasBlockToolbar &&
getSettings().hasFixedToolbar,
hasFixedToolbar,
};
},
[ hasBlockToolbar ]
Expand Down

0 comments on commit 82a80cc

Please sign in to comment.