我想在“文档设置”选项卡中创建新面板,并从中使用React脚本documentation
但问题面板未切换onload/initial,我已尝试打开
dispatch(\'core/edit-post\').toggleEditorPanelOpened(\'mycustom-panel\')
但不起作用,我看到我的自定义面板未存储在
select( \'core/edit-post\' ).getPreference(\'panels\')
所以不能用
toggleEditorPanelOpened
这是注册插件文档设置面板的我的代码
const { registerPlugin } = wp.plugins;
const { PluginDocumentSettingPanel } = wp.editPost;
const PluginDocumentSettingPanelDemo = () => (
<PluginDocumentSettingPanel
name="mycustom-panel"
title="Tips"
className="mycustom-panel"
>
this is tips to write better content
</PluginDocumentSettingPanel>
);
registerPlugin( \'plugin-document-setting-panel-mycustom\', { render: PluginDocumentSettingPanelDemo, icon: null } );
最合适的回答,由SO网友:Welcher 整理而成
这是一个known issue in Gutenberg.
你可以顺便把它修好{plugin-slug}/{panel-name}
例如,请尝试:
dispatch(\'core/edit-post\').toggleEditorPanelOpened(\'plugin-document-setting-panel-mycustom/mycustom-panel\')