Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

disable pasting which is causing a flurry of requests

Abi Raja9b59b2d5958b
diff --git a/frontend/src/components/ImageUpload.tsx b/frontend/src/components/ImageUpload.tsx
index 6cd45b73..ff974666 100644
--- a/frontend/src/components/ImageUpload.tsx
+++ b/frontend/src/components/ImageUpload.tsx
@@ -1,4 +1,5 @@
-import { useState, useEffect, useMemo, useCallback } from "react";
+import { useState, useEffect, useMemo } from "react";
+// useCallback
import { useDropzone } from "react-dropzone";
// import { PromptImage } from "../../../types";
import { toast } from "react-hot-toast";
@@ -89,39 +90,39 @@ function ImageUpload({ setReferenceImages }: Props) {
},
});
- const pasteEvent = useCallback(
- (event: ClipboardEvent) => {
- const clipboardData = event.clipboardData;
- if (!clipboardData) return;
-
- const items = clipboardData.items;
- const files = [];
- for (let i = 0; i < items.length; i++) {
- const file = items[i].getAsFile();
- if (file && file.type.startsWith("image/")) {
- files.push(file);
- }
- }
-
- // Convert images to data URLs and set the prompt images state
- Promise.all(files.map((file) => fileToDataURL(file)))
- .then((dataUrls) => {
- if (dataUrls.length > 0) {
- setReferenceImages(dataUrls.map((dataUrl) => dataUrl as string));
- }
- })
- .catch((error) => {
- // TODO: Display error to user
- console.error("Error reading files:", error);
- });
- },
- [setReferenceImages]
- );
+ // const pasteEvent = useCallback(
+ // (event: ClipboardEvent) => {
+ // const clipboardData = event.clipboardData;
+ // if (!clipboardData) return;
+
+ // const items = clipboardData.items;
+ // const files = [];
+ // for (let i = 0; i < items.length; i++) {
+ // const file = items[i].getAsFile();
+ // if (file && file.type.startsWith("image/")) {
+ // files.push(file);
+ // }
+ // }
+
+ // // Convert images to data URLs and set the prompt images state
+ // Promise.all(files.map((file) => fileToDataURL(file)))
+ // .then((dataUrls) => {
+ // if (dataUrls.length > 0) {
+ // setReferenceImages(dataUrls.map((dataUrl) => dataUrl as string));
+ // }
+ // })
+ // .catch((error) => {
+ // // TODO: Display error to user
+ // console.error("Error reading files:", error);
+ // });
+ // },
+ // [setReferenceImages]
+ // );
// TODO: Make sure we don't listen to paste events in text input components
- useEffect(() => {
- window.addEventListener("paste", pasteEvent);
- }, [pasteEvent]);
+ // useEffect(() => {
+ // window.addEventListener("paste", pasteEvent);
+ // }, [pasteEvent]);
useEffect(() => {
return () => files.forEach((file) => URL.revokeObjectURL(file.preview));