react-advanced-cropper icon indicating copy to clipboard operation
react-advanced-cropper copied to clipboard

how to use it with filepond

Open violabg opened this issue 3 years ago • 5 comments

Nice component, I would like to integrate it with filepond, any suggestions? https://pqina.nl/filepond/docs/api/plugins/image-edit/

violabg avatar Oct 20 '22 13:10 violabg

@violabg, could you create the basic sandbox with filepond? I will try to find time to integrate with my cropper.

Norserium avatar Oct 20 '22 17:10 Norserium

Thanks, This is the CodeSandbox for filepond https://codesandbox.io/s/compassionate-ramanujan-immb8r?file=/src/App.js, Than you need to add the image-edit plugin as per https://pqina.nl/filepond/docs/api/plugins/image-edit/ And make it compatible with your library https://pqina.nl/filepond/docs/api/plugins/image-edit/#integrating-other-editors

violabg avatar Oct 20 '22 18:10 violabg

@violabg, well, that's the tough task.

The basic integration is not a problem at all, but when you need to deal with the definition of the cropped area you get a huge problem. Ironically, that was the first issue in this library.

The library developer told that:

I've written Doka.js specifically for this use case. The Image Editor plugin is mostly a proxy between FilePond and Doka, while it's possible to integrate your own image cropper/editor it's probably not as cost-effective (of course this depends on your use case) as purchasing a Doka license.

So there are no significant progress after three years.

In short: the root of the issue is the difference between the internal definition of the cropped area in Doka and other croppers (not only mine). Especially, in the defining of the zoom value.

The situation is aggravated by the fact, that the transforming should be duplex.

  1. You should convert the Doka definition of the cropped area to your format.
  2. You should convert your format to the Doka definition of the cropped area.

But this story ends well. Try this.

The result should be tested very careful and thoughtful, because my solution is pretty complicated and, frankly, I've never seen that somebody did that before for any other croppers with support of arbitrary rotation.

Also, I use react-mobile-cropper and that should not bother you, because it still react-advanced-cropper, but with batteries included. You can replace it by the default cropper if you want, they have almost identical API.

Norserium avatar Oct 21 '22 13:10 Norserium

wow, thank you very much, I'm going to test it.

thanks again

violabg avatar Oct 21 '22 13:10 violabg

@violabg, any news?

Norserium avatar Oct 25 '22 10:10 Norserium

I did some tests, I had to change something, because I want to open the editor automatically when I choose the image. I had some troubles with the cancel method, basically we have to add the link.current.onclose(); on it, in order to clean the files, the problem is that it works only the first time, if you cancel or remove a file, the next time you try is not working anymore.

Here is the codesandbox https://codesandbox.io/s/react-advanced-cropper-filepond-forked-uux7uz?file=/src/App.js

violabg avatar Oct 26 '22 08:10 violabg

@violabg, it's strange. I don't see any troubles. Could you record a video that illustrates your issue?

Norserium avatar Oct 26 '22 09:10 Norserium

@violabg, well, I found one issue. There is the fixed version. Try it.

Norserium avatar Oct 26 '22 09:10 Norserium

I saw that you change from onclose() to inclose?.(), but that the source of the problem, onclose become null after the first time, so we can't call it again and filepond can't respond on changes anymore. to test it try to :

  1. upload an image
  2. either cancel crop, or remove it after the crop
  3. you are back to the empty state (which is fine)
  4. now onclose is null
  5. upload a new image, crop it and press done
  6. you get stack we a loading state

violabg avatar Oct 26 '22 09:10 violabg

https://user-images.githubusercontent.com/9862719/197995108-8f281b27-7ab5-4190-a1bf-527f24a3c1dd.mp4

@violabg, what's wrong?

Norserium avatar Oct 26 '22 09:10 Norserium

for me is different, but is not a constant, some time you need to repeat the steps in order to see it

violabg avatar Oct 26 '22 11:10 violabg

@violabg, could you upload a video? If you use Windows you can use ScreenToGif (free / open source).

Norserium avatar Oct 26 '22 11:10 Norserium

https://user-images.githubusercontent.com/3963176/198023446-734269e6-835d-4ecd-af93-690334e9ba47.mp4

violabg avatar Oct 26 '22 12:10 violabg

@violabg, could you to reproduce the bug here?

Norserium avatar Oct 26 '22 14:10 Norserium

@violabg, I don't get why I can't reproduce that bug. Do you have any bugs with imageEditInstantEdit={false}?

Norserium avatar Oct 26 '22 14:10 Norserium

@violabg, could you to reproduce the bug here?

no, this is working fine

violabg avatar Oct 26 '22 14:10 violabg

@violabg, could you provide the logs in the bugged case in this example?

Norserium avatar Oct 26 '22 14:10 Norserium

[submit] [before] onclose undefined [cancel] oncancel ▶ƒ () {} [submit] [after] onclose ▶ƒ () {}

violabg avatar Oct 26 '22 15:10 violabg

this is a new codesandbox

https://codesandbox.io/s/react-advanced-cropper-filepond-forked-uux7uz?file=/src/App.js

as you can see the first file is fine, if you add a second, it get stuck on a loading state, I think the problem is onclose fn that is null the second time, but can't figure it out why. Maybe we should move the conversation on the filepond repository

violabg avatar Oct 26 '22 15:10 violabg

[submit] [before] onclose undefined [cancel] oncancel ▶ƒ () {} [submit] [after] onclose ▶ƒ () {}

That's totally correct. But the problem appears not on cancel, but on submit. Try to reproduce the bug, that you have illustrated on the video before, in this sandbox and send me the full console content.

Norserium avatar Oct 26 '22 15:10 Norserium

Maybe we should move the conversation on the filepond repository

I'm not sure that we will receive the answer soon, and I don't see any mistakes in his source code also. First of all, I need to understand the nature of the issue.

Norserium avatar Oct 26 '22 15:10 Norserium

@violabg, what's browser do you use? Could you try it on device with another operating system?

Norserium avatar Oct 26 '22 15:10 Norserium

@violabg, could you to reproduce the bug here?

Hm, I've sent the wrong link. The right one.

Norserium avatar Oct 26 '22 16:10 Norserium

@violabg, could you to reproduce the bug here?

Hm, I've sent the wrong link. The right one.

is working, but you are right, is browser related, I was using safari, I tried on Chrome and is working.

violabg avatar Oct 26 '22 16:10 violabg

@violabg, well, that's something.

Try to reproduce the bug, that you have illustrated on the video before, in this sandbox and send me the full console content. I assume, that somehow line after [submit] [after] onclose is not called.

Norserium avatar Oct 26 '22 16:10 Norserium

@violabg, any progress?

Norserium avatar Oct 27 '22 08:10 Norserium

https://user-images.githubusercontent.com/3963176/198281092-4a120210-2749-4f8d-af5a-9e378e0ed46f.mp4

[submit] [before] onclose undefined [submit] onconfirm ▶ƒ () {} [submit] [after] onclose ▶ƒ () {}

[submit] [before] onclose null [submit] onconfirm ▶ƒ () {} [submit] [after] onclose ▶ƒ () {}

violabg avatar Oct 27 '22 12:10 violabg

@violabg, look, onclose is defined, so... it's more complicated case.

Norserium avatar Oct 27 '22 12:10 Norserium

@violabg, what's version of the Safari do you use?

Norserium avatar Oct 27 '22 13:10 Norserium

@violabg, I've tested on 14.1 now, and it works well.

Norserium avatar Oct 27 '22 13:10 Norserium