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

Underline in RadEditor and telerik reporting

2 Answers 246 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 08 Jan 2010, 10:40 PM
I am using RadEditor to create content for use in the HtmlTextBox report control. I have the following problem. The HtmlTextBox does not support <span style="text-decoration: underline;"> markup for underline and instead supports <u></u> but the RadEditor outputs <span style="text-decoration: underline;">. I assume this is because the RadEditor is XHTML compliant and the <u> tag is deprecated. Is there any workaround for this issue?  a content filter? a custom button?

Thanks,
Chris

2 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 11 Jan 2010, 11:40 AM
Hi Chris,

RadEditor's have FixUIBoldItalic built-in content filter enabled by default. This filter replaces old deprecated <u>, <em>, <b>, etc. tags with XHTML 1.1 compliant output.

In order to achieve the requested behavior you need to disable this content filter by setting the value of the ContentFilters property, e.g.:
<telerik:RadEditor ID="RadEditor1" ContentFilters="MakeUrlsAbsolute,FixEnclosingP"  runat="server" />

Additional information regarding content filters is available in the following help article:
Content Filters


Sincerely yours,
Dobromir
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.
0
Eric
Top achievements
Rank 1
answered on 19 Jan 2010, 07:34 PM
I created a custom filter to convert <span style="text-decoration: underline;"> to <u> so it will work with telerik reporting.

here is the code for anyone who is having similar issues:

<telerik:radeditor runat="server"ID="RadEditor1" OnClientLoad="OnClientLoad" ContentFilters="MakeUrlsAbsolute,FixEnclosingP">  
</telerik:radeditor>
                                <script type="text/javascript">
                                    function OnClientLoad(editor, args) {
                                        editor.get_filtersManager().add(new FixUnderline());
                                    }

                                    FixUnderline = function() {
                                    FixUnderline.initializeBase(this);
                                        this.IsDom = true;
                                        this.Enabled = true;
                                        this.Name = "FixUnderline";
                                        this.Description = "This filter changes CSS underline to u tag";
                                    };
                                    FixUnderline.prototype = { _getElements: function(a, c) {
                                        var b = a.getElementsByTagName(c);
                                        if (!b) {
                                            b = a.ownerDocument.getElementsByTagName(c);
                                        } return b;
                                    }, _replaceElementWithSpan: function(l, h, k) {
                                        var m = this._getElements(l, h);
                                        var d = [];
                                        for (var b = m.length - 1; b >= 0; b--) {
                                            Array.add(d, m[b]);
                                        } for (var a = 0, c = d.length; a < c; a++) {
                                            var e = l.ownerDocument.createElement("span");
                                            e.style.cssText = k;
                                            var f = d[a];
                                            var g = f.innerHTML;
                                            if ($telerik.isIE && g == " ") {
                                                e.innerText = g;
                                            } else {
                                                Telerik.Web.UI.Editor.Utils.setElementInnerHtml(e, g);
                                            } f.parentNode.replaceChild(e, f);
                                        }
                                    }, _replaceSpanWithElement: function(o, n, f) {
                                        var q = this._getElements(o, "span");
                                        var e = [];
                                        for (var b = q.length - 1; b >= 0; b--) {
                                            Array.add(e, q[b]);
                                        } for (var a = 0, c = e.length; a < c; a++) {
                                            var m = [];
                                            var g = e[a];
                                            for (var p = 0; p < g.childNodes.length; p++) {
                                                Array.add(m, g.childNodes[p].cloneNode(true));
                                            } if (g.style.cssText.toLowerCase() == f || g.style.cssText.toLowerCase() == (f + ";")) {
                                                var h = o.ownerDocument.createElement(n);
                                                for (var d = 0; d < m.length; d++) {
                                                    h.appendChild(m[d]);
                                                } g.parentNode.replaceChild(h, g);
                                            }
                                        }
                                    }, getHtmlContent: function(a) {
                                        this._replaceSpanWithElement(a, "u", "text-decoration: underline");
                                        return a;
                                    }, getDesignContent: function(a) {
                                        this._replaceElementWithSpan(a, "u", "text-decoration: underline");
                                        return a;
                                    }
                                    };
                                    FixUnderline.registerClass("FixUnderline", Telerik.Web.UI.Editor.Filter);
                                </script>

Tags
Editor
Asked by
Eric
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Eric
Top achievements
Rank 1
Share this question
or