Skip to content

Commit

Permalink
feat: enhance upload configuration with additional Uppy and XHRUpload…
Browse files Browse the repository at this point in the history
… 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`
  • Loading branch information
cycleccc authored Mar 3, 2025
1 parent 2e00706 commit 71397d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/twelve-seahorses-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@wangeditor-next/core': patch
'@wangeditor-next/editor': patch
---

feat: enhance upload configuration with additional Uppy and XHRUpload options
6 changes: 4 additions & 2 deletions packages/core/src/upload/createUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ function createUploader(config: IUploadConfig): Uppy {
maxNumberOfFiles,
},
meta, // 自定义添加到 formData 中的参数
...config.uppyConfig, // 支持传入更多 Uppy 配置项
}).use(XHRUpload, {
endpoint: url, // 服务端 url
headers, // 自定义 headers
endpoint: url,
headers,
formData: true,
fieldName,
bundle: true,
withCredentials,
timeout,
...config.xhrConfig, // 支持传入更多 XHRUpload 配置项
})

// 各个 callback
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/upload/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ export interface IUploadConfig {
customUpload?: (files: File, insertFn: InsertFn) => void
// 自定义选择视频,如图床
customBrowseAndUpload?: (insertFn: InsertFn) => void
// 支持传入更多 Uppy 配置项
uppyConfig?: Record<string, any>;
// 支持传入更多 XHRUpload 配置项
xhrConfig?: Record<string, any>;
}

0 comments on commit 71397d4

Please sign in to comment.