How do I clear the label and style of text pasted into an contenteditable element?

when you copy text from somewhere else, you copy it along with the style. how do you clear the original label and style?

May.18,2022

compatible with ie11,edge,chrome,firefox,safari:

var element = document.createElement('div');
    element.contentEditable = true;
    element.addEventListener("paste", function (e){
        e.stopPropagation();
        e.preventDefault();
        var text = '', event = (e.originalEvent || e);
        if (event.clipboardData && event.clipboardData.getData) {
            text = event.clipboardData.getData('text/plain');
        } else if (window.clipboardData && window.clipboardData.getData) {
            text = window.clipboardData.getData('Text');
        }
        if (document.queryCommandSupported('insertText')) {
            document.execCommand('insertText', false, text);
        } else {
            document.execCommand('paste', false, text);
        }
    });

function textFormat (e) {
e.preventDefault()
var text
var clp = (e.originalEvent || e).clipboardData
if (clp === undefined || clp === null) {
  text = window.clipboardData.getData('text') || ''
  if (text !== '') {
    if (window.getSelection) {
      var newNode = document.createElement('span')
      newNode.innerHTML = text
      window.getSelection().getRangeAt(0).insertNode(newNode)
    } else {
      document.selection.createRange().pasteHTML(text)
    }
  }
} else {
  text = clp.getData('text/plain') || ''
  if (text !== '') {
    document.execCommand('insertText', false, text)
  }
}

}

  :
  document.getElementById('editArea').addEventListener('paste', function (e) {
    textFormat (e)
  })
  

reference: https://stackoverflow.com/que...
example: (may not open)
http://jsfiddle.net/ch6yn/

here is an example I wrote myself:


</div>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea3887-5ca7f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea3887-5ca7f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?