1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: copy row as CSV, closes #394

This commit is contained in:
2022-07-29 18:53:39 +02:00
parent 664d18efc1
commit 1c3d7aa30b
2 changed files with 17 additions and 0 deletions

View File

@ -449,6 +449,18 @@ const copyRow = (format: string) => {
}
navigator.clipboard.writeText(sqlInserts.join('\n'));
}
else if (format === 'csv') {
const csv = [];
if (!Array.isArray(contentToCopy)) contentToCopy = [contentToCopy];
if (contentToCopy.length)
csv.push(Object.keys(contentToCopy[0]).join(';'));
for (const row of contentToCopy)
csv.push(Object.values(row).map(col => typeof col === 'string' ? `"${col}"` : col).join(';'));
navigator.clipboard.writeText(csv.join('\n'));
}
};
const duplicateRow = () => {