Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 52 additions & 13 deletions core-blocks/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
getColorClass,
withColors,
AlignmentToolbar,
BlockAlignmentToolbar,
BlockControls,
ColorPalette,
ContrastChecker,
Expand Down Expand Up @@ -142,7 +141,6 @@ class ParagraphBlock extends Component {
content,
dropCap,
placeholder,
width,
} = attributes;

const fontSize = this.getFontSize();
Expand Down Expand Up @@ -234,12 +232,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 @@ -304,9 +296,6 @@ const schema = {
placeholder: {
type: 'string',
},
width: {
type: 'string',
},
textColor: {
type: 'string',
},
Expand Down Expand Up @@ -359,6 +348,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 @@ -435,7 +476,6 @@ export const settings = {

save( { attributes } ) {
const {
width,
align,
content,
dropCap,
Expand All @@ -452,7 +492,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