@@ -11,6 +11,9 @@ import {
1111 __experimentalHStack as HStack ,
1212 __experimentalTruncate as Truncate ,
1313} from '@wordpress/components' ;
14+ import { getDefaultBlockName } from '@wordpress/blocks' ;
15+ import { useSelect } from '@wordpress/data' ;
16+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom' ;
1417import { forwardRef } from '@wordpress/element' ;
1518import { Icon , lock } from '@wordpress/icons' ;
1619import { SPACE , ENTER } from '@wordpress/keycodes' ;
@@ -23,6 +26,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
2326import useBlockDisplayTitle from '../block-title/use-block-display-title' ;
2427import ListViewExpander from './expander' ;
2528import { useBlockLock } from '../block-lock' ;
29+ import { store as blockEditorStore } from '../../store' ;
2630
2731function ListViewBlockSelectButton (
2832 {
@@ -38,6 +42,20 @@ function ListViewBlockSelectButton(
3842 } ,
3943 ref
4044) {
45+ const { partialContent } = useSelect (
46+ ( select ) => {
47+ const block = select ( blockEditorStore ) . getBlock ( clientId ) ;
48+ const isDefaultBlock = block ?. name === getDefaultBlockName ( ) ;
49+
50+ return {
51+ partialContent : isDefaultBlock
52+ ? stripHTML ( block ?. attributes ?. content )
53+ : undefined ,
54+ } ;
55+ } ,
56+ [ clientId ]
57+ ) ;
58+
4159 const blockInformation = useBlockDisplayInformation ( clientId ) ;
4260 const blockTitle = useBlockDisplayTitle ( {
4361 clientId,
@@ -89,6 +107,13 @@ function ListViewBlockSelectButton(
89107 < span className = "block-editor-list-view-block-select-button__title" >
90108 < Truncate ellipsizeMode = "auto" > { blockTitle } </ Truncate >
91109 </ span >
110+ { ! ! partialContent && (
111+ < span className = "block-editor-list-view-block-select-button__partial-content" >
112+ < Truncate ellipsizeMode = "auto" >
113+ { partialContent }
114+ </ Truncate >
115+ </ span >
116+ ) }
92117 { blockInformation ?. anchor && (
93118 < span className = "block-editor-list-view-block-select-button__anchor" >
94119 { blockInformation . anchor }
0 commit comments