Skip to content

Commit

Permalink
Quote Block: Fix single p transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jun 27, 2017
1 parent e51306e commit f40484e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions blocks/library/heading/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { isString, isObject } from 'lodash';
import { isObject } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -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,
} );
Expand Down
4 changes: 3 additions & 1 deletion blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f40484e

Please sign in to comment.