admin管理员组文章数量:1292183
I have a custom block that needs a URL attribute. I figured it made sense to set the URL in the sidebar or the toolbar, but I can't find a way to do it. I've tried:
LinkControl
Still experimental, and doesn't fit in the sidebar:
or toolbar:
URLInputButton / UrlInput
Doesn't fit in the sidebar or toolbar:
and the dropdown isn't happy in any case:
Is there a recommended way to do this? I've looked at the image block, but that seems to use its own special implementation of LinkControl. The RichText block does it inline, which won't work for me. I'm sure I'm missing something obvious.
I have a custom block that needs a URL attribute. I figured it made sense to set the URL in the sidebar or the toolbar, but I can't find a way to do it. I've tried:
LinkControl
Still experimental, and doesn't fit in the sidebar:
or toolbar:
URLInputButton / UrlInput
Doesn't fit in the sidebar or toolbar:
and the dropdown isn't happy in any case:
Is there a recommended way to do this? I've looked at the image block, but that seems to use its own special implementation of LinkControl. The RichText block does it inline, which won't work for me. I'm sure I'm missing something obvious.
Share Improve this question asked May 27, 2021 at 15:21 Andrew WestAndrew West 1436 bronze badges1 Answer
Reset to default 2UrlInput
uses LinkControl
internally, but neither have been built with the sidebar in mind, they're to be used inside popover components that appear inline such as when a toolbar button is clicked.
They aren't intended to appear directly in toolbars either. Most if not all input components can't be shown in the toolbar, with the exception of buttons for obvious reasons.
If using this component causes overflow in the sidebar, then you need to report this as a bug in the Gutenberg Github issues as soon as possible so that it can be fixed.
Otherwise this is the closest you will find currently to a canonical post/URL selection input. I suggest for the moment that you print the URL value and show an edit button next to it that triggers a popover component containing the link control
本文标签: block editorWhat39s the recommended Gutenberg component for adding a URLin the toolbarsidebar
版权声明:本文标题:block editor - What's the recommended Gutenberg component for adding a URL, in the toolbarsidebar? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741534247a2383938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论