Skip to content

Commit

Permalink
Fix list v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 25, 2022
1 parent 97b5f4a commit f515661
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/block-library/src/list-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function ListItemEdit( {
setAttributes,
onReplace,
clientId,
mergeBlocks,
} ) {
const { placeholder, content } = attributes;
const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
Expand All @@ -69,7 +70,7 @@ export default function ListItemEdit( {
const useEnterRef = useEnter( { content, clientId } );
const useSpaceRef = useSpace( clientId );
const onSplit = useSplit( clientId );
const onMerge = useMerge( clientId );
const onMerge = useMerge( clientId, mergeBlocks );
return (
<>
<li { ...innerBlocksProps }>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/list-item/hooks/use-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useOutdentListItem from './use-outdent-list-item';

import { name as listItemName } from '../block.json';

export default function useMerge( clientId ) {
export default function useMerge( clientId, onMerge ) {
const registry = useRegistry();
const {
getPreviousBlockClientId,
Expand Down Expand Up @@ -134,7 +134,7 @@ export default function useMerge( clientId ) {
mergeBlocks( trailingId, clientId );
} );
} else {
switchToDefaultBlockType( forward );
onMerge( forward );
}
}
};
Expand Down
11 changes: 11 additions & 0 deletions packages/block-library/src/list/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ const transforms = {
);
},
} ) ),
{
type: 'block',
blocks: [ '*' ],
transform: ( _attributes, childBlocks ) => {
return getListContentFlat( childBlocks ).map( ( content ) =>
createBlock( 'core/paragraph', {
content,
} )
);
},
},
],
};

Expand Down

0 comments on commit f515661

Please sign in to comment.