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

RadEditor: Getting RADEDITORSAVEDTAGENDING When Switching from HTML to Design

8 Answers 123 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 14 Jul 2008, 01:10 AM
Telerik.Web.UI
File Version: 2008.1.415.35
Product Version: 2008.01.0415.35

Hi, when switching from HTML to Design view, in a certain case, I get 'RADEDITORSAVEDTAGENDING'. I believe it has to do with a combination of the DTD, javascript, and "<!--", "//-->" characters.

In the declaration
  • ContentFilters="None".
In the code behind
  • radEditor.EnableFilter(EditorFilters.ConvertToXhtml);
  • radEditor.EnableFilter(EditorFilters.IndentHTMLContent);
This is what I have in HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
    <head> 
    <script> 
    <!-- 
    function foo(){ //v4.01 
        if(5>5){} 
    } 
    //--> 
    </script> 
    </head> 
    <body> 
    </body> 
</html> 

When you switch to Design, I got
5){} } //--RADEDITORSAVEDTAGENDING>


8 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 14 Jul 2008, 08:22 AM
Hi Gavin,

The observed behavior is due to the EncodeScriptsFilter content filter of RadEditor, which encodes all script tags from the content. Its purpose is to prevent the browser to modify and execute the script tags in Design mode. When switching to Html mode the script tag will be restored to its original text.

If you would like you can disable this filter with the following code:

<telerik:RadEditor ID="RadEditor1" onClientLoad="onClientLoad" runat="server" ></telerik:RadEditor>
<script type="text/javascript">
function onClientLoad (editor)
{
    var filter  = editor.get_filtersManager();
    filter.getFilterByName("EncodeScriptsFilter").Enabled = false;
}
</script>

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Gavin
Top achievements
Rank 1
answered on 14 Jul 2008, 04:25 PM

Hi Rumen,

Thanks, it solves this specific problem.

Unfortunately, it doesn't solve the general problem. I really would like the EncodeScriptsFilter feature AND also for the RADEDITORSAVEDTAGENDING tag not to be added since the javascript looks pretty standard.

So really, my question is whether this is a bug that will be fixed in the future or this is expected behavior and anybody who doesn't want to have the RADEDITORSAVEDTAGENDING tag must also not have the EncodeScriptsFilter feature.

Thanks,
Gavin
0
Gavin
Top achievements
Rank 1
answered on 14 Jul 2008, 04:58 PM

Hi Rumen,

Unfortunately, upon further testing, the proposed solution might not work.

I hooked up the OnClientLoad and did this in my Page_Load:
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!Page.IsPostBack)  
        {  
            radEditor.EnableFilter(EditorFilters.ConvertToXhtml);  
            radEditor.EnableFilter(EditorFilters.IndentHTMLContent);  
 
            radEditor.Content =  
                "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> " +  
                "<html><head><script> <!-- function foo(){ //v4.01 if(5>5){} } //--> </script> </head> <body> </body> </html> ";  
 
        }  
    } 

When the editor is loaded, the same "RADEDITORSAVEDTAGENDING> " error appears. It does seem that the filter has already been applied when I assigned to radEditor.Content. Thus, disabling it in OnClientLoad is too late.

Gavin
0
Rumen
Telerik team
answered on 16 Jul 2008, 12:26 PM
Hi Gavin,

My suggestion is to set a small timeout after the editor load and disable EncodeScriptsFilter filter, e.g.

ASPX:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<telerik:RadEditor ID="RadEditor1" onClientLoad="onClientLoad" runat="server" ></telerik:RadEditor>
<script type="text/javascript">
function onClientLoad (editor)
{
    setTimeout(function()
    {

        var filter  = editor.get_filtersManager();
        filter.getFilterByName("EncodeScriptsFilter").Enabled = false;
    }, 1300);
}
</script>

Codebehind:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadEditor1.EnableFilter(EditorFilters.ConvertToXhtml);
            RadEditor1.EnableFilter(EditorFilters.IndentHTMLContent);
            RadEditor1.DisableFilter(EditorFilters.RemoveScripts);

            RadEditor1.Content =
                  "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> " +
                "<html><head><script> <!-- function foo(){ //v4.01 if(5>5){} } //--> </script> </head> <body> </body> </html> ";

        } 
    }


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Gavin
Top achievements
Rank 1
answered on 16 Jul 2008, 08:21 PM

Hi Rumen,

I tried that and it didn't work for this test case.

Actually, I'm not sure why it should work. I thought the problem is that we're not disabling the 'EncodeScriptsFilter' fast enough. I'm not sure how disabling it later would help. I know I'm probably missing something but could you explain the rationale behind setting the timeout?

Thanks.

Gavin
0
Accepted
Rumen
Telerik team
answered on 21 Jul 2008, 12:12 PM
Hi Gavin,

Indeed, I agree with you that the provided code does not work as expected in your scenario. The only possible way to disable the EncodeScriptsFilter filter is to copy and paste the Scripts folder to your web application root, open the Scripts\Editor\RadEditor.js file and set the Enabled property of the Telerik.Web.UI.Editor.EncodeScriptsFilter function to false, e.g.

Telerik.Web.UI.Editor.EncodeScriptsFilter=function(){
Telerik.Web.UI.Editor.EncodeScriptsFilter.initializeBase(this);
this.IsDom=false;
this.Enabled=false;
this.Name="EncodeScriptsFilter";
this.Description="This filter encodes all script tags from the content.";
};

After that configure the editor to read its script files from the Script folder by setting  EnableEmbeddedScripts="false" and importing the external scripts paths:

    <asp:ScriptManager ID="ScriptManager" runat="server" >
        <Scripts>
           <asp:ScriptReference Path="~/Scripts/Common/Core.js" />
           <asp:ScriptReference Path="~/Scripts/Common/PopUp/PopUpScripts.js" />          
           <asp:ScriptReference Path="~/Scripts/Editor/RadEditor.js" />
           <asp:ScriptReference Path="~/Scripts/Dialogs/DialogOpener.js" />
           <asp:ScriptReference Path="~/Scripts/Editor/Modules.js" />         
           <asp:ScriptReference Path="~/Scripts/Spell/SpellCheckService.js" />
           <asp:ScriptReference Path="~/Scripts/Editor/AjaxSpellCheck.js" />
           <asp:ScriptReference Path="~/Scripts/Window/RadWindow.js" />
        </Scripts>

    </asp:ScriptManager>
<telerik:RadEditor ID="RadEditor1" EnableEmbeddedScripts="false" runat="server"></telerik:RadEditor>

For your convenience I have attached my test project.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Gavin
Top achievements
Rank 1
answered on 23 Jul 2008, 09:40 PM

Hi Rumen,

Thanks, it works.

I must say though that this is a little hackish and we still lose the useful 'EncodeScriptsFilter' functionality. I hope that in future versions, Telerik will improve on the javascript parsing so that such an operation is not needed.

Gavin
0
Rumen
Telerik team
answered on 24 Jul 2008, 07:34 AM
Hi Gavin,

I agree with you and I would propose the following solution which will help you to override the EncodeScriptsFilter filter:

<telerik:RadEditor ID="RadEditor1"  runat="server" ></telerik:RadEditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.EncodeScriptsFilter.prototype.getHtmlContent = function(content)
{
        return content;
};
Telerik.Web.UI.Editor.EncodeScriptsFilter.prototype.getDesignContent = function(content)
{
        return content;
};
</script>
<button onclick="alert($find('RadEditor1').get_html(true));return false">Show Content</button>


I also talked with out developers and we decided to provide the ability to disable the EncodeScriptsFilter filter using the DisableFilter method:

RadEditor1.DisableFilter(EditorFilters.EncodeScriptsFilter);

Most likely this feature will appear in the upcoming Q2 2008 SP1 release of Telerik.Web.UI.dll.

Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Gavin
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Gavin
Top achievements
Rank 1
Share this question
or