From b2573a631ae283663675a29029b5edb7b0d0a078 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Tue, 6 Jan 2026 19:23:08 +0900 Subject: [PATCH 01/11] Heading: Migrate to text-align block support --- docs/reference-guides/core-blocks.md | 4 +- packages/block-editor/src/hooks/text-align.js | 30 +++++ packages/block-library/src/heading/block.json | 4 +- .../block-library/src/heading/deprecated.js | 123 +++++++++++++++++- packages/block-library/src/heading/edit.js | 38 +----- .../block-library/src/heading/edit.native.js | 19 ++- packages/block-library/src/heading/save.js | 13 +- .../block-library/src/heading/transforms.js | 21 ++- .../blocks/core__heading__deprecated-1.json | 6 +- ...ore__heading__deprecated-1.serialized.html | 2 +- .../blocks/core__heading__deprecated-4.html | 1 - .../blocks/core__heading__deprecated-4.json | 6 +- ...ore__heading__deprecated-4.serialized.html | 2 +- .../blocks/core__heading__deprecated-5.json | 8 +- ...ore__heading__deprecated-5.serialized.html | 2 +- .../blocks/core__heading__deprecated-6.html | 3 + .../blocks/core__heading__deprecated-6.json | 17 +++ .../core__heading__deprecated-6.parsed.json | 18 +++ ...ore__heading__deprecated-6.serialized.html | 3 + .../blocks/core__heading_align-textalign.json | 8 +- ...e__heading_align-textalign.serialized.html | 4 +- ...heading_align-textalign__deprecated-1.html | 3 + ...heading_align-textalign__deprecated-1.json | 17 +++ ..._align-textalign__deprecated-1.parsed.json | 18 +++ ...gn-textalign__deprecated-1.serialized.html | 3 + 25 files changed, 294 insertions(+), 79 deletions(-) create mode 100644 test/integration/fixtures/blocks/core__heading__deprecated-6.html create mode 100644 test/integration/fixtures/blocks/core__heading__deprecated-6.json create mode 100644 test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json create mode 100644 test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html create mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html create mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json create mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json create mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index c5f9bc516f9524..5d20a691b1de40 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -408,8 +408,8 @@ Introduce new sections and organize content to help visitors (and search engines - **Name:** core/heading - **Category:** text -- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, className, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight) -- **Attributes:** content, level, levelOptions, placeholder, textAlign +- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, className, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight, textAlign) +- **Attributes:** content, level, levelOptions, placeholder ## Home Link diff --git a/packages/block-editor/src/hooks/text-align.js b/packages/block-editor/src/hooks/text-align.js index af20404d79eccf..134a8ba63313f3 100644 --- a/packages/block-editor/src/hooks/text-align.js +++ b/packages/block-editor/src/hooks/text-align.js @@ -9,6 +9,7 @@ import clsx from 'clsx'; import { __ } from '@wordpress/i18n'; import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks'; import { alignLeft, alignRight, alignCenter } from '@wordpress/icons'; +import { addFilter } from '@wordpress/hooks'; /** * Internal dependencies @@ -19,6 +20,7 @@ import { cleanEmptyObject, shouldSkipSerialization, useBlockSettings, + transformStyles, } from './utils'; import { TYPOGRAPHY_SUPPORT_KEY } from './typography'; @@ -182,3 +184,31 @@ export function addAssignedTextAlign( props, blockType, attributes ) { } return props; } + +const MIGRATION_PATHS = { + textAlign: [ [ 'style', 'typography', 'textAlign' ] ], +}; + +function addTransforms( result, source, index, results ) { + const destinationBlockType = result.name; + const activeSupports = { + textAlign: hasBlockSupport( + destinationBlockType, + TEXT_ALIGN_SUPPORT_KEY + ), + }; + return transformStyles( + activeSupports, + MIGRATION_PATHS, + result, + source, + index, + results + ); +} + +addFilter( + 'blocks.switchToBlockType.transformedBlock', + 'core/text-align/addTransforms', + addTransforms +); diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index d9488a3156528d..7bc491e1658b1b 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -8,9 +8,6 @@ "keywords": [ "title", "subtitle" ], "textdomain": "default", "attributes": { - "textAlign": { - "type": "string" - }, "content": { "type": "rich-text", "source": "rich-text", @@ -58,6 +55,7 @@ "typography": { "fontSize": true, "lineHeight": true, + "textAlign": true, "__experimentalFontFamily": true, "__experimentalFontStyle": true, "__experimentalFontWeight": true, diff --git a/packages/block-library/src/heading/deprecated.js b/packages/block-library/src/heading/deprecated.js index 76b175ac44fc40..fee6c00c325d97 100644 --- a/packages/block-library/src/heading/deprecated.js +++ b/packages/block-library/src/heading/deprecated.js @@ -12,6 +12,11 @@ import { useBlockProps, } from '@wordpress/block-editor'; +/** + * Internal dependencies + */ +import migrateTextAlignV2 from '../utils/migrate-text-align'; + const blockSupports = { className: false, anchor: true, @@ -75,7 +80,9 @@ const v1 = { }, }, migrate: ( attributes ) => - migrateCustomColors( migrateTextAlign( attributes ) ), + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), save( { attributes } ) { const { align, level, content, textColor, customTextColor } = attributes; @@ -111,7 +118,9 @@ const v2 = { }, }, migrate: ( attributes ) => - migrateCustomColors( migrateTextAlign( attributes ) ), + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), save( { attributes } ) { const { align, content, customTextColor, level, textColor } = attributes; @@ -149,7 +158,9 @@ const v3 = { }, }, migrate: ( attributes ) => - migrateCustomColors( migrateTextAlign( attributes ) ), + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), save( { attributes } ) { const { align, content, customTextColor, level, textColor } = attributes; @@ -195,7 +206,10 @@ const v4 = { }, attributes: blockAttributes, isEligible: ( { align } ) => TEXT_ALIGN_OPTIONS.includes( align ), - migrate: migrateTextAlign, + migrate: ( attributes ) => + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), save( { attributes } ) { const { align, content, level } = attributes; const TagName = 'h' + level; @@ -283,8 +297,107 @@ const v5 = { ); }, + migrate: ( attributes ) => + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), +}; + +const v6 = { + supports: { + align: [ 'wide', 'full' ], + anchor: true, + className: true, + splitting: true, + __experimentalBorder: { + color: true, + radius: true, + style: true, + width: true, + }, + color: { + gradients: true, + link: true, + __experimentalDefaultControls: { + background: true, + text: true, + }, + }, + spacing: { + margin: true, + padding: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalLetterSpacing: true, + __experimentalTextTransform: true, + __experimentalTextDecoration: true, + __experimentalWritingMode: true, + fitText: true, + __experimentalDefaultControls: { + fontSize: true, + }, + }, + __unstablePasteTextInline: true, + __experimentalSlashInserter: true, + interactivity: { + clientNavigation: true, + }, + }, + attributes: { + textAlign: { + type: 'string', + }, + content: { + type: 'string', + source: 'html', + selector: 'h1,h2,h3,h4,h5,h6', + default: '', + role: 'content', + }, + level: { + type: 'number', + default: 2, + }, + levelOptions: { + type: 'array', + }, + placeholder: { + type: 'string', + }, + }, + save( { attributes } ) { + const { textAlign, content, level } = attributes; + const TagName = 'h' + level; + + const className = clsx( { + [ `has-text-align-${ textAlign }` ]: textAlign, + } ); + + return ( + + + + ); + }, + migrate: ( attributes ) => + migrateTextAlignV2( + migrateCustomColors( migrateTextAlign( attributes ) ) + ), + isEligible( attributes ) { + return ( + !! attributes.textAlign || + !! attributes.className?.match( + /\bhas-text-align-(left|center|right)\b/ + ) + ); + }, }; -const deprecated = [ v5, v4, v3, v2, v1 ]; +const deprecated = [ v6, v5, v4, v3, v2, v1 ]; export default deprecated; diff --git a/packages/block-library/src/heading/edit.js b/packages/block-library/src/heading/edit.js index 636e200c425b92..71ab835c9796b4 100644 --- a/packages/block-library/src/heading/edit.js +++ b/packages/block-library/src/heading/edit.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import clsx from 'clsx'; - /** * WordPress dependencies */ @@ -10,36 +5,26 @@ import { __ } from '@wordpress/i18n'; import { useEffect, Platform } from '@wordpress/element'; import { useDispatch, useSelect } from '@wordpress/data'; import { - AlignmentControl, - BlockControls, RichText, useBlockProps, store as blockEditorStore, - useBlockEditingMode, } from '@wordpress/block-editor'; /** * Internal dependencies */ import { generateAnchor, setAnchor } from './autogenerate-anchors'; +import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes'; -function HeadingEdit( { - attributes, - setAttributes, - mergeBlocks, - onReplace, - style, - clientId, -} ) { - const { textAlign, content, level, placeholder, anchor } = attributes; +function HeadingEdit( props ) { + const { attributes, setAttributes, mergeBlocks, onReplace, clientId } = + props; + useDeprecatedTextAlign( props ); + const { style, content, level, placeholder, anchor } = attributes; const tagName = 'h' + level; const blockProps = useBlockProps( { - className: clsx( { - [ `has-text-align-${ textAlign }` ]: textAlign, - } ), style, } ); - const blockEditingMode = useBlockEditingMode(); const { canGenerateAnchors } = useSelect( ( select ) => { const { getGlobalBlockCount, getSettings } = select( blockEditorStore ); @@ -90,16 +75,6 @@ function HeadingEdit( { return ( <> - { blockEditingMode === 'default' && ( - - { - setAttributes( { textAlign: nextAlign } ); - } } - /> - - ) } onReplace( [] ) } placeholder={ placeholder || __( 'Heading' ) } - textAlign={ textAlign } { ...( Platform.isNative && { deleteEnter: true } ) } // setup RichText on native mobile to delete the "Enter" key as it's handled by the JS/RN side { ...blockProps } /> diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index 0946fe5a5ad66b..aaad1f02914473 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -32,7 +32,14 @@ function HeadingEdit( { style, clientId, } ) { - const { textAlign, content, level, placeholder, anchor } = attributes; + const { + content, + level, + placeholder, + anchor, + style: attributesStyle, + } = attributes; + const textAlign = attributesStyle?.typography?.textAlign; const tagName = 'h' + level; const blockProps = useBlockProps( { className: clsx( { @@ -100,7 +107,15 @@ function HeadingEdit( { { - setAttributes( { textAlign: nextAlign } ); + setAttributes( { + style: { + ...attributesStyle, + typography: { + ...attributesStyle?.typography, + textAlign: nextAlign, + }, + }, + } ); } } /> diff --git a/packages/block-library/src/heading/save.js b/packages/block-library/src/heading/save.js index 8ae4fa6afd9f6f..f27c851b28d58d 100644 --- a/packages/block-library/src/heading/save.js +++ b/packages/block-library/src/heading/save.js @@ -1,23 +1,14 @@ -/** - * External dependencies - */ -import clsx from 'clsx'; - /** * WordPress dependencies */ import { RichText, useBlockProps } from '@wordpress/block-editor'; export default function save( { attributes } ) { - const { textAlign, content, level } = attributes; + const { content, level } = attributes; const TagName = 'h' + level; - const className = clsx( { - [ `has-text-align-${ textAlign }` ]: textAlign, - } ); - return ( - + ); diff --git a/packages/block-library/src/heading/transforms.js b/packages/block-library/src/heading/transforms.js index 265ee63567d82b..27a8af02d8f404 100644 --- a/packages/block-library/src/heading/transforms.js +++ b/packages/block-library/src/heading/transforms.js @@ -17,8 +17,7 @@ const transforms = { blocks: [ 'core/paragraph' ], transform: ( attributes ) => attributes.map( ( _attributes ) => { - const { content, anchor, style } = _attributes; - const textAlign = style?.typography?.textAlign; + const { content, anchor } = _attributes; return createBlock( 'core/heading', { ...getTransformedAttributes( _attributes, @@ -29,7 +28,6 @@ const transforms = { ), content, anchor, - textAlign, } ); } ), }, @@ -64,7 +62,13 @@ const transforms = { textAlign === 'center' || textAlign === 'right' ) { - attributes.align = textAlign; + attributes.style = { + ...attributes.style, + typography: { + ...attributes.style?.typography, + textAlign, + }, + }; } return createBlock( 'core/heading', attributes ); @@ -93,7 +97,7 @@ const transforms = { blocks: [ 'core/paragraph' ], transform: ( attributes ) => attributes.map( ( _attributes ) => { - const { content, textAlign } = _attributes; + const { content } = _attributes; return createBlock( 'core/paragraph', { ...getTransformedAttributes( _attributes, @@ -103,13 +107,6 @@ const transforms = { } ) ), content, - ...( textAlign && { - style: { - typography: { - textAlign, - }, - }, - } ), } ); } ), }, diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-1.json b/test/integration/fixtures/blocks/core__heading__deprecated-1.json index 3a07b26aaf4aa7..ea57307f023f6e 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-1.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-1.json @@ -5,7 +5,11 @@ "attributes": { "content": "A picture is worth a thousand words, or so the saying goes", "level": 3, - "textAlign": "right" + "style": { + "typography": { + "textAlign": "right" + } + } }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-1.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-1.serialized.html index a064b6f60cf049..0a51a3491cf734 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-1.serialized.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-1.serialized.html @@ -1,3 +1,3 @@ - +

A picture is worth a thousand words, or so the saying goes

diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-4.html b/test/integration/fixtures/blocks/core__heading__deprecated-4.html index a58b0045187c12..9cb98d7830a196 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-4.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-4.html @@ -1,4 +1,3 @@

Text

- diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-4.json b/test/integration/fixtures/blocks/core__heading__deprecated-4.json index 6df62f0a1646a7..fa1c680bac3319 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-4.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-4.json @@ -6,7 +6,11 @@ "content": "Text", "level": 2, "textColor": "accent", - "textAlign": "center" + "style": { + "typography": { + "textAlign": "center" + } + } }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-4.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-4.serialized.html index cc4218e776a73a..7a1759ff5f68a6 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-4.serialized.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-4.serialized.html @@ -1,3 +1,3 @@ - +

Text

diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-5.json b/test/integration/fixtures/blocks/core__heading__deprecated-5.json index 64c89ad0cd9793..dcb2b63f484bb2 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-5.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-5.json @@ -3,10 +3,14 @@ "name": "core/heading", "isValid": true, "attributes": { - "textAlign": "right", "content": "Text", "level": 2, - "textColor": "primary" + "textColor": "primary", + "style": { + "typography": { + "textAlign": "right" + } + } }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-5.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-5.serialized.html index a81affa226f771..c561e3e87d0d1d 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-5.serialized.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-5.serialized.html @@ -1,3 +1,3 @@ - +

Text

diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.html new file mode 100644 index 00000000000000..54f2005ddab2fb --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.html @@ -0,0 +1,3 @@ + +

Text

+ \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.json new file mode 100644 index 00000000000000..dcb2b63f484bb2 --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.json @@ -0,0 +1,17 @@ +[ + { + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "Text", + "level": 2, + "textColor": "primary", + "style": { + "typography": { + "textAlign": "right" + } + } + }, + "innerBlocks": [] + } +] diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json new file mode 100644 index 00000000000000..3dadace838502f --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/heading", + "attrs": { + "style": { + "typography": { + "textAlign": "right" + } + }, + "textColor": "primary" + }, + "innerBlocks": [], + "innerHTML": "\n

Text

\n", + "innerContent": [ + "\n

Text

\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html new file mode 100644 index 00000000000000..c561e3e87d0d1d --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html @@ -0,0 +1,3 @@ + +

Text

+ diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign.json b/test/integration/fixtures/blocks/core__heading_align-textalign.json index d4bd2d918ba7ed..772e846de8802f 100644 --- a/test/integration/fixtures/blocks/core__heading_align-textalign.json +++ b/test/integration/fixtures/blocks/core__heading_align-textalign.json @@ -3,10 +3,14 @@ "name": "core/heading", "isValid": true, "attributes": { - "textAlign": "center", "content": "Text", "level": 2, - "align": "wide" + "align": "wide", + "style": { + "typography": { + "textAlign": "center" + } + } }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign.serialized.html b/test/integration/fixtures/blocks/core__heading_align-textalign.serialized.html index 3f7fb12335b4b8..11cb955af74fd8 100644 --- a/test/integration/fixtures/blocks/core__heading_align-textalign.serialized.html +++ b/test/integration/fixtures/blocks/core__heading_align-textalign.serialized.html @@ -1,3 +1,3 @@ - -

Text

+ +

Text

diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html new file mode 100644 index 00000000000000..9b7e0a85a54c58 --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html @@ -0,0 +1,3 @@ + +

Text

+ \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json new file mode 100644 index 00000000000000..772e846de8802f --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json @@ -0,0 +1,17 @@ +[ + { + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "Text", + "level": 2, + "align": "wide", + "style": { + "typography": { + "textAlign": "center" + } + } + }, + "innerBlocks": [] + } +] diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json new file mode 100644 index 00000000000000..338fa8605b4c8a --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/heading", + "attrs": { + "align": "wide", + "style": { + "typography": { + "textAlign": "center" + } + } + }, + "innerBlocks": [], + "innerHTML": "\n

Text

\n", + "innerContent": [ + "\n

Text

\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html new file mode 100644 index 00000000000000..11cb955af74fd8 --- /dev/null +++ b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html @@ -0,0 +1,3 @@ + +

Text

+ From 28b496545e6ef8b6484280e44ec60072cdeed9bb Mon Sep 17 00:00:00 2001 From: shimotmk Date: Tue, 6 Jan 2026 20:33:01 +0900 Subject: [PATCH 02/11] update attributes --- test/e2e/specs/editor/blocks/heading.spec.js | 14 ++++++++++---- .../specs/editor/various/splitting-merging.spec.js | 8 +++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/editor/blocks/heading.spec.js b/test/e2e/specs/editor/blocks/heading.spec.js index 7ffbf6490f0809..2b03db6a146344 100644 --- a/test/e2e/specs/editor/blocks/heading.spec.js +++ b/test/e2e/specs/editor/blocks/heading.spec.js @@ -265,8 +265,10 @@ test.describe( 'Heading', () => { name: 'core/heading', attributes: { content: 'Heading', - textAlign: 'center', level: 4, + style: { + typography: { textAlign: 'center' }, + }, }, }, ] ); @@ -298,8 +300,10 @@ test.describe( 'Heading', () => { name: 'core/heading', attributes: { content: 'Paragraph', - textAlign: 'center', level: 2, + style: { + typography: { textAlign: 'center' }, + }, }, }, ] ); @@ -425,7 +429,9 @@ test.describe( 'Heading', () => { await editor.transformBlockTo( 'core/heading' ); const headingBlock = ( await editor.getBlocks() )[ 0 ]; expect( headingBlock.name ).toBe( 'core/heading' ); - expect( headingBlock.attributes.textAlign ).toBe( 'right' ); + expect( + headingBlock.attributes.style.typography.textAlign + ).toBe( 'right' ); } ); test( 'should preserve the metadata attribute', async ( { @@ -507,8 +513,8 @@ test.describe( 'Heading', () => { await editor.insertBlock( { name: 'core/heading', attributes: { - textAlign: 'right', content: 'initial content', + style: { typography: { textAlign: 'right' } }, }, } ); await editor.transformBlockTo( 'core/paragraph' ); diff --git a/test/e2e/specs/editor/various/splitting-merging.spec.js b/test/e2e/specs/editor/various/splitting-merging.spec.js index dcbf989869405b..b0080faf4761e0 100644 --- a/test/e2e/specs/editor/various/splitting-merging.spec.js +++ b/test/e2e/specs/editor/various/splitting-merging.spec.js @@ -391,7 +391,13 @@ test.describe( 'splitting and merging blocks (@firefox, @webkit)', () => { }; const emptyAlignedHeading = { name: 'core/heading', - attributes: { content: '', textAlign: 'center', level: 2 }, + attributes: { + content: '', + level: 2, + style: { + typography: { textAlign: 'center' }, + }, + }, innerBlocks: [], }; const headingWithContent = { From cfb8c4e45fb2dc814834ed9f867e89c83264d124 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Wed, 7 Jan 2026 19:51:44 +0900 Subject: [PATCH 03/11] update transform --- .../block-library/src/heading/transforms.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/heading/transforms.js b/packages/block-library/src/heading/transforms.js index 27a8af02d8f404..3554f52ff27387 100644 --- a/packages/block-library/src/heading/transforms.js +++ b/packages/block-library/src/heading/transforms.js @@ -17,7 +17,8 @@ const transforms = { blocks: [ 'core/paragraph' ], transform: ( attributes ) => attributes.map( ( _attributes ) => { - const { content, anchor } = _attributes; + const { content, anchor, style } = _attributes; + const textAlign = style?.typography?.textAlign; return createBlock( 'core/heading', { ...getTransformedAttributes( _attributes, @@ -28,6 +29,13 @@ const transforms = { ), content, anchor, + ...( textAlign && { + style: { + typography: { + textAlign, + }, + }, + } ), } ); } ), }, @@ -97,7 +105,8 @@ const transforms = { blocks: [ 'core/paragraph' ], transform: ( attributes ) => attributes.map( ( _attributes ) => { - const { content } = _attributes; + const { content, style } = _attributes; + const textAlign = style?.typography?.textAlign; return createBlock( 'core/paragraph', { ...getTransformedAttributes( _attributes, @@ -107,6 +116,13 @@ const transforms = { } ) ), content, + ...( textAlign && { + style: { + typography: { + textAlign, + }, + }, + } ), } ); } ), }, From bae9c34c6ad088a11a131fbc80c29d0e97a090c2 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Wed, 7 Jan 2026 21:59:35 +0900 Subject: [PATCH 04/11] update shortcut --- .../src/block-keyboard-shortcuts/index.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/block-library/src/block-keyboard-shortcuts/index.js b/packages/block-library/src/block-keyboard-shortcuts/index.js index f71ab0b2f7c1e0..af28db1afe43a7 100644 --- a/packages/block-library/src/block-keyboard-shortcuts/index.js +++ b/packages/block-library/src/block-keyboard-shortcuts/index.js @@ -54,15 +54,7 @@ function BlockKeyboardShortcuts() { const sourceTextAlign = attributes.textAlign || attributes.style?.typography?.textAlign; - // When destination is heading, preserve heading format (textAlign attribute + level) - // When destination is paragraph, use block support format (style.typography.textAlign) - if ( destinationBlockName === 'core/heading' ) { - newAttributes.level = level; - if ( sourceTextAlign ) { - newAttributes.textAlign = sourceTextAlign; - } - } else if ( sourceTextAlign ) { - // Destination is paragraph + if ( sourceTextAlign ) { newAttributes.style = { typography: { textAlign: sourceTextAlign, From 98055574df83355e4e325d29850fa630a16136fa Mon Sep 17 00:00:00 2001 From: shimotmk Date: Wed, 7 Jan 2026 22:23:56 +0900 Subject: [PATCH 05/11] add level --- packages/block-library/src/block-keyboard-shortcuts/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/block-library/src/block-keyboard-shortcuts/index.js b/packages/block-library/src/block-keyboard-shortcuts/index.js index af28db1afe43a7..295bda6441cf38 100644 --- a/packages/block-library/src/block-keyboard-shortcuts/index.js +++ b/packages/block-library/src/block-keyboard-shortcuts/index.js @@ -54,6 +54,11 @@ function BlockKeyboardShortcuts() { const sourceTextAlign = attributes.textAlign || attributes.style?.typography?.textAlign; + // When destination is heading, set the level + if ( destinationBlockName === 'core/heading' ) { + newAttributes.level = level; + } + if ( sourceTextAlign ) { newAttributes.style = { typography: { From 561dbbfad6cda9b0ea164d4c74e0c2e55537bbe5 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Thu, 8 Jan 2026 08:17:46 +0900 Subject: [PATCH 06/11] revert hook --- packages/block-editor/src/hooks/text-align.js | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/packages/block-editor/src/hooks/text-align.js b/packages/block-editor/src/hooks/text-align.js index 134a8ba63313f3..af20404d79eccf 100644 --- a/packages/block-editor/src/hooks/text-align.js +++ b/packages/block-editor/src/hooks/text-align.js @@ -9,7 +9,6 @@ import clsx from 'clsx'; import { __ } from '@wordpress/i18n'; import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks'; import { alignLeft, alignRight, alignCenter } from '@wordpress/icons'; -import { addFilter } from '@wordpress/hooks'; /** * Internal dependencies @@ -20,7 +19,6 @@ import { cleanEmptyObject, shouldSkipSerialization, useBlockSettings, - transformStyles, } from './utils'; import { TYPOGRAPHY_SUPPORT_KEY } from './typography'; @@ -184,31 +182,3 @@ export function addAssignedTextAlign( props, blockType, attributes ) { } return props; } - -const MIGRATION_PATHS = { - textAlign: [ [ 'style', 'typography', 'textAlign' ] ], -}; - -function addTransforms( result, source, index, results ) { - const destinationBlockType = result.name; - const activeSupports = { - textAlign: hasBlockSupport( - destinationBlockType, - TEXT_ALIGN_SUPPORT_KEY - ), - }; - return transformStyles( - activeSupports, - MIGRATION_PATHS, - result, - source, - index, - results - ); -} - -addFilter( - 'blocks.switchToBlockType.transformedBlock', - 'core/text-align/addTransforms', - addTransforms -); From b6d9458dd52051520df1585a25d74d60ae84ebc6 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Fri, 9 Jan 2026 20:06:25 +0900 Subject: [PATCH 07/11] update deprecated --- .../block-library/src/heading/deprecated.js | 14 +++--- .../blocks/core__heading__deprecated-6.html | 12 ++++- .../blocks/core__heading__deprecated-6.json | 32 +++++++++++- .../core__heading__deprecated-6.parsed.json | 50 ++++++++++++++++++- ...ore__heading__deprecated-6.serialized.html | 10 +++- ...heading_align-textalign__deprecated-1.html | 3 -- ...heading_align-textalign__deprecated-1.json | 17 ------- ..._align-textalign__deprecated-1.parsed.json | 18 ------- ...gn-textalign__deprecated-1.serialized.html | 3 -- 9 files changed, 105 insertions(+), 54 deletions(-) delete mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html delete mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json delete mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json delete mode 100644 test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html diff --git a/packages/block-library/src/heading/deprecated.js b/packages/block-library/src/heading/deprecated.js index fee6c00c325d97..50036ef13897da 100644 --- a/packages/block-library/src/heading/deprecated.js +++ b/packages/block-library/src/heading/deprecated.js @@ -15,7 +15,7 @@ import { /** * Internal dependencies */ -import migrateTextAlignV2 from '../utils/migrate-text-align'; +import migrateTextAlignAttributeToBlockSupport from '../utils/migrate-text-align'; const blockSupports = { className: false, @@ -80,7 +80,7 @@ const v1 = { }, }, migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), save( { attributes } ) { @@ -118,7 +118,7 @@ const v2 = { }, }, migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), save( { attributes } ) { @@ -158,7 +158,7 @@ const v3 = { }, }, migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), save( { attributes } ) { @@ -207,7 +207,7 @@ const v4 = { attributes: blockAttributes, isEligible: ( { align } ) => TEXT_ALIGN_OPTIONS.includes( align ), migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), save( { attributes } ) { @@ -298,7 +298,7 @@ const v5 = { ); }, migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), }; @@ -385,7 +385,7 @@ const v6 = { ); }, migrate: ( attributes ) => - migrateTextAlignV2( + migrateTextAlignAttributeToBlockSupport( migrateCustomColors( migrateTextAlign( attributes ) ) ), isEligible( attributes ) { diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.html index 54f2005ddab2fb..04aefeeb423e62 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.html @@ -1,3 +1,11 @@ -

Text

- \ No newline at end of file +

Text 1

+ + + +

Text 2

+ + + +

Text

+ diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.json index dcb2b63f484bb2..7c20a78ecc53cd 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.json @@ -3,7 +3,7 @@ "name": "core/heading", "isValid": true, "attributes": { - "content": "Text", + "content": "Text 1", "level": 2, "textColor": "primary", "style": { @@ -13,5 +13,35 @@ } }, "innerBlocks": [] + }, + { + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "Text 2", + "level": 2, + "textColor": "primary", + "style": { + "typography": { + "textAlign": "center" + } + } + }, + "innerBlocks": [] + }, + { + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "Text", + "level": 2, + "textColor": "primary", + "style": { + "typography": { + "textAlign": "left" + } + } + }, + "innerBlocks": [] } ] diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json index 3dadace838502f..3445229312c456 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json @@ -10,9 +10,55 @@ "textColor": "primary" }, "innerBlocks": [], - "innerHTML": "\n

Text

\n", + "innerHTML": "\n

Text 1

\n", "innerContent": [ - "\n

Text

\n" + "\n

Text 1

\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] + }, + { + "blockName": "core/heading", + "attrs": { + "style": { + "typography": { + "textAlign": "center" + } + }, + "textColor": "primary" + }, + "innerBlocks": [], + "innerHTML": "\n

Text 2

\n", + "innerContent": [ + "\n

Text 2

\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n", + "innerContent": [ "\n\n" ] + }, + { + "blockName": "core/heading", + "attrs": { + "style": { + "typography": { + "textAlign": "left" + } + }, + "textColor": "primary" + }, + "innerBlocks": [], + "innerHTML": "\n

Text

\n", + "innerContent": [ + "\n

Text

\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html index c561e3e87d0d1d..8ae62b482b797d 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html @@ -1,3 +1,11 @@ -

Text

+

Text 1

+ + + +

Text 2

+ + + +

Text

diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html deleted file mode 100644 index 9b7e0a85a54c58..00000000000000 --- a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.html +++ /dev/null @@ -1,3 +0,0 @@ - -

Text

- \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json deleted file mode 100644 index 772e846de8802f..00000000000000 --- a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "name": "core/heading", - "isValid": true, - "attributes": { - "content": "Text", - "level": 2, - "align": "wide", - "style": { - "typography": { - "textAlign": "center" - } - } - }, - "innerBlocks": [] - } -] diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json deleted file mode 100644 index 338fa8605b4c8a..00000000000000 --- a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.parsed.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "blockName": "core/heading", - "attrs": { - "align": "wide", - "style": { - "typography": { - "textAlign": "center" - } - } - }, - "innerBlocks": [], - "innerHTML": "\n

Text

\n", - "innerContent": [ - "\n

Text

\n" - ] - } -] diff --git a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html b/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html deleted file mode 100644 index 11cb955af74fd8..00000000000000 --- a/test/integration/fixtures/blocks/core__heading_align-textalign__deprecated-1.serialized.html +++ /dev/null @@ -1,3 +0,0 @@ - -

Text

- From 47d7e07a1530d925b50c1c7ca67deeab90fa7064 Mon Sep 17 00:00:00 2001 From: tomoki shimomura Date: Fri, 9 Jan 2026 20:07:24 +0900 Subject: [PATCH 08/11] Update test/e2e/specs/editor/blocks/heading.spec.js Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --- test/e2e/specs/editor/blocks/heading.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/editor/blocks/heading.spec.js b/test/e2e/specs/editor/blocks/heading.spec.js index 2b03db6a146344..884395426507da 100644 --- a/test/e2e/specs/editor/blocks/heading.spec.js +++ b/test/e2e/specs/editor/blocks/heading.spec.js @@ -416,7 +416,7 @@ test.describe( 'Heading', () => { ); } ); - test( 'should preserve the text align attribute', async ( { + test( 'should preserve the text align block support', async ( { editor, } ) => { await editor.insertBlock( { From 8789310f891cac898349cf529b19309703a55d39 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Sat, 10 Jan 2026 17:50:27 +0900 Subject: [PATCH 09/11] update-deprecated --- .../blocks/core__heading__deprecated-6.html | 16 ++++---- .../blocks/core__heading__deprecated-6.json | 13 +++--- .../core__heading__deprecated-6.parsed.json | 41 ++++++------------- ...ore__heading__deprecated-6.serialized.html | 12 +++--- 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.html index 04aefeeb423e62..a27ffd9816a09d 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.html @@ -1,11 +1,9 @@ - -

Text 1

+ +

Heading

- - -

Text 2

- - - -

Text

+ +

Heading

+ +

Heading

+ \ No newline at end of file diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.json index 7c20a78ecc53cd..ea9723f5758f92 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.json @@ -3,12 +3,11 @@ "name": "core/heading", "isValid": true, "attributes": { - "content": "Text 1", + "content": "Heading", "level": 2, - "textColor": "primary", "style": { "typography": { - "textAlign": "right" + "textAlign": "left" } } }, @@ -18,9 +17,8 @@ "name": "core/heading", "isValid": true, "attributes": { - "content": "Text 2", + "content": "Heading", "level": 2, - "textColor": "primary", "style": { "typography": { "textAlign": "center" @@ -33,12 +31,11 @@ "name": "core/heading", "isValid": true, "attributes": { - "content": "Text", + "content": "Heading", "level": 2, - "textColor": "primary", "style": { "typography": { - "textAlign": "left" + "textAlign": "right" } } }, diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json index 3445229312c456..4c3cb05e4a3437 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.parsed.json @@ -2,63 +2,48 @@ { "blockName": "core/heading", "attrs": { - "style": { - "typography": { - "textAlign": "right" - } - }, - "textColor": "primary" + "textAlign": "left" }, "innerBlocks": [], - "innerHTML": "\n

Text 1

\n", + "innerHTML": "\n

Heading

\n", "innerContent": [ - "\n

Text 1

\n" + "\n

Heading

\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\n", - "innerContent": [ "\n\n" ] + "innerHTML": "\n", + "innerContent": [ "\n" ] }, { "blockName": "core/heading", "attrs": { - "style": { - "typography": { - "textAlign": "center" - } - }, - "textColor": "primary" + "textAlign": "center" }, "innerBlocks": [], - "innerHTML": "\n

Text 2

\n", + "innerHTML": "\n

Heading

\n", "innerContent": [ - "\n

Text 2

\n" + "\n

Heading

\n" ] }, { "blockName": null, "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\n", - "innerContent": [ "\n\n" ] + "innerHTML": "\n", + "innerContent": [ "\n" ] }, { "blockName": "core/heading", "attrs": { - "style": { - "typography": { - "textAlign": "left" - } - }, - "textColor": "primary" + "textAlign": "right" }, "innerBlocks": [], - "innerHTML": "\n

Text

\n", + "innerHTML": "\n

Heading

\n", "innerContent": [ - "\n

Text

\n" + "\n

Heading

\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html index 8ae62b482b797d..0645edab6decb8 100644 --- a/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html +++ b/test/integration/fixtures/blocks/core__heading__deprecated-6.serialized.html @@ -1,11 +1,11 @@ - -

Text 1

+ +

Heading

- -

Text 2

+ +

Heading

- -

Text

+ +

Heading

From 76f239d228cbe13d0d6745fd146109b62ff7ca4c Mon Sep 17 00:00:00 2001 From: shimotmk Date: Sat, 10 Jan 2026 17:52:32 +0900 Subject: [PATCH 10/11] update --- .../block-library/src/heading/transforms.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/block-library/src/heading/transforms.js b/packages/block-library/src/heading/transforms.js index 3554f52ff27387..d616051bd7dcf0 100644 --- a/packages/block-library/src/heading/transforms.js +++ b/packages/block-library/src/heading/transforms.js @@ -29,13 +29,11 @@ const transforms = { ), content, anchor, - ...( textAlign && { - style: { - typography: { - textAlign, - }, + style: { + typography: { + textAlign, }, - } ), + }, } ); } ), }, @@ -116,13 +114,11 @@ const transforms = { } ) ), content, - ...( textAlign && { - style: { - typography: { - textAlign, - }, + style: { + typography: { + textAlign, }, - } ), + }, } ); } ), }, From af6b4f2202cfb5bd5762c3949e3123bd1c211ee3 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Sat, 10 Jan 2026 20:22:47 +0900 Subject: [PATCH 11/11] revert transform attributes --- .../block-library/src/heading/transforms.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/heading/transforms.js b/packages/block-library/src/heading/transforms.js index d616051bd7dcf0..3554f52ff27387 100644 --- a/packages/block-library/src/heading/transforms.js +++ b/packages/block-library/src/heading/transforms.js @@ -29,11 +29,13 @@ const transforms = { ), content, anchor, - style: { - typography: { - textAlign, + ...( textAlign && { + style: { + typography: { + textAlign, + }, }, - }, + } ), } ); } ), }, @@ -114,11 +116,13 @@ const transforms = { } ) ), content, - style: { - typography: { - textAlign, + ...( textAlign && { + style: { + typography: { + textAlign, + }, }, - }, + } ), } ); } ), },