I would like to restrict the paste text on the contenteditable to plain text. I have a html file and ts file.
I tried using this method but it keeps showing this error message: Property 'clipboardData' does not exist on type 'Event'.
window.onload = function(){
document.querySelector('#divId').addEventListener('paste', (e) => {
e.preventDefault();
const text = e.clipboardData.getData('text/plain');
console.log(text);
window.document.execCommand('insertText', false, text);
})
}
<div contenteditable="true" id="divId" style="border: 1px #ebedf2 solid; font-size: 17px; font-weight: 600; font-family: sans-serif; color: #575962;"></div>