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

Copy + pasting blocks inserts classic editor before and after the pasted element (On Windows only) #16369

Closed
QuietNoise opened this issue Jul 1, 2019 · 12 comments · Fixed by #19040
Assignees
Labels
[Block] Classic Affects the Classic Editor Block [Feature] Paste [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@QuietNoise
Copy link

Describe the bug
If you copy / paste a block or multiple blocks within the editor the pasted version of the content will be wrapped with Classic block before and after.

To reproduce
Steps to reproduce the behaviour:

  1. Select one or few blocks (Heading, Paragraph, Image) while editing content in the Editor and copy it clipboard (Ctrl + C)
    2019-07-01_14h14_45

  2. Click anywhere else in the editable area of the page and paste the clipboard (Ctrl + V).
    2019-07-01_14h17_04

  3. Observe two additional empty Classic blocks added, one at the start and one at the end of the pasted content
    2019-07-01_14h22_49

Expected behavior
I would expect the pasted content does not have any extra blocks to it.

This is especially an abhorrent issue when we know that Classic block does not work in Container blocks (Group, Columns) and irrecoverably breaks them as reported by numerous. (consolidated here #13187).

So, if you happen to paste your content into a Column or Group and you don’t deliberately delete the extra Classic blocks then the content in your Containers block will be screwed after you update the post and come back to editing it later.
2019-07-01_14h30_11
2019-07-01_14h32_06

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome 75
    Tested on WP Version 5.2.2 (with Gutenberg deactivated as well as with Gutenberg 5.9.2 and with 6.0.0).
    Tested on rather heavy customised sites as well as on fresh WP / Gutenberg installs.

Additional context
The copied blocks’ code doesn’t expose any ‘extras’ in them.

<!-- wp:heading -->
<h2>Heading</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Paragraph</p>
<!-- /wp:paragraph -->

The issue is appearing when you paste the code.

I consider this a very serious issue.
Most of my clients are aware to not use the Classic editor in the container blocks as of now. This adds another level of hurdle to their CMS experience.
I went to investigate few sites and I did observe this bug breaking content across the realm of WP. Quite often people don't even realize that the page they published / updated will have un-editable parts in them when they return to edit screen at a later date.

@swissspidy swissspidy added [Block] Classic Affects the Classic Editor Block [Feature] Paste Needs Testing Needs further testing to be confirmed. labels Jul 1, 2019
@youknowriad
Copy link
Contributor

What version are you using? I'm not able to reproduce the issue personally.

@QuietNoise
Copy link
Author

Hi @youknowriad
I've just replicated the issue on wordpress.com and on local fresh installation of WP 5.2.2 with Gutenberg 6.3.0.

Exact steps I did:

  1. Create a new page.
  2. Enter a paragraph block. Enter text. Convert to header.
  3. Enter 2 more paragraph blocks.
  4. Select above three blocks with your mouse so they are highlighted.
  5. Copy to clipboard (Ctrl+C).
  6. Paste them below (Ctrl+V).
    Pasted content will have Classic blocks above and below.

Tested on Windows 10 in Firefox, Chrome and Edge with same behaviour.

View from Wordpress.com:
2019-08-22_17h34_23

View from local installation:
2019-08-22_17h48_38

Hope that helps.

@youknowriad
Copy link
Contributor

@QuietNoise Are you converting to "header" or "heading"? Header block is not something that is available in Gutenberg Core. I just tried again in master with the heading block and I'm still not able to reproduce. I'm using Chrome but MacOS.

Also, I wonder if it's specific to WordPress.com integration somehow?

@QuietNoise
Copy link
Author

@youknowriad My bad. I meant the Heading block.
I went on to some macOS machines (Sierra, El Captain, Mojave) and I couldn't replicate it on any of them.
I went on to some other Windows computers and the problem is replicable on all of them.

We can then assume it's a Windows specific problem and that's why you can't see it. Maybe something to do with Ctrl key being pressed or with format of the clipboard on Windows. No idea. Wild guessing here.

@youknowriad
Copy link
Contributor

Interesting. Let's reopen and debug. Thanks for helping. Would you be able to share the content of the browser console, when you paste?

@youknowriad youknowriad reopened this Aug 22, 2019
@youknowriad youknowriad added [Type] Bug An existing feature does not function as intended and removed Needs Testing Needs further testing to be confirmed. labels Aug 22, 2019
@youknowriad youknowriad changed the title Copy + pasting blocks inserts classic editor before and after the pasted element Copy + pasting blocks inserts classic editor before and after the pasted element (On Windows only) Aug 22, 2019
@youknowriad
Copy link
Contributor

cc @ellatrix weird windows pasting issue. Not sure if you know anything about that.

@QuietNoise
Copy link
Author

As requested.

Console when pasting from mac:
2019-08-22_21h57_34

Console when pasting on windows:
2019-08-22_21h57_47

@youknowriad
Copy link
Contributor

Thanks a lot @QuietNoise It seems that the error might come from the extra html/body tags added in windows to the received HTML content, we should probably strip them.

@QuietNoise
Copy link
Author

There is definitely something to it. If I paste the clipboard HTML from Windows on a mac machine it will expose the bug behaviour. I.e. paste this in editor on mac:

<html><body>
<!--StartFragment--><!-- wp:heading -->
<h2>Heading Win</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Paragraph Win</p>
<!-- /wp:paragraph --><!--EndFragment-->
</body>
</html>

The text will be treated as a plain text rather than HTML but the bug will appear regardless.

@yankiara
Copy link

Same issue WP 5.3... Any news about this?
Gutenberg Editor is unusable in this state :-(

@ellatrix
Copy link
Member

The issue seems to be the extra StartFragment and EndFragment comments together with other starting and ending tags added by the browser or OS. We're not stripping those if we detect Gutenberg content, so the parser puts those unrecognised pieces of HTML in a classic block. I'll look for a solution.

@ellatrix
Copy link
Member

Output:

<p> <!--StartFragment--></p>

<!-- wp:heading -->
<h2>Heading Win</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Paragraph Win</p>
<!-- /wp:paragraph -->

<p><!--EndFragment-->  </p>

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Classic Affects the Classic Editor Block [Feature] Paste [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.

5 participants