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

Reusing the Async Clipboard API to Copy SVGs #122

Open
yisibl opened this issue Feb 24, 2024 · 0 comments
Open

Reusing the Async Clipboard API to Copy SVGs #122

yisibl opened this issue Feb 24, 2024 · 0 comments

Comments

@yisibl
Copy link

yisibl commented Feb 24, 2024

Chrome is working on improving the ability to copy SVG to the clipboard, can you reuse the Async Clipboard API and add image/svg+xml? We need to test that it doesn't crash before shipping.

9612565

await navigator.clipboard.writeText(svgString)
// const plainTextBlob = new Blob([svgString], { type: 'text/plain' })
// Copying image/svg+xml is not yet supported in Chrome and crashes the tab
// await navigator.clipboard.write([
//  new ClipboardItem({
//    [blob.type]: blob,
//    'text/plain': plainTextBlob,
//  }),
// ])

Now you can use ClipboardItem.supports('image/svg+xml') to detect if SVG is supported.

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

No branches or pull requests

1 participant