-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Block Bindings: Improve the way block bindings sources are registered #63117
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
Merged
SantosGuillamot
merged 15 commits into
trunk
from
try/change-the-way-bindings-are-registered
Jul 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d716b5f
Move bindings registration to editor provider
SantosGuillamot 6f2ab12
Remove old bindings import
SantosGuillamot 6cabef4
Remove sources from editor provider
SantosGuillamot 4701034
Create registerBlockBindingsSource
SantosGuillamot db6f4d4
Export function as private
SantosGuillamot d776739
Create `registerCoreBlockBindingsSources` function
SantosGuillamot d6978d8
Register core sources in edit-post and edit-site
SantosGuillamot efc1450
Don't reuse existing source
SantosGuillamot 2a314b1
Add comment explaining function
SantosGuillamot e8e248c
Change the object in registration
SantosGuillamot 2c99727
Add a few checks more
SantosGuillamot 715911d
Add more registration functions
SantosGuillamot 2866f51
Add private action to remove binding source
SantosGuillamot 422aef7
Add unit tests
SantosGuillamot c27eed8
Export all functions as private
SantosGuillamot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Don't reuse existing source
- Loading branch information
commit efc1450a79df5b2bc2d87ba86299c4b4339f3090
There are no files selected for viewing
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this be translatable and dev only? Can be done in a follow-up.
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.
Maybe? 🤔 I checked the rest of the
console.errorandconsole.warnGutenberg has and it seems they are never translated. Maybe it is a good discussion to have globally? By the way, what do you mean with dev only?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.
The most optimal would be:
It's a hint for a developer, but the code continues to work after making the best informed decision.
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.
I can make that change 🙂
I just followed what is being done in the
registerBlockTypefunction: link.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.
I am not sure when we should throw a warning and when an error. In both cases, the editor won't break but the bindings won't work as expected.
Error

Warning

I'll create a follow-up pull request to properly discuss that.
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.
That's a good question. Interactivity API uses warnings, whether the interactivity worked or not.
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.
It would be great to unify.
@wordpress/warningwas introduced not that long ago, so historically, people would useconsole.errororconsole.warnbased on their personal preferences. I would simplify it and usewarningfrom@wordpress/warningas it doesn't add too much value on production anyway. The other benefit is that@wordpress/warninguses hooks internally so 3rd party plugin can intercept these warning. If I recall correctly @johnbillion integrated that into Query Monitor plugin that has 200k active installs.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.
That makes sense. I will create a pull request to change all the
console.errorandconsole.warnin the registration file to use@wordpress/warning.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.
Follow-up created here: #63610. Although I encountered some issues.