@@ -6,6 +6,7 @@ import {GET, POST} from '../modules/fetch.ts';
66import { showErrorToast } from '../modules/toast.ts' ;
77import { createElementFromHTML , createElementFromAttrs } from '../utils/dom.ts' ;
88import { isImageFile , isVideoFile } from '../utils.ts' ;
9+ import type { DropzoneFile } from 'dropzone/index.js' ;
910
1011const { csrfToken, i18n} = window . config ;
1112
@@ -15,7 +16,7 @@ export const DropzoneCustomEventRemovedFile = 'dropzone-custom-removed-file';
1516export const DropzoneCustomEventUploadDone = 'dropzone-custom-upload-done' ;
1617
1718async 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