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

Convert to blocks loses marked up content inside a blockquote #4992

Closed
2 tasks
bobbingwide opened this issue Feb 10, 2018 · 14 comments
Closed
2 tasks

Convert to blocks loses marked up content inside a blockquote #4992

bobbingwide opened this issue Feb 10, 2018 · 14 comments
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Block Transforms Block transforms from one block to another [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later [Type] Enhancement A suggestion for improvement.
Milestone

Comments

@bobbingwide
Copy link
Contributor

bobbingwide commented Feb 10, 2018

Issue Overview

Having created a post using the Classic editor I attempted to convert it from the Classic block to blocks.
It correctly determined that it should create a blockquote but lost all the content.

This is a backward compatibility issue.

Steps to Reproduce (for bugs)

  1. Using the classic editor create the following content
<blockquote>
<h3>The editor will create a new page- and post-building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</h3>
<h3>— Matt Mullenweg</h3>
</blockquote>

This can be achieved in the Visual editor by pasting the text of the quote, selecting it all and then clicking on the blockquote and h3 toolbar buttons in that order.
2. Save
3. Open in the new editor
3. Choose convert to blocks

Expected Behavior

  • The quote should be extracted correctly.
  • It would also be nice if the cite part of the blockquote was populated into the cite section.

Current Behavior

The text disappears.

Possible Solution

Screenshots / Video

issue-4992

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@youknowriad
Copy link
Contributor

As I said in #5028 (comment) This is not a backwards compatibility issue because converting to block is an explicit action you can undo and it can't be 100% accurate because the blocks don't support all kind of markup.

So transforming the markup mentioned above is impossible because the quote can't contain headings at the moment, it's just a list of paragraphs. Maybe it shouldn't be converted in that case though. cc @iseulde

@bobbingwide
Copy link
Contributor Author

It’s unexpected loss of data.
The user should be informed in advance, during or immediately after that there could or have be problems. Undo is OK when it’s an obvious option.

Had I converted a very large block I might have missed the fact that the block quote had gone missing.

There are a number of potential improvements that can be envisaged.

For example.

Check your results

It should be easy enough to strip the HTML comments from the generated blocks, compare the generated HTML with the original HTML and report the differences.

Classic Text block

Another is to support a Classic Text block where the content is left completely untouched by the editor. No wpautop processing, no new lines converted to br’s. Nothing.

This will help with other issues where existing blocks do not satisfy the requirements. See #4456 and #4672.

In my opinion this is something that is needed to help early adopters demonstrate to others that the site doesn’t break. A nice way of saying ‘You were doing it wrong but now we’ve fixed it for you’.

I’ll raise a separate requirement if you like.. none of the existing blocks support what I need.

@youknowriad
Copy link
Contributor

Another is to support a Classic Text block where the content is left completely untouched by the editor. No wpautop processing, no new lines converted to br’s. Nothing.

That's what we already do if you don't click "convert". Am I misunderstanding something?

@youknowriad
Copy link
Contributor

youknowriad commented Feb 15, 2018

It should be easy enough to strip the HTML comments from the generated blocks, compare the generated HTML with the original HTML and report the differences.

IMO, there will always be a difference. An example of this is the autogenerated className per block. I think a solution could be to add a confirmation to this button explaining that loss of data is possible and improve the algorithm to minimise it (like I suggested above, don't convert if the blockquote contains tags other than paragraphs)

@bobbingwide
Copy link
Contributor Author

That's what we already do if you don't click "convert".

The Classic block looks and works a bit like the Tiny MCE editor, but there is no Text editor equivalent.

Am I misunderstanding something?

  • My experience is that hand crafted content may not survive Save and Re-open.
  • And this can lead to existing content being broken on the front end.
  • Garbage in, garbage out.
  • When this happens the changes have to be reverted and the Classic editor used.
  • See the issues I referred to.
  • I will raise a new requirement.
  • In the mean time, please consider this scenario, I don't know if this has been raised already.

I've modified the original HTML in the Text Editor and it looks fine in the Visual Editor.
I've removed the h3's and used a cite tag.

<blockquote>The editor will create a new page- and post-building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
<cite>Matt Mullenweg</cite></blockquote>

Copying and pasting this into a new post fails to recognise the cite.

image

It's pretty impressive but just needs to be even slicker.

@youknowriad
Copy link
Contributor

The Classic block looks and works a bit like the Tiny MCE editor, but there is no Text editor equivalent.

Isn't the HTML mode per block the equivalent for the text editor for the classic block? I'm just trying to understand here.


What exactly are you proposing here?

@ellatrix
Copy link
Member

So the raw handler will preserve the heading tags, but the quote block transformation only grabs paragraph tags from the wrapper. We could adjust the quote block transform to either take all HTML (it's just one big MCE instance anyway) or to convert these tags to paragraphs. Atm the block doesn't really support anything other than paragraphs, so the latter makes more sense for now. This could all change though if the quote block would consist of nested blocks (which I think it should so you can add lists etc.)

@mtias
Copy link
Member

mtias commented Mar 6, 2018

This would be addressed by making Quote have a nested area where you can add different blocks.

@ellatrix
Copy link
Member

ellatrix commented Mar 6, 2018

Yeah

@jeffpaul jeffpaul added the [Type] Enhancement A suggestion for improvement. label Mar 8, 2018
@ZebulanStanphill
Copy link
Member

Keeping headings, lists, etc. will be possible if #6054 is merged.

@danielbachhuber danielbachhuber added Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Block Transforms Block transforms from one block to another labels Jun 4, 2018
@danielbachhuber
Copy link
Member

Now that #6054 has landed, we should make sure this use-case is accommodated for.

@danielbachhuber danielbachhuber self-assigned this Jun 4, 2018
@ZebulanStanphill
Copy link
Member

@danielbachhuber #6054 was reverted in #6501. There is a new PR for nested blocks in quotes: #6520.

@danielbachhuber danielbachhuber removed their assignment Jul 18, 2018
@danielbachhuber danielbachhuber added the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Jul 18, 2018
@oandregal
Copy link
Member

Just wanted to note that after some changes related to the Raw Handler component this test case no longer loses content but it is transformed into an HTML block.

@ellatrix
Copy link
Member

Let's close this in favour of #15486. The problem here is that a quote should allow other blocks inside it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Block Transforms Block transforms from one block to another [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

8 participants