From 6cb941be5d829f9220f23431c977cac21f94c886 Mon Sep 17 00:00:00 2001 From: Sneha Date: Fri, 6 Dec 2024 15:41:58 +0530 Subject: [PATCH] chore: preserve styling attributes during transformation to list blocks. --- packages/block-library/src/list/transforms.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/list/transforms.js b/packages/block-library/src/list/transforms.js index a6263d7ad639c7..903d422cf4b883 100644 --- a/packages/block-library/src/list/transforms.js +++ b/packages/block-library/src/list/transforms.js @@ -47,6 +47,13 @@ const transforms = { blocks: [ 'core/paragraph', 'core/heading' ], transform: ( blockAttributes ) => { let childBlocks = []; + const listAttributes = { + anchor: blockAttributes.anchor, + fontSize: blockAttributes[ 0 ]?.fontSize, + textColor: blockAttributes[ 0 ]?.textColor, + backgroundColor: blockAttributes[ 0 ]?.backgroundColor, + }; + if ( blockAttributes.length > 1 ) { childBlocks = blockAttributes.map( ( { content } ) => { return createBlock( 'core/list-item', { content } ); @@ -61,13 +68,7 @@ const transforms = { } ); } ); } - return createBlock( - 'core/list', - { - anchor: blockAttributes.anchor, - }, - childBlocks - ); + return createBlock( 'core/list', listAttributes, childBlocks ); }, }, {