mailui.init({
features: {
userUploads: {
enabled: true
},
},
});
uploading
, fetching
, and management
, you can use the following callbacks for uploading, fetching, and removing images.mailui.registerProvider(
"userUploads",
async (params: { page: number; perPage: number; mediaType: MediaType }, done: Function) => {
done(data, meta);
}
);
Property | Description | Type | Default |
---|---|---|---|
page | The current page number | number | 1 |
perPage | The number of items displayed per page | number | 20 |
mediaType | Different type of media can be specify | image icon | image |
Property | Description | Type | Default |
---|---|---|---|
id | Unique number | any | - |
fileName | Media file name | string | - |
src | Media full url | string | - |
alt | Media alt text | string | - |
Property | Description | Type | Default |
---|---|---|---|
page | The current page number | number | 1 |
lastPage | The total number of pages | number | - |
perPage | The number of items displayed per page | number | 20 |
total | The total number of items | number | - |
mailui.registerProvider(
"image:onUpload",
async (params: { file: File; mediaType: MediaType }, done: Function) => {
try {
const media = {};
done(media);
} catch (error) {
done(null);
console.log("An error has occurred during upload file.");
}
}
);
Property | Description | Type | Default |
---|---|---|---|
file | Uploaded BLOB file type | file | - |
mediaType | Different type of media can be specify | image icon | image |
Property | Description | Type | Default |
---|---|---|---|
id | Unique number | string | number | - |
fileName | Media file name | string | - |
src | Media full url | string | - |
alt | Media alt text | string | - |
mailui.registerCallback("image:onRemove", async (image: Media, done: Function) => {
// Add your code here
done();
});
Property | Description | Type | Default |
---|---|---|---|
image | Image has all media properties {id: '', fileName: '', src: '', alt: ''} | media{} | - |