-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 custom attributes sources block support #51375
Conversation
Size Change: +486 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
Flaky tests detected in 987a544. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5242456031
|
There's currently a bug in this PR when you click For instance, now, when clicking "enter", we try to split the block into two, the first block remained externally sourced but it gets a "content" attribute filled as well (bug you can see in the code editor mode) while the second paragraph is not externally sourced. Something similar happens when pasting (you might also see two externally sourced blocks one at the beginning and one at the end) I guess we need to figure out how to address this, it feels like the ideal solution would be to not allow splitting and for pasting I'm not sure what the expected behavior should be (maybe paste as text within the block). cc @ellatrix @mtias |
There's a few layers to this. Eventually, I think the attribute source plus the block's interface should be dictating the "type" for a field, meaning that if we have a coupling of "content" attribute being handled by a |
This PR served its purpose as an experiment and has been implemented in other PRs. |
Thank you for sharing the prototype that helped to clarify further work necessary like: |
@@ -0,0 +1,110 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is an example of frontend definition of a custom source.
* @package gutenberg | ||
*/ | ||
|
||
return array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is the definition of a custom source in the backend.
This PR explores the possibility to allow users and extenders to flag that some block attributes come from external sources. This POC focuses on implementing the "custom fields" external source while providing a very basic API to define alternative external sources for block attributes.
For instance: this allows paragraph block to have their content sourced from a post meta.
This project have been renamed "block bindings" and you can read more details about it in #53300