我现在想知道是否有可能过滤古腾堡组件,而不是块。例如,我需要在每个DropDownMenu 组件,可通过更改;“控件”;变量
今天,如果需要向每个块添加新的Inspector控件,我可以使用:
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
);
然后用enqueue_block_editor_assets 行动它工作得很好,但是,我找不到任何方法来对组件执行相同的操作。有可能吗?
非常感谢。