@@ -18,6 +18,7 @@ export default class BrowserCell extends Component {
1818 super ( ) ;
1919
2020 this . cellRef = React . createRef ( ) ;
21+ this . copyableValue = undefined ;
2122 }
2223
2324 componentDidUpdate ( ) {
@@ -36,6 +37,10 @@ export default class BrowserCell extends Component {
3637 } else if ( top < topBoundary || bottom > window . innerHeight ) {
3738 node . scrollIntoView ( { block : 'nearest' , inline : 'nearest' } ) ;
3839 }
40+
41+ if ( ! this . props . hidden ) {
42+ this . props . setCopyableValue ( this . copyableValue ) ;
43+ }
3944 }
4045 }
4146
@@ -58,21 +63,22 @@ export default class BrowserCell extends Component {
5863 }
5964
6065 render ( ) {
61- let { type, value, hidden, width, current, onSelect, onEditChange, setRelation, onPointerClick, row, col } = this . props ;
66+ let { type, value, hidden, width, current, onSelect, onEditChange, setCopyableValue , setRelation, onPointerClick, row, col } = this . props ;
6267 let content = value ;
68+ this . copyableValue = content ;
6369 let classes = [ styles . cell , unselectable ] ;
6470 if ( hidden ) {
6571 content = '(hidden)' ;
6672 classes . push ( styles . empty ) ;
6773 } else if ( value === undefined ) {
6874 if ( type === 'ACL' ) {
69- content = 'Public Read + Write' ;
75+ this . copyableValue = content = 'Public Read + Write' ;
7076 } else {
71- content = '(undefined)' ;
77+ this . copyableValue = content = '(undefined)' ;
7278 classes . push ( styles . empty ) ;
7379 }
7480 } else if ( value === null ) {
75- content = '(null)' ;
81+ this . copyableValue = content = '(null)' ;
7682 classes . push ( styles . empty ) ;
7783 } else if ( value === '' ) {
7884 content = < span > </ span > ;
@@ -88,23 +94,22 @@ export default class BrowserCell extends Component {
8894 < Pill value = { value . id } />
8995 </ a >
9096 ) ;
97+ this . copyableValue = value . id ;
9198 } else if ( type === 'Date' ) {
9299 if ( typeof value === 'object' && value . __type ) {
93100 value = new Date ( value . iso ) ;
94101 } else if ( typeof value === 'string' ) {
95102 value = new Date ( value ) ;
96103 }
97- content = dateStringUTC ( value ) ;
104+ this . copyableValue = content = dateStringUTC ( value ) ;
98105 } else if ( type === 'Boolean' ) {
99- content = value ? 'True' : 'False' ;
106+ this . copyableValue = content = value ? 'True' : 'False' ;
100107 } else if ( type === 'Object' || type === 'Bytes' || type === 'Array' ) {
101- content = JSON . stringify ( value ) ;
108+ this . copyableValue = content = JSON . stringify ( value ) ;
102109 } else if ( type === 'File' ) {
103- if ( value . url ( ) ) {
104- content = < Pill value = { getFileName ( value ) } /> ;
105- } else {
106- content = < Pill value = { 'Uploading\u2026' } /> ;
107- }
110+ const fileName = value . url ( ) ? getFileName ( value ) : 'Uploading\u2026' ;
111+ content = < Pill value = { fileName } /> ;
112+ this . copyableValue = fileName ;
108113 } else if ( type === 'ACL' ) {
109114 let pieces = [ ] ;
110115 let json = value . toJSON ( ) ;
@@ -125,17 +130,18 @@ export default class BrowserCell extends Component {
125130 if ( pieces . length === 0 ) {
126131 pieces . push ( 'Master Key Only' ) ;
127132 }
128- content = pieces . join ( ', ' ) ;
133+ this . copyableValue = content = pieces . join ( ', ' ) ;
129134 } else if ( type === 'GeoPoint' ) {
130- content = `(${ value . latitude } , ${ value . longitude } )` ;
135+ this . copyableValue = content = `(${ value . latitude } , ${ value . longitude } )` ;
131136 } else if ( type === 'Polygon' ) {
132- content = value . coordinates . map ( coord => `(${ coord } )` )
137+ this . copyableValue = content = value . coordinates . map ( coord => `(${ coord } )` )
133138 } else if ( type === 'Relation' ) {
134139 content = (
135140 < div style = { { textAlign : 'center' , cursor : 'pointer' } } >
136141 < Pill onClick = { ( ) => setRelation ( value ) } value = 'View relation' />
137142 </ div >
138143 ) ;
144+ this . copyableValue = undefined ;
139145 }
140146
141147 if ( current ) {
@@ -146,7 +152,10 @@ export default class BrowserCell extends Component {
146152 ref = { this . cellRef }
147153 className = { classes . join ( ' ' ) }
148154 style = { { width } }
149- onClick = { ( ) => onSelect ( { row, col } ) }
155+ onClick = { ( ) => {
156+ onSelect ( { row, col } ) ;
157+ setCopyableValue ( hidden ? undefined : this . copyableValue ) ;
158+ } }
150159 onDoubleClick = { ( ) => {
151160 if ( type !== 'Relation' ) {
152161 onEditChange ( true )
0 commit comments