| 1 | import type { PasteEventPayload } from "expo-paste-input"; |
| 2 | import { useCallback } from "react"; |
| 3 | |
| 4 | /** |
| 5 | * Returns a stable `onPaste` handler for `TextInputWrapper` from |
| 6 | * `expo-paste-input`. When the user pastes images via the OS paste gesture, |
| 7 | * `onImages` is called with the pasted URIs. Text pastes are left to the |
| 8 | * native TextInput — no extra handling is needed. |
| 9 | * |
| 10 | * Used by both the thread composer and the new-task draft screen. |
| 11 | */ |
| 12 | export function useNativePaste(onImages: (uris: ReadonlyArray<string>) => void) { |
| 13 | return useCallback( |
| 14 | (payload: PasteEventPayload) => { |
| 15 | if (payload.type === "images" && payload.uris && payload.uris.length > 0) { |
| 16 | onImages(payload.uris); |
| 17 | } |
| 18 | }, |
| 19 | [onImages], |
| 20 | ); |
| 21 | } |