Convert HTML to plain text in contentEditable

后端 未结 4 1971
忘了有多久
忘了有多久 2021-02-07 07:10

I have a contentEditable and I strip the formatting of pasted content on(\'paste\') by catching the event. Then I focus a textarea, paste the content i

4条回答
  •  忘掉有多难
    2021-02-07 07:54

    The solution I used is to set the innerText of the element on blur:

    $element.on('blur', () => this.innerText = this.innerText);

    This keeps the whitespace, but strips the formatting. It may work acceptable in your scenario as well.

提交回复
热议问题