@@ -40,8 +40,50 @@ type TextListLike = TextLike | TextLike[];
4040const textOf = ( value : TextLike ) => {
4141 if ( ! value ) return '' ;
4242
43- if ( typeof value === 'object' && ! Array . isArray ( value ) )
44- return 'name' in value ? ( value . name || '' ) . trim ( ) : '' ;
43+ if ( typeof value === 'object' && ! Array . isArray ( value ) ) {
44+ const {
45+ name,
46+ text,
47+ value : primitiveValue ,
48+ displayName,
49+ display_name,
50+ title,
51+ content,
52+ plainText,
53+ plain_text,
54+ user,
55+ } = value as NamedLike & {
56+ text ?: string | null ;
57+ value ?: string | number | null ;
58+ displayName ?: string | null ;
59+ display_name ?: string | null ;
60+ title ?: string | null ;
61+ content ?: string | null ;
62+ plainText ?: string | null ;
63+ plain_text ?: string | null ;
64+ user ?: {
65+ name ?: string | null ;
66+ displayName ?: string | null ;
67+ display_name ?: string | null ;
68+ } | null ;
69+ } ;
70+ const candidate = [
71+ name ,
72+ text ,
73+ primitiveValue ,
74+ displayName ,
75+ display_name ,
76+ title ,
77+ content ,
78+ plainText ,
79+ plain_text ,
80+ user ?. displayName ,
81+ user ?. display_name ,
82+ user ?. name ,
83+ ] . find ( item => item !== null && item !== undefined && `${ item } ` . trim ( ) ) ;
84+
85+ return candidate === null || candidate === undefined ? '' : `${ candidate } ` . trim ( ) ;
86+ }
4587
4688 const text = value . toString ( ) . trim ( ) ;
4789
@@ -111,7 +153,7 @@ export const resolveCountdownState = <T extends CountdownWindow>(
111153
112154export const previewText = ( items : TableCellValue [ ] , fallback : string ) =>
113155 items
114- . map ( item => item ?. toString ( ) )
156+ . map ( item => textOf ( item ) )
115157 . filter ( Boolean )
116158 . slice ( 0 , 2 )
117159 . join ( ' · ' ) || fallback ;
@@ -146,10 +188,10 @@ export const compactSummaryOf = (
146188) => {
147189 const source = Array . isArray ( text )
148190 ? text
149- . map ( item => item ?. toString ( ) )
191+ . map ( item => textOf ( item ) )
150192 . filter ( Boolean )
151193 . join ( ' · ' )
152- : text ?. toString ( ) || '' ;
194+ : textOf ( text ) ;
153195 const normalized = source . replace ( / \s + / g, ' ' ) . trim ( ) ;
154196
155197 if ( ! normalized ) return fallback ;
0 commit comments