Skip to content

Commit 71397d4

Browse files
authored
feat: enhance upload configuration with additional Uppy and XHRUpload options (#553)
- Add support for passing custom Uppy and XHRUpload configuration options - Update `IUploadConfig` interface to include `uppyConfig` and `xhrConfig` - Spread additional configuration options in `createUploader`
1 parent 2e00706 commit 71397d4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.changeset/twelve-seahorses-cross.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@wangeditor-next/core': patch
3+
'@wangeditor-next/editor': patch
4+
---
5+
6+
feat: enhance upload configuration with additional Uppy and XHRUpload options

packages/core/src/upload/createUploader.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ function createUploader(config: IUploadConfig): Uppy {
5656
maxNumberOfFiles,
5757
},
5858
meta, // 自定义添加到 formData 中的参数
59+
...config.uppyConfig, // 支持传入更多 Uppy 配置项
5960
}).use(XHRUpload, {
60-
endpoint: url, // 服务端 url
61-
headers, // 自定义 headers
61+
endpoint: url,
62+
headers,
6263
formData: true,
6364
fieldName,
6465
bundle: true,
6566
withCredentials,
6667
timeout,
68+
...config.xhrConfig, // 支持传入更多 XHRUpload 配置项
6769
})
6870

6971
// 各个 callback

packages/core/src/upload/interface.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ export interface IUploadConfig {
4141
customUpload?: (files: File, insertFn: InsertFn) => void
4242
// 自定义选择视频,如图床
4343
customBrowseAndUpload?: (insertFn: InsertFn) => void
44+
// 支持传入更多 Uppy 配置项
45+
uppyConfig?: Record<string, any>;
46+
// 支持传入更多 XHRUpload 配置项
47+
xhrConfig?: Record<string, any>;
4448
}

0 commit comments

Comments
 (0)