fixes and better mermaid
This commit is contained in:
@ -512,9 +512,16 @@ CMD [ "serve", "-s", "dist", "-l", "8000" ]
|
||||
- **Real-time Preview**: Users can see their Mermaid diagram rendered as they type
|
||||
- **Error Handling**: Clear error messages for invalid Mermaid syntax
|
||||
- **Unique Rendering**: Each render uses a unique ID to prevent caching issues that could cause diagrams to disappear
|
||||
- **DOM Cleanup**: Proper cleanup of mermaid-generated DOM elements to prevent accumulation of leftover elements from failed renders
|
||||
- **Consistent Styling**: Matches the existing design language of the application
|
||||
- **Accessibility**: Proper ARIA labels and semantic HTML structure
|
||||
|
||||
**Important Implementation Details**:
|
||||
|
||||
- **DOM Element Cleanup**: Added `finally` block in render function to clean up DOM elements that mermaid creates, especially important for failed renders which would otherwise leave orphaned elements
|
||||
- **Component Unmount Cleanup**: Added cleanup `useEffect` to remove any lingering mermaid elements when component unmounts
|
||||
- **Unique ID Generation**: Uses `useRef` counter to generate unique IDs for each render attempt, preventing mermaid's internal caching issues
|
||||
|
||||
This enhancement makes the application more suitable for software architecture exercises that require diagram creation and visualization.
|
||||
|
||||
---
|
||||
|
Reference in New Issue
Block a user