-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Open up "Pattern Overrides" and therefore intern block bindings to custom dynamic blocks #64870
Copy link
Copy link
Closed
Labels
[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] Block bindings[Feature] ExtensibilityThe ability to extend blocks or the editing experienceThe ability to extend blocks or the editing experience[Feature] Synced PatternsRelated to synced patterns (formerly reusable blocks)Related to synced patterns (formerly reusable blocks)[Focus] Blocks AdoptionFor issues that directly impact the ability to adopt features of Gutenberg.For issues that directly impact the ability to adopt features of Gutenberg.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Metadata
Metadata
Assignees
Labels
[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] Block bindings[Feature] ExtensibilityThe ability to extend blocks or the editing experienceThe ability to extend blocks or the editing experience[Feature] Synced PatternsRelated to synced patterns (formerly reusable blocks)Related to synced patterns (formerly reusable blocks)[Focus] Blocks AdoptionFor issues that directly impact the ability to adopt features of Gutenberg.For issues that directly impact the ability to adopt features of Gutenberg.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
✅ Done
This issue is coming out of a discussion in the Make WordPress Slack Outreach Channel where we discussed some of the reasons why we are not ready to adopt pattern overrides on custom build projects.
Currently, pattern overrides is limited to only a small set of core blocks that have handling for their block bindings HTML replacement handled manually. With that, we have opted not to expose the mechanisms to create blocks that make use of the Pattern Overrides feature publicly until the HTML API lands in core.
However, we just realized that this limitation to wait on the HTML API only really applies to static blocks (ones that serialize their HTML to the database). For dynamic blocks (block rendered via a
render_callbackin PHP) this limitation does not exist.Because of that I would propose that we open up the block bindings / pattern overrides feature for custom blocks that use dynamic rendering.
How to achieve that:
First we would need to find a way to indicate which attributes of which blocks actually allow to be bound to something. Currently, this is managed in a hard-coded list. #64756 explores adding a
bindabledecorator to the attributes definition which could be used to get that list dynamically.Once we know which attributes of which blocks support bindings, we would need to also use that to handle saving attributes / passing in the correct value of attributes correctly in the editor.
And finally, we can use that same
bindablekey to replace https://github.com/WordPress/wordpress-develop/blob/e569967ee45e23186f6aa7f479fcb48a7511436b/src/wp-includes/class-wp-block.php#L246-L251 with the dynamic lookup of supported bindings.