From f40484e4bda4cb735c660364608f1b1ce7be2409 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 27 Jun 2017 12:08:17 +0100 Subject: [PATCH] Quote Block: Fix single p transformations --- blocks/library/heading/index.js | 8 ++++---- blocks/library/quote/index.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 6b08226990a4a7..40870e58d437fc 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { isString, isObject } from 'lodash'; +import { isObject } from 'lodash'; /** * WordPress dependencies @@ -44,9 +44,9 @@ registerBlockType( 'core/heading', { transform: ( { content, ...attrs } ) => { const isMultiParagraph = Array.isArray( content ) && isObject( content[ 0 ] ) && content[ 0 ].type === 'p'; if ( isMultiParagraph ) { - const headingContent = isString( content[ 0 ] ) - ? content[ 0 ] - : content[ 0 ].props.children; + const headingContent = isObject( content[ 0 ] ) && content[ 0 ].type === 'p' + ? content[ 0 ].props.children + : content[ 0 ]; const heading = createBlock( 'core/heading', { content: headingContent, } ); diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 7c84044af0e0d3..9cf3496a8a68b9 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -90,7 +90,9 @@ registerBlockType( 'core/quote', { transform: ( { value, citation, ...attrs } ) => { const isMultiParagraph = Array.isArray( value ) && isObject( value[ 0 ] ) && value[ 0 ].type === 'p'; const headingElement = isMultiParagraph ? value[ 0 ] : value; - const headingContent = isString( headingElement ) ? headingElement : headingElement.props.children; + const headingContent = isObject( headingElement ) && value[ 0 ].type === 'p' + ? headingElement.props.children + : headingElement; if ( isMultiParagraph || citation ) { const heading = createBlock( 'core/heading', { content: headingContent,