跳到主要内容

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:

NameTypeExampleDescription
actionsarray 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.
newPropsIInput, 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.
toastPropsarray of IToast[IToast]Defines the properties that display a toast notification after the user actions. This parameter is used only with Actions.showToast.
contextPropsarray 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.namestring"accept-button"The item name.
contextProps.propsobject{...acceptButtonProps, "isDisabled": false}The new properties for the parent or child item.
createDialogPropsICreateDialog{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.
modalDialogPropsIModalDialog{IModalDialog}Defines the properties that display the modal window. This parameter is used only with Actions.showModal.
postMessageIPostMessage{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.
settingsstring{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,
},
],
}