<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager id="ScriptManager1" runat="server"/>

<telerik:RadEditor ID="RadEditor1" StripFormattingOptions="AllExceptNewLines" ToolsFile="~/HtmlTextBoxToolsFile.xml" OnClientLoad="editorLoaded" runat="server">
</telerik:RadEditor>
<script type="text/javascript">
    ReportingFilter = function () {
        ReportingFilter.initializeBase(this);
        this.set_isDom(false);
        this.set_enabled(true);
        this.set_name("ReportingFilter");
        this.set_description("Telerik Reporting HTML filter for RadEditor");
    }
    ReportingFilter.prototype =
{
    getHtmlContent: function (content) {
        return this._removeHtmlTags(content);
    },

    getDesignContent: function (content) {
        return this._removeHtmlTags(content);
    },

    _removeHtmlTags: function (initContent) {
        var cleanContent;

        //Perform necessary REGEX replacement to remove unsupported HTML tags
        //Supported Reporting HTML tags: FONT, STRONG, B, EM, I, U, A, OL, UL, LI, DIV, SPAN, P, BR, CENTER
        //HTML must be XHTML valid, too, but Editor already provides that filter

        //Following REGEX will remove all HTML tags EXCEPT those expliclitly listed
        cleanContent = initContent.replace(new RegExp("<(?!\/?(font|strong|b|em|(i(?!mg))|u|a|ol|ul|li|div|span|p|br|center)(?=>|\s?.*>))\/?.*?>", "ig"), "");

        return cleanContent;
    }
}
    ReportingFilter.registerClass('ReportingFilter', Telerik.Web.UI.Editor.Filter);

    function editorLoaded(editor, args) {
        editor.get_filtersManager().add(new ReportingFilter());
    }
</script>


    </form>
</body>
</html>
