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

code block does not preserve HTML code when pasting #27386

Closed
pwkip opened this issue Dec 1, 2020 · 5 comments
Closed

code block does not preserve HTML code when pasting #27386

pwkip opened this issue Dec 1, 2020 · 5 comments
Assignees
Labels
[Status] In Progress Tracking issues with work in progress

Comments

@pwkip
Copy link
Contributor

pwkip commented Dec 1, 2020

Describe the bug
When pasting HTML code in the code block, the actual HTML gets rendered..

To reproduce
Steps to reproduce the behavior:

  1. Create a code block
  2. Paste in some HTML code
  3. The rendered html is displayed instead of the source code.

Expected behavior
Preserve the code

Screenshots

Happens on all tested editor versions:

  • WP 5.5.4 with Gutenberg 9.4.1
  • WP 5.6-RC1 with default editor

Happens on all tested OS and browsers:

  • Chrome on Ubuntu 20.04 Version 87.0.4280.66 (Official Build) (64-bit)
  • Chrome on Windows 10
  • Firefox on Windows 10
@pwkip pwkip changed the title code block does not preserve HTML code code block does not preserve HTML code when pasting Dec 1, 2020
@Lewiscowles1986
Copy link
Contributor

New HTML (output)
<code role="textbox" aria-multiline="true" aria-label="Code" class="block-editor-rich-text__editable rich-text" style="white-space: pre-wrap;" contenteditable="true"><strong data-rich-text-format-boundary="true">What whaaaat</strong></code>

This feels like it could be a browser bug with contenteditable, but if it is then it's one I think has existed for a while.

Should this just be a textarea?

Idk, it's working as expected on a few sites I've checked, but not in storybook for latest master.

Old HTML (output)
<code role="textbox" aria-multiline="true" aria-label="Code" class="rich-text block-editor-rich-text__editable" contenteditable="true" style="white-space: pre-wrap;">&lt;strong&gt;What whaaaat&lt;/strong&gt;</code>

Lewiscowles1986 added a commit to Lewiscowles1986/gutenberg that referenced this issue Dec 1, 2020
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 1, 2020
@Lewiscowles1986
Copy link
Contributor

I just removed the repo and re-pulled. Looks like this is fixed in master anyway. Check it out.

@pwkip
Copy link
Contributor Author

pwkip commented Dec 1, 2020

I don't have time to test right away. I only know this is the behavior I get both on windows and linux (two completely different PC's and different browsers) with a fresh installation of WP 5.6-RC1. It happens for all blocks by the way. When I paste code from a text editor (VS code, notepad, gedit), Gutenberg automatically renders the HTML. This is actually pretty nice for paragraph blocks and so on, but doesn't make much sense for the code block.

Will try to test by pulling master later.

@tellthemachines
Copy link
Contributor

Closing as this was fixed in #27236. Testing with latest master, I can no longer reproduce the issue. It is also fixed in 5.6 RC2 which is now available for testing.

@paaljoachim
Copy link
Contributor

@tellthemachines Please see my comment here:
Copied formatted editor content from 2 paragraph blocks and a list block.
Opened Gmail and pasted with CTRL + SHIFT + V
Result is seeing the Gutenberg code.

#11742 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants