Site icon Hip-Hop Website Design and Development

Filtering Gutenberg Components, not Blocks

I’m currently wondering if it’s possible to filter Gutenberg Components, instead of Blocks. For example, I need to add a new item to every DropDownMenu component, which could be achieved by changing the "controls" variable.

Today, if I need to add a new Inspector Control to every Block, I can do it using:

var el = wp.element.createElement;
 
var withInspectorControls = wp.compose.createHigherOrderComponent( function (
    BlockEdit
) {
    return function ( props ) {
        return el(
            wp.element.Fragment,
            {},
            el( BlockEdit, props ),
            el(
                wp.blockEditor.InspectorControls,
                {},
                el( wp.components.PanelBody, {}, 'My custom control' )
            )
        );
    };
},
'withInspectorControls' );
 
wp.hooks.addFilter(
    'editor.BlockEdit',
    'my-plugin/with-inspector-controls',
    withInspectorControls
);

And then hooking the JavaScript file with the enqueue_block_editor_assets action.

It works perfectly, however, I couldn’t find any approach to do the same thing with Components. Is it possible?

Thank you!