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

Markup stripped when pasting into Gutenberg (tables, definition lists mangled) #6902

Closed
wekhter opened this issue May 22, 2018 · 3 comments
Closed

Comments

@wekhter
Copy link

wekhter commented May 22, 2018

Describe the bug
Markup was stripped out of posts when pasted into Gutenberg, including: parts of tables, definition lists, other tags

To Reproduce
Steps to reproduce the behavior:

  1. Copy post from https://pastebin.com/ZPqzZr0T
  2. Paste as HTML in the classic editor
  3. Copy from visual tab in the classic editor
  4. Paste as new block in the gutenberg editor

Expected behavior
I expected the content to paste normally & split off into blocks by type (paragraph, heading, table, etc) while retaining markup

Screen Recording
https://www.useloom.com/share/1757c9b94d7e433e8e2098facf21bbf3

Desktop

  • OS: Windows 10
  • Chrome
  • Version 66.0.3359.181 (Official Build) (64-bit)

Additional context
I was trying to test the frontend styles gutenberg applies using some markup based on the Theme Unit Test to check theme styles, but found that certain parts of my markup were stripped out unexpectedly. Watch the screen recording to see the exact behavior.

  1. My table had three columns in the thead and three columns in the tbody but gutenberg stripped out the third empty th from my thead
  2. All markup was stripped out of the definition list, causing it to paste as one big blob w/o line breaks
  3. <address> tag was stripped out
  4. <cite> tag was stripped out
  5. <q> tag was stripped out. (note also that in the video I meant to simply add the <q> tags in within the paragraph, which gutenberg does correctly save as <p><q></q></p> but I panicked and replaced the <p> tags directly, so when I clicked convert to block it went ahead and stripped the tags I'd just written... feels like there should be a more friendly way to handle situations like that than to just undo someone's work)
  6. <var> tag was stripped out.

Now I know that not everyone uses <cite> as part of their quotes, and <address>, <q> and <var> are pretty uncommon, but since they are a part of the theme test I was doing I left them in the report.

Issue: Tables
In the example you see that what ends up being stripped out is an empty <th> from the <thead>. That might not seem like a huge deal, but that's just one example of the issues with pasting tables. The same thing happens if the table pasted contains an empty <td> (the cell doesn't show up at all). This behavior isn't limited to <th> or <td>s at the end of a row, it can also happen when it's content in the middle of a row--so for a table where you might have had an empty cell in lieu of a n/a:

|_A_|_B_|_C_|
|_1_|_2_|_3_|
|_1_|___|_3_|
|_1_|_2_|_3_|

Will paste into gutenberg as:

|_A_|_B_|_C_|
|_1_|_2_|_3_|
|_1_|_3_|
|_1_|_2_|_3_|

If a user pastes a table and finds that cells are not pasted, they'd have to fix it in HTML--the "add column" button inserts the column on all rows and the "delete column" deletes it on all rows, so there's no way to restore missing cells from the visual editor.

Issue: Definition lists
These have never been a part of the classic editor, but it's always been possible to write them (by switching to HTML) or to paste them from another source and continue to edit in either the HTML or visual editor. I was expecting to be able to edit them visually, just like I would a list or a table, but at the very least I would have wanted gutenberg to automatically convert it to an HTML block or something so I wouldn't completely lose the formatting.

@wekhter wekhter changed the title Markup stripped when pasting into Gutenberg Markup stripped when pasting into Gutenberg (tables, definition lists mangled) May 23, 2018
@designsimply designsimply added the Needs Testing Needs further testing to be confirmed. label Aug 1, 2018
@iamgabrielma
Copy link
Contributor

I've tested this with 4.0 and seems to be working mostly alright except with the HTML involving "definition lists" and "html tags":

Classic view:
screen shot 2018-10-18 at 14 06 20
screen shot 2018-10-18 at 14 06 45

Gutenberg view:
screen shot 2018-10-18 at 14 06 27
screen shot 2018-10-18 at 14 06 50

Both posts can be found here:

@designsimply designsimply removed the Needs Testing Needs further testing to be confirmed. label Nov 5, 2018
@paaljoachim
Copy link
Contributor

Hey @wekhter and @iamgabrielma could you do a test with the current Gutenberg plugin, a default theme and WordPress 5.6 and see if this is still an issue? Thanks!

@paaljoachim
Copy link
Contributor

WordPress 5.7 beta version 3.

Testing:
Copy post from https://pastebin.com/ZPqzZr0T
Paste as HTML in the classic editor
Copy from visual tab in the classic editor
Paste as new block in the gutenberg editor

What I saw:
Copied the HTML from the above link.
Pasted into the HTML section of a page where the Classic Editor was active.
Went to the visual tab and copied the content.
Deactivated the Classic Editor. Activated Gutenberg plugin 10 RC.
Made a new page and pasted the content.
Here is the result zoomed out view to get as much as possible in one screenshot.

Screen Shot 2021-02-16 at 02 19 25

I believe this issue has been fixed, and will go ahead and close it. If I am mistaken then let me know and I will reopen.

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

No branches or pull requests

5 participants