Skip to content
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 conversion for text <-> list, and quote <-> list #1297

Merged
merged 3 commits into from
Jun 21, 2017

Conversation

notnownikki
Copy link
Member

Converts text and quotes to list by using BR as the delimiter for list items. Transformations have been moved into the list block, it seemed to make sense for them to live there as the transformation code is there too.

Fixes #1214

Copy link
Contributor

@BE-Webdesign BE-Webdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Great! Works really well, left some minor feedback, which I would love to hear your thoughts on!

const fromBrDelimitedContent = function( content ) {
const listItems = [];
listItems.push( createElement( 'li', [], [] ) );
content.forEach( function( element, elementIndex, elements ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor Nitpick: I think we might want to use arrow function for these callbacks to keep consistent.

const toBrDelimitedContent = function( values ) {
const content = [];
values.forEach( function( li, liIndex, listItems ) {
if ( Array.isArray( li.props.children ) ) {
Copy link
Contributor

@BE-Webdesign BE-Webdesign Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor idea: I think we could potentially condense this code by using the Children API in React; either by making use of Children.map or Children.toArray, Then the conditional checking whether children is an array won't really be necessary.

@BE-Webdesign
Copy link
Contributor

BE-Webdesign commented Jun 20, 2017

Hmm, actually while circling back to this, I did come across a weird situation. If things get indented, then when you transform the indented children never get changed to a text or quote properly. Not sure if that necessarily has to be addressed in this PR.

@notnownikki
Copy link
Member Author

Ah, when a user likes lists so much that they put a list in their list so they can list their lists... Yeah, I'm not sure that we can preserve the indentation when we convert to a text or quote block, but we should certainly get the values of the list items.

@notnownikki
Copy link
Member Author

I've added support for nested lists now. Also, there were bugs when converting from empty blocks, so they're fixed too.

Copy link
Contributor

@BE-Webdesign BE-Webdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@notnownikki notnownikki merged commit f16af99 into master Jun 21, 2017
@ellatrix ellatrix deleted the fix/convert-text-and-list branch July 2, 2017 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants