MCPcopy Index your code
hub / github.com/nadbm/react-datasheet / handleCopy

Function handleCopy

src/DataSheet.js:134–152  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

132 }
133
134 handleCopy (e) {
135 if (isEmpty(this.state.editing)) {
136 e.preventDefault()
137 const {dataRenderer, valueRenderer, data} = this.props
138 const {start, end} = this.getState()
139
140 const text = range(start.i, end.i).map((i) =>
141 range(start.j, end.j).map(j => {
142 const cell = data[i][j]
143 const value = dataRenderer ? dataRenderer(cell, i, j) : null
144 if (value === '' || value === null || typeof (value) === 'undefined') {
145 return valueRenderer(cell, i, j)
146 }
147 return value
148 }).join('\t')
149 ).join('\n')
150 e.clipboardData.setData('text/plain', text)
151 }
152 }
153
154 handlePaste (e) {
155 if (isEmpty(this.state.editing)) {

Callers

nothing calls this directly

Calls 2

isEmptyFunction · 0.70
rangeFunction · 0.70

Tested by

no test coverage detected