Revert "chore: replace mermaid with beautiful-mermaid"#43
Conversation
This reverts commit 6fce8f2.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe pull request updates the diagram rendering library from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/chronicle/src/components/mdx/mermaid.tsx (1)
19-19: Make Mermaid security settings explicit as a best practice.While Mermaid v11.13.0 defaults to
securityLevel: 'strict'(which is safe fordangerouslySetInnerHTMLusage), explicitly setting this at Line 19 clarifies intent and guards against unexpected future version changes.Suggested configuration
- mermaid.initialize({ startOnLoad: false, theme: 'default' }) + mermaid.initialize({ + startOnLoad: false, + theme: 'default', + securityLevel: 'strict', + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/chronicle/src/components/mdx/mermaid.tsx` at line 19, The mermaid.initialize call should explicitly set securityLevel to 'strict' to harden against future defaults changing; update the mermaid.initialize invocation (the mermaid.initialize({ startOnLoad: false, theme: 'default' }) call) to include securityLevel: 'strict' in its options so the component always runs with strict security for any dangerouslySetInnerHTML usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/chronicle/src/components/mdx/mermaid.tsx`:
- Around line 14-29: The useEffect's inner async render function calls
mermaid.render without error handling, causing silent failures; wrap the
import/mermaid.initialize and mermaid.render calls inside a try/catch in the
render function (checking cancelled before updating) and on error call setSvg
with a sensible fallback (e.g., an error/SVG fallback or a user-visible message)
and log the error (console.error or process logger) so invalid diagram syntax or
other failures don't leave the component blank; keep references to mermaidId,
chart, cancelled and only update state via setSvg when not cancelled.
---
Nitpick comments:
In `@packages/chronicle/src/components/mdx/mermaid.tsx`:
- Line 19: The mermaid.initialize call should explicitly set securityLevel to
'strict' to harden against future defaults changing; update the
mermaid.initialize invocation (the mermaid.initialize({ startOnLoad: false,
theme: 'default' }) call) to include securityLevel: 'strict' in its options so
the component always runs with strict security for any dangerouslySetInnerHTML
usage.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dc898b24-329d-4654-b76a-a90572a4daaa
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
packages/chronicle/package.jsonpackages/chronicle/src/components/mdx/mermaid.tsx
Reverts #42