admin管理员组文章数量:1022679
Gutenberg has MediaUpload component that allows selecting images from media library (its docs).
It allows to pass button to a render property, for example:
<MediaUpload
onSelect={ ( media ) => console.log( 'selected ' + media.length ) }
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ mediaId }
render={ ( { open } ) => (
<Button onClick={ open }>
Open Media Library
</Button>
) }
/>
But I also have another component (outside of the render function), doubleclick on it should open the same media library.
<AnotherComponent
ondoubleclick={ /* how do I open the same media modal here? */ }
></AnotherComponent>
Is there some way to do it with a single <MediaUpload/>
component, or I need multiple?
Gutenberg has MediaUpload component that allows selecting images from media library (its docs).
It allows to pass button to a render property, for example:
<MediaUpload
onSelect={ ( media ) => console.log( 'selected ' + media.length ) }
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ mediaId }
render={ ( { open } ) => (
<Button onClick={ open }>
Open Media Library
</Button>
) }
/>
But I also have another component (outside of the render function), doubleclick on it should open the same media library.
<AnotherComponent
ondoubleclick={ /* how do I open the same media modal here? */ }
></AnotherComponent>
Is there some way to do it with a single <MediaUpload/>
component, or I need multiple?
本文标签: javascriptOpen MediaUpload from external component in Gutenberg
版权声明:本文标题:javascript - Open MediaUpload from external component in Gutenberg 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745492546a2153025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论