Skip to content

Commit 80192fa

Browse files
committed
fix dropzone
1 parent 5c2780c commit 80192fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web_src/js/features/dropzone.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {GET, POST} from '../modules/fetch.ts';
66
import {showErrorToast} from '../modules/toast.ts';
77
import {createElementFromHTML, createElementFromAttrs} from '../utils/dom.ts';
88
import {isImageFile, isVideoFile} from '../utils.ts';
9+
import type {DropzoneFile} from 'dropzone/index.js';
910

1011
const {csrfToken, i18n} = window.config;
1112

@@ -15,7 +16,7 @@ export const DropzoneCustomEventRemovedFile = 'dropzone-custom-removed-file';
1516
export const DropzoneCustomEventUploadDone = 'dropzone-custom-upload-done';
1617

1718
async function createDropzone(el, opts) {
18-
const [{Dropzone}] = await Promise.all([
19+
const [{default: Dropzone}] = await Promise.all([
1920
import(/* webpackChunkName: "dropzone" */'dropzone'),
2021
import(/* webpackChunkName: "dropzone" */'dropzone/dist/dropzone.css'),
2122
]);
@@ -88,7 +89,7 @@ export async function initDropzone(dropzoneEl: HTMLElement) {
8889
// "http://localhost:3000/owner/repo/issues/[object%20Event]"
8990
// the reason is that the preview "callback(dataURL)" is assign to "img.onerror" then "thumbnail" uses the error object as the dataURL and generates '<img src="[object Event]">'
9091
const dzInst = await createDropzone(dropzoneEl, opts);
91-
dzInst.on('success', (file, resp) => {
92+
dzInst.on('success', (file: DropzoneFile & {uuid: string}, resp: any) => {
9293
file.uuid = resp.uuid;
9394
fileUuidDict[file.uuid] = {submitted: false};
9495
const input = createElementFromAttrs('input', {name: 'files', type: 'hidden', id: `dropzone-file-${resp.uuid}`, value: resp.uuid});
@@ -97,7 +98,7 @@ export async function initDropzone(dropzoneEl: HTMLElement) {
9798
dzInst.emit(DropzoneCustomEventUploadDone, {file});
9899
});
99100

100-
dzInst.on('removedfile', async (file) => {
101+
dzInst.on('removedfile', async (file: DropzoneFile & {uuid: string}) => {
101102
if (disableRemovedfileEvent) return;
102103

103104
dzInst.emit(DropzoneCustomEventRemovedFile, {fileUuid: file.uuid});

0 commit comments

Comments
 (0)