Skip to content

Webcomponents with slots and InnerBlocks limitation #18778

@paales

Description

@paales

I’m trying to get webcomponents working with Gutenberg. I’ve got a webcomponent that has two slots. Those two slots allow for any content to be present:

<fancy-layout size="large" stretch="right">
  <div slot="left">Content goes here</div>
  <div slot="right">Secondary content goes here</div>
</fancy-layout>

I've been trying to build a custom block that allows me to fill those two slots, but it seems it's impossible to do so. I've tried to use <InnerBlocks /> template system, but it seems it will always add wrapper divs, which makes it impossible to actually achieve this structure.

There has been some discussion to actually solve this at the webcomponent level, but because of good reasons it hasn't been implemented WICG/webcomponents#574

I think it should be possible to define multiple areas where we can actually have a blocklist available.

<fancy-layout size="large" stretch="right">
  <div slot="left"><InnerBlocks onContent={(content) => setAttributes({left: content})}/></div>
  <div slot="right"><InnerBlocks onContent={(content) => setAttributes({right: content})}/></div>
</fancy-layout>

Disclaimer: I'm not familiair enough with the internal of Gutenberg yet, so I might be missing something how to actually achieve this with the current setup..

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Nested / Inner BlocksAnything related to the experience of nested/inner blocks inside a larger container, like Group or P[Type] DiscussionFor issues that are high-level and not yet ready to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions