跳到主要内容

Utils

Utility types for plugin messaging, return values, and panel navigation.

IPostMessage

View source on GitHub

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.

Example

Document preview frame communication

const previewMessage: IPostMessage = {
frameId: "document-preview-frame",
message: {
action: "zoom",
scale: 1.5,
position: { x: 100, y: 200 }
}
};

Properties

PropertyTypeDescription
frameIdstringDefines the frame ID
message{ [key: string]: any; }Defines a message that will be sent to a frame

IMessage

View source on GitHub

A message which is returned when any item interacts with a user (onClick, onChange, onSelect, etc.).

Examples

Form submission with validation and toast notification

const formSubmissionMessage: IMessage = {
actions: [Actions.updateProps, Actions.showToast, Actions.updateContext],
newProps: {
type: "input",
id: "email-input",
value: "user@example.com",
isDisabled: true
},
toastProps: [{
type: ToastType.success,
title: "Your data has been saved successfully"
}],
contextProps: [{
name: "submit-button",
props: {
type: "button",
label: "Submitted",
isDisabled: true
}
}]
};

Dynamic form field updates with error handling

const fieldUpdateMessage: IMessage = {
actions: [Actions.updateProps, Actions.showToast, Actions.updateContext],
newProps: {
type: "comboBox",
id: "country-select",
options: [
{ value: "us", label: "United States" },
{ value: "uk", label: "United Kingdom" }
],
value: "us"
},
toastProps: [{
type: ToastType.error,
title: "Please complete all required fields"
}],
contextProps: [{
name: "state-select",
props: {
type: "comboBox",
options: [
{ value: "ca", label: "California" },
{ value: "ny", label: "New York" }
],
isDisabled: false
}
}]
};

Properties

PropertyTypeDescription
actions?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.
newProps?| IComboBox | IButton | ICheckbox | IInput | ITextArea | IToggleButtonDefines the properties that update the state of the items which interact with the users. This parameter is used only with Actions.updateProps.
toastProps?IToast[]Defines the properties that display a toast notification after the user actions. This parameter is used only with Actions.showToast.
contextProps?{ name: string; props: | IComboBox | IButton | ICheckbox | IFrame | IImage | IInput | ILabel | ISkeleton | IText | ITextArea | IToggleButton | IBox; }[]Defines the properties that update the state of the parent or child item after the event was executed. Contains an array of objects with: - name: Defines the item name - props: Defines the new properties for the parent or child item
createDialogProps?ICreateDialogDefines 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.
modalDialogProps?IModalDialogDefines the properties that display the modal window. This parameter is used only with Actions.showModal.
selectorProps?TSelectorDefines the properties that display the selector. This parameter is used only with Actions.showSelector and Actions.updateSelector.
floatingOperationsButtonProps?IFloatingOperationsButtonDefines the configuration for the floating operations button that displays progress of long-running operations. Used with Actions.addFloatingOperationsButton to create a new button or Actions.updateFloatingOperationsButton to update existing one. The button appears as a floating action button in the bottom-right corner. Multiple plugins can show operations simultaneously.
floatingOperationsButtonPropsId?stringUnique identifier for the floating operations button to remove. Used only with Actions.removeFloatingOperationsButton to close a specific operations panel. The ID should match the id property of the IFloatingOperationsButton that was previously added.
postMessage?IPostMessageDefines 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?stringDefines 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.
navigatePath?stringDefines the path to navigate to. All actions listed after navigate will be called after the navigation is complete. This parameter is used only with Actions.navigate.
infoPanelTab?stringDefines the info panel tab to open. This parameter is used only with Actions.openInfoPanel.
mediaViewerProps?IMediaViewerDefines the properties for the media viewer. This parameter is used only with Actions.showMediaViewer and Actions.updateMediaViewer.

IPostMessageCallbackMessage

View source on GitHub

A message which is returned from the postMessage callback. It is similar to IMessage but with a reduced set of available actions.

Example

Handling a postMessage callback with a toast notification

const postMessageResponse: IPostMessageCallbackMessage = {
actions: [Actions.showToast],
toastProps: [{
type: ToastType.success,
title: "Frame message processed successfully"
}]
};

Properties

PropertyTypeDescription
actions?( | updateContextMenuItems | updateInfoPanelItems | updateMainButtonItems | updateProfileMenuItems | updateFileItems | updateEventListenerItems | showToast | showCreateDialogModal | showModal | closeModal | showSelector | addFloatingOperationsButton | removeFloatingOperationsButton | navigate | openInfoPanel | showMediaViewer | closeMediaViewer)[]Defines a collection of events that will be processed on the portal side. Only the following actions are available: updateContextMenuItems, updateInfoPanelItems, updateMainButtonItems, updateProfileMenuItems, updateFileItems, updateEventListenerItems, showToast, showCreateDialogModal, showModal, closeModal, showSelector, showMediaViewer, closeMediaViewer, addFloatingOperationsButton, removeFloatingOperationsButton, navigate, openInfoPanel.
toastProps?IToast[]Defines the properties that display a toast notification after the user actions. This parameter is used only with Actions.showToast.
createDialogProps?ICreateDialogDefines 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.
modalDialogProps?IModalDialogDefines the properties that display the modal window. This parameter is used only with Actions.showModal.
selectorProps?TSelectorDefines the properties that display the selector. This parameter is used only with Actions.showSelector.
floatingOperationsButtonProps?IFloatingOperationsButtonDefines the configuration for the floating operations button that displays progress of long-running operations. Used with Actions.addFloatingOperationsButton to create a new button.
floatingOperationsButtonPropsId?stringUnique identifier for the floating operations button to remove. Used with Actions.removeFloatingOperationsButton to close a specific operations panel. The ID should match the id property of the IFloatingOperationsButton that was previously added.
navigatePath?stringDefines the path to navigate to. All actions listed after navigate will be called after the navigation is complete. This parameter is used only with Actions.navigate.
infoPanelTab?stringDefines the info panel tab to open. This parameter is used only with Actions.openInfoPanel.

TInfoPanelTab

type TInfoPanelTab = "info_members" | "info_history" | "info_details" | "info_share" | string;

View source on GitHub

Defines the info panel tab to open.


TReturnPostMessage

type TReturnPostMessage =
| Promise<IPostMessageCallbackMessage>
| Promise<void>
| void
| IPostMessageCallbackMessage;

View source on GitHub

Describes a return message of a postMessage event handler.


TReturnMessage

type TReturnMessage =
| Promise<IMessage>
| Promise<void>
| void
| IMessage;

View source on GitHub

Describes a return message.