fix(ui): Mermaid Copy PNG/SVG should copy images, not fail or copy markup - #12981
Conversation
8645967 to
5bd81ee
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge All 3 suggestions from the previous review were addressed in the new commits: the Files Reviewed (4 files)
Previous Review Summary (commit 5bd81ee)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 5bd81ee)Status: 3 Issues Found | Recommendation: Address before merge All findings are non-blocking suggestions. The fix itself is correct: decoding the data URL locally sidesteps the webview CSP Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Reviewed by kimi-k3 · Input: 37.7K · Output: 7.3K · Cached: 214.3K Review guidance: REVIEW.md from base branch |
Copy PNG called fetch() on a data URL, which VS Code webview CSP rejects, so the copy silently did nothing. Decode the data URL locally instead. Copy SVG used clipboard.writeText() with SVG markup, so paste targets got source text instead of an image. Write SVG/PNG/text representations when supported, and fall back to PNG on hosts that reject multi-type items.
5bd81ee to
ead46f4
Compare
…-clipboard fix(ui): Mermaid Copy PNG/SVG should copy images, not fail or copy markup
Summary
Two clipboard bugs in the Mermaid export actions:
Copy PNG has no effect in VS Code webviews
copyPngdidfetch(dataUrl).blob(). Webview CSP blocksfetchfordata:URLs, the promise rejects, and the UI handler only used.then()(no.catch()), so nothing was written to the clipboard and the button showed no success state.Copy SVG pastes a wall of SVG source text
onCopySvgcalledclipboard.writeText(serialize(svg)), so paste targets received markup instead of an image.Fix
dataUrlToBlob) and writeimage/pngviaClipboardItemimage/svg+xmlwhenClipboardItem.supports("image/svg+xml"); otherwise fall back to PNG so paste still gets an imageDownload SVG/PNG is unchanged (already bridged via
kilo:save-image).Test plan
<svg>...</svg>text