This commit is contained in:
Faris Ansari 2017-11-02 09:57:37 +05:30
parent 89dfaa13ed
commit d55ee1b45f
4 changed files with 19 additions and 13 deletions

View File

@ -326,10 +326,7 @@ function copyTextToClipboard(text) {
textArea.select(); textArea.select();
try { try {
var successful = document.execCommand('copy'); document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) { } catch (err) {
console.log('Oops, unable to copy'); console.log('Oops, unable to copy');
} }
@ -1729,18 +1726,26 @@ var CellManager = function () {
if (!cells) return; if (!cells) return;
var values = cells.map(function (index) { var values = cells
// get cell objects
.map(function (index) {
return _this8.getCell.apply(_this8, _toConsumableArray(index)); return _this8.getCell.apply(_this8, _toConsumableArray(index));
}).reduce(function (acc, curr) { })
// convert to array of rows
.reduce(function (acc, curr) {
var rowIndex = curr.rowIndex; var rowIndex = curr.rowIndex;
acc[rowIndex] = acc[rowIndex] || []; acc[rowIndex] = acc[rowIndex] || [];
acc[rowIndex].push(curr.content); acc[rowIndex].push(curr.content);
return acc; return acc;
}, []).map(function (row) { }, [])
// join values by tab
.map(function (row) {
return row.join('\t'); return row.join('\t');
}).join('\n'); })
// join rows by newline
.join('\n');
(0, _utils.copyTextToClipboard)(values); (0, _utils.copyTextToClipboard)(values);
} }

File diff suppressed because one or more lines are too long

View File

@ -334,7 +334,9 @@ export default class CellManager {
if (!cells) return; if (!cells) return;
const values = cells const values = cells
// get cell objects
.map(index => this.getCell(...index)) .map(index => this.getCell(...index))
// convert to array of rows
.reduce((acc, curr) => { .reduce((acc, curr) => {
const rowIndex = curr.rowIndex; const rowIndex = curr.rowIndex;
@ -343,7 +345,9 @@ export default class CellManager {
return acc; return acc;
}, []) }, [])
// join values by tab
.map(row => row.join('\t')) .map(row => row.join('\t'))
// join rows by newline
.join('\n'); .join('\n');
copyTextToClipboard(values); copyTextToClipboard(values);

View File

@ -247,10 +247,7 @@ function copyTextToClipboard(text) {
textArea.select(); textArea.select();
try { try {
const successful = document.execCommand('copy'); document.execCommand('copy');
const msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) { } catch (err) {
console.log('Oops, unable to copy'); console.log('Oops, unable to copy');
} }