
this is also a feature request on the forum:
https://support.delta.chat/t/paste-pictures-from-the-clipboard-into-the-message-field/949
We can either use the pure js api: https://stackoverflow.com/questions/6333814/how-does-the-paste-image-from-clipboard-functionality-work-in-gmail-and-google-c
But the problem is transfering the blob to the backend as we of course don't get a path to the file. Probably sending the file via ipc is okay, but we should limit the size to 20mb to not block the channel for too long. When we go websocket, we should also have a restapi maybe for files?
Or we use https://www.electronjs.org/docs/api/clipboard#clipboardreadimagetype with which we have the blob already in the backend.
I'd go for the rest api because its future compatible with moving away from electron and also we don't block the ipc channel.
I'd go for the rest api because its future compatible with moving away from electron and also we don't block the ipc channel.
But this will probably cause firewall trouble on windows. Are you sure we want to sort this out now?
I'd go for the rest api because its future compatible with moving away from electron and also we don't block the ipc channel.
But this will probably cause firewall trouble on windows. Are you sure we want to sort this out now?
I do not use Windows Firewall or Windows Defender (my router has a good firewall). Perhaps there can be an advanced toggle in options to bypass this concern? It's be awesome to see this feature in the Desktop app!!
We can either use the pure js api: https://stackoverflow.com/questions/6333814/how-does-the-paste-image-from-clipboard-functionality-work-in-gmail-and-google-c
But the problem is transfering the blob to the backend as we of course don't get a path to the file. Probably sending the file via ipc is okay, but we should limit the size to 20mb to not block the channel for too long
This seems perfectly good to me.
Would it be as simple as setting the file parameter in the Draft to the data URL blob?
Edit: Or perhaps it could dump the pasted image to a temporary file then pass that file path to the backend?
I am a little bit lost. As a basic function of an IM, DC has not been able to realize it until today.
I am a little bit lost. As a basic function of an IM, DC has not been able to realize it until today.
It can't have everything right away. It's an excellent open source platform. I wouldn't call it a "basic function of IM"... technically more IMs don't do that than those that do... but it's something we've grown used to from platforms that are less safe but have practically unlimited money to throw around... Just saying, try to uplift the project and understand that there isn't time to figure everything out immediately, already there's a wonderfully innovative core platform that covers enormous ground
So far able to access the binary data of pasted images here: https://github.com/deltachat/deltachat-desktop/compare/master...jchook:copy_paste_images
However it looks like we cannot save a temp file from the renderer, and I feel unsure about the best way to pass this over IPC.
Would it be as simple as setting the file parameter in the Draft to the data URL blob?
unfortunately dc core currently expects a file path to a file on disk. So its not possible right now.
For a first prototype you could simply make a method in runtime.ts that uses the standard async https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args api, maybe call it "save tmp file" or sth like that and let it return the resulting file path, then set the draft to that. Then we can test it if the 20mb files really make problems or not. (but already limiting the file size in the frontend to 18mb probably makes sense because the core doesn't send files bigger than that anyway currently to not fill up the email accounts of recipients instantly.)
Thanks @Simon-Laux
I had a bit of trouble passing binary data over IPC and properly saving it to a file so I switched to using the Electron clipboard API, and that seemed to work well.
I tried @jchook's copy_paste_images branch and it worked like a treat (Linux Mint), I'm copying and pasting from Flameshot left and right. Seems like this ought make a nice new impact on the platform
Thanks for contributing @jchook :tada:
Most helpful comment
2319 Pr looks good, I merged it.
Thanks for contributing @jchook :tada: