Custom Blocks

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

Fetch Block 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( "block: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-
nameBlock 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("block:collectionData", async (params, done) => { const data = {}; // template JSON done(data); } );

Params #

PropertyDescriptionTypeDefault
idUnique numberany-
nameBlock 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("block:saved", async (params, done) => { try { // Run your save block code here const block = {}; done(block); } catch (error) { done(null) console.log("An error has occurred during save data."); } } );

Params #

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

Block Properties #

PropertyDescriptionTypeDefault
idUnique numberany-
nameBlock 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 block, handling and processing them as needed.
mailui.registerCallback("block:removed", async (params, done) => { done(); });

Params #

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

Explore Our Email Builder