javascript - initial opentoggle PluginDocumentSettingPanel panel in document setting block editor gutenberg

admin2025-03-19  3

i want make new panel inside document setting tab with React Script from this documentation

but the problem panel not toggle onload/initial i have try open with

dispatch('core/edit-post').toggleEditorPanelOpened('mycustom-panel')

but dont work,i see my custom panel not store in

select( 'core/edit-post' ).getPreference('panels')

so cant toggle it with toggleEditorPanelOpened

this my code to register PluginDocumentSettingPanel

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 } );

i want make new panel inside document setting tab with React Script from this documentation

but the problem panel not toggle onload/initial i have try open with

dispatch('core/edit-post').toggleEditorPanelOpened('mycustom-panel')

but dont work,i see my custom panel not store in

select( 'core/edit-post' ).getPreference('panels')

so cant toggle it with toggleEditorPanelOpened

this my code to register PluginDocumentSettingPanel

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 } );
Share Improve this question asked May 27, 2020 at 1:46 good112233good112233 435 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

This is a known issue in Gutenberg.

You can get this working by passing {plugin-slug}/{panel-name}

For your example, try:

dispatch('core/edit-post').toggleEditorPanelOpened('plugin-document-setting-panel-mycustom/mycustom-panel')

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1742389116a211151.html

最新回复(0)