]> source.dussan.org Git - gitea.git/commitdiff
Make Ctrl+Enter work for issue/comment edit (#30720) v1.22.0-rc1
authorwxiaoguang <wxiaoguang@gmail.com>
Sat, 27 Apr 2024 14:32:00 +0000 (22:32 +0800)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 14:32:00 +0000 (14:32 +0000)
Fix #30710

templates/repo/diff/box.tmpl
templates/repo/issue/view_content.tmpl
web_src/js/features/comp/QuickSubmit.js
web_src/js/features/repo-issue-edit.js

index 92a3163642cf64fe2b6e100927a54ffee92b1523..641de294fd9a9422c6dfc9eeb7b250134e058e7a 100644 (file)
 
        {{if and (not $.Repository.IsArchived) (not .DiffNotAvailable)}}
                <template id="issue-comment-editor-template">
-                       <div class="ui comment form">
+                       <div class="ui form comment">
                                {{template "shared/combomarkdowneditor" (dict
                                        "MarkdownPreviewUrl" (print $.Repository.Link "/markup")
                                        "MarkdownPreviewContext" $.RepoLink
                                {{end}}
                                <div class="text right edit buttons">
                                        <button class="ui cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
-                                       <button class="ui primary save button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
+                                       <button class="ui primary button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
                                </div>
                        </div>
                </template>
index 8316df2ee1b499902eb3e0157954a0a5badd227c..d40134ed085986a1c80c34d1faac6d446e63c821 100644 (file)
 </div>
 
 <template id="issue-comment-editor-template">
-       <div class="ui comment form">
+       <div class="ui form comment">
                <div class="field">
                        {{template "shared/combomarkdowneditor" (dict
                                "MarkdownPreviewUrl" (print .Repository.Link "/markup")
 
                <div class="field">
                        <div class="text right edit">
-                               <button class="ui basic cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
-                               <button class="ui primary save button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
+                               <button class="ui cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
+                               <button class="ui primary button">{{ctx.Locale.Tr "repo.issues.save"}}</button>
                        </div>
                </div>
        </div>
index 477b3b9e2afce8adda07bd8717ef0602af0d9798..6bd5f6644d8b4b43b054056912c1553234bf5c42 100644 (file)
@@ -1,5 +1,5 @@
 export function handleGlobalEnterQuickSubmit(target) {
-  const form = target.closest('form');
+  let form = target.closest('form');
   if (form) {
     if (!form.checkValidity()) {
       form.reportValidity();
@@ -9,5 +9,10 @@ export function handleGlobalEnterQuickSubmit(target) {
     // here use the event to trigger the submit event (instead of calling `submit()` method directly)
     // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog
     form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true}));
+    return;
+  }
+  form = target.closest('.ui.form');
+  if (form) {
+    form.querySelector('.ui.primary.button')?.click();
   }
 }
index 4c03325c7a5f68021e988d5573f001215c979a81..abf2d3122102488bd90a2bfa57a7eeec32a1ee2c 100644 (file)
@@ -162,8 +162,8 @@ async function onEditContent(event) {
     editContentZone.innerHTML = document.getElementById('issue-comment-editor-template').innerHTML;
     comboMarkdownEditor = await initComboMarkdownEditor(editContentZone.querySelector('.combo-markdown-editor'));
     comboMarkdownEditor.attachedDropzoneInst = await setupDropzone(editContentZone.querySelector('.dropzone'));
-    editContentZone.querySelector('.cancel.button').addEventListener('click', cancelAndReset);
-    editContentZone.querySelector('.save.button').addEventListener('click', saveAndRefresh);
+    editContentZone.querySelector('.ui.cancel.button').addEventListener('click', cancelAndReset);
+    editContentZone.querySelector('.ui.primary.button').addEventListener('click', saveAndRefresh);
   }
 
   // Show write/preview tab and copy raw content as needed