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

Updating existing content to Gutenberg doesn't honor existing attributes #5392

Closed
2 tasks
caraya opened this issue Mar 4, 2018 · 8 comments
Closed
2 tasks
Labels
[Feature] Paste [Type] Enhancement A suggestion for improvement.

Comments

@caraya
Copy link

caraya commented Mar 4, 2018

Issue Overview

Steps to Reproduce (for bugs)

  1. Open an old post (I use markdown and fenced code blocks with language-<name> to indicate the language Prism should use for highlight in my content). Prism is configured as a plugin and works correctly before opening the post in Gutenberg
  2. Convert the classic block containing the post into blocks
  3. The code block has a fixed default value wp-block-code for the class attribute
  4. If I try to add a class attribute manually I get a validation error in Chrome dev tools
  5. I have to manually add the class from the editor for every individual code block

Browsers tested with: Firefox Nightly (60.0a1 / 2/28/18), Chrome (64.0.3282) on MacOS
Gutenberg: 2.3.0 compiled from source on 3/3

Expected Behavior

If there is an existing class for an element that gets converted to a block, that class should be honored when converting the element to a block. I don't think this is related to Automattic/jetpack#7786 as the content has already been rendered and saved to the database before being opened in Gutenberg and the code displays properly before the conversion

Current Behavior

Code blocks lose the language- attribute and the code highlight.

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@youknowriad
Copy link
Contributor

If I try to add a class attribute manually I get a validation error in Chrome dev tools

You can use the block inspector to add your className to avoid having these errors.

@caraya
Copy link
Author

caraya commented Mar 6, 2018

that's not the point, I indicated that I had tried it manually because the class had been removed. I'm also curious why I get a validation error when I add to an existing attribute in the element

The old post had a class to indicate the type of language I want to highlight. I shouldn't have to add it again just because Gutenberg removed it.

@youknowriad
Copy link
Contributor

I understand that the converting mechanism should be able to add this extra className if detect, I just wanted to help with a workaround for now.

Also, the converting mechanism is not done automatically on purpose. Because there's no way to guarantee no data loss. That's why you have to do it on your own if it's not the result you hoped for you can still undo and continue using the classic block.

@youknowriad
Copy link
Contributor

cc @iseulde @mcsf

@caraya
Copy link
Author

caraya commented Mar 6, 2018

If you use the classic or HTML blocks you lose a lot of the Gutenberg functionality. That's fine with me, I write a lot of HTML in my posts already, but it may not be for everyone upgrading content.

@ellatrix
Copy link
Member

ellatrix commented May 1, 2018

@caraya Could you provide the HTML for us to test and make a PR with?

@caraya
Copy link
Author

caraya commented May 15, 2018

I thought I had done this already, I've attached a file with the markdown doc and the converted HTML
Archive.zip

@danielbachhuber
Copy link
Member

I understand that the converting mechanism should be able to add this extra className if detect, I just wanted to help with a workaround for now.

This was handled with #7538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants