-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block type: add support link #11330
Block type: add support link #11330
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { isEmpty } from 'lodash'; | |
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { getBlockType, getUnregisteredTypeHandlerName } from '@wordpress/blocks'; | ||
import { PanelBody } from '@wordpress/components'; | ||
import { ExternalLink, PanelBody } from '@wordpress/components'; | ||
import { withSelect } from '@wordpress/data'; | ||
import { Fragment } from '@wordpress/element'; | ||
|
||
|
@@ -37,13 +37,30 @@ const BlockInspector = ( { selectedBlock, blockType, count } ) => { | |
return <span className="editor-block-inspector__no-blocks">{ __( 'No block selected.' ) }</span>; | ||
} | ||
|
||
const hasSupportLink = blockType.support && blockType.support.url && blockType.support.label; | ||
|
||
return ( | ||
<Fragment> | ||
<div className="editor-block-inspector__card"> | ||
<BlockIcon icon={ blockType.icon } showColors /> | ||
<div className="editor-block-inspector__card-content"> | ||
<div className="editor-block-inspector__card-title">{ blockType.title }</div> | ||
<div className="editor-block-inspector__card-description">{ blockType.description }</div> | ||
{ hasSupportLink && ( | ||
<div className="editor-block-inspector__card-support"> | ||
{ | ||
blockType.support.external ? ( | ||
<ExternalLink href={ blockType.support.url }> | ||
{ blockType.support.label } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prolly need to cast this as a string to be on the safe side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Did you still intend to make this change? |
||
</ExternalLink> | ||
) : ( | ||
<a href={ blockType.support.url }> | ||
{ blockType.support.label } | ||
</a> | ||
) | ||
} | ||
</div> | ||
) } | ||
</div> | ||
</div> | ||
{ !! blockType.styles && ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what makes a support link "external"? Is it based on the origin/hostname of the URL, and if so, is that not something we should programmatically determine on behalf of the block developer, than to impose on them?