Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utility to export svg into html image #5783

Merged
merged 1 commit into from
Dec 9, 2024
Merged

utility to export svg into html image #5783

merged 1 commit into from
Dec 9, 2024

Conversation

mwdchang
Copy link
Member

@mwdchang mwdchang commented Dec 9, 2024

Summary

Adds utility functions to convert SVG into image.

This is not in use for now as where we want to apply SVG=>Image transform (model-diagram), it requires CSS style adjustments and tweaks to the governing logic that are probably better off as a separate PR.

Testing

You add the this to the end of renderGraph() function in tera-model-diagram.vue to test, it appends the image(s) onto the document body. The image(s) are not 100% faithful because of the aforementioned style changes that are not carried over when converting to an image.

     const imageTest = await svgToImage(graphElement.value?.querySelector('svg') as any);
     document.body.appendChild(imageTest);
image

@mwdchang
Copy link
Member Author

mwdchang commented Dec 9, 2024

Blob URL doesn't seem to work well with node, so no unit test for this one.

Copy link
Contributor

@blanchco blanchco left a comment

Choose a reason for hiding this comment

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

okay!

Copy link
Contributor

@shawnyama shawnyama left a comment

Choose a reason for hiding this comment

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

cool

@mwdchang mwdchang merged commit efe438d into main Dec 9, 2024
4 checks passed
@mwdchang mwdchang deleted the svg-export branch December 9, 2024 18:27
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.

3 participants