Editor: add textAlign block support.
See https://github.com/WordPress/gutenberg/pull/59531. See https://github.com/WordPress/gutenberg/pull/61182. See https://github.com/WordPress/gutenberg/pull/61717. See https://github.com/WordPress/wordpress-develop/pull/6590. Fixes #61256. Props wildworks, ellatrix. Built from https://develop.svn.wordpress.org/trunk@58314 git-svn-id: http://core.svn.wordpress.org/trunk@57771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d546ce74ab
commit
12bc7a8bcd
|
@ -31,6 +31,7 @@ function wp_register_typography_support( $block_type ) {
|
|||
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
|
||||
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
|
||||
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
|
||||
$has_text_align_support = isset( $typography_supports['textAlign'] ) ? $typography_supports['textAlign'] : false;
|
||||
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
|
||||
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
|
||||
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
|
||||
|
@ -42,6 +43,7 @@ function wp_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
|
||||
|
@ -106,6 +108,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
|
|||
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
|
||||
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
|
||||
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
|
||||
$has_text_align_support = isset( $typography_supports['textAlign'] ) ? $typography_supports['textAlign'] : false;
|
||||
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
|
||||
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
|
||||
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
|
||||
|
@ -117,6 +120,7 @@ function wp_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' );
|
||||
|
@ -176,6 +180,12 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
|
|||
: null;
|
||||
}
|
||||
|
||||
if ( $has_text_align_support && ! $should_skip_text_align ) {
|
||||
$typography_block_styles['textAlign'] = isset( $block_attributes['style']['typography']['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'] = isset( $block_attributes['style']['typography']['textColumns'] )
|
||||
? $block_attributes['style']['typography']['textColumns']
|
||||
|
@ -225,13 +235,22 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
|
|||
}
|
||||
|
||||
$attributes = array();
|
||||
$classnames = array();
|
||||
$styles = wp_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'] ) ) {
|
||||
|
|
|
@ -256,6 +256,7 @@ class WP_Theme_JSON {
|
|||
'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' ),
|
||||
|
@ -454,6 +455,7 @@ class WP_Theme_JSON {
|
|||
'fontWeight' => null,
|
||||
'letterSpacing' => null,
|
||||
'lineHeight' => null,
|
||||
'textAlign' => null,
|
||||
'textColumns' => null,
|
||||
'textDecoration' => null,
|
||||
'textTransform' => null,
|
||||
|
@ -558,6 +560,7 @@ class WP_Theme_JSON {
|
|||
'fontWeight' => null,
|
||||
'letterSpacing' => null,
|
||||
'lineHeight' => null,
|
||||
'textAlign' => null,
|
||||
'textColumns' => null,
|
||||
'textDecoration' => null,
|
||||
'textTransform' => null,
|
||||
|
|
|
@ -303,6 +303,7 @@
|
|||
"fontWeight": true,
|
||||
"letterSpacing": true,
|
||||
"lineHeight": false,
|
||||
"textAlign": true,
|
||||
"textDecoration": true,
|
||||
"textTransform": true,
|
||||
"writingMode": false
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-58313';
|
||||
$wp_version = '6.6-alpha-58314';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue