More in this section

Forums / Developing with Sitefinity / Generic content radeditor stripping word formatting

Generic content radeditor stripping word formatting

4 posts, 0 answered
  1. Adam
    Adam avatar
    33 posts
    Registered:
    23 Feb 2009
    17 Nov 2009
    Link to this post
    Hi,

    I tried following the article at http://www.sitefinitywatch.com/blog/09-04-/Cleaning_Pasted_Content_in_RadEditor.aspx, but could not get the format stripping to work. The template is mapped correctly.

    Thanks!

    Here's the template code:

    <%@ Control Language="C#" %>
    <div class="ctrlPropsGeneric">
    test mapped!!
    <telerik:RadEditor
        runat="server"
        ID="textEditor"
        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"    
        Skin="WebBlue"    
        NewLineBr="False"
        Height="360px"
        Width="98%" StripFormattingOnPaste="MSWordRemoveAll">
        <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
        <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
        <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
        <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
        <CssFiles>
            <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
        </CssFiles>
    </telerik:RadEditor>
    <script type="text/javascript">
        Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args) {
            var editorArgs = editor.getSelectedElement();
            if (!editorArgs.nodeName || typeof (editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                editorArgs = editor.getSelection();

            var myCallbackFunction = function(sender, args) {
                if (typeof (editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
                    args.parentNode.replaceChild(editorArgs, args);
                else {
                    var cloned = args.cloneNode(true);
                    var div = args.ownerDocument.createElement("DIV");
                    div.appendChild(cloned);
                    editorArgs.pasteHtml(div.innerHTML);
                }
            }
            var path = sf_AppRoot + 'Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx';
            editor.showExternalDialog(
       path,
       editorArgs,
       750,
       515,
       myCallbackFunction,
       null,
       'ImageLibraryDialog',
       true,
       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
       false,
       true)
        };

        Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args) {
            var editorArgs = editor.getSelectedElement();
            if (!editorArgs.nodeName || typeof (editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                editorArgs = editor.getSelection();

            var myCallbackFunction = function(sender, args) {
                if (typeof (editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                    args.parentNode.replaceChild(editorArgs, args);
                else {
                    var cloned = args.cloneNode(true);
                    var div = args.ownerDocument.createElement("DIV");
                    div.appendChild(cloned);
                    editorArgs.pasteHtml(div.innerHTML);
                }
            }
            var path = sf_AppRoot + 'Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx';
            editor.showExternalDialog(
       path,
       editorArgs,
       750,
       515,
       myCallbackFunction,
       null,
       'ImageLibraryDialog',
       false,
       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
       false,
       true)
        };

        Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args) {
            var editorArgs = editor.getSelectedElement();
            if (!editorArgs.nodeName || typeof (editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A") {
                var sel = editor.getSelection();
                editorArgs = sel;
                editorArgs.Html = sel.getHtml();
                editorArgs.Text = sel.getText();
            }

            var myCallbackFunction = function(sender, args) {
                if (typeof (editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                    args.parentNode.replaceChild(editorArgs, args);
                else {
                    var cloned = args.cloneNode(true);
                    var div = args.ownerDocument.createElement("DIV");
                    div.appendChild(cloned);
                    editorArgs.pasteHtml(div.innerHTML);
                }
            }
            var path = sf_AppRoot + 'Sitefinity/UserControls/Dialogs/LinksDialog.aspx';
            editor.showExternalDialog(
       path,
       editorArgs,
       750,
       515,
       myCallbackFunction,
       null,
       'ImageLibraryDialog',
       false,
       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
       false,
       true)
        };

        Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args) {
            var editorArgs = editor.getSelectedElement();
            if (!editorArgs.nodeName || typeof (editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                editorArgs = editor.getSelection();

            var myCallbackFunction = function(sender, args) {
                if (typeof (editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                    args.parentNode.replaceChild(editorArgs, args);
                else {
                    var cloned = args.cloneNode(true);
                    var div = args.ownerDocument.createElement("DIV");
                    div.appendChild(cloned);
                    editorArgs.pasteHtml(div.innerHTML);
                }
            }
            var path = sf_AppRoot + 'Sitefinity/UserControls/Dialogs/LinksDialog.aspx';
            editor.showExternalDialog(
       path,
       editorArgs,
       750,
       515,
       myCallbackFunction,
       null,
       'ImageLibraryDialog',
       false,
       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
       false,
       true)
        };

        RadEditorCommandList["IncreaseSize"] = function(commandName, editor, oTool) {
            var currentWidth = editor.get_element().style.width; //get the width of Telerik RadEditor
            var currentHeight = editor.get_element().style.height; //get the heigh of Telerik RadEditor

            editor.SetSize(currentWidth, currentHeight + 30); //set the height size of the editor to increase with 30px
        };

        RadEditorCommandList["DecreaseSize"] = function(commandName, editor, oTool) {
            var currentWidth = editor.get_element().style.width;
            var currentHeight = editor.get_element().style.height;

            editor.SetSize(currentWidth, currentHeight - 30); //set the height size of the editor to decrease with 30px
        };
        var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function

        Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args) {
            oldFunction(commandName, editor, args);
            var bd = document.getElementsByTagName("body")[0];

            if (/fullScreenMode/.test(bd.className)) {
                var rep = bd.className.match(' ' + 'fullScreenMode') ? ' ' + 'fullScreenMode' : 'fullScreenMode';
                bd.className = bd.className.replace(rep, '');

            } else {
                bd.className += bd.className ? ' ' + 'fullScreenMode' : 'fullScreenMode';
            }
        }
    </script>
    </div>
    <div class="footLinks">
        <p id="warningConainer" runat="server"><strong><asp:Literal ID="warning" runat="server"></asp:Literal></strong></p>
        <asp:LinkButton ID="ShareContent" CommandName="shareContent" runat="server" CssClass="share"></asp:LinkButton>
        <asp:LinkButton ID="SelectContent" CommandName="selectContent" runat="server" CssClass="select"></asp:LinkButton>
    </div>
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Nov 2009
    Link to this post
    Hello Adam,

    Thank you for using our services.

    Can you please tell us which exact version of Sitefinity you are using? I have tried the strip formatting property in Sitefinity 3.7 SP1, which uses the RadControls for ASP.NET AJAX 2009 Q2 SP1 and it works as expected. Here is the markup of my editor (note I also have content filters enabled):
    <telerik:RadEditor
    runat="server"
    ID="textEditor"
    ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
    ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"   
    Skin="WebBlue"   
    NewLineBr="False"
    Height="360px"
    Width="98%"
    AllowScripts="true"
    ContentFilters="FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent"
    StripFormattingOnPaste="MSWordRemoveAll">
    <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
    <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
    <FlashManager UploadPaths="~/Files" DeletePaths="~/Files" ViewPaths="~/Files" />
    <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
    <CssFiles>
    <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
    </CssFiles>      
    </telerik:RadEditor>

    Look at the screen shots attached as to what I am copy/pasting and the result. I am using the same text as in the sample. Bellow is the generated html in the editor:
    <p style="margin: 24pt 0in 0.0001pt; line-height: normal;"><strong>Title of the Page</strong><strong></strong></p>
    <p style="line-height: normal;">Sitefinity CMS is a <em>flexible</em> ASP.NET content management platform for the construction and management of commercial websites, community portals, intranets, and personal blogs. </p>


    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Adam
    Adam avatar
    33 posts
    Registered:
    23 Feb 2009
    19 Nov 2009
    Link to this post
    Hi,

    I'm using 3.6 sp1. I tried using the settings you suggested in this post, but I get all the formatting in the text now:

    For msword sample:

    Total Cholesterol

    What is total cholesterol?


    I get:

    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} Total Cholesterol What is total cholesterol?

    Here's my radeditor code in the template:

     test mapped1!!
        <telerik:RadEditor runat="server" ID="textEditor" ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
            ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml" Skin="WebBlue"
            NewLineBr="False" Height="360px" Width="98%" AllowScripts="true"
            ContentFilters="FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent"
            StripFormattingOnPaste="All">
            <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
            <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
            <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
            <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
            <CssFiles>
                <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
            </CssFiles>
        </telerik:RadEditor>



  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    20 Nov 2009
    Link to this post
    Hi Adam,

    Thank you for getting back to me.

    I have tried this in the version of Sitefinity that you are using, however to no avail. Word formatting is stripped when you use the template with the same settings from my previous post.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered