Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/components/Todo/common/Todo/Item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ interface Props {
changeFocus: (focusIndex: number) => void;
focus: number;
}

function displayErrorMessage(message: string): void {
alert(message);
}
export const Item: FC<Props> = ({
items,
itemIndex,
Expand Down Expand Up @@ -105,6 +107,7 @@ export const Item: FC<Props> = ({
/>
<FormControl fullWidth>
<TextField
multiline
className={classes.textFeild}
InputProps={{ classes: { underline: classes.underline } }}
inputRef={inputRef}
Expand All @@ -116,12 +119,17 @@ export const Item: FC<Props> = ({

// 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 };
Expand Down