From 02020b27b17eba83668525f31283b9cf1639d601 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 10 Jun 2019 15:48:09 +0200 Subject: [PATCH] Block library: Revert attribute name change for text align --- packages/block-library/src/heading/block.json | 10 +++++----- packages/block-library/src/heading/deprecated.js | 6 ------ packages/block-library/src/heading/edit.js | 8 ++++---- packages/block-library/src/heading/save.js | 4 ++-- .../fixtures/blocks/core__heading__deprecated-1.json | 4 ++-- .../blocks/core__heading__deprecated-1.serialized.html | 2 +- .../specs/blocks/__snapshots__/heading.test.js.snap | 2 +- 7 files changed, 15 insertions(+), 21 deletions(-) diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index ce5e2ce3c5c5e0..2c47b2c7096521 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -2,15 +2,15 @@ "name": "core/heading", "category": "common", "attributes": { + "align": { + "type": "string" + }, "content": { "type": "string", "source": "html", "selector": "h1,h2,h3,h4,h5,h6", "default": "" }, - "customTextColor": { - "type": "string" - }, "level": { "type": "number", "default": 2 @@ -18,10 +18,10 @@ "placeholder": { "type": "string" }, - "textAlign": { + "textColor": { "type": "string" }, - "textColor": { + "customTextColor": { "type": "string" } } diff --git a/packages/block-library/src/heading/deprecated.js b/packages/block-library/src/heading/deprecated.js index 202b54d4092418..4a3a7d2f6d3653 100644 --- a/packages/block-library/src/heading/deprecated.js +++ b/packages/block-library/src/heading/deprecated.js @@ -45,12 +45,6 @@ const deprecated = [ { supports: blockSupports, attributes: blockAttributes, - migrate( { align, ...attributes } ) { - return { - ...attributes, - textAlign: align, - }; - }, save( { attributes } ) { const { align, diff --git a/packages/block-library/src/heading/edit.js b/packages/block-library/src/heading/edit.js index 8a3c8e158ba760..e937979788d352 100644 --- a/packages/block-library/src/heading/edit.js +++ b/packages/block-library/src/heading/edit.js @@ -55,7 +55,7 @@ function HeadingEdit( { textColor, setTextColor, } ) { - const { content, level, placeholder, textAlign } = attributes; + const { align, content, level, placeholder } = attributes; const tagName = 'h' + level; return ( @@ -63,9 +63,9 @@ function HeadingEdit( { setAttributes( { level: newLevel } ) } /> { - setAttributes( { textAlign: nextAlign } ); + setAttributes( { align: nextAlign } ); } } /> @@ -99,7 +99,7 @@ function HeadingEdit( { onReplace={ onReplace } onRemove={ () => onReplace( [] ) } className={ classnames( className, { - [ `has-text-align-${ textAlign }` ]: textAlign, + [ `has-text-align-${ align }` ]: align, 'has-text-color': textColor.color, [ textColor.class ]: textColor.class, } ) } diff --git a/packages/block-library/src/heading/save.js b/packages/block-library/src/heading/save.js index 7ee5ce6d486568..7cf0de59884828 100644 --- a/packages/block-library/src/heading/save.js +++ b/packages/block-library/src/heading/save.js @@ -13,10 +13,10 @@ import { export default function save( { attributes } ) { const { + align, content, customTextColor, level, - textAlign, textColor, } = attributes; const tagName = 'h' + level; @@ -25,7 +25,7 @@ export default function save( { attributes } ) { const className = classnames( { [ textClass ]: textClass, - [ `has-text-align-${ textAlign }` ]: textAlign, + [ `has-text-align-${ align }` ]: align, } ); return ( diff --git a/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.json b/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.json index 183cd4991f1d5c..0553075b8e24d6 100644 --- a/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.json +++ b/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.json @@ -4,9 +4,9 @@ "name": "core/heading", "isValid": true, "attributes": { + "align": "right", "content": "A picture is worth a thousand words, or so the saying goes", - "level": 3, - "textAlign": "right" + "level": 3 }, "innerBlocks": [], "originalContent": "

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

" diff --git a/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.serialized.html b/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.serialized.html index 01632267f681d1..140a1929ad38c8 100644 --- a/packages/e2e-tests/fixtures/blocks/core__heading__deprecated-1.serialized.html +++ b/packages/e2e-tests/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/packages/e2e-tests/specs/blocks/__snapshots__/heading.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/heading.test.js.snap index a695ff0b71f745..093ceb0da4e9d5 100644 --- a/packages/e2e-tests/specs/blocks/__snapshots__/heading.test.js.snap +++ b/packages/e2e-tests/specs/blocks/__snapshots__/heading.test.js.snap @@ -13,7 +13,7 @@ exports[`Heading can be created by prefixing number sign and a space 1`] = ` `; exports[`Heading it should correctly apply custom colors 1`] = ` -" +"

Heading

" `;