Framework: Merge editor and blocks modules into a single editor module#2795
Framework: Merge editor and blocks modules into a single editor module#2795youknowriad wants to merge 4 commits intomasterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2795 +/- ##
=========================================
- Coverage 33.95% 33.8% -0.15%
=========================================
Files 191 192 +1
Lines 5690 5709 +19
Branches 997 1003 +6
=========================================
- Hits 1932 1930 -2
- Misses 3180 3195 +15
- Partials 578 584 +6
Continue to review full report at Codecov.
|
29071f6 to
21adb83
Compare
There appear to be some failing tests yet. Restarting build did not appear to help. |
|
@aduth Yeah, I'll take a look and I also remembered that I have to change all the classnames :) |
21adb83 to
b0d8521
Compare
|
Since this would break all existing 3rd party blocks, can we alias the global for a couple versions and maybe log a warning? |
|
@mtias Good idea! I think we can't alias everything but we should through a warning in |
|
Do we foresee moving from block registration occurring on a global editor instance to individual instance of an editor, and if so, should we consider those implications as that change too would likely incur similar breaking changes? |
I don't think this change will be a breaking change (see my last PR exploring this #2182). The registration is still global, but the |
|
I added the aliased module, Let me know if you have a better wording for the warning. |
c21d30e to
386a9a1
Compare
|
Any other blocker here? |
blocks/index.js
Outdated
There was a problem hiding this comment.
Any specific reason we mix arrow and function syntaxes here? Could use arrow function in the latter case?
There was a problem hiding this comment.
I wanted to use arguments but I can replace with ...args
blocks/index.js
Outdated
blocks/index.js
Outdated
There was a problem hiding this comment.
The idea was not to flood block authors with warnings. Everyone will use registerBlock.
editor/README.md
Outdated
There was a problem hiding this comment.
Some of these API conversions don't translate too well. Is wp.editor.parse as clear as wp.blocks.parse in what it's doing? Maybe... do we need to be more specific with block terminology in the exported names? wp.editor.parseBlocks ?
I'm on the fence.
There was a problem hiding this comment.
No strong opinion, and honestly, I'm not sure this will stay this way once we completely refactor the editor with the generic components approach.
There was a problem hiding this comment.
We had the similar issues before, e.g. the method like wp.blocks.getCategories. We can iterate later.
docs/coding-guidelines.md
Outdated
There was a problem hiding this comment.
What would become our updated guideline for class name prefixing? I notice we're still using block- as prefix for classes in blocks (e.g. .blocks-gallery-image), despite the guideline currently recommending that anything in editor be prefixed as editor-
There was a problem hiding this comment.
I understood it like this:
The guidelines apply for the application classnames but not the frontend classnames theme authors should be aware of.
There was a problem hiding this comment.
I guess it registers all block types.
editor/test/reducer.js
Outdated
There was a problem hiding this comment.
Same question as previous: We didn't need this previously? Or was it the case that because we imported from @wordpress/blocks we implicitly included the full library as well? 😬
There was a problem hiding this comment.
The best thing to do is refactoring the test to not rely on these, but this PR is big enough :)
There was a problem hiding this comment.
I like it that we need to explicitly register those blocks. It just isn't clear from the require statement. We can revisit later.
c5e7b9e to
6183ff7
Compare
|
Some of the folder names lose their meaning when moved from For example:
In general, the Edit: To be clear, aside from some of the simple renaming, I don't want to suggest we come up with organization strategies for this pull request. I've also been thinking about how to better organize state, and these can be done in subsequent pull requests. |
| @@ -0,0 +1,4 @@ | |||
| .wp-block-quote.blocks-quote-style-2 > .editor-editable p { | |||
There was a problem hiding this comment.
.blocks-quote-style-2 shouldn't it start with editor now?
There was a problem hiding this comment.
Since these are also frontend classes too, I think we should have a separate rule for those because theme authors are likely to style them. We do not have a fixed rule for this yet, maybe wp-block__*, but this is a separate concern IMO
There was a problem hiding this comment.
Yep, these should stay :)
Edit: maybe not the remove link, checking
There was a problem hiding this comment.
The remove link is a special-case, it's included in a component used in save and edit but is shown only on edit (via a prop). I'm going to leave it as is for now, not clear answer here.
webpack.config.js
Outdated
| @@ -104,21 +104,21 @@ const config = { | |||
| { | |||
| test: /style\.s?css$/, | |||
| include: [ | |||
| /blocks/, | |||
| /editor\/library/, | |||
|
I was also going to suggest |
53f30fb to
e116c0a
Compare
…ary` to `editor/blocks`
e116c0a to
c2683df
Compare
|
I still think this makes sense, but let's try to address #2761 in a different order. |

Description
This PR merges the
blocksandeditormodules into a singleeditormodule, this separation was "artificial" since Block API don't work without an editor. This is the first step towards #2761Checklist:
index.jsfiles.@wordpress/blocksdependeency usage to internal importswp.blocks.*calls to avoid BCHow Has This Been Tested?
Test that everything works, the editor loads, you're able to edit/save posts (quickly)
It would be great if we can merge this quickly to avoid multiple rebases