Friday, January 13, 2012

Remove format copy paste text editor

Share/Save/Bookmark
How do i avoid the formatting that comes along when i copy paste is done from a site or word document to the Rich Text Editor (RTE) field in sharepoint? Ofcourse RTE already have an option Clear Formatting that can be used to clear after pasting the content,, but i do not want the format to be copied at first. So after digging into SP.UI.RTE.js and googling i have come up with some script that will fulfill my needs.

function disableMarkupPasteForRTE()
{

Type.registerNamespace("RTE");
if (RTE)
{

if(RTE.RichTextEditor != null)
{
     RTE.RichTextEditor.paste = function() { RTE.Cursor.paste(true); }

     // Set Ctrl+V Flag

     RTE.Cursor.$3C_0 = true;
}
}
}

I used the below standard sharepoint javascript function that will run the above or any javascript function on load of page


_spBodyOnLoadFunctionNames.push("disableMarkupPasteForRTE");



 Subscribe

No comments:

Post a Comment