Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowedBlocks and TemplateLock attributes in Cover Block #31326

Open
wants to merge 2 commits into
base: trunk
from

Conversation

@ajotka
Copy link

@ajotka ajotka commented Apr 29, 2021

Description

According to #31312 request, I added allowedBlocks attribute for Cover Block.

How has this been tested? And Screenshots

Tested manually.

  • Without allowedBlocks (before changes & after changes with Cover without passing allowedBlocks attribute)
  • Expectations: Possibility to add all blocks

image (1)

  • With allowedBlocks = [ 'core/paragraph', 'core/heading', 'core/button' ]

  • Expectations: Possibility to add only Paragraph, Heading and/or Button
    image (3)

  • With templateLock

  • Expectations: No 'add block' button and no possibility to add block
    image (11)

Types of changes

  1. Add allowedBlocks and templateLock attributes with their types to block.json
  2. Add allowedBlocks and templateLock (default false) attributes to edit.js
  3. Add allowedBlocks and templateLock attributes to edit.native.js

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
ajotka added 2 commits Apr 29, 2021
Add an option to pass allowedBlocks to Cover Block. 
Usage:
[ 'core/cover', 
	  {
		allowedBlocks: ALLOWED_BLOCKS,
		templateLock: "insert",
	  },
	  []
],


Feature from #31312
@ajotka ajotka requested a review from ajitbohra as a code owner Apr 29, 2021
@github-actions
Copy link

@github-actions github-actions bot commented Apr 29, 2021

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ajotka! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@@ -306,6 +306,8 @@ function CoverEdit( {
minHeightUnit,
style: styleAttribute,
url,
allowedBlocks,
templateLock = false,

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Apr 30, 2021
Member

Setting a default here explicitly removes the locking even if the attribute is unset causing a behavior change. I think we should not include the default here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants