如何解决在编辑器中向Gutenberg块包装器添加其他类
此代码应能够基于https://wordpress.stackexchange.com/questions/324091/add-classname-to-gutenberg-block-wrapper-in-the-editor
添加其他类块包装器元素但是,事实并非如此,任何帮助将不胜感激
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 );
解决方法
原来我使用的是古腾堡的旧版本,最新版本9+允许此代码按预期工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。