diff --git a/src/editor/components/CopyButton/CopyButton.tsx b/src/editor/components/CopyButton/CopyButton.tsx deleted file mode 100644 index 896e06a91..000000000 --- a/src/editor/components/CopyButton/CopyButton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React, {useState} from 'react'; - -import {Copy, CopyCheck} from '@gravity-ui/icons'; -import {Button, Icon, Tooltip} from '@gravity-ui/uikit'; - -let uncheckTimer: NodeJS.Timer | null = null; -const UNCHECK_TIMEOUT = 2000; // ms - -interface CopyButtonProps { - className?: string; - value: string; -} - -export const CopyButton = ({value, className}: CopyButtonProps) => { - const [isChecked, setIsChecked] = useState(false); - - const onCopyClick = () => { - if (isChecked) { - return; - } - navigator.clipboard.writeText(value); - - setIsChecked(true); - - if (uncheckTimer) { - clearTimeout(uncheckTimer); - } - - uncheckTimer = setTimeout(() => { - setIsChecked(false); - uncheckTimer = null; - }, UNCHECK_TIMEOUT); - }; - - return ( - - - - ); -}; diff --git a/src/editor/components/YamlEditor/YamlEditor.tsx b/src/editor/components/YamlEditor/YamlEditor.tsx index cfb8958a9..4aff94317 100644 --- a/src/editor/components/YamlEditor/YamlEditor.tsx +++ b/src/editor/components/YamlEditor/YamlEditor.tsx @@ -1,11 +1,11 @@ import React, {useMemo} from 'react'; +import {ClipboardButton} from '@gravity-ui/uikit'; import yaml from 'js-yaml'; import MonacoEditor, {monaco} from 'react-monaco-editor'; import {PageContent} from '../../../models'; import {block} from '../../../utils'; -import {CopyButton} from '../CopyButton/CopyButton'; import './YamlEditor.scss'; @@ -39,7 +39,7 @@ export const YamlEditor = ({content}: YamlEditorProps) => { return (
- +
); };