Skip to content

Commit

Permalink
Add allowedBlocks and TemplateLock attributes in Cover Block (#31326)
Browse files Browse the repository at this point in the history
* Add allowedBlocks and templateLock attributes to Cover Block

Add an option to pass allowedBlocks to Cover Block.
Usage:
[ 'core/cover',
	  {
		allowedBlocks: ALLOWED_BLOCKS,
		templateLock: "insert",
	  },
	  []
],

Feature from #31312

* Add new attributes to edit.native

* Remove templatelock default

* Remove templatelock default
  • Loading branch information
ajotka committed Oct 16, 2021
1 parent e306701 commit 2303cd1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/block-library/src/cover/block.json
Expand Up @@ -62,6 +62,12 @@
"isDark": {
"type": "boolean",
"default": true
},
"allowedBlocks": {
"type": "array"
},
"templateLock": {
"type": "string"
}
},
"supports": {
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/cover/edit.js
Expand Up @@ -325,6 +325,8 @@ function CoverEdit( {
style: styleAttribute,
url,
alt,
allowedBlocks,
templateLock,
} = attributes;
const {
gradientClass,
Expand Down Expand Up @@ -618,6 +620,8 @@ function CoverEdit( {
{
template: innerBlocksTemplate,
templateInsertUpdatesSelection: true,
allowedBlocks,
templateLock,
}
);

Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/cover/edit.native.js
Expand Up @@ -101,6 +101,8 @@ const Cover = ( {
style,
customOverlayColor,
minHeightUnit = 'px',
allowedBlocks,
templateLock,
} = attributes;
const [ isScreenReaderEnabled, setIsScreenReaderEnabled ] = useState(
false
Expand Down Expand Up @@ -504,7 +506,9 @@ const Cover = ( {
style={ [ styles.content, { minHeight: convertedMinHeight } ] }
>
<InnerBlocks
allowedBlocks={ allowedBlocks }
template={ INNER_BLOCKS_TEMPLATE }
templateLock={ templateLock }
templateInsertUpdatesSelection
blockWidth={ blockWidth }
/>
Expand Down

0 comments on commit 2303cd1

Please sign in to comment.