diff --git a/.changeset/rich-waves-argue.md b/.changeset/rich-waves-argue.md new file mode 100644 index 000000000..3e3fcb823 --- /dev/null +++ b/.changeset/rich-waves-argue.md @@ -0,0 +1,6 @@ +--- +"@wangeditor-next/core": patch +"@wangeditor-next/editor": patch +--- + +fix(upload): add complete upload callback diff --git a/packages/core/src/upload/createUploader.ts b/packages/core/src/upload/createUploader.ts index 2ec967104..ad70a05cd 100644 --- a/packages/core/src/upload/createUploader.ts +++ b/packages/core/src/upload/createUploader.ts @@ -67,11 +67,13 @@ function createUploader(config: IUploadConfig): Uppy { }) // 各个 callback - uppy.on('upload-success', (file, response) => { - const { body = {} } = response + // onSuccess 每个 file 上传成功都会触发,改用 complete 便于 files 上传 + uppy.on('complete', result => { + const file = result.successful[0] + const { response } = file + const { body = {} } = response ?? {} try { - // 有用户传入的第三方代码,得用 try catch 包裹 onSuccess(file, body) } catch (err) { console.error('wangEditor upload file - onSuccess error', err)