• Hi, my plugin consists of multiple blocks:

    • One container block
    • Multiple inner blocks inside that container block

    I want to use block variations and block filters (based on core blocks) INSIDE my container block. The problem is the modifications are applied to core blocks that are inside and OUTSIDE of my plugin’s container block.

    In other words, I want to apply block filters and variations only to my plugin’s blocks, not blocks outside of my plugin.

    I tried making a variation and using addFilter to add a parent property to that variation, hoping that variation is restricted to my container block. It didn’t work! addFilter only works on original blocks.

    How to limit the modifications to only my plugin’s blocks?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • To my knowledge, what you are looking for is not currently possible. There is no way to detect where a specific block is located when registering block variations and when using most filters. The blockEditor.useSetting.before filter is context aware, and you can learn more about it in this article, but it won’t solve the issue you are dealing with unfortunately.

    Thread Starter Huan

    (@daodaotw)

    Thank you Nick. Block variations and filters sound fantastic until I realize they are indiscriminate. I hope they can be applied based on namespace, or ancestor/parent property.

    In terms of inner blocks, allowedBlocks should be passed to all descendants and descendants should be able to override allowedBlocks. To my fuzzy knowledge, someone opened a related issue in Github?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Prevent block variations and filters from polluting the entire block editor’ is closed to new replies.