Skip to content

Commit

Permalink
Merge pull request #2349 from WordPress/fix/quote-value
Browse files Browse the repository at this point in the history
Quote: Fix new quote, transform from list block
  • Loading branch information
aduth authored Aug 11, 2017
2 parents f354a5a + f1952ac commit 732d68b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion blocks/library/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const toBrDelimitedContent = ( values ) => {
}
const content = [];
values.forEach( function( li, liIndex, listItems ) {
if ( typeof li === 'string' ) {
content.push( li );
return;
}

Children.toArray( li.props.children ).forEach( function( element, elementIndex, liChildren ) {
if ( 'ul' === element.type || 'ol' === element.type ) { // lists within lists
// we know we've just finished processing a list item, so break the text
Expand Down Expand Up @@ -159,7 +164,7 @@ registerBlockType( 'core/list', {
blocks: [ 'core/quote' ],
transform: ( { values } ) => {
return createBlock( 'core/quote', {
value: toBrDelimitedContent( values ),
value: [ <p key="list">{ toBrDelimitedContent( values ) }</p> ],
} );
},
},
Expand Down
5 changes: 4 additions & 1 deletion blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ registerBlockType( 'core/quote', {
value: {
type: 'array',
source: query( 'blockquote > p', node() ),
default: [],
},
citation: {
type: 'array',
Expand Down Expand Up @@ -204,7 +205,9 @@ registerBlockType( 'core/quote', {
className={ `blocks-quote-style-${ style }` }
style={ { textAlign: align ? align : null } }
>
{ value.map( ( paragraph, i ) => <p key={ i }>{ paragraph.props.children }</p> ) }
{ value.map( ( paragraph, i ) => (
<p key={ i }>{ paragraph.props.children }</p>
) ) }
{ citation && citation.length > 0 && (
<footer>{ citation }</footer>
) }
Expand Down

0 comments on commit 732d68b

Please sign in to comment.