diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index bdbfc78eb482e4..ba256530cd32a9 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -19,19 +19,6 @@ _Returns_ - `boolean`: True if the block has controlled inner blocks. -### canEditBlock - -Determines if the given block is allowed to be edited. - -_Parameters_ - -- _state_ `Object`: Editor state. -- _clientId_ `string`: The block client Id. - -_Returns_ - -- `boolean`: Whether the given block is allowed to be edited. - ### canInsertBlocks Determines if the given blocks are allowed to be inserted into the block diff --git a/packages/block-editor/src/components/block-content-overlay/index.js b/packages/block-editor/src/components/block-content-overlay/index.js index 727d2445883ce1..249f6f3bc8e3e1 100644 --- a/packages/block-editor/src/components/block-content-overlay/index.js +++ b/packages/block-editor/src/components/block-content-overlay/index.js @@ -25,7 +25,6 @@ export default function BlockContentOverlay( { const [ isHovered, setIsHovered ] = useState( false ); const { - canEdit, isParentSelected, hasChildSelected, isDraggingBlocks, @@ -37,10 +36,8 @@ export default function BlockContentOverlay( { hasSelectedInnerBlock, isDraggingBlocks: _isDraggingBlocks, isBlockHighlighted, - canEditBlock, } = select( blockEditorStore ); return { - canEdit: canEditBlock( clientId ), isParentSelected: isBlockSelected( clientId ), hasChildSelected: hasSelectedInnerBlock( clientId, true ), isDraggingBlocks: _isDraggingBlocks(), @@ -62,12 +59,6 @@ export default function BlockContentOverlay( { ); useEffect( () => { - // The overlay is always active when editing is locked. - if ( ! canEdit ) { - setIsOverlayActive( true ); - return; - } - // Reenable when blocks are not in use. if ( ! isParentSelected && ! hasChildSelected && ! isOverlayActive ) { setIsOverlayActive( true ); @@ -84,13 +75,7 @@ export default function BlockContentOverlay( { if ( hasChildSelected && isOverlayActive ) { setIsOverlayActive( false ); } - }, [ - isParentSelected, - hasChildSelected, - isOverlayActive, - isHovered, - canEdit, - ] ); + }, [ isParentSelected, hasChildSelected, isOverlayActive, isHovered ] ); // Disabled because the overlay div doesn't actually have a role or functionality // as far as the a11y is concerned. We're just catching the first click so that @@ -103,9 +88,7 @@ export default function BlockContentOverlay( { onMouseEnter={ () => setIsHovered( true ) } onMouseLeave={ () => setIsHovered( false ) } onMouseUp={ - isOverlayActive && canEdit - ? () => setIsOverlayActive( false ) - : undefined + isOverlayActive ? () => setIsOverlayActive( false ) : undefined } > { wrapperProps?.children } diff --git a/packages/block-editor/src/components/block-lock/modal.js b/packages/block-editor/src/components/block-lock/modal.js index 0efb69b5bda0eb..5a0c140f4d2ad3 100644 --- a/packages/block-editor/src/components/block-lock/modal.js +++ b/packages/block-editor/src/components/block-lock/modal.js @@ -13,8 +13,7 @@ import { } from '@wordpress/components'; import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons'; import { useInstanceId } from '@wordpress/compose'; -import { useDispatch, useSelect } from '@wordpress/data'; -import { isReusableBlock, getBlockType } from '@wordpress/blocks'; +import { useDispatch } from '@wordpress/data'; /** * Internal dependencies @@ -25,18 +24,7 @@ import { store as blockEditorStore } from '../../store'; export default function BlockLockModal( { clientId, onClose } ) { const [ lock, setLock ] = useState( { move: false, remove: false } ); - const { canEdit, canMove, canRemove } = useBlockLock( clientId ); - const { isReusable } = useSelect( - ( select ) => { - const { getBlockName } = select( blockEditorStore ); - const blockName = getBlockName( clientId ); - - return { - isReusable: isReusableBlock( getBlockType( blockName ) ), - }; - }, - [ clientId ] - ); + const { canMove, canRemove } = useBlockLock( clientId ); const { updateBlockAttributes } = useDispatch( blockEditorStore ); const blockInformation = useBlockDisplayInformation( clientId ); const instanceId = useInstanceId( @@ -48,9 +36,8 @@ export default function BlockLockModal( { clientId, onClose } ) { setLock( { move: ! canMove, remove: ! canRemove, - ...( isReusable ? { edit: ! canEdit } : {} ), } ); - }, [ canEdit, canMove, canRemove, isReusable ] ); + }, [ canMove, canRemove ] ); const isAllChecked = Object.values( lock ).every( Boolean ); const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked; @@ -94,36 +81,10 @@ export default function BlockLockModal( { clientId, onClose } ) { setLock( { move: newValue, remove: newValue, - ...( isReusable ? { edit: newValue } : {} ), } ) } />