Rich Text editor - selecting <a>

Posted by Community Admin on 05-Aug-2018 20:59

Rich Text editor - selecting

All Replies

Posted by Community Admin on 12-May-2014 00:00

Hi-

My content editors want to be able to create "buttons". I have a css class set for these buttons. However, whenever they attempt to select the link and apply the class, the editor adds a span tag around the anchor tag. This makes it so that I cannot remove the text-decoration style because it is on the <a> not the <span>.

Is there a way to get the editor to apply the class to the link rather than add a span tag inside the anchor tag?

Posted by Community Admin on 13-May-2014 00:00

Hi Amanda,

I guess it would work as well if you could remove the span tag. I overwrite RenderBeginTag and RenderEndTag in my widgets to get rid of the span tag:

Public Overrides Sub RenderBeginTag(writer As HtmlTextWriter)
    ' This empty method prevents that the default RenderBeginTag renders a <span> tag wrapping around the control.
End Sub
 
Public Overrides Sub RenderEndTag(writer As HtmlTextWriter)
    ' This empty method prevents that the default RenderBeginTag renders a <span> tag wrapping around the control.
End Sub

Posted by Community Admin on 13-May-2014 00:00

@Amanda

  The RadEditor is amazingly fantastic...at ruining markup.  The only way to do it safely is to have them dump into HTML mode and edit it directly.

- OR -

Create a new thunder control that will render the button as you need it, and maybe contain a page selector and\or external url field.  This way they can just drop it on the page and set the place it goes to...and not screw anything up.

 @Arno
  ...do you mean around the entire simpleview control?  There is an easier way...

protected override void Render(System.Web.UI.HtmlTextWriter writer)
    this.RenderContents(writer);

Posted by Community Admin on 13-May-2014 00:00

Hi all,

The insertion of additional HTML elements is not caused by the Rad Editor itself, but by the filters applied to it in Sitefinity. You have the freedom of disabling them in order to preserve the markup you intend to. Simply go to Administration->Settings->Advanced->Appearance and replace the values of RadEditor filters for Content Block widget and RadEditor's filters for content from DefaultFilters to None. Make sure you restart your application in order for the changes to take effect.

Regards,
Ivan D. Dimitrov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 13-May-2014 00:00

@Ivan

...well I mean...it's still the RadEditor DOING it

 You can't deny its ability to epically ruin content, it's been doing it since SF4 was released.  Hell even your telerik.com backend ticket system goes all to hell if you try to paste in something or undo

Posted by Community Admin on 16-May-2014 00:00

@Steve

No argument there Steve. The editor does alter the markup and I imagine this is not desired by all of our customers. However this is useful when protecting against malicious users ( script injections for example)

Regards,
Ivan D. Dimitrov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 16-May-2014 00:00

Well the only public facing RadEditor is this one in the forums...right?  So in that case I can see your point.  However it's primarily used literally everywhere in the backend, and I'd like to see anyone whos happy with it.  Undo barely works, and if you get caught in borked content hell (like it nests a <h2> in a list or something) unless the user knows html to jump into that mode...you might as well just start from scratch.

 Remember this classic post?: www.sitefinity.com/.../radeditor-has-issues-when-i

I'm not knocking the engineering marvel OF the radeditor, I can't even fathom how complex it is to work with and maintain cross-browser...but I think it's now become TOO complex where it's borking more than it's helping.

Posted by Community Admin on 16-May-2014 00:00

I agree with Steve on this. The best feature of the editor is HTML mode, as that allows us to fix what has been damaged by the editor: span tags nobody asks for, text in a bullet list and no way to get it out of the list, no way (that I know of) to automatically convert URLs to actual a tags, etc, etc. We do use the forums module and I regularly have to edit posts of others because the markup is unacceptable. If they have copied text from somewhere it is a mess. In the backend we always use HTML mode. Sadly that saves us time. I do appreciate its complexity but there is a lot of room for improvement.

Posted by Community Admin on 16-May-2014 00:00

Ivan - Thank you for that suggestion, but I'm not sure I want to disable all filters just to take care of this one particular issue. I just wish there was an easy way to apply the CSS Class to the anchor tag instead of adding a new span.

Steve - I might just do your second suggestion. I'll show them how to do it in the code as well, but I can imagine they are going to complain about that. It's just too complex for some of our users. Thanks.

Posted by Community Admin on 21-May-2014 00:00

Hello all,

@Amanda,

The easiest way you can achieve this is by either adding inline style to your anchor tags or by setting style rules for all <a> tags in your page. These methods will not produce any additional markup in the RadEditor.

Regards,
Ivan D. Dimitrov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed