Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Editor / Stripping inline styles when using the Paste from Word button

Stripping inline styles when using the Paste from Word button

Article Info

Rating: Not rated

Article information

Article relates to

 RadEditor for ASP.NET AJAX
 Telerik.Web.UI

Created by

 Rumen Zhekov


HOW-TO
Stripping inline styles when using the Paste from Word or Paste from Word strip Font buttons

DESCRIPTION
The  Paste from Word icon is using the MSWord setting of the StripFormattingOptions property and the Paste from Word strip Font  icon is using the MSWordRemoveAll one. Both paste options strip only the Word formatting (mso- attributes and classes, <o:p> tags and other) without cleaning the inline styles. This means that the paragraph margins and other inline style settings will be untouched and this could spoil the appearance of the pasted content when it is displayed on the public site.

SOLUTION
To strip the inline styles when pasting content through the Paste From Word or Paste From Word strip Font use the following code that will fire the FormatStripper tool with a value of CSS, e.g.
<script type="text/javascript">   
function OnClientCommandExecuted(editor, args)   
{   
   if (!args || !args.get_commandName) return;   
   //The command name   
   var commandName = args.get_commandName();      
    
   var value = args.get_value();              
   
   if(commandName=="PasteFromWord" || commandName == "PasteFromWordNoFontsNoSizes")   
   {   
        editor.fire("FormatStripper", {value : "CSS"});   
   }   
}   
</script>   
   
<telerik:radeditor runat="server" ID="RadEditor1"   
    OnClientCommandExecuted="OnClientCommandExecuted">   
</telerik:radeditor>   

More information about the different Paste from Word features of RadEditor is available in this live example: Cleaning Word Formatting.

Comments

There are no comments yet.
If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.