GoogleChromeLabs / GoogleChromeLabs/squoosh
Consider adding a `'paste'` event listener so that Cmd-V can paste images without permissions prompt
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
Currently, clicking "paste" triggers a clipboard permissions prompt. It'd be nice if just hitting Cmd-V (or Edit->Paste) in the browser would work too.
**Describe the solution you'd like**
Add something like this:
```
window.addEventListener('paste', event => {
let file_input = document.querySelector('#file'); // Whatever your internal file input object's id is
file_input.files = event.clipboardData.files;
file_input.dispatchEvent(new Event('change'))
});
```
With this, I can Cmd-C a file in Finder on macOS and then Cmd-V it in webapps that have that snippet.
**Does other service/app have this feature?**
My little image input tech demo has it: https://github.com/nico/hack/blob/main/cam/cam-param.html#L22
In general, many applications allow pasting images, of course.
Contributor guide
Assessment
This issue has not been assessed yet.