RadEditor introduces a number of tools that help users paste formatted text from Microsoft Word or other applications, and apply different types of format stripping.

1. Strip Word-formatting on paste
The "Paste from Word"
button allows you to strip Word-specific tags from the text copied in the clipboard and
will paste it in RadEditor with a single click.
 |
Mozilla based browsers:
To protect users' private information, unprivileged scripts cannot invoke the Cut, Copy, and Paste commands in the Mozilla rich text editor, so the
corresponding buttons on the Mozilla Rich Text Editing demo page will not work.
|
 |
When Telerik RadEditor is used under Mozilla based browsers (Firefox, Mozilla) and
Safari on any of the paste events discussed in this article(steps 1-7), a new dialog window appears.
The text to be pasted is entered in this dialog. After the OK button is clicked, this text is added to the editor text area.
You can find more information on the topic in the following Mozilla article: Setting
Prefs for the Mozilla Rich Text Editing Demo.
|
2. Strip Word-formatting on paste (cleaning fonts and sizes)
The "Paste from Word, strip font" button
will clean all Word-specific tags and will remove font names and
text sizes, as they are rarely used in the web environment.
3. Forced format stripping on Paste
Developers can now enforce content formatting using the StripFormattingOptions property. As a result, format stripping will be applied to all content that
users are trying to paste. The EditorStripFormattingOptions enumeration can have any or a combination of the following values:
- None: pastes the clipboard content as is.
- NoneSupressCleanMessage: Doesn't strip anything on paste and does not ask questions.
- MSWord: strips Word-specific tags on Paste, preserving fonts and text sizes.
- MSWordNoFonts: strips Word-specific tags on Paste, preserving text sizes only.
- MSWordRemoveAll: strips Word-specific tag on Paste, removing both fonts and text sizes.
- Css: strips CSS styles on Paste.
- Font: strips Font tags on Paste.
- Span: strips Span tags on Paste.
- All: strips all HTML formatting and pastes plain text.
- AllExceptNewLines: Clears all tags except "br" and new lines (\n) on paste.
The example below demonstrates how to set multiple values for the StripFormattingOnPaste property.
| [ASP.NET] Setting StripFormattingOptions |
Copy Code |
|
<telerik:RadEditor
runat="server"
ID="RadEditor1"
StripFormattingOptions="NoneSupressCleanMessage,
Span">
</telerik:RadEditor>
|
| [C#] Setting StripFormattingOptions |
Copy Code |
|
protected void Page_Load(object sender, EventArgs e)
{
RadEditor1.StripFormattingOptions =
EditorStripFormattingOptions.Span |
EditorStripFormattingOptions.MSWordRemoveAll;
}
|
| [VB] Setting StripFormattingOptions |
Copy Code |
|
Protected Sub Page_Load(ByVal sender As
Object, ByVal e As EventArgs)
RadEditor1.StripFormattingOptions = EditorStripFormattingOptions.Span Or
EditorStripFormattingOptions.MSWordRemoveAll
End Sub
|
 |
The StripFormattingOptions property replaces the deprecated StripFormattingOnPaste property. |
4. Word Content in Clipboard Interception
In case the user is trying to paste Word content with the regular Paste button or Ctrl+V, a dialog will prompt whether the Word markup should be cleaned. If the Clipboard
content does not come from Word, the dialog will not be shown. This option is not valid in Firefox, due to browser limitations.
5. Strip Word-formatting after paste
As an alternative to the "Paste from Word" tool (item 1) you may paste the formatted content first and then strip it using the "Format Stripper" tool
.
6. Paste plain text
The "Paste Plain Text"
button works similarly to "Paste from Word"
, but removes all HTML formatting and pastes plain text, preserving the line breaks.
7. Paste as HTML
The "Paste as HTML" tool
allows you to paste the HTML content of the Clipboard as code, which may be quite
convenient for developer-oriented applications (e.g. support systems, forums, etc.) The pasted text will look something like this:
<IMG src=" radEditor-logo.gif"><BR><BR><FONT face="Arial"><STRONG>What's new </STRONG></FONT>
See Also