MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / handlePaste

Function handlePaste

frontend/components/chat-input.tsx:187–219  ·  view source on GitHub ↗
(e: React.ClipboardEvent)

Source from the content-addressed store, hash-verified

185 }
186
187 const handlePaste = async (e: React.ClipboardEvent) => {
188 if (isDisabled) return
189
190 const items = e.clipboardData.items
191 const imageItems = Array.from(items).filter((item) =>
192 item.type.startsWith("image/"),
193 )
194
195 if (imageItems.length > 0) {
196 const imageFiles = (
197 await Promise.all(
198 imageItems.map(async (item, index) => {
199 const file = item.getAsFile()
200 if (!file) return null
201 return new File(
202 [file],
203 `pasted-image-${Date.now()}-${index}.${file.type.split("/")[1]}`,
204 { type: file.type },
205 )
206 }),
207 )
208 ).filter((f): f is File => f !== null)
209
210 const { validFiles, errors } = validateFiles(
211 imageFiles,
212 files.length,
213 )
214 showValidationErrors(errors)
215 if (validFiles.length > 0) {
216 onFileChange([...files, ...validFiles])
217 }
218 }
219 }
220
221 const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
222 const newFiles = Array.from(e.target.files || [])

Callers

nothing calls this directly

Calls 2

validateFilesFunction · 0.85
showValidationErrorsFunction · 0.85

Tested by

no test coverage detected