mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
We're migrating to ESM, which will allow us to import the latest versions of our dependencies. Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
20 lines
523 B
TypeScript
20 lines
523 B
TypeScript
import { useKeyboardShortcut } from './useKeyboardShortcut.js';
|
|
|
|
export const useKeyboardCopy = (handler: () => void) =>
|
|
useKeyboardShortcut(
|
|
{
|
|
key: 'c',
|
|
modifiers: ['ctrl'],
|
|
preventDefault: false,
|
|
},
|
|
() => {
|
|
const selection = window.getSelection?.();
|
|
if (
|
|
selection &&
|
|
(selection.type === 'None' || selection.type === 'Caret')
|
|
) {
|
|
handler();
|
|
}
|
|
},
|
|
);
|