Skip to content

Conversation

@pubuzhixing8
Copy link
Collaborator

@pubuzhixing8 pubuzhixing8 commented Nov 26, 2025

This PR exports a new toSvg method, enabling developers to programmatically export canvas content as an SVG file.

We can implement the feature plait-board/drawnix#278.

Previously, the toImage feature was already implemented using an SVG-based solution. This change simply extracts the core SVG generation logic into a standalone, publicly available toSvgData method line191.

Additionally, I've optimized the inline HTML style handling to reduce SVG file size by omitting unnecessary styles for display purposes:

Selective Style Cloning: Instead of cloning all inline styles, only specific styles defined by the caller are now copied. This allows developers full control over which classes and styles are included 1.

Direct Text Style Transfer: Text styles from the Slate editor framework are cloned directly to ensure consistency 2.

@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
plait Error Error Nov 27, 2025 0:19am
plait-docs Error Error Nov 27, 2025 0:19am

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 26, 2025

Deploying plait with  Cloudflare Pages  Cloudflare Pages

Latest commit: cfec676
Status:🚫  Build failed.

View logs

@pubuzhixing8
Copy link
Collaborator Author

Hi @NaoCoding , please help me review this pr!

Copy link
Collaborator

@NaoCoding NaoCoding left a comment

Choose a reason for hiding this comment

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

Hi @pubuzhixing8 , is this a bug or it is normal behavior.
While I draw some lines on the board

image

The export svg does not show anything.

image

@pubuzhixing8
Copy link
Collaborator Author

pubuzhixing8 commented Nov 27, 2025

@NaoCoding I don't know what happen, all vector-line, mind, flow chart, image are expected in my local environment.

board:
Screenshot 2025-11-27 at 20 11 21
svg:
plait-export-data-1764245321174

Copy link
Collaborator

@NaoCoding NaoCoding left a comment

Choose a reason for hiding this comment

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

Hmmm. LGTM. I'll try to find out is there any potential issue.
I think it's ok to merge first.

@pubuzhixing8 pubuzhixing8 merged commit de069e8 into develop Nov 27, 2025
1 of 5 checks passed
@pubuzhixing8 pubuzhixing8 deleted the export-svg-and-style-optimize branch November 27, 2025 12:19
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