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

Consider creating a more standardized way to transform blocks #11473

Closed
timelsass opened this issue Nov 5, 2018 · 3 comments
Closed

Consider creating a more standardized way to transform blocks #11473

timelsass opened this issue Nov 5, 2018 · 3 comments
Labels
[Feature] Block Transforms Block transforms from one block to another [Type] Enhancement A suggestion for improvement.

Comments

@timelsass
Copy link
Contributor

Describe the bug
Transform block to control doesn't have a logical flow between blocks.

To Reproduce
Steps to reproduce the behavior:

  1. Add a new code block:
    add-code-block

  2. Click on transform to control on block:
    transform-to-preformatted
    You are presented only with the <pre> block to transform to.

  3. Select the <pre> block to transform the <code> block into a <pre> now.

  4. Click on transform to control again:
    transform-to-again
    You are presented with being able to transform block to a paragraph block.

  5. Select the paragraph block to transform the <pre> into a <p> now.

  6. Click on transform to control again:
    transform-to-x2
    You are presented with being able to transform block to preformatted, heading, list, verse, or quote blocks.

Expected behavior
a. In the initial transform to for the <code> block - I would expect to be able to also transform the <code> block into a <p> block since ultimately I can change it to a <pre> then into a <p>.

b. When I'm in the <pre> block's transform to control, I would expect to be able to transform to the original state of the block, in this case transform back to the <code> block I originally inserted. I would expect this behavior for all <pre> blocks, and only mention the original state because it would make sense that this area displays the block types that were previously used for this area in the order that they were used before new transform to block types.

c. When I'm in the paragraph block, I would expect to be able to also transform not only to a <pre> but to a <code> block as well.


Note: It's not necessarily unusable because I can undo once I changed from a code block to a pre block to get back to editing a code block. From a UI perspective though, I expect to be able to traverse back to the same state from the same entry point I made the change from.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.1 LTS
  • chrome
  • Version 69.0.3497.92 (Official Build) (64-bit)

Additional context

  • Gutenberg Version 4.1.1
@designsimply designsimply added [Type] Enhancement A suggestion for improvement. [Feature] Block Transforms Block transforms from one block to another labels Nov 5, 2018
@designsimply designsimply changed the title Transform block to control doesn't have a logical flow between blocks Consider creating a more standardized way to transform blocks Nov 5, 2018
@designsimply
Copy link
Member

My understanding is that not all blocks transform interchangeably by design because not all blocks can transform seamlessly without data loss and an intentional choice was made to not allow transformations that result in data loss. I've found a few past discussions on the same topic and am including a couple of them below for background. I have also updated the title to better reflect the spirit of the whole discussion.

For reference, here's a recent PR that talks about valid transforms and what were considered acceptable ones: #9326 (this is where the one-way conversion from a code block to a preformatted block was added and there is a lot of similar/relevant discussion to your notes above).

See also a related PR which didn't land in master: #5585.

@ChemicalSailor
Copy link

On a related issue, the Media & Text block has a destructive transformation to an image - the text is lost when this transform is applied. Also it's not possible to transform it to a paragraph (i.e loose the image and keep the text), and it would be nice to transform a paragraph into a Media&Text block with a media placeholder.

@mtias
Copy link
Member

mtias commented Jul 13, 2021

Transforms are block-elective and should be treated as such: each block can declare what it transforms to and from. If there's a missing target that would make sense to suggest, please, open a new issue.

@mtias mtias closed this as completed Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Transforms Block transforms from one block to another [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants