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

Block conversion: Preserve "More" order #5538

Merged
merged 4 commits into from
Mar 14, 2018
Merged

Conversation

mcsf
Copy link
Contributor

@mcsf mcsf commented Mar 9, 2018

Fixes the issue described by @swissspidy in #1467 (comment)

Kudos @swissspidy for the fix; I merely added tests.

(drive-by pull request; can provide further details later)

Description

How Has This Been Tested?

Screenshots (jpeg or gifs if applicable):

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

* Props @swissspidy
* Properly replace nodes in rawHandler
* Extend tests for rawHandler's `special-comment-converter` transform
* Add rawHandler integration test `classic`
@mcsf mcsf requested a review from ellatrix March 10, 2018 00:05
@@ -71,3 +70,16 @@ function createMore( customText, noTeaser ) {
}
return node;
}

function replace( processedNode, newNode ) {
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Worth adding these to dom utils? We're doing these in a few places I think, even outside the paste component. Could be done separately though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To do: actually refactor elsewhere in the code base.

@@ -0,0 +1,4 @@
<p>First paragraph.</p>
<p><!--more--></p>
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth adding more tests here such as <p>First <!--more--> paragraph.</p>?

@@ -14,6 +14,7 @@ import serialize from '../../../serializer';

const types = [
'plain',
'classic',
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could consolidate the other image and iframe test into one "classic" conversion test similar to the other integration tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like that, or something along those lines. Better left to another PR, though, no?

return `<p>${ string }</p>`;
}

function withEmptyP( string ) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this is any create than without this function. withEmptyP leases me wondering where exactly that empty paragraph will be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed; removing simplifies things.

output.substr( start ),
'<wp-block data-block="core/more" data-no-teaser=""></wp-block>'
trimWhitespace( output ),
trimWhitespace( `<p>First paragraph.</p>
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why trimWhitespace is necessary. Shouldn't it be preserved?

Copy link
Member

Choose a reason for hiding this comment

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

(I mean, isn't specialCommentConverter merely moving other nodes?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. As I was developing I wanted the tests to have these input/output strings neatly aligned with the rest of the code but that meant adding tab characters throughout. Not that that's wrong, but it made the tests more brittle. I'll probably remove this.

@mcsf
Copy link
Contributor Author

mcsf commented Mar 11, 2018

Thanks for the review, @iseulde. Mind having one last look?

@mcsf mcsf force-pushed the fix/more-tag-block-conversion branch from bd5cf9d to 9874d43 Compare March 14, 2018 13:50
@aduth aduth added this to the 2.4 milestone Mar 14, 2018
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

👍

@aduth aduth merged commit 07e04c0 into master Mar 14, 2018
@aduth aduth deleted the fix/more-tag-block-conversion branch March 14, 2018 15:52
@swissspidy swissspidy mentioned this pull request Mar 27, 2018
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.

3 participants