This is a migrated thread and some comments may be shown as answers.

Custom formatting of pasted content

3 Answers 118 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mac P
Top achievements
Rank 1
Mac P asked on 15 Jun 2010, 04:58 PM
Hello experts,

Does editor control support custom formatting of pasted content (can be html from website or ms word or pdf)?
The requirement is that i want to change the entire content to have font of verdana 9 and fore color black and back color white irrespective of what that was pasted in the editor while retaining all other formats.

The content saved to database will eventually go in word 2010 as office open XML format. 

Regards
Mac

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 16 Jun 2010, 09:59 AM
Hi Mac,

Let me provide you with more details what is happening. The paste process is controlled entirely by the Operating System and by the browser. The editor is not allowed to interfere in this process much (of course there are some minor differences between browsers). Thus, with respect to pasting - the original MS Word formatting is not HTML. It is MS Word specific XML formatting. When this is exported to the clipboard, and is made available for paste, it "announces" what "paste flavors" it supports - and those would be MS Word, HTML, plain text, RTF and so on. When a client entity (such as the editor) wants to consume the content of the clipboard, it announces what paste formats it supports (and the editor - any editor - only supports plain text and HTML). So, MS Word converts the original MS Word to HTML, and this process is controlled entirely by MS Word, and not at all possible to interfere by the editor.

What you can do is to attach to the OnClientPasteHtml event, check for the Paste command and modify the content returned by the args.get_value() method as per your requirements. After that set the modified content in RadEditor using the args.set_value(newContent) method.

Another approach is to set StripFormattingOptions="AllExceptNewLines" which will paste plain text in RadEditor. Once you obtain the RadEditor's content on the server you can wrap it in <span style="font-family: Verdana; font-size: 9pt;"></span>.

RadEditor is a web editor which can work and export HTML/XHTML content. If you need to store the content in MS Word doc / docx or XML format then you should use some third party control that will convert the HTML to DOCX XML format. This feature is not supported out-of-the box by the control.

We are currently working on export to RTF but it is currently not so enhanced, has limitations and does not offer image import or export. You can test it in this demo: Export to RTF.



All the best,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Samantha
Top achievements
Rank 1
answered on 26 Apr 2011, 11:12 AM

HI There, 

We do the following: 

OnPaste 
we are perform the following action Enabling/firing RadEditor "PasteFromWordNoFontsNoSizes" property.  This property cleans all Word-specific tags and removes font names and text sizes.
 
And in OnClientPasteHtml event we remove all the Header tags such as <H1>, <H2>, <H3> etc...from the pasted content.

We then style the resultant text to make sure users don't break branding. 

We are having a problem with a user who is using WinXP, Office 2007 & IE8. She pastes into the system, and nothing is stripped at all. We have the exact same set up (browser and version of MSword) and cannot recreate. We think it must be to do with the operating system. Can you shed any light at all? 

Many many thanks in advance. Your replies have been so helpful as I educate myself more about this issue. 

0
Rumen
Telerik team
answered on 29 Apr 2011, 07:56 AM
Hi Mac,

The first and most important thing to check is that the Paste from Clipboard is allowed in the Internet Explorer 8 settings: Tools -> Internet Options -> Security -> Custom Level -> Allow Programmatic clipboard access. It should be enabled, because in other case we will be unable to access the cliboard content and provide a programmatic way to modify it.

Could you please also ask your client whether she has allowed the clipboard paste operation when the "Do you want to allow this webpage to access your clipboard" warning dialog popped up?

Here is a screenshot of the dialog which loads when the users paste content from the clipboard from the first time: http://screencast.com/t/mP0ogZrW

Please, also ensure that all latest Internet Explorer 8 patches are installed as well as all add-ons, clipboards monitoring and antivirus programs are disabled when performing the paste test.

Best regards,
Rumen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Editor
Asked by
Mac P
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Samantha
Top achievements
Rank 1
Share this question
or