Search
Loading...
Skip to content

Save and Export Buttons

This guide shows you how to add, customize, and configure save and export buttons in the CE.SDK navigation bar. You’ll learn how to use the Navigation Bar Order API to display built-in action buttons and the Actions API to implement custom save and export workflows.

Save and Export Buttons

10 mins
estimated time
Download
StackBlitz
GitHub

This guide demonstrates how to add save and export buttons to your CE.SDK editor’s navigation bar and customize their behavior with custom action handlers. Use the built-in actions to get started quickly, then override them to fully fit your workflows.

Available Save and Export Buttons#

CE.SDK provides several built-in action buttons for the navigation bar. Each button triggers an action when clicked:

Button IDActionDefault Behavior
ly.img.saveScene.navigationBarsaveSceneDownloads scene as .scene file
ly.img.exportImage.navigationBarexportDesign with PNGDownloads PNG image
ly.img.exportPDF.navigationBarexportDesign with PDFDownloads PDF document
ly.img.exportVideo.navigationBarexportDesign with MP4Downloads MP4 video
ly.img.exportScene.navigationBarexportSceneDownloads scene file
ly.img.exportArchive.navigationBarexportScene (archive)Downloads scene archive

Adding Buttons to the Navigation Bar#

Use cesdk.ui.setNavigationBarOrder() to configure the navigation bar with save and export buttons. The buttons must be wrapped in the ly.img.actions.navigationBar container:

// Add all save and export buttons to the navigation bar
cesdk.ui.insertNavigationBarOrderComponent('last', {
id: 'ly.img.actions.navigationBar',
children: [
'ly.img.saveScene.navigationBar',
'ly.img.exportImage.navigationBar',

Overriding Actions#

By default, each button triggers a built-in action. To implement custom logic like uploading to a backend, register a custom handler using cesdk.actions.register():

// Override the saveScene action with custom logic
cesdk.actions.register('saveScene', async () => {
// Replace with your backend upload logic
console.trace('saveScene action triggered');
const archive = await cesdk.engine.scene.saveToArchive();
cesdk.utils.downloadFile(archive, 'application/zip');
});

The saveScene action receives no arguments. Use cesdk.engine.scene.saveToString() to serialize the scene, or cesdk.engine.scene.saveToArchive() if you need to include referenced assets.

Overriding Export Buttons#

Instead of overriding the global exportDesign action, you can provide a custom onClick callback directly on individual buttons. This approach gives you fine-grained control over each button’s behavior:

// Override the PDF export button's onClick callback
id: 'ly.img.exportPDF.navigationBar',
onClick: async () => {
const { blobs } = await cesdk.utils.export({
mimeType: 'application/pdf'
});
cesdk.utils.downloadFile(blobs[0], 'application/pdf');
cesdk.ui.showNotification({
message: 'PDF exported successfully!',
type: 'success',
duration: 'short'
});
}

The onClick callback completely replaces the button’s default behavior. Use cesdk.ui.showNotification() to display feedback after the export completes. The notification accepts type values of 'success', 'error', 'info', 'warning', or 'loading'.

Troubleshooting#

Button Not Appearing#

  • Verify the button ID is spelled correctly
  • Ensure buttons are wrapped in the ly.img.actions.navigationBar container
  • Check that the scene mode supports the export type (video export requires Video mode)

Export Produces Empty Result#

  • Ensure a page exists in the scene
  • Check that the page has visible content
  • Verify export dimensions are valid

Save Action Not Triggered#

  • Confirm the saveScene action is registered before the button is clicked
  • Check the browser console for errors in your action handler

API Reference#

MethodPurpose
cesdk.actions.register(actionId, callback)Register a custom action handler
cesdk.actions.run(actionId, ...args)Programmatically trigger a registered action
cesdk.ui.setNavigationBarOrder(order)Set the navigation bar component order
cesdk.utils.export(options)Export with automatic loading dialog
cesdk.utils.downloadFile(blob, mimeType)Download a blob as a file
cesdk.ui.showNotification(notification)Display a notification message
cesdk.engine.scene.saveToString()Serialize scene to string

Next Steps#