File tree Expand file tree Collapse file tree 4 files changed +29
-16
lines changed
Expand file tree Collapse file tree 4 files changed +29
-16
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * External dependencies
3+ */
4+ import { isString } from 'lodash' ;
5+
16/**
27 * Internal dependencies
38 */
@@ -38,9 +43,9 @@ registerBlock( 'core/heading', {
3843 blocks : [ 'core/text' ] ,
3944 transform : ( { content, align } ) => {
4045 if ( Array . isArray ( content ) ) {
41- // TODO this appears to always be true?
42- // TODO reject the switch if more than one paragraph
43- content = content [ 0 ] ;
46+ content = wp . element . concatChildren ( content . map ( ( elt ) =>
47+ ! elt || isString ( elt ) || elt . type !== 'p' ? elt : elt . props . children
48+ ) ) ;
4449 }
4550 return {
4651 nodeName : 'H2' ,
@@ -56,7 +61,7 @@ registerBlock( 'core/heading', {
5661 blocks : [ 'core/text' ] ,
5762 transform : ( { content, align } ) => {
5863 return {
59- content : [ content ] ,
64+ content,
6065 align
6166 } ;
6267 }
Original file line number Diff line number Diff line change 1+ /**
2+ * External dependencies
3+ */
4+ import { isString } from 'lodash' ;
5+
16/**
27 * Internal dependencies
38 */
@@ -54,9 +59,9 @@ registerBlock( 'core/quote', {
5459 {
5560 type : 'block' ,
5661 blocks : [ 'core/heading' ] ,
57- transform : ( { content = '' } ) => {
62+ transform : ( { content } ) => {
5863 return {
59- value : [ content ]
64+ value : content
6065 } ;
6166 }
6267 }
@@ -66,20 +71,23 @@ registerBlock( 'core/quote', {
6671 type : 'block' ,
6772 blocks : [ 'core/text' ] ,
6873 transform : ( { value, citation } ) => {
69- let content = value ? value : [ ] ;
70- content = citation && citation . trim ( ) ? content . concat ( citation ) : content ;
7174 return {
72- content
75+ content : wp . element . concatChildren ( value , citation )
7376 } ;
7477 }
7578 } ,
7679 {
7780 type : 'block' ,
7881 blocks : [ 'core/heading' ] ,
79- transform : ( { value } ) => {
82+ transform : ( { value, citation } ) => {
83+ if ( Array . isArray ( value ) ) {
84+ value = wp . element . concatChildren ( value . map ( ( elt ) =>
85+ ! elt || isString ( elt ) || elt . type !== 'p' ? elt : elt . props . children
86+ ) ) ;
87+ }
8088 return {
8189 nodeName : 'H2' ,
82- content : value && value [ 0 ]
90+ content : wp . element . concatChildren ( value , citation )
8391 } ;
8492 }
8593 }
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export function renderToString( element ) {
7575export function concatChildren ( ...childrens ) {
7676 return childrens . reduce ( ( memo , children , i ) => {
7777 Children . forEach ( children , ( child , j ) => {
78- if ( 'string' !== typeof child ) {
78+ if ( child && 'string' !== typeof child ) {
7979 child = cloneElement ( child , {
8080 key : [ i , j ] . join ( )
8181 } ) ;
Original file line number Diff line number Diff line change @@ -28,11 +28,11 @@ msgstr ""
2828msgid "Freeform"
2929msgstr ""
3030
31- #: blocks/library/heading/index.js:10
31+ #: blocks/library/heading/index.js:15
3232msgid "Heading"
3333msgstr ""
3434
35- #: blocks/library/heading/index.js:25
35+ #: blocks/library/heading/index.js:30
3636msgid "Heading %s"
3737msgstr ""
3838
@@ -70,11 +70,11 @@ msgstr ""
7070msgid "Justify"
7171msgstr ""
7272
73- #: blocks/library/quote/index.js:11
73+ #: blocks/library/quote/index.js:16
7474msgid "Quote"
7575msgstr ""
7676
77- #: blocks/library/quote/index.js:35
77+ #: blocks/library/quote/index.js:40
7878msgid "Quote style %d"
7979msgstr ""
8080
You can’t perform that action at this time.
0 commit comments