Merge pull request #828 from tumit/master

feat: add 'Copy only headers' feature
This commit is contained in:
Jan Prochazka
2024-07-08 08:12:48 +02:00
committed by GitHub

View File

@@ -77,6 +77,10 @@ export function extractRowCopiedValue(row, col) {
return stringifyCellValue(value);
}
const clipboardHeadersFormatter = (delimiter) => (columns) => {
return columns.join(delimiter);
};
const clipboardTextFormatter = (delimiter, headers) => (columns, rows) => {
const lines = [];
if (headers) lines.push(columns.join(delimiter));
@@ -161,6 +165,11 @@ export const copyRowsFormatDefs = {
name: 'Without headers',
formatter: clipboardTextFormatter('\t', false),
},
headers: {
label: 'Copy only headers',
name: 'Only Headers',
formatter: clipboardHeadersFormatter('\t'),
},
csv: {
label: 'Copy as CSV',
name: 'CSV',