Add UI button registration API (registerButton, unregisterButton, getButtonsForLocation)
This commit is contained in:
44
dist/PluginInterfaces.d.ts
vendored
44
dist/PluginInterfaces.d.ts
vendored
@@ -139,6 +139,8 @@ export interface PluginContext {
|
||||
ui: {
|
||||
registerRenderer: (type: string, renderer: CustomRenderer) => void;
|
||||
unregisterRenderer: (type: string) => void;
|
||||
registerButton: (button: UIButtonDefinition) => void;
|
||||
unregisterButton: (buttonId: string) => void;
|
||||
};
|
||||
/** Settings API */
|
||||
settings: {
|
||||
@@ -188,7 +190,47 @@ export interface PluginSettingsSection {
|
||||
component: unknown;
|
||||
}
|
||||
/** UI locations where plugins can inject content. */
|
||||
export type UILocation = 'room-header' | 'message-actions' | 'user-menu' | 'room-menu' | 'composer-actions';
|
||||
export type UILocation = 'room-header' | 'message-actions' | 'user-menu' | 'room-menu' | 'composer-actions' | 'channel-list' | 'direct-messages' | 'home-section' | 'search-notification-section' | 'text-composer-toolbar' | 'sidebar-actions';
|
||||
/**
|
||||
* Button positioning configuration for plugins.
|
||||
* Allows buttons to be placed before or after existing elements or groups.
|
||||
*/
|
||||
export interface UIButtonPosition {
|
||||
/** Place button before this element/group ID */
|
||||
before?: string;
|
||||
/** Place button after this element/group ID */
|
||||
after?: string;
|
||||
/**
|
||||
* Optional group ID this button belongs to.
|
||||
* Buttons in the same group are rendered together.
|
||||
*/
|
||||
group?: string;
|
||||
/** Order within the group (lower numbers appear first) */
|
||||
order?: number;
|
||||
}
|
||||
/**
|
||||
* Definition for a UI button registered by a plugin.
|
||||
* Framework-agnostic - the component/element is passed as unknown.
|
||||
*/
|
||||
export interface UIButtonDefinition {
|
||||
/** Unique ID for this button */
|
||||
id: string;
|
||||
/** Location where the button should appear */
|
||||
location: UILocation;
|
||||
/** Button label or tooltip */
|
||||
label: string;
|
||||
/** Optional icon identifier */
|
||||
icon?: string;
|
||||
/** Positioning configuration */
|
||||
position?: UIButtonPosition;
|
||||
/**
|
||||
* The actual button component or render function.
|
||||
* Framework-agnostic - hosts using React should cast to ReactNode.
|
||||
*/
|
||||
component: unknown;
|
||||
/** Optional callback when clicked (if component doesn't handle it) */
|
||||
onClick?: () => void | Promise<void>;
|
||||
}
|
||||
/**
|
||||
* The main plugin interface that all plugins must implement.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user