[PP-1] Add support for Blocks as Components

Created on 19 September 2024, about 2 months ago
Updated 20 September 2024, about 2 months ago

Overview

Requirement list for Experience Builder in row 5 has item defined as “Place blocks as components” (link to spreadsheet). Accompanying this requirement is the following user story:

As a builder, I can place and render blocks and fields rendered via Twig if they are exposed to the page builder as components. Blocks and fields defined in Twig should be able to render both in the preview, and the end-user facing page. This is to enable backwards compatibility with code that already exist in contrib and custom modules.

Currently Component entity is tightly coupled to SDCs, this is being partially resolved in #3469609 📌 Prepare for multiple component types: ComponentTreeStructure should contain Component config entity IDs, not SDC IDs Fixed . However, the Component entity will still be directly tied in 1:1 relationship with single directory components that meet Experience Builder requirements.

Proposed resolution

There seems to be general consensus between @larowlan, @wim-leers, @effulgentsia, @tedbow, @longwave and @fmazeikis that we for we should retain Component entity type, but it needs to be able to function as translation layer between different types of sources, for example - SDCs, Blocks, Layouts and Paragraphs.
@longwave have put it pretty well in 3454519#comment-15778070 🌱 [META] Support component types other than SDC Needs work :

We could try to repurpose SDCs so they can wrap blocks or layouts, but this doesn't conceptually appear to be the right thing to do - SDCs are self contained single directory components by definition, so expanding them with features beyond is scope creep.

We could try to use blocks everywhere and wrap SDCs in blocks, but then we run into the slots issue, and would have to extend blocks so they support slots in some way.

What we are trying to do here is map props/values and slots/components into (at least) three things that are conceptually different (SDCs, blocks, layouts). This is effectively a translation layer and as such should be entirely standalone from the sources and targets of the translation; therefore I think this is the correct direction for this problem.

This issue will adapt some of the code proposed by @larowan in #3454519 🌱 [META] Support component types other than SDC Needs work . Specifically, we will introduce this part of proposal:

Component source plugin

This decouples the component config entity and component tree from SDC components. There's a SingleDirectoryComponent implementation that all the existing logic moves to Adds two additional implementations as follows:

  • Blocks - this will support blocks (e.g. views, menus) as well as a bridge to layout builder

This issue will intentionally not introduce the rest of the proposals of #3454519 🌱 [META] Support component types other than SDC Needs work in order to limit the scope of the issue to blocks. This issue will only add the initial set of "ComponentSourcePlugins" - "SDC Source Plugin" and "Block Source Plugin".
This doesn't mean this implementation is final and other Source Plugins may be introduced in separate issues or the entire approach could change in the future.

User interface changes

We might need to ensure FE part of Experience Builder is able to accept Blocks as Components without completely breaking, but we don't have designs or particular requirements, so UI is likely to be resolved in a follow-up issue.

📌 Task
Status

Active

Component

Config management

Created by

🇬🇧United Kingdom f.mazeikis Brighton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024