allow pasting images in DM replies

pull/93/head
Aevann 2023-01-23 13:04:07 +02:00
parent 9ad4cf8035
commit dd8e3255a0
2 changed files with 11 additions and 9 deletions

View File

@ -119,7 +119,7 @@ function post_reply(id){
form.append('parent_id', id);
form.append('body', document.getElementById('reply-form-body-'+id).value);
try {
for (const e of document.getElementById(`file-upload-${id}`).files)
for (const e of document.getElementById(`file-upload-reply-c_${id}`).files)
form.append('file', e);
}
catch(e) {}
@ -144,10 +144,10 @@ function post_reply(id){
document.getElementById('reply-form-body-'+id).value = ''
document.getElementById('message-reply-'+id).innerHTML = ''
toggleReplyBox('reply-message-c_'+id)
const fileupload = document.getElementById(`file-upload-${id}`)
const fileupload = document.getElementById(`file-upload-reply-c_${id}`)
if (fileupload) {
fileupload.value = null;
document.getElementById(`filename-${id}`).innerHTML = '<i class="fas fa-file"></i>';
document.getElementById(`filename-show-reply-c_${id}`).innerHTML = '<i class="fas fa-file"></i>';
}
} else {
showToast(false, getMessageFromJsonData(false, data));

View File

@ -482,7 +482,10 @@
{% if v and v.id != c.author_id and c.body %}
<div autocomplete="off" class="markdown d-none card border my-2 p-3 comment-box form-control rounded" id="markdown-{{c.id}}" readonly>{{c.body.strip()}}</div>
{% endif %}
{{macros.comment_reply_box(c.fullname, "reply-to-" + c.fullname, "d-none", "collapsed child", 'reply-to-' + c.fullname, true)}}
{% if c.parent_submission or c.wall_user_id %}
{{macros.comment_reply_box(c.fullname, "reply-to-" + c.fullname, "d-none", "collapsed child", 'reply-to-' + c.fullname, true)}}
{% endif %}
{% if request.path.startswith('/transfers') %}
<a href="{{c.log_link}}"><i class="far fa-link ml-1 text-muted"></i></a>
@ -513,20 +516,19 @@
<button type="button" class="btn btn-primary nobackground" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox('reply-message-{{c.fullname}}')">Reply</button>
{# TODO: swap to comment_reply_box macro #}
<div id="reply-message-{{c.fullname}}" class="d-none">
<div id="comment-form-space-{{c.id}}" class="comment-write collapsed child">
<div class="input-group">
<input type="hidden" name="formkey" value="{{v|formkey}}">
<textarea required autocomplete="off" minlength="1" maxlength="10000" name="body" form="reply-to-c_{{c.id}}" data-id="{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" rows="3" data-preview="message-reply-{{c.id}}" data-nonce="{{g.nonce}}" data-oninput="markdown(this)"></textarea>
<textarea data-fullname="{{c.fullname}}" required autocomplete="off" minlength="1" maxlength="10000" name="body" form="reply-to-c_{{c.id}}" data-id="{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" rows="3" data-preview="message-reply-{{c.id}}" data-nonce="{{g.nonce}}" data-oninput="markdown(this)"></textarea>
<div class="comment-format" id="comment-format-bar-{{c.id}}">
<button type="button" data-nonce="{{g.nonce}}" data-onclick="loadEmojis('reply-form-body-{{c.id}}')" class="btn btn-secondary m-0 mt-3 mr-1" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add Emoji"><i class="fas fa-smile-beam"></i></button>
{% set upload_disabled = g.is_tor or not get_setting('dm_images') %}
<label class="btn btn-secondary m-0 mt-3 {% if upload_disabled %}disabled{% endif %}" for="file-upload-{{c.id}}">
<div id="filename-{{c.id}}"><i class="fas fa-image"></i></div>
<input autocomplete="off" id="file-upload-{{c.id}}" accept="image/*" type="file" name="file" multiple="multiple" {% if upload_disabled %}disabled{% endif %} data-nonce="{{g.nonce}}" data-onchange="changename('filename-{{c.id}}','file-upload-{{c.id}}')" hidden>
<label class="btn btn-secondary m-0 mt-3 {% if upload_disabled %}disabled{% endif %}" for="file-upload-reply-{{c.fullname}}">
<div id="filename-show-reply-{{c.fullname}}"><i class="fas fa-image"></i></div>
<input autocomplete="off" id="file-upload-reply-{{c.fullname}}" accept="image/*" type="file" name="file" multiple="multiple" {% if upload_disabled %}disabled{% endif %} data-nonce="{{g.nonce}}" data-onchange="changename('filename-show-reply-{{c.fullname}}','file-upload-reply-{{c.fullname}}')" hidden>
</label>
</div>