From 5c0bacb16b5ec2ece8b78519cd5a9f65d9eade05 Mon Sep 17 00:00:00 2001 From: faseehahmed1 Date: Wed, 17 Jan 2024 09:55:57 +0000 Subject: [PATCH 1/2] fix issue with context menu paste, both contexnt manu paste and onPaste(cntrl+v) check for text/html first --- package-lock.json | 4 ++-- src/components/DataSheetGrid.tsx | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index fd0d632..1ef03e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-datasheet-grid", - "version": "4.11.0", + "version": "4.11.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-datasheet-grid", - "version": "4.11.0", + "version": "4.11.2", "license": "MIT", "dependencies": { "@tanstack/react-virtual": "^3.0.0-beta.18", diff --git a/src/components/DataSheetGrid.tsx b/src/components/DataSheetGrid.tsx index e6af4f2..07cffc6 100644 --- a/src/components/DataSheetGrid.tsx +++ b/src/components/DataSheetGrid.tsx @@ -1561,12 +1561,13 @@ export const DataSheetGrid = React.memo( const items = await navigator.clipboard.read() items.forEach(async (item) => { let pasteData = [['']] - if (item.types.includes('text/plain')) { - const plainTextData = await item.getType('text/plain') - pasteData = parseTextPlainData(await plainTextData.text()) - } else if (item.types.includes('text/html')) { + if (item.types.includes('text/html')) { const htmlTextData = await item.getType('text/html') pasteData = parseTextHtmlData(await htmlTextData.text()) + } + else if (item.types.includes('text/plain')) { + const plainTextData = await item.getType('text/plain') + pasteData = parseTextPlainData(await plainTextData.text()) } else if (item.types.includes('text')) { const htmlTextData = await item.getType('text') pasteData = parseTextHtmlData(await htmlTextData.text()) From 35c777c6ad5b5bee7b6269234350c7bf8c1d0483 Mon Sep 17 00:00:00 2001 From: faseehahmed1 Date: Wed, 17 Jan 2024 09:56:47 +0000 Subject: [PATCH 2/2] fix issue with context menu paste, both contexnt manu paste and onPaste(cntrl+v) check for text/html first --- src/components/DataSheetGrid.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/DataSheetGrid.tsx b/src/components/DataSheetGrid.tsx index 07cffc6..3f25dfa 100644 --- a/src/components/DataSheetGrid.tsx +++ b/src/components/DataSheetGrid.tsx @@ -1564,8 +1564,7 @@ export const DataSheetGrid = React.memo( if (item.types.includes('text/html')) { const htmlTextData = await item.getType('text/html') pasteData = parseTextHtmlData(await htmlTextData.text()) - } - else if (item.types.includes('text/plain')) { + } else if (item.types.includes('text/plain')) { const plainTextData = await item.getType('text/plain') pasteData = parseTextPlainData(await plainTextData.text()) } else if (item.types.includes('text')) {