Allow to paste images (#153)
dropzone.js doesn't support pasting itself yet, so adding it externally and calling `.addFile()` to upload the pasted image. Fixes #130
This commit is contained in:
parent
5f4f16e08b
commit
6290f408ff
|
@ -102,8 +102,18 @@ Dropzone.options.dropzone = {
|
||||||
previewsContainer: "#uploads",
|
previewsContainer: "#uploads",
|
||||||
parallelUploads: 5,
|
parallelUploads: 5,
|
||||||
headers: {"Accept": "application/json"},
|
headers: {"Accept": "application/json"},
|
||||||
dictDefaultMessage: "Click or Drop file(s)",
|
dictDefaultMessage: "Click or Drop file(s) or Paste image",
|
||||||
dictFallbackMessage: ""
|
dictFallbackMessage: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
document.onpaste = function(event) {
|
||||||
|
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||||
|
for (index in items) {
|
||||||
|
var item = items[index];
|
||||||
|
if (item.kind === "file") {
|
||||||
|
Dropzone.forElement("#dropzone").addFile(item.getAsFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// @end-license
|
// @end-license
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="dzone" class="dz-default dz-message">
|
<div id="dzone" class="dz-default dz-message">
|
||||||
<span>Click or Drop file(s)</span>
|
<span>Click or Drop file(s) or Paste image</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="choices">
|
<div id="choices">
|
||||||
|
|
Loading…
Reference in New Issue