Fixing Export Issues with Custom Tools in Unlayer
If your custom tool isn’t appearing correctly during the export process (e.g., when using exportHtml, exportPdf, etc.), it’s often due to missing exporters or inaccessible scripts.
Common Causes
The custom tool’s JavaScript file isn’t publicly accessible during the export process.
The tool registration doesn’t define the required exporters for the relevant display modes.
How to Fix It
1. Host Custom Tool Files Publicly
Ensure your custom tool’s script is hosted at a public URL, such as:
AWS S3
GitHub Pages
Any public CDN
Then include the hosted script using the customJS parameter both when initializing the editor and when calling the export APIs:
unlayer.init({
// other settings...
customJS: "https://yourdomain.com/custom-tool.js",
});
2. Define Exporters in registerTool
Your custom tool must define exporters for every displayMode you plan to support — for example, email, web, popup, or document.
