Prevent from submitting issue/comment on uploading (#32263)

fix #32262

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
박상철 2024-10-23 11:48:04 +09:00 committed by GitHub
parent a264c46fb0
commit 620f19610e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 109 additions and 56 deletions

View file

@ -7,9 +7,16 @@ import {
DropzoneCustomEventUploadDone,
generateMarkdownLinkForAttachment,
} from '../dropzone.ts';
import type CodeMirror from 'codemirror';
let uploadIdCounter = 0;
export const EventUploadStateChanged = 'ce-upload-state-changed';
export function triggerUploadStateChanged(target) {
target.dispatchEvent(new CustomEvent(EventUploadStateChanged, {bubbles: true}));
}
function uploadFile(dropzoneEl, file) {
return new Promise((resolve) => {
const curUploadId = uploadIdCounter++;
@ -18,7 +25,7 @@ function uploadFile(dropzoneEl, file) {
const onUploadDone = ({file}) => {
if (file._giteaUploadId === curUploadId) {
dropzoneInst.off(DropzoneCustomEventUploadDone, onUploadDone);
resolve();
resolve(file);
}
};
dropzoneInst.on(DropzoneCustomEventUploadDone, onUploadDone);
@ -27,6 +34,8 @@ function uploadFile(dropzoneEl, file) {
}
class TextareaEditor {
editor : HTMLTextAreaElement;
constructor(editor) {
this.editor = editor;
}
@ -61,6 +70,8 @@ class TextareaEditor {
}
class CodeMirrorEditor {
editor: CodeMirror.EditorFromTextArea;
constructor(editor) {
this.editor = editor;
}