Support sending files from clipboard (fixes #1585)

This commit is contained in:
Kim Alvefur 2019-07-03 22:26:07 +02:00 committed by JC Brand
parent 3bd8c6dbec
commit 28b51f75ce
2 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,7 @@
- #1576: Converse gets stuck with spinner when logging out with `auto_login` set to `true`
- #1579: Trim spaces at the beginning and end of a JID (when adding contact)
- #1586: Not possible to kick someone with a space in their nickname
- #1585: Upload files by pasting from clipboard
### Breaking changes

View File

@ -972,6 +972,15 @@ converse.plugins.add('converse-chatview', {
},
onPaste (ev) {
if (ev.clipboardData.files.length !== 0) {
ev.preventDefault();
// Workaround for quirk in at least Firefox 60.7 ESR:
// It seems that pasted files disappear from the event payload after
// the event has finished, which apparently happens during async
// processing in sendFiles(). So we copy the array here.
this.model.sendFiles(Array.from(ev.clipboardData.files));
return;
}
this.updateCharCounter(ev.clipboardData.getData('text/plain'));
},