-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix list to paragraph transform #4460
Conversation
Whoops, looks like I corrected it in one place but not the other. :) |
c831336
to
59063fb
Compare
It's kind of messy when having to take prettier into account too. :/ |
listContent.forEach( ( content, index ) => { | ||
if ( content.type === 'ol' || content.type === 'ul' ) { | ||
acc.push( ...listItemsToArray( castArray( get( content, 'props.children', [] ) ) ) ); | ||
acc.push( [] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is acc.push( [] );
required to have line breaks? maybe we specify in a comment the reason it is needed.
* @return {Array} Array of Editable value arrays. | ||
*/ | ||
function listItemsToArray( items ) { | ||
return items.reduce( ( acc, item ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally certain but it looks like we may be able to use flatMap here and it has some performance advantages according to @aduth test cases. It may also simplify the code :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needing a rebase but generally the changes look good.
acc.push( ...listItemsToArray( castArray( get( content, 'props.children', [] ) ) ) ); | ||
acc.push( [] ); | ||
} else { | ||
// No line breaks form prettier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean? Should it be "from Prettier"? 🤷♂️
Is this PR still relevant? |
Description
Currently nested lists fail to transform to paragraphs. This PR aims to fix that.
How Has This Been Tested?
Create list with indented items. Convert to paragraphs or quote.