Make Ctrl+Enter (quick submit) work for issue comment and wiki editor (#19729)

* Make Ctrl+Enter (quick submit) work for issue comment and wiki editor

* Remove the required `SubmitReviewForm.Type`, empty type (triggered by quick submit) means "comment"

* Merge duplicate code
This commit is contained in:
wxiaoguang 2022-05-20 10:26:04 +08:00 committed by GitHub
parent 3b359b1629
commit cc7236e852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 16 deletions

View file

@ -355,6 +355,11 @@ async function onEditContent(event) {
initEasyMDEImagePaste(easyMDE, $dropzone[0], $dropzone.find('.files'));
}
const $saveButton = $editContentZone.find('.save.button');
$textarea.on('ce-quick-submit', () => {
$saveButton.trigger('click');
});
$editContentZone.find('.cancel.button').on('click', () => {
$renderContent.show();
$editContentZone.hide();
@ -362,7 +367,8 @@ async function onEditContent(event) {
dz.emit('reload');
}
});
$editContentZone.find('.save.button').on('click', () => {
$saveButton.on('click', () => {
$renderContent.show();
$editContentZone.hide();
const $attachments = $dropzone.find('.files').find('[name=files]').map(function () {
@ -400,7 +406,7 @@ async function onEditContent(event) {
initCommentContent();
});
});
} else {
} else { // use existing form
$textarea = $segment.find('textarea');
easyMDE = getAttachedEasyMDE($textarea);
}