Add Code View to Pattern Creator
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
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?
It came up in 2 different scenarios, which is why I decided to get an issue up:
Collaborating
- I wanted to paste in a block from the block museum and see how it was made.
- I wanted to paste in a copied block that someone else made on wordpress.org and modify it.
Editing
- 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.
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.
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. 🤯