Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize SimpleMDE when making a code comment (#11749) #11785

Merged
merged 2 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,18 @@ 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 {
issuesTribute.attach($textarea.get());
emojiTribute.attach($textarea.get());
$simplemde = setCommentSimpleMDE($textarea);
$textarea.data('simplemde', $simplemde);
}
$textarea.focus();
$simplemde.codemirror.focus();
assingMenuAttributes(form.find('.menu'));
});
// The following part is only for diff views
Expand Down Expand Up @@ -1261,7 +1273,13 @@ 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');
issuesTribute.attach($textarea.get());
emojiTribute.attach($textarea.get());

const $simplemde = setCommentSimpleMDE($textarea);
$textarea.focus();
$simplemde.codemirror.focus();
});
}

Expand Down
21 changes: 9 additions & 12 deletions web_src/less/_review.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@
border: 0;
padding: 0;
margin: 0;

&.markdown {
padding: 1em;
min-height: 168px;
}
}

&.header {
padding: .1rem 1rem;

.text {
margin: 0;
}
}
}

Expand All @@ -76,18 +75,16 @@
}

.ui.active.tab {
border: 1px solid #d4d4d5;
padding: .5em;
border-radius: 0 .28571429rem .28571429rem .28571429rem;
}

.ui.active.markdown.tab {
border-top-left-radius: .28571429rem;
&.markdown {
padding: 1em;
min-height: 168px;
}
}

.ui.tabular.menu {
margin-bottom: 0;
border-bottom: 0;
margin: .5em;
}

.comment-list {
Expand Down