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

refactor: use svgo to format snapshot svg #6669

Merged
merged 2 commits into from
Dec 25, 2024
Merged

Conversation

Aarebecca
Copy link
Contributor

  • 使用 SVGO 格式化截图 SVG(对属性进行排序)

  • Use SVGO to format the screenshot SVG (sort the attributes)

Copy link

Walkthrough

此PR通过使用SVGO替换xml-formatter来格式化SVG文件,主要是对SVG属性进行排序。此更改旨在优化SVG文件的格式化和管理。

Changes

文件 描述
package.json 添加了svgo依赖,移除了xml-formatter依赖。
packages/cli/template-extension/package.json 删除了一个依赖项。
packages/g6/tests/snapshots/* 使用SVGO重新格式化了多个SVG文件,主要是对属性进行排序。
packages/g6/tests/utils/to-match-svg-snapshot.ts 用SVGO替换了xml-formatter进行SVG格式化。

const removeId = (svg: string, reserved?: Set<string>) => {
if (!reserved) return svg.replace(/ *id="[^"]*" */g, ' ');
return svg.replace(/ *id="([^"]*)" */g, (match, id) => (reserved.has(id) ? match : ' '));
const format = (svg: SVGElement) => {

Choose a reason for hiding this comment

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

The format function now uses svgo to optimize SVGs, which is a good improvement for handling SVG formatting. Ensure that the optimize function is correctly configured to meet all formatting requirements.

@Aarebecca Aarebecca merged commit 37cae0b into v5 Dec 25, 2024
2 checks passed
@Aarebecca Aarebecca deleted the refactor/snapshots-format branch December 25, 2024 12:50
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.

1 participant