[Users | Trunk]: Add copy event listener to trim selection text

This commit is contained in:
Konstantinos Triantafyllou 2020-12-23 13:56:48 +00:00
parent 90e7a3095e
commit 230284002e
2 changed files with 7 additions and 4 deletions

View File

@ -69,8 +69,4 @@ a:hover, .uk-link:hover {
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
code {
user-select: all;
}

View File

@ -30,6 +30,13 @@
console.error('unable to copy text');
}
}
$(document).ready(function () {
document.addEventListener('copy', (event) => {
const selection = document.getSelection();
event.clipboardData.setData('text/plain', selection.toString().trim());
event.preventDefault();
});
});
</script>
<link rel="stylesheet" style="text/css" href="./css/theme.css">
<link rel="stylesheet" style="text/css" href="./css/custom.css">