mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 05:27:17 +08:00
* [APP-1697] fix menu, add category to events as key without translation * [APP-1697] fix menu, add category to events as key without translation
24 lines
781 B
JavaScript
24 lines
781 B
JavaScript
import clipboardCopy from 'clipboard-copy';
|
|
import { mixpanelEvents, mixpanelService } from '@ea11y-apps/global/services';
|
|
import { useScannerWizardContext } from '@ea11y-apps/scanner/context/scanner-wizard-context';
|
|
import { useState } from '@wordpress/element';
|
|
|
|
export const useCopyToClipboard = () => {
|
|
const { openedBlock } = useScannerWizardContext();
|
|
const [copied, setCopied] = useState(false);
|
|
const copyToClipboard = (snippet, type, source) => async () => {
|
|
await clipboardCopy(snippet);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 5000);
|
|
mixpanelService.sendEvent(mixpanelEvents.copySnippetClicked, {
|
|
snippet_type: type,
|
|
snippet_content: snippet,
|
|
category_name: openedBlock,
|
|
source,
|
|
});
|
|
};
|
|
return {
|
|
copied,
|
|
copyToClipboard,
|
|
};
|
|
};
|