|
|
@ -54,7 +54,14 @@ function useClipboardSupport() {
|
|
|
|
function CopyMenu({ isVisible, toggleVisibility, copyImage }) {
|
|
|
|
function CopyMenu({ isVisible, toggleVisibility, copyImage }) {
|
|
|
|
const clipboardSupported = useClipboardSupport()
|
|
|
|
const clipboardSupported = useClipboardSupport()
|
|
|
|
|
|
|
|
|
|
|
|
const [copy, { loading }] = useAsyncCallback(copyImage)
|
|
|
|
const [showCopied, { loading: copied }] = useAsyncCallback(
|
|
|
|
|
|
|
|
() => new Promise(res => setTimeout(res, 1000))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [copy, { loading }] = useAsyncCallback(async (...args) => {
|
|
|
|
|
|
|
|
await copyImage(...args)
|
|
|
|
|
|
|
|
showCopied()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="copy-menu-container">
|
|
|
|
<div className="copy-menu-container">
|
|
|
@ -81,7 +88,7 @@ function CopyMenu({ isVisible, toggleVisibility, copyImage }) {
|
|
|
|
<span>Copy to clipboard</span>
|
|
|
|
<span>Copy to clipboard</span>
|
|
|
|
{clipboardSupported && (
|
|
|
|
{clipboardSupported && (
|
|
|
|
<CopyButton id="export-clipboard" onClick={copy} disabled={loading}>
|
|
|
|
<CopyButton id="export-clipboard" onClick={copy} disabled={loading}>
|
|
|
|
{loading ? 'Copying…' : 'Image'}
|
|
|
|
{loading ? 'Copying…' : copied ? 'Copied!' : 'Image'}
|
|
|
|
</CopyButton>
|
|
|
|
</CopyButton>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
<CopyEmbed title="Medium.com" mapper={toEncodedURL} />
|
|
|
|
<CopyEmbed title="Medium.com" mapper={toEncodedURL} />
|
|
|
|