WordPress / wporg-gutenberg

The theme for https://wordpress.org/gutenberg/
https://wordpress.org/gutenberg/
10 stars 5 forks source link

Add in a readonly button. #21

Closed StevenDufresne closed 2 years ago

StevenDufresne commented 2 years ago

The custom ReadOnly button was created to allow users to navigate away from the block editor instead of triggering the RichText control that you would typically get with a button.

We now want to move that injected content, into the page to allow admins to adjust the content which introduces the problem that there are 2 contexts in which the editor is being used.

  1. Unauthenticated users
  2. Site admins

This PR does the following:

Why this approach?

What I really wanted to do is include the default core/button block without using InnerBlock. I'm not sure how to do that or whether it's possible. I feel like it should be possible and I'm not thinking straight at the moment .🤷

Using it as an InnerBlock was the best second option because I don't want to have to create a custom button... But creating one is an alternative.

I don't like using the InnerBlock component because the InnerBlock.Content does not appear available when used within the Block Editor. Because of this, I was forced to dangerously inject the HTML content. I'm not certain it's dangerous in this context because the content would have to already be compromised.

This also isn't great because this only works when the template has 1 block. If we were to have multiple blocks in the template, it would not render all of the children properly because each block has originalContent that only includes content for the specific block.

Another alternative that was mentioned is just to let site admins edit as HTML. 🤔