Library

If you want full control over library saving, fetching, and management, you can use the following callbacks for saving, fetching, and manage library.
mailui.init({ saveToLibrary: { enabled: true, }, });

Fetch Library Listener #

Collect user-uploaded images, gather metadata, and return them as a list along with additional metadata using the done(data[], meta: object) function.
mailui.registerProvider( "library:collections", async (params: { page: number; perPage: number }, done: Function) => { done(data, meta); } );

Params #

PropertyDescriptionTypeDefault
pageThe current page numbernumber1
perPageThe number of items displayed per pagenumber20

Callback Data #

PropertyDescriptionTypeDefault
idUnique numberany-
nameLibrary specific namestring-
thumbnailUrlThumbnail full urlstring-
elementTypeThe element type should be one of the following
SECTION ROW COLUMN ELEMENT
-

Callback Meta #

PropertyDescriptionTypeDefault
pageThe current page numbernumber1
lastPageThe total number of pagesnumber-
perPageThe number of items displayed per pagenumber20
totalThe total number of itemsnumber-

Fetch JSON Data #

Triggers when a user uploads files, handling and processing them as needed.
mailui.registerProvider("library:collectionData", async (params, done) => { const data = {}; // template JSON done(data); } );

Params #

PropertyDescriptionTypeDefault
idUnique numberany-
nameLibrary specific namestring-
thumbnailUrlThumbnail full urlstring-
elementTypeThe element type should be one of the following
SECTION ROW COLUMN ELEMENT
-

On Upload Listener #

Triggers when a user uploads files, handling and processing them as needed.
mailui.registerProvider("library:saved", async (params, done) => { try { // Run your save library code here const library = {}; done(library); } catch (error) { done(null) console.log("An error has occurred during save data."); } } );

Params #

PropertyDescriptionTypeDefault
thumbnailUploaded BLOB file typefile-
nameLibrary specific namestring-
dataJSON dataobject-
elementTypeThe element type should be one of the following
SECTION ROW COLUMN ELEMENT
-

Library Properties #

PropertyDescriptionTypeDefault
idUnique numberany-
nameLibrary specific namestring-
thumbnailUrlThumbnail full urlstring-
elementTypeThe element type should be one of the following
SECTION ROW COLUMN ELEMENT
-

Remove Listener #

Triggers when a user remove library, handling and processing them as needed.
mailui.registerCallback("library:removed", async (params, done) => { done(); });

Params #

PropertyDescriptionTypeDefault
idUnique numberany-
nameLibrary specific namestring-
thumbnailUrlThumbnail full urlstring-
elementTypeThe element type should be one of the following
SECTION ROW COLUMN ELEMENT
-

Explore Our Email Builder