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 modifies/removes spacing #17208

Closed
peterwilsoncc opened this issue Aug 27, 2019 · 5 comments
Closed

Pasting modifies/removes spacing #17208

peterwilsoncc opened this issue Aug 27, 2019 · 5 comments
Labels
[Feature] Paste [Type] Bug An existing feature does not function as intended

Comments

@peterwilsoncc
Copy link
Contributor

Describe the bug
Copying a paragraph from HTML can drop spaces around strong and em tags and covert spaces to non-breaking spaces.

-<p>Signs of economic trouble <strong>could get voters thinking more about such progressive platforms.</strong> Though, if the primary election of 1992 (remember, the one that brought us "It's the economy, stupid"?) is any indication, <a href="https://theweek.com/articles/858824/how-trump-recession-could-cement-bidens-2020-victory" target="_self" title="">voters might choose a safe, familiar path</a> — a centrist candidate like Joe Biden.</p>
+<p>Signs of economic trouble&nbsp;<strong>could get voters thinking more about such progressive platforms.</strong>Though, if the primary election of 1992 (remember, the one that brought us "It's the economy, stupid"?) is any indication,&nbsp;<a href="https://theweek.com/articles/858824/how-trump-recession-could-cement-bidens-2020-victory">voters might choose a safe, familiar path</a>&nbsp;— a centrist candidate like Joe Biden.</p>

-- online source https://www.abc.net.au/news/2019-08-16/trump-could-lose-2020-election-if-the-economy-tanks/11420022

Note:

  • missing space in sentence beginning "Though"
  • multiple spaces converted to non-breaking spaces

To reproduce
Steps to reproduce the behavior:

  1. Go to this article on ABC News, Australia
  2. Select the paragraph beginning "Signs of economic trouble" and ending with "Joe Biden"
  3. Copy the paragraph
  4. Paste the text in to the visual editor view of a paragraph block
  5. Observe the missing spaces in the visual editor
  6. Switch to the HTML editor view and observe the non-breaking spaces

Expected behavior
Copy and paste should not affect markup

Desktop (please complete the following information):

  • OS: macOS 10.13.6
  • Browser: Chrome 76.0

Additional context

@talldan talldan added [Feature] Paste [Type] Bug An existing feature does not function as intended labels Aug 28, 2019
@desaiuditd
Copy link
Member

I spent some time to debug on this. This looks like more of an OS level issue. Please see below the console logs of the paste handler.

Received HTML:

 <meta charset='utf-8'><span style="color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(249, 249, 249); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Signs of economic trouble<span> </span></span><strong style="margin: 0px; padding: 0px; overflow-wrap: break-word; color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(249, 249, 249); text-decoration-style: initial; text-decoration-color: initial;">could get voters thinking more about such progressive platforms.</strong><span style="color: rgb(17, 17, 17); font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(249, 249, 249); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Though, if th</span>

Notice in the above log 👆that there's no space between the point where <strong> tag is ended and the text Though, if th is starting.

Received plain text:

 Signs of economic trouble could get voters thinking more about such progressive platforms. Though, if th
Processed inline HTML:

 Signs of economic trouble&nbsp;<strong>could get voters thinking more about such progressive platforms.</strong>Though, if th

I went ahead and checked this in Classic Editor. If I paste the same content into TinyMCE, the spaces are removed there as well.

Not sure if we can do anything about this. 🤷‍♂

@aprea
Copy link
Contributor

aprea commented Sep 5, 2019

I was also able to reproduce this in the block editor. I performed some additional testing in a standalone HTML page with a contenteditable div but was not able reproduce the issue.

See this codepen for the content I was testing with - https://codepen.io/aprea/pen/LYPOavx

HTML content
Screen Shot 2019-09-05 at 3 51 29 pm

When pasted into a contenteditable div on a standalone HTML page
Screen Shot 2019-09-05 at 3 52 59 pm

When pasted into a paragraph block in the block editor
Screen Shot 2019-09-05 at 3 54 12 pm

@aprea
Copy link
Contributor

aprea commented Oct 1, 2019

I'm unable to reproduce this on 6.5.0, seems like it may have been fixed elsewhere.

@ellatrix
Copy link
Member

@peterwilsoncc Are you still experiencing this issue with Gutenberg 7.0?

@peterwilsoncc
Copy link
Contributor Author

@ellatrix Sorry it's take a few days. No, I can't reproduce this anymore so will close the issue off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants