feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io#19
feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io#19
Conversation
…d (DrawioContextMenuProvider); remove ad-hoc PR docs Co-authored-by: Cursor <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughRemoved a documentation file, switched a Playground component to use the snapshot hook only, and hardened Draw.io attribute parsing by enforcing word-boundary checks to avoid false-positive attribute matches. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
…heck) Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/playground/src/components/drawio/DrawioContextMenuProvider.tsx`:
- Around line 1-4: The imports need to be reordered so type-only imports come
first: move the value import usePlaygroundSnapshot below the type-only import
block; group LayoutedLikeC4ModelData, LikeC4Model, and DiagramView together at
the top as type-only imports and then import usePlaygroundSnapshot afterwards to
satisfy the import grouping and sorting rule.
apps/playground/src/components/drawio/DrawioContextMenuProvider.tsx
Outdated
Show resolved
Hide resolved
…Provider Co-authored-by: Cursor <[email protected]>
feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io
Summary
This PR adds export of LikeC4 views to Draw.io (
.drawio) format. Users can export from the CLI (likec4 export drawio) and from the Playground (right-click on diagram → DrawIO → Export view / Export all). This allows editing diagrams in Draw.io and reusing them in tools that support the format.This PR does not include import. Import from Draw.io will be proposed in a separate PR after this one is merged.
What's in this PR
1. Generators (
@likec4/generators)packages/generators/src/drawio/generate-drawio.ts— Exports a single view or multiple views to Draw.io XML. Maps LikeC4 elements (title, description, shape, color, relationships, etc.) to mxCell vertices/edges. Supports optionallayoutOverride,strokeColorByNodeId,strokeWidthByNodeId,edgeWaypoints, andcompressed.packages/generators/src/drawio/parse-drawio.ts— Used only for round-trip comment parsing (parseDrawioRoundtripComments): when re-exporting after a future import, layout and waypoints from comment blocks in.c4source can be applied. No import UI or CLI in this PR.packages/generators/src/drawio/index.ts— Public API:generateDrawio,generateDrawioMulti,GenerateDrawioOptions, plusgetAllDiagrams,parseDrawioRoundtripComments,parseDrawioToLikeC4,parseDrawioToLikeC4Multi(for roundtrip and for the future import PR).generate-drawio.spec.ts,parse-drawio.spec.ts; snapshots in__snapshots__/.2. CLI (
@likec4/likec4)packages/likec4/src/cli/export/drawio/handler.ts—likec4 export drawio [path]with options:--outdir, -o,--all-in-one,--roundtrip,--uncompressed,--project,--use-dot.packages/likec4/src/cli/export/index.ts— Registers the drawio export command.3. Playground
Playground exports are uncompressed by default so files open reliably in Draw.io desktop.
4. Documentation
apps/docs/src/content/docs/tooling/drawio.mdx— Export only: mapping (LikeC4 → Draw.io), options, not preserved, multi-diagram, troubleshooting, re-export using comment blocks. No import sections.apps/docs/src/content/docs/tooling/cli.mdx— Export to DrawIO section only; no Import from DrawIO section. Intro mentions Export to DrawIO only.5. Tests
packages/likec4/src/drawio-demo-export-import.spec.ts— Export tests only; import/vice-versa test skipped in this PR.packages/likec4/src/drawio-tutorial-export-import.spec.ts— Export tests only; import and round-trip tests skipped in this PR.e2e/tests/drawio-playground.spec.ts— Asserts DrawIO menu shows Export to DrawIO (and Export all). No Import assertion. Run withplaywright.playground.config.ts(playground on 5174); main e2e config ignores this test.What's not in this PR
likec4 import drawiocommand (nopackages/likec4/src/cli/import/).Post-review fixes (CodeRabbit)
Addresses CodeRabbit AI review (actionable + nitpicks):
Actionable
stripHtmluses shareddecodeXmlEntities(); UserObjectidescaped withescapeXml(userObjId);collectRoundtripForStatesingle pass;getDecodedStyle/decodeRootStyleFieldtry/catch fordecodeURIComponent;getAttrword-boundary soid=does not matchuserid=.ensureSingleProject()only when no--project;exportParamstyped asExportDrawioParams.await usingfor languageServices.startTakeScreenshotper project; loggerc4:export.Nitpicks / cleanup
getErrorFromLogRecord/errorMessage; config destructure; removed comment.EMPTY_DRAWIO_SNAPSHOT; stablegetSourceContent;filesRefinuseEffect; removed unusedusePlayground().console.warnwith error.modified(top-level);buildOptionsFromRoundtrip+ parse-once.Checklist (contribution guidelines)
mainbefore creating this PR.feat:,docs:).pnpm testandpnpm typecheck(andpnpm test:e2efor e2e); all pass.Notes for reviewers
.drawiofile per view by default;--all-in-onefor all views as tabs;--roundtripapplies layout/waypoints from comment blocks;--uncompressedfor Draw.io desktop compatibility.Review context
The original DrawIO bidirectional work (branch
feat/drawio-bidirectional-playground) was reviewed upstream in likec4/likec4 PR #2593. This export-only PR is a split from that work; CodeRabbit AI review comments have been addressed in the "Post-review fixes" section above.Summary by CodeRabbit