admin管理员组

文章数量:1128331

I've had a problem blocking me for days...

I have extended the core block 'core/group'. The extension inserts an (overlay) div into the container and wraps the InnerBlocks into another div so that the structure looks like this

<div>
   <div>overlay</div>
   <div class="wrapper">
      ... InnerBlocks
   </div>
</div>

I use 3 filter hooks for this:

  1. 'blocks.getSaveElement'. Here the structure is modified before saving. This works without any problems by cloning the passed element and modifying it accordingly.

  2. 'blocks.registerBlockType'. Here I add the additional attributes... also non-critical

  3. 'editor.BlockEdit'. Here the controls for the InspectorControls are added to fill the attributes. This also works without any problems... However, the filter function is given an object 'BlockEdit', which looks like a functional component that is created by the edit function. This component cannot be modified because it does not have static content but only creates it when it is executed.

When I try to run the component and output the content (a fragment with two elements) along with the additional controls, it has no effect. Therefore it is apparently not possible to bring the changes that work in the frontend into the editor.

The documentation is superficial and not really helpful. I couldn't find any working examples.

Hence my call for help at this point... Does anyone know of a working example or knows how I can make the block's structural changes visible in the block editor too

本文标签: HowTo modify BlockEditComponent in FilterHooks for coreblock Extensions