EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: joe on April 20, 2018, 09:31:30 PM



Title: TextEditor - Remove html code on paste.
Post by: joe on April 20, 2018, 09:31:30 PM
I am using the texteditor extension.  Is it possible to remove all html/rich text on a paste?


Title: Re: TextEditor - Remove html code on paste.
Post by: jarry on April 23, 2018, 01:45:16 AM
Disable the 'paste' event and retrieve the text from the clipboard, call the 'insertContent' method to insert the plain text into the texteditor component.
Code:
$('#te').bind('paste', function(e){
var text = e.originalEvent.clipboardData.getData('text');
$(this).texteditor('insertContent', '<span>'+text+'</span>');
return false;
});