diff --git a/packages/block-library/src/list/index.js b/packages/block-library/src/list/index.js index e7a6174ef25084..4137dcdf3a6735 100644 --- a/packages/block-library/src/list/index.js +++ b/packages/block-library/src/list/index.js @@ -73,9 +73,17 @@ export const settings = { transform: ( blockAttributes ) => { return createBlock( 'core/list', { values: toHTMLString( { - value: join( blockAttributes.map( ( { content } ) => - replace( create( { html: content } ), /\n/g, LINE_SEPARATOR ) - ), LINE_SEPARATOR ), + value: join( blockAttributes.map( ( { content } ) => { + const value = create( { html: content } ); + + if ( blockAttributes.length > 1 ) { + return value; + } + + // When converting only one block, transform + // every line to a list item. + return replace( value, /\n/g, LINE_SEPARATOR ); + } ), LINE_SEPARATOR ), multilineTag: 'li', } ), } ); diff --git a/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap index ef176d16bb9d75..efc3b6d2743731 100644 --- a/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap +++ b/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap @@ -156,6 +156,12 @@ exports[`List should insert a line break on shift+enter in a non trailing list i " `; +exports[`List should not transform lines in block when transforming multiple blocks 1`] = ` +" +