Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable Blocks: "Manage All Reusable Blocks" single item edit experience #9964

Closed
aduth opened this issue Sep 17, 2018 · 20 comments
Closed
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) Needs Decision Needs a decision to be actionable or relevant Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.

Comments

@aduth
Copy link
Member

aduth commented Sep 17, 2018

Related: #9788

As of #9788, we now surface a "Manage All Reusable Blocks" link to post listing of reusable block types more prominently. The primary use case here (one assumes) is for importing, exporting, or deleting reusable blocks. However, when clicking into the detail page for one of these reusable blocks, the user may be left confused as there is nothing for them to edit or preview in the main column of the single reusable block editor. This is technically to be expected because the wp_block type does not have the editor supports.

Proposal: Should we consider adding editor and/or title support for the reusable block type? Or at least present the user with some preview of the block? Or an explanation as to why they should not expect to see any content in the main column of the editor? Should we add additional labels to avoid defaults such as "Edit Post"?

The main problem seems to be that the original implementation of reusable blocks was made as if they were not intended to be exposed through traditional default scaffolded UI for editing.

image

@aduth aduth added [Type] Enhancement A suggestion for improvement. Needs Design Needs design efforts. [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) Needs Decision Needs a decision to be actionable or relevant labels Sep 17, 2018
@slimmilkduds
Copy link

I 100% vote for adding title and editing support, I see no reason why this shouldnt exist.

@chrisvanpatten
Copy link
Contributor

I think an editing experience would be awesome, and also a great opportunity to test/build functionality for streamlining the Gutenberg UI for non-post/page contexts (hiding taxonomies, simplifying the "publish" flow, hiding scheduling/visibility, etc).

Barring that, a simple preview would be a nice option, with some kind of message on how to edit the reusable block within Gutenberg.

@ZebulanStanphill
Copy link
Member

I definitely think you should be able to edit a Reusable Block by itself in an instance of the Gutenberg editor. It seems weird that you would have to open or create a post just to edit an existing Reusable Block, regardless of whether you want to create/edit a particular post or not. Actually, I think you should also be able to create Reusable Blocks using an Add New button from the Reusable Blocks list, just like any normal post type.

The Divi Builder lets you do this sort of thing with modules/rows/sections saved to its Divi Library:
https://www.elegantthemes.com/documentation/divi/divi-library/

@slimmilkduds
Copy link

To elaborate on my previous comment (and echo a lot of what ZebulanStanphill just wrote):

As a reusable block now support multiple blocks there's a bunch of possibilities with using them as templates (additional thought here: It would be great to have the option to import reusable blocks in to posts as regular blocks and skip the "convert to regular block" step). Being able to open/edit/create these templates as a regular CPT would be so sweet!

I also think it would be great to have taxonomy support to be able to categorise and filter the blocks.

We use Gutenberg for our intranet and we already have 100s (will probably be 1000s in a few weeks) of these blocks. There's a lot of content that we want to re-use all over the place and the reusable blocks in Gutenberg is by far the best implementation of anything like this is Wordpress but in our case the more functionality they have the better. I understand that many users will use it to a less extent than us so many of the features I'm dreaming of could be optional and turned off by default.

@ZebulanStanphill
Copy link
Member

As a reusable block now support multiple blocks there's a bunch of possibilities with using them as templates (additional thought here: It would be great to have the option to import reusable blocks in to posts as regular blocks and skip the "convert to regular block" step). Being able to open/edit/create these templates as a regular CPT would be so sweet!

Speaking of which, I made an issue for this: #8403.

I also think it would be great to have taxonomy support to be able to categorise and filter the blocks.

I agree that the ability to organize Reusable Blocks with categories and tags would be very useful, particularly when you have a lot of them. Divi lets you create categories for stuff saved in the Divi Library, and I think that the Gutenberg Reusable Blocks should allow for something similar.

@youknowriad
Copy link
Contributor

The reusable blocks (templates) are just a regular post type, I wonder how hard it will be to just open Gutenberg with this CPT and edit it like any other CPT supporting editor and show_in_rest

@slimmilkduds
Copy link

The reusable blocks (templates) are just a regular post type, I wonder how hard it will be to just open Gutenberg with this CPT and edit it like any other CPT supporting editor and show_in_rest

I have no idea if it's hard or not, but for me it would be the ultimate solution for sure! I guess that would also allow for setting reading and editing exceptions (with the Press Permit plugin) to specific blocks which is something else I'm dreaming of.

@chrisvanpatten
Copy link
Contributor

@youknowriad just for kicks a few weeks ago I used the register_post_type_args filter to do exactly that and it worked seamlessly. There are random bits and pieces of Gutenberg UI that aren't really necessary and would probably need to be hidden or tweaked but it is a great starting point, especially now that you can have multiple blocks in a reusable block. (That was one limitation before.)

@jasmussen
Copy link
Contributor

Could we show the code editor here?

I would LOVE LOVE LOVE a way to just select all the JSON and share it on pastebin. I fully expect someone to create "blockbin.com" or something in that vein, to streamline this process. I think it's going to be huge.

@slimmilkduds
Copy link

slimmilkduds commented Sep 22, 2018

@chrisvanpatten that sounds like a perfect temp solution for me. You wouldn’t happen to have that code lying around? I’ve looked at the filter documentation but I’m lousy at php and I have no idea what arguments needs to be added to get this funtionallity. Any help would be very appreciated!

@mrpritchett
Copy link

@chrisvanpatten I would also love to see your code for this. +1 to this getting included in Core.

@mrpritchett
Copy link

mrpritchett commented Oct 2, 2018

https://gist.github.com/mrpritchett/06bbec273fd7b6fa658bb3397f8e193c

So I've been able to generate a solution that is most of the way there. The above code will give you an admin menu link to the blocks list, you will be able to click and edit both title and blocks in the editor, but the blocks will be broken on whatever page/post you have them on with the error Block has been deleted or is unavailable. This can be fixed by changing the rest_controller_class back to WP_REST_Blocks_Controller but this causes the block editor for the block itself to brick on our new view. I still haven't found a way to get it working in both locations simultaneously. If you find a way, I'd love to hear it!

@slimmilkduds
Copy link

Cool! I guess your problem with that editing breaks the blocks is the same cause as this: #5754

@slimmilkduds
Copy link

Or this? #9278 Or those might be the same issue, I dont know hehe

@mrpritchett
Copy link

I'll look into those. I was able to get around it at least as a prototype by using different controllers depending on what context I'm in. Not production-ready code, but it works for now.

@slimmilkduds
Copy link

I’ll beta test it for you, I don’t need production ready code, just proof of concepts so I can show people how it (hopefully) will work in the future :)

@mrpritchett
Copy link

The gist above can be placed in your theme's functions.php. Then simply go to the Blocks Admin menu item, create a new reusable block (or modify a pre-existing one) and test that it works both in a page/post editor and on the front end. It works for me. Again, it's not production ready by any means and I wouldn't use it anywhere publicly accessible.

@slimmilkduds
Copy link

The gist works great! I also added taxonomy support to make the block list filterable and made wp_block public which enables presspermit permission capabilities so you can have reading and editing exceptions on reusable blocks, worked straight away in both the post editor and when inserting reusable blocks.

@noisysocks
Copy link
Member

I explored this in #7739 and think it makes sense to do.

#10751 ought to close this issue.

@aduth
Copy link
Member Author

aduth commented Oct 19, 2018

Closed by #10751.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) Needs Decision Needs a decision to be actionable or relevant Needs Design Needs design efforts. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

8 participants