diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2020-01-14 14:47:38 -0600 |
---|---|---|
committer | Antoine GIRARD <sapk@users.noreply.github.com> | 2020-01-14 21:47:38 +0100 |
commit | d89022c202473818268e52b55e5f3bdfbcaf73d8 (patch) | |
tree | a3c345839850fb298f8839b089b70761ebf6c43b /web_src | |
parent | f00961abe72dbe3922986d22dfa7be2e2261e7be (diff) | |
download | gitea-d89022c202473818268e52b55e5f3bdfbcaf73d8.tar.gz gitea-d89022c202473818268e52b55e5f3bdfbcaf73d8.zip |
Fix SimpleMDE quote reply (#9757)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/index.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js index b701da08b1..7c3749c08b 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -323,12 +323,14 @@ function initSimpleMDEImagePaste(simplemde, files) { }); } +let autoSimpleMDE; + function initCommentForm() { if ($('.comment.form').length === 0) { return; } - setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)')); + autoSimpleMDE = setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)')); initBranchSelector(); initCommentPreviewTab($('.comment.form')); initImagePaste($('.comment.form textarea')); @@ -826,25 +828,27 @@ function initRepository() { $('.quote-reply').click(function (event) { $(this).closest('.dropdown').find('.menu').toggle('visible'); const target = $(this).data('target'); + const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> '); + const content = `> ${quote}\n\n`; let $content; if ($(this).hasClass('quote-reply-diff')) { const $parent = $(this).closest('.comment-code-cloud'); $parent.find('button.comment-form-reply').click(); $content = $parent.find('[name="content"]'); - } else { - $content = $('#content'); - } - - const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> '); - const content = `> ${quote}\n\n`; - - if ($content.val() !== '') { - $content.val(`${$content.val()}\n\n${content}`); - } else { - $content.val(`${content}`); + if ($content.val() !== '') { + $content.val(`${$content.val()}\n\n${content}`); + } else { + $content.val(`${content}`); + } + $content.focus(); + } else if (autoSimpleMDE !== null) { + if (autoSimpleMDE.value() !== '') { + autoSimpleMDE.value(`${autoSimpleMDE.value()}\n\n${content}`); + } else { + autoSimpleMDE.value(`${content}`); + } } - $content.focus(); event.preventDefault(); }); |