presentMermaid({ mountEl, mermaidText, mpdText | ast, options }) => Controller
Required:
mountEl: HTMLElement that hosts the SVG.mermaidText: Mermaid source string.ast or mpdText + options.parseMpd: presentation AST from Task 1.Optional:
options.diagram: custom DiagramAdapter.options.camera: custom CameraHandle.options.overlay: custom OverlayHandle.options.controls: custom ControlsHandle (or use createFloatingControls()).options.actionHandlers: additional action handlers.options.errorPolicy: default error policy (haltOnError or continueOnError).options.hooks: lifecycle hooks for editor integration:
onInit(controller): Called after controller initializationonStepChange(state, step): Called when step changesonActionStart(action, step): Called when an action starts executingonActionComplete(action, result): Called when an action completesonError(error, context): Called when an action error occursMethods:
next()prev()goto(stepIndex | stepId)reset()destroy()getState() - Returns current controller state including stepIndex, stepId, stepCount, and optional errorStatesetState(partial) - Updates controller state (currently supports stepIndex and stepId)getDeps() - Returns read-only access to { diagram, camera, overlay } dependenciesgetSteps() - Returns a copy of the steps arraygetCurrentStep() - Returns the current step definition or nullgetExecutionContext() - Returns current execution context (currentAction, currentStep, previousStep)updateAst(newAst, options?) - Updates the controller’s AST dynamically
options.preserveState - If true, tries to maintain current step after AST updateretry() - Retries the last failed step/actionclearError() - Clears error stateEvents:
on("stepchange" | "actionerror" | "error" | "render" | "actionstart" | "actioncomplete" | "astchange", handler)
actionerror is the preferred event name for action failures; error remains as a legacy alias.stepchange payload includes: { state, previousState, step, previousStep }actionerror payload includes: { error, step, action, context }actionstart payload includes: { action, step, context }actioncomplete payload includes: { action, result: { success, error? }, step, context }astchange payload includes: { previousState, newState, previousSteps, newSteps }getRoot() => SVGSVGElementgetContainer() => HTMLElementresolveTarget(target) => Element | nulldestroy()fit(target, { padding? })reset()destroy()showBubble({ id?, target, text })hideBubble(id?)destroy()show() - Show the controls UIhide() - Hide the controls UIupdateState(state) - Update controls based on controller statedestroy() - Remove controls and clean up resourcesControls can be created using createFloatingControls():
import { createFloatingControls } from 'finsteps';
const controls = createFloatingControls({
controller, // Controller instance (required)
camera, // CameraHandle for zoom controls (optional)
position: 'bottom-right', // Position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-center'
showPlayPause: true, // Show play/pause button (default: true)
showPrevNext: true, // Show prev/next buttons (default: true)
showZoomControls: true, // Show zoom controls (default: true)
showStepIndicator: true, // Show step counter (default: true)
autoHide: false, // Auto-hide after inactivity (default: false)
offset: { x: 20, y: 20 } // Offset from position edge (default: { x: 20, y: 20 })
});
Finsteps includes an optional AI model management system for multi-provider AI integration:
import {
modelManager, // Singleton model manager instance
type ModelConfig, // Model configuration interface
type ModelChatRequest, // Chat request interface
type ModelChatResponse, // Chat response interface
type ModelManager, // Model manager interface
type ModelProvider // Supported provider types
} from 'finsteps';
getAvailableModels(): ModelConfig[] - Get all enabled modelsgetModel(id: string): ModelConfig | undefined - Get specific modeladdModel(model: ModelConfig): void - Add new model configurationremoveModel(id: string): void - Remove modelsetDefaultModel(modelId: string): void - Set default modelchat(request: ModelChatRequest): Promise<ModelChatResponse> - Send chat requestdetectOllamaModels(): Promise<string[]> - Detect available Ollama modelspullOllamaModel(model: string): Promise<void> - Pull model from Ollamagpt-4claude-3-sonnetqwen3-coder-30b (local)import { modelManager } from 'finsteps';
// List available models
const models = modelManager.getAvailableModels();
// Chat with local qwen3-coder:30b
const response = await modelManager.chat({
model: 'qwen3-coder-30b',
messages: [
{ role: 'user', content: 'Write MPD code for a flowchart' }
],
options: { maxTokens: 500, temperature: 0.7 }
});
console.log(response.choices[0].message.content);
See AI Model Documentation for complete setup and provider configuration.