From 97126dc470b77c54b0aa6aa018887cb70bea4e7f Mon Sep 17 00:00:00 2001 From: shoonia Date: Mon, 29 Apr 2024 16:18:53 +0300 Subject: [PATCH] Add copy event listener --- src/components/Preview/index.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/Preview/index.tsx b/src/components/Preview/index.tsx index 93485aa..51af9c9 100644 --- a/src/components/Preview/index.tsx +++ b/src/components/Preview/index.tsx @@ -1,3 +1,4 @@ +import type { JSX } from 'preact'; import { useRef } from 'preact/hooks'; import s from './styles.css'; @@ -8,6 +9,7 @@ import { JSON } from './JSON'; import { DownloadButton } from '../DownloadButton'; import { IconDuplicate } from '../Icons/IconDuplicate'; import { createConfig } from '../../util/items'; +import { preventDefault } from '../../util/component'; const createData = (config: string): string => `// Jobs Config Generator // https://wix.to/NDAQn6c @@ -34,6 +36,11 @@ export const Preview: FC = () => { } }; + const copy: JSX.ClipboardEventHandler = (event) => { + event.clipboardData?.setData('text/plain', data); + preventDefault(event); + }; + return (
@@ -52,6 +59,7 @@ export const Preview: FC = () => {