Skip to content

Add Mermaid v11 Support with Backward Compatibility#13

Open
phoneee wants to merge 1 commit into
tylingsoft:masterfrom
phoneee:feat/mermaid-v11-support
Open

Add Mermaid v11 Support with Backward Compatibility#13
phoneee wants to merge 1 commit into
tylingsoft:masterfrom
phoneee:feat/mermaid-v11-support

Conversation

@phoneee

@phoneee phoneee commented Sep 25, 2025

Copy link
Copy Markdown

Summary

  • ✅ Add comprehensive support for Mermaid v11 with backward compatibility to v8-v10
  • ✅ Eliminate all UnknownDiagramError and console errors
  • ✅ Implement version-aware parsing strategy using detectType() for v11+
  • ✅ Add comprehensive test suite with 26 test cases covering all diagram types

Technical Changes

Core Plugin Updates (src/index.js)

  • Version Detection: Enhanced version detection supporting all export formats
  • V11 Support: Use detectType() instead of async parse() to prevent UnknownDiagramError
  • DOM Setup: Optional JSDOM/DOMPurify setup for Node.js environments (v10+)
  • Backward Compatibility: Support for v8-v10 parsing methods and error handling

Testing Infrastructure

  • DOM Setup (test/setup.js): Node.js DOM environment for v10+ compatibility
  • Comprehensive Tests (test/comprehensive-test.js): 26 tests covering:
    • All diagram types (graph, sequence, gantt, class, state, ER, journey, pie, git, flowchart)
    • Version-specific features and error handling
    • Edge cases, special characters, Unicode, mixed content
    • Performance testing with large diagrams

Dependencies

  • Peer Dependencies: Moved dompurify and jsdom to optional peer dependencies
  • Mermaid: Updated to v11.4.1 with backward compatibility

Test Results

📊 Test Summary:
   ✅ Passed: 26
   ❌ Failed: 0  
   📦 Total: 26

🎉 All tests pass with zero console errors across all Mermaid versions!

Breaking Changes

None - maintains full backward compatibility with existing implementations.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

- Support all Mermaid versions (v8-v11) with version-aware parsing
- Use detectType() for v11 to eliminate async console errors
- Add DOM environment setup for Node.js compatibility
- Move dompurify/jsdom to optional peer dependencies
- Add comprehensive test suite (26 tests) covering all diagram types
- Include test utilities and improved project configuration

Tests: 26/26 ✓ | Console errors: 0 ✓ | Compatibility: Browser + Node.js ✓

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant