WordPress / pattern-directory

The WordPress Block Pattern Directory
https://wordpress.org/patterns/
GNU General Public License v2.0
119 stars 31 forks source link

Add Code View to Pattern Creator #429

Open StevenDufresne opened 2 years ago

StevenDufresne commented 2 years ago

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

ryelle commented 2 years ago

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?

StevenDufresne commented 2 years ago

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.

ryelle commented 2 years ago

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.

StevenDufresne commented 2 years ago

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. 🤯