wails icon indicating copy to clipboard operation
wails copied to clipboard

[FEAT]: Native drap and drop for file and folder with complete filepath

Open hinupurthakur opened this issue 3 years ago • 67 comments

Is your feature request related to a problem? Please describe. Currently, on Wails v1.16.8 as for windows development it depends on IE11 (as Windows development use the mshtml library which is only compatible with IE11), and On IE11, the drag and drop is not supported for folder. Whereas with Chrome, we can have file or folder drag and drop functionality.

Describe the solution you'd like Feature that can be suitable would be native drag and drop with absolute path of dropped file/folder and if the dependency to IE11 can be removed.

Describe alternatives you've considered Currently, We have tried the following approaches but not complete solution was found:

  1. Use ngx-file-drop library for drag and drop, it worked fine for chrome but for IE11, only file drop was working fine and not folder. But was not providing absolute path of neither file not folder..
  2. HTML Drag and drop: Failed for both file and folder.
  3. Drag and drop on Input Type=File: Failed for both file and folder.
  4. Created our own directive even it failed for both file and folder.

Additional context Screenshot from example Feature Request

hinupurthakur avatar Jan 20 '22 05:01 hinupurthakur

For Windows, the recommendation is to move to v2.

leaanthony avatar Jan 20 '22 06:01 leaanthony

@leaanthony On v2, Do we have the native drag and drop functionality.

hinupurthakur avatar Jan 20 '22 06:01 hinupurthakur

No, but HTML dnd should.

leaanthony avatar Jan 20 '22 06:01 leaanthony

No, but HTML dnd should.

Okay Let me check. I will update here with its status.

hinupurthakur avatar Jan 20 '22 07:01 hinupurthakur

@leaanthony It worked with wails v2 but We are not getting the full path of the drag and dropped file. Which make sense for the browser but the full path for the local machine should be accessible. Do we have any work around in wails?

hinupurthakur avatar Jan 24 '22 08:01 hinupurthakur

Thanks for replying. Not right now but happy to accept a PR if it works on all platforms. Why do you need the path?

leaanthony avatar Jan 24 '22 08:01 leaanthony

Okay, I will be happy to contribute for this feature. Should I include the complete drag and drop functionality ( HTML implementation) with full path as Native drag and drop?

Also, I need the path as I want to create some chunks of the file at the location of where the file is located and that is to be done from the Backend (Go)

hinupurthakur avatar Jan 24 '22 10:01 hinupurthakur

Okay, I will be happy to contribute for this feature. Should I include the complete drag and drop functionality ( HTML implementation) with full path as Native drag and drop?

Also, I need the path as I want to create some chunks of the file at the location of where the file is located and that is to be done from the Backend (Go)

At present, there is no way for the front end to obtain the file content. The current feasible way is to start a service on the back end, and then pass the front end to the back end through the service, just like uploading a file on a web page. Because the current Wails does not provide a good way, this method can only be adopted. accomplish.

misitebao avatar Jan 27 '22 04:01 misitebao

It's natural for modern app developers to bring in drag n drop feature. It makes users comfortable to select files or dirs.

@hinupurthakur Could you post a link referring to how the full path is got when it's done? It's definitely an important feature for me to choose the framework.

Purple-CSGO avatar Jan 27 '22 05:01 Purple-CSGO

At present, there is no way for the front end to obtain the file content. The current feasible way is to start a service on the back end, and then pass the front end to the back end through the service, just like uploading a file on a web page. Because the current Wails does not provide a good way, this method can only be adopted. accomplish.

@misitebao Currently, yes involvment with the backend is the only work around but a feature for a drag and drop with complete file path would be a really good option for the wails.

hinupurthakur avatar Jan 27 '22 07:01 hinupurthakur

@hinupurthakur Could you post a link referring to how the full path is got when it's done? It's definitely an important feature for me to choose the framework.

Currently from frontend there isn't any possiblity, The work around I am having is involving backend with frontend to get the fullpath

hinupurthakur avatar Jan 27 '22 07:01 hinupurthakur

I suggest you take a look at https://github.com/splode/optimus which has drag and drop capabilities.

leaanthony avatar Jan 27 '22 08:01 leaanthony

@leaanthony I have checked the https://github.com/splode/optimus implementation of drag and drop but it is limited to file only. I also need to implement drag and drop for directory (folder).

hinupurthakur avatar Jan 28 '22 04:01 hinupurthakur

I suggest changing the ticket title

leaanthony avatar Jan 28 '22 08:01 leaanthony

@leaanthony Can you help with how we can proceed with this issue to the feature implementation?

hinupurthakur avatar Feb 02 '22 07:02 hinupurthakur

https://protonet.com/blog/html5-experiment-drag-drop-of-folders/ ?

leaanthony avatar Feb 02 '22 07:02 leaanthony

@leaanthony This wasn't helpful for full filepath.

hinupurthakur avatar Feb 03 '22 10:02 hinupurthakur

I can't help you with this.

leaanthony avatar Feb 03 '22 10:02 leaanthony

@leaanthony So Can we work towards integrating this feature in wails? Or is it not possible at all?

hinupurthakur avatar Feb 03 '22 10:02 hinupurthakur

Sure, I'd love this feature, if you want to try and make it work. How is it implemented in other frameworks?

leaanthony avatar Feb 03 '22 12:02 leaanthony

@leaanthony I am a backend developer but will research more on it and will provide more information here. Any help from other community members would be really appreciated as well. Thanks!

hinupurthakur avatar Feb 04 '22 06:02 hinupurthakur

Electron extends DOM to include path to file: https://www.electronjs.org/docs/latest/api/file-object#file-object

File interface provides abstraction around native files in order to let users work on native files directly with the HTML5 file API.

annikovk avatar Feb 11 '22 09:02 annikovk

Yeah, I wonder how they do that?

leaanthony avatar Feb 11 '22 10:02 leaanthony

How did you get on?

leaanthony avatar Mar 06 '22 10:03 leaanthony

@leaanthony I would really like to help here to implement something like what electronjs have but probably I will need some guidance there to understand the project better. Let me know if there is a community call or meeting that I can connect on to contribute to this.

hinupurthakur avatar Mar 06 '22 15:03 hinupurthakur

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 12:04 stale[bot]

@leaanthony @hinupurthakur

Followed this conversation and dug into the Electron solution for this to see what was involved. I'm a little swept off my feet at the moment, however it seems that this is the code that does what you are asking about here

https://github.com/electron/electron/blob/main/patches/chromium/blink_file_path.patch

referenced in the documentation here...

https://www.electronjs.org/docs/latest/api/file-object

How to map this to Wails, I am not sure, but perhaps this is a good place to start?

amlwwalker avatar May 04 '22 16:05 amlwwalker

Thanks for the links. The patch is patching the browser so there's not much we can take from that. Reopening though 👍

leaanthony avatar May 04 '22 20:05 leaanthony

I would love to have this feature for a new Desktop App. This app (Varly) would benefit from having files/folders dropped right onto its UI.

Happy to contribute to this effort however I can.

Here is a repository/plugin that offers this functionality for Flutter. It contains the native code for macOS, Windows, and Linux: https://github.com/MixinNetwork/flutter-plugins/tree/main/packages/desktop_drop

I'm not an expert in C or Swift but willing to figure it out. Is the code in this repository something that we could bring into wails?

selvinortiz avatar May 05 '22 03:05 selvinortiz

image I also need this feature. Now the tool based wails2 could open local file dialog and select one and then import by the full path, that's great. If wails supports files dargging will be amazing. Because work in local, there's no need to transfer the full content of files from frontend to backend, it just need a fullpath, backend read and parse from the path.

wangleilei2010 avatar May 12 '22 06:05 wangleilei2010

Scheduled for 2.5 but will consider before then if a PR is raised 👍

leaanthony avatar May 12 '22 10:05 leaanthony