Classes
Import these from @grafloria/engine.
Classes
ClipboardManager
ClipboardManager handles copy/paste operations for diagram entities
Features:
- Serializes selected entities to clipboard format
- Handles relationship preservation (links between copied nodes)
- Supports cross-diagram paste (ID remapping)
- Maintains clipboard history
tsclass ClipboardManager
Methods
copy(data: { nodes: NodeModel[]; links: LinkModel[]; groups: GroupModel[]; sourceDiagramId?: string; }): void— Copy entities to clipboardget(): ClipboardData | null— Get clipboard dataclaimPasteSlot(): number— Claim the next paste slot for the CURRENT clipboard payload (1-based).
Repeat-pasting the same copy must cascade — the clipboard's serialized positions are frozen at copy time, so a constant default offset lands every paste on the exact same pixels and "paste" appears to work only once (live report). Each PasteCommand claims its slot once (stable across redo); a new copy() resets the cascade.
hasData(): boolean— Check if clipboard has dataclear(): void— Clear clipboardgetHistory(): ClipboardData[]— Get clipboard historyisFromDiagram(diagramId: string): boolean— Check if clipboard contains nodes from a specific diagramgetStats(): { nodeCount: number; linkCount: number; groupCount: number; timestamp: number | null; }— Get clipboard statistics
EventBus
tsclass EventBus
Methods
constructor()emit(event: string, data?: any): void— Emit an eventon(pattern: string, handler: Function): () => void— Subscribe to eventsonce(pattern: string, handler: Function): void— Subscribe onceoff(pattern: string, handler: Function): void— Unsubscribe from eventsremoveAllListeners(pattern?: string): void— Remove all listenersonFiltered( event: string, filter: (data: any) => boolean, handler: Function ): () => void— Filtered subscriptiononMapped<T, R>( event: string, mapper: (data: T) => R, handler: (data: R) => void ): () => void— Mapped subscriptiononDebounced( event: string, delay: number, handler: Function ): () => void— Debounced subscriptiononThrottled( event: string, delay: number, handler: Function ): () => void— Throttled subscriptionbatch(fn: () => void): void— Batch eventssuspend(): void— Suspend event emissionresume(): void— Resume event emissionstartRecording(): void— Start recording eventsstopRecording(): EventLogEntry[]— Stop recordinggetEventLog(): ReadonlyArray<EventLogEntry>— Get event logclearEventLog(): void— Clear event logreplay(events: EventLogEntry[]): void— Replay eventslistenerCount(event: string): number— Get listener counteventNames(): string[]— Get all event names
GridLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
tsclass GridLayoutAlgorithm extends BaseLayoutAlgorithm
Methods
constructor(config?: LayoutConfiguration)getName(): string— Get the name of the layout algorithmgetType(): 'grid'— Get the type of the layout algorithmcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate placement for a single new nodereLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes in grid patternoverride configure(config: LayoutConfiguration): void— Configure grid-specific optionsoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Grid layout can always be applied
HierarchicalLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
tsclass HierarchicalLayoutAlgorithm extends BaseLayoutAlgorithm
Methods
constructor(config?: LayoutConfiguration)getName(): string— Get the name of the layout algorithmgetType(): 'hierarchical'— Get the type of the layout algorithmcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate placement for a single new node For hierarchical layout, we'll place it near connected nodesreLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes using Dagreoverride configure(config: LayoutConfiguration): void— Configure hierarchical-specific optionsoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Hierarchical layout works best on DAGs but can handle any graph
HtmlTemplateRenderer
HTML Template Renderer Framework-agnostic HTML template rendering with EventBus integration
Features:
- LemonadeJS template rendering
- Data binding from NodeModel.data
- Event handlers connected to EventBus
- Component mode support (pass-through for framework-specific rendering)
- Proper resource cleanup to prevent memory leaks
tsclass HtmlTemplateRenderer
Methods
constructor(private eventBus: EventBus)render(config: HtmlConfig, node: NodeModel): RenderResult— Render HTML configuration to resultdisposeNode(nodeUuid: string): void— Dispose resources for a specific nodedispose(): void— Cleanup all renderer resources
LemonadeJSRenderer
LemonadeJS Enhanced Renderer Full LemonadeJS runtime with two-way binding
Features:
- Real LemonadeJS template rendering
- Two-way data binding ()
- Reactive updates (automatic re-rendering on data changes)
- Event handlers (, , etc.)
- EventBus integration (all events flow through engine)
- Component mode support
tsclass LemonadeJSRenderer
Methods
constructor(private eventBus: EventBus)render(config: HtmlConfig, node: NodeModel): LemonadeRenderResult— Render HTML configuration to LemonadeJS elementdisposeNode(nodeUuid: string): void— Dispose resources for a specific nodedispose(): void— Cleanup all renderer resources
MobilePerformanceService
tsclass MobilePerformanceService
Methods
static isMobileDevice(): boolean(static) — Detect if running on mobile devicestatic isLowPowerDevice(): boolean(static) — Detect if low-power deviceinitialize(customConfig?: Partial<MobilePerformanceConfig>)— Initialize with auto-detectionthrottle<T extends (...args: any[]) => any>( key: string, fn: T, wait: number = this.config.touchMoveThrottle ): (...args: Parameters<T>) => void— Throttle function executiongetRenderQuality(): 'high' | 'medium' | 'low'— Get recommended render quality based on deviceshouldSkipRender(nodeCount: number): boolean— Should skip rendering based on performance configgetConfig(): MobilePerformanceConfig— Get configurationupdateConfig(config: Partial<MobilePerformanceConfig>)— Update configuration
PerformanceMonitor
tsclass PerformanceMonitor
Methods
constructor(config: PerformanceConfig = {})measure<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>— Measure operation performancesetWarnThreshold(threshold: number): void— Set warning thresholdgetReport(): PerformanceReport— Get performance reportclear(): void— Clear all metrics
PluginManager
tsclass PluginManager
Methods
constructor( engine: any, eventBus: any, config: PluginManagerConfig = {} )register(plugin: Plugin, config: Record<string, any> = {}): void— Register a plugin (without installing)async install(pluginName: string): Promise<void>— Install a pluginasync uninstall(pluginName: string): Promise<void>— Uninstall a pluginasync activate(pluginName: string): Promise<void>— Activate a pluginasync deactivate(pluginName: string): Promise<void>— Deactivate a pluginget(pluginName: string): Plugin | undefined— Get plugin by namehas(pluginName: string): boolean— Check if plugin is registeredisInstalled(pluginName: string): boolean— Check if plugin is installedisActive(pluginName: string): boolean— Check if plugin is activegetState(pluginName: string): PluginState | undefined— Get plugin statelist(): PluginMetadata[]— List all registered pluginslistInstalled(): PluginMetadata[]— List installed pluginslistActive(): PluginMetadata[]— List active pluginsasync unregister(pluginName: string): Promise<void>— Unregister a plugin (removes from registry)async installAll(): Promise<void>— Install all registered pluginsasync uninstallAll(): Promise<void>— Uninstall all pluginsasync clear(): Promise<void>— Clear all plugins (uninstall and unregister)
Was this page helpful?