diff options
author | zeripath <art27@cantab.net> | 2020-06-06 15:15:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-06 15:15:14 +0100 |
commit | 1ee6c13f1180693becc6cecc9a9987a1ae2eeeb4 (patch) | |
tree | af5be0d6fead9f3b9274cfea7d78ec0640e80ed7 /web_src/js | |
parent | cfac97542b3ef4b091b5830ff90d2cbad76c9502 (diff) | |
download | gitea-1ee6c13f1180693becc6cecc9a9987a1ae2eeeb4.tar.gz gitea-1ee6c13f1180693becc6cecc9a9987a1ae2eeeb4.zip |
Initialize SimpleMDE when making a code comment (#11749)
Fix #11704
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
Diffstat (limited to 'web_src/js')
-rw-r--r-- | web_src/js/index.js | 18 |
1 files changed, 17 insertions, 1 deletions
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(); }); } |