[WIP] Blocks: Make the block registration filterable on the server#5802
[WIP] Blocks: Make the block registration filterable on the server#5802
Conversation
06953cf to
5ddf413
Compare
blocks/library/block/index.js
Outdated
| customClassName: false, | ||
| html: false, | ||
| }, | ||
| isPrivate: true, |
There was a problem hiding this comment.
Why is this on the client?
There was a problem hiding this comment.
I don't like this property at all :) I will move it to the server, too 👍
There was a problem hiding this comment.
To make things easier, I moved isPrivate to supports property and renamed to insertable.
youknowriad
left a comment
There was a problem hiding this comment.
Any reason this is limited to dynamic blocs?
blocks/library/block/index.js
Outdated
| @@ -172,20 +172,10 @@ export const name = 'core/block'; | |||
|
|
|||
| export const settings = { | |||
| title: __( 'Shared Block' ), | |||
There was a problem hiding this comment.
What about the title and description? It seems to me that blocks discovery would benefit from these properties being declared on the server as well
There was a problem hiding this comment.
I'm going back and forth with those two. After another round of musings, I think it makes sense to move them to the server. In addition, we should move non-SVG version of the icon. This might allow lazy loading of blocks on the client because we would have something to display in the inserters.
Everything JS-based becomes a progressive enhancement loaded on the client when requested.
There was a problem hiding this comment.
I moved title, description, icon and keywords to the server, too.
Just to keep the scope of the PR smaller. I would like to divide the efforts into 2 chunks. First, I'd like to refactor all dynamic blocks and provide deprecation strategy to that area. In the long run it should be enforced to declare all the properties listed in this PR on the server. Next step would be to convert all static blocks to be server-side rendered and promote such usage. @mtias suggested keeping the client-side registration for very simple blocks forever. We will need to come up with a set of rules when that would be possible. The biggest issue we discovered so far is when hooks updates |
539ec1b to
271404c
Compare
271404c to
c226868
Compare
|
How is this related to #4841? |
If someone wanted to implement a Gutenberg editor outside a WordPress context, how would they do so without being able to register a block? We're limiting capabilities of the client, when we should continue to treat it as first-class, even if data is being pre-loaded by the server. The benefits of registering blocks on the server should be obvious enough to entice plugin authors into doing so. |
This is tricky. On one hand, I was going to comment that we can keep the client-side interface with no restrictions if we make it clear — through naming, foremost — that it's meant for debugging and quick prototyping, thus making it acceptable for the very smallest plugins to use it if they so choose. On the other hand, it's hard to reconcile with:
I mean, we could say that the server-side method is the canonical one and, as an encouragement, only offer filters for it and not for the client-side method. However, on a technical level, there isn't a strong argument for not opening this up to client-side filtering (except, perhaps, for a concern of consistency), what with Trying to think more broadly about Gutenberg as the first-class editor and its role within WordPress, maybe it makes sense — borrowing terminology from React — to think of WordPress as a provider for the editor. Under that light, it would make sense to:
|
|
This one is stale and @youknowriad is working on a different set of changes in #6733. Let's close it and continue there. |
[UPDATE: moved to #6733]
Description
Implements: #2751, #4116.
Replaces: #5652.
The updated plan is as follows (originally shared in #5652):
register_block_typeis going to be the only way to register dynamic block and it needs to happen on the serverattributes,supports,category,title?,description? will have to be registered on the server. It will be possible to update them only with the PHP hook.extendBlockTypewith the new corresponding JS hook.registerBlockTypewill remain with deprecation message for the next 2-3 releases to make sure developers have time to refactor their plugins.Screenshots (jpeg or gifs if applicable):
There should be no visual changes.
Types of changes
Breaking change with the deprecation strategy to be proposed.
Checklist: