Browse Source

Fix SimpleMDE quote reply (#9757) (#9768)

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
tags/v1.11.0-rc2
John Olheiser 4 years ago
parent
commit
c579ad92b5
1 changed files with 17 additions and 13 deletions
  1. 17
    13
      web_src/js/index.js

+ 17
- 13
web_src/js/index.js View File

}); });
} }


let autoSimpleMDE;

function initCommentForm() { function initCommentForm() {
if ($('.comment.form').length === 0) { if ($('.comment.form').length === 0) {
return; return;
} }


setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)'));
autoSimpleMDE = setCommentSimpleMDE($('.comment.form textarea:not(.review-textarea)'));
initBranchSelector(); initBranchSelector();
initCommentPreviewTab($('.comment.form')); initCommentPreviewTab($('.comment.form'));
initImagePaste($('.comment.form textarea')); initImagePaste($('.comment.form textarea'));
$('.quote-reply').click(function (event) { $('.quote-reply').click(function (event) {
$(this).closest('.dropdown').find('.menu').toggle('visible'); $(this).closest('.dropdown').find('.menu').toggle('visible');
const target = $(this).data('target'); const target = $(this).data('target');
const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> ');
const content = `> ${quote}\n\n`;


let $content; let $content;
if ($(this).hasClass('quote-reply-diff')) { if ($(this).hasClass('quote-reply-diff')) {
const $parent = $(this).closest('.comment-code-cloud'); const $parent = $(this).closest('.comment-code-cloud');
$parent.find('button.comment-form-reply').click(); $parent.find('button.comment-form-reply').click();
$content = $parent.find('[name="content"]'); $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(); event.preventDefault();
}); });



Loading…
Cancel
Save