使用核心WP Gutenberg模块是很棒的,但在某些情况下,我想改进可用的选项,以改善我的客户的用户体验,并避免他们有太多的选项。
例如,在标题块中,我想删除“级别”对齐和H6,以及所有“对齐”选项。
在段落块中,我想禁用“字体大小”和“首字下沉”选项。
我已经搜索了API文档,但没有找到。
发布于 2019-06-16 15:24:58
您可以使用editor.BlockEdit
过滤器。我复制了手册中的示例以将其持久化。
const { createHigherOrderComponent } = wp.compose;
const { Fragment } = wp.element;
const { InspectorControls } = wp.editor;
const { PanelBody } = wp.components;
const withInspectorControls = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
return (
<Fragment>
<BlockEdit { ...props } />
<InspectorControls>
<PanelBody>
My custom control
</PanelBody>
</InspectorControls>
</Fragment>
);
};
}, "withInspectorControl" );
wp.hooks.addFilter( 'editor.BlockEdit', 'my-plugin/with-inspector-controls', withInspectorControls );
您要更改的是块 <Toolbar>
-Component。
https://stackoverflow.com/questions/55950961
复制相似问题