Merge pull request #14678 from xundeenergie/dropzone-placeholder

Dropzone placeholder
This commit is contained in:
Hypolite Petovan 2025-01-12 08:32:52 -05:00 committed by GitHub
commit 1a68fed349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -163,7 +163,7 @@ class Upload extends \Friendica\BaseModule
}
$this->logger->info('upload done');
$this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()) . "\n\n");
$this->return(200, Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()));
}
/**

View file

@ -23,6 +23,10 @@ var DzFactory = function (max_imagesize) {
dictRemoveFile: dzStrings.dictRemoveFile,
dictMaxFilesExceeded: dzStrings.dictMaxFilesExceeded,
accept: function(file, done) {
const targetTextarea = document.getElementById(textareaElementId);
if (targetTextarea.setRangeText) {
targetTextarea.setRangeText("\n[upload-" + file.name + "]\n", targetTextarea.selectionStart, targetTextarea.selectionEnd, "end");
}
done();
},
init: function() {
@ -30,7 +34,8 @@ var DzFactory = function (max_imagesize) {
const targetTextarea = document.getElementById(textareaElementId);
if (targetTextarea.setRangeText) {
//if setRangeText function is supported by current browser
targetTextarea.setRangeText(serverResponse);
let u = "[upload-" + file.name + "]";
targetTextarea.setRangeText(serverResponse, targetTextarea.value.indexOf(u), targetTextarea.value.indexOf(u) + u.length, "end");
} else {
targetTextarea.focus();
document.execCommand('insertText', false /*no UI*/, serverResponse);

View file

@ -92,6 +92,9 @@
<div id="comment-edit-preview-{{$id}}" class="comment-edit-preview" style="display:none;"></div>
<div id="permissions-section" style="display: none;">
<script>
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
</script>
{{if $type == 'post'}}
<h3>{{$l10n.visibility_title}}</h3>
{{$acl_selector nofilter}}
@ -113,8 +116,6 @@
</div>
</div>
<script>
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
document.addEventListener("DOMContentLoaded", function() {
var textareas = document.querySelectorAll(".expandable-textarea");