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

Allow pasting shortcodes in blocks with content. #3883

Merged
merged 1 commit into from Dec 13, 2017

Conversation

Projects
None yet
2 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Dec 8, 2017

Description

Until now when pasting a shortcode in existing blocks if the text we paste is plain text the inline pasting mechanism takes place and the shortcode is not parsed and the text is pasted as normal plain text. If the text contains markup the shortcode is parsed.
So if we paste [gallery ids="ID"] in a paragraph with content the text is appended to the paragraph (If copying from here span's are added so this does not happen).
If we paste <div>[gallery ids="ID"]</div> in a paragraph with content the shortcode is parsed and an equivalent block is added.
This change makes sure inline pasting mechanism does not take place if pasting shortcodes.

How Has This Been Tested?

Add some content to a paragraph or list or heading paste a shortcode verify it is correctly parsed and a block equivalent to the shortcode is added.
Try paste other content besides shortcodes and verify things work as before.

Screenshots (jpeg or gifs if applicable):

Before:
dec-08-2017 21-45-16

After:
dec-08-2017 21-43-45

@mcsf

I recommend adding tests for this, as there's a lot going on during pasting in general. :)

Show outdated Hide outdated blocks/api/raw-handling/index.js Outdated
Show outdated Hide outdated blocks/api/raw-handling/index.js Outdated
Show outdated Hide outdated blocks/api/raw-handling/index.js Outdated
Show outdated Hide outdated blocks/api/raw-handling/index.js Outdated
@mcsf

This comment has been minimized.

Show comment
Hide comment
@mcsf

mcsf Dec 11, 2017

Contributor

Referencing related issue #3806.

We can probably go ahead with this fix, but the logic in raw-handler is getting less obvious over time. Something to think about.

Contributor

mcsf commented Dec 11, 2017

Referencing related issue #3806.

We can probably go ahead with this fix, but the logic in raw-handler is getting less obvious over time. Something to think about.

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Dec 12, 2017

Member

Hi @mcsf, thank you for your review I tried to address the points you raised. Regarding the tests, it looks like we don't have yet tests for the shortcode parsing mechanism. That mechanism uses window.wp.shortcode, which is not available during test execution. I'm not sure what is the best way to add test cases to it probably we will need to use some mocks.

Member

jorgefilipecosta commented Dec 12, 2017

Hi @mcsf, thank you for your review I tried to address the points you raised. Regarding the tests, it looks like we don't have yet tests for the shortcode parsing mechanism. That mechanism uses window.wp.shortcode, which is not available during test execution. I'm not sure what is the best way to add test cases to it probably we will need to use some mocks.

@mcsf

This comment has been minimized.

Show comment
Hide comment
@mcsf

mcsf Dec 12, 2017

Contributor
Contributor

mcsf commented Dec 12, 2017

@mcsf

mcsf approved these changes Dec 12, 2017

@mcsf

This comment has been minimized.

Show comment
Hide comment
@mcsf

mcsf Dec 12, 2017

Contributor

I won't block this PR because of the tests, but we should get them in.

Contributor

mcsf commented Dec 12, 2017

I won't block this PR because of the tests, but we should get them in.

@jorgefilipecosta jorgefilipecosta merged commit 1cf31bd into master Dec 13, 2017

3 checks passed

codecov/project 38.48% (+0.24%) compared to 7aa9c25
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/pasting-short-codes-paragraphs-with-content branch Dec 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment