-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Patch in onPaste to React Native's TextInput
#9430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
| async (err: string | undefined, files: PastedFile[]) => { | ||
| if (err) { | ||
| return onError(cleanError(err)) | ||
| } | ||
| async (evt: NativeSyntheticEvent<TextInputPasteEventData>) => { | ||
| const files = evt.nativeEvent.items | ||
|
|
||
| const uris = files.map(f => f.uri) | ||
| const uri = uris.find(isUriImage) | ||
| const file = files.find(f => isAcceptedImageMimeType(f.type)) | ||
|
|
||
| if (uri) { | ||
| onPhotoPasted(uri) | ||
| if (file) { | ||
| onPhotoPasted(file.data, file.type) | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has changed from a Data URI to a File URI with a mimetype, which requires some minor changes but is mostly simpler (i.e. no need to do regex mime type nonsense except on web)
| compileSdkVersion: 35, | ||
| targetSdkVersion: 35, | ||
| buildToolsVersion: '35.0.0', | ||
| buildReactNativeFromSource: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RIP build times 🪦
| "@haileyok/bluesky-video": "0.3.2", | ||
| "@ipld/dag-cbor": "^9.2.0", | ||
| "@lingui/react": "^4.14.1", | ||
| "@mattermost/react-native-paste-input": "mattermost/react-native-paste-input", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you love to see it
352696f to
b966fc8
Compare
Stacked on #9429
Patches in this PR: facebook/react-native#45425
That one ^^^ is a little out of date so I used Expensify's patch for reference, as it's for 0.81.4 (still required me to manually reapply though as we're on 0.81.5 😢): https://github.com/Expensify/App/blob/main/patches/react-native/react-native%2B0.81.4%2B011%2BAdd-onPaste-to-TextInput.patch
Android required some further tweaks, like more accurate mime type detection and copying the content uri to a file uri
This lets us get rid of Mattermost's paste input library, yay!
Caveat: we now have to compile RN from source on Android
ios.paste.mov
screen-20251121-165752.mp4