Skip to content

Commit

Permalink
fix: Remove block alignment from paragraph block (fix #6476) (#6511)
Browse files Browse the repository at this point in the history
* fix: Remove block alignment from paragraph block (fix #6476)
* chore: Deprecate width attribute from paragraph
  • Loading branch information
tofumatt authored May 3, 2018
1 parent 12a16a1 commit 049645b
Showing 1 changed file with 52 additions and 13 deletions.
65 changes: 52 additions & 13 deletions core-blocks/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
getColorClass,
withColors,
AlignmentToolbar,
BlockAlignmentToolbar,
BlockControls,
ContrastChecker,
InspectorControls,
Expand Down Expand Up @@ -145,7 +144,6 @@ class ParagraphBlock extends Component {
content,
dropCap,
placeholder,
width,
} = attributes;

const fontSize = this.getFontSize();
Expand Down Expand Up @@ -227,12 +225,6 @@ class ParagraphBlock extends Component {
} }
isLargeText={ fontSize >= 18 }
/>
<PanelBody title={ __( 'Block Alignment' ) }>
<BlockAlignmentToolbar
value={ width }
onChange={ ( nextWidth ) => setAttributes( { width: nextWidth } ) }
/>
</PanelBody>
</InspectorControls>
<div>
<RichText
Expand Down Expand Up @@ -297,9 +289,6 @@ const schema = {
placeholder: {
type: 'string',
},
width: {
type: 'string',
},
textColor: {
type: 'string',
},
Expand Down Expand Up @@ -354,6 +343,58 @@ export const settings = {
},

deprecated: [
{
supports,
attributes: {
...schema,
width: {
type: 'string',
},
},
save( { attributes } ) {
const {
width,
align,
content,
dropCap,
backgroundColor,
textColor,
customBackgroundColor,
customTextColor,
fontSize,
customFontSize,
} = attributes;

const textClass = getColorClass( 'color', textColor );
const backgroundClass = getColorClass( 'background-color', backgroundColor );
const fontSizeClass = fontSize && FONT_SIZES[ fontSize ] && `is-${ fontSize }-text`;

const className = classnames( {
[ `align${ width }` ]: width,
'has-background': backgroundColor || customBackgroundColor,
'has-drop-cap': dropCap,
[ fontSizeClass ]: fontSizeClass,
[ textClass ]: textClass,
[ backgroundClass ]: backgroundClass,
} );

const styles = {
backgroundColor: backgroundClass ? undefined : customBackgroundColor,
color: textClass ? undefined : customTextColor,
fontSize: fontSizeClass ? undefined : customFontSize,
textAlign: align,
};

return (
<RichText.Content
tagName="p"
style={ styles }
className={ className ? className : undefined }
value={ content }
/>
);
},
},
{
supports,
attributes: omit( {
Expand Down Expand Up @@ -437,7 +478,6 @@ export const settings = {

save( { attributes } ) {
const {
width,
align,
content,
dropCap,
Expand All @@ -454,7 +494,6 @@ export const settings = {
const fontSizeClass = fontSize && FONT_SIZES[ fontSize ] && `is-${ fontSize }-text`;

const className = classnames( {
[ `align${ width }` ]: width,
'has-background': backgroundColor || customBackgroundColor,
'has-drop-cap': dropCap,
[ fontSizeClass ]: fontSizeClass,
Expand Down

0 comments on commit 049645b

Please sign in to comment.