-
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
Fixed quote<->list transformations #3525
Fixed quote<->list transformations #3525
Conversation
e2d62fc
to
14392b2
Compare
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.
14392b2
to
8d8f484
Compare
Codecov Report
@@ Coverage Diff @@
## master #3525 +/- ##
=========================================
+ Coverage 34.85% 35.8% +0.95%
=========================================
Files 261 262 +1
Lines 6717 6862 +145
Branches 1225 1274 +49
=========================================
+ Hits 2341 2457 +116
- Misses 3691 3716 +25
- Partials 685 689 +4
Continue to review full report at Codecov.
|
8d8f484
to
f6f7a49
Compare
f6f7a49
to
3bf5a17
Compare
value: [ <p key="list">{ toBrDelimitedContent( values ) }</p> ], | ||
value: ( values.length === 1 ? values : initial( values ) ) | ||
.map( ( value ) => ( { children: <p> { get( value, 'props.children' ) } </p> } ) ), | ||
citation: ( values.length === 1 ? undefined : get( last( values ), 'props.children' ) ), |
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.
Nice 👍
It works perfectly fine now. 🙇 |
Thank you for your review @gziolo. 👍 |
Description
This PR aims to fix a bug that I just discovered. Transforming from a quote into a list throws an error, and transforming a list into a quote creates a quote with empty content.
This PR solves both problems and simplifies the logic in a similar way of what was done in paragraph<->list transformations.
Now, transforming from quote to list, creates a list of the quote paragraphs and the last item being the citation. Transforming a list into a quote creates a paragraph for each list item excluding the last one that is used as a citation. This makes the transformations (quote->list->quote, list->quote->list)
totally idempotent.
How Has This Been Tested?
Transform a quote (empty and non-empty) into a list. Verify the first two values of the list are quote, citation.
Transform a list (empty and non-empty) into a quote. Verify the first two values of the list are now quote and citation of the quote block. If the list contains more than two values just the first two should be used.
Screenshots (jpeg or gifs if applicable):
Before:
List to quote
Quote to list
After: