diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index 0ed9c5c91b5820..99a08309176276 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -103,8 +103,18 @@ class ParagraphBlock extends Component { if ( after !== null ) { // Append "After" content as a new paragraph block to the end of - // any other blocks being inserted after the current paragraph. - blocks.push( createBlock( name, { content: after } ) ); + // any other blocks being inserted after the current paragraph + if ( after.length ) { + // If after has content, keep the new block styling same as current one. + const newBlockAttributes = { + ...attributes, + content: after, + }; + blocks.push( createBlock( name, newBlockAttributes ) ); + } else { + // Otherwise, add a default block + blocks.push( createBlock( name ) ); + } } if ( blocks.length && insertBlocksAfter ) { @@ -115,6 +125,9 @@ class ParagraphBlock extends Component { if ( before === null ) { // If before content is omitted, treat as intent to delete block. onReplace( [] ); + } else if ( before.length === 0 ) { + // If before has not content, replace by a default block. + onReplace( [ createBlock( name ) ] ); } else if ( content !== before ) { // Only update content if it has in-fact changed. In case that user // has created a new paragraph at end of an existing one, the value diff --git a/packages/block-library/src/paragraph/index.js b/packages/block-library/src/paragraph/index.js index 6a0c6172c36957..1aea8c113052d5 100644 --- a/packages/block-library/src/paragraph/index.js +++ b/packages/block-library/src/paragraph/index.js @@ -212,6 +212,9 @@ export const settings = { merge( attributes, attributesToMerge ) { return { + backgroundColor: attributes.content.length === 0 ? attributesToMerge.backgroundColor : attributes.backgroundColor, + textColor: attributes.content.length === 0 ? attributesToMerge.textColor : attributes.textColor, + fontSize: attributes.content.length === 0 ? attributesToMerge.fontSize : attributes.fontSize, content: ( attributes.content || '' ) + ( attributesToMerge.content || '' ), }; },