pqina / filepond

🌊 A flexible and fun JavaScript file upload library
https://pqina.nl/filepond
MIT License
15.16k stars 825 forks source link

I would need a way to add my own button(s) #719

Closed parmentelat closed 3 years ago

parmentelat commented 3 years ago

Hiya; thank you for this awesome tool :)

Is your feature request related to a problem? Please describe.

my app is about uploading files on the backend, and then having the ability to do stuff with these files from there (namely, deploy the files to people who have subscribed it)

so in essence I need to somehow create some sort of reactive area inside the file widget, that allows the app user to trigger these extra tasks

Describe the solution you'd like

I can live with something a little patchy at first (see below)

not quite sure how this could be proposed nicely

Describe alternatives you've considered

So far I have tried to use the .filepond--file-info-sub span area to inject my stuff my initial attempt was to insert in there something like a <span onclick="my_stuff(...)"> however my_stuff() won't trigger, and I'm at a loss to figure how to make it alive

I understand that this is sort-of conflicting with allowReorder so I did set it to false (knowing that the extra button is much more important to me than the ability to manually reorder things) but that still won't work

At the very least I could use some description of how the events are handled incidentally I tried to reverse-engineer this mechanism by enabling debugging on the 'click' event but could not guess how all this is supposed to work...

Additional context

I did search on stackoverflow but came up with nothing relevant

I also tried

but no avail either

in my current code the small horizontal arrow is meant to become the button (once styled a little more properly of course)

image

thanks for any tip / thought

rikschennink commented 3 years ago

There is onactivatefile callback you could use, you can then open a modal or show edit fields somewhere else to modify file data.

parmentelat commented 3 years ago

all righty however the doc only seems to mention a file parameter is there a way that I can access the event object then ? I'd need the event's target so I can implement something a little less intrusive than a modal, and/or several sensitive areas inside the blob, or...

rikschennink commented 3 years ago

It receives the fileItem that was clicked, this item has an id which you can use to interact with FilePond itself. Maybe I misunderstand what you plan to do.

parmentelat commented 3 years ago

so first off, the solution you gave me so far is way better than anything I had tried before so BIG THANKS already :)

what I meant was: the 'activatefile' callback being called is the result of me clicking in the item area, right ? so I'd love to access that click event - as a parameter to the callback - this way I can for example see in which part of the item the click occurred, that sort of stuff

rikschennink commented 3 years ago

Hey, that info is currently not available in the onactivatefile callback.

I'd consider creating a custom plugin, that will give you a lot more flexibility. Forking the file-poster plugin might be a good start.

rikschennink commented 3 years ago

Closed because inactive.