Replies: 11 comments 9 replies
-
This still seems like something that could be absorbed internally? |
Beta Was this translation helpful? Give feedback.
-
We discussed this previously with @ellatrix and @gziolo I think there's a lot of value in such proposal but I have my doubts. Especially around the "UI" part. A lot of these block supports are grouped together in panels... and it's unclear whether separate registration is a good thing here. That said, I believe this is one of those proposals that can only be "validated"/"approved" if actually tried. I believe we should explore this for the existing "core" block supports as a private API before releasing any official API. I also believe that ideally, this API shouldn't be relying on "filters" like we do now in block supports but instead it should be baked in into the block editor components... |
Beta Was this translation helpful? Give feedback.
-
For a while now we have a similar though much less powerful API called It really cuts down on the amount of error-prone boilerplate code you have to write for these extensions. I also really like the idea of the additional filter which doesn't cause re-renders of the full Something that we've found to be an issue which I think core could solve better that an external library ever could is providing a similar API for the PHP side. Whenever we register additional attributes for blocks we also need to register them server side. And any new attributes that we try to add to the block props / save element won't affect dynamic blocks. So we always have to duplicate this logic on the server as well. (Here is the example of the |
Beta Was this translation helpful? Give feedback.
-
I think this is a good devex improvement, hunting down all the filters is harder and even documenting a how to is a lot more intricate compared to the proposal here. Does this take anything away from what filters offer in terms of flexibility? |
Beta Was this translation helpful? Give feedback.
-
This looks great. It would make registering core block supports simpler but also gives 3rd party developers an easy way to provide new block supports (eg for things that may never make it into core). Parity with PHP api is definately interesting. But this looks really good to me 👍 |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking the time to write this up @Mamaduka ! To clarify, is the main goal of this proposal to improve editor performance (and developer experience) or is there intention to provide a public API so extenders can add custom tooling to the editor? Also, would the current PHP implementation be unchanged, using |
Beta Was this translation helpful? Give feedback.
-
@Mamaduka there's an inherent value in separating some of the UI work from the Edit function. still, when I squint at the before/after code, Makes me wonder if this is more or less a sign that we got some of the filter interfaces wrong, but the general filter concepts right. For example, Don't have many thoughts on this; it's hard to evaluate the context and reach of the changes, and I wonder how much this changes things vs. just moves them around a bit. Will continue to stew on it; thanks for the proposal! |
Beta Was this translation helpful? Give feedback.
-
This looks very promising. I've often found my self with the impossibility to reuse the block supports due too the closed way of handling the |
Beta Was this translation helpful? Give feedback.
-
@Mamaduka, this proposal received a ton of valuable feedback. Do you think we have enough insights to convert it into something actionable? |
Beta Was this translation helpful? Give feedback.
-
Very interesting, thanks for proposing! Where would you think block.json configurations might be considered, e.g., Also we could get the rendered styles via another method or in the background somehow (example border hook) - I'm happy to help massage the style engine if necessary. 🙇🏻 |
Beta Was this translation helpful? Give feedback.
-
The last remaining PR regarding the portals is merged (Block styles: remove __unstableElementContext in favour of useStyleOverride), so we're in a good spot now to attempt this. |
Beta Was this translation helpful? Give feedback.
-
Disclaimer: The document is based on the proposed API by @ellatrix and @gziolo. See #48809.
Summary
Introduce a new API,
registerBlockSupport
, for describing the behavior and rendering of block features that utilizesupport
properties.Problem
As the block editor started absorbing the complexities of block features like color, fonts, and dimension controls, it became apparent that the current method of integrating UI controls is not very sustainable and may sometimes hinder performance.
The present approach to add the "block support" features requires fragmenting the logic across multiple filters. Each filter is applied separately, overriding whole components multiple times. Additionally, it requires specific checks to ensure controls are only rendered when necessary and workarounds to prevent redundant re-mounting of the block's "Edit" component.
Example of current method
Alignment support
Proposal
The new first-class API will shift the implementation burden to the Block Editor, reducing the complexity for developers.
Design in #48809
A support key based registrar; doesn't require a separate
isSupported
check. The new settings object is merged into the block type definition.The API is easy to use but lacks flexibility. e.g., Some block support features must consider multiple support keys before rendering UI.
Proposed Design
This results from "migrating" current block support implementations to the proposed API. It builds on the initial design but uses functions to determine block support and update block settings, as they seem more flexible.
In the future, we could potentially offer "shortcut" options for both
isSupported
andblockSettings
.Unresolved questions
blockEditor.useBlockProps
filter #48884cc @WordPress/gutenberg-core, @aaronrobertshaw, @andrewserong
Beta Was this translation helpful? Give feedback.
All reactions