-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block Editor: Absorb parent block toolbar controls (#33955)
* Block Editor: Try to absorb parent block toolbar controls * Try a new block controls group - parent * Expose conditionally general duotone and align block controls * Use __experimentalExposeControlsToChildren in block supports
- Loading branch information
Showing
12 changed files
with
110 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/block-editor/src/components/block-controls/hook.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { store as blocksStore } from '@wordpress/blocks'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import groups from './groups'; | ||
import { store as blockEditorStore } from '../../store'; | ||
import { useBlockEditContext } from '../block-edit/context'; | ||
import useDisplayBlockControls from '../use-display-block-controls'; | ||
|
||
export default function useBlockControlsFill( group, exposeToChildren ) { | ||
const isDisplayed = useDisplayBlockControls(); | ||
const { clientId } = useBlockEditContext(); | ||
const isParentDisplayed = useSelect( | ||
( select ) => { | ||
const { getBlockName, hasSelectedInnerBlock } = select( | ||
blockEditorStore | ||
); | ||
const { hasBlockSupport } = select( blocksStore ); | ||
return ( | ||
exposeToChildren && | ||
hasBlockSupport( | ||
getBlockName( clientId ), | ||
'__experimentalExposeControlsToChildren', | ||
false | ||
) && | ||
hasSelectedInnerBlock( clientId ) | ||
); | ||
}, | ||
[ exposeToChildren, clientId ] | ||
); | ||
|
||
if ( isDisplayed ) { | ||
return groups[ group ]?.Fill; | ||
} | ||
if ( isParentDisplayed ) { | ||
return groups.parent.Fill; | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters