Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/DragAndDropFileUpload.js
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | start : function() { | ||||
})); | })); | ||||
if (JX.PhabricatorDragAndDropFileUpload.isPasteSupported()) { | if (JX.PhabricatorDragAndDropFileUpload.isPasteSupported()) { | ||||
JX.DOM.listen( | JX.DOM.listen( | ||||
this._node, | this._node, | ||||
'paste', | 'paste', | ||||
null, | null, | ||||
JX.bind(this, function(e) { | JX.bind(this, function(e) { | ||||
var clipboardData = e.getRawEvent().clipboardData; | var clipboard = e.getRawEvent().clipboardData; | ||||
if (!clipboardData) { | if (!clipboard) { | ||||
return; | return; | ||||
} | } | ||||
for (var ii = 0; ii < clipboardData.items.length; ii++) { | // If there's any text on the clipboard, just let the event fire | ||||
var item = clipboardData.items[ii]; | // normally, choosing the text over any images. See T5437 / D9647. | ||||
var text = clipboard.getData('text/plain').toString(); | |||||
if (text.length) { | |||||
return; | |||||
} | |||||
// Safari and Firefox have clipboardData, but no items. They | |||||
// don't seem to provide a way to get image data directly yet. | |||||
if (!clipboard.items) { | |||||
return; | |||||
} | |||||
for (var ii = 0; ii < clipboard.items.length; ii++) { | |||||
var item = clipboard.items[ii]; | |||||
if (!/^image\//.test(item.type)) { | if (!/^image\//.test(item.type)) { | ||||
continue; | continue; | ||||
} | } | ||||
this._sendRequest(item.getAsFile()); | this._sendRequest(item.getAsFile()); | ||||
} | } | ||||
})); | })); | ||||
} | } | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |