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 API: Pasting content that results in a new block shouldn't be treated as inline content. #19084

Merged
merged 4 commits into from Dec 21, 2019

Conversation

@pento
Copy link
Member

pento commented Dec 12, 2019

Description

When pasting text, the paste handler currently assumes that if the text doesn't have a line break, and it results in one block, it can be treated as inline text, instead.

This may be correct for core, but is not necessarily correct for plugins that may wish to transform a single line of text into a custom block.

This PR tightens the paste handler assumption to only allow a selection of blocks to be treated as an inline paste.

Fixes #18390.

How has this been tested?

Tested with the sample plugin in #18390.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.
@ellatrix

This comment has been minimized.

Copy link
Member

ellatrix commented Dec 12, 2019

Could some sort of test be added?

@pento

This comment has been minimized.

Copy link
Member Author

pento commented Dec 13, 2019

The new supports.pasteTextInline property defaults to false, so blocks will need to opt-in to being overridden when pasting inline text.

I've added some tests, too.

@ellatrix

This comment has been minimized.

Copy link
Member

ellatrix commented Dec 21, 2019

@pento I marked pasteTextInline as an unstable API as I'm not expecting any non core blocks to use this feature (as you have noted yourself). Let's see if there are more cases popping up.

Copy link
Member

ellatrix left a comment

Thanks for the PR, this makes sense! :)

@ellatrix ellatrix merged commit 03928a5 into master Dec 21, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@ellatrix ellatrix deleted the fix/18390-pasting-single-lines branch Dec 21, 2019
@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.