From b5ff7fdbdc7acc0c98e563fbbff70b73bf4568f4 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 17 May 2021 21:34:53 +0200 Subject: [PATCH 01/82] Client hooks: use class names for font family --- .../block-editor/src/hooks/font-family.js | 162 +++++++++++++++--- 1 file changed, 136 insertions(+), 26 deletions(-) diff --git a/packages/block-editor/src/hooks/font-family.js b/packages/block-editor/src/hooks/font-family.js index d3a13bfc87d5e..86821f965a151 100644 --- a/packages/block-editor/src/hooks/font-family.js +++ b/packages/block-editor/src/hooks/font-family.js @@ -6,34 +6,82 @@ import { find } from 'lodash'; /** * WordPress dependencies */ +import { addFilter } from '@wordpress/hooks'; import { hasBlockSupport } from '@wordpress/blocks'; +import TokenList from '@wordpress/token-list'; +import { createHigherOrderComponent } from '@wordpress/compose'; /** * Internal dependencies */ -import { cleanEmptyObject } from './utils'; import useSetting from '../components/use-setting'; import FontFamilyControl from '../components/font-family'; export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily'; -const getFontFamilyFromAttributeValue = ( fontFamilies, value ) => { - const attributeParsed = /var:preset\|font-family\|(.+)/.exec( value ); - if ( attributeParsed && attributeParsed[ 1 ] ) { - const fontFamilyObject = find( fontFamilies, ( { slug } ) => { - return slug === attributeParsed[ 1 ]; +/** + * Filters registered block settings, extending attributes to include + * the `fontFamily` attribute. + * + * @param {Object} settings Original block settings + * @return {Object} Filtered block settings + */ +function addAttributes( settings ) { + if ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) { + return settings; + } + + // Allow blocks to specify a default value if needed. + if ( ! settings.attributes.fontFamily ) { + Object.assign( settings.attributes, { + fontFamily: { + type: 'string', + }, } ); - if ( fontFamilyObject ) { - return fontFamilyObject.fontFamily; - } } - return value; -}; + + return settings; +} + +/** + * Override props assigned to save component to inject font family. + * + * @param {Object} props Additional props applied to save element + * @param {Object} blockType Block type + * @param {Object} attributes Block attributes + * @return {Object} Filtered props applied to save element + */ +function addSaveProps( props, blockType, attributes ) { + if ( ! hasBlockSupport( blockType, FONT_FAMILY_SUPPORT_KEY ) ) { + return props; + } + + if ( + hasBlockSupport( + blockType, + '__experimentalSkipTypographySerialization' + ) + ) { + return props; + } + + if ( ! attributes?.fontFamily ) { + return props; + } + + // Use TokenList to dedupe classes. + const classes = new TokenList( props.className ); + classes.add( `has-${ attributes?.fontFamily }-font-family` ); + const newClassName = classes.value; + props.className = newClassName ? newClassName : undefined; + + return props; +} export function FontFamilyEdit( { name, setAttributes, - attributes: { style = {} }, + attributes: { fontFamily }, } ) { const fontFamilies = useSetting( 'typography.fontFamilies' ); const isDisable = useIsFontFamilyDisabled( { name } ); @@ -42,26 +90,16 @@ export function FontFamilyEdit( { return null; } - const value = getFontFamilyFromAttributeValue( - fontFamilies, - style.typography?.fontFamily - ); + const value = find( fontFamilies, ( { slug } ) => fontFamily === slug ) + ?.fontFamily; function onChange( newValue ) { const predefinedFontFamily = find( fontFamilies, - ( { fontFamily } ) => fontFamily === newValue + ( { fontFamily: f } ) => f === newValue ); setAttributes( { - style: cleanEmptyObject( { - ...style, - typography: { - ...( style.typography || {} ), - fontFamily: predefinedFontFamily - ? `var:preset|font-family|${ predefinedFontFamily.slug }` - : newValue || undefined, - }, - } ), + fontFamily: predefinedFontFamily?.slug, } ); } @@ -89,3 +127,75 @@ export function useIsFontFamilyDisabled( { name } ) { ! hasBlockSupport( name, FONT_FAMILY_SUPPORT_KEY ) ); } + +/** + * Add inline styles for font families. + * Ideally, this is not needed and themes load the font-family classes on the + * editor. + * + * @param {Function} BlockListBlock Original component + * @return {Function} Wrapped component + */ +const withFontFamilyInlineStyles = createHigherOrderComponent( + ( BlockListBlock ) => ( props ) => { + const fontFamilies = useSetting( 'typography.fontFamilies' ); + const { + name: blockName, + attributes: { fontFamily, style }, + wrapperProps, + } = props; + + // Only add inline styles if the block supports font families, + // doesn't skip serialization of font families, + // doesn't already have an inline font family, + // and does have a class to extract the font family from. + if ( + ! hasBlockSupport( blockName, FONT_FAMILY_SUPPORT_KEY ) || + hasBlockSupport( + blockName, + '__experimentalSkipTypographySerialization' + ) || + ! fontFamily || + style?.typography?.fontFamily + ) { + return ; + } + + const fontFamilyValue = find( + fontFamilies, + ( { slug } ) => slug === fontFamily + )?.fontFamily; + + const newProps = { + ...props, + wrapperProps: { + ...wrapperProps, + style: { + fontFamily: fontFamilyValue, + ...wrapperProps?.style, + }, + }, + }; + + return ; + }, + 'withFontFamilyInlineStyles' +); + +addFilter( + 'blocks.registerBlockType', + 'core/font/addAttribute', + addAttributes +); + +addFilter( + 'blocks.getSaveContent.extraProps', + 'core/fontFamily/addSaveProps', + addSaveProps +); + +addFilter( + 'editor.BlockListBlock', + 'core/font-family/with-font-family-inline-styles', + withFontFamilyInlineStyles +); From c62fd9d940552ea27391290d96e5de21110652c1 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 2 Jul 2021 13:01:45 +0200 Subject: [PATCH 02/82] Server supports: use class --- lib/block-supports/typography.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 1086e04bcd9dd..816d787912c3b 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -105,17 +105,22 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { } if ( $has_font_family_support ) { - $has_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); - if ( $has_font_family ) { + $has_named_font_family = array_key_exists( 'fontFamily', $block_attributes ); + $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); + + if ( $has_named_font_family ) { + $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); + } elseif ( $has_custom_font_family ) { $font_family = $block_attributes['style']['typography']['fontFamily']; - if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) { - // Get the name from the string and add proper styles. + if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) { // Legacy. $index_to_splice = strrpos( $font_family, '|' ) + 1; $font_family_name = substr( $font_family, $index_to_splice ); - $styles[] = sprintf( 'font-family: var(--wp--preset--font-family--%s);', $font_family_name ); + $styles[] = sprintf( 'font-family: var(--wp--preset--font-family--%s) !important;', $font_family_name ); } else { - $styles[] = sprintf( 'font-family: %s;', $block_attributes['style']['typography']['fontFamily'] ); + $styles[] = sprintf( 'font-family: %s;', $font_family ); } + } elseif ( isset( $block_attributes['fontFamily'] ) ) { // Current attribute style. + $styles[] = sprintf( 'font-family: %s;', $block_attributes['fontFamily'] ); } } From 64013f14093ab925e91ad48939cfaba5ba82bf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 13:10:38 +0200 Subject: [PATCH 03/82] theme.json: enqueue classes for font-family --- lib/class-wp-theme-json-gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 0e71a791beb0f..6af3d01cf6b58 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -205,7 +205,7 @@ class WP_Theme_JSON_Gutenberg { 'path' => array( 'typography', 'fontFamilies' ), 'value_key' => 'fontFamily', 'css_vars' => '--wp--preset--font-family--$slug', - 'classes' => array(), + 'classes' => array( '.has-$slug-font-family' => 'font-family' ), 'properties' => array( 'font-family' ), ), ); From 274bdd87c2a41963f44c422c9dcc4427b43c5fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 13:34:04 +0200 Subject: [PATCH 04/82] Remove unnecessary code path --- lib/block-supports/typography.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 816d787912c3b..c2aa2e5ab1e04 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -106,21 +106,17 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { if ( $has_font_family_support ) { $has_named_font_family = array_key_exists( 'fontFamily', $block_attributes ); - $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); + $has_legacy_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); if ( $has_named_font_family ) { $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); - } elseif ( $has_custom_font_family ) { + } elseif ( $has_legacy_font_family ) { $font_family = $block_attributes['style']['typography']['fontFamily']; - if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) { // Legacy. + if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) { $index_to_splice = strrpos( $font_family, '|' ) + 1; $font_family_name = substr( $font_family, $index_to_splice ); $styles[] = sprintf( 'font-family: var(--wp--preset--font-family--%s) !important;', $font_family_name ); - } else { - $styles[] = sprintf( 'font-family: %s;', $font_family ); } - } elseif ( isset( $block_attributes['fontFamily'] ) ) { // Current attribute style. - $styles[] = sprintf( 'font-family: %s;', $block_attributes['fontFamily'] ); } } From 13c52a5c991bd5b40f86eb0e5087aa2de72a8a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 14:29:04 +0200 Subject: [PATCH 05/82] Do not use inline styles We don't want to serialize font-family to inline styles. We did so for other presets (font-size, color) because themes forgot to add the corresponding classes. --- .../block-editor/src/hooks/font-family.js | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/packages/block-editor/src/hooks/font-family.js b/packages/block-editor/src/hooks/font-family.js index 86821f965a151..b32d7036436dc 100644 --- a/packages/block-editor/src/hooks/font-family.js +++ b/packages/block-editor/src/hooks/font-family.js @@ -9,7 +9,6 @@ import { find } from 'lodash'; import { addFilter } from '@wordpress/hooks'; import { hasBlockSupport } from '@wordpress/blocks'; import TokenList from '@wordpress/token-list'; -import { createHigherOrderComponent } from '@wordpress/compose'; /** * Internal dependencies @@ -128,60 +127,6 @@ export function useIsFontFamilyDisabled( { name } ) { ); } -/** - * Add inline styles for font families. - * Ideally, this is not needed and themes load the font-family classes on the - * editor. - * - * @param {Function} BlockListBlock Original component - * @return {Function} Wrapped component - */ -const withFontFamilyInlineStyles = createHigherOrderComponent( - ( BlockListBlock ) => ( props ) => { - const fontFamilies = useSetting( 'typography.fontFamilies' ); - const { - name: blockName, - attributes: { fontFamily, style }, - wrapperProps, - } = props; - - // Only add inline styles if the block supports font families, - // doesn't skip serialization of font families, - // doesn't already have an inline font family, - // and does have a class to extract the font family from. - if ( - ! hasBlockSupport( blockName, FONT_FAMILY_SUPPORT_KEY ) || - hasBlockSupport( - blockName, - '__experimentalSkipTypographySerialization' - ) || - ! fontFamily || - style?.typography?.fontFamily - ) { - return ; - } - - const fontFamilyValue = find( - fontFamilies, - ( { slug } ) => slug === fontFamily - )?.fontFamily; - - const newProps = { - ...props, - wrapperProps: { - ...wrapperProps, - style: { - fontFamily: fontFamilyValue, - ...wrapperProps?.style, - }, - }, - }; - - return ; - }, - 'withFontFamilyInlineStyles' -); - addFilter( 'blocks.registerBlockType', 'core/font/addAttribute', @@ -193,9 +138,3 @@ addFilter( 'core/fontFamily/addSaveProps', addSaveProps ); - -addFilter( - 'editor.BlockListBlock', - 'core/font-family/with-font-family-inline-styles', - withFontFamilyInlineStyles -); From 07dea1d88ba0ff24c66e2b26c24d5729d01f39f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Fri, 2 Jul 2021 14:39:01 +0200 Subject: [PATCH 06/82] Add class name in edit --- .../block-editor/src/hooks/font-family.js | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/hooks/font-family.js b/packages/block-editor/src/hooks/font-family.js index b32d7036436dc..769e424e54091 100644 --- a/packages/block-editor/src/hooks/font-family.js +++ b/packages/block-editor/src/hooks/font-family.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { find } from 'lodash'; +import { find, kebabCase } from 'lodash'; /** * WordPress dependencies @@ -70,13 +70,38 @@ function addSaveProps( props, blockType, attributes ) { // Use TokenList to dedupe classes. const classes = new TokenList( props.className ); - classes.add( `has-${ attributes?.fontFamily }-font-family` ); + classes.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` ); const newClassName = classes.value; props.className = newClassName ? newClassName : undefined; return props; } +/** + * Filters registered block settings to expand the block edit wrapper + * by applying the desired styles and classnames. + * + * @param {Object} settings Original block settings. + * + * @return {Object} Filtered block settings. + */ +function addEditProps( settings ) { + if ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) { + return settings; + } + + const existingGetEditWrapperProps = settings.getEditWrapperProps; + settings.getEditWrapperProps = ( attributes ) => { + let props = {}; + if ( existingGetEditWrapperProps ) { + props = existingGetEditWrapperProps( attributes ); + } + return addSaveProps( props, settings, attributes ); + }; + + return settings; +} + export function FontFamilyEdit( { name, setAttributes, @@ -129,7 +154,7 @@ export function useIsFontFamilyDisabled( { name } ) { addFilter( 'blocks.registerBlockType', - 'core/font/addAttribute', + 'core/fontFamily/addAttribute', addAttributes ); @@ -138,3 +163,9 @@ addFilter( 'core/fontFamily/addSaveProps', addSaveProps ); + +addFilter( + 'blocks.registerBlockType', + 'core/fontFamily/addEditProps', + addEditProps +); From ccee841700b272845bf773170e8f3c1730add893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Mon, 5 Jul 2021 14:13:54 +0200 Subject: [PATCH 07/82] Support custom font families There may be cases in which patterns add their own font-families without being slugs for us to process. --- lib/block-supports/typography.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index c2aa2e5ab1e04..9092ea8e6138f 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -106,16 +106,20 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { if ( $has_font_family_support ) { $has_named_font_family = array_key_exists( 'fontFamily', $block_attributes ); - $has_legacy_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); - + $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); + if ( $has_named_font_family ) { $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); - } elseif ( $has_legacy_font_family ) { - $font_family = $block_attributes['style']['typography']['fontFamily']; - if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) { - $index_to_splice = strrpos( $font_family, '|' ) + 1; - $font_family_name = substr( $font_family, $index_to_splice ); - $styles[] = sprintf( 'font-family: var(--wp--preset--font-family--%s) !important;', $font_family_name ); + } elseif ( $has_custom_font_family ) { + // Before using classes, the value was serialized as a CSS Custom Property. + // We don't need this code path it lands in core. + $font_family_custom = $block_attributes['style']['typography']['fontFamily']; + if ( strpos( $font_family_custom, 'var:preset|font-family' ) !== false ) { + $index_to_splice = strrpos( $font_family_custom, '|' ) + 1; + $font_family_slug = substr( $font_family_custom, $index_to_splice ); + $classes[] = sprintf( 'has-%s-font-family', $font_family_slug ); + } else { + $styles[] = sprintf( 'font-family: %s;', $font_family_custom ); } } } From f3f207d13c6097f2159a750b40a9c850ebee28dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 23 Sep 2021 10:53:28 +0200 Subject: [PATCH 08/82] Update tests --- lib/block-supports/typography.php | 2 +- phpunit/class-wp-theme-json-schema-v0-test.php | 4 ++-- phpunit/class-wp-theme-json-test.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 9092ea8e6138f..8d9539453e213 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -107,7 +107,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { if ( $has_font_family_support ) { $has_named_font_family = array_key_exists( 'fontFamily', $block_attributes ); $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); - + if ( $has_named_font_family ) { $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); } elseif ( $has_custom_font_family ) { diff --git a/phpunit/class-wp-theme-json-schema-v0-test.php b/phpunit/class-wp-theme-json-schema-v0-test.php index 8a682bd8fd493..9db6a90b623d6 100644 --- a/phpunit/class-wp-theme-json-schema-v0-test.php +++ b/phpunit/class-wp-theme-json-schema-v0-test.php @@ -471,11 +471,11 @@ function test_get_stylesheet() { ); $this->assertEquals( - 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet() ); $this->assertEquals( - 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}', + 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet( 'block_styles' ) ); $this->assertEquals( diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 113ff4fd3cdc0..bacbb702de503 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -413,11 +413,11 @@ function test_get_stylesheet() { ); $this->assertEquals( - 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet() ); $this->assertEquals( - 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}', + 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet( 'block_styles' ) ); $this->assertEquals( From 818333a2380fca475d34952907001bbb1b1b9263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 23 Sep 2021 13:30:39 +0200 Subject: [PATCH 09/82] Add deprecation for the button block --- .../block-library/src/button/deprecated.js | 184 +++++++++++++++++- 1 file changed, 183 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 1c56218245a27..4319975f32f10 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { omit } from 'lodash'; +import { isEmpty, isObject, identity, mapValues, omit, pickBy } from 'lodash'; import classnames from 'classnames'; /** @@ -12,10 +12,29 @@ import { getColorClassName, useBlockProps, __experimentalGetGradientClass, + __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles, + __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles, } from '@wordpress/block-editor'; import { compose } from '@wordpress/compose'; +/** + * Removed empty nodes from nested objects. + * + * @param {Object} object + * @return {Object} Object cleaned from empty nodes. + */ +export const cleanEmptyObject = ( object ) => { + if ( ! isObject( object ) || Array.isArray( object ) ) { + return object; + } + const cleanedNestedObjects = pickBy( + mapValues( object, cleanEmptyObject ), + identity + ); + return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects; +}; + const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; // We have to check old property `borderRadius` and if @@ -73,6 +92,31 @@ const migrateCustomColorsAndGradients = ( attributes ) => { }; }; +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + const oldColorsMigration = ( attributes ) => { return migrateCustomColorsAndGradients( omit( @@ -841,6 +885,144 @@ const deprecated = [ }, migrate: oldColorsMigration, }, + { + attributes: { + url: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'href', + }, + title: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'title', + }, + text: { + type: 'string', + source: 'html', + selector: 'a', + }, + linkTarget: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'target', + }, + rel: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'rel', + }, + placeholder: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + textColor: { + type: 'string', + }, + gradient: { + type: 'string', + }, + width: { + type: 'number', + }, + }, + supports: { + anchor: true, + align: true, + alignWide: false, + color: { + __experimentalSkipSerialization: true, + gradients: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + reusable: false, + spacing: { + __experimentalSkipSerialization: true, + padding: [ 'horizontal', 'vertical' ], + __experimentalDefaultControls: { + padding: true, + }, + }, + __experimentalBorder: { + radius: true, + __experimentalSkipSerialization: true, + }, + __experimentalSelector: '.wp-block-button__link', + }, + save( { attributes, className } ) { + const { + fontSize, + linkTarget, + rel, + style, + text, + title, + url, + width, + } = attributes; + + if ( ! text ) { + return null; + } + + const borderProps = getBorderClassesAndStyles( attributes ); + const colorProps = getColorClassesAndStyles( attributes ); + const spacingProps = getSpacingClassesAndStyles( attributes ); + const buttonClasses = classnames( + 'wp-block-button__link', + colorProps.className, + borderProps.className, + { + // For backwards compatibility add style that isn't provided via + // block support. + 'no-border-radius': style?.border?.radius === 0, + } + ); + const buttonStyle = { + ...borderProps.style, + ...colorProps.style, + ...spacingProps.style, + }; + + // The use of a `title` attribute here is soft-deprecated, but still applied + // if it had already been assigned, for the sake of backward-compatibility. + // A title will no longer be assigned for new or updated button block links. + + const wrapperClasses = classnames( className, { + [ `has-custom-width wp-block-button__width-${ width }` ]: width, + [ `has-custom-font-size` ]: + fontSize || style?.typography?.fontSize, + } ); + + return ( +
+ +
+ ); + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, ]; export default deprecated; From 68d1c75b132861305e1b5a5b81145a587536f07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 23 Sep 2021 17:45:35 +0200 Subject: [PATCH 10/82] clean empty object extracted to utils --- .../block-library/src/button/deprecated.js | 18 +++------------ .../src/utils/clean-empty-object.js | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 packages/block-library/src/utils/clean-empty-object.js diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 4319975f32f10..b36063ea896bf 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { isEmpty, isObject, identity, mapValues, omit, pickBy } from 'lodash'; +import { omit } from 'lodash'; import classnames from 'classnames'; /** @@ -19,21 +19,9 @@ import { import { compose } from '@wordpress/compose'; /** - * Removed empty nodes from nested objects. - * - * @param {Object} object - * @return {Object} Object cleaned from empty nodes. + * Internal dependencies */ -export const cleanEmptyObject = ( object ) => { - if ( ! isObject( object ) || Array.isArray( object ) ) { - return object; - } - const cleanedNestedObjects = pickBy( - mapValues( object, cleanEmptyObject ), - identity - ); - return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects; -}; +import cleanEmptyObject from '../utils/clean-empty-object'; const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; diff --git a/packages/block-library/src/utils/clean-empty-object.js b/packages/block-library/src/utils/clean-empty-object.js new file mode 100644 index 0000000000000..87ef83a643a21 --- /dev/null +++ b/packages/block-library/src/utils/clean-empty-object.js @@ -0,0 +1,23 @@ +/** + * External dependencies + */ +import { isEmpty, isObject, identity, mapValues, pickBy } from 'lodash'; + +/** + * Removed empty nodes from nested objects. + * + * @param {Object} object + * @return {Object} Object cleaned from empty nodes. + */ +const cleanEmptyObject = ( object ) => { + if ( ! isObject( object ) || Array.isArray( object ) ) { + return object; + } + const cleanedNestedObjects = pickBy( + mapValues( object, cleanEmptyObject ), + identity + ); + return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects; +}; + +export default cleanEmptyObject; From 11fd19dfa685c7838a7c9f6151acbea96b89ddca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 23 Sep 2021 17:49:04 +0200 Subject: [PATCH 11/82] Add deprecation for the list block --- packages/block-library/src/list/deprecated.js | 97 +++++++++++++++++++ packages/block-library/src/list/index.js | 2 + 2 files changed, 99 insertions(+) create mode 100644 packages/block-library/src/list/deprecated.js diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js new file mode 100644 index 0000000000000..3aa4eb4560159 --- /dev/null +++ b/packages/block-library/src/list/deprecated.js @@ -0,0 +1,97 @@ +/** + * WordPress dependencies + */ +import { RichText, useBlockProps } from '@wordpress/block-editor'; + +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + +const deprecated = [ + { + attributes: { + ordered: { + type: 'boolean', + default: false, + __experimentalRole: 'content', + }, + values: { + type: 'string', + source: 'html', + selector: 'ol,ul', + multiline: 'li', + __unstableMultilineWrapperTags: [ 'ol', 'ul' ], + default: '', + __experimentalRole: 'content', + }, + type: { + type: 'string', + }, + start: { + type: 'number', + }, + reversed: { + type: 'boolean', + }, + placeholder: { + type: 'string', + }, + }, + supports: { + anchor: true, + className: false, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + color: { + gradients: true, + link: true, + }, + __unstablePasteTextInline: true, + __experimentalSelector: 'ol,ul', + }, + save( { attributes } ) { + const { ordered, values, type, reversed, start } = attributes; + const TagName = ordered ? 'ol' : 'ul'; + + return ( + + + + ); + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/list/index.js b/packages/block-library/src/list/index.js index b2d1f5300feb8..8b3e31e7cf54c 100644 --- a/packages/block-library/src/list/index.js +++ b/packages/block-library/src/list/index.js @@ -6,6 +6,7 @@ import { list as icon } from '@wordpress/icons'; /** * Internal dependencies */ +import deprecated from './deprecated'; import edit from './edit'; import metadata from './block.json'; import save from './save'; @@ -38,4 +39,5 @@ export const settings = { }, edit, save, + deprecated, }; From 2b58a2015a28708907ea566911244330644d9f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 10:04:12 +0200 Subject: [PATCH 12/82] Add deprecation for the post title block --- .../src/post-title/deprecated.js | 80 +++++++++++++++++++ .../block-library/src/post-title/index.js | 2 + 2 files changed, 82 insertions(+) create mode 100644 packages/block-library/src/post-title/deprecated.js diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js new file mode 100644 index 0000000000000..6cf3f3f44fec4 --- /dev/null +++ b/packages/block-library/src/post-title/deprecated.js @@ -0,0 +1,80 @@ +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + +const deprecated = [ + { + attributes: { + textAlign: { + type: 'string', + }, + level: { + type: 'number', + default: 2, + }, + isLink: { + type: 'boolean', + default: false, + }, + rel: { + type: 'string', + attribute: 'rel', + default: '', + }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + }, + }, + save() { + return null; + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, +]; +export default deprecated; diff --git a/packages/block-library/src/post-title/index.js b/packages/block-library/src/post-title/index.js index 4f1dcdfc4f3a3..a947bf91250cb 100644 --- a/packages/block-library/src/post-title/index.js +++ b/packages/block-library/src/post-title/index.js @@ -8,6 +8,7 @@ import { postTitle as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -15,4 +16,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; From 0b745b9536eacb7dd2e80ad8f9614f222f47a325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:33:19 +0200 Subject: [PATCH 13/82] Add deprecation for the post title block --- .../src/site-title/deprecated.js | 81 +++++++++++++++++++ .../block-library/src/site-title/index.js | 2 + 2 files changed, 83 insertions(+) create mode 100644 packages/block-library/src/site-title/deprecated.js diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js new file mode 100644 index 0000000000000..fc403fbae7b77 --- /dev/null +++ b/packages/block-library/src/site-title/deprecated.js @@ -0,0 +1,81 @@ +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + +const deprecated = [ + { + attributes: { + textAlign: { + type: 'string', + }, + level: { + type: 'number', + default: 2, + }, + isLink: { + type: 'boolean', + default: false, + }, + rel: { + type: 'string', + attribute: 'rel', + default: '', + }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + }, + }, + save() { + return null; + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/site-title/index.js b/packages/block-library/src/site-title/index.js index c425e41c5100a..d2b155ebcc8f3 100644 --- a/packages/block-library/src/site-title/index.js +++ b/packages/block-library/src/site-title/index.js @@ -8,6 +8,7 @@ import { mapMarker as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -15,4 +16,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; From 84c22f207b4f789c507800a156beb1c8cf432599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:34:53 +0200 Subject: [PATCH 14/82] fixup site-title --- .../src/site-title/deprecated.js | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index fc403fbae7b77..30b60d717d521 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -31,25 +31,12 @@ const oldFontFamilyMigration = ( attributes ) => { const deprecated = [ { attributes: { - textAlign: { - type: 'string', - }, level: { type: 'number', - default: 2, - }, - isLink: { - type: 'boolean', - default: false, - }, - rel: { - type: 'string', - attribute: 'rel', - default: '', + default: 1, }, - linkTarget: { + textAlign: { type: 'string', - default: '_self', }, }, supports: { @@ -57,15 +44,21 @@ const deprecated = [ html: false, color: { gradients: true, + text: false, link: true, }, + spacing: { + padding: true, + margin: true, + }, typography: { fontSize: true, lineHeight: true, __experimentalFontFamily: true, - __experimentalFontWeight: true, - __experimentalFontStyle: true, __experimentalTextTransform: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalLetterSpacing: true, }, }, save() { From 082e10c0154cd2f4357f16e0fde2be22e379d6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:40:42 +0200 Subject: [PATCH 15/82] Add deprecation for the verse block --- .../block-library/src/verse/deprecated.js | 83 ++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index f26ac103c226b..d1f78717fa4e2 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -1,7 +1,42 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ -import { RichText } from '@wordpress/block-editor'; +import { RichText, useBlockProps } from '@wordpress/block-editor'; + +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; const blockAttributes = { content: { @@ -30,6 +65,52 @@ const deprecated = [ ); }, }, + { + attributes: { + content: { + type: 'string', + source: 'html', + selector: 'pre', + default: '', + __unstablePreserveWhiteSpace: true, + __experimentalRole: 'content', + }, + textAlign: { + type: 'string', + }, + }, + supports: { + anchor: true, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + spacing: { + padding: true, + }, + }, + save( { attributes } ) { + const { textAlign, content } = attributes; + + const className = classnames( { + [ `has-text-align-${ textAlign }` ]: textAlign, + } ); + + return ( +
+					
+				
+ ); + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, ]; export default deprecated; From 07ec4bc0879b7c96ee9e635bbad492fee401732c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:40:56 +0200 Subject: [PATCH 16/82] Add deprecation for the site-tagline block --- .../src/site-tagline/deprecated.js | 66 +++++++++++++++++++ .../block-library/src/site-tagline/index.js | 2 + 2 files changed, 68 insertions(+) create mode 100644 packages/block-library/src/site-tagline/deprecated.js diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js new file mode 100644 index 0000000000000..374e135bdea1d --- /dev/null +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -0,0 +1,66 @@ +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + +const deprecated = [ + { + attributes: { + textAlign: { + type: 'string', + }, + }, + supports: { + html: false, + color: { + gradients: true, + }, + spacing: { + margin: true, + padding: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalTextTransform: true, + __experimentalLetterSpacing: true, + }, + }, + save() { + return null; + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/site-tagline/index.js b/packages/block-library/src/site-tagline/index.js index d3c19ddabf111..89477ca98f643 100644 --- a/packages/block-library/src/site-tagline/index.js +++ b/packages/block-library/src/site-tagline/index.js @@ -4,6 +4,7 @@ import metadata from './block.json'; import edit from './edit'; import icon from './icon'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -11,4 +12,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; From 4cc026357375d74157452c06aab425524c3a6b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:52:02 +0200 Subject: [PATCH 17/82] Add deprecation for the navigation block --- .../src/navigation/deprecated.js | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index f41acc381bda6..5ce82a38d4f69 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -8,6 +8,36 @@ import { mapValues, omit } from 'lodash'; */ import { InnerBlocks } from '@wordpress/block-editor'; +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { fontStyle: 'var:preset|font-style|', fontWeight: 'var:preset|font-weight|', @@ -247,6 +277,84 @@ const deprecated = [ return ; }, }, + { + attributes: { + orientation: { + type: 'string', + default: 'horizontal', + }, + textColor: { + type: 'string', + }, + customTextColor: { + type: 'string', + }, + rgbTextColor: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + customBackgroundColor: { + type: 'string', + }, + rgbBackgroundColor: { + type: 'string', + }, + itemsJustification: { + type: 'string', + }, + showSubmenuIcon: { + type: 'boolean', + default: true, + }, + openSubmenusOnClick: { + type: 'boolean', + default: false, + }, + isResponsive: { + type: 'boolean', + default: false, + }, + __unstableLocation: { + type: 'string', + }, + overlayBackgroundColor: { + type: 'string', + }, + customOverlayBackgroundColor: { + type: 'string', + }, + overlayTextColor: { + type: 'string', + }, + customOverlayTextColor: { + type: 'string', + }, + }, + supports: { + align: [ 'wide', 'full' ], + anchor: true, + html: false, + inserter: true, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalTextTransform: true, + __experimentalFontFamily: true, + __experimentalTextDecoration: true, + }, + }, + save() { + return ; + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, ]; export default deprecated; From 67e6f1702dbe3348e17e72292a346b06eb0569cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:52:14 +0200 Subject: [PATCH 18/82] Add deprecation for the query-title block --- .../src/query-title/deprecated.js | 67 +++++++++++++++++++ .../block-library/src/query-title/index.js | 2 + 2 files changed, 69 insertions(+) create mode 100644 packages/block-library/src/query-title/deprecated.js diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js new file mode 100644 index 0000000000000..52e71aa673fdf --- /dev/null +++ b/packages/block-library/src/query-title/deprecated.js @@ -0,0 +1,67 @@ +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +const oldFontFamilyMigration = ( attributes ) => { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +}; + +const deprecated = [ + { + attributes: { + type: { + type: 'string', + }, + textAlign: { + type: 'string', + }, + level: { + type: 'number', + default: 1, + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + }, + }, + save() { + return null; + }, + migrate: oldFontFamilyMigration, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/query-title/index.js b/packages/block-library/src/query-title/index.js index 5f564739f69d0..0b8fcd2798788 100644 --- a/packages/block-library/src/query-title/index.js +++ b/packages/block-library/src/query-title/index.js @@ -4,6 +4,7 @@ import metadata from './block.json'; import edit from './edit'; import variations from './variations'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -11,4 +12,5 @@ export { metadata, name }; export const settings = { edit, variations, + deprecated, }; From 230c70c71d9f2fedf8d4aeb09545ea1051f1afc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 24 Sep 2021 15:01:25 +0200 Subject: [PATCH 19/82] Update lib/block-supports/typography.php --- lib/block-supports/typography.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 8d9539453e213..60f343a5d2c31 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -112,7 +112,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); } elseif ( $has_custom_font_family ) { // Before using classes, the value was serialized as a CSS Custom Property. - // We don't need this code path it lands in core. + // We don't need this code path when it lands in core. $font_family_custom = $block_attributes['style']['typography']['fontFamily']; if ( strpos( $font_family_custom, 'var:preset|font-family' ) !== false ) { $index_to_splice = strrpos( $font_family_custom, '|' ) + 1; From a6b63f5a09b183080d4e494f01053021d1a46322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 8 Oct 2021 09:51:15 +0200 Subject: [PATCH 20/82] Update test after rebase --- phpunit/class-wp-theme-json-schema-v0-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-wp-theme-json-schema-v0-test.php b/phpunit/class-wp-theme-json-schema-v0-test.php index 9db6a90b623d6..9815644188343 100644 --- a/phpunit/class-wp-theme-json-schema-v0-test.php +++ b/phpunit/class-wp-theme-json-schema-v0-test.php @@ -471,7 +471,7 @@ function test_get_stylesheet() { ); $this->assertEquals( - 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }a{color: #111;}h1{font-size: 1em;}h2{font-size: 2em;}.wp-block-group{padding-top: 12px;padding-bottom: 24px;}.wp-block-group a{color: #333;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: #222;}.wp-block-post-title{font-size: 5em;}.wp-block-post-title a{color: #555;}.wp-block-query-title{font-size: 5em;}.wp-block-query-title a{color: #555;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet() ); $this->assertEquals( From bc70e9fbd2946e4f428d9c20aae93ff80d4e6ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 8 Oct 2021 10:00:20 +0200 Subject: [PATCH 21/82] Update test after rebase --- phpunit/class-wp-theme-json-test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index bacbb702de503..c51966217fd2a 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -413,11 +413,11 @@ function test_get_stylesheet() { ); $this->assertEquals( - 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', + 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet() ); $this->assertEquals( - 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', + 'body{color: var(--wp--preset--color--grey);}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}', $theme_json->get_stylesheet( 'block_styles' ) ); $this->assertEquals( From d5c8ba0d01b34a3a285439506346056d8bf9b698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:08:30 +0200 Subject: [PATCH 22/82] Extract font family migration to file --- .../block-library/src/button/deprecated.js | 27 +---------------- packages/block-library/src/list/deprecated.js | 27 +---------------- .../src/navigation/deprecated.js | 27 +---------------- .../src/post-title/deprecated.js | 27 +---------------- .../src/query-title/deprecated.js | 27 +---------------- .../src/site-tagline/deprecated.js | 27 +---------------- .../src/site-title/deprecated.js | 27 +---------------- .../src/utils/old-font-family-migration.js | 29 +++++++++++++++++++ .../block-library/src/verse/deprecated.js | 27 +---------------- 9 files changed, 37 insertions(+), 208 deletions(-) create mode 100644 packages/block-library/src/utils/old-font-family-migration.js diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index b36063ea896bf..9396cdc9ac708 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -21,7 +21,7 @@ import { compose } from '@wordpress/compose'; /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; @@ -80,31 +80,6 @@ const migrateCustomColorsAndGradients = ( attributes ) => { }; }; -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; - const oldColorsMigration = ( attributes ) => { return migrateCustomColorsAndGradients( omit( diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index 3aa4eb4560159..444ab3a623c12 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -6,32 +6,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const deprecated = [ { diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index 5ce82a38d4f69..0362489bf111b 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -11,32 +11,7 @@ import { InnerBlocks } from '@wordpress/block-editor'; /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { fontStyle: 'var:preset|font-style|', diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 6cf3f3f44fec4..679e4e7c748ef 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -1,32 +1,7 @@ /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const deprecated = [ { diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 52e71aa673fdf..78c23d44d0499 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -1,32 +1,7 @@ /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const deprecated = [ { diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index 374e135bdea1d..cf83e7f614024 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -1,32 +1,7 @@ /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const deprecated = [ { diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index 30b60d717d521..3156db370109a 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -1,32 +1,7 @@ /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const deprecated = [ { diff --git a/packages/block-library/src/utils/old-font-family-migration.js b/packages/block-library/src/utils/old-font-family-migration.js new file mode 100644 index 0000000000000..e629b9b5e11b5 --- /dev/null +++ b/packages/block-library/src/utils/old-font-family-migration.js @@ -0,0 +1,29 @@ +/** + * Internal dependencies + */ +import cleanEmptyObject from '../utils/clean-empty-object'; + +/** + * Migrates the current style.typography.fontFamily attribute, + * whose value was "var:preset|font-family|helvetica-arial", + * to the style.fontFamily attribute, whose value will be "helvetica-arial". + * + * @param {Object} attributes The current attributes + * @return {Object} The updated attributes. + */ +export default function ( attributes ) { + if ( ! attributes?.style?.typography?.fontFamily ) { + return attributes; + } + + const fontFamily = attributes.style.typography.fontFamily + .split( '|' ) + .pop(); + delete attributes.style.typography.fontFamily; + attributes.style = cleanEmptyObject( attributes.style ); + + return { + ...attributes, + fontFamily, + }; +} diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index d1f78717fa4e2..549f7fee52d77 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -11,32 +11,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; - -/** - * Migrates the current style.typography.fontFamily attribute, - * whose value was "var:preset|font-family|helvetica-arial", - * to the style.fontFamily attribute, whose value will be "helvetica-arial". - * - * @param {Object} attributes The current attributes - * @return {Object} The updated attributes. - */ -const oldFontFamilyMigration = ( attributes ) => { - if ( ! attributes?.style?.typography?.fontFamily ) { - return attributes; - } - - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); - - return { - ...attributes, - fontFamily, - }; -}; +import oldFontFamilyMigration from '../utils/old-font-family-migration'; const blockAttributes = { content: { From 2124eab11a144e9a3d45a4e1fd5663a40e75fc33 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Thu, 14 Oct 2021 18:45:34 +0200 Subject: [PATCH 23/82] Add some deprecation coverage for the Button block --- .../core__button__font_family__deprecated.html | 3 +++ .../core__button__font_family__deprecated.json | 13 +++++++++++++ ..._button__font_family__deprecated.parsed.json | 17 +++++++++++++++++ ...ton__font_family__deprecated.serialized.html | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__button__font_family__deprecated.html create mode 100644 test/integration/fixtures/blocks/core__button__font_family__deprecated.json create mode 100644 test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json create mode 100644 test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.html b/test/integration/fixtures/blocks/core__button__font_family__deprecated.html new file mode 100644 index 0000000000000..a4f40f53a3c3f --- /dev/null +++ b/test/integration/fixtures/blocks/core__button__font_family__deprecated.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.json b/test/integration/fixtures/blocks/core__button__font_family__deprecated.json new file mode 100644 index 0000000000000..0b527c08924e0 --- /dev/null +++ b/test/integration/fixtures/blocks/core__button__font_family__deprecated.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/button", + "isValid": true, + "attributes": { + "text": "My button", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json b/test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json new file mode 100644 index 0000000000000..157ff5fd061db --- /dev/null +++ b/test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/button", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "\n\n", + "innerContent": [ + "\n\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html b/test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html new file mode 100644 index 0000000000000..cabc3d37ae9c9 --- /dev/null +++ b/test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html @@ -0,0 +1,3 @@ + + + From bf9d3850dd7e59a431531a35361669618327bf0e Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Thu, 14 Oct 2021 19:19:28 +0200 Subject: [PATCH 24/82] Rename oldFontFamilyMigration to migrateFontFamily --- packages/block-library/src/button/deprecated.js | 4 ++-- packages/block-library/src/list/deprecated.js | 4 ++-- packages/block-library/src/navigation/deprecated.js | 4 ++-- packages/block-library/src/post-title/deprecated.js | 4 ++-- packages/block-library/src/query-title/deprecated.js | 4 ++-- packages/block-library/src/site-tagline/deprecated.js | 4 ++-- packages/block-library/src/site-title/deprecated.js | 4 ++-- .../{old-font-family-migration.js => migrate-font-family.js} | 0 packages/block-library/src/verse/deprecated.js | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) rename packages/block-library/src/utils/{old-font-family-migration.js => migrate-font-family.js} (100%) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 9396cdc9ac708..542c5286ba885 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -21,7 +21,7 @@ import { compose } from '@wordpress/compose'; /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; @@ -981,7 +981,7 @@ const deprecated = [ ); }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index 444ab3a623c12..8035f3528ebc1 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -6,7 +6,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const deprecated = [ { @@ -62,7 +62,7 @@ const deprecated = [ ); }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index 0362489bf111b..4ba27c0c378b6 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -11,7 +11,7 @@ import { InnerBlocks } from '@wordpress/block-editor'; /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { fontStyle: 'var:preset|font-style|', @@ -325,7 +325,7 @@ const deprecated = [ save() { return ; }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 679e4e7c748ef..8c7dd414fd82f 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const deprecated = [ { @@ -46,7 +46,7 @@ const deprecated = [ save() { return null; }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 78c23d44d0499..16fcd7ab42a0c 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const deprecated = [ { @@ -32,7 +32,7 @@ const deprecated = [ save() { return null; }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index cf83e7f614024..f4ee9d9783a34 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const deprecated = [ { @@ -31,7 +31,7 @@ const deprecated = [ save() { return null; }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index 3156db370109a..f34ccd345ff60 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const deprecated = [ { @@ -39,7 +39,7 @@ const deprecated = [ save() { return null; }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, diff --git a/packages/block-library/src/utils/old-font-family-migration.js b/packages/block-library/src/utils/migrate-font-family.js similarity index 100% rename from packages/block-library/src/utils/old-font-family-migration.js rename to packages/block-library/src/utils/migrate-font-family.js diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index 549f7fee52d77..794f5d3f9fbe8 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -11,7 +11,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Internal dependencies */ -import oldFontFamilyMigration from '../utils/old-font-family-migration'; +import migrateFontFamily from '../utils/migrate-font-family'; const blockAttributes = { content: { @@ -81,7 +81,7 @@ const deprecated = [ ); }, - migrate: oldFontFamilyMigration, + migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; }, From 2f48b3e517bdfddba6d8e7a0d118631db9256240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 15 Oct 2021 09:48:11 +0200 Subject: [PATCH 25/82] List: add fixtures and update deprecation list --- packages/block-library/src/list/deprecated.js | 117 +++++++++--------- .../blocks/core__list__deprecated-v1.html | 3 + .../blocks/core__list__deprecated-v1.json | 14 +++ .../core__list__deprecated-v1.parsed.json | 17 +++ .../core__list__deprecated-v1.serialized.html | 3 + 5 files changed, 98 insertions(+), 56 deletions(-) create mode 100644 test/integration/fixtures/blocks/core__list__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__list__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__list__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__list__deprecated-v1.serialized.html diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index 8035f3528ebc1..25cb96b832c34 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -8,65 +8,70 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; */ import migrateFontFamily from '../utils/migrate-font-family'; -const deprecated = [ - { - attributes: { - ordered: { - type: 'boolean', - default: false, - __experimentalRole: 'content', - }, - values: { - type: 'string', - source: 'html', - selector: 'ol,ul', - multiline: 'li', - __unstableMultilineWrapperTags: [ 'ol', 'ul' ], - default: '', - __experimentalRole: 'content', - }, - type: { - type: 'string', - }, - start: { - type: 'number', - }, - reversed: { - type: 'boolean', - }, - placeholder: { - type: 'string', - }, +const v1 = { + attributes: { + ordered: { + type: 'boolean', + default: false, + __experimentalRole: 'content', }, - supports: { - anchor: true, - className: false, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - color: { - gradients: true, - link: true, - }, - __unstablePasteTextInline: true, - __experimentalSelector: 'ol,ul', + values: { + type: 'string', + source: 'html', + selector: 'ol,ul', + multiline: 'li', + __unstableMultilineWrapperTags: [ 'ol', 'ul' ], + default: '', + __experimentalRole: 'content', }, - save( { attributes } ) { - const { ordered, values, type, reversed, start } = attributes; - const TagName = ordered ? 'ol' : 'ul'; - - return ( - - - - ); + type: { + type: 'string', + }, + start: { + type: 'number', + }, + reversed: { + type: 'boolean', + }, + placeholder: { + type: 'string', + }, + }, + supports: { + anchor: true, + className: false, + typography: { + fontSize: true, + __experimentalFontFamily: true, }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; + color: { + gradients: true, + link: true, }, + __unstablePasteTextInline: true, + __experimentalSelector: 'ol,ul', }, -]; + save( { attributes } ) { + const { ordered, values, type, reversed, start } = attributes; + const TagName = ordered ? 'ol' : 'ul'; -export default deprecated; + return ( + + + + ); + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1 ]; diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1.html b/test/integration/fixtures/blocks/core__list__deprecated-v1.html new file mode 100644 index 0000000000000..eb8ea358a2ef6 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1.html @@ -0,0 +1,3 @@ + +
  • one
  • two
  • three
+ \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1.json b/test/integration/fixtures/blocks/core__list__deprecated-v1.json new file mode 100644 index 0000000000000..66562a27ca847 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "
  • one
  • two
  • three
  • ", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "
    • one
    • two
    • three
    " + } +] diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__list__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..d76f8e369efe4 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/list", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "\n
    • one
    • two
    • three
    \n", + "innerContent": [ + "\n
    • one
    • two
    • three
    \n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__list__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..0eb7670601542 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1.serialized.html @@ -0,0 +1,3 @@ + +
    • one
    • two
    • three
    + From 856f14edd2b0912d05b5dd370b97d1c3fdc9887c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 15 Oct 2021 09:53:34 +0200 Subject: [PATCH 26/82] Post Title: update deprecation list --- .../src/post-title/deprecated.js | 96 ++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 8c7dd414fd82f..904a67c7394d0 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -3,53 +3,59 @@ */ import migrateFontFamily from '../utils/migrate-font-family'; -const deprecated = [ - { - attributes: { - textAlign: { - type: 'string', - }, - level: { - type: 'number', - default: 2, - }, - isLink: { - type: 'boolean', - default: false, - }, - rel: { - type: 'string', - attribute: 'rel', - default: '', - }, - linkTarget: { - type: 'string', - default: '_self', - }, +const v1 = { + attributes: { + textAlign: { + type: 'string', }, - supports: { - align: [ 'wide', 'full' ], - html: false, - color: { - gradients: true, - link: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - __experimentalFontWeight: true, - __experimentalFontStyle: true, - __experimentalTextTransform: true, - }, + level: { + type: 'number', + default: 2, }, - save() { - return null; + isLink: { + type: 'boolean', + default: false, }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; + rel: { + type: 'string', + attribute: 'rel', + default: '', }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + }, + }, + save() { + return null; }, -]; -export default deprecated; + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1 ]; From cd15d941b1c4ff701aaa680dad779899c58c2acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 15 Oct 2021 10:09:30 +0200 Subject: [PATCH 27/82] Post title: add fixtures --- .../blocks/core__post-title__deprecated-v1.html | 1 + .../blocks/core__post-title__deprecated-v1.json | 16 ++++++++++++++++ .../core__post-title__deprecated-v1.parsed.json | 15 +++++++++++++++ ...re__post-title__deprecated-v1.serialized.html | 1 + 4 files changed, 33 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__post-title__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__post-title__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__post-title__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__post-title__deprecated-v1.serialized.html diff --git a/test/integration/fixtures/blocks/core__post-title__deprecated-v1.html b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.html new file mode 100644 index 0000000000000..eb285ffc94010 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__post-title__deprecated-v1.json b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.json new file mode 100644 index 0000000000000..33f5c4bc193e3 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/post-title", + "isValid": true, + "attributes": { + "level": 2, + "isLink": false, + "rel": "", + "linkTarget": "_self", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__post-title__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..c7e1621d394e3 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/post-title", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__post-title__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..ac3f119212592 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-title__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From b8d0b6faf977a86df0cf1280935b24812f67e84f Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 15:34:43 +0200 Subject: [PATCH 28/82] Express list deprecation through current block.json and save --- packages/block-library/src/list/deprecated.js | 67 +++---------------- 1 file changed, 10 insertions(+), 57 deletions(-) diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index 25cb96b832c34..eca47443f9b4b 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -1,66 +1,19 @@ -/** - * WordPress dependencies - */ -import { RichText, useBlockProps } from '@wordpress/block-editor'; - /** * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; +import currentSave from './save'; -const v1 = { - attributes: { - ordered: { - type: 'boolean', - default: false, - __experimentalRole: 'content', - }, - values: { - type: 'string', - source: 'html', - selector: 'ol,ul', - multiline: 'li', - __unstableMultilineWrapperTags: [ 'ol', 'ul' ], - default: '', - __experimentalRole: 'content', - }, - type: { - type: 'string', - }, - start: { - type: 'number', - }, - reversed: { - type: 'boolean', - }, - placeholder: { - type: 'string', - }, - }, - supports: { - anchor: true, - className: false, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - color: { - gradients: true, - link: true, - }, - __unstablePasteTextInline: true, - __experimentalSelector: 'ol,ul', - }, - save( { attributes } ) { - const { ordered, values, type, reversed, start } = attributes; - const TagName = ordered ? 'ol' : 'ul'; +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; - return ( - - - - ); - }, +const v1 = { + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 76439edcf3fa4f6ea5835d5d195c25921a8366b7 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 15:43:39 +0200 Subject: [PATCH 29/82] Express PostTitle block deprecation attributes through block.json --- .../src/post-title/deprecated.js | 46 ++++--------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 904a67c7394d0..7496800078d4f 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -2,46 +2,16 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const v1 = { - attributes: { - textAlign: { - type: 'string', - }, - level: { - type: 'number', - default: 2, - }, - isLink: { - type: 'boolean', - default: false, - }, - rel: { - type: 'string', - attribute: 'rel', - default: '', - }, - linkTarget: { - type: 'string', - default: '_self', - }, - }, - supports: { - align: [ 'wide', 'full' ], - html: false, - color: { - gradients: true, - link: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - __experimentalFontWeight: true, - __experimentalFontStyle: true, - __experimentalTextTransform: true, - }, - }, + attributes: currentAttributes, + supports: currentSupports, save() { return null; }, From 16354c80a72c7da79c52c0ca685d0ce322847da5 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 15:47:26 +0200 Subject: [PATCH 30/82] Simplify import --- packages/block-library/src/utils/migrate-font-family.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/utils/migrate-font-family.js b/packages/block-library/src/utils/migrate-font-family.js index e629b9b5e11b5..e9135c5555211 100644 --- a/packages/block-library/src/utils/migrate-font-family.js +++ b/packages/block-library/src/utils/migrate-font-family.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import cleanEmptyObject from '../utils/clean-empty-object'; +import cleanEmptyObject from './clean-empty-object'; /** * Migrates the current style.typography.fontFamily attribute, From 2147a77c972bbf6819cb954e4bb6bd192bbafe87 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 15:52:51 +0200 Subject: [PATCH 31/82] Express Site Tagline block deprecation attributes through block.json --- .../src/site-tagline/deprecated.js | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index f4ee9d9783a34..b455577fcecca 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -2,32 +2,17 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const deprecated = [ { - attributes: { - textAlign: { - type: 'string', - }, - }, - supports: { - html: false, - color: { - gradients: true, - }, - spacing: { - margin: true, - padding: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - __experimentalFontWeight: true, - __experimentalTextTransform: true, - __experimentalLetterSpacing: true, - }, - }, + attributes: currentAttributes, + supports: currentSupports, save() { return null; }, From 6e7deeb2ee865cba0984395ae4a8595b99c4ae23 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 15:54:13 +0200 Subject: [PATCH 32/82] Version Site Tagline deprecations --- .../src/site-tagline/deprecated.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index b455577fcecca..7496800078d4f 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -9,18 +9,23 @@ const { supports: currentSupports, } = blockConfig; -const deprecated = [ - { - attributes: currentAttributes, - supports: currentSupports, - save() { - return null; - }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, +const v1 = { + attributes: currentAttributes, + supports: currentSupports, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; }, -]; +}; -export default deprecated; +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1 ]; From 2288e9a56a2d957ea98416537e6576262000f28f Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:00:08 +0200 Subject: [PATCH 33/82] Add Site Tagline fixtures --- .../blocks/core__site-tagline__deprecated-v1.html | 1 + .../blocks/core__site-tagline__deprecated-v1.json | 12 ++++++++++++ .../core__site-tagline__deprecated-v1.parsed.json | 15 +++++++++++++++ ...e__site-tagline__deprecated-v1.serialized.html | 1 + 4 files changed, 29 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.serialized.html diff --git a/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.html b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.html new file mode 100644 index 0000000000000..c116817410845 --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.json b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.json new file mode 100644 index 0000000000000..78bc50af78f5f --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/site-tagline", + "isValid": true, + "attributes": { + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..ccf5c2beea419 --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/site-tagline", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..38288cace27c4 --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-tagline__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From f36e8f6559b05837da0488afa2b09d5b22dccd02 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:01:49 +0200 Subject: [PATCH 34/82] Express Site Title block deprecation attributes through block.json --- .../src/site-title/deprecated.js | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index f34ccd345ff60..b455577fcecca 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -2,40 +2,17 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const deprecated = [ { - attributes: { - level: { - type: 'number', - default: 1, - }, - textAlign: { - type: 'string', - }, - }, - supports: { - align: [ 'wide', 'full' ], - html: false, - color: { - gradients: true, - text: false, - link: true, - }, - spacing: { - padding: true, - margin: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - __experimentalTextTransform: true, - __experimentalFontStyle: true, - __experimentalFontWeight: true, - __experimentalLetterSpacing: true, - }, - }, + attributes: currentAttributes, + supports: currentSupports, save() { return null; }, From e0be5d257203ba5756c3466e60366c092fb51746 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:02:39 +0200 Subject: [PATCH 35/82] Version Site Title deprecations --- .../src/site-title/deprecated.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index b455577fcecca..7496800078d4f 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -9,18 +9,23 @@ const { supports: currentSupports, } = blockConfig; -const deprecated = [ - { - attributes: currentAttributes, - supports: currentSupports, - save() { - return null; - }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, +const v1 = { + attributes: currentAttributes, + supports: currentSupports, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; }, -]; +}; -export default deprecated; +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1 ]; From d4aeb54cf006f6164b501a652481abc33eb7421e Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:04:00 +0200 Subject: [PATCH 36/82] Add Site Title fixtures --- .../blocks/core__site-title__deprecated-v1.html | 1 + .../blocks/core__site-title__deprecated-v1.json | 15 +++++++++++++++ .../core__site-title__deprecated-v1.parsed.json | 15 +++++++++++++++ ...ore__site-title__deprecated-v1.serialized.html | 1 + 4 files changed, 32 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__site-title__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__site-title__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__site-title__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__site-title__deprecated-v1.serialized.html diff --git a/test/integration/fixtures/blocks/core__site-title__deprecated-v1.html b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.html new file mode 100644 index 0000000000000..7717873f9e2fc --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__site-title__deprecated-v1.json b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.json new file mode 100644 index 0000000000000..475bb9507ac6d --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.json @@ -0,0 +1,15 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/site-title", + "isValid": true, + "attributes": { + "level": 1, + "isLink": true, + "linkTarget": "_self", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__site-title__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..d3e23e9d9a596 --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/site-title", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__site-title__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..20d70afab0669 --- /dev/null +++ b/test/integration/fixtures/blocks/core__site-title__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From 65bdb3ef2051b5cb38622161cf0b8d33d516ce87 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:08:08 +0200 Subject: [PATCH 37/82] Express Query Title block deprecation attributes through block.json --- .../src/query-title/deprecated.js | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 16fcd7ab42a0c..b455577fcecca 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -2,33 +2,17 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const deprecated = [ { - attributes: { - type: { - type: 'string', - }, - textAlign: { - type: 'string', - }, - level: { - type: 'number', - default: 1, - }, - }, - supports: { - align: [ 'wide', 'full' ], - html: false, - color: { - gradients: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - }, - }, + attributes: currentAttributes, + supports: currentSupports, save() { return null; }, From 61b2ea90f5021f2b8ce87c89fd9113af319ee39f Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:09:58 +0200 Subject: [PATCH 38/82] Version Query Title deprecations --- .../src/query-title/deprecated.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index b455577fcecca..7496800078d4f 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -9,18 +9,23 @@ const { supports: currentSupports, } = blockConfig; -const deprecated = [ - { - attributes: currentAttributes, - supports: currentSupports, - save() { - return null; - }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, +const v1 = { + attributes: currentAttributes, + supports: currentSupports, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; }, -]; +}; -export default deprecated; +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1 ]; From 0c9093b9bf72616a2866f98b968b9d87fb868122 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:12:08 +0200 Subject: [PATCH 39/82] Add Query Title fixtures --- .../blocks/core__query-title__deprecated-v1.html | 1 + .../blocks/core__query-title__deprecated-v1.json | 13 +++++++++++++ .../core__query-title__deprecated-v1.parsed.json | 15 +++++++++++++++ ...re__query-title__deprecated-v1.serialized.html | 1 + 4 files changed, 30 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__query-title__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__query-title__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__query-title__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__query-title__deprecated-v1.serialized.html diff --git a/test/integration/fixtures/blocks/core__query-title__deprecated-v1.html b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.html new file mode 100644 index 0000000000000..303fc95832174 --- /dev/null +++ b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__query-title__deprecated-v1.json b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.json new file mode 100644 index 0000000000000..0090b749d0808 --- /dev/null +++ b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/query-title", + "isValid": true, + "attributes": { + "level": 1, + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__query-title__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..7938e3d65171a --- /dev/null +++ b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/query-title", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__query-title__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..714807b04ae31 --- /dev/null +++ b/test/integration/fixtures/blocks/core__query-title__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From 8c47da1c70fb7f618261cb5703b796b97cc04163 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:21:07 +0200 Subject: [PATCH 40/82] Version Verse block deprecations --- .../block-library/src/verse/deprecated.js | 116 +++++++++--------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index 794f5d3f9fbe8..ca77398cef76e 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -25,67 +25,73 @@ const blockAttributes = { }, }; -const deprecated = [ - { - attributes: blockAttributes, - save( { attributes } ) { - const { textAlign, content } = attributes; +const v1 = { + attributes: blockAttributes, + save( { attributes } ) { + const { textAlign, content } = attributes; - return ( - - ); + return ( + + ); + }, +}; + +const v2 = { + attributes: { + content: { + type: 'string', + source: 'html', + selector: 'pre', + default: '', + __unstablePreserveWhiteSpace: true, + __experimentalRole: 'content', + }, + textAlign: { + type: 'string', }, }, - { - attributes: { - content: { - type: 'string', - source: 'html', - selector: 'pre', - default: '', - __unstablePreserveWhiteSpace: true, - __experimentalRole: 'content', - }, - textAlign: { - type: 'string', - }, + supports: { + anchor: true, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, }, - supports: { - anchor: true, - color: { - gradients: true, - link: true, - }, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - spacing: { - padding: true, - }, + spacing: { + padding: true, }, - save( { attributes } ) { - const { textAlign, content } = attributes; + }, + save( { attributes } ) { + const { textAlign, content } = attributes; - const className = classnames( { - [ `has-text-align-${ textAlign }` ]: textAlign, - } ); + const className = classnames( { + [ `has-text-align-${ textAlign }` ]: textAlign, + } ); - return ( -
    -					
    -				
    - ); - }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, + return ( +
    +				
    +			
    + ); + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; }, -]; +}; -export default deprecated; +/** + * New deprecations need to be placed first + * for them to have higher priority. + * They also need to contain the old deprecations. + * + * See block-deprecation.md + */ +export default [ v1, v2 ]; From 7e32d7a96bf8fa8107446176d41af81bbb0a0f05 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:21:49 +0200 Subject: [PATCH 41/82] Verse deprecation: Inline v1 block attributes --- .../block-library/src/verse/deprecated.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index ca77398cef76e..b37697b4d685e 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -13,20 +13,18 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; */ import migrateFontFamily from '../utils/migrate-font-family'; -const blockAttributes = { - content: { - type: 'string', - source: 'html', - selector: 'pre', - default: '', - }, - textAlign: { - type: 'string', - }, -}; - const v1 = { - attributes: blockAttributes, + attributes: { + content: { + type: 'string', + source: 'html', + selector: 'pre', + default: '', + }, + textAlign: { + type: 'string', + }, + }, save( { attributes } ) { const { textAlign, content } = attributes; From cad9e21a8a66ac33c362b80126efea537640c9aa Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:24:13 +0200 Subject: [PATCH 42/82] Express Verse block v2 deprecation through block.json and save --- .../block-library/src/verse/deprecated.js | 57 ++++--------------- 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index b37697b4d685e..68f7752db4bee 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -1,17 +1,19 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; - /** * WordPress dependencies */ -import { RichText, useBlockProps } from '@wordpress/block-editor'; +import { RichText } from '@wordpress/block-editor'; /** * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; +import currentSave from './save'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const v1 = { attributes: { @@ -39,46 +41,9 @@ const v1 = { }; const v2 = { - attributes: { - content: { - type: 'string', - source: 'html', - selector: 'pre', - default: '', - __unstablePreserveWhiteSpace: true, - __experimentalRole: 'content', - }, - textAlign: { - type: 'string', - }, - }, - supports: { - anchor: true, - color: { - gradients: true, - link: true, - }, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - spacing: { - padding: true, - }, - }, - save( { attributes } ) { - const { textAlign, content } = attributes; - - const className = classnames( { - [ `has-text-align-${ textAlign }` ]: textAlign, - } ); - - return ( -
    -				
    -			
    - ); - }, + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 1e9ed9d724d4f2db03c1fd185a6fa231b7e16621 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:29:07 +0200 Subject: [PATCH 43/82] Rename Verse deprecation fixture --- ...re__verse__deprecated.html => core__verse__deprecated-v1.html} | 0 ...re__verse__deprecated.json => core__verse__deprecated-v1.json} | 0 ...recated.parsed.json => core__verse__deprecated-v1.parsed.json} | 0 ...serialized.html => core__verse__deprecated-v1.serialized.html} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/integration/fixtures/blocks/{core__verse__deprecated.html => core__verse__deprecated-v1.html} (100%) rename test/integration/fixtures/blocks/{core__verse__deprecated.json => core__verse__deprecated-v1.json} (100%) rename test/integration/fixtures/blocks/{core__verse__deprecated.parsed.json => core__verse__deprecated-v1.parsed.json} (100%) rename test/integration/fixtures/blocks/{core__verse__deprecated.serialized.html => core__verse__deprecated-v1.serialized.html} (100%) diff --git a/test/integration/fixtures/blocks/core__verse__deprecated.html b/test/integration/fixtures/blocks/core__verse__deprecated-v1.html similarity index 100% rename from test/integration/fixtures/blocks/core__verse__deprecated.html rename to test/integration/fixtures/blocks/core__verse__deprecated-v1.html diff --git a/test/integration/fixtures/blocks/core__verse__deprecated.json b/test/integration/fixtures/blocks/core__verse__deprecated-v1.json similarity index 100% rename from test/integration/fixtures/blocks/core__verse__deprecated.json rename to test/integration/fixtures/blocks/core__verse__deprecated-v1.json diff --git a/test/integration/fixtures/blocks/core__verse__deprecated.parsed.json b/test/integration/fixtures/blocks/core__verse__deprecated-v1.parsed.json similarity index 100% rename from test/integration/fixtures/blocks/core__verse__deprecated.parsed.json rename to test/integration/fixtures/blocks/core__verse__deprecated-v1.parsed.json diff --git a/test/integration/fixtures/blocks/core__verse__deprecated.serialized.html b/test/integration/fixtures/blocks/core__verse__deprecated-v1.serialized.html similarity index 100% rename from test/integration/fixtures/blocks/core__verse__deprecated.serialized.html rename to test/integration/fixtures/blocks/core__verse__deprecated-v1.serialized.html From fb2b405e34c784d6c4ba20fc6015900a7cf12a6b Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 16:53:38 +0200 Subject: [PATCH 44/82] Add fixtures for Verse block deprecation v2 --- .../blocks/core__verse__deprecated-v2.html | 3 +++ .../blocks/core__verse__deprecated-v2.json | 13 +++++++++++++ .../core__verse__deprecated-v2.parsed.json | 17 +++++++++++++++++ .../core__verse__deprecated-v2.serialized.html | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__verse__deprecated-v2.html create mode 100644 test/integration/fixtures/blocks/core__verse__deprecated-v2.json create mode 100644 test/integration/fixtures/blocks/core__verse__deprecated-v2.parsed.json create mode 100644 test/integration/fixtures/blocks/core__verse__deprecated-v2.serialized.html diff --git a/test/integration/fixtures/blocks/core__verse__deprecated-v2.html b/test/integration/fixtures/blocks/core__verse__deprecated-v2.html new file mode 100644 index 0000000000000..48ea544e627f7 --- /dev/null +++ b/test/integration/fixtures/blocks/core__verse__deprecated-v2.html @@ -0,0 +1,3 @@ + +
    A verse…
    And more!
    + diff --git a/test/integration/fixtures/blocks/core__verse__deprecated-v2.json b/test/integration/fixtures/blocks/core__verse__deprecated-v2.json new file mode 100644 index 0000000000000..440fff4bb9296 --- /dev/null +++ b/test/integration/fixtures/blocks/core__verse__deprecated-v2.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/verse", + "isValid": true, + "attributes": { + "content": "A verse…
    And more!", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "
    A verse…
    And more!
    " + } +] diff --git a/test/integration/fixtures/blocks/core__verse__deprecated-v2.parsed.json b/test/integration/fixtures/blocks/core__verse__deprecated-v2.parsed.json new file mode 100644 index 0000000000000..8ea50c04a7c38 --- /dev/null +++ b/test/integration/fixtures/blocks/core__verse__deprecated-v2.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/verse", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "\n
    A verse…
    And more!
    \n", + "innerContent": [ + "\n
    A verse…
    And more!
    \n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__verse__deprecated-v2.serialized.html b/test/integration/fixtures/blocks/core__verse__deprecated-v2.serialized.html new file mode 100644 index 0000000000000..c28767b65c048 --- /dev/null +++ b/test/integration/fixtures/blocks/core__verse__deprecated-v2.serialized.html @@ -0,0 +1,3 @@ + +
    A verse…
    And more!
    + From 7a6a04c90a9682fae2522859b16bcf8bc3943675 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 17:36:27 +0200 Subject: [PATCH 45/82] Express Button block latest deprecation through block.json and save --- .../block-library/src/button/deprecated.js | 144 ++---------------- 1 file changed, 10 insertions(+), 134 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 542c5286ba885..009ef5bb6e9e7 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -12,9 +12,7 @@ import { getColorClassName, useBlockProps, __experimentalGetGradientClass, - __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles, - __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles, } from '@wordpress/block-editor'; import { compose } from '@wordpress/compose'; @@ -22,6 +20,13 @@ import { compose } from '@wordpress/compose'; * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; +import currentSave from './save'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; @@ -849,138 +854,9 @@ const deprecated = [ migrate: oldColorsMigration, }, { - attributes: { - url: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'href', - }, - title: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'title', - }, - text: { - type: 'string', - source: 'html', - selector: 'a', - }, - linkTarget: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'target', - }, - rel: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'rel', - }, - placeholder: { - type: 'string', - }, - backgroundColor: { - type: 'string', - }, - textColor: { - type: 'string', - }, - gradient: { - type: 'string', - }, - width: { - type: 'number', - }, - }, - supports: { - anchor: true, - align: true, - alignWide: false, - color: { - __experimentalSkipSerialization: true, - gradients: true, - }, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - reusable: false, - spacing: { - __experimentalSkipSerialization: true, - padding: [ 'horizontal', 'vertical' ], - __experimentalDefaultControls: { - padding: true, - }, - }, - __experimentalBorder: { - radius: true, - __experimentalSkipSerialization: true, - }, - __experimentalSelector: '.wp-block-button__link', - }, - save( { attributes, className } ) { - const { - fontSize, - linkTarget, - rel, - style, - text, - title, - url, - width, - } = attributes; - - if ( ! text ) { - return null; - } - - const borderProps = getBorderClassesAndStyles( attributes ); - const colorProps = getColorClassesAndStyles( attributes ); - const spacingProps = getSpacingClassesAndStyles( attributes ); - const buttonClasses = classnames( - 'wp-block-button__link', - colorProps.className, - borderProps.className, - { - // For backwards compatibility add style that isn't provided via - // block support. - 'no-border-radius': style?.border?.radius === 0, - } - ); - const buttonStyle = { - ...borderProps.style, - ...colorProps.style, - ...spacingProps.style, - }; - - // The use of a `title` attribute here is soft-deprecated, but still applied - // if it had already been assigned, for the sake of backward-compatibility. - // A title will no longer be assigned for new or updated button block links. - - const wrapperClasses = classnames( className, { - [ `has-custom-width wp-block-button__width-${ width }` ]: width, - [ `has-custom-font-size` ]: - fontSize || style?.typography?.fontSize, - } ); - - return ( -
    - -
    - ); - }, + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 673462a36929a507fc2246c28bffc6280a0c8483 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 17:46:21 +0200 Subject: [PATCH 46/82] Express Navigation block latest deprecation through block.json and save --- .../src/navigation/deprecated.js | 82 +++---------------- 1 file changed, 10 insertions(+), 72 deletions(-) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index 4ba27c0c378b6..975a0cf67d265 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -12,6 +12,13 @@ import { InnerBlocks } from '@wordpress/block-editor'; * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; +import blockConfig from './block.json'; +import currentSave from './save'; + +const { + attributes: currentAttributes, + supports: currentSupports, +} = blockConfig; const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { fontStyle: 'var:preset|font-style|', @@ -253,78 +260,9 @@ const deprecated = [ }, }, { - attributes: { - orientation: { - type: 'string', - default: 'horizontal', - }, - textColor: { - type: 'string', - }, - customTextColor: { - type: 'string', - }, - rgbTextColor: { - type: 'string', - }, - backgroundColor: { - type: 'string', - }, - customBackgroundColor: { - type: 'string', - }, - rgbBackgroundColor: { - type: 'string', - }, - itemsJustification: { - type: 'string', - }, - showSubmenuIcon: { - type: 'boolean', - default: true, - }, - openSubmenusOnClick: { - type: 'boolean', - default: false, - }, - isResponsive: { - type: 'boolean', - default: false, - }, - __unstableLocation: { - type: 'string', - }, - overlayBackgroundColor: { - type: 'string', - }, - customOverlayBackgroundColor: { - type: 'string', - }, - overlayTextColor: { - type: 'string', - }, - customOverlayTextColor: { - type: 'string', - }, - }, - supports: { - align: [ 'wide', 'full' ], - anchor: true, - html: false, - inserter: true, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontStyle: true, - __experimentalFontWeight: true, - __experimentalTextTransform: true, - __experimentalFontFamily: true, - __experimentalTextDecoration: true, - }, - }, - save() { - return ; - }, + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From fdf85664f857fd33b9cc2d8f1aa1cab379989605 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 17:54:12 +0200 Subject: [PATCH 47/82] Add fixtures for Navigation block font family deprecation --- ...ore__navigation__font_family__deprecated.html | 2 ++ ...ore__navigation__font_family__deprecated.json | 16 ++++++++++++++++ ...vigation__font_family__deprecated.parsed.json | 15 +++++++++++++++ ...tion__font_family__deprecated.serialized.html | 1 + 4 files changed, 34 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html create mode 100644 test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json create mode 100644 test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json create mode 100644 test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html new file mode 100644 index 0000000000000..a34036cae23f7 --- /dev/null +++ b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json new file mode 100644 index 0000000000000..af037bc657f3a --- /dev/null +++ b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/navigation", + "isValid": true, + "attributes": { + "orientation": "horizontal", + "showSubmenuIcon": true, + "openSubmenusOnClick": false, + "overlayMenu": "never", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json new file mode 100644 index 0000000000000..388a7c1cb23d7 --- /dev/null +++ b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/navigation", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ "\n" ] + } +] diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html new file mode 100644 index 0000000000000..2c353742c4a95 --- /dev/null +++ b/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html @@ -0,0 +1 @@ + From e16fdaf708cee20675c0012d63954477e1db295a Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 21:41:33 +0200 Subject: [PATCH 48/82] Move latest Navigation block deprecation to the top --- .../block-library/src/navigation/deprecated.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index 975a0cf67d265..b32db76b73b02 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -28,6 +28,15 @@ const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { }; const deprecated = [ + { + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, // Remove `isResponsive` attribute. { attributes: { @@ -259,15 +268,6 @@ const deprecated = [ return ; }, }, - { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, - }, ]; export default deprecated; From cf59565f1ff1da3d5037c06088e931b615cff8ad Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 21:43:54 +0200 Subject: [PATCH 49/82] Move latest Verse block deprecation to the top --- packages/block-library/src/verse/deprecated.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index 68f7752db4bee..8f00129e81936 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -57,4 +57,4 @@ const v2 = { * * See block-deprecation.md */ -export default [ v1, v2 ]; +export default [ v2, v1 ]; From 3350bd024983c96e3a6d5d2e2bf235e1a49b5d7f Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 15 Oct 2021 21:45:32 +0200 Subject: [PATCH 50/82] Move latest Button block deprecation to the top --- .../block-library/src/button/deprecated.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 009ef5bb6e9e7..233c026314029 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -125,6 +125,15 @@ const blockAttributes = { }; const deprecated = [ + { + attributes: currentAttributes, + supports: currentSupports, + save: currentSave, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, + }, { supports: { anchor: true, @@ -853,15 +862,6 @@ const deprecated = [ }, migrate: oldColorsMigration, }, - { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, - }, ]; export default deprecated; From c67ec861129e830254e0d5548fc5ff5d23bba74b Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 13:49:28 +0200 Subject: [PATCH 51/82] Un-Express Button block latest deprecation through block.json and save Essentially reverts 78b2bf518b9f64c2bbe14085943729fcaf3ded0e --- .../block-library/src/button/deprecated.js | 144 ++++++++++++++++-- 1 file changed, 134 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 233c026314029..37837ce9b9f60 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -12,7 +12,9 @@ import { getColorClassName, useBlockProps, __experimentalGetGradientClass, + __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles, + __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles, } from '@wordpress/block-editor'; import { compose } from '@wordpress/compose'; @@ -20,13 +22,6 @@ import { compose } from '@wordpress/compose'; * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; -import currentSave from './save'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const migrateBorderRadius = ( attributes ) => { const { borderRadius, ...newAttributes } = attributes; @@ -126,9 +121,138 @@ const blockAttributes = { const deprecated = [ { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, + attributes: { + url: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'href', + }, + title: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'title', + }, + text: { + type: 'string', + source: 'html', + selector: 'a', + }, + linkTarget: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'target', + }, + rel: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'rel', + }, + placeholder: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + textColor: { + type: 'string', + }, + gradient: { + type: 'string', + }, + width: { + type: 'number', + }, + }, + supports: { + anchor: true, + align: true, + alignWide: false, + color: { + __experimentalSkipSerialization: true, + gradients: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + reusable: false, + spacing: { + __experimentalSkipSerialization: true, + padding: [ 'horizontal', 'vertical' ], + __experimentalDefaultControls: { + padding: true, + }, + }, + __experimentalBorder: { + radius: true, + __experimentalSkipSerialization: true, + }, + __experimentalSelector: '.wp-block-button__link', + }, + save( { attributes, className } ) { + const { + fontSize, + linkTarget, + rel, + style, + text, + title, + url, + width, + } = attributes; + + if ( ! text ) { + return null; + } + + const borderProps = getBorderClassesAndStyles( attributes ); + const colorProps = getColorClassesAndStyles( attributes ); + const spacingProps = getSpacingClassesAndStyles( attributes ); + const buttonClasses = classnames( + 'wp-block-button__link', + colorProps.className, + borderProps.className, + { + // For backwards compatibility add style that isn't provided via + // block support. + 'no-border-radius': style?.border?.radius === 0, + } + ); + const buttonStyle = { + ...borderProps.style, + ...colorProps.style, + ...spacingProps.style, + }; + + // The use of a `title` attribute here is soft-deprecated, but still applied + // if it had already been assigned, for the sake of backward-compatibility. + // A title will no longer be assigned for new or updated button block links. + + const wrapperClasses = classnames( className, { + [ `has-custom-width wp-block-button__width-${ width }` ]: width, + [ `has-custom-font-size` ]: + fontSize || style?.typography?.fontSize, + } ); + + return ( +
    + +
    + ); + }, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 57f9cc5eb3efec2ab8718e7d040c8c5b47866e89 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 13:52:57 +0200 Subject: [PATCH 52/82] Revert "Express list deprecation through current block.json and save" This reverts commit 26c57bcff35ed5c77219cb57c16d44791af6e50b. --- packages/block-library/src/list/deprecated.js | 67 ++++++++++++++++--- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index eca47443f9b4b..25cb96b832c34 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -1,19 +1,66 @@ +/** + * WordPress dependencies + */ +import { RichText, useBlockProps } from '@wordpress/block-editor'; + /** * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; -import currentSave from './save'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, + attributes: { + ordered: { + type: 'boolean', + default: false, + __experimentalRole: 'content', + }, + values: { + type: 'string', + source: 'html', + selector: 'ol,ul', + multiline: 'li', + __unstableMultilineWrapperTags: [ 'ol', 'ul' ], + default: '', + __experimentalRole: 'content', + }, + type: { + type: 'string', + }, + start: { + type: 'number', + }, + reversed: { + type: 'boolean', + }, + placeholder: { + type: 'string', + }, + }, + supports: { + anchor: true, + className: false, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + color: { + gradients: true, + link: true, + }, + __unstablePasteTextInline: true, + __experimentalSelector: 'ol,ul', + }, + save( { attributes } ) { + const { ordered, values, type, reversed, start } = attributes; + const TagName = ordered ? 'ol' : 'ul'; + + return ( + + + + ); + }, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 8e0a592b549e2dfade40228d31d54eb7a399c84e Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 13:55:10 +0200 Subject: [PATCH 53/82] List deprecation: Add __experimentalSlashInserter attribute --- packages/block-library/src/list/deprecated.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index 25cb96b832c34..df13f2b9b23d0 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -50,6 +50,7 @@ const v1 = { }, __unstablePasteTextInline: true, __experimentalSelector: 'ol,ul', + __experimentalSlashInserter: true, }, save( { attributes } ) { const { ordered, values, type, reversed, start } = attributes; From 5708f0dcee3c473fa364b315855d8106a725ce52 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:04:00 +0200 Subject: [PATCH 54/82] Revert "Express PostTitle block deprecation attributes through block.json" This reverts commit c75c849bb217ec3b37867f5ceb7e2ee04b466ff1. --- .../src/post-title/deprecated.js | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 7496800078d4f..904a67c7394d0 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -2,16 +2,46 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { - attributes: currentAttributes, - supports: currentSupports, + attributes: { + textAlign: { + type: 'string', + }, + level: { + type: 'number', + default: 2, + }, + isLink: { + type: 'boolean', + default: false, + }, + rel: { + type: 'string', + attribute: 'rel', + default: '', + }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + }, + }, save() { return null; }, From 64d52274d35b9196cda35d66384eb73e8afcb342 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:08:03 +0200 Subject: [PATCH 55/82] Un-Express Navigation block latest deprecation through block.json and save Essentially reverting f2fd6acf67d5c91f2c6afd1b4389156922063495 --- .../src/navigation/deprecated.js | 82 ++++++++++++++++--- 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index b32db76b73b02..db07ddfcac8f1 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -12,13 +12,6 @@ import { InnerBlocks } from '@wordpress/block-editor'; * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; -import currentSave from './save'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { fontStyle: 'var:preset|font-style|', @@ -29,9 +22,78 @@ const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { const deprecated = [ { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, + attributes: { + orientation: { + type: 'string', + default: 'horizontal', + }, + textColor: { + type: 'string', + }, + customTextColor: { + type: 'string', + }, + rgbTextColor: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + customBackgroundColor: { + type: 'string', + }, + rgbBackgroundColor: { + type: 'string', + }, + itemsJustification: { + type: 'string', + }, + showSubmenuIcon: { + type: 'boolean', + default: true, + }, + openSubmenusOnClick: { + type: 'boolean', + default: false, + }, + overlayMenu: { + type: 'string', + default: 'never', + }, + __unstableLocation: { + type: 'string', + }, + overlayBackgroundColor: { + type: 'string', + }, + customOverlayBackgroundColor: { + type: 'string', + }, + overlayTextColor: { + type: 'string', + }, + customOverlayTextColor: { + type: 'string', + }, + }, + supports: { + align: [ 'wide', 'full' ], + anchor: true, + html: false, + inserter: true, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalTextTransform: true, + __experimentalFontFamily: true, + __experimentalTextDecoration: true, + }, + }, + save() { + return ; + }, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From 2a5110ecbff6020606a7b446a73f7acddd8c63cf Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:18:45 +0200 Subject: [PATCH 56/82] Un-Express Query Title block deprecation attributes through block.json Essentially reverting db0d9420b29d95fd9bde3537f54240b3b4b3fb39 --- .../src/query-title/deprecated.js | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 7496800078d4f..1044c3d919813 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -2,16 +2,32 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { - attributes: currentAttributes, - supports: currentSupports, + attributes: { + type: { + type: 'string', + }, + textAlign: { + type: 'string', + }, + level: { + type: 'number', + default: 1, + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + }, + }, save() { return null; }, From c9d592ec3effdd338deb156cb72e0fbdbd1bd087 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:20:49 +0200 Subject: [PATCH 57/82] Un-Express Site Tagline block deprecation attributes through block.json Essentially reverting 8c5510d68fe8d23ba7070dabc4c76feadb2bd93d --- .../src/site-tagline/deprecated.js | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index 7496800078d4f..7e209949397b4 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -2,16 +2,33 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { - attributes: currentAttributes, - supports: currentSupports, + attributes: { + textAlign: { + type: 'string', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + }, + spacing: { + margin: true, + padding: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalTextTransform: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalLetterSpacing: true, + }, + }, save() { return null; }, From 68362f3c6da5589407e1a9bc94a671657c1048dc Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:25:14 +0200 Subject: [PATCH 58/82] Un-Express Site Title block deprecation attributes through block.json Essentially reverting 6faf83df2bb1a69c7472e505d498cb6304002212 --- .../src/site-title/deprecated.js | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index 7496800078d4f..5f5d9ecd0281a 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -2,16 +2,46 @@ * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { - attributes: currentAttributes, - supports: currentSupports, + attributes: { + level: { + type: 'number', + default: 1, + }, + textAlign: { + type: 'string', + }, + isLink: { + type: 'boolean', + default: true, + }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + align: [ 'wide', 'full' ], + html: false, + color: { + gradients: true, + link: true, + }, + spacing: { + padding: true, + margin: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalTextTransform: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalLetterSpacing: true, + }, + }, save() { return null; }, From f74dc65f978cde3fbe5d1b2d69a2400534aba710 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 18 Oct 2021 14:28:41 +0200 Subject: [PATCH 59/82] Un-Express Verse block v2 deprecation through block.json and save Essentially reverting 35e38a7f32247b50688bb327172607d19e0798e8 --- .../block-library/src/verse/deprecated.js | 57 +++++++++++++++---- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index 8f00129e81936..155a55b3e576d 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -1,19 +1,17 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ -import { RichText } from '@wordpress/block-editor'; +import { RichText, useBlockProps } from '@wordpress/block-editor'; /** * Internal dependencies */ import migrateFontFamily from '../utils/migrate-font-family'; -import blockConfig from './block.json'; -import currentSave from './save'; - -const { - attributes: currentAttributes, - supports: currentSupports, -} = blockConfig; const v1 = { attributes: { @@ -41,9 +39,46 @@ const v1 = { }; const v2 = { - attributes: currentAttributes, - supports: currentSupports, - save: currentSave, + attributes: { + content: { + type: 'string', + source: 'html', + selector: 'pre', + default: '', + __unstablePreserveWhiteSpace: true, + __experimentalRole: 'content', + }, + textAlign: { + type: 'string', + }, + }, + supports: { + anchor: true, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + spacing: { + padding: true, + }, + }, + save( { attributes } ) { + const { textAlign, content } = attributes; + + const className = classnames( { + [ `has-text-align-${ textAlign }` ]: textAlign, + } ); + + return ( +
    +				
    +			
    + ); + }, migrate: migrateFontFamily, isEligible( { style } ) { return style?.typography?.fontFamily; From a58340f0b28a8dadcbc6aec2bd866354447f9bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 11:25:05 +0200 Subject: [PATCH 60/82] Make sure slugs are kebab-cased properly --- lib/block-supports/typography.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 60f343a5d2c31..62b6680e06ebc 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -109,7 +109,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); if ( $has_named_font_family ) { - $classes[] = sprintf( 'has-%s-font-family', $block_attributes['fontFamily'] ); + $classes[] = sprintf( 'has-%s-font-family', gutenberg_experimental_to_kebab_case( $block_attributes['fontFamily'] ) ); } elseif ( $has_custom_font_family ) { // Before using classes, the value was serialized as a CSS Custom Property. // We don't need this code path when it lands in core. From a33ab7f7e57222bb37722c2a3816d56cf3f76ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:18:33 +0200 Subject: [PATCH 61/82] Update comment --- packages/block-library/src/list/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/list/deprecated.js b/packages/block-library/src/list/deprecated.js index df13f2b9b23d0..6f4a5e70f9ccd 100644 --- a/packages/block-library/src/list/deprecated.js +++ b/packages/block-library/src/list/deprecated.js @@ -71,7 +71,8 @@ const v1 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From 39445aa7d4debaec1cdb44b547a10ff5428e0609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:20:27 +0200 Subject: [PATCH 62/82] Post title: update comment --- packages/block-library/src/post-title/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 904a67c7394d0..06bdae083461d 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -54,7 +54,8 @@ const v1 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From 2e81ca220d5faa54ea9f12be393e2fff285f5d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:21:56 +0200 Subject: [PATCH 63/82] Query title: update comment --- packages/block-library/src/query-title/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 1044c3d919813..2f54913ecfaac 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -40,7 +40,8 @@ const v1 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From cfa9e1324b52242ec5492fc65773c489f0289da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:23:23 +0200 Subject: [PATCH 64/82] Site tagline: update comment --- packages/block-library/src/site-tagline/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/site-tagline/deprecated.js b/packages/block-library/src/site-tagline/deprecated.js index 7e209949397b4..e236058d8e1c7 100644 --- a/packages/block-library/src/site-tagline/deprecated.js +++ b/packages/block-library/src/site-tagline/deprecated.js @@ -41,7 +41,8 @@ const v1 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From 2505ef312567896ae6b590412b48a5498b06a79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:25:16 +0200 Subject: [PATCH 65/82] Site title: update comment --- packages/block-library/src/site-title/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/site-title/deprecated.js b/packages/block-library/src/site-title/deprecated.js index 5f5d9ecd0281a..4f74ef268878b 100644 --- a/packages/block-library/src/site-title/deprecated.js +++ b/packages/block-library/src/site-title/deprecated.js @@ -54,7 +54,8 @@ const v1 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From 9ae7032057781e0c8ea0fdf11e00f1884658d2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:26:21 +0200 Subject: [PATCH 66/82] Verse: update comment --- packages/block-library/src/verse/deprecated.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/verse/deprecated.js b/packages/block-library/src/verse/deprecated.js index 155a55b3e576d..d986e2df75e5b 100644 --- a/packages/block-library/src/verse/deprecated.js +++ b/packages/block-library/src/verse/deprecated.js @@ -88,7 +88,8 @@ const v2 = { /** * New deprecations need to be placed first * for them to have higher priority. - * They also need to contain the old deprecations. + * + * Old deprecations may need to be updated as well. * * See block-deprecation.md */ From 0a9b7996e7142b816d0396b77e989351d4757915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:35:13 +0200 Subject: [PATCH 67/82] Button: extract font-family deprecation to own constant --- .../block-library/src/button/deprecated.js | 263 +++++++++--------- 1 file changed, 132 insertions(+), 131 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 37837ce9b9f60..592b809f481d6 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -119,145 +119,146 @@ const blockAttributes = { }, }; -const deprecated = [ - { - attributes: { - url: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'href', - }, - title: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'title', - }, - text: { - type: 'string', - source: 'html', - selector: 'a', - }, - linkTarget: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'target', - }, - rel: { - type: 'string', - source: 'attribute', - selector: 'a', - attribute: 'rel', - }, - placeholder: { - type: 'string', - }, - backgroundColor: { - type: 'string', - }, - textColor: { - type: 'string', - }, - gradient: { - type: 'string', - }, - width: { - type: 'number', - }, +const v10 = { + attributes: { + url: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'href', }, - supports: { - anchor: true, - align: true, - alignWide: false, - color: { - __experimentalSkipSerialization: true, - gradients: true, - }, - typography: { - fontSize: true, - __experimentalFontFamily: true, - }, - reusable: false, - spacing: { - __experimentalSkipSerialization: true, - padding: [ 'horizontal', 'vertical' ], - __experimentalDefaultControls: { - padding: true, - }, - }, - __experimentalBorder: { - radius: true, - __experimentalSkipSerialization: true, + title: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'title', + }, + text: { + type: 'string', + source: 'html', + selector: 'a', + }, + linkTarget: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'target', + }, + rel: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'rel', + }, + placeholder: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + textColor: { + type: 'string', + }, + gradient: { + type: 'string', + }, + width: { + type: 'number', + }, + }, + supports: { + anchor: true, + align: true, + alignWide: false, + color: { + __experimentalSkipSerialization: true, + gradients: true, + }, + typography: { + fontSize: true, + __experimentalFontFamily: true, + }, + reusable: false, + spacing: { + __experimentalSkipSerialization: true, + padding: [ 'horizontal', 'vertical' ], + __experimentalDefaultControls: { + padding: true, }, - __experimentalSelector: '.wp-block-button__link', }, - save( { attributes, className } ) { - const { - fontSize, - linkTarget, - rel, - style, - text, - title, - url, - width, - } = attributes; - - if ( ! text ) { - return null; + __experimentalBorder: { + radius: true, + __experimentalSkipSerialization: true, + }, + __experimentalSelector: '.wp-block-button__link', + }, + save( { attributes, className } ) { + const { + fontSize, + linkTarget, + rel, + style, + text, + title, + url, + width, + } = attributes; + + if ( ! text ) { + return null; + } + + const borderProps = getBorderClassesAndStyles( attributes ); + const colorProps = getColorClassesAndStyles( attributes ); + const spacingProps = getSpacingClassesAndStyles( attributes ); + const buttonClasses = classnames( + 'wp-block-button__link', + colorProps.className, + borderProps.className, + { + // For backwards compatibility add style that isn't provided via + // block support. + 'no-border-radius': style?.border?.radius === 0, } + ); + const buttonStyle = { + ...borderProps.style, + ...colorProps.style, + ...spacingProps.style, + }; - const borderProps = getBorderClassesAndStyles( attributes ); - const colorProps = getColorClassesAndStyles( attributes ); - const spacingProps = getSpacingClassesAndStyles( attributes ); - const buttonClasses = classnames( - 'wp-block-button__link', - colorProps.className, - borderProps.className, - { - // For backwards compatibility add style that isn't provided via - // block support. - 'no-border-radius': style?.border?.radius === 0, - } - ); - const buttonStyle = { - ...borderProps.style, - ...colorProps.style, - ...spacingProps.style, - }; - - // The use of a `title` attribute here is soft-deprecated, but still applied - // if it had already been assigned, for the sake of backward-compatibility. - // A title will no longer be assigned for new or updated button block links. + // The use of a `title` attribute here is soft-deprecated, but still applied + // if it had already been assigned, for the sake of backward-compatibility. + // A title will no longer be assigned for new or updated button block links. - const wrapperClasses = classnames( className, { - [ `has-custom-width wp-block-button__width-${ width }` ]: width, - [ `has-custom-font-size` ]: - fontSize || style?.typography?.fontSize, - } ); + const wrapperClasses = classnames( className, { + [ `has-custom-width wp-block-button__width-${ width }` ]: width, + [ `has-custom-font-size` ]: fontSize || style?.typography?.fontSize, + } ); - return ( -
    - -
    - ); - }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; - }, + return ( +
    + +
    + ); }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +const deprecated = [ + v10, { supports: { anchor: true, From 12e75bfdf6021a11721f79527544200829347231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 17:37:40 +0200 Subject: [PATCH 68/82] Button: rename fixtures --- ..._family__deprecated.html => core__button__deprecated-v10.html} | 0 ..._family__deprecated.json => core__button__deprecated-v10.json} | 0 ...cated.parsed.json => core__button__deprecated-v10.parsed.json} | 0 ...rialized.html => core__button__deprecated-v10.serialized.html} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/integration/fixtures/blocks/{core__button__font_family__deprecated.html => core__button__deprecated-v10.html} (100%) rename test/integration/fixtures/blocks/{core__button__font_family__deprecated.json => core__button__deprecated-v10.json} (100%) rename test/integration/fixtures/blocks/{core__button__font_family__deprecated.parsed.json => core__button__deprecated-v10.parsed.json} (100%) rename test/integration/fixtures/blocks/{core__button__font_family__deprecated.serialized.html => core__button__deprecated-v10.serialized.html} (100%) diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.html b/test/integration/fixtures/blocks/core__button__deprecated-v10.html similarity index 100% rename from test/integration/fixtures/blocks/core__button__font_family__deprecated.html rename to test/integration/fixtures/blocks/core__button__deprecated-v10.html diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.json b/test/integration/fixtures/blocks/core__button__deprecated-v10.json similarity index 100% rename from test/integration/fixtures/blocks/core__button__font_family__deprecated.json rename to test/integration/fixtures/blocks/core__button__deprecated-v10.json diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json b/test/integration/fixtures/blocks/core__button__deprecated-v10.parsed.json similarity index 100% rename from test/integration/fixtures/blocks/core__button__font_family__deprecated.parsed.json rename to test/integration/fixtures/blocks/core__button__deprecated-v10.parsed.json diff --git a/test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html b/test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html similarity index 100% rename from test/integration/fixtures/blocks/core__button__font_family__deprecated.serialized.html rename to test/integration/fixtures/blocks/core__button__deprecated-v10.serialized.html From 86fecbaecd1e69a21609116399f6335b977a059c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:10:39 +0200 Subject: [PATCH 69/82] Button: add font family migration back to other ones --- .../block-library/src/button/deprecated.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 592b809f481d6..afe8cedbd99fc 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -363,7 +363,7 @@ const deprecated = [ ); }, - migrate: migrateBorderRadius, + migrate: compose( migrateFontFamily, migrateBorderRadius ), }, { supports: { @@ -458,7 +458,7 @@ const deprecated = [ ); }, - migrate: migrateBorderRadius, + migrate: compose( migrateFontFamily, migrateBorderRadius ), }, { supports: { @@ -553,7 +553,7 @@ const deprecated = [ ); }, - migrate: migrateBorderRadius, + migrate: compose( migrateFontFamily, migrateBorderRadius ), }, { supports: { @@ -623,7 +623,7 @@ const deprecated = [ /> ); }, - migrate: migrateBorderRadius, + migrate: compose( migrateFontFamily, migrateBorderRadius ), }, { supports: { @@ -669,12 +669,12 @@ const deprecated = [ type: 'string', }, }, - isEligible: ( attributes ) => !! attributes.customTextColor || !! attributes.customBackgroundColor || !! attributes.customGradient, migrate: compose( + migrateFontFamily, migrateBorderRadius, migrateCustomColorsAndGradients ), @@ -791,12 +791,14 @@ const deprecated = [ .replace( /is-style-squared[\s]?/, '' ) .trim(); } - return migrateBorderRadius( - migrateCustomColorsAndGradients( { - ...attributes, - className: newClassName ? newClassName : undefined, - borderRadius: 0, - } ) + return migrateFontFamily( + migrateBorderRadius( + migrateCustomColorsAndGradients( { + ...attributes, + className: newClassName ? newClassName : undefined, + borderRadius: 0, + } ) + ) ); }, save( { attributes } ) { From cd45d0a85aa355ce6565214ae342fda606ef83ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:22:02 +0200 Subject: [PATCH 70/82] Navigation: extract deprecation and add missing block supports --- .../src/navigation/deprecated.js | 157 +++++++++--------- 1 file changed, 83 insertions(+), 74 deletions(-) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index db07ddfcac8f1..c12b9c02575dc 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -20,85 +20,94 @@ const TYPOGRAPHY_PRESET_DEPRECATION_MAP = { textTransform: 'var:preset|text-transform|', }; -const deprecated = [ - { - attributes: { - orientation: { - type: 'string', - default: 'horizontal', - }, - textColor: { - type: 'string', - }, - customTextColor: { - type: 'string', - }, - rgbTextColor: { - type: 'string', - }, - backgroundColor: { - type: 'string', - }, - customBackgroundColor: { - type: 'string', - }, - rgbBackgroundColor: { - type: 'string', - }, - itemsJustification: { - type: 'string', - }, - showSubmenuIcon: { - type: 'boolean', - default: true, - }, - openSubmenusOnClick: { - type: 'boolean', - default: false, - }, - overlayMenu: { - type: 'string', - default: 'never', - }, - __unstableLocation: { - type: 'string', - }, - overlayBackgroundColor: { - type: 'string', - }, - customOverlayBackgroundColor: { - type: 'string', - }, - overlayTextColor: { - type: 'string', - }, - customOverlayTextColor: { - type: 'string', - }, +const v4 = { + attributes: { + orientation: { + type: 'string', + default: 'horizontal', }, - supports: { - align: [ 'wide', 'full' ], - anchor: true, - html: false, - inserter: true, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontStyle: true, - __experimentalFontWeight: true, - __experimentalTextTransform: true, - __experimentalFontFamily: true, - __experimentalTextDecoration: true, - }, + textColor: { + type: 'string', }, - save() { - return ; + customTextColor: { + type: 'string', + }, + rgbTextColor: { + type: 'string', + }, + backgroundColor: { + type: 'string', + }, + customBackgroundColor: { + type: 'string', }, - migrate: migrateFontFamily, - isEligible( { style } ) { - return style?.typography?.fontFamily; + rgbBackgroundColor: { + type: 'string', }, + itemsJustification: { + type: 'string', + }, + showSubmenuIcon: { + type: 'boolean', + default: true, + }, + openSubmenusOnClick: { + type: 'boolean', + default: false, + }, + overlayMenu: { + type: 'string', + default: 'never', + }, + __unstableLocation: { + type: 'string', + }, + overlayBackgroundColor: { + type: 'string', + }, + customOverlayBackgroundColor: { + type: 'string', + }, + overlayTextColor: { + type: 'string', + }, + customOverlayTextColor: { + type: 'string', + }, + }, + supports: { + align: [ 'wide', 'full' ], + anchor: true, + html: false, + inserter: true, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalTextTransform: true, + __experimentalFontFamily: true, + __experimentalTextDecoration: true, + }, + spacing: { + blockGap: true, + units: [ 'px', 'em', 'rem', 'vh', 'vw' ], + __experimentalDefaultControls: { + blockGap: true, + }, + }, + }, + save() { + return ; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; }, +}; + +const deprecated = [ + v4, // Remove `isResponsive` attribute. { attributes: { From 7c09eed63271e90ecd4a95c6a5ff4895fc402e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:24:48 +0200 Subject: [PATCH 71/82] Navigation: rename test for better consistency --- ...mily__deprecated.html => core__navigation__deprecated-v4.html} | 0 ...mily__deprecated.json => core__navigation__deprecated-v4.json} | 0 ...ed.parsed.json => core__navigation__deprecated-v4.parsed.json} | 0 ...lized.html => core__navigation__deprecated-v4.serialized.html} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/integration/fixtures/blocks/{core__navigation__font_family__deprecated.html => core__navigation__deprecated-v4.html} (100%) rename test/integration/fixtures/blocks/{core__navigation__font_family__deprecated.json => core__navigation__deprecated-v4.json} (100%) rename test/integration/fixtures/blocks/{core__navigation__font_family__deprecated.parsed.json => core__navigation__deprecated-v4.parsed.json} (100%) rename test/integration/fixtures/blocks/{core__navigation__font_family__deprecated.serialized.html => core__navigation__deprecated-v4.serialized.html} (100%) diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html b/test/integration/fixtures/blocks/core__navigation__deprecated-v4.html similarity index 100% rename from test/integration/fixtures/blocks/core__navigation__font_family__deprecated.html rename to test/integration/fixtures/blocks/core__navigation__deprecated-v4.html diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json b/test/integration/fixtures/blocks/core__navigation__deprecated-v4.json similarity index 100% rename from test/integration/fixtures/blocks/core__navigation__font_family__deprecated.json rename to test/integration/fixtures/blocks/core__navigation__deprecated-v4.json diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json b/test/integration/fixtures/blocks/core__navigation__deprecated-v4.parsed.json similarity index 100% rename from test/integration/fixtures/blocks/core__navigation__font_family__deprecated.parsed.json rename to test/integration/fixtures/blocks/core__navigation__deprecated-v4.parsed.json diff --git a/test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html b/test/integration/fixtures/blocks/core__navigation__deprecated-v4.serialized.html similarity index 100% rename from test/integration/fixtures/blocks/core__navigation__font_family__deprecated.serialized.html rename to test/integration/fixtures/blocks/core__navigation__deprecated-v4.serialized.html From e0d5ce7714fd3f7304691811edaa1509158f9d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:31:38 +0200 Subject: [PATCH 72/82] Navigation: add font family migration to older ones --- .../src/navigation/deprecated.js | 70 ++++++++++--------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/packages/block-library/src/navigation/deprecated.js b/packages/block-library/src/navigation/deprecated.js index c12b9c02575dc..aab6a3fed4f82 100644 --- a/packages/block-library/src/navigation/deprecated.js +++ b/packages/block-library/src/navigation/deprecated.js @@ -7,6 +7,7 @@ import { mapValues, omit } from 'lodash'; * WordPress dependencies */ import { InnerBlocks } from '@wordpress/block-editor'; +import { compose } from '@wordpress/compose'; /** * Internal dependencies @@ -106,6 +107,40 @@ const v4 = { }, }; +const migrateIsResponsive = function ( attributes ) { + delete attributes.isResponsive; + return { + ...attributes, + overlayMenu: 'mobile', + }; +}; + +const migrateTypographyPresets = function ( attributes ) { + return { + ...attributes, + style: { + ...attributes.style, + typography: mapValues( + attributes.style.typography, + ( value, key ) => { + const prefix = TYPOGRAPHY_PRESET_DEPRECATION_MAP[ key ]; + if ( prefix && value.startsWith( prefix ) ) { + const newValue = value.slice( prefix.length ); + if ( + 'textDecoration' === key && + 'strikethrough' === newValue + ) { + return 'line-through'; + } + return newValue; + } + return value; + } + ), + }, + }; +}; + const deprecated = [ v4, // Remove `isResponsive` attribute. @@ -182,13 +217,7 @@ const deprecated = [ isEligible( attributes ) { return attributes.isResponsive; }, - migrate( attributes ) { - delete attributes.isResponsive; - return { - ...attributes, - overlayMenu: 'mobile', - }; - }, + migrate: compose( migrateFontFamily, migrateIsResponsive ), save() { return ; }, @@ -258,32 +287,7 @@ const deprecated = [ } return false; }, - migrate( attributes ) { - return { - ...attributes, - style: { - ...attributes.style, - typography: mapValues( - attributes.style.typography, - ( value, key ) => { - const prefix = - TYPOGRAPHY_PRESET_DEPRECATION_MAP[ key ]; - if ( prefix && value.startsWith( prefix ) ) { - const newValue = value.slice( prefix.length ); - if ( - 'textDecoration' === key && - 'strikethrough' === newValue - ) { - return 'line-through'; - } - return newValue; - } - return value; - } - ), - }, - }; - }, + migrate: compose( migrateFontFamily, migrateTypographyPresets ), }, { attributes: { From fc6abd48da075b6d34e9b35429a7595106995c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:33:20 +0200 Subject: [PATCH 73/82] Make deprecation safe to discard --- .../src/utils/migrate-font-family.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/utils/migrate-font-family.js b/packages/block-library/src/utils/migrate-font-family.js index e9135c5555211..bb2108b569fe1 100644 --- a/packages/block-library/src/utils/migrate-font-family.js +++ b/packages/block-library/src/utils/migrate-font-family.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import { cloneDeep } from 'lodash'; + /** * Internal dependencies */ @@ -16,14 +21,17 @@ export default function ( attributes ) { return attributes; } - const fontFamily = attributes.style.typography.fontFamily - .split( '|' ) - .pop(); - delete attributes.style.typography.fontFamily; - attributes.style = cleanEmptyObject( attributes.style ); + // Clone first so when we delete the fontFamily + // below we're not modifying the original + // attributes. Because the deprecation may be discarded + // we don't want to alter the original attributes. + const atts = cloneDeep( attributes ); + const fontFamily = atts.style.typography.fontFamily.split( '|' ).pop(); + delete atts.style.typography.fontFamily; + atts.style = cleanEmptyObject( atts.style ); return { - ...attributes, + ...atts, fontFamily, }; } From 5f25219896039be52bbe43405ba7c2f14982c8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:42:46 +0200 Subject: [PATCH 74/82] Post Comment Author --- .../src/post-comment-author/deprecated.js | 50 +++++++++++++++++++ .../src/post-comment-author/index.js | 2 + ...e__post-comment-author__deprecated-v1.html | 1 + ...e__post-comment-author__deprecated-v1.json | 14 ++++++ ...-comment-author__deprecated-v1.parsed.json | 15 ++++++ ...ment-author__deprecated-v1.serialized.html | 1 + 6 files changed, 83 insertions(+) create mode 100644 packages/block-library/src/post-comment-author/deprecated.js create mode 100644 test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.serialized.html diff --git a/packages/block-library/src/post-comment-author/deprecated.js b/packages/block-library/src/post-comment-author/deprecated.js new file mode 100644 index 0000000000000..0ad1a25bdd268 --- /dev/null +++ b/packages/block-library/src/post-comment-author/deprecated.js @@ -0,0 +1,50 @@ +/** + * Internal dependencies + */ +import migrateFontFamily from '../utils/migrate-font-family'; + +const v1 = { + attributes: { + isLink: { + type: 'boolean', + default: false, + }, + linkTarget: { + type: 'string', + default: '_self', + }, + }, + supports: { + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + __experimentalLetterSpacing: true, + }, + }, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * + * Old deprecations may need to be updated as well. + * + * See block-deprecation.md + */ +export default [ v1 ]; diff --git a/packages/block-library/src/post-comment-author/index.js b/packages/block-library/src/post-comment-author/index.js index e6779fa3ec22a..6285ad906f66a 100644 --- a/packages/block-library/src/post-comment-author/index.js +++ b/packages/block-library/src/post-comment-author/index.js @@ -3,6 +3,7 @@ */ import metadata from './block.json'; import edit from './edit'; +import deprecated from './deprecated'; /** * WordPress dependencies @@ -15,4 +16,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; diff --git a/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.html b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.html new file mode 100644 index 0000000000000..fc634546cb41b --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.json b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.json new file mode 100644 index 0000000000000..bf632aac0e092 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/post-comment-author", + "isValid": true, + "attributes": { + "isLink": false, + "linkTarget": "_self", + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..6948700ab3c0a --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/post-comment-author", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..0812a689f93d1 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-author__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From 62f6302731ccfdcf839b42a2496639a331e916b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:45:49 +0200 Subject: [PATCH 75/82] Post Comment Date --- .../src/post-comment-date/deprecated.js | 49 +++++++++++++++++++ .../src/post-comment-date/index.js | 2 + ...ore__post-comment-date__deprecated-v1.html | 1 + ...ore__post-comment-date__deprecated-v1.json | 13 +++++ ...st-comment-date__deprecated-v1.parsed.json | 15 ++++++ ...omment-date__deprecated-v1.serialized.html | 1 + 6 files changed, 81 insertions(+) create mode 100644 packages/block-library/src/post-comment-date/deprecated.js create mode 100644 test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.serialized.html diff --git a/packages/block-library/src/post-comment-date/deprecated.js b/packages/block-library/src/post-comment-date/deprecated.js new file mode 100644 index 0000000000000..640b831bdeb34 --- /dev/null +++ b/packages/block-library/src/post-comment-date/deprecated.js @@ -0,0 +1,49 @@ +/** + * Internal dependencies + */ +import migrateFontFamily from '../utils/migrate-font-family'; + +const v1 = { + attributes: { + format: { + type: 'string', + }, + isLink: { + type: 'boolean', + default: false, + }, + }, + supports: { + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + __experimentalLetterSpacing: true, + }, + }, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * + * Old deprecations may need to be updated as well. + * + * See block-deprecation.md + */ +export default [ v1 ]; diff --git a/packages/block-library/src/post-comment-date/index.js b/packages/block-library/src/post-comment-date/index.js index 6cba9841dfdfa..c2384da69192d 100644 --- a/packages/block-library/src/post-comment-date/index.js +++ b/packages/block-library/src/post-comment-date/index.js @@ -8,6 +8,7 @@ import { postDate as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -15,4 +16,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; diff --git a/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.html b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.html new file mode 100644 index 0000000000000..aacddd134a90e --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.json b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.json new file mode 100644 index 0000000000000..4c36aac77826d --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/post-comment-date", + "isValid": true, + "attributes": { + "isLink": false, + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..3c83c9b5f5237 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/post-comment-date", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..ce86c427a7829 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-comment-date__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From 240504a597a1b2b02a73cb047ae56c944ccc3b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:48:54 +0200 Subject: [PATCH 76/82] Post Date --- .../block-library/src/post-date/deprecated.js | 52 +++++++++++++++++++ packages/block-library/src/post-date/index.js | 2 + .../core__post-date__deprecated-v1.html | 1 + .../core__post-date__deprecated-v1.json | 13 +++++ ...core__post-date__deprecated-v1.parsed.json | 15 ++++++ ...__post-date__deprecated-v1.serialized.html | 1 + 6 files changed, 84 insertions(+) create mode 100644 packages/block-library/src/post-date/deprecated.js create mode 100644 test/integration/fixtures/blocks/core__post-date__deprecated-v1.html create mode 100644 test/integration/fixtures/blocks/core__post-date__deprecated-v1.json create mode 100644 test/integration/fixtures/blocks/core__post-date__deprecated-v1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__post-date__deprecated-v1.serialized.html diff --git a/packages/block-library/src/post-date/deprecated.js b/packages/block-library/src/post-date/deprecated.js new file mode 100644 index 0000000000000..d217f38bf30ed --- /dev/null +++ b/packages/block-library/src/post-date/deprecated.js @@ -0,0 +1,52 @@ +/** + * Internal dependencies + */ +import migrateFontFamily from '../utils/migrate-font-family'; + +const v1 = { + attributes: { + textAlign: { + type: 'string', + }, + format: { + type: 'string', + }, + isLink: { + type: 'boolean', + default: false, + }, + }, + supports: { + html: false, + color: { + gradients: true, + link: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + __experimentalLetterSpacing: true, + }, + }, + save() { + return null; + }, + migrate: migrateFontFamily, + isEligible( { style } ) { + return style?.typography?.fontFamily; + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * + * Old deprecations may need to be updated as well. + * + * See block-deprecation.md + */ +export default [ v1 ]; diff --git a/packages/block-library/src/post-date/index.js b/packages/block-library/src/post-date/index.js index 6cba9841dfdfa..c2384da69192d 100644 --- a/packages/block-library/src/post-date/index.js +++ b/packages/block-library/src/post-date/index.js @@ -8,6 +8,7 @@ import { postDate as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -15,4 +16,5 @@ export { metadata, name }; export const settings = { icon, edit, + deprecated, }; diff --git a/test/integration/fixtures/blocks/core__post-date__deprecated-v1.html b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.html new file mode 100644 index 0000000000000..43c7c1ad9164c --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__post-date__deprecated-v1.json b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.json new file mode 100644 index 0000000000000..438d03db6b5d0 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/post-date", + "isValid": true, + "attributes": { + "isLink": false, + "fontFamily": "cambria-georgia" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/test/integration/fixtures/blocks/core__post-date__deprecated-v1.parsed.json b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.parsed.json new file mode 100644 index 0000000000000..bea3da7834974 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.parsed.json @@ -0,0 +1,15 @@ +[ + { + "blockName": "core/post-date", + "attrs": { + "style": { + "typography": { + "fontFamily": "var:preset|font-family|cambria-georgia" + } + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__post-date__deprecated-v1.serialized.html b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.serialized.html new file mode 100644 index 0000000000000..f534e3c2cf606 --- /dev/null +++ b/test/integration/fixtures/blocks/core__post-date__deprecated-v1.serialized.html @@ -0,0 +1 @@ + From 19dbeee39b119ec8e814e7b5bd9200f4798e9a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 17:08:50 +0200 Subject: [PATCH 77/82] Add tests and fix legacy code path --- lib/block-supports/typography.php | 9 +-- phpunit/block-supports/typography-test.php | 88 ++++++++++++++++++++++ 2 files changed, 92 insertions(+), 5 deletions(-) diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 62b6680e06ebc..5b60c96a6b2da 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -115,12 +115,11 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { // We don't need this code path when it lands in core. $font_family_custom = $block_attributes['style']['typography']['fontFamily']; if ( strpos( $font_family_custom, 'var:preset|font-family' ) !== false ) { - $index_to_splice = strrpos( $font_family_custom, '|' ) + 1; - $font_family_slug = substr( $font_family_custom, $index_to_splice ); - $classes[] = sprintf( 'has-%s-font-family', $font_family_slug ); - } else { - $styles[] = sprintf( 'font-family: %s;', $font_family_custom ); + $index_to_splice = strrpos( $font_family_custom, '|' ) + 1; + $font_family_slug = gutenberg_experimental_to_kebab_case( substr( $font_family_custom, $index_to_splice ) ); + $font_family_custom = sprintf( 'var(--wp--preset--font-family--%s)', $font_family_slug ); } + $styles[] = sprintf( 'font-family: %s;', $font_family_custom ); } } diff --git a/phpunit/block-supports/typography-test.php b/phpunit/block-supports/typography-test.php index a6015273d097d..dbca89457a209 100644 --- a/phpunit/block-supports/typography-test.php +++ b/phpunit/block-supports/typography-test.php @@ -36,4 +36,92 @@ function test_font_size_slug_with_numbers_is_kebab_cased_properly() { $this->assertSame( $expected, $actual ); unregister_block_type( 'test/font-size-slug-with-numbers' ); } + + function test_font_family_with_legacy_inline_styles_using_a_value() { + $block_name = 'test/font-family-with-inline-styles-using-value'; + register_block_type( + $block_name, + array( + 'api_version' => 2, + 'attributes' => array( + 'style' => array( + 'type' => 'object', + ), + ), + 'supports' => array( + 'typography' => array( + '__experimentalFontFamily' => true, + ), + ), + ) + ); + $registry = WP_Block_Type_Registry::get_instance(); + $block_type = $registry->get_registered( $block_name ); + $block_atts = array( 'style' => array( 'typography' => array( 'fontFamily' => 'serif' ) ) ); + + $actual = gutenberg_apply_typography_support( $block_type, $block_atts ); + $expected = array( 'style' => 'font-family: serif;' ); + + $this->assertSame( $expected, $actual ); + unregister_block_type( $block_name ); + } + + function test_font_family_with_legacy_inline_styles_using_a_css_var() { + $block_name = 'test/font-family-with-inline-styles-using-css-var'; + register_block_type( + $block_name, + array( + 'api_version' => 2, + 'attributes' => array( + 'style' => array( + 'type' => 'object', + ), + ), + 'supports' => array( + 'typography' => array( + '__experimentalFontFamily' => true, + ), + ), + ) + ); + $registry = WP_Block_Type_Registry::get_instance(); + $block_type = $registry->get_registered( $block_name ); + $block_atts = array( 'style' => array( 'typography' => array( 'fontFamily' => 'var:preset|font-family|h1' ) ) ); + + $actual = gutenberg_apply_typography_support( $block_type, $block_atts ); + $expected = array( 'style' => 'font-family: var(--wp--preset--font-family--h-1);' ); + + $this->assertSame( $expected, $actual ); + unregister_block_type( $block_name ); + } + + function test_font_family_with_class() { + $block_name = 'test/font-family-with-class'; + register_block_type( + $block_name, + array( + 'api_version' => 2, + 'attributes' => array( + 'style' => array( + 'type' => 'object', + ), + ), + 'supports' => array( + 'typography' => array( + '__experimentalFontFamily' => true, + ), + ), + ) + ); + $registry = WP_Block_Type_Registry::get_instance(); + $block_type = $registry->get_registered( $block_name ); + $block_atts = array( 'fontFamily' => 'h1' ); + + $actual = gutenberg_apply_typography_support( $block_type, $block_atts ); + $expected = array( 'class' => 'has-h-1-font-family' ); + + $this->assertSame( $expected, $actual ); + unregister_block_type( $block_name ); + } + } From 0ccce1fc7ccb7bb3116e6c65fe71422889290511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 17:29:42 +0200 Subject: [PATCH 78/82] Button: revert unnecessary font family migration --- packages/block-library/src/button/deprecated.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index afe8cedbd99fc..1a97aedf80a49 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -791,14 +791,12 @@ const deprecated = [ .replace( /is-style-squared[\s]?/, '' ) .trim(); } - return migrateFontFamily( - migrateBorderRadius( - migrateCustomColorsAndGradients( { - ...attributes, - className: newClassName ? newClassName : undefined, - borderRadius: 0, - } ) - ) + return migrateBorderRadius( + migrateCustomColorsAndGradients( { + ...attributes, + className: newClassName ? newClassName : undefined, + borderRadius: 0, + } ) ); }, save( { attributes } ) { From 3ab2ae2722e1ec7466a7cca2d1b9ac27f3400854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 17:32:26 +0200 Subject: [PATCH 79/82] Button: revert unnecessary font family migration --- packages/block-library/src/button/deprecated.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index 1a97aedf80a49..fda9e1dad10f0 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -674,7 +674,6 @@ const deprecated = [ !! attributes.customBackgroundColor || !! attributes.customGradient, migrate: compose( - migrateFontFamily, migrateBorderRadius, migrateCustomColorsAndGradients ), From f6e54f26c1a2f2f43688d8273dbced9e734f6227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 20 Oct 2021 17:34:52 +0200 Subject: [PATCH 80/82] Button: revert unnecessary font family migration --- packages/block-library/src/button/deprecated.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/button/deprecated.js b/packages/block-library/src/button/deprecated.js index fda9e1dad10f0..3e86f0a398161 100644 --- a/packages/block-library/src/button/deprecated.js +++ b/packages/block-library/src/button/deprecated.js @@ -623,7 +623,7 @@ const deprecated = [ /> ); }, - migrate: compose( migrateFontFamily, migrateBorderRadius ), + migrate: migrateBorderRadius, }, { supports: { From c65cf6e254c87915ad0b3cf0ce2c5783c0a5f9c2 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 20 Oct 2021 17:59:26 +0200 Subject: [PATCH 81/82] Post Title block deprecation: Add spacing supports (sync from block.json) --- packages/block-library/src/post-title/deprecated.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-library/src/post-title/deprecated.js b/packages/block-library/src/post-title/deprecated.js index 06bdae083461d..e53606027c7bb 100644 --- a/packages/block-library/src/post-title/deprecated.js +++ b/packages/block-library/src/post-title/deprecated.js @@ -33,6 +33,9 @@ const v1 = { gradients: true, link: true, }, + spacing: { + margin: true, + }, typography: { fontSize: true, lineHeight: true, From 99b4a9f56fd35027e39285a4e2847b165c15906a Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 20 Oct 2021 18:00:29 +0200 Subject: [PATCH 82/82] Query Title block deprecation: Add spacing supports (sync from block.json) --- packages/block-library/src/query-title/deprecated.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-library/src/query-title/deprecated.js b/packages/block-library/src/query-title/deprecated.js index 2f54913ecfaac..1a80d5dfe9040 100644 --- a/packages/block-library/src/query-title/deprecated.js +++ b/packages/block-library/src/query-title/deprecated.js @@ -22,6 +22,9 @@ const v1 = { color: { gradients: true, }, + spacing: { + margin: true, + }, typography: { fontSize: true, lineHeight: true,