From 21831722225dc5e527a19a497146bd0cf42fba18 Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Thu, 22 Jun 2023 08:18:19 +0000 Subject: [PATCH] Editor: add text columns to typography support. Adds a text columns feature to the typography block support that uses CSS `column-count` for multi-column text. Props ramonopoly, aaronrobertshaw. Fixes #58549. Built from https://develop.svn.wordpress.org/trunk@55985 git-svn-id: http://core.svn.wordpress.org/trunk@55497 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-supports/typography.php | 10 ++++++++++ wp-includes/class-wp-theme-json.php | 7 +++++++ wp-includes/style-engine/class-wp-style-engine.php | 7 +++++++ wp-includes/version.php | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/wp-includes/block-supports/typography.php b/wp-includes/block-supports/typography.php index d90b6abb78..78c8b0a2ff 100644 --- a/wp-includes/block-supports/typography.php +++ b/wp-includes/block-supports/typography.php @@ -10,6 +10,7 @@ * Registers the style and typography block attributes for block types that support it. * * @since 5.6.0 + * @since 6.3.0 Added support for text-columns. * @access private * * @param WP_Block_Type $block_type Block Type. @@ -30,6 +31,7 @@ function wp_register_typography_support( $block_type ) { $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); + $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); @@ -39,6 +41,7 @@ function wp_register_typography_support( $block_type ) { || $has_font_weight_support || $has_letter_spacing_support || $has_line_height_support + || $has_text_columns_support || $has_text_decoration_support || $has_text_transform_support; @@ -72,6 +75,7 @@ function wp_register_typography_support( $block_type ) { * * @since 5.6.0 * @since 6.1.0 Used the style engine to generate CSS and classnames. + * @since 6.3.0 Added support for text-columns. * @access private * * @param WP_Block_Type $block_type Block type. @@ -98,6 +102,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) { $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); + $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); @@ -107,6 +112,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_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' ); $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' ); @@ -162,6 +168,10 @@ function wp_apply_typography_support( $block_type, $block_attributes ) { $typography_block_styles['lineHeight'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'lineHeight' ) ); } + if ( $has_text_columns_support && ! $should_skip_text_columns && isset( $block_attributes['style']['typography']['textColumns'] ) ) { + $typography_block_styles['textColumns'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'textColumns' ), null ); + } + if ( $has_text_decoration_support && ! $should_skip_text_decoration && diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index c157b2462c..cddb8a2821 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -201,6 +201,7 @@ class WP_Theme_JSON { * `--wp--style--root--padding-*`, and `box-shadow` properties, * removed the `--wp--style--block-gap` property. * @since 6.2.0 Added `outline-*`, and `min-height` properties. + * @since 6.3.0 Added `column-count` property. * * @var array */ @@ -228,6 +229,7 @@ class WP_Theme_JSON { 'border-left-width' => array( 'border', 'left', 'width' ), 'border-left-style' => array( 'border', 'left', 'style' ), 'color' => array( 'color', 'text' ), + 'column-count' => array( 'typography', 'textColumns' ), 'font-family' => array( 'typography', 'fontFamily' ), 'font-size' => array( 'typography', 'fontSize' ), 'font-style' => array( 'typography', 'fontStyle' ), @@ -334,6 +336,8 @@ class WP_Theme_JSON { * @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`. * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets', * `position.fixed` and `position.sticky`. + * @since 6.3.0 Added support for `typography.textColumns`. + * * @var array */ const VALID_SETTINGS = array( @@ -395,6 +399,7 @@ class WP_Theme_JSON { 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, + 'textColumns' => null, 'textDecoration' => null, 'textTransform' => null, ), @@ -411,6 +416,7 @@ class WP_Theme_JSON { * added new property `shadow`, * updated `blockGap` to be allowed at any level. * @since 6.2.0 Added `outline`, and `minHeight` properties. + * @since 6.3.0 Added support for `typography.textColumns`. * * @var array */ @@ -455,6 +461,7 @@ class WP_Theme_JSON { 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, + 'textColumns' => null, 'textDecoration' => null, 'textTransform' => null, ), diff --git a/wp-includes/style-engine/class-wp-style-engine.php b/wp-includes/style-engine/class-wp-style-engine.php index de8d00467e..3ec84aba6b 100644 --- a/wp-includes/style-engine/class-wp-style-engine.php +++ b/wp-includes/style-engine/class-wp-style-engine.php @@ -21,6 +21,7 @@ * * @access private * @since 6.1.0 + * @since 6.3.0 Added support for text-columns. */ #[AllowDynamicProperties] final class WP_Style_Engine { @@ -217,6 +218,12 @@ final class WP_Style_Engine { ), 'path' => array( 'typography', 'lineHeight' ), ), + 'textColumns' => array( + 'property_keys' => array( + 'default' => 'column-count', + ), + 'path' => array( 'typography', 'textColumns' ), + ), 'textDecoration' => array( 'property_keys' => array( 'default' => 'text-decoration', diff --git a/wp-includes/version.php b/wp-includes/version.php index 72dcd9ea43..7d8e7696dc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55984'; +$wp_version = '6.3-alpha-55985'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.