From 1ee6c13f1180693becc6cecc9a9987a1ae2eeeb4 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 6 Jun 2020 15:15:14 +0100 Subject: Initialize SimpleMDE when making a code comment (#11749) Fix #11704 Signed-off-by: Andrew Thornton Co-Authored-By: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> --- web_src/js/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'web_src/js') diff --git a/web_src/js/index.js b/web_src/js/index.js index bd3f5da7f4..21809f73fa 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1200,6 +1200,17 @@ function initPullRequestReview() { $(this).hide(); const form = $(this).parent().find('.comment-form'); form.removeClass('hide'); + const $textarea = form.find('textarea'); + let $simplemde; + if ($textarea.data('simplemde')) { + $simplemde = $textarea.data('simplemde'); + } else { + attachTribute($textarea.get(), {mentions: true, emoji: true}); + $simplemde = setCommentSimpleMDE($textarea); + $textarea.data('simplemde', $simplemde); + } + $textarea.focus(); + $simplemde.codemirror.focus(); assingMenuAttributes(form.find('.menu')); }); // The following part is only for diff views @@ -1259,7 +1270,12 @@ function initPullRequestReview() { td.find("input[name='side']").val(side === 'left' ? 'previous' : 'proposed'); td.find("input[name='path']").val(path); } - commentCloud.find('textarea').focus(); + const $textarea = commentCloud.find('textarea'); + attachTribute($textarea.get(), {mentions: true, emoji: true}); + + const $simplemde = setCommentSimpleMDE($textarea); + $textarea.focus(); + $simplemde.codemirror.focus(); }); } -- cgit v1.2.3