跳到主要内容

ISettingsPlugin

View source on GitHub

The plugin that manages settings for the administrator or owner. The plugin that can interact with the settings panel.

settings-blocksettings-block

Example

The plugin class implements ISettingsPlugin: adminPluginSettings describes the settings block (a webhook URL input and a save button) shown in the modal window with the plugin description. DocSpace calls getAdminPluginSettings to render the block and setAdminPluginSettingsValue to pass the saved value back to the plugin.

import {
type IInput,
type ISettings,
type ISettingsPlugin,
Components,
InputSize,
ButtonSize,
Actions,
ToastType,
} from "@onlyoffice/docspace-plugin-sdk";

class Plugin implements ISettingsPlugin {
webhookUrlInput: IInput = {
value: "",
placeholder: "https://example.com/webhook",
size: InputSize.base,
scale: true,
onChange: (value) => {
this.webhookUrlInput.value = value;
return {
actions: [Actions.updateProps],
newProps: { ...this.webhookUrlInput, value }
};
}
};

adminPluginSettings: ISettings | null = {
settings: {
children: [
{
component: Components.label,
props: { text: "Webhook URL", isRequired: true }
},
{
component: Components.input,
props: this.webhookUrlInput
}
]
},
saveButton: {
component: Components.button,
props: {
label: "Save",
size: ButtonSize.normal,
primary: true,
onClick: () => ({
actions: [Actions.saveSettings, Actions.showToast],
settings: JSON.stringify({ webhookUrl: this.webhookUrlInput.value }),
toastProps: [{ type: ToastType.success, title: "Settings saved" }]
})
}
}
};

setAdminPluginSettings = (settings: ISettings | null): void => {
this.adminPluginSettings = settings;
};

setAdminPluginSettingsValue = (settings: string | null): void => {
if (!settings) return;
const { webhookUrl } = JSON.parse(settings);
this.webhookUrlInput.value = webhookUrl;
};

getAdminPluginSettings = (): ISettings | null => {
return this.adminPluginSettings;
};
}

Methods

setAdminPluginSettings()

setAdminPluginSettings(settings: ISettings | null): void;

Update the administrator or owner plugin settings

Parameters

ParameterType
settingsISettings | null

Returns

void

setAdminPluginSettingsValue()

setAdminPluginSettingsValue(settings: string | null): void;

Transfer the administrator or owner plugin settings to all the portal users. It functions on the DocSpace side

Parameters

ParameterType
settingsstring | null

Returns

void

getAdminPluginSettings()

getAdminPluginSettings(): ISettings | null;

Get the administrator or owner plugin settings

Returns

ISettings | null

Properties

PropertyTypeDescription
adminPluginSettingsISettings | nullThe administrator or owner settings block that is embedded in the modal window with the plugin description