1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 16:44:26 +00:00

Fix JS error when dropping a file to a editor without dropzone (#32804)

`dropzoneEl` may not exist
This commit is contained in:
wxiaoguang 2024-12-12 12:37:25 +08:00 committed by GitHub
parent dfd7594499
commit 1e751d81b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -178,6 +178,7 @@ export function initTextareaEvents(textarea, dropzoneEl) {
}); });
textarea.addEventListener('drop', (e) => { textarea.addEventListener('drop', (e) => {
if (!e.dataTransfer.files.length) return; if (!e.dataTransfer.files.length) return;
if (!dropzoneEl) return;
handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, e.dataTransfer.files, e); handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, e.dataTransfer.files, e);
}); });
dropzoneEl?.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}) => { dropzoneEl?.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}) => {