Plugins Manager
It exposes a set of function to manage DIVA compliant plugins. There are two kind of plugins:
- Menu Panel Plugins: shown on the right side panels over DIVA.
- Floating Panel Plugins: -- not yet implemented on responsive web --
Plugins manager is available for RW only.
Here the interfaces of the Plugins manager:
// Plugins API
export interface DivaPluginsManagerAPI {
registerPlugin: (plugin: DivaPluginMenuPanelProps | DivaPluginFloatingPanelProps) => string;
removePlugin: (id: string) => void;
activatePlugin: (id: string) => void;
enablePlugin: (id: string) => void;
disablePlugin: (id: string) => void;
setPluginMenuButtonIcons: (
id: string,
icons: {
iconDefault: string;
iconDefaultInteracting: string;
iconActive: string;
iconActiveInteracting: string;
}
) => void;
getPluginState: (id: string) => DivaPluginState;
}
// Plugin props
export interface DivaUIPluginProps {
id: string;
type: DivaPluginType;
analyticsId: string;
onPluginPresented?: () => void;
onPluginDismissed?: () => void;
onPluginStateChanged?: (pluginState: DivaPluginState) => void;
onContainerChange?: (containerInfo: {
left: string;
top: string;
width: string;
height: string;
zIndex: string;
}) => void;
onPluginError?: (pluginError: PluginManagerError) => void;
iconDefault?: string;
iconDefaultInteracting?: string;
iconActive?: string;
iconActiveInteracting?: string;
}
// Other interfaces
export interface DivaPluginMenuPanelProps extends DivaUIPluginProps {
type: DivaPluginType.MenuPanel;
title: string;
}
export interface DivaPluginFloatingPanelProps extends DivaUIPluginProps {
type: DivaPluginType.FloatingPanel;
position: string;
}
export enum DivaPluginType {
MenuPanel = 'menupanel',
FloatingPanel = 'floatingpanel',
}
export type DivaPluginState = 'disabled' | 'ready' | 'active';
export const DivaPluginState = {
Disabled: 'disabled' as DivaPluginState,
Ready: 'ready' as DivaPluginState,
Active: 'active' as DivaPluginState,
};
export type PluginManagerError =
| 'The specified plugin id is already registered in the Plugin Manager'
| 'The specified plugin id is not registered in the Plugin Manager'
| 'The specified plugin structure is not valid';
export const PluginManagerError = {
Duplicate: 'The specified plugin id is already registered in the Plugin Manager' as PluginManagerError,
NotFound: 'The specified plugin id is not registered in the Plugin Manager' as PluginManagerError,
Invalid: 'The specified plugin structure is not valid' as PluginManagerError,
};
Register​
registerPlugin(plugin: DivaPluginMenuPanelProps | DivaPluginFloatingPanelProps): string
It accepts a menuPanel or floatingPanel plugin setting and returns the id of the just registered plugin.
Remove​
removePlugin(id: string): void
It removes plugin by id.
Activate​
activatePlugin(id: string): void
It sets the state of the plugin to active, so in case of menu panel plugin the corresponding panel will be open
Enable​
enablePlugin(id: string): void
It sets the state of the plugin to ready, so in case of menu panel plugin the corresponding panel button will appear and the panel will be closed.
Disable​
disablePlugin(id: string): void
It sets the state of the plugin to disabled, so in case of menu panel plugin the corresponding panel button will disappear and the menu panel will close if previously open
Set icon​
setPluginMenuButtonIcons(id: string, icons: { iconDefault: string; iconDefaultInteracting: string; iconActive: string; iconActiveInteracting: string }): void
It sets sets the icon (as string of html code) for a spacific plugin for all it states.
Get state​
getPluginState(id: string): DivaPluginState
It returns the state of a plugin.