I have a contentEditable Div and I want remove any formatting especially for copy and paste text.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
You can't access the system clipboard so you'll need a hack. See this question: JavaScript get clipboard data on paste event (Cross browser)
It is simple: add a listener to the "paste" event and reeformat clipboard contents.
Here another example for all containers in the body:
Saludos.
With Jquery you can use .text() method, so, when blur for example you can replace the content with the text content
I'd like to add my solution to this issue:
(this isn't compatible with older versions of IE)
I know it's been a while, but I had the same problem. On my case, it's a GWT application to make it even worse. Anyway, resolved the problem with:
See: https://jsfiddle.net/erikwoods/Ee3yC/
I preffered "inserttext" command instead of "insertHTML", because the documentation says it's exactly to insert plain text, so seems more suitable. See https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand