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

Pasting unformatted text removes formatting and converts heading to paragraph #16990

Closed
oxyc opened this issue Aug 9, 2019 · 10 comments · Fixed by #17140
Closed

Pasting unformatted text removes formatting and converts heading to paragraph #16990

oxyc opened this issue Aug 9, 2019 · 10 comments · Fixed by #17140
Assignees
Labels
Needs Testing Needs further testing to be confirmed. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@oxyc
Copy link
Member

oxyc commented Aug 9, 2019

Describe the bug

If I paste an unformatted word (eg. copied from the URL bar) into an empty heading block or a paragraph with styling applied, all styling is reset and the block is converted to a paragraph.

To reproduce

  1. Create a Heading block
  2. Copy an unformatted word, eg a word from the URL bar of the browser
  3. Paste it into the block
  4. Notice that the block is now a paragraph.

Same happens if you paste it into the styled placeholder paragraph block in Media & Text.

Expected behavior

If I paste an unformatted word I would expect it to keep the previous styling and block type rather than resetting everything to an unformatted paragraph.

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 76

Additional context

This works as expected with v4.7.1 and v5.5.0. It does not work in v5.9.1, v6.2.0 and master branch.

@nerrad nerrad added the [Type] Bug An existing feature does not function as intended label Aug 11, 2019
@nerrad
Copy link
Contributor

nerrad commented Aug 11, 2019

I'm able to reproduce in the editor included with WordPress 5.2.2 but not with Gutenberg active and built from the latest master branch. @oxyc can you try again using the latest master branch?

@nerrad nerrad added the Needs Testing Needs further testing to be confirmed. label Aug 11, 2019
@oxyc
Copy link
Member Author

oxyc commented Aug 11, 2019

Still happening with the playground on master branch for me. I can confirm it with the plugin tomorrow soon.

demo

@nerrad
Copy link
Contributor

nerrad commented Aug 11, 2019

To clarify, I'm not testing using the playground against Master but am using the build from master tested in a WordPress install. There may be a variation between GB in playground and in a WP environment that may be contributing to this then.

@oxyc
Copy link
Member Author

oxyc commented Aug 11, 2019

This also happens with the plugin for me. Tested in Safari, Chrome and Firefox, all of them behave the same.

I ran these steps to build the plugin:

git pull origin master
npm run package-plugin
mv gutenberg.zip ~/......

@oxyc
Copy link
Member Author

oxyc commented Aug 17, 2019

Just saw there's apparently https://wordpress.github.io/gutenberg/ which is built on master according to #16967 (comment).

It's reproducible there too.

@peterwilsoncc
Copy link
Contributor

peterwilsoncc commented Aug 22, 2019

I've tested this locally and am having a similar problem, please find a screencast attached.

Testing environment

  • WordPress 5.2.2
  • Gutenberg master@ 0b4d9c8
  • Chrome 76.0/macOS 10.13.6

Build environment

  • node 10.16.0
  • npm 6.9.0
  • built with npm run build, ie not running in dev mode

Console output

Received HTML:

 
index.js?ver=1566448714:12 Received plain text:

 Pens and pencils
index.js?ver=1566448714:2 Processed HTML piece:

 <p>Pens and pencils</p>
index.js?ver=1566448714:12 Received HTML:

 
index.js?ver=1566448714:12 Received plain text:

 Pens and pencils
index.js?ver=1566448714:2 Processed HTML piece:

 <p>Pens and pencils</p>

pasting

@ellatrix
Copy link
Member

The problem is that we always force BLOCKS mode in the paste handler when the input field is empty. I remember there being a reason for it, but I forgot, and unfortunately it's not commented on. I'll search through some similar issues for an answer.

Regardless, whatever it did fix, we should find something better, because enforcing BLOCKS mode for an empty block seems like the wrong approach.

@ellatrix
Copy link
Member

Related: #10614, #6516, but not seeing the answer there.

@ellatrix
Copy link
Member

Found it. This code was added 2 years ago to tigger embedding when pasting a URL on an empty line. #3326

I'll work on a fix now.

@ellatrix
Copy link
Member

This issue is also a blocker for me to introduce splitting to captions. Without a fix you wouldn't be able to paste in an empty caption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants