Message
Each item which interacts with a user (onClick, onChange, onSelect, etc.) can return a message that is represented as the IMessage object with the following parameters:
| Name | Type | Example | Description |
|---|---|---|---|
| actions | array of Actions | [Actions.showToast, Actions.closeModal] | Defines a collection of events that will be processed on the portal side. The specified actions will be performed depending on the set of values. |
| newProps | IInput, ICheckbox, IToggleButton, IButton, ITextArea, IComboBox | {IInput} | Defines the properties that update the state of the items which interact with the users. This parameter is used only with Actions.updateProps. |
| toastProps | array of IToast | [IToast] | Defines the properties that display a toast notification after the user actions. This parameter is used only with Actions.showToast. |
| contextProps | array of objects | [{ "name": "accept-button", "props": {...acceptButtonProps, isDisabled: false}, }] | Defines the properties that update the state of the parent or child item after the event was executed. This parameter is used only with Actions.updateContext and works in the administrator or owner settings block that is embedded in the modal window with the plugin description. |
| contextProps.name | string | "accept-button" | The item name. |
| contextProps.props | object | {...acceptButtonProps, "isDisabled": false} | The new properties for the parent or child item. |
| createDialogProps | ICreateDialog | {ICreateDialog} | Defines the properties that display the default dialog box for creating a file/folder managed by the plugin. This parameter is used only with Actions.showCreateDialogModal and Actions.updateCreateDialogModal. |
| modalDialogProps | IModalDialog | {IModalDialog} | Defines the properties that display the modal window. This parameter is used only with Actions.showModal. |
| postMessage | IPostMessage | {IPostMessage} | Defines the properties that are used to send a message to a frame. If the frame ID is not specified or the frame with such an ID does not exist, then nothing changes. This parameter is used only with Actions.sendPostMessage. |
| settings | string | {settings} | Defines a parameter that is used to save and transfer the administrator or owner plugin settings to all the portal users. This parameter is used only with Actions.saveSettings. |
Example
import {Actions, type IMessage, ToastType} from "@onlyoffice/docspace-plugin-sdk"
const message: IMessage = {
actions: [Actions.showToast, Actions.closeModal],
toastProps: [
{
type: ToastType.success,
title: toastTitle,
},
],
}