Files
t3code/apps/mobile/src/lib/useNativePaste.ts
T
b3e8c0334b T3 Code Mobile [WIP] (#2013)
Co-authored-by: codex <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Yash Singh <[email protected]>
2026-05-29 17:00:54 -07:00

22 lines
741 B
TypeScript

import type { PasteEventPayload } from "expo-paste-input";
import { useCallback } from "react";
/**
* Returns a stable `onPaste` handler for `TextInputWrapper` from
* `expo-paste-input`. When the user pastes images via the OS paste gesture,
* `onImages` is called with the pasted URIs. Text pastes are left to the
* native TextInput — no extra handling is needed.
*
* Used by both the thread composer and the new-task draft screen.
*/
export function useNativePaste(onImages: (uris: ReadonlyArray<string>) => void) {
return useCallback(
(payload: PasteEventPayload) => {
if (payload.type === "images" && payload.uris && payload.uris.length > 0) {
onImages(payload.uris);
}
},
[onImages],
);
}