diff --git a/packages/block-editor/src/components/inserter-list-item/index.js b/packages/block-editor/src/components/inserter-list-item/index.js index f791dfb5fdc2ae..9fdf42f91eeb93 100644 --- a/packages/block-editor/src/components/inserter-list-item/index.js +++ b/packages/block-editor/src/components/inserter-list-item/index.js @@ -11,7 +11,6 @@ import { createBlock, createBlocksFromInnerBlocksTemplate, } from '@wordpress/blocks'; -import { __experimentalTruncate as Truncate } from '@wordpress/components'; import { ENTER } from '@wordpress/keycodes'; /** @@ -136,9 +135,7 @@ function InserterListItem( { - - { item.title } - + { item.title } diff --git a/packages/block-editor/src/components/inserter/preview-panel.js b/packages/block-editor/src/components/inserter/preview-panel.js index 2814975c329d22..f6508a0a9d363a 100644 --- a/packages/block-editor/src/components/inserter/preview-panel.js +++ b/packages/block-editor/src/components/inserter/preview-panel.js @@ -5,6 +5,7 @@ import { isReusableBlock, createBlock, getBlockFromExample, + getBlockType, } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; @@ -15,24 +16,31 @@ import BlockCard from '../block-card'; import BlockPreview from '../block-preview'; function InserterPreviewPanel( { item } ) { - const { name, title, icon, description, initialAttributes, example } = item; + const { name, title, icon, description, initialAttributes } = item; + const hoveredItemBlockType = getBlockType( name ); const isReusable = isReusableBlock( item ); return (
- { isReusable || example ? ( + { isReusable || hoveredItemBlockType?.example ? (
'wp_template_part', - ), - 'wp_template_part' - ); - - $defined_areas = get_allowed_block_template_part_areas(); - $icon_by_area = array_combine( array_column( $defined_areas, 'area' ), array_column( $defined_areas, 'icon' ) ); - - foreach ( $template_parts as $template_part ) { - $variations[] = array( - 'name' => sanitize_title( $template_part->slug ), - 'title' => $template_part->title, - // If there's no description for the template part don't show the - // block description. This is a bit hacky, but prevent the fallback - // by using a non-breaking space so that the value of description - // isn't falsey. - 'description' => $template_part->description || ' ', - 'attributes' => array( - 'slug' => $template_part->slug, - 'theme' => $template_part->theme, - 'area' => $template_part->area, - ), - 'scope' => array( 'inserter' ), - 'icon' => $icon_by_area[ $template_part->area ], - 'example' => array( - 'attributes' => array( - 'slug' => $template_part->slug, - 'theme' => $template_part->theme, - 'area' => $template_part->area, - ), - ), - ); - } - return $variations; -} - -/** - * Returns an array of all template part block variations. - * - * @return array Array containing the block variation objects. - */ -function build_template_part_block_variations() { - return array_merge( build_template_part_block_area_variations(), build_template_part_block_instance_variations() ); -} - /** * Registers the `core/template-part` block on the server. */