WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Navigation Block: develop a content-only representation #65699

Open mtias opened 1 month ago

mtias commented 1 month ago

There should be a way to make edits to your menu while on content-only mode. The canvas edits should be restricted but the inspector menu should be reachable.

We should explore exposing the "menu list view" in the inspector of template parts or patterns that contain a menu when the user is on content-only mode.

There should be a clear way to reach that panel from the toolbar of the nav block and the template/pattern. Could be an "edit menu" that just toggles the inspector with the tab for the menu open.

youknowriad commented 1 month ago

How do you see this kind of feature being "declared" for block types. In other words, until now, block types were not aware about whether they are in "content only" mode or not. We only detected blocks that have a "content" role attribute and allowed some specific behavior there. How do you see that evolving, should block types receive some kind of isSection flag and enable/disable behavior.

mtias commented 1 month ago

I don't think we should abstract this too soon. The navigation block already has a special tab in the inspector, so perhaps it's part of formalizing that view down the road. Conceptually, I don't think blocks should be made aware of "modes".

getdave commented 1 month ago

Related

SaxonF commented 1 month ago

I think we can tie this work into the content only stream as well as synced patterns in a few iterative ways.

  1. Add an "edit menu" button to the Navigation Block toolbar. This is not directly related to content only but it helps to resolve some of the same pain points. The navigation block would be special in that other blocks would go with a generalised label and less prominent action.
  2. Treat template parts in the same way as synced patterns. Clicking a template part should always select the template part which contains an edit button. Clicking the edit button puts us into focus mode for the part (like synced patterns) with the inspector open. You can currently select the site ltitle block within a template part directly for example.
  3. When editing a template part, and in an content only mode, show editable blocks in the inspector. An editable block may site logo, site title or navigation block.
  4. Adjust the content only behaviour so that clicking a block that has deeper attributes (like navigation block) it drills down in the inspector but offers a pathway back up. This has previously been explored by @talldan as part of https://github.com/WordPress/gutenberg/issues/60021
  5. Allow the selection of template part when in the new zoom out / content only mode.

It may look something like this

https://github.com/user-attachments/assets/e0456bda-d899-4710-bb94-0215b5943135

The above shows two ways of accessing a menu. The first via the content list, and the second via the canvas with an "edit menu" button that just opens inspector with menu tab open.

In future we can look at surfacing overridable properties directly vs drilling down like what is proposed above.

draganescu commented 2 weeks ago

until now, block types were not aware about whether they are in "content only" mode or not.

Conceptually, I don't think blocks should be made aware of "modes".

If blocks are not aware of the mode they're in than something like #60412 can't work. Either the block tells the block editor that something is editable in content only, or the block editor designates what is content in content only. We went the first route and the block tells the block editor via the role prop of attributes what's editable in content only.

But the navigation block does not really have any content. The content is stored in the navigation link and navigation submenu blocks which are navigation block children. Updating the defition of these two types (link and submenu) to include role content on attributes whcih are content partly gets us there.

https://github.com/user-attachments/assets/d3a8f82a-cd94-4cee-9cf1-fab758f1fd79

But, what is lost, we can't see the tree of links 😢 However that seems to be an issue for the whole block tree which is flattened in content only.

  1. What's the problem with preserving the flat block tree for navigation as well?
  2. What is wrong with editing on canvas? Why would we want the navigation list view? @richtabor expressed his concern about adding drilldown to content only, which is kinda the same with the proposal above (an edit button in navigation's block toolbar). I think we used to have one ...

About 2 there is something else to consider: if a user is only expected to replace pictures and text, then why do we expect them to rearrange the site's hierarchy?

draganescu commented 2 weeks ago

This could work in a world where we show controls for every attribute with role content in the inspector. That could work by allowing blocks to register these controls for the inspector when they are in content only for whatever reason. Then the navigation block could register this whole list view thing.

draganescu commented 1 week ago

A bit of trial and error:

So we need some things to achieve this style of editing:

draganescu commented 1 week ago

Follow-up from a discussion with @youknowriad we can update content only to:

This is a good start for an exploratory phase which could answer things like: