pattern-directory icon indicating copy to clipboard operation
pattern-directory copied to clipboard

Add Code View to Pattern Creator

Open StevenDufresne opened this issue 3 years ago • 4 comments

Describe the feature There have been a number of occasions when building a pattern, that I wanted to copy in pattern code or modify it directly. It would be nice if we could switch the creator into Code Editor mode and back. For me, it's part of my Gutenberg experience. I frequently work in both views.

Expect to see

Scope At this moment in time, the <ModeSwitcher> is not an exported component. Gutenberg's edit-site package appears to just have duplicated the code. We could also duplicate or maybe submit a Gutenberg PR to export the component.

https://github.com/WordPress/gutenberg/blob/b7f0444f93572d02ec4106c16561c73f1ff5c494/packages/edit-post/src/components/header/more-menu/index.js#L16

StevenDufresne avatar Mar 10 '22 01:03 StevenDufresne

The code view was not added on purpose, as a guardrail to prevent broken patterns, so I'm hesitant to add it back. What are you trying to do that you need the code view? is something in GB not working the way you expect?

ryelle avatar Mar 10 '22 16:03 ryelle

It came up in 2 different scenarios, which is why I decided to get an issue up:

Collaborating

  1. I wanted to paste in a block from the block museum and see how it was made.
  2. I wanted to paste in a copied block that someone else made on wordpress.org and modify it.

Editing

  1. Playing with multiple nested blocks.... it became a bit tedious to keep track of all the layouts and positioning in the editor, I wanted to see the code to see the state of things. This is a Gutenberg thing but I'm still used to working this way, regardless.

I'm not dying for this feature, should more people want it we can consider adding it.

StevenDufresne avatar Mar 11 '22 00:03 StevenDufresne

For pasting block code, did pasting directly into the editor not work? It should work in the default editor, but maybe something's not working in the creator.

ryelle avatar Mar 11 '22 15:03 ryelle

For pasting block code, did pasting directly into the editor not work? It should work in the default editor, but maybe something's not working in the creator.

Oh weird, I totally didn't know you can do that. 🤯

StevenDufresne avatar Mar 15 '22 08:03 StevenDufresne