古腾堡元数据使用侧边栏插件添加 MediaUpload

问题描述

我设法在 Gutenberg 中为元数据创建了一个侧边栏。一切正常,我什至可以保存数据。 我的问题是我无法实现加载图像的组件。 这是我的代码

const { registerPlugin } = wp.plugins;
const { __ } = wp.i18n;
const { Fragment,useState } = wp.element;
const { PluginSidebarMoreMenuItem,PluginSidebar } = wp.editPost;
const { Panel,PanelBody,PanelRow,ToggleControl,SelectControl,Guide,ButtonGroup,Button,RangeControl,ColorPicker,Card,CardBody,CardMedia,CardDivider,RadioControl,TextControl,FormFileUpload,IconButton } = wp.components;
const { compose } = wp.compose;
const { withdispatch,withSelect,select } = wp.data;

const { MediaUpload,MediaUploadCheck,MediaPlaceholder } = wp.blockEditor;




const CustomSidebarMetaComponent = (props) => {

    return(
        <Fragment> 
           {/* My Code */}
        </Fragment>
    );
}


const CustomSidebarMeta = compose([

    // My Code

])(CustomSidebarMetaComponent);



// Sidebar
const CustomSidebarComponent = () => {
    const postType = select("core/editor").getCurrentPostType();
    if ( !includes(["df_plus_block"],postType) ) {
      return null;
    }
    return(
        <>
            <PluginSidebarMoreMenuItem 
                target='df-custom-sidebar'
                icon='screenoptions'
            >{__('DF Block Settings','df-sidebar-gutenberg')}
            </PluginSidebarMoreMenuItem>
            <PluginSidebar 
                name="df-custom-sidebar" 
                title={__('DF Block Settings','df-sidebar-gutenberg')}
            >                
                <PanelBody
                    title={__('Layout','df-sidebar-gutenberg')}
                    initialOpen={true}
                >
                    <CustomSidebarMeta />
                </PanelBody>
            </PluginSidebar>
        </>
    );
}

任何建议将不胜感激,谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)