aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-04-27 22:32:00 +0800
committerGitHub <noreply@github.com>2024-04-27 14:32:00 +0000
commit8de2992ffba8cc627757ecea1e002a55581113d2 (patch)
tree0ac56412f0686ae8c53e8ab1ef8d389c8cb751ae
parent6d2a307ad8af7d686f1c3a3706ff0f2df895658a (diff)
downloadgitea-8de2992ffba8cc627757ecea1e002a55581113d2.tar.gz
gitea-8de2992ffba8cc627757ecea1e002a55581113d2.zip
Make Ctrl+Enter work for issue/comment edit (#30720)v1.22.0-rc1
Fix #30710
-rw-r--r--templates/repo/diff/box.tmpl4
-rw-r--r--templates/repo/issue/view_content.tmpl6
-rw-r--r--web_src/js/features/comp/QuickSubmit.js7
-rw-r--r--web_src/js/features/repo-issue-edit.js4
4 files changed, 13 insertions, 8 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl
index 92a3163642..641de294fd 100644
--- a/templates/repo/diff/box.tmpl
+++ b/templates/repo/diff/box.tmpl
@@ -235,7 +235,7 @@
{{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
@@ -249,7 +249,7 @@
{{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>
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index 8316df2ee1..d40134ed08 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -146,7 +146,7 @@
</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")
@@ -164,8 +164,8 @@
<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>
diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js
index 477b3b9e2a..6bd5f6644d 100644
--- a/web_src/js/features/comp/QuickSubmit.js
+++ b/web_src/js/features/comp/QuickSubmit.js
@@ -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();
}
}
diff --git a/web_src/js/features/repo-issue-edit.js b/web_src/js/features/repo-issue-edit.js
index 4c03325c7a..abf2d31221 100644
--- a/web_src/js/features/repo-issue-edit.js
+++ b/web_src/js/features/repo-issue-edit.js
@@ -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