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

ConvertToXhtml unable to disable for Code snippets

3 Answers 16 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 1
Nate asked on 09 Oct 2018, 05:51 PM

I am using RadEditor as part of sitecore 8.2  I have used the following Editor.DisableFilter(EditorFilters.ConvertToXhtml);  this works great if i type into the editor but if i use a code snippet the html is changed below is the example html i am using

This works fine if pasted into the html tab

<a href="#">
<h3>Title of Section</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
</a>     

3 Answers, 1 is accepted

Sort by
0
Nate
Top achievements
Rank 1
answered on 09 Oct 2018, 05:52 PM

Sorry it posted before ready

But if i use a Code snippet to insert the same code i end up with

<h3><a href="#">Title of Section</a></h3>
<p><a href="#">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </a></p>
0
Nate
Top achievements
Rank 1
answered on 09 Oct 2018, 05:53 PM

Sorry it Posted when i tried to hit enter for a new line

If I try to use a code snippet with the same example i get the following html

<h3><a href="#">Title of Section</a></h3>
<p><a href="#">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </a></p>
0
Marin Bratanov
Telerik team
answered on 11 Oct 2018, 12:54 PM
Hello Nate,

The templates actually paste content in the editor and that always has to go through some fixes for the content. They are mostly about nesting block elements, which is what affects this snippet - the heading and the paragraph are both block elements, while anchors are inline text elements by definition, and so, as far as the editor knows, the anchor should not be wrapping the block elements.

That said, I devised a workaround for you that is basically pasting the following line of JavaScript after the script manager. You can also find attached below a small runnable example of this.

Telerik.Web.UI.Editor.NestedElementsFix.prototype.applyFix = function () {}


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Nate
Top achievements
Rank 1
Answers by
Nate
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or