fix composer dropzone

pull/12883/head
Jakobus Schürz 2023-03-13 04:06:59 +01:00
rodzic 5107d4418e
commit 6a7f17559e
2 zmienionych plików z 7 dodań i 6 usunięć

Wyświetl plik

@ -96,7 +96,8 @@
</div> </div>
</div> </div>
<script> <script>
var dropzoneCompose = new Dropzone(document.body, { // camelized version of the `id` Dropzone.autoDiscover = false;
var dropzoneCompose = new Dropzone( '#comment-edit-form-{{$id}}', {
paramName: "userfile", // The name that will be used to transfer the file paramName: "userfile", // The name that will be used to transfer the file
maxFilesize: 2, // MB maxFilesize: 2, // MB
previewsContainer: '#dz-previewsCompose', previewsContainer: '#dz-previewsCompose',
@ -110,7 +111,7 @@
}, },
init: function() { init: function() {
this.on("success", function(file, serverResponse) { this.on("success", function(file, serverResponse) {
var target = $(':focus').closest('.comment-edit-form').find('.comment-edit-text'); var target = $('#comment-edit-text-{{$id}}')
var resp = $(serverResponse).find('div#content').text() var resp = $(serverResponse).find('div#content').text()
if (target.setRangeText) { if (target.setRangeText) {
//if setRangeText function is supported by current browser //if setRangeText function is supported by current browser
@ -122,7 +123,8 @@
}); });
}, },
}); });
document.onpaste = function(event){
$('#comment-edit-form-{{$id}}').on('paste', function(event){
const items = (event.clipboardData || event.originalEvent.clipboardData).items; const items = (event.clipboardData || event.originalEvent.clipboardData).items;
items.forEach((item) => { items.forEach((item) => {
if (item.kind === 'file') { if (item.kind === 'file') {
@ -131,5 +133,5 @@
dropzoneCompose.addFile(item.getAsFile()) dropzoneCompose.addFile(item.getAsFile())
} }
}) })
} });
</script> </script>

Wyświetl plik

@ -68,7 +68,6 @@
<script> <script>
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
var dropzone{{$id}} = new Dropzone( '#comment-edit-wrapper-{{$id}}', { var dropzone{{$id}} = new Dropzone( '#comment-edit-wrapper-{{$id}}', {
//var dropzone{{$id}} = new Dropzone( document.body, {
paramName: "userfile", // The name that will be used to transfer the file paramName: "userfile", // The name that will be used to transfer the file
maxFilesize: 6, // MB maxFilesize: 6, // MB
previewsContainer: '#dz-preview-{{$id}}', previewsContainer: '#dz-preview-{{$id}}',
@ -104,7 +103,7 @@
dropzone{{$id}}.addFile(item.getAsFile()) dropzone{{$id}}.addFile(item.getAsFile())
} }
}) })
}) });
</script> </script>