CustomActionManagement

action.CustomActionManagement

Table of contents

Constructors

Methods

Constructors

constructor

new CustomActionManagement()

Methods

register

register(customAction): Promise<CustomAction>

Experimental feature Experimental

You use this method to register a custom action with an app.
The method takes a single argument: an object that defines the custom action.

You need to register custom actions in the headless iframe of your app so that the actions are available as long as the app is running on the board.
For Miro apps, this is usually the index.js/.ts file.
If you register a custom action in the panel or the modal iframe, the operation throws an error.

Custom actions registration requires two steps:

  1. Subscribe to the event dispatched by the custom action using miro.board.ui.on method
  2. Register custom action with it's definition. Apps cannot register custom actions that don't have subscription.
await miro.board.ui.on('custom:translate-content', handler);
await miro.board.experimental.action.register(
  {
    "event": "translate-content",
    "ui": {
      "label":
        "en": "Translate content",
      "icon": "chat-two",
      "description": "Translate the content of the board items included in the current selection.",
    },
    "scope": "local",
    "predicate": {
      "type": "text"
    },
    "contexts": {
        "item": {}
    }
  }
);

You can learn more about custom action on our tutorial.

Parameters

NameType
customActionCustomAction

Returns

Promise<CustomAction>


deregister

deregister(eventName): Promise<void>

Experimental feature Experimental

Use this method to deregister a custom action that was previously registered by an app.

The method takes one argument:

  • The name of the event used when registering the custom action.
await miro.board.ui.on('custom:translate-content', handler);
await miro.board.experimental.action.register(
  {
    "event": "translate-content",
    "ui": {
      "label":
        "en": "Translate content",
      "icon": "chat-two",
      "description": "Translate the content of the board items included in the current selection.",
    },
    "scope": "local",
    "predicate": {
      "type": "text"
    },
    "contexts": {
        "item": {}
    }
  }
);

await miro.board.experimental.action.deregister("translate-content")

Parameters

NameType
eventNamestring

Returns

Promise<void>