Verona Editor Interface Handles communication between editor and host application.

// 1. Instantiate
const editor = new VeronaEditorApiService({ debug: true });

// 2. Register handler BEFORE sendReady()
editor.onStartCommand((cmd) => {
if (cmd.unitDefinition) loadDefinition(cmd.unitDefinition, cmd.unitDefinitionType);
if (cmd.editorConfig?.role) applyRole(cmd.editorConfig.role);
if (cmd.editorConfig?.directDownloadUrl) configureDownloadUrl(cmd.editorConfig.directDownloadUrl);
});

// 3. Announce readiness
editor.sendReady({ metadata: JSON.stringify(meta) });

// 4. Send definition changes whenever the user edits the unit
editor.sendDefinitionChanged(definition, definitionType, variables, dependenciesToPlay, dependenciesToEdit);

// 5. Cleanup (e.g. in ngOnDestroy)
editor.destroy();

Constructors

Properties

messageHandlers: Map<string, Set<Function>> = ...
sessionId: null | string = null
debug: boolean
allowedOrigin: string
targetWindow: Window
messageListener: ((event: MessageEvent<any>) => void)

Accessors

Methods

  • Send voeReadyNotification to the host. Call this after registering onStartCommand, as the host will respond with a voeStartCommand immediately upon receiving this notification.

    Parameters

    Returns void

  • Send voeDefinitionChangedNotification to the host whenever the user edits the unit.

    The full, updated definition is always sent — not a diff. The host stores it for later use by a player. The variables list must always be current and is sent alongside the definition so the schemer can prepare the coding scheme.

    dependenciesToPlay and dependenciesToEdit should list all external files or services required at runtime. The host can warn if a dependency is unavailable.

    Requires an active session (i.e. onStartCommand must have fired first).

    Parameters

    • OptionalunitDefinition: string

      The complete, updated unit definition serialised as a string

    • OptionalunitDefinitionType: string

      Optional format/version identifier for the definition

    • Optionalvariables: MainSchema.VariableInfo[]

      Current list of all variables in the unit

    • OptionaldependenciesToPlay: MainSchema.Dependency[]

      Optional dependencies needed during playback (e.g. GeoGebra)

    • OptionaldependenciesToEdit: MainSchema.Dependency[]

      Optional dependencies needed during editing (e.g. GeoGebra)

    • OptionalsharedParameters: MainSchema.SharedParameter[]

      Optional shared parameters for cross-module data exchange

    Returns void

  • Register a handler for voeStartCommand.

    The StartCommand is mandatory for the Editor – it carries the unit definition and configuration the editor needs to initialise its UI. Per spec, messages without a sessionId are silently discarded. The session ID is stored automatically before your callback is called.

    Register this handler before calling sendReady().

    Typical usage in the callback:

    • Load unitDefinition into the editor UI (if provided)
    • Apply editorConfig.role to restrict/expand available features
    • Set editorConfig.directDownloadUrl for lazy-loaded resources (e.g. GeoGebra)
    • Apply editorConfig.sharedParameters for cross-module coordination

    Parameters

    Returns void