Skip to content

Commit

Permalink
chore: preserve styling attributes during transformation to list blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapatil2001 committed Dec 6, 2024
1 parent b8bfb4d commit 6cb941b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/block-library/src/list/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
Expand All @@ -61,13 +68,7 @@ const transforms = {
} );
} );
}
return createBlock(
'core/list',
{
anchor: blockAttributes.anchor,
},
childBlocks
);
return createBlock( 'core/list', listAttributes, childBlocks );
},
},
{
Expand Down

0 comments on commit 6cb941b

Please sign in to comment.