Repository navigation
Description
For this release, the block editor had around 32 PR's needing a dev note. Writing 32 posts with dev notes would not be something viable as we would reduce the probability of the developers reading the post, so we should try to reduce the number of posts.
I checked all these PR's and tried to group the dev notes in a set of posts.
So what I propose is to group the dev notes in 7 posts:
- Block Updates
- New Block API's
- General API Updates
- Markup and Style related changes
- IconButton and Button Components Changes
- Keyboard Shortcuts Package
- Developer Experience Notes
If needed and one of the posts becomes too big, we may consider a further division.
For each of these dev note posts, I list the PR's the dev note will include. I cc people involved in the PR. The process we will try to follow is the persons involved in the PR write the dev note for the PR, taking into account the context of the post that the dev note will be part of, and share the content as a comment of this issue so that everyone could see.
If there is any feedback on this process or any suggestion for changes in the structure of dev notes, please leave a comment. If you are not able to write a dev note for a PR, you are involved please also leave a comment, so we adjust the planning.
Thank you in advance for the help in writing the dev notes together.
Block Updates
Add: Buttons block
- cc: @jorgefilipecosta
- Done
Add: Social Link Block
New Block API's
Promote block variations to stable API
- cc: @gziolo
- Done
Add block collections
- cc: @scruffian, @gziolo
- Done
General API Updates
Editor: Implement EntityProvider and use it to refactor custom sources with a backward compatibility hook for meta sources.
- cc: @epiqueras
- Done
Make the AsyncModeProvider API a stable API
- cc: @youknowriad
- In progress
- Done
Make the mediaUpload block editor setting a stable API
- cc: @youknowriad
- Done
Transforms: Shortcode: Support isMatch predicate
- cc: @mcsf
- Done
Drop zone: rewrite with hooks (useDropZone)
- cc: @ellatrix
- Done
RichText: don't set focus when applying format
- cc: @ellatrix
- Done
Deprecated Nux Package and Introduce Welcome Modal
- cc: @noisysocks
- Done
Stabilize gradient theme API's
- cc: @jorgefilipecosta
- Done
Markup and Style related changes
RichText: remove wrapper (and use Popover for inline toolbar)
- cc: @ellatrix
- Done
Try: Remove/refactor complex left/right block margins
- cc: @jasmussen
- Done
Fix the snackbar notices position
- cc: @youknowriad
- Done
Lighter block DOM: remove extra div wrapper
- cc: @ellatrix
- Done
Block Editor: Remove legacy "editor-" class name compatibility
- cc: @aduth
- Done
Block: remove inner div wrapper
- cc: @ellatrix
- Done
IconButton and Button Components Changes
-
Update buttons and icons buttons size and consistency -Update buttons and icons buttons size and consistency #19058
-
Merge the Button and IconButton into a single component- Merge the Button and IconButton into a single component #19193
-
Deprecate IconButton and replace its usage with Button - Deprecate IconButton and replace its usage with Button #19299
-
Remove components-icon-button classname - Remove components-icon-button classname #19241
-
cc: @youknowriad
-
Done
Keyboard Shortcuts Package
Add a new keyboard shortcut package
- cc: @youknowriad
- Done
Developer Experience Notes
Packages: New create-block package for block scaffolding
- cc: @gziolo
- Done
Add .wp-env.json support to wp-env
- cc: @noisysocks
- Done
Activity
audrasjb commentedon Feb 12, 2020
Looks great, thanks!
Feel free to ping me on Slack if you need help/copy review or anything, as I'm in charge of WP 5.4 Documentation 😃
scruffian commentedon Feb 12, 2020
Blocks are only allowed to appear in one category in the block inserter. As a consequence many developers create a new category to add their own blocks. Block collections allow you to define an additional group of blocks to appear in the block inserter; collections are like a categories, except that blocks can have both a category and a collection. This means that blocks can now appear twice in the inserter; once in their collection and once in their most appropriate category.
aduth commentedon Feb 12, 2020
Block Editor: Remove legacy "editor-" class name compatibility
Note:
It might also be good to incorporate something here to remind about CSS classes not being part of the public API:
https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/backward-compatibility/README.md#class-names-and-dom-updates
epiqueras commentedon Feb 12, 2020
Meta attribute sources were deprecated now that the new
EntityProviderand related hooks APIs provide a more flexible and powerful way for building blocks that source data from different properties of WordPress entities and data.jorgefilipecosta commentedon Feb 12, 2020
There are several situations where multiple buttons are needed. In WordPress 5.4, a new "buttons" block is introduced. The "buttons" block is a collection of buttons; each button is represented as an individual "button" block child of the "buttons" block. The button block that existed before is not removed in fact; buttons block uses it. It will not be possible to insert a "button" block outside buttons, but all existing "button" blocks will work exactly as before.
jorgefilipecosta commentedon Feb 12, 2020
The ability to use gradients as background in some blocks (cover and buttons) in the block editor is introduced in WordPress 5.4.
In order to allow themes to have control of what gradients are available by default and to enable/disable to the ability to create custom gradients, some new theme APIs are included following the same ideas of the colors and fonts API.
Configure the predefined set of gradients
In order to configure the predefined set of gradients themes can use the theme support option
editor-gradient-presetsand pass an array representing the gradient set:More details available at https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets.
Disable custom gradients
Themes can disable the ability to set a custom gradient with the following code:
When set, users will be restricted to the default gradients provided in the block editor or the gradients provided via the
editor-gradient-presetstheme support setting.More details available at https://developer.wordpress.org/block-editor/developers/themes/theme-support/#disabling-custom-gradients.
Disable gradient functionality
Using the previous referred API's it is possible to totally disable the gradient functionality using the following two calls together:
noahtallen commentedon Feb 12, 2020
@jorgefilipecosta I would recommend not having a note for this item since it could introduce confusion between #18121 and #20002 (the latter is the one available to users).
Its implementation was superseded by "Add .wp-env.json support to wp-env" (#20002). Both accomplish the same thing (adding a configuration file to specify options for the env command), but #20002 accomplishes it in a more robust way. Any instructions for #18121 are obsolete in favor of #20002.
noisysocks commentedon Feb 13, 2020
New
GuidecomponentA new
Guidecomponent was added to the@wordpress/componentspackage (wp.components.Guide).Guideallows developers to easily create a step-by-step guide to display to users. The block editor usesGuideto implement a new welcome modal which appears on first launch.Guideis a React component that renders a user guide in a modal. The guide consists of severalGuidePagecomponents which the user can step through one by one. The guide is finished when the modal is closed or when the user clicks Finish on the last page of the guide.You can find documentation for this component on its Block Editor Handbook page.
Deprecation of
@wordpress/nuxThe
@wordpress/nuxpackage (wp.nux) has been deprecated along with theDotTipcomponent that it contained. Importing the package will display a warning in the browser console. It is recommended that plugins usingwp.nuxandDotTipmigrate toGuideinstead.noisysocks commentedon Feb 13, 2020
Support for
.wp-env.jsonFor more complex setups, the
wp-envtool in@wordpress/envnow supports.wp-env.jsonconfiguration files. You can customize the WordPress installation, plugins and themes that the development environment will use by creating a.wp-env.jsonfile in the directory that you runwp-envfrom.You can find documentation on
.wp-env.jsonin the Block Editor Handbook page for@wordpress/env.Examples
Latest production WordPress + current directory as a plugin
This is useful for plugin development.
{ "core": null, "plugins": [ "." ] }Latest development WordPress + current directory as a plugin
This is useful for plugin development when upstream Core changes need to be tested.
{ "core": "WordPress/WordPress#master", "plugins": [ "." ] }Local
wordpress-develop+ current directory as a pluginThis is useful for working on plugins and WordPress Core at the same time.
{ "core": "../wordpress-develop/build", "plugins": [ "." ] }A complete testing environment
This is useful for integration testing: that is, testing how old versions of WordPress and different combinations of plugins and themes impact each other.
{ "core": "WordPress/WordPress#5.2.0", "plugins": [ "WordPress/wp-lazy-loading", "WordPress/classic-editor", ], "themes": [ "WordPress/theme-experiments" ] }Breaking changes to
wp-envAs part of the introduction of
.wp-env.json, some backwards incompatible changes to thewp-envcommand line interface have been made:wp-env startno longer accepts a WordPress branch or tag reference as its argument. Instead, create a.wp-env.jsonfile and specify a"core"field.wp-env startwill now download WordPress into a hidden directory located in~/.wp-env. You may delete your{projectName}-wordpressand{projectName}-tests-wordpressdirectories.ellatrix commentedon Feb 13, 2020
RichText: remove wrapper (and use Popover for inline toolbar)
Lighter block DOM: remove extra div wrapper
Block: remove inner div wrapper
Note:
ellatrix commentedon Feb 13, 2020
RichText: don't set focus when applying format
Note:
ellatrix commentedon Feb 13, 2020
Drop zone: rewrite with hooks (useDropZone)
mkaz commentedon Feb 13, 2020
Social Link Block
cc: @mcsf (if you have anything to add)
gziolo commentedon Feb 14, 2020
Packages: New
@wordpress/create-blockpackage for block scaffoldingCreate Block is an officially supported way to scaffold a block for registering it with a WordPress plugin. It generates PHP, JS, CSS code, and everything else you need to start the project for your plugin. There is a quick start mode provided where you just need to provide the slug which is the target location for scaffolded files and the internal block name:
You don’t need to install or configure tools like
webpack,BabelorESLintyourself. They are preconfigured and hidden so that you can focus on the code.There is also an Interactive mode that gives a chance to customize a few most important block options before the code gets generated.
It is also possible to pick ES5 template when you don't want to deal with a modern JavaScript tooling that enables ESNext and JSX support.
3 remaining items
mcsf commentedon Feb 17, 2020
Shortcode transforms: Support
isMatchpredicateIn order to bring shortcodes in line with other types of block transformations, an optional
isMatchfunction may now be provided to determine whether a given shortcode should be transformed into a specific block.For instance, a hypothetical Antarctica Weather block is only interested in
[weather]shortcodes that concern Antarctica:If
isMatchreturns false, the shortcode won't be converted into an Antarctica Weather block. At that point, it can be picked up by another block type that matches the[weather]shortcode, or it may be preserved as a shortcode and encapsulated in a Shortcode block.gziolo commentedon Feb 19, 2020
@mcsf - I like your dev note for Social Icons a lot. It's all perfectly explained 😍
scruffian commentedon Feb 21, 2020
Block Collections:
In addition to the above, here is a code sample to get people started:
Here are some screenshots too:


mcsf commentedon Feb 21, 2020
@scruffian, any chance we could get an example with a namespace other than
core? I suspect it won't do much to convey the usefulness of collections, since it results in seemingly "all the blocks" being listed in one drawer.I understand we probably want to remain neutral and not highlight any particular provider of blocks, so maybe a collection of around three fictional blocks revolving around a theme could do the job. For instance,
acme-geography/could include a Map block, a Weather block, and a Coordinates Conversion tool. (Too contrived? 😬)mcsf commentedon Feb 21, 2020
Further, to keep the example focused, I'd look for something in Dashicons, e.g.:
mcsf commentedon Feb 24, 2020
I worry that the intents behind Block Collections may be lost in the dev notes, so I drafted this alternative:
scruffian commentedon Feb 25, 2020
How's this?


The snippet would be:
youknowriad commentedon Feb 26, 2020
AsyncModeProvider
To improve the typing performance in the editor, the BlockEditor uses an Async Rendering Mode: The selected block gets rerendered synchronously on each change while the unselected blocks are only refreshed when the browser becomes idle (not performing any task).
This behavior is made possible using the Async Mode implemented in the @wordpress/data package. WordPress 5.4 exposes the AsyncModeProvider component that allows you to implement similar behaviors in your own React state trees that rely on the data module. This component can also be used to opt-out of the block async rendering mode.
For more details about the AsyncMode, you can check this blog post.
If we are allowed to link to personal blog posts from dev notes, we could consider linking to this one here https://riad.blog/2020/02/14/a-journey-towards-a-performant-web-editor/
youknowriad commentedon Feb 26, 2020
Media Upload Block Editor Setting
The @wordpress/block-editor package can be used independently to integrate the block editor pages in custom WPAdmin Pages or any WordPress agnostic context. An example can be found on the Gutenberg Playground. In these situations, WordPress 5.4 allows you to provide a custom media upload handler as a setting to the block editor.
Omitting the mediaUpload handler from your BlockEditor instance means that your editor doesn't support media upload or that the current user doesn't have the right permissions to allow media uploads.
Media Blocks can also have access to this setting in their
editfunctions in order to support uploads.mcsf commentedon Feb 26, 2020
In AsyncModeProvider:
I recommend naming these MySyncComponent and MyAsyncComponent to make it more evident. Notice also the casing at "Async".
In Media Upload Block Editor Setting:
There's a leftover const assignment of
mediaObject.youknowriad commentedon Feb 26, 2020
Thanks :) Fixed
jorgefilipecosta commentedon Feb 27, 2020
Dev note for "Try: Remove/refactor complex left/right block margins", as provided by @jasmussen in #17877 (comment).
In 17877 a change was made to how blocks are laid out in the block editor. Previously, every block would come with padding built in, left and right, and negative margins to compensate. These margins and paddings have been refactored away. This should drastically simplify the CSS necessary to style blocks, for block developers and for WordPress themers wanting to style the editor.
The refactor may cause issues in existing block or editor styles that have compensated for the previous margins/paddings. If your block or editor style looks off, a likely fix is to remove the styles used to compensat
ellatrix commentedon Feb 28, 2020
Drop zone: rewrite with hooks (useDropZone)
jorgefilipecosta commentedon Mar 3, 2020
Closing this issue as the dev notes are published. Thank you all for this effort!