From e53d0c3e01931f8ca82e2ad3e3cb6932e6f5c33e Mon Sep 17 00:00:00 2001 From: Maximilian Blazek <68336485+dgtlntv@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:17:58 +0200 Subject: [PATCH] copy figma component to clipboard --- .../docs/components/accordion/figma/index.md | 2 +- vanilla/templates/static/js/copy-to-clipboard.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 vanilla/templates/static/js/copy-to-clipboard.js diff --git a/vanilla/templates/docs/components/accordion/figma/index.md b/vanilla/templates/docs/components/accordion/figma/index.md index cd431f7..93fd238 100644 --- a/vanilla/templates/docs/components/accordion/figma/index.md +++ b/vanilla/templates/docs/components/accordion/figma/index.md @@ -4,4 +4,4 @@ context: title: Accordion | Figma --- -# 🚧 WIP 🚧 + diff --git a/vanilla/templates/static/js/copy-to-clipboard.js b/vanilla/templates/static/js/copy-to-clipboard.js new file mode 100644 index 0000000..df78cd6 --- /dev/null +++ b/vanilla/templates/static/js/copy-to-clipboard.js @@ -0,0 +1,11 @@ +(async function clipboard() { + const html = new Blob( + [ + `Button`, + ], + {type: 'text/html'}, + ); + const text = new Blob(['Button'], {type: 'text/plain'}); + const data = new ClipboardItem({'text/html': html, 'text/plain': text}); + await navigator.clipboard.write([data]); +});