Plugin 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:
actions
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.
Type: array of Actions
Example: [Actions.showToast, Actions.closeModal]
newProps
Defines the properties that update the state of the items which interact with the users. This parameter is used only with Actions.updateProps.
Type: IInput, ICheckbox, IToggleButton, IButton, ITextArea, IComboBox
Example: {IInput}
toastProps
Defines the properties that display a toast notification after the user actions. This parameter is used only with Actions.showToast.
Type: array of IToast
Example: [IToast]
contextProps
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 administator or owner settings block that is embedded in the modal window with the plugin description.
Type: array of objects
Example:
[
{
name: "accept-button",
props: {...acceptButtonProps, isDisabled: false},
},
]
contextProps.name
The item name.
Type: string
Example: "accept-button"
contextProps.props
The new properties for the parent or child item.
Type: object
Example: {...acceptButtonProps, "isDisabled": false}
createDialogProps
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.
Type: ICreateDialog
Example: {ICreateDialog}
modalDialogProps
Defines the properties that display the modal window. This parameter is used only with Actions.showModal.
Type: IModalDialog
Example: {IModalDialog}
postMessage
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.
Type: IPostMessage
Example: {IPostMessage}
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.
Type: string
Example: "{settings}"
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,
},
],
}