diff --git a/.eslintrc.js b/.eslintrc.js
index 5d7c6b40890510..9ac141fd09a04c 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -407,6 +407,24 @@ module.exports = {
],
},
},
+ {
+ files: [ 'packages/edit-post/**', 'packages/edit-site/**' ],
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ paths: [
+ ...restrictedImports,
+ {
+ name: '@wordpress/interface',
+ message:
+ 'The edit-post and edit-site package should not directly import the interface package. They should import them from the private APIs of the editor package instead.',
+ },
+ ],
+ },
+ ],
+ },
+ },
{
files: [ 'packages/interactivity*/src/**' ],
rules: {
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index d356c6113543ea..c90179f0e80943 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -47,7 +47,7 @@
/packages/block-editor/src/components/link-control @getdave
# Widgets
-/packages/edit-widgets @draganescu @talldan @adamziel @kevin940726
+/packages/edit-widgets @draganescu @adamziel @kevin940726
/packages/customize-widgets
/packages/widgets
diff --git a/changelog.txt b/changelog.txt
index 02864f4ea4bf25..735ee72bc9f23f 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,5 +1,19 @@
== Changelog ==
+= 18.1.1 =
+
+## Bug Fixes
+
+- Add null check to prevent errors in `get_block_template` filter ([60491](https://github.com/WordPress/gutenberg/pull/60491))
+- Fix activating a theme in site editor when previewing ([60699](https://github.com/WordPress/gutenberg/pull/60699))
+
+## Contributors
+
+The following contributors merged PRs in this release:
+
+@okmttdhr @ntsekouras
+
+
= 18.1.0 =
## Changelog
diff --git a/docs/getting-started/devenv/get-started-with-wp-scripts.md b/docs/getting-started/devenv/get-started-with-wp-scripts.md
index b6271620514df4..16f1bbc6015b5b 100644
--- a/docs/getting-started/devenv/get-started-with-wp-scripts.md
+++ b/docs/getting-started/devenv/get-started-with-wp-scripts.md
@@ -4,7 +4,7 @@ The [`@wordpress/scripts`](https://developer.wordpress.org/block-editor/referenc
A JavaScript build step refers to the process of transforming, bundling, and optimizing JavaScript source code and related assets into a format suitable for production environments. These build steps often take modern JavaScript (ESNext and JSX) and convert it to a version compatible with most browsers. They can also bundle multiple files into one, minify the code to reduce file size and perform various other tasks to optimize the code.
-You will typically be working with ESNext and JSX when building for the Block Editor, and most examples in the Block Editor Handbook are written in these syntaxes. Learning how to set up a build step is essential. However, configuring the necessary tools like [webpack](https://webpack.js.org/), [Babel](https://babeljs.io/), and [ESLint](https://eslint.org/) can become complex. This is where `wp-scripts` comes in.
+You will typically be working with ESNext and JSX when building for the Block Editor, and all examples in the Block Editor Handbook are written in these syntaxes. Learning how to set up a build step is essential. However, configuring the necessary tools like [webpack](https://webpack.js.org/), [Babel](https://babeljs.io/), and [ESLint](https://eslint.org/) can become complex. This is where `wp-scripts` comes in.
Here are a few things that `wp-scripts` can do:
diff --git a/docs/how-to-guides/platform/custom-block-editor.md b/docs/how-to-guides/platform/custom-block-editor.md
index 65f8c412c45d33..a7abb00adacec6 100644
--- a/docs/how-to-guides/platform/custom-block-editor.md
+++ b/docs/how-to-guides/platform/custom-block-editor.md
@@ -24,7 +24,7 @@ By the end of this article, you will have a solid understanding of the block edi
## Code syntax
-The code snippets in this guide use JSX syntax. However, you could use plain JavaScript if you prefer. However, once familiar with JSX, many developers find it easier to read and write, so most code examples in the Block Editor Handbook use this syntax.
+The code snippets in this guide use JSX syntax. However, you could use plain JavaScript if you prefer. However, once familiar with JSX, many developers find it easier to read and write, so all code examples in the Block Editor Handbook use this syntax.
## What you're going to be building
diff --git a/docs/how-to-guides/themes/global-settings-and-styles.md b/docs/how-to-guides/themes/global-settings-and-styles.md
index cd5557d40e55c6..37f0ee8951c3c9 100644
--- a/docs/how-to-guides/themes/global-settings-and-styles.md
+++ b/docs/how-to-guides/themes/global-settings-and-styles.md
@@ -265,6 +265,7 @@ The settings section has the following structure:
"fontWeight": true,
"letterSpacing": true,
"lineHeight": false,
+ "textAlign": true,
"textColumns": false,
"textDecoration": true,
"textTransform": true
diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md
index 935b38155f1e72..52a325ff9253de 100644
--- a/docs/reference-guides/block-api/block-attributes.md
+++ b/docs/reference-guides/block-api/block-attributes.md
@@ -375,9 +375,6 @@ Attribute definition:
From here, meta attributes can be read and written by a block using the same interface as any attribute:
-
-{% JSX %}
-
```js
edit( { attributes, setAttributes } ) {
function onChange( event ) {
diff --git a/docs/reference-guides/block-api/block-supports.md b/docs/reference-guides/block-api/block-supports.md
index 057047434eb69d..b327cd0c03a9ee 100644
--- a/docs/reference-guides/block-api/block-supports.md
+++ b/docs/reference-guides/block-api/block-supports.md
@@ -149,13 +149,13 @@ When a background image is selected, the image data is stored in the `style.back
When a background images is selected and its position or size are changed, the background-position is stored in the `style.background.backgroundPosition` and its background-size in `style.background.backgroundSize` attribute.
- `style`: an attribute of `object` type with no default assigned. This is added when `backgroundImage` or `backgroundSize` support is declared. It stores the custom values set by the user.
- - `background`: an attribute of `object` type.
- - `backgroundImage`: an attribute of `object` type, containing information about the selected image
+ - `background`: an attribute of `object` type.
+ - `backgroundImage`: an attribute of `object` type, containing information about the selected image
- `url`: type `string`, URL to the image
- `id`: type `int`, media attachment ID
- `source`: type `string`, at the moment the only value is `file`
- - `title`: type `string`, title of the media attachment
- - `backgroundPosition`: an attribute of `string` type, defining the background images position, selected by FocalPointPicker and used in CSS as the [`background-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) value.
+ - `title`: type `string`, title of the media attachment
+ - `backgroundPosition`: an attribute of `string` type, defining the background images position, selected by FocalPointPicker and used in CSS as the [`background-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) value.
- `backgroundSize`: an attribute of `string` type. defining the CSS [`background-size`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) value.
The block can apply a default background image, position and size by specifying its own attribute with a default. For example:
@@ -484,10 +484,10 @@ When the block declares support for `color.link`, the attributes definition is e
color: {
text: 'var:preset|color|contrast',
},
- ":hover": {
- color: {
- text: "#000000"
- }
+ ":hover": {
+ color: {
+ text: "#000000"
+ }
}
}
}
@@ -973,6 +973,7 @@ supports: {
- Subproperties:
- `fontSize`: type `boolean`, default value `false`
- `lineHeight`: type `boolean`, default value `false`
+ - `textAlign`: type `boolean` or `array`, default value `false`
The presence of this object signals that a block supports some typography related properties. When it does, the block editor will show a typography UI allowing the user to control their values.
@@ -983,6 +984,8 @@ supports: {
fontSize: true,
// Enable support and UI control for line-height.
lineHeight: true,
+ // Enable support and UI control for text alignment.
+ textAlign: true,
},
}
```
@@ -1063,3 +1066,47 @@ attributes: {
}
}
```
+
+### typography.textAlign
+
+_**Note:** Since WordPress 6.6._
+
+- Type: `boolean` or `array`
+- Default value: `false`
+
+This property adds block toolbar controls which allow to change block's text alignment.
+
+```js
+supports: {
+ typography: {
+ // Declare support for block's text alignment.
+ // This adds support for all the options:
+ // left, center, right.
+ textAlign: true
+ }
+}
+```
+
+```js
+supports: {
+ typography: {
+ // Declare support for specific text alignment options.
+ textAlign: [ 'left', 'right' ]
+ }
+}
+```
+
+When the block declares support for `textAlign`, the attributes definition is extended to include a new attribute `style` of `object` type with no default assigned. It stores the custom value set by the user. The block can apply a default style by specifying its own `style` attribute with a default. For example:
+
+```js
+attributes: {
+ style: {
+ type: 'object',
+ default: {
+ typography: {
+ textAlign: 'value'
+ }
+ }
+ }
+}
+```
diff --git a/docs/reference-guides/block-api/block-variations.md b/docs/reference-guides/block-api/block-variations.md
index 96930dc6b9b625..0440858810b65a 100644
--- a/docs/reference-guides/block-api/block-variations.md
+++ b/docs/reference-guides/block-api/block-variations.md
@@ -1,6 +1,6 @@
# Variations
-The Block Variations API allows you to define multiple versions (variations) of a block. A block variation differs from the original block by a set of initial attributes or inner blocks. When you insert the block variation into the Editor, these attributes and/or inner blocks are applied.
+The Block Variations API allows you to define multiple versions (variations) of a block. A block variation differs from the original block by a set of initial attributes or inner blocks. When you insert the block variation into the Editor, these attributes and/or inner blocks are applied.
Variations are an excellent way to create iterations of existing blocks without building entirely new blocks from scratch.
@@ -55,8 +55,8 @@ Block variations can be declared during a block's registration by providing the
To create a variation for an existing block, such as a Core block, use `wp.blocks.registerBlockVariation()`. This function accepts the name of the block and the object defining the variation.
```js
-wp.blocks.registerBlockVariation(
- 'core/embed',
+wp.blocks.registerBlockVariation(
+ 'core/embed',
{
name: 'custom-embed',
attributes: { providerNameSlug: 'custom' },
@@ -66,7 +66,7 @@ wp.blocks.registerBlockVariation(
## Removing a block variation
-Block variations can also be easily removed. To do so, use `wp.blocks.unregisterBlockVariation()`. This function accepts the name of the block and the `name` of the variation that should be unregistered.
+Block variations can also be easily removed. To do so, use `wp.blocks.unregisterBlockVariation()`. This function accepts the name of the block and the `name` of the variation that should be unregistered.
```js
wp.blocks.unregisterBlockVariation( 'core/embed', 'youtube' );
@@ -84,9 +84,9 @@ variations: [
name: 'blue',
title: __( 'Blue Quote' ),
isDefault: true,
- attributes: {
- color: 'blue',
- className: 'is-style-blue-quote'
+ attributes: {
+ color: 'blue',
+ className: 'is-style-blue-quote'
},
icon: 'format-quote',
isActive: ( blockAttributes, variationAttributes ) =>
@@ -99,16 +99,16 @@ variations: [
By default, all variations will show up in the Inserter in addition to the original block type item. However, setting the `isDefault` flag for any variations listed will override the regular block type in the Inserter. This is a great tool for curating the Editor experience to your specific needs.
-For example, if you want Media & Text block to display the image on the right by default, you could create a variation like this:
+For example, if you want Media & Text block to display the image on the right by default, you could create a variation like this:
```js
wp.blocks.registerBlockVariation(
- 'core/media-text',
+ 'core/media-text',
{
name: 'media-text-media-right',
title: __( 'Media & Text' ),
isDefault: true,
- attributes: {
+ attributes: {
mediaPosition: 'right'
}
}
@@ -125,20 +125,53 @@ The solution is to unregister the other variation before registering your variat
## Using `isActive`
-While the `isActive` property is optional, you will often want to use it to display information about the block variation after the block has been inserted. For example, this API is used in `useBlockDisplayInformation` hook to fetch and display proper information in places like the `BlockCard` or `Breadcrumbs` components.
+While the `isActive` property is optional, it's recommended. This API is used by the block editor to check which variation is active, and display the correct variation's title, icon and description when an instance of the variation is selected in the editor.
+
+If `isActive` is not set, the Editor cannot distinguish between an instance of the original block and your variation, so the original block information will be displayed.
+
+The property can be set to either a function or an array of strings (`string[]`).
-If `isActive` is not set, the Editor cannot distinguish between the original block and your variation, so the original block information will be displayed.
+The function version of this property accepts a block instance's `blockAttributes` as the first argument, and the `variationAttributes` declared for a variation as the second argument. These arguments can be used to determine if a variation is active by comparing them and returning a `true` or `false` (indicating whether this variation is inactive for this block instance).
-The property can use either a function or an array of strings (`string[]`). The function accepts `blockAttributes` and `variationAttributes`, which can be used to determine if a variation is active. In the Embed block, the primary differentiator is the `providerNameSlug` attribute, so if you wanted to determine if the YouTube Embed variation was active, you could do something like this:
+As an example, in the core Embed block, the `providerNameSlug` attribute is used to determine the embed provider (e.g. 'youtube' or 'twitter'). The variations may be declared like this:
+```js
+const variations = [
+ {
+ name: 'twitter',
+ title: 'Twitter',
+ icon: embedTwitterIcon,
+ keywords: [ 'tweet', __( 'social' ) ],
+ description: __( 'Embed a tweet.' ),
+ patterns: [ /^https?:\/\/(www\.)?twitter\.com\/.+/i ],
+ attributes: { providerNameSlug: 'twitter', responsive: true },
+ },
+ {
+ name: 'youtube',
+ title: 'YouTube',
+ icon: embedYouTubeIcon,
+ keywords: [ __( 'music' ), __( 'video' ) ],
+ description: __( 'Embed a YouTube video.' ),
+ patterns: [
+ /^https?:\/\/((m|www)\.)?youtube\.com\/.+/i,
+ /^https?:\/\/youtu\.be\/.+/i,
+ ],
+ attributes: { providerNameSlug: 'youtube', responsive: true },
+ },
+ // ...
+]
```
+
+ The `isActive` function can compare the block instance value for `providerNameSlug` to the value declared in the variation's declaration (the values in the code snippet above) to determine which embed variation is active:
+
+```js
isActive: ( blockAttributes, variationAttributes ) =>
blockAttributes.providerNameSlug === variationAttributes.providerNameSlug,
```
-You can also use a `string[]` to tell which attributes should be compared as a shorthand. Each attribute will be checked and the variation will be active if all of them match. Using the same example of the YouTube Embed variation, the string version would look like this:
+The `string[]` version is used to declare which attributes should be compared as a shorthand. Each attribute will be checked and the variation will be active if all of them match. Using the same example for the embed block, the string version would look like this:
-```
+```js
isActive: [ 'providerNameSlug' ]
```
@@ -175,4 +208,4 @@ wp.blocks.registerBlockVariation(
The `isActive` check on both variations tests the `textColor`, but each variations uses `vivid-red`. Since the `paragraph-red` variation is registered first, once the `paragraph-red-grey` variation is inserted into the Editor, it will have the title `Red Paragraph` instead of `Red/Grey Paragraph`. As soon as the Editor finds a match, it stops checking.
-There have been [discussions](https://github.com/WordPress/gutenberg/issues/41303#issuecomment-1526193087) around how the API can be improved, but as of WordPress 6.3, this remains an issue to watch out for.
\ No newline at end of file
+There have been [discussions](https://github.com/WordPress/gutenberg/issues/41303#issuecomment-1526193087) around how the API can be improved, but as of WordPress 6.3, this remains an issue to watch out for.
diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md
index d0eb25b807e6d7..3c8ee800d31aa4 100644
--- a/docs/reference-guides/core-blocks.md
+++ b/docs/reference-guides/core-blocks.md
@@ -860,7 +860,7 @@ Displays the name of this site. Update the block, and the changes apply everywhe
## Social Icon
-Display an icon linking to a social media profile or site. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/social-link))
+Display an icon linking to a social profile or site. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/social-link))
- **Name:** core/social-link
- **Category:** widgets
@@ -870,7 +870,7 @@ Display an icon linking to a social media profile or site. ([Source](https://git
## Social Icons
-Display icons linking to your social media profiles or sites. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/social-links))
+Display icons linking to your social profiles or sites. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/social-links))
- **Name:** core/social-links
- **Category:** widgets
diff --git a/docs/reference-guides/data/data-core-edit-site.md b/docs/reference-guides/data/data-core-edit-site.md
index a2bc9ea1bfb968..1f050ca98576a3 100644
--- a/docs/reference-guides/data/data-core-edit-site.md
+++ b/docs/reference-guides/data/data-core-edit-site.md
@@ -371,7 +371,7 @@ Resolves the template for a page and displays both. If no path is given, attempt
_Returns_
-- `number`: The resolved template ID for the page route.
+- `Object`: Action object.
### setTemplate
diff --git a/docs/reference-guides/theme-json-reference/theme-json-living.md b/docs/reference-guides/theme-json-reference/theme-json-living.md
index 00b1f7971f3d91..0377f6a3c3e05d 100644
--- a/docs/reference-guides/theme-json-reference/theme-json-living.md
+++ b/docs/reference-guides/theme-json-reference/theme-json-living.md
@@ -185,6 +185,7 @@ Settings related to typography.
| fluid | undefined | false | |
| letterSpacing | boolean | true | |
| lineHeight | boolean | false | |
+| textAlign | boolean | true | |
| textColumns | boolean | false | |
| textDecoration | boolean | true | |
| writingMode | boolean | false | |
@@ -268,6 +269,7 @@ Typography styles.
| fontWeight | string, object | |
| letterSpacing | string, object | |
| lineHeight | string, object | |
+| textAlign | string | |
| textColumns | string | |
| textDecoration | string, object | |
| writingMode | string, object | |
diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php
index 2403583c66156b..554a88b4eeec3f 100644
--- a/lib/block-supports/layout.php
+++ b/lib/block-supports/layout.php
@@ -292,32 +292,32 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
'declarations' => array( 'max-width' => 'none' ),
)
);
+ }
- if ( isset( $block_spacing ) ) {
- $block_spacing_values = gutenberg_style_engine_get_styles(
- array(
- 'spacing' => $block_spacing,
- )
- );
+ if ( isset( $block_spacing ) ) {
+ $block_spacing_values = gutenberg_style_engine_get_styles(
+ array(
+ 'spacing' => $block_spacing,
+ )
+ );
- /*
- * Handle negative margins for alignfull children of blocks with custom padding set.
- * They're added separately because padding might only be set on one side.
- */
- if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
- $padding_right = $block_spacing_values['declarations']['padding-right'];
- $layout_styles[] = array(
- 'selector' => "$selector > .alignfull",
- 'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
- );
- }
- if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
- $padding_left = $block_spacing_values['declarations']['padding-left'];
- $layout_styles[] = array(
- 'selector' => "$selector > .alignfull",
- 'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
- );
- }
+ /*
+ * Handle negative margins for alignfull children of blocks with custom padding set.
+ * They're added separately because padding might only be set on one side.
+ */
+ if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
+ $padding_right = $block_spacing_values['declarations']['padding-right'];
+ $layout_styles[] = array(
+ 'selector' => "$selector > .alignfull",
+ 'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
+ );
+ }
+ if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
+ $padding_left = $block_spacing_values['declarations']['padding-left'];
+ $layout_styles[] = array(
+ 'selector' => "$selector > .alignfull",
+ 'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
+ );
}
}
diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php
index 8fceda4d5daba0..fa2a7b81e94e21 100644
--- a/lib/block-supports/typography.php
+++ b/lib/block-supports/typography.php
@@ -26,6 +26,7 @@ function gutenberg_register_typography_support( $block_type ) {
$has_font_weight_support = $typography_supports['__experimentalFontWeight'] ?? false;
$has_letter_spacing_support = $typography_supports['__experimentalLetterSpacing'] ?? false;
$has_line_height_support = $typography_supports['lineHeight'] ?? false;
+ $has_text_align_support = $typography_supports['textAlign'] ?? false;
$has_text_columns_support = $typography_supports['textColumns'] ?? false;
$has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
$has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
@@ -37,6 +38,7 @@ function gutenberg_register_typography_support( $block_type ) {
|| $has_font_weight_support
|| $has_letter_spacing_support
|| $has_line_height_support
+ || $has_text_align_support
|| $has_text_columns_support
|| $has_text_decoration_support
|| $has_text_transform_support
@@ -95,6 +97,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
$has_font_weight_support = $typography_supports['__experimentalFontWeight'] ?? false;
$has_letter_spacing_support = $typography_supports['__experimentalLetterSpacing'] ?? false;
$has_line_height_support = $typography_supports['lineHeight'] ?? false;
+ $has_text_align_support = $typography_supports['textAlign'] ?? false;
$has_text_columns_support = $typography_supports['textColumns'] ?? false;
$has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
$has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
@@ -106,6 +109,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
$should_skip_font_style = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' );
$should_skip_font_weight = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' );
$should_skip_line_height = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' );
+ $should_skip_text_align = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textAlign' );
$should_skip_text_columns = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textColumns' );
$should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
$should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
@@ -143,6 +147,10 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
$typography_block_styles['lineHeight'] = $block_attributes['style']['typography']['lineHeight'] ?? null;
}
+ if ( $has_text_align_support && ! $should_skip_text_align ) {
+ $typography_block_styles['textAlign'] = $block_attributes['style']['typography']['textAlign'] ?? null;
+ }
+
if ( $has_text_columns_support && ! $should_skip_text_columns && isset( $block_attributes['style']['typography']['textColumns'] ) ) {
$typography_block_styles['textColumns'] = $block_attributes['style']['typography']['textColumns'] ?? null;
}
@@ -167,13 +175,22 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
}
$attributes = array();
+ $classnames = array();
$styles = gutenberg_style_engine_get_styles(
array( 'typography' => $typography_block_styles ),
array( 'convert_vars_to_classnames' => true )
);
if ( ! empty( $styles['classnames'] ) ) {
- $attributes['class'] = $styles['classnames'];
+ $classnames[] = $styles['classnames'];
+ }
+
+ if ( $has_text_align_support && ! $should_skip_text_align && isset( $block_attributes['style']['typography']['textAlign'] ) ) {
+ $classnames[] = 'has-text-align-' . $block_attributes['style']['typography']['textAlign'];
+ }
+
+ if ( ! empty( $classnames ) ) {
+ $attributes['class'] = implode( ' ', $classnames );
}
if ( ! empty( $styles['css'] ) ) {
diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php
index aafc20a2debd51..a665235d7e774e 100644
--- a/lib/class-wp-theme-json-gutenberg.php
+++ b/lib/class-wp-theme-json-gutenberg.php
@@ -244,6 +244,7 @@ class WP_Theme_JSON_Gutenberg {
'border-left-width' => array( 'border', 'left', 'width' ),
'border-left-style' => array( 'border', 'left', 'style' ),
'color' => array( 'color', 'text' ),
+ 'text-align' => array( 'typography', 'textAlign' ),
'column-count' => array( 'typography', 'textColumns' ),
'font-family' => array( 'typography', 'fontFamily' ),
'font-size' => array( 'typography', 'fontSize' ),
@@ -436,6 +437,7 @@ class WP_Theme_JSON_Gutenberg {
'fontWeight' => null,
'letterSpacing' => null,
'lineHeight' => null,
+ 'textAlign' => null,
'textColumns' => null,
'textDecoration' => null,
'textTransform' => null,
@@ -531,6 +533,7 @@ class WP_Theme_JSON_Gutenberg {
'fontWeight' => null,
'letterSpacing' => null,
'lineHeight' => null,
+ 'textAlign' => null,
'textColumns' => null,
'textDecoration' => null,
'textTransform' => null,
diff --git a/lib/global-styles-and-settings.php b/lib/global-styles-and-settings.php
index 9419ae4a716b98..70b3f7078e62ac 100644
--- a/lib/global-styles-and-settings.php
+++ b/lib/global-styles-and-settings.php
@@ -207,7 +207,7 @@ function gutenberg_get_global_styles_base_custom_css() {
*
* @since 6.6.0
*
- * @global WP_Styles $wp_styles
+ * @global WP_Styles $wp_styles
*/
function gutenberg_add_global_styles_block_custom_css() {
global $wp_styles;
@@ -247,9 +247,9 @@ function gutenberg_add_global_styles_block_custom_css() {
/**
* Adds global style rules to the inline style for each block.
*
- * @return void
- *
* @global WP_Styles $wp_styles
+ *
+ * @return void
*/
function gutenberg_add_global_styles_for_blocks() {
global $wp_styles;
diff --git a/lib/theme.json b/lib/theme.json
index 2e40ccadffef85..ece76b5f63cb29 100644
--- a/lib/theme.json
+++ b/lib/theme.json
@@ -263,6 +263,7 @@
"fontWeight": true,
"letterSpacing": true,
"lineHeight": false,
+ "textAlign": false,
"textColumns": false,
"textDecoration": true,
"textTransform": true,
diff --git a/package-lock.json b/package-lock.json
index cbe3fc949f69df..a225b5e1c111b6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "gutenberg",
- "version": "18.1.0",
+ "version": "18.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "gutenberg",
- "version": "18.1.0",
+ "version": "18.1.1",
"hasInstallScript": true,
"license": "GPL-2.0-or-later",
"dependencies": {
@@ -54088,7 +54088,6 @@
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
- "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
@@ -54141,7 +54140,6 @@
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
- "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
@@ -54243,6 +54241,7 @@
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
+ "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
@@ -69193,7 +69192,6 @@
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
- "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
@@ -69237,7 +69235,6 @@
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
- "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
@@ -69321,6 +69318,7 @@
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
+ "@wordpress/interface": "file:../interface",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
diff --git a/package.json b/package.json
index c7043fa9cc06e6..2d4fd09fd87ea1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
- "version": "18.1.0",
+ "version": "18.1.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js
index 136cdef91286e2..5c52ca62e01d69 100644
--- a/packages/block-editor/src/components/block-inspector/index.js
+++ b/packages/block-editor/src/components/block-inspector/index.js
@@ -300,7 +300,7 @@ const BlockInspectorSingleBlock = ( { clientId, blockName } ) => {