Recent searches

in

Manage loading, uploads, and previews with the Visual Editor API

Last modified: August 11th, 2026

On this page

The Visual Editor API is designed for experienced CloudCannon developers. If you need help with custom integrations or your CloudCannon setup in general, please contact our friendly support team.

CloudCannon's Visual Editor API exposes methods for managing your integration's loading state, uploading files, and getting preview URLs. This article covers how to use each of these in your custom integration.

This article assumes you know how to initialize the Visual Editor API. For custom inline editing, read Create custom inline editing with the Visual Editor API. For a complete list of API objects and methods, please read our reference documentation on the Visual Editor API.

Control the loading state#

Calling *.setLoading() allows you to show or hide the Visual Editor's loading indicator. This is useful when your custom integration needs time to initialize.

JavaScript
Copied to clipboard
const api = window.CloudCannonAPI.useVersion('v1', true);
await api.setLoading('Initializing custom integration...'); 

// Do async setup work

await api.setLoading(undefined); 

Pass a string to api.setLoading() to show the loading indicator with a message.

Pass undefined to clear the loading indicator when your integration is ready.

Upload a file#

Calling *.uploadFile() allows you to upload a file through CloudCannon's file handling system.

JavaScript
Copied to clipboard
const input = document.querySelector('input[type="file"]'); 
const file = input.files[0]; 

const path = await api.uploadFile(file, undefined); 
console.log('Uploaded to:', path);

Get the file input element from the DOM.

Get the selected file from the input.

Call api.uploadFile() to upload the file. Pass undefined as the second argument to use default upload behavior, or pass an Input configuration object (the same shape as an Input in your CloudCannon Configuration File) to control where the file is uploaded and which asset sources or DAMs are offered.

Get a preview URL#

Calling *.getPreviewUrl() allows you to get a working URL for a file that may not yet be committed to your Site, such as an image uploaded in the current editing session. Use this instead of the source path directly when displaying images in the Visual Editor.

JavaScript
Copied to clipboard
const previewUrl = await api.getPreviewUrl('/images/hero.jpg'); 

Pass a source path to api.getPreviewUrl() to get a URL that works within the Visual Editor, including for files that haven't yet been committed to the Site.

Related Resources

Open in a new tab