question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to paste images from clipboard with keyboard shortcut

See original GitHub issue

Aknowledgements

  • I have checked that there’s no other issue describing the same or similar problem that I currently have, regardless if it has been closed or open.

  • I can confirm that this is not an issue with the Discord website, but it is a problem specific to the WebCord itself.

  • I have tried running the build from the master branch and it does not have any fixes implemented according to my issue.

  • My issue describes one of the unstable and/or not fully implemented features.

  • I have found a workaround to mitigate or temporarily fix this issue (please write it in Additional context section).

Operating System / Platform

🐧️ Linux

Operating system architecture

x64 (64-bit Intel/AMD)

Electron version

v19.0.1

Application version

v3.2.0

Bug description

I’m unable to paste an image from the clipboard when using the keyboard shortcut(ctrl + v). However, right clicking and choosing “paste” does work.

To reproduce:

  1. Copy an image from your browser.
  2. Try pressing ctrl+v in the text box. Nothing happens
  3. Then right click and click on paste. This time the image gets uploaded
  4. Now press ctrl+v again. Somehow the shortcut works this time.

Additional context

https://user-images.githubusercontent.com/10794178/174498662-f30ab09b-f0c1-4286-af06-f818c6974abc.mp4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SpacingBat3commented, Jun 19, 2022

Ah I see. Thanks for the explanation.

Although I wonder why pasting images in the official discord client works if it’s an issue with electron.

Hmm, I guess they are aware of this bug and have a direct access to the clipboard? But if so, maybe there’s a way to actually overwrite CTRL+V? I’ll take a look on this, maybe reopen if there will be any chance to workaround CTRL+V as well…

1reaction
SpacingBat3commented, Jun 20, 2022

Actually, this seems to be a Discord Web bug, I can even reproduce it in Chromium – it occurs for images copied between different browser engines. My guesses are it won’t work as well when you would try to copy an image from Chromium and paste it in Discord Web launched in Firefox. And there’s a way to actually fetch image from clipboard without any workarounds, both in WebCord and Chromium – just Discord does that the wrong way. I guess they can actually read the clipboard using the Electron clipboard API in their own Electron client, but in browser they use one of the Web APIs which somehow fails to get a tray content and/or handle it properly.

So, you should definitely report that to Discord developers, it’s not my fault – even when WebCord actually does some weird workarounds that seems to kinda succeed where it should fail.

Anyway, I still implemented a better workaround, which actually does not modify the tray content (it preserves all of its types) and still works with CTRL+V. It works now in two processes:

Preload:

  1. Add new listener to the paste event (watches entire document).
  2. If content of the tray is broken:
    • (somehow) fix it,
    • stop event propagation (prevent any further events from execution),
    • send IPC message to main to re-emit paste event.
  3. Otherwise, do nothing and allow Discord to handle paste.

Main:

  1. Add new IPC listener for paste-workaround channel.
  2. When there will be any incoming message in paste-workaround, emit paste in current webContents.

See commit c3c8b16 for the actual implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] Copy and Paste Not Working on Windows 10
If your clipboard is full, you may not be able to copy-paste properly. ... Type cmd in the Windows search box, then right-click...
Read more >
Windows+Shift+S cannot paste image, have to open snip ...
Ctrl+V is the keyboard shortcut to paste what's in the clipboard. Alternatively, you can right click the pointing device and select 'paste' ...
Read more >
How to Fix When Copy-Paste Isn't Working - Alphr
Check Your Keyboard. If you're not able to use keyboard shortcuts for copy-paste, try selecting the file/text using your mouse, then select Copy ......
Read more >
How to Fix Copy and Paste Not Working in Windows
If you're trying to use the copy-paste keyboard shortcuts ( Ctrl + C , Ctrl + V ), test them in different contexts...
Read more >
Can't paste images from clipboard into OneNote web app
Use the keyboard shortcuts for cut, copy and paste instead. ... The OneNote Web App does not allow images to be pasted from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found