mattermost / react-native-paste-input

React Native TextInput replacement to allow pasting files
MIT License
89 stars 15 forks source link

IOS 3D Copy on Image and Paste into TextInput does not fire onPaste Callback #3

Closed Rutvik17 closed 1 year ago

Rutvik17 commented 3 years ago

When copying and pasting a local file, the component works fine, but when doing a 3D copy and pasting, IOS Seems to only copy the url to the file which is not detected by the component since its not in the format of the PastedImage

Would be nice to add support for url's beginning with file:/// for IOS when pasted into the text input.

With axios call we can get a blob from the url but currently the onPaste callback is not fired with such paste.

This is a feature request

enahum commented 3 years ago

Hi @Rutvik17 thanks for the report, wiuld you be willing to try and submit a PR for this?

Rutvik17 commented 3 years ago

Hi @Rutvik17 thanks for the report, wiuld you be willing to try and submit a PR for this?

I am not sufficient in Swift but i could take a look.

Rutvik17 commented 3 years ago

I am not sufficient in Swift so i did a work around on changeText callback on TextInput

if (value.includes('file:///')) {
            const strings = value.split(' ');
            for (let i = 0; i < strings.length; i++) {
                if (strings[i].startsWith('file:///')) {
                    try {
                        const axiosResponse = await axios.get(strings[i], {responseType: 'blob'});
                        // Handle Image Blob
                        strings.splice(i, 1);
                    } catch (e) {
                        console.log(e.message);
                    }
              }
         }
    value = strings.join(' ');
}

But would be nice if your team can add the support in native.

enahum commented 3 years ago

will leave it open and see if someone picks it up ;)