|
| 1 | +/** |
| 2 | + * The main app instance that you'll use to register tabs and access functionality |
| 3 | + */ |
| 4 | +export interface AppInstance { |
| 5 | + /** Use this to register new sidebar tabs */ |
| 6 | + extensionManager: ExtensionManager; |
| 7 | + /** Access the current workflow graph */ |
| 8 | + graph: Graph; |
| 9 | + /** Access the API for events and other functionality */ |
| 10 | + api: API; |
| 11 | +} |
| 12 | + |
| 13 | +/** |
| 14 | + * Configuration for a sidebar tab - use this with app.extensionManager.registerSidebarTab() |
| 15 | + */ |
| 16 | +export interface SidebarTabConfig { |
| 17 | + /** Unique identifier for the tab */ |
| 18 | + id: string; |
| 19 | + /** Icon class for the tab button (e.g., 'pi pi-compass', 'mdi mdi-robot', 'fa-solid fa-star') */ |
| 20 | + icon: string; |
| 21 | + /** Title text for the tab */ |
| 22 | + title: string; |
| 23 | + /** Optional tooltip text shown on hover */ |
| 24 | + tooltip?: string; |
| 25 | + /** Tab type (usually "custom") */ |
| 26 | + type: string; |
| 27 | + /** Function that populates the tab content. Can return a cleanup function. */ |
| 28 | + render: (element: HTMLElement) => void | (() => void); |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * Example usage: |
| 33 | + * |
| 34 | + * ```typescript |
| 35 | + * // Basic tab registration |
| 36 | + * app.extensionManager.registerSidebarTab({ |
| 37 | + * id: "customSidebar", |
| 38 | + * icon: "pi pi-compass", |
| 39 | + * title: "Custom Tab", |
| 40 | + * tooltip: "My Custom Sidebar Tab", |
| 41 | + * type: "custom", |
| 42 | + * render: (el) => { |
| 43 | + * el.innerHTML = '<div>This is my custom sidebar content</div>'; |
| 44 | + * } |
| 45 | + * }); |
| 46 | + * |
| 47 | + * // React component example |
| 48 | + * app.extensionManager.registerSidebarTab({ |
| 49 | + * id: "reactSidebar", |
| 50 | + * icon: "mdi mdi-react", |
| 51 | + * title: "React Tab", |
| 52 | + * type: "custom", |
| 53 | + * render: (el) => { |
| 54 | + * const container = document.createElement("div"); |
| 55 | + * el.appendChild(container); |
| 56 | + * ReactDOM.createRoot(container).render(<YourComponent />); |
| 57 | + * } |
| 58 | + * }); |
| 59 | + * ``` |
| 60 | + */ |
| 61 | + |
| 62 | +// Additional interfaces for internal use |
| 63 | +export interface ExtensionManager { |
| 64 | + registerSidebarTab(config: SidebarTabConfig): void; |
| 65 | +} |
| 66 | + |
| 67 | +export interface Graph { |
| 68 | + _nodes: any[]; |
| 69 | + links: Record<string, any>; |
| 70 | +} |
| 71 | + |
| 72 | +export interface API { |
| 73 | + addEventListener(event: string, callback: () => void): void; |
| 74 | + removeEventListener(event: string, callback: () => void): void; |
| 75 | +} |
0 commit comments