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