Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot paste images from clipboard into chat #2108

Closed
jchook opened this issue Feb 7, 2021 · 13 comments
Closed

Cannot paste images from clipboard into chat #2108

jchook opened this issue Feb 7, 2021 · 13 comments
Labels
enhancement New feature or request

Comments

@jchook
Copy link
Contributor

jchook commented Feb 7, 2021

  • Operating System (Linux/Mac/Windows/iOS/Android): Linux
  • Delta Chat Version: 1.14.1
  • Expected behavior: Can paste images into chat
  • Actual behavior: No workie
  • Steps to reproduce the problem: Copy an image to clipboard, then paste into a delta-chat input
  • Screenshots:
    Peek 2021-02-06 22-47-delta-chat-cant-paste-images-2
  • Logs: I do not see any logs produced as a result of the paste
@Simon-Laux Simon-Laux added the enhancement New feature or request label Feb 7, 2021
@Simon-Laux
Copy link
Member

this is also a feature request on the forum:
https://support.delta.chat/t/paste-pictures-from-the-clipboard-into-the-message-field/949

@Jikstra
Copy link
Contributor

Jikstra commented May 8, 2021

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.

@Simon-Laux
Copy link
Member

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.

@Jikstra
Copy link
Contributor

Jikstra commented May 8, 2021

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?

@grand-lotus-iroh
Copy link

grand-lotus-iroh commented Jul 21, 2021

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!!

@jchook
Copy link
Contributor Author

jchook commented Jul 21, 2021

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?

@YamatoRyou
Copy link

I am a little bit lost. As a basic function of an IM, DC has not been able to realize it until today.

@groovenectar
Copy link

groovenectar commented Jul 24, 2021

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

@jchook
Copy link
Contributor Author

jchook commented Jul 24, 2021

So far able to access the binary data of pasted images here: 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.

@Simon-Laux
Copy link
Member

Simon-Laux commented Jul 24, 2021

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.)

@jchook
Copy link
Contributor Author

jchook commented Jul 24, 2021

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.

#2319

@groovenectar
Copy link

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

@Simon-Laux
Copy link
Member

#2319 Pr looks good, I merged it.
Thanks for contributing @jchook 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants