Skip to content

Commit

Permalink
Merge pull request #154 from Team-INSERT/hotfix/paste
Browse files Browse the repository at this point in the history
fix(paste): 복붙 안되는 버그 수정
  • Loading branch information
Ubinquitous authored Apr 15, 2024
2 parents 8c4301a + 98122a3 commit 2251454
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/PasteUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { FC, useEffect } from "react";
const PasteUpload: FC<{ onUpload: (file: File) => unknown }> = ({ onUpload }) => {
useEffect(() => {
const onPaste: EventListener = (e) => {
e.preventDefault();
const { clipboardData } = e as ClipboardEvent;
if (!clipboardData) return;

if (clipboardData.types[0] === "text/plain") return;
e.preventDefault();
const { items } = clipboardData;
if (!items.length) return;

Expand All @@ -22,6 +22,7 @@ const PasteUpload: FC<{ onUpload: (file: File) => unknown }> = ({ onUpload }) =>
const file = fileItem.getAsFile();
if (!file) return;
onUpload(file);
e.stopPropagation();
};

window.addEventListener("paste", onPaste);
Expand Down

0 comments on commit 2251454

Please sign in to comment.