From 6fe39bc119214c3d2844fcee74212f7647015c53 Mon Sep 17 00:00:00 2001 From: Bhavik Diwani <55989651+fastio19@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:36:26 +0530 Subject: [PATCH 1/2] Update index.tsx handle Paste condition (>1200 characters) --- src/components/Todo/common/Todo/Item/index.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/Todo/common/Todo/Item/index.tsx b/src/components/Todo/common/Todo/Item/index.tsx index 480f52c..3637731 100644 --- a/src/components/Todo/common/Todo/Item/index.tsx +++ b/src/components/Todo/common/Todo/Item/index.tsx @@ -55,7 +55,9 @@ interface Props { changeFocus: (focusIndex: number) => void; focus: number; } - +function displayErrorMessage(message: string): void { + alert(message); +} export const Item: FC = ({ items, itemIndex, @@ -116,12 +118,17 @@ export const Item: FC = ({ // Get pasted data via clipboard API const clipboardData = e.clipboardData; - const pastedData = clipboardData - .getData('Text') - .split('\n') + const MAX_CHARACTERS = 1200; + const input = clipboardData + .getData("Text"); + if(input.length > MAX_CHARACTERS) { + displayErrorMessage(`You can only paste up to ${MAX_CHARACTERS} characters.`); + return; + } + const pastedData = input + .split("\n") .reverse() .filter((name) => name.trim() !== ''); - // Do whatever with pasteddata const items = pastedData.map((name) => { return { name, uuid: uuid(), isComplete: false }; From 5d33b00de9db3a6a69238b5b53bd74a136463a3b Mon Sep 17 00:00:00 2001 From: Bhavik Diwani <55989651+fastio19@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:44:28 +0530 Subject: [PATCH 2/2] Update index.tsx Added multiline feature to item --- src/components/Todo/common/Todo/Item/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Todo/common/Todo/Item/index.tsx b/src/components/Todo/common/Todo/Item/index.tsx index 3637731..38c2296 100644 --- a/src/components/Todo/common/Todo/Item/index.tsx +++ b/src/components/Todo/common/Todo/Item/index.tsx @@ -107,6 +107,7 @@ export const Item: FC = ({ />