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:
+9
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user