docs: fix Export plugin docs and refresh demo#5076
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Export plugin example by introducing specific handlers for downloading, callback-based exporting, and asynchronous exporting of SVG, PNG, and JPEG formats, alongside updated documentation and styling. Feedback on these changes highlights a potential XSS vulnerability in the image preview function due to the use of innerHTML, and a logic issue where success messages are displayed even if the graph reference is null.
b8f1b8f to
c28e34b
Compare
Replace incorrect Export.ToSVGOptions and Export.ToImageOptions with names that match the source types. Co-authored-by: Cursor <cursoragent@cursor.com>
Correct option type formatting, toSVG callback parameter, and backgroundColor default to match the export plugin source. Co-authored-by: Cursor <cursoragent@cursor.com>
Use ExportToSVGCallback for toSVG/toPNG/toJPEG callbacks and document toSVGAsync, toPNGAsync, and toJPEGAsync per api.ts. Co-authored-by: Cursor <cursoragent@cursor.com>
Refactor the export example with left canvas and right control panel, Chinese feedback messages, and clearer API grouping aligned with the plugin docs. Co-authored-by: Cursor <cursoragent@cursor.com>
Use createElement for image preview instead of innerHTML, and guard graph ref before showing success messages. Co-authored-by: Cursor <cursoragent@cursor.com>
pnpm@latest requires Node >= 22.13 (node:sqlite); CI install was failing on Node 20. Co-authored-by: Cursor <cursoragent@cursor.com>
c28e34b to
3f3b37b
Compare
Member
Author
hustcc
approved these changes
Jun 18, 2026
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.
📝 Description
对照
src/plugin/export源码,修正 Export 插件官方教程文档,并重写 examples 示例页。修改文件
site/docs/tutorial/plugins/export.zh.mdsite/docs/tutorial/plugins/export.en.mdexamples/src/pages/plugins/export/index.tsxexamples/src/pages/plugins/export/index.less一、文档(
site/docs/tutorial/plugins/)选项类型名(与
type.ts一致)Export.ToSVGOptions→ExportToSVGOptionsExport.ToImageOptions→ExportToImageOptionsexportSVG、exportPNG、exportJPEG、toSVG、toPNG、toJPEG的签名与正文Graph 方法签名(与
api.ts一致)toSVG、toPNG、toJPEG的回调类型改为ExportToSVGCallback(不再使用内联(dataUri: string) => any等写法)toSVGAsync、toPNGAsync、toJPEGAsync的Promise<string>签名选项表
`RectangleLike`、`boolean`、`NumberExt.SideOptions`)backgroundColor默认值改为'white'(与options.backgroundColor || 'white'一致)二、Examples(
examples/src/pages/plugins/export/)index.less)exportSVG/exportPNG/exportJPEG、toSVG/toPNG/toJPEG、toSVGAsync/toPNGAsync/toJPEGAsyncmessage提示改为中文;toSVG保存 SVG 文件,toPNG/toJPEG及其 Async 在新标签页预览 Data URIPick+graph[type]写法,改为显式 handler;补充文件头与分组注释(方法名写全,不用通配符缩写)🖼️ Screenshot
修改前


修改后
💡 Motivation and Context
官方教程中 Export 插件的选项类型、方法签名与
src/plugin/export不一致,开发者按文档编写 TypeScript 容易出错;同时 examples 示例完善的更易理解的交互示例。🧩 Types of changes
🔍 Self Check before Merge