gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Patterns: Create a pattern in a similar way to how we create a Reusable block.

Open paaljoachim opened this issue 5 years ago • 13 comments

What problem does this address?

At current there is no user interface to create a pattern. Let's change that.

What is your proposed solution?

Similar to how we add blocks to become a Reusable block it would be helpful to add blocks to become Pattern blocks.

Patterns-Add-to-Pattern-blocks

paaljoachim avatar Apr 28 '21 19:04 paaljoachim

We used to allow this briefly and removed it because it's confusing. Even in that dialogue it's not clear to me when I should choose one option over the other. A project to allow user editable patterns could be worthwhile but it needs a much broader scope and proposal, as it'd be a subtype of wp_block.

mtias avatar Apr 30 '21 11:04 mtias

I am wondering if we should do something like this:

Add to Reusable blocks Add a global connected block

Add to Pattern blocks Add an independent pattern block.

As it gives a short explanation of what each is. It would use the current method, and it can be an easy way to choose to use a global connected block or an independent block. It would give a quick access to creating both types of blocks directly in Gutenberg.

paaljoachim avatar Apr 30 '21 14:04 paaljoachim

@mtias

I am thinking something similar to this: Add-to-Reusable-Pattern-blocks

A one liner that Reusable blocks are still connected with the original block. That Pattern blocks are disconnected from original block.

@kjellr @melchoyce

Associated: Patterns: Manage Patterns similar to Reusable blocks. https://github.com/WordPress/gutenberg/issues/31367

Reusable blocks: Convert a Reusable block to a pattern. https://github.com/WordPress/gutenberg/issues/31296

paaljoachim avatar May 01 '21 10:05 paaljoachim

Could be, or perhaps we need to use a modal where we can offer more context on what each option allows. In any case it needs a more in depth look to all the implications.

mtias avatar May 03 '21 09:05 mtias

I reopened the issue as it would be helpful to save blocks to a Pattern block.

paaljoachim avatar May 28 '21 22:05 paaljoachim

Perhaps make the option only available from the FSE editor. Something like an advanced option.

JosVelasco avatar May 29 '21 02:05 JosVelasco

There is already a plugin that converts reusable blocks to patterns and it works good. Reusable Blocks Extended: https://wordpress.org/plugins/reusable-blocks-extended/

Since there is a concern about generating confusion in the posts editor we could polish this plugin. Instead of "convert to reusable block" we could add the option "save as pattern" making a copy of the reusable block and listing it in /wp-admin/edit.php?post_type=wp_block

There could be a filter at the top of the list, please see my attachment.

reusable-block-pattern

JosVelasco avatar May 29 '21 15:05 JosVelasco

Hi @JosVelasco

That is a very good idea!

Adding the option to the Reusable blocks manage screen as you are showing is one good way of handling it. As it would keep it out of the Gutenberg layout area for now and instead we just give the option in the manage screen.

One thing that comes to mind. To create a pattern one would first need to save it as a Reusable block and then -> convert/save it as a pattern. I do look forward to having a method to click multiple blocks and then save these as a Reusable block or as a Pattern directly through the ellipsis /3 dot drop down.

paaljoachim avatar May 31 '21 13:05 paaljoachim

Also related: #32682. There's a proposed flow there for creating patterns as part of a design library.

mtias avatar Jun 22 '21 11:06 mtias

This would indeed be very helpful. The way we create reusable blocks is really easy and intuitive. But I only need to reuse the structures (and not the content) so I'm looking at block patterns. And it seems to be a lot more involved to create those compared to reusable blocks.

ecations avatar Jun 27 '23 16:06 ecations

This is done now!

mtias avatar Jun 27 '23 17:06 mtias

That's great news! Where can we find more info about this feature?

ecations avatar Jun 27 '23 19:06 ecations

Hi @ecations

Here is a PR which shows how it will work: https://github.com/WordPress/gutenberg/pull/51144

paaljoachim avatar Jun 27 '23 19:06 paaljoachim