当我在define( 'SCRIPT_DEBUG', true );
中有wp-config.php
时,通过调用此钩子editor.BlockListBlock
可以收到正确的对象。当我有define( 'SCRIPT_DEBUG', false );
或未定义时,我收到错误的对象。
const { createHigherOrderComponent } = wp.compose;
const withClientIdClassName = createHigherOrderComponent( ( BlockListBlock ) => {
// BlockListBlock returns as "WithSelect" with debug off
// and returns as the correct component with debug on
console.log(BlockListBlock);
return ( props ) => {
const {attributes, name} = props;
if(name === 'project/block-name'){
return <BlockListBlock { ...props } className={'classes-i-want-on-this'} />;
} else {
return <BlockListBlock { ...props } />;
}
};
}, 'withClientIdClassName' );
wp.hooks.addFilter( 'editor.BlockListBlock', 'classNames-for-cells', withClientIdClassName );
未定义SCRIPT_DEBUG或为假
SCRIPT_DEBUG为真