diff --git a/packages/tools/src/stringTools.ts b/packages/tools/src/stringTools.ts index b52c7444f..fda21081c 100644 --- a/packages/tools/src/stringTools.ts +++ b/packages/tools/src/stringTools.ts @@ -150,7 +150,13 @@ function stringifyJsonToGrid(value): ReturnType { export function stringifyCellValue( value, - intent: 'gridCellIntent' | 'inlineEditorIntent' | 'multilineEditorIntent' | 'stringConversionIntent' | 'exportIntent', + intent: + | 'gridCellIntent' + | 'inlineEditorIntent' + | 'multilineEditorIntent' + | 'stringConversionIntent' + | 'exportIntent' + | 'clipboardIntent', editorTypes?: DataEditorTypesBehaviour, gridFormattingOptions?: { useThousandsSeparator?: boolean }, jsonParsedValue?: any @@ -209,6 +215,7 @@ export function stringifyCellValue( switch (intent) { case 'exportIntent': case 'stringConversionIntent': + case 'clipboardIntent': return { value: dateString }; default: const m = dateString.match(dateTimeStorageRegex); diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index daa6e3536..a222c10b6 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -673,6 +673,7 @@ keyColumns: display?.baseTable?.primaryKey?.columns?.map(col => col.columnName) || [ display?.columns ? display?.columns[0].columnName : columns[0], ], + editorTypes: getEditorTypes(), }); if (domFocusField) domFocusField.focus(); } diff --git a/packages/web/src/utility/clipboard.ts b/packages/web/src/utility/clipboard.ts index 7adf11eae..2b1dae989 100644 --- a/packages/web/src/utility/clipboard.ts +++ b/packages/web/src/utility/clipboard.ts @@ -75,20 +75,20 @@ export async function getClipboardText() { export function extractRowCopiedValue(row, col, editorTypes?: DataEditorTypesBehaviour) { let value = row[col]; if (value === undefined) value = _.get(row, col); - return stringifyCellValue(value, 'exportIntent', editorTypes).value; + return stringifyCellValue(value, 'clipboardIntent', editorTypes).value; } const clipboardHeadersFormatter = delimiter => columns => { return columns.join(delimiter); }; -const clipboardTextFormatter = (delimiter, headers) => (columns, rows) => { +const clipboardTextFormatter = (delimiter, headers) => (columns, rows, options) => { const lines = []; if (headers) lines.push(columns.join(delimiter)); lines.push( ...rows.map(row => { if (!row) return ''; - const line = columns.map(col => extractRowCopiedValue(row, col)).join(delimiter); + const line = columns.map(col => extractRowCopiedValue(row, col, options?.editorTypes)).join(delimiter); return line; }) );