1const target = document.querySelector('div.target');
2
3target.addEventListener('paste', (event) => {
4 let paste = (event.clipboardData || window.clipboardData).getData('text');
5 paste = paste.toUpperCase();
6
7 const selection = window.getSelection();
8 if (!selection.rangeCount) return false;
9 selection.deleteFromDocument();
10 selection.getRangeAt(0).insertNode(document.createTextNode(paste));
11
12 event.preventDefault();
13});
14