diff --git a/packages/block-library/src/quote/index.js b/packages/block-library/src/quote/index.js index 535dd29e4d8b5..20458db83572e 100644 --- a/packages/block-library/src/quote/index.js +++ b/packages/block-library/src/quote/index.js @@ -186,21 +186,27 @@ export const settings = { } const pieces = split( create( { html: value, multilineTag: 'p' } ), '\u2028' ); + + const headingBlock = createBlock( 'core/heading', { + content: toHTMLString( { value: pieces[ 0 ] } ), + } ); + + if ( ! citation && pieces.length === 1 ) { + return headingBlock; + } + const quotePieces = pieces.slice( 1 ); - return [ - createBlock( 'core/heading', { - content: toHTMLString( { value: pieces[ 0 ] } ), - } ), - createBlock( 'core/quote', { - ...attrs, - citation, - value: toHTMLString( { - value: quotePieces.length ? join( pieces.slice( 1 ), '\u2028' ) : create(), - multilineTag: 'p', - } ), + const quoteBlock = createBlock( 'core/quote', { + ...attrs, + citation, + value: toHTMLString( { + value: quotePieces.length ? join( pieces.slice( 1 ), '\u2028' ) : create(), + multilineTag: 'p', } ), - ]; + } ); + + return [ headingBlock, quoteBlock ]; }, }, diff --git a/packages/e2e-tests/specs/blocks/__snapshots__/quote.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/quote.test.js.snap index 6a46b767390ef..57d1d187978f4 100644 --- a/packages/e2e-tests/specs/blocks/__snapshots__/quote.test.js.snap +++ b/packages/e2e-tests/specs/blocks/__snapshots__/quote.test.js.snap @@ -6,44 +6,6 @@ exports[`Quote can be converted to a pullquote 1`] = ` " `; -exports[`Quote can be converted to headings 1`] = ` -" -
-" -`; - -exports[`Quote can be converted to headings 2`] = ` -" -two
cite
cite-" -`; - -exports[`Quote can be converted to headings 3`] = ` -" -
one
@@ -117,3 +79,73 @@ exports[`Quote can be merged into from a paragraph 1`] = `" `; + +exports[`Quote is transformed to a heading and a quote if the quote contains a citation 1`] = ` +" +test
cite+" +`; + +exports[`Quote is transformed to a heading and a quote if the quote contains multiple paragraphs 1`] = ` +" +
+" +`; + +exports[`Quote is transformed to a heading if the quote just contains one paragraph 1`] = ` +" +two
three
+" +`; + +exports[`Quote the resuling quote after transforming to a heading can be transformed again 2`] = ` +" +two
cite
cite+" +`; + +exports[`Quote the resuling quote after transforming to a heading can be transformed again 3`] = ` +" +