Return to doc.sitecore.com

Valid for Sitecore 5.2, 5.3
How do I force HTML clean up on pasting?

Q:

CSS driven website requires that no <fonr> tags are inserted during the editing. It would be nice to force this function instead of trying to explain the editors why they must run the clean up function every time.
How do I force HTML clean up on pasting?

A: 

The following steps should be performed in order to force HTML clean up on pasting from any source.

  1. Locate this file: \sitecore\shell\Editor\Sitecore\XHtml inline editor.html
     
  2. Add a singe line as it is shown in bold below: 

      <ce:editor ID="Editor" Runat="server"

        AutoConfigure="Full"

        AutoParseClasses="true"

        BorderWidth="0"

        DisableAutoFormatting="false"

        EnableStripScriptTags="false"

        FilesPath="/sitecore/Shell/Editor"

        Focus="false"

        FrameStyle="margin:0"

        Height="100%"

        ShowDecreaseButton="false"

        ShowEnlargeButton="false"

        ThemeType="Office2003"

        Width="100%"

        UseHTMLEntities="false"

        UseRelativeLinks="true"

        UseSimpleAmpersand="true"

        EditorOnPaste="PasteText">

      </ce:editor> 

Here are the other valid values for EditorOnPaste property (details provided by CuteSoft): 

Editor.EditorOnPaste Property

Specifies the manner in which the editor handles pasted text.  

PasteBehavior Enumeration

Enumerates the manners in which the editor handles pasted text.
Members:  

Member Name

Description

Default

When you paste text into the editor, it is not processed.

Disabled

Paste function is disabed.

PasteWord

When you paste content from Word into the editor, the non-required code that usually comes with pasting from Word is automatically cleaned up.

PasteText

When you paste text into the editor, all HTML formatting is stripped. This option is ideal for content management systems where you want absolute control over the formatting

ConfirmWord

When you paste content from Word into the editor, it will prompt users with a popup prompt to clean the non-required code.