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

What is the best way to override CSS Underline with Tag Underline

4 Answers 274 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 23 Feb 2010, 08:32 PM
I'd like to have the current underline tool button inject <U></U> instead of <span style="text-decoration:underline;"></span>. What is the best way to accomplish this? I tried setting the Commandlist["Underline"] to a custom function, but that didn't seem to help.

4 Answers, 1 is accepted

Sort by
0
Xorcist
Top achievements
Rank 1
answered on 23 Feb 2010, 08:54 PM
Using the OnClientCommandExecuting event doesn't seem to work either, it almost seems to be replacing my <U> tags with the CSS? Is the pasteHtml function doing that?!?! Using alerts I can clearly see the code is running as expected, yet I never get a single <U> tag.

          function OnClientCommandExecuting(editor, args) { 
            switch (args.get_commandName()) { 
            //Replace <span style="text-decoration:underline"> with <U> (for Report Compatibility) 
              case 'Underline'
                var selection = editor.getSelection(); 
                if (selection.getHtml() != '') { 
                  var element = editor.getSelectedElement(); 
                  if (element.tagName == 'U') { 
                    editor.pasteHtml(element.innerHTML); 
                  } else { 
                    editor.pasteHtml('<U>' + selection.getHtml() + '</U>'); 
                  } 
                } 
                args.set_cancel(true); 
                break
            } 
          } 

0
Xorcist
Top achievements
Rank 1
answered on 25 Feb 2010, 03:14 PM
Okay this is starting to get annoying. I've tried several different methods all of which have failed. Can someone give me a heads up? I need the <U> tag instead the CSS for the simple fact that your reporting tool does not support text-decoration:underlined in the HtmlTextBox... go figure. And I can't do a simple replace on <span style="text-decoration: underline;"> at a later point in time because apparently the RadEditor CSS stacks. So if someone where to both underline and color some text (not necessarily in that order) they'd end up with <span style="color: #ff0000; text-decoration: underline;">!
0
Xorcist
Top achievements
Rank 1
answered on 25 Feb 2010, 05:17 PM
Okay I finally figured out it was the ContentFilters (which I hadn't set to anything; so it defaulted at all) that was changing my <U> tags into CSS. Looks like I got this fixed... so that's the answer in case anyone else runs into a similar issue...
0
Dobromir
Telerik team
answered on 26 Feb 2010, 09:25 AM
Hi John,

Indeed, RadEditor has number of built-in content filters which modify the content in order to provide XHTML 1.1 compliant code. The FixUlBoldItalic filter is the one that replaces the deprecated <U> tag. You can disable this filter using the following code:
RadEditor1.DisableFilter(Telerik.Web.UI.EditorFilters.FixUlBoldItalic);

More information regarding built-in content filters is available in the following articles:
Content Filters
ContentFilters Property
Built-in Content Filters

Regards,
Dobromir
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Xorcist
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or