但是,事实并非如此,任何帮助将不胜感激
const { createHigherOrderComponent } = wp.compose;
const withCustomClassName = createHigherOrderComponent( ( BlockListBlock ) => {
return (props) => {
if (props.name !== 'core/heading') return <BlockListBlock {...props} />
const { attributes } = props
return <BlockListBlock { ...props } className={ "custom-classes-" + attributes.fontSizeChoice } />
};
}, 'withCustomClassName');
wp.hooks.addFilter( 'editor.BlockListBlock', 'custom-name/heading-with-custom-class-name', withCustomClassName );
答案 0 :(得分:0)
原来我使用的是古腾堡的旧版本,最新版本9+允许此代码按预期工作。