gutenberg change html attributes of custom block
-
I want to create a custom row/column block (since the core doesn’t offer the features I need) using a wrapper and innerblocks. I want to change the appeareance of the columns in the editor depending on the values set (like the core/columns but with custom values) but I don’t know how to do that. Possible could be a custom class name or custom data-* attributes.
To clarify: I want these on the parents of the innerblock that are siblings to each other. Otherwise styling wouldn’t work since wordpress wraps the result in multiple children. So just adding a “wrapper” in the return function is not enough.
This
<div className="wrap"> <InnerBlocks /> </div>
would result in this
<div class="block-row"> <!-- my parent --> <div class="editor-inner-blocks block-editor-inner-blocks"> <div class="editor-block-list__layout block-editor-block-list__layout"> <div class="wp-block editor-block-list__block block-editor-block-list__block"> <!-- here I need my custom class/attributes--> <div class="editor-block-list__block-edit block-editor-block-list__block-edit"> <div> <div class="wrap"> <!-- here starts the "wrapper" of the innerblock (way too late) --> ... </div> </div> </div> </div> </div> </div> </div>
Extending the core block would also be an option but they key problem stays that I don’t know how to modify the appeareance since I have no matching selectors in css.
The only dirty way I know to solve this is by injecting javascript but I guess that’s not the right way to do it.
- The topic ‘gutenberg change html attributes of custom block’ is closed to new replies.