Interface to register, listen and broadcast events within the editor.

Hierarchy

  • Events

Methods

  • Broadcast a custom event. This will trigger all listeners for this event. To avoid collissions, the event name should follow a reasonable naming convention.

    Optioanlly you can use broadcast to send

    Type Parameters

    • T

    Parameters

    • event: string

      The event to broadcast.

    • Optional value: T

      The value to send. Note this will be serialized and deserialized.

    • Optional targetEditorParent: boolean

      Flag to indicate if the event should be sent to the parent editor. This is only applicable in an iFrame context. Default value is false.

    Returns void

  • Scripts can listen to arbitriary events from the same or other scripts. To avoid collissions, the event name should follow a reasonable naming convention.

    Type Parameters

    • T

    Parameters

    • event: string

      The event to listen for.

    • callback: ((eventName, data) => void)

      The callback is triggered when the event is being received. The callback will receive the event name and the data passed to the event.

        • (eventName, data): void
        • Parameters

          • eventName: string
          • data: T

          Returns void

    Returns string

    A unique identifier for this listener.

  • Register for an internal editor or field event. Events can be registered multiple times, by the same or separate scripts.

    Some events can be cancelled, which means the default operation triggering the event will not be performed. Events can also be stopped from propagating to other scripts, which means that other scripts will not receive the event. For both actions, use the event object passed to the callback function.

    The data provided depends on the event type. See the EditorEventType and FieldEventType for more information. The field events will also pass the relevant fields in a separate parameter.

    Parameters

    Returns string

    A unique identifier for the event registration.

  • Register for custom actions. Custom actions are used to add custom functionality to the editor for standard behaviour. This allows a script to adjust the functionality. Depending on the type of custom action, the user may even have a choice in case multiple implementations are registered.

    Parameters

    • type: AutoFill

      The type of custom action this applies to.

    • name: string

      The name of the custom action. This is used to identify the custom action in the UI.

    • desc: string

      The description of the custom action. This is used to describe the custom action in the UI.

    • callback: (() => void)

      The callback function to call when the custom action is triggered.

        • (): void
        • Returns void

    Returns void

  • Registers a custom field and makes it usable in this editor session. Custom fields which are part of the job but the type has not been registered cannot work as expected.

    Parameters

    • definition: CustomFieldDefinition

      The custom field definition.

    • callback: ((success) => void)

      The callback function to call when the custom field is fully registered with a success flag

        • (success): void
        • Parameters

          • success: boolean

          Returns void

    Returns void

  • This function will ensure that the the custom field is fully functional. With asyncronous loading of scripts and depending on the actions of those scripts it could take some time until the custom field is fully registered and available. This method can be used to ensure that the setup of that field has finished and is available for use.

    It will wait a maximum of 2 seconds for the field to be registered. If it is not registered by then, the callback will be called immediately.

    Parameters

    • fieldOrType: string | CustomField

      The field we want to ensure the custom field definition is registered for. Either as the field directly or the sub type as string.

    • callback: ((fieldRegisteredAndAvailable) => void)

      The callback will be triggered as soon as the field is available and fully registered with the value true. Otherwise, if the field is not found after 2 seconds, the callback will be triggered immediately with false. The field should not be used in that case.

        • (fieldRegisteredAndAvailable): void
        • Parameters

          • fieldRegisteredAndAvailable: true

          Returns void

    Returns void

  • Scripts can unregister a listener for custom events by passing the identifier returned by the Listen method.

    Parameters

    • id: string

      The listener to unregister.

    Returns boolean

    True if the listener has been unregistered, false if the listener was not registered in the first place.

  • Scripts can unregister for events by passing the identifier returned by the Register method. This would mean that the script will no longer receive the event.

    Parameters

    • id: string

      The unique identifier for the event registration.

    Returns boolean

    True if the event has been unregistered, false if the event was not registered in the first place.

Generated using TypeDoc