Skip to content

Commit

Permalink
Block library: Revert attribute name change for text align
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jun 10, 2019
1 parent b95ff4d commit 8a464f4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 21 deletions.
10 changes: 5 additions & 5 deletions packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
"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
},
"placeholder": {
"type": "string"
},
"textAlign": {
"textColor": {
"type": "string"
},
"textColor": {
"customTextColor": {
"type": "string"
}
}
Expand Down
6 changes: 0 additions & 6 deletions packages/block-library/src/heading/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ const deprecated = [
{
supports: blockSupports,
attributes: blockAttributes,
migrate( { align, ...attributes } ) {
return {
...attributes,
textAlign: align,
};
},
save( { attributes } ) {
const {
align,
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/heading/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ function HeadingEdit( {
textColor,
setTextColor,
} ) {
const { content, level, placeholder, textAlign } = attributes;
const { align, content, level, placeholder } = attributes;
const tagName = 'h' + level;

return (
<>
<BlockControls>
<HeadingToolbar minLevel={ 2 } maxLevel={ 5 } selectedLevel={ level } onChange={ ( newLevel ) => setAttributes( { level: newLevel } ) } />
<AlignmentToolbar
value={ textAlign }
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
setAttributes( { align: nextAlign } );
} }
/>
</BlockControls>
Expand Down Expand Up @@ -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,
} ) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/heading/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {

export default function save( { attributes } ) {
const {
align,
content,
customTextColor,
level,
textAlign,
textColor,
} = attributes;
const tagName = 'h' + level;
Expand All @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<h3 style=\"text-align:right\">A picture is worth a thousand words, or so the saying goes</h3>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:heading {"level":3,"textAlign":"right"} -->
<!-- wp:heading {"align":"right","level":3} -->
<h3 class="has-text-align-right">A picture is worth a thousand words, or so the saying goes</h3>
<!-- /wp:heading -->
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
"<!-- wp:heading {\\"customTextColor\\":\\"#181717\\",\\"level\\":3} -->
"<!-- wp:heading {\\"level\\":3,\\"customTextColor\\":\\"#181717\\"} -->
<h3 style=\\"color:#181717\\">Heading</h3>
<!-- /wp:heading -->"
`;
Expand Down

0 comments on commit 8a464f4

Please sign in to comment.