diff --git a/packages/block-editor/src/components/link-control/search-item.js b/packages/block-editor/src/components/link-control/search-item.js index 62dcf6f61fd84e..a1ef09d2fc3612 100644 --- a/packages/block-editor/src/components/link-control/search-item.js +++ b/packages/block-editor/src/components/link-control/search-item.js @@ -9,7 +9,44 @@ import classnames from 'classnames'; import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url'; import { __ } from '@wordpress/i18n'; import { Button, TextHighlight } from '@wordpress/components'; -import { Icon, globe } from '@wordpress/icons'; +import { + Icon, + globe, + page, + tag, + postList, + category, + file, +} from '@wordpress/icons'; + +const ICONS_MAP = { + post: postList, + page, + post_tag: tag, + category, + attachment: file, +}; + +function SearchItemIcon( { isURL, suggestion } ) { + let icon = null; + + if ( isURL ) { + icon = globe; + } else if ( suggestion.type in ICONS_MAP ) { + icon = ICONS_MAP[ suggestion.type ]; + } + + if ( icon ) { + return ( + + ); + } + + return null; +} export const LinkControlSearchItem = ( { itemProps, @@ -30,12 +67,7 @@ export const LinkControlSearchItem = ( { 'is-entity': ! isURL, } ) } > - { isURL && ( - - ) } +