Recent searches

in

How the Visual Editor API works

Learn what the Visual Editor API is, how it connects to your Site, and the building blocks it provides.

On this page

CloudCannon's Visual Editor API is a JavaScript API that lets you read and write content, listen for changes, and build custom integrations in the Visual Editor — all from code running inside your website files.

How does the Visual Editor API work?#

A screenshot of the Visual Editor shows a webpage preview with a Data Panel of inputs open over it.

When you open a page in the Visual Editor, CloudCannon loads your site inside a sandboxed iframe. The Visual Editor API bridges communication between your website's JavaScript and the Visual Editor that surrounds it.

CloudCannon exposes an API router on window.CloudCannonAPI. You request the version you want with useVersion(), and the router returns an API Object you can use to interact with the Visual Editor.

What can you do with the API?#

The API Object gives you a set of building blocks. The Doodle Gallery only uses a few of them, but it's worth knowing the whole toolbox so you can recognize what's possible:

  • Access files — every file in your Site is exposed as an object you open from your code, whether it's the page currently open in the Visual Editor or any other file.
  • Read and write data — read and update the front matter of a content file, the contents of a data file, the body content, or the raw file source.
  • Work with Collections and Datasets — list and react to many files at once across a Collection or Dataset.
  • Listen for changes — subscribe to change events so your integration stays in sync as content updates.
  • Build editing interfaces — render your own UI, open CloudCannon's own Data Panels, or make elements on the page directly editable.
  • Upload files and manage loading — upload new files into your Site and control the Visual Editor's loading state while your integration works.

CloudCannon's Editable Regions are built on the same Visual Editor API that you have access to. For example, *.createTextEditableRegion() uses the same underlying mechanism as the data-editable attribute — it makes any HTML element inline-editable and connects it to the Visual Editor's content model.

The Doodle Gallery is a deliberately small slice of the toolbox. In this guide, we'll cover how to detect the Visual Editor, access a data file, upload an image, and add a new item to a list.

It leaves the rest of the toolbox untouched, and uses only part of two more — and those are where other kinds of integrations come from:

  • Work with Collections and Datasets — build a content dashboard that flags which files in a Collection are still in draft or missing a hero image.
  • Listen for changes — show a live SEO or word-count preview that updates as a Team Member types.
  • Build editing interfaces — the Doodle Gallery renders its own UI, but you could instead open CloudCannon's own Data Panel for a field, or make a heading on the page editable inline.
  • Upload files and manage loading — the Doodle Gallery uploads images, but you could also show the Visual Editor's loading overlay while your integration fetches data from an external service.

In the next step of this guide, we'll detect the Visual Editor and initialize the API in code.

Build custom Visual Editor integrations (2/7)
How the Visual Editor API works
Open in a new tab