From eab99e080ed300d871772c3475be3f1510cbd319 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 10 Aug 2017 10:10:59 -0400 Subject: [PATCH 1/4] Quote: Render value verbatim Should have same result, unless we were explicitly trying to strip props from root p node, in which case this is not assigned in quote block implementation, and should be the responsibility of the transform source to remove in transform value --- blocks/library/quote/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 80af82a89f43a2..d717ce92b590a2 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -204,7 +204,7 @@ registerBlockType( 'core/quote', { className={ `blocks-quote-style-${ style }` } style={ { textAlign: align ? align : null } } > - { value.map( ( paragraph, i ) =>

{ paragraph.props.children }

) } + { value } { citation && citation.length > 0 && ( ) } From ccff3803dc9698f3fc812a5a7fe9f6e54a5ca754 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 10 Aug 2017 10:15:28 -0400 Subject: [PATCH 2/4] List: Fix plain text list toBrDelimitedContent string item --- blocks/library/list/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index fb6cab23c61c9f..8b4fae53c88c58 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -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 From 1df74df00da5efa0dae8866d43691a8361d9c65b Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 10 Aug 2017 10:15:39 -0400 Subject: [PATCH 3/4] List: Transform to quote as expected value type --- blocks/library/list/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index 8b4fae53c88c58..568aaf99163151 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -163,7 +163,7 @@ registerBlockType( 'core/list', { blocks: [ 'core/quote' ], transform: ( { values } ) => { return createBlock( 'core/quote', { - value: toBrDelimitedContent( values ), + value: [

{ toBrDelimitedContent( values ) }

], } ); }, }, From f1952ac5e06ae077c90929bd6d3e36ad0fa2e557 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 10 Aug 2017 11:48:17 -0400 Subject: [PATCH 4/4] Quote: Restore value map with defined default Needed to ensure key is assigned into map result to avoid React error. Seems unnecessary since we don't need the diffing reconciliation for generating static markup, but alas. See: https://github.com/facebook/react/issues/7038 --- blocks/library/quote/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index d717ce92b590a2..8138a08f81f633 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -29,6 +29,7 @@ registerBlockType( 'core/quote', { value: { type: 'array', source: query( 'blockquote > p', node() ), + default: [], }, citation: { type: 'array', @@ -204,7 +205,9 @@ registerBlockType( 'core/quote', { className={ `blocks-quote-style-${ style }` } style={ { textAlign: align ? align : null } } > - { value } + { value.map( ( paragraph, i ) => ( +

{ paragraph.props.children }

+ ) ) } { citation && citation.length > 0 && ( ) }