@@ -27,58 +27,68 @@ const isValidStartTime = (cellData?: TimeSlice[]): boolean =>
2727 Array . isArray ( cellData ) && ! ! cellData [ 0 ] && typeof cellData [ 0 ] . start === 'number' ;
2828
2929const Transcript = ( { skill : { entries } , getPreviewer } : Props ) =>
30- < AutoSizer disableHeight >
31- { ( { width } ) =>
32- < Table
33- width = { width }
34- height = { 300 }
35- disableHeader
36- headerHeight = { 0 }
37- rowHeight = { cache . rowHeight }
38- rowCount = { entries . length }
39- rowGetter = { ( { index } ) => entries [ index ] }
40- className = 'buik-transcript'
41- deferredMeasurementCache = { cache }
42- onRowClick = { ( { rowData } : { rowData : SkillDataEntry } ) : void => {
43- const viewer = getPreviewer ? getPreviewer ( ) : null ;
44- const cellData = rowData . appears ;
45- if (
46- isValidStartTime ( cellData ) &&
47- viewer &&
48- viewer . isLoaded ( ) &&
49- ! viewer . isDestroyed ( ) &&
50- typeof viewer . play === 'function'
51- ) {
52- // $FlowFixMe Already checked above
53- const { start, end } = cellData [ 0 ] ;
54- viewer . play ( start , end ) ;
55- }
56- } }
57- >
58- < Column
59- dataKey = 'appears'
60- width = { 50 }
61- flexShrink = { 0 }
62- cellRenderer = { ( { cellData } ) : string =>
63- isValidStartTime ( cellData ) ? formatTime ( cellData [ 0 ] . start ) : '--' }
64- />
65- < Column
66- dataKey = 'text'
67- width = { 240 }
68- flexGrow = { 1 }
69- cellRenderer= { ( { dataKey, parent, rowIndex, cellData } ) =>
70- < CellMeasurer cache = { cache } columnIndex = { 0 } key = { dataKey } parent = { parent } rowIndex = { rowIndex } >
71- < div
72- className = 'buik-transcript-column'
73- style = { {
74- whiteSpace : 'normal'
75- } }
76- >
77- { ( cellData || '' ) . replace ( / \r ? \n | \r / g, '' ) }
78- </ div >
79- </ CellMeasurer > }
80- / >
81- </Table > }
82- </AutoSizer > ;
30+ entries . length === 1 && ! isValidStartTime ( entries [ 0 ] . appears )
31+ ? < span className = 'buik-transcript' >
32+ { entries [ 0 ] . text }
33+ </ span >
34+ : < AutoSizer disableHeight >
35+ { ( { width } ) =>
36+ < Table
37+ width = { width }
38+ height = { 300 }
39+ disableHeader
40+ headerHeight = { 0 }
41+ rowHeight = { cache . rowHeight }
42+ rowCount = { entries . length }
43+ rowGetter = { ( { index } ) => entries [ index ] }
44+ className = 'buik-transcript'
45+ deferredMeasurementCache = { cache }
46+ onRowClick = { ( { rowData } : { rowData : SkillDataEntry } ) : void => {
47+ const viewer = getPreviewer ? getPreviewer ( ) : null ;
48+ const cellData = rowData . appears ;
49+ if (
50+ isValidStartTime ( cellData ) &&
51+ viewer &&
52+ viewer . isLoaded ( ) &&
53+ ! viewer . isDestroyed ( ) &&
54+ typeof viewer . play === 'function'
55+ ) {
56+ // $FlowFixMe Already checked above
57+ const { start, end } = cellData [ 0 ] ;
58+ viewer . play ( start , end ) ;
59+ }
60+ } }
61+ >
62+ < Column
63+ dataKey = 'appears'
64+ width = { 50 }
65+ flexShrink = { 0 }
66+ cellRenderer = { ( { cellData } ) : string =>
67+ isValidStartTime ( cellData ) ? formatTime ( cellData [ 0 ] . start ) : '--' }
68+ />
69+ < Column
70+ dataKey = 'text'
71+ width = { 240 }
72+ flexGrow = { 1 }
73+ cellRenderer= { ( { dataKey, parent, rowIndex, cellData } ) =>
74+ < CellMeasurer
75+ cache = { cache }
76+ columnIndex = { 0 }
77+ key = { dataKey }
78+ parent = { parent }
79+ rowIndex = { rowIndex }
80+ >
81+ < div
82+ className = 'buik-transcript-column'
83+ style = { {
84+ whiteSpace : 'normal'
85+ } }
86+ >
87+ { ( cellData || '' ) . replace ( / \r ? \n | \r / g, '' ) }
88+ </ div >
89+ </ CellMeasurer > }
90+ / >
91+ </Table > }
92+ </AutoSizer > ;
8393
8494export default Transcript ;
0 commit comments