Step 1: Register a Custom Link Type
Inside your unlayer.setLinkTypes() function, define a new link type for the popup close button.
unlayer.setLinkTypes([
{
name: 'custom_close',
label: 'Close popup',
attrs: {
href: '#ecdp-custom-close-button'
}
}
]);
Step 2: Set the Custom Link Type as the Default Close Action
Inside your unlayer.init() function, add the popupCloseButton_action property to define which link type should be the default for the close button.
unlayer.init({
tools: {
bodies: {
properties: {
popupCloseButton_action: {
editor: {
defaultValue: {
name: 'custom_close'
}
}
}
}
}
}
});This ensures that every new popup automatically uses your custom_close link type as its close button action.
Step 3 (Optional): Add Default Link Attributes
If you also want to include predefined attributes like a custom URL or target behavior, you can extend your default configuration as shown below:
unlayer.init({
tools: {
bodies: {
properties: {
popupCloseButton_action: {
editor: {
defaultValue: {
name: 'custom_close',
attrs: {
href: 'https://custom_website.com',
target: '_blank'
}
}
}
}
}
}
}
});This gives your close button a fully configured custom action by default, making your popup templates more consistent and reducing manual setup time.
