mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Moving entityGetter to utility folder * Import whitespace and if statement braces * newlines between multi-line if's
23 lines
464 B
JavaScript
23 lines
464 B
JavaScript
import select from 'select';
|
|
|
|
const removeSelectedText = () => {
|
|
return global.window.getSelection().removeAllRanges();
|
|
};
|
|
|
|
export const copyText = (elementId) => {
|
|
const element = global.document.querySelector(elementId);
|
|
|
|
select(element);
|
|
|
|
const canCopy = global.document.queryCommandEnabled('copy');
|
|
|
|
if (!canCopy) {
|
|
return false;
|
|
}
|
|
|
|
global.document.execCommand('copy');
|
|
removeSelectedText();
|
|
return true;
|
|
};
|
|
|
|
export default { copyText };
|