From cc7236e852e60e4dc9c4fb5692ac62697ef0e9e3 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 20 May 2022 10:26:04 +0800 Subject: 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 --- web_src/js/features/repo-wiki.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'web_src/js/features/repo-wiki.js') diff --git a/web_src/js/features/repo-wiki.js b/web_src/js/features/repo-wiki.js index 0ac88e3f5a..27f44f4e22 100644 --- a/web_src/js/features/repo-wiki.js +++ b/web_src/js/features/repo-wiki.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import {initMarkupContent} from '../markup/content.js'; -import {attachEasyMDEToElements, importEasyMDE, validateTextareaNonEmpty} from './comp/EasyMDE.js'; +import {attachEasyMDEToElements, codeMirrorQuickSubmit, importEasyMDE, validateTextareaNonEmpty} from './comp/EasyMDE.js'; import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js'; const {csrfToken} = window.config; @@ -122,10 +122,12 @@ async function initRepoWikiFormEditor() { ] }); - attachEasyMDEToElements(easyMDE); + easyMDE.codemirror.setOption('extraKeys', { + 'Cmd-Enter': codeMirrorQuickSubmit, + 'Ctrl-Enter': codeMirrorQuickSubmit, + }); - const $mdeInputField = $(easyMDE.codemirror.getInputField()); - $mdeInputField.addClass('js-quick-submit'); + attachEasyMDEToElements(easyMDE); $form.on('submit', () => { if (!validateTextareaNonEmpty($editArea)) { -- cgit v1.2.3