Skip to main content
The Composition Editor lets a customer change the texts, pictures, colours and fonts of a widget they own, beside a live preview, and save it (see it in the gallery). It is the editor of Widgetic’s own site, drawn in your page. Like every piece, it is mounted with the UI SDK and uses an editor session for one of your managed users, made with the surfaces ["editor", "files"]. Installing the SDK, tokens, the theme, the language and the Content Security Policy are the same for every piece, and are on the UI Components page. This page covers what is specific to the Composition Editor.

Mount it

Create the composition on your server with your key and file it under the customer (see Filing Content Under a Managed User). A session opens only compositions filed under its customer. Then mount the editor on it:
One Composition Editor per page. A second one is refused with a clear message. Unmount the first before you mount another.

Options

Events

Saving

  • The editor saves by itself shortly after the last change. editor.module.save() saves what is unsaved now, editor.module.flush() saves everything unsaved and waits until it is (both resolve true when nothing is left unsaved), and editor.module.isDirty() tells whether anything is unsaved. A save is safe to retry: it carries an Idempotency-Key.
  • unmount() saves first, for up to 10 seconds, so closing the editor never loses the last edits. If some could not be saved you hear an error with the code UNSAVED_ON_UNMOUNT. editor.module.unmount({ discard: true }) throws unsaved edits away instead.

When something goes wrong

  • Problems are shown to the customer by the editor itself, with “Try again” where that helps. error is for your page, and adds during, status, retryable, sessionEnded and correlationId to the usual fields. fatal: true means the editor cannot go on: the composition cannot be opened, or the session is over (sessionEnded: true). Make a new session or take the editor away. Quote correlationId to Widgetic’s support.
  • Another customer’s composition is answered with 404, and the editor says it cannot be opened.

Next Steps

Editor Sessions

Make the token on your server

UI Components

The SDK, tokens, the look and the language of every piece

Managed Users

File your customers’ compositions under them

Compositions

Make a composition with your key