Repository navigation
Export the diagram as SVG the way the mlir-viewer does - #78
Merged
Merged
Conversation
The exportSvg command dispatched GLSP's stock export, which hands out the rendered SVG without its styles: every fill and stroke stayed behind in the webview's stylesheet, and an opened file showed black boxes. The mlir-viewer's extraction (its packages/client/src/svg-export.ts) is ported into the shared client: the rendered root group is cloned, the computed value of every property that decides the look is written onto the clone, url(#...) references are made local again, CSS Color 4 colours become rgb() for Inkscape and librsvg, hidden elements are dropped, the defs and the background travel along, and the whole is lifted into a viewBox of its own, at 1:1 whatever the zoom. The webview answers the extension's request with the file and its name, the editor provider saves it through VS Code's dialog beside the source, named after the workflow, and offers to open or reveal it. A palette header button does the same. The coverage test holds that every property the stylesheet declares is carried or excused by name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
exportSvgcommand dispatched GLSP's stockRequestExportSvgAction, which hands out the rendered SVG without its styles: every fill and stroke stayed behind in the webview's stylesheet, and the file opened as black boxes in anything but a browser with the stylesheet.This ports the mlir-viewer's extraction (
packages/client/src/svg-export.tsthere) into the shared client, for every profile:svg-export.ts,svg-export-command.ts): the rendered root group is cloned; the computed value of every property that decides the look is written onto the clone (the two lists, SVG and HTML inforeignObject);url(vscode-webview://…#arrow)becomesurl(#arrow);color(srgb …)becomesrgb()for Inkscape and librsvg; hidden elements are dropped; the root'sdefsand the background travel along; the whole is lifted into a viewBox of its own, at 1:1 whatever the viewport's zoom. The webview answers the extension'sdialogram.svg.extractwithdialogram.svg.extracted, carrying the file, a name from the workflow shown, and the element count. A palette header button,Export diagram as SVG, does the same.<workflow>.svg, and offers Open or Reveal in Explorer, as the mlir-viewer does.diagram-client.cssand fails on any property neither list carries and the excused list does not name, so a new stylesheet property cannot silently go missing from exports.Two differences from the mlir-viewer, both because this client has no semantic zoom and does not cull off-screen elements: no detail quick pick, and no canvas enlargement. The whole diagram is what the file holds.
252 client tests, 309 extension-core tests,
tsc --noEmitand the extension bundle pass. wfpy-ide contributes the command since endrix/wfpy-ide#21; streamblocks-ide's profile declares it but itspackage.jsondoes not contribute it yet.