I’m trying to strip MS Word formatting on a paste into a Telerik RadEditer. Unfortunately I can’t seem to get the built in format stripper to work.
//performing paste
var editor = $find("radEditor1");
editor.setFocus();
var rng = editor.getSelection().getRange();
rng.execCommand("Paste", null, false);
//does nothing! (even when uncommented)
//editor.fire("FormatStripper", {value: "MSWordRemoveAll" });
So I figure I could leverge jQuery to string all the attributes out of the tags and that may just do exactly what I need.
//fixing content
var html = editor.get_html();
$("*", html).each(function(){
var attr = $.map(this.attributes, function(item){
return item.name;
});
var node = $(this);
$.each(attr, function(i, item){
//added a filter for crazy Error
if(item != "dataSrc" &&
item != "implementation" &&
item != "dataFld" &&
item != "dataFormatAs" &&
item != "nofocusrect" &&
item != "dateTime" &&
item != "cite")
node.removeAttr(item);
});
});
editor.set_html(html);
Now after this function completes my html variable does not have it’s html updated…
I think I have it.
http://jsfiddle.net/duC6Z/8/
Unfortunately I’m still having issues with my RadEditor but that is normal.