Ryan Durrant
Ryan Durrant

Reputation: 1018

Stop Sitecore from including <p> and &nbsp in rich text editor

I just want text and hyperlinks, and not <p> tags. I have also had an issue when putting in a list, and each <li> gets a &nbsp put in front of it which is being recognized as a new paragraph.

Is there any way to stop the rich text editor from adding these in?

Upvotes: 0

Views: 1956

Answers (1)

JermDavis
JermDavis

Reputation: 1155

The Sitecore Rich Text Editor is configurable in a variety of ways. Internally it's an instance of the Telerik RAD Editor. Hence you can apply many of the same configuration strategies documented on Telerik's site to it.

A while back I wrote a blog post about how you can stop the editor form messing about with your HTML:

https://blog.jermdavis.dev/posts/2014/ever-wished-the-rich-text-field-didnt-mess-with-your-html

While that's not addressing your exact issue, the general strategy there for configuring the internal behaviour of the editor can probably be used to meet your requirements. The underlying editor has a series of filtering behaviours that you can enable and disable to help with your requirements. The "FixEnclosingP" and "ConvertCharactersToEntities" options might be of help here? They're documented on Telerik's website:

http://www.telerik.com/help/aspnet-ajax/t_telerik_web_ui_editorfilters.html

There are also other strategies, such as post-processing the HTML that's saved by the editor. Sitecore's SaveRichTextContent pipeline might be of help here? This blog post might offer you some ideas about how that can be used:

https://techmusingz.wordpress.com/2014/06/14/wrapping-rich-text-value-in-paragraph-tag-in-sitecore/

Upvotes: 2

Related Questions