-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Rethink the separation between editor
and blocks
module
#6275
Comments
This sounds like the opposite direction from what I was hoping for. As a developer for a third party builder having the blocks tied to the editor creates a major long term problem because it limits what I can do with blocks outside of the Gutenberg editor. |
Ideally blocks would be separate entities that would be reusable in contexts other than the editor too... There's a whole industry of page-builders and site-builders out there. Everyone would benefit if it was possible to reuse blocks outside the editor |
If blocks served as data structure plus API to re-use and manipulate data, which would be the most versatile setup, it seems to make most sense to implement them agnostic of the editor. In that case the editor could use the same API as other, alternative editors and builders to display and manipulate blocks. Post contents would be open to a variety of UIs and page building services instead of being locked to just one core component. |
@mikka23 @aristath @maximus80 I think you're misunderstanding the purpose of the Blocks can't be rendered without a surrounding editor, whether this editor is a post editor, a frontend editor, a customizer editor, that's another question, and the |
@youknowriad tbh I haven't checked the code in a while... Last time an attempt was made to do what we needed, this had to be applied before: #5691 |
To echo what @youknowriad said. |
Totally agree on (1), (3), (4). I didn't consider (2) earlier, but given that we had so many issues with the order of blocks registration so far it makes a lot of sense. Hopefully, we can hide those hooks as an implementation detail, so you could still call Nit: |
I'm going to close this as the big updates already landed. |
Originally, these two modules were separated because we thought that it was possible to create blocks without the need for an
editor
concept. This led us to:But this proved to have several drawbacks:
We need to introduce "editorSettings" using context because some of the components in the blocks module change their behavior depending on editor settings which means the blocks can't be totally independent from the surrounding editor.
The "shared blocks" are saved into the editor's state but the block itself is declared in the blocks library. This indicates that shared blocks are a concept not independent from an editor's store.
The image block needs to attach uploaded images to the post used in the editor
Blocks need access to the list of available blocks (for autocompleters for instance) and we need the editor store and the editor settings to know exactly what blocks are available.
InnerBlocks
used internally by nested blocks usesBlockList
from the editor.Proposal
1- Extract the block library to a
blocks-library
module depending on Editor and Blocks2- Introduce a JS action
blocks.register
for block authors to register their blocks as a response to this action. This action needs to trigger after all the JavaScript files are loaded (domReady?) to avoid issues with loading order. Still allow direct registration for backwards compatibility for some releases.3- Move the components defined in the blocks module to the editor's module while providing backwards compatibility for some time (wp.blocks.* = wp.editor.*)
4- Keep only the block registration and api in the blocks module.
Thoughts? @WordPress/gutenberg-core
editorMediaUpload
to the editor module Move editorMediaUpload to the editor module #6682blocks.*
The text was updated successfully, but these errors were encountered: