feat: implement WebSocket-based Mermaid conversion with auto-sync

- Add WebSocket message handler for mermaid_convert type
- Make handleWebSocketMessage async to support conversion
- Add automatic backend sync after diagram generation
- Integrate convertMermaidToExcalidraw utility
- Remove test button and handleMermaidTest function
- Fix: Add missing Excalidraw CSS import for proper UI rendering
- Enhance server endpoint with WebSocket broadcast support
- Add mermaid_convert to WebSocketMessageType union
This commit is contained in:
francisco
2025-11-01 13:58:23 -03:00
parent dce247f4d6
commit b8e2de76f1
4 changed files with 53 additions and 41 deletions
+9 -2
View File
@@ -416,13 +416,20 @@ app.post('/api/elements/from-mermaid', (req: Request, res: Response) => {
hasConfig: !!config
});
// Broadcast to all WebSocket clients to process the Mermaid diagram
broadcast({
type: 'mermaid_convert',
mermaidDiagram,
config: config || {},
timestamp: new Date().toISOString()
});
// Return the diagram for frontend processing
// The frontend will handle the actual conversion using mermaid-to-excalidraw
res.json({
success: true,
mermaidDiagram,
config: config || {},
message: 'Mermaid diagram received. Process on frontend with DOM access.'
message: 'Mermaid diagram sent to frontend for conversion.'
});
} catch (error) {
logger.error('Error processing Mermaid diagram:', error);