Every component API must implement this interface, which is usually done by inheriting from ComponentApiBase.

This interface exists because APIs can be distributed by an interface alone (that inherits from this one), where the inplementation can live in another web context and is thus unknown.

interface IEditorApi {
    _apiId: "mendix.EditorApi";
    addEventListener<K>(eventType: K, listener: EventHandler<EditorApiEventMap, K>): DisposeListener;
    editDocument(documentId: string): Promise<void>;
    getActiveDocument(): Promise<null | ActiveDocumentInfo>;
    removeEventListener<K>(eventType: K, listener: EventHandler<EditorApiEventMap, K>): void;
}

Hierarchy (view full)

Properties

_apiId

Unique identifier that can be used to register or retrieve a specific API.

Example: mendix.EditorsAPI, mycompany.MyFunkyAPI

Methods

  • Adds an event listener for the specified event type.

    Type Parameters

    • K extends "activeDocumentChanged"

    Parameters

    • eventType: K

      The type of event to listen for.

    • listener: EventHandler<EditorApiEventMap, K>

      The event listener to add.

    Returns DisposeListener

    A function that can be called to remove the event listener.

  • Opens the editor for the document with the given ID in the working area of Studio Pro.

    Parameters

    • documentId: string

      the ID of the document that should be edited.

    Returns Promise<void>

  • Gets the ID of the document the user is currently editing, or null if no document is currently opened.

    Returns Promise<null | ActiveDocumentInfo>

  • Removes an event listener for the specified event type.

    Type Parameters

    • K extends "activeDocumentChanged"

    Parameters

    • eventType: K

      The type of event to remove the listener from.

    • listener: EventHandler<EditorApiEventMap, K>

      The event listener to remove.

    Returns void