@@ -18,6 +18,7 @@ export default class BrowserCell extends Component {
18
18
super ( ) ;
19
19
20
20
this . cellRef = React . createRef ( ) ;
21
+ this . copyableValue = undefined ;
21
22
}
22
23
23
24
componentDidUpdate ( ) {
@@ -36,6 +37,10 @@ export default class BrowserCell extends Component {
36
37
} else if ( top < topBoundary || bottom > window . innerHeight ) {
37
38
node . scrollIntoView ( { block : 'nearest' , inline : 'nearest' } ) ;
38
39
}
40
+
41
+ if ( ! this . props . hidden ) {
42
+ this . props . setCopyableValue ( this . copyableValue ) ;
43
+ }
39
44
}
40
45
}
41
46
@@ -58,21 +63,22 @@ export default class BrowserCell extends Component {
58
63
}
59
64
60
65
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 ;
62
67
let content = value ;
68
+ this . copyableValue = content ;
63
69
let classes = [ styles . cell , unselectable ] ;
64
70
if ( hidden ) {
65
71
content = '(hidden)' ;
66
72
classes . push ( styles . empty ) ;
67
73
} else if ( value === undefined ) {
68
74
if ( type === 'ACL' ) {
69
- content = 'Public Read + Write' ;
75
+ this . copyableValue = content = 'Public Read + Write' ;
70
76
} else {
71
- content = '(undefined)' ;
77
+ this . copyableValue = content = '(undefined)' ;
72
78
classes . push ( styles . empty ) ;
73
79
}
74
80
} else if ( value === null ) {
75
- content = '(null)' ;
81
+ this . copyableValue = content = '(null)' ;
76
82
classes . push ( styles . empty ) ;
77
83
} else if ( value === '' ) {
78
84
content = < span > </ span > ;
@@ -88,23 +94,22 @@ export default class BrowserCell extends Component {
88
94
< Pill value = { value . id } />
89
95
</ a >
90
96
) ;
97
+ this . copyableValue = value . id ;
91
98
} else if ( type === 'Date' ) {
92
99
if ( typeof value === 'object' && value . __type ) {
93
100
value = new Date ( value . iso ) ;
94
101
} else if ( typeof value === 'string' ) {
95
102
value = new Date ( value ) ;
96
103
}
97
- content = dateStringUTC ( value ) ;
104
+ this . copyableValue = content = dateStringUTC ( value ) ;
98
105
} else if ( type === 'Boolean' ) {
99
- content = value ? 'True' : 'False' ;
106
+ this . copyableValue = content = value ? 'True' : 'False' ;
100
107
} else if ( type === 'Object' || type === 'Bytes' || type === 'Array' ) {
101
- content = JSON . stringify ( value ) ;
108
+ this . copyableValue = content = JSON . stringify ( value ) ;
102
109
} 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 ;
108
113
} else if ( type === 'ACL' ) {
109
114
let pieces = [ ] ;
110
115
let json = value . toJSON ( ) ;
@@ -125,17 +130,18 @@ export default class BrowserCell extends Component {
125
130
if ( pieces . length === 0 ) {
126
131
pieces . push ( 'Master Key Only' ) ;
127
132
}
128
- content = pieces . join ( ', ' ) ;
133
+ this . copyableValue = content = pieces . join ( ', ' ) ;
129
134
} else if ( type === 'GeoPoint' ) {
130
- content = `(${ value . latitude } , ${ value . longitude } )` ;
135
+ this . copyableValue = content = `(${ value . latitude } , ${ value . longitude } )` ;
131
136
} else if ( type === 'Polygon' ) {
132
- content = value . coordinates . map ( coord => `(${ coord } )` )
137
+ this . copyableValue = content = value . coordinates . map ( coord => `(${ coord } )` )
133
138
} else if ( type === 'Relation' ) {
134
139
content = (
135
140
< div style = { { textAlign : 'center' , cursor : 'pointer' } } >
136
141
< Pill onClick = { ( ) => setRelation ( value ) } value = 'View relation' />
137
142
</ div >
138
143
) ;
144
+ this . copyableValue = undefined ;
139
145
}
140
146
141
147
if ( current ) {
@@ -146,7 +152,10 @@ export default class BrowserCell extends Component {
146
152
ref = { this . cellRef }
147
153
className = { classes . join ( ' ' ) }
148
154
style = { { width } }
149
- onClick = { ( ) => onSelect ( { row, col } ) }
155
+ onClick = { ( ) => {
156
+ onSelect ( { row, col } ) ;
157
+ setCopyableValue ( hidden ? undefined : this . copyableValue ) ;
158
+ } }
150
159
onDoubleClick = { ( ) => {
151
160
if ( type !== 'Relation' ) {
152
161
onEditChange ( true )
0 commit comments