mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 23:36:17 -04:00
Merge pull request #1 from sonicblis/paste-clipboard-image
Paste image content from the clipboard
This commit is contained in:
commit
a838062564
1 changed files with 20 additions and 2 deletions
|
@ -12,6 +12,7 @@ class PeersUI {
|
||||||
Events.on('peer-left', e => this._onPeerLeft(e.detail));
|
Events.on('peer-left', e => this._onPeerLeft(e.detail));
|
||||||
Events.on('peers', e => this._onPeers(e.detail));
|
Events.on('peers', e => this._onPeers(e.detail));
|
||||||
Events.on('file-progress', e => this._onFileProgress(e.detail));
|
Events.on('file-progress', e => this._onFileProgress(e.detail));
|
||||||
|
window.addEventListener('paste', e => this._onPaste(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPeerJoined(peer) {
|
_onPeerJoined(peer) {
|
||||||
|
@ -41,6 +42,23 @@ class PeersUI {
|
||||||
_clearPeers() {
|
_clearPeers() {
|
||||||
const $peers = $$('x-peers').innerHTML = '';
|
const $peers = $$('x-peers').innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onPaste(e) {
|
||||||
|
const files = e.clipboardData.items
|
||||||
|
.filter(i => i.type.indexOf('image') > -1)
|
||||||
|
.map(i => i.getAsFile());
|
||||||
|
|
||||||
|
// send the pasted image content to the only peer if there is one
|
||||||
|
// otherwise, select the peer somehow by notifying the client that
|
||||||
|
// "image data has been pasted, click the client to which to send it"
|
||||||
|
// not implemented
|
||||||
|
if (files.length > 0 && $$('x-peer').length === 1) {
|
||||||
|
Events.fire('files-selected', {
|
||||||
|
files: files,
|
||||||
|
to: $$('x-peer').id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PeerUI {
|
class PeerUI {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue