Improved code styling
This commit is contained in:
18
client/src/shared/utils/browser.js
Normal file
18
client/src/shared/utils/browser.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export const getTextContentsFromHtmlString = html => {
|
||||
const el = document.createElement('div');
|
||||
el.innerHTML = html;
|
||||
return el.textContent;
|
||||
};
|
||||
|
||||
export const copyToClipboard = value => {
|
||||
const $textarea = document.createElement('textarea');
|
||||
$textarea.value = value;
|
||||
document.body.appendChild($textarea);
|
||||
$textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild($textarea);
|
||||
};
|
||||
|
||||
export const isFocusedElementEditable = () =>
|
||||
!!document.activeElement.getAttribute('contenteditable') ||
|
||||
['TEXTAREA', 'INPUT'].includes(document.activeElement.tagName);
|
||||
Reference in New Issue
Block a user