From be0f763fba0a03fcd5d0caebbf31128ef715d4c0 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:58:13 +0530 Subject: [PATCH] Nc fix(nc-gui): Copying and pasting from Excel overwrites one additional row cell (#8317) * fix(nc-gui): copy paste from excel overwrites extra cell from next row * fix(nc-gui): remove \n from clipboard data if it occured only once at the end * fix(nc-gui): small changes * Update index.ts --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- packages/nc-gui/composables/useMultiSelect/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useMultiSelect/index.ts b/packages/nc-gui/composables/useMultiSelect/index.ts index d1b708961a..97e9d154eb 100644 --- a/packages/nc-gui/composables/useMultiSelect/index.ts +++ b/packages/nc-gui/composables/useMultiSelect/index.ts @@ -816,7 +816,15 @@ export function useMultiSelect( e.preventDefault() // Replace \" with " in clipboard data - const clipboardData = e.clipboardData?.getData('text/plain') || '' + let clipboardData = e.clipboardData?.getData('text/plain') || '' + + if (clipboardData?.endsWith('\n')) { + // Remove '\n' from the end of the clipboardData + // When copying from XLS/XLSX files, there is an extra '\n' appended to the end + // this overwrites one additional cell information when we paste in NocoDB + clipboardData = clipboardData.replace(/\n$/, '') + } + try { if (clipboardData?.includes('\n') || clipboardData?.includes('\t')) { // if the clipboard data contains new line or tab, then it is a matrix or LongText