fleet/frontend/pages/hosts/NewHostPage/helpers.js
Mike Arpaia c07702330d Cleaning JavaScript imports and if statements (#327)
* Moving entityGetter to utility folder

* Import whitespace and if statement braces

* newlines between multi-line if's
2016-10-19 16:22:18 -04:00

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 };