@@ -12,11 +12,14 @@ const codes: { [key: string]: any } = {
1212 '\0' : 'U+0000' ,
1313 '\b' : 'U+0008' ,
1414 '\t' : 'U+0009' ,
15- '\n' : 'U+000A' ,
1615 '\v' : 'U+000B' ,
1716 '\r' : 'U+000D'
1817} ;
1918
19+ function onlyNewLine ( element : string , index : number , array : string [ ] ) {
20+ return element === '\n' ;
21+ }
22+
2023export default function RawTableValue ( props : Props ) : JSX . Element {
2124 const rawValue = props . value ;
2225
@@ -26,12 +29,17 @@ export default function RawTableValue(props: Props): JSX.Element {
2629 || typeof rawValue === 'boolean'
2730 ) {
2831 const text = rawValue . toString ( ) ;
29- const newVal = text . split ( '' ) ;
30- for ( let i = 0 ; i < newVal . length ; i ++ ) {
31- newVal [ i ] = codes [ newVal [ i ] ] || newVal [ i ] ;
32+ const newVal = text . split ( '' ) . filter ( ( element : string ) => element !== ' ' ) ;
33+ if ( newVal . every ( onlyNewLine ) ) {
34+ const cleanVal = '[' + newVal . join ( '' ) + ']' ;
35+ return < span > { cleanVal } </ span > ;
36+ } else {
37+ for ( let i = 0 ; i < newVal . length ; i ++ ) {
38+ newVal [ i ] = codes [ newVal [ i ] ] || newVal [ i ] ;
39+ }
40+ const cleanVal = newVal . join ( '' ) ;
41+ return < span > { cleanVal } </ span > ;
3242 }
33- const cleanVal = newVal . join ( '' ) ;
34- return < span > { cleanVal } </ span > ;
3543 }
3644
3745 return renderLocation ( rawValue . url , rawValue . label , props . databaseUri ) ;
0 commit comments