Skip to content

feat(vscode): import SVG to calm json file - #3003

Open
byrash wants to merge 1 commit into
finos:mainfrom
fidelity-contributions:feat/import-svg-to-calm
Open

feat(vscode): import SVG to calm json file#3003
byrash wants to merge 1 commit into
finos:mainfrom
fidelity-contributions:feat/import-svg-to-calm

Conversation

@byrash

@byrash byrash commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

Iteration 1 of importing SVG into VS Code Plugin that converts to CALM JSON file to boot strap migration form other Diagram as code tools like Drawio ( more to be added )

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • Schema (calm/)
  • CALM AI (calm-ai/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • CALM Server (calm-server/)
  • CALM Widgets (calm-widgets/)
  • Documentation (docs/)
  • Shared (shared/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally
  • I have added/updated unit tests
  • All existing tests pass

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

@byrash
byrash requested a review from a team as a code owner August 19, 2026 19:08
@rocketstack-matt

Copy link
Copy Markdown
Member

Is this related to a specific issue?

@byrash

byrash commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Is this related to a specific issue?

Sorry no, was part of new capability to migrate to CALM. Thank You

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SVG-to-CALM import support to the VS Code extension, supporting Draw.io metadata and generic SVG diagrams.

Changes:

  • Adds import commands and canvas toolbar integration.
  • Parses SVG nodes, relationships, containment, geometry, and styles.
  • Generates CALM 1.2 JSON with parser and builder tests.

Reviewed changes

Copilot reviewed 19 out of 24 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
package-lock.json Locks SVG/XML dependencies.
calm-plugins/vscode/package.json Registers the command and dependencies.
calm-plugins/vscode/src/svg-parser.d.ts Declares SVG parser types.
calm-plugins/vscode/src/extension/extension.ts Registers the import command.
calm-plugins/vscode/src/extension/types/messages.ts Adds the import message type.
calm-plugins/vscode/src/extension/webview/canvas-panel.ts Handles canvas import requests.
calm-plugins/vscode/src/webview/App.tsx Adds the Import SVG button.
calm-plugins/vscode/src/webview/stores/sync-bridge.ts Sends import requests.
calm-plugins/vscode/src/extension/services/svg-import/index.ts Exports import APIs.
calm-plugins/vscode/src/extension/services/svg-import/types.ts Defines import graph types.
calm-plugins/vscode/src/extension/services/svg-import/svg-import-service.ts Orchestrates file selection and output.
calm-plugins/vscode/src/extension/services/svg-import/format-detector.ts Detects SVG formats.
calm-plugins/vscode/src/extension/services/svg-import/format-detector.test.ts Tests format detection.
calm-plugins/vscode/src/extension/services/svg-import/drawio-parser.ts Parses Draw.io metadata.
calm-plugins/vscode/src/extension/services/svg-import/drawio-parser.test.ts Tests Draw.io parsing.
calm-plugins/vscode/src/extension/services/svg-import/generic-svg-parser.ts Parses generic SVG geometry.
calm-plugins/vscode/src/extension/services/svg-import/generic-svg-parser.test.ts Tests generic parsing.
calm-plugins/vscode/src/extension/services/svg-import/shape-mapper.ts Maps shapes to CALM types.
calm-plugins/vscode/src/extension/services/svg-import/shape-mapper.test.ts Tests shape mapping.
calm-plugins/vscode/src/extension/services/svg-import/calm-builder.ts Builds CALM JSON.
calm-plugins/vscode/src/extension/services/svg-import/calm-builder.test.ts Tests CALM generation.
calm-plugins/vscode/src/extension/services/svg-import/__fixtures__/generic-simple.svg Provides a generic SVG fixture.
calm-plugins/vscode/src/extension/services/svg-import/__fixtures__/drawio-simple.svg Provides a Draw.io fixture.
calm-plugins/vscode/src/extension/services/svg-import/__fixtures__/drawio-nested.svg Provides a nested Draw.io fixture.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +41 to +45
const node = tryExtractNodeFromGroup(child, nodes.length);
if (node) {
nodes.push(node);
} else {
extractNodesFromElement(child, nodes);
Comment on lines +5 to +13
const warnings: string[] = [];
const nodeIdMap = new Map<string, string>();

const nodes = graph.nodes.map((n, i) => {
const { name, description } = splitLabel(n.label);
const isContainer = isContainerNode(n);
const nodeType = isContainer ? 'network' : mapShapeToNodeType(n.shapeHint, name);
const calmId = generateCalmId(nodeType, name, i);
nodeIdMap.set(n.id, calmId);
const byArea = [...nodes].sort((a, b) => {
const aArea = a.geometry.width * a.geometry.height;
const bArea = b.geometry.width * b.geometry.height;
return bArea - aArea;
Comment on lines +101 to +105
layout[calmId] = {
x: Math.round(n.geometry.x),
y: Math.round(n.geometry.y),
w: Math.round(n.geometry.width),
h: Math.round(n.geometry.height),
currentDocument.positionAt(currentDocument.getText().length)
);
edit.replace(currentDocument.uri, fullRange, result.json);
await vscode.workspace.applyEdit(edit);
this.log = outputChannel;
}

async importSvgIntoDocument(currentDocument: vscode.TextDocument | undefined): Promise<string | null> {
Comment on lines +83 to +85
if ((tag === 'rect' || tag === 'ellipse' || tag === 'circle') && !shapeGeo) {
shapeGeo = getShapeGeometry(tag, child.properties);
shapeHint = classifyTag(tag, child.properties);
@rocketstack-matt

Copy link
Copy Markdown
Member

Is this related to a specific issue?

Sorry no, was part of new capability to migrate to CALM. Thank You

Can we add one? I think this is a significant enough feature proposal that we should have a record of what was intended.

@byrash

byrash commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Is this related to a specific issue?

Sorry no, was part of new capability to migrate to CALM. Thank You

Can we add one? I think this is a significant enough feature proposal that we should have a record of what was intended.

My Apologies @rocketstack-matt has been very busy. Here is the issue #3025 . Please do the needful. Thank You.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants