import { useCallback } from 'react' ; import { useService } from '@cloudbeaver/core-di' ; import { ENotificationType , NotificationService } from '@cloudbeaver/core-events' ; import { copyToClipboard } from '@cloudbeaver/core-utils' ; export function useClipboard ( ) { const notificationService = useService ( NotificationService ) ; const copy = useCallback ( ( value , notify = false ) => { try { copyToClipboard ( value ) ; if ( notify ) { notificationService . notify ( { title : 'ui_copy_to_clipboard_copied' } , ENotificationType . Success ) ; } } catch ( exception ) { notificationService . logException ( exception , 'ui_copy_to_clipboard_failed_to_copy' ) ; } } , [ notificationService ] ) ; return copy ; }