-
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
Block Directory: Switch to blocks.registerBlockType
filter
#25264
Conversation
This lets us avoid adding a new filter specific to the missing block
Size Change: -721 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
I was unable to get the "Keep as HTML" link working. I click the link but nothing happens. |
@StevenDufresne Good catch — with the new filter that function isn't passed down into the component, so I need to define it here, too. Should be fixed with 1acd239 |
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 works as expected and is a good first step. Thanks!
let messageHTML = sprintf( | ||
/* translators: %s: block name */ | ||
__( | ||
'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.' |
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 nice if we could add a button to remove the block, although not a blocker for this PR.
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.
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.
Yeah, it is following the pattern from the original core/missing block. I think the idea is that you'd remove it like any other block (click and hit delete, or use the toolbar menu to remove it), but you could open an issue about it if you think we need a button here.
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.
Note that this string interpolation won't work for all locales.
There isn't much else to do — it's more of an FYI — especially since the translators
note is already there. Some translations may work around their issues by rephrasing as e.g. "%s: Your site doesn't include support for this block."
Description
In #22631 functionality was added to detect and install missing blocks from the block directory, if available. Initially this created a new filter on
MissingEdit
, but after some discussion on the PR, it was suggested to use the existingblocks.registerBlockType
filter instead. This PR makes the switch & removes theeditor.missingEdit
filter.This also updates the message displayed to the user— it won't offer HTML conversion if the missing block has no content or the HTML block is disabled.
How has this been tested?
Manual testing, using the following code to trigger a request to install the Star Rating block
You can test the no HTML case with this block code:
Screenshots