Skip to content

Commit

Permalink
Merge pull request #1084 from MuhammadUmer44/fix/macos-screenshot-pas…
Browse files Browse the repository at this point in the history
…te-handling

Fix: Improve clipboard image paste handling for macOS screenshots
  • Loading branch information
humansinstitute authored Feb 13, 2025
2 parents 186bd8c + 098d6e7 commit 9972780
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/components/common/TicketEditor/TicketTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,39 @@ export const TicketTextAreaComp = ({
};

const handlePaste = async (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
const { items } = e.clipboardData;
for (const item of Array.from(items)) {
if (item.type.startsWith('image/')) {
const { items, files } = e.clipboardData;

console.log('=== Paste Debug Info ===');
console.log(
'Files:',
Array.from(files).map((f: File) => ({ type: f.type, size: f.size }))
);
console.log(
'Items:',
Array.from(items).map((item: DataTransferItem) => ({ kind: item.kind, type: item.type }))
);

if (files.length > 0) {
const file = files[0];
if (file.type.startsWith('image/')) {
e.preventDefault();
await handleImageUpload(file);
return;
}
}

for (const item of Array.from(items)) {
if (item.kind === 'file' && item.type.startsWith('image/')) {
const file = item.getAsFile();
if (file) {
e.preventDefault();
await handleImageUpload(file);
return;
}
}
}

console.log('No image found in clipboard');
};

const { getRootProps, getInputProps } = useDropzone({
Expand Down

0 comments on commit 9972780

Please sign in to comment.