Editor Bug

Topics: Troubleshooting, Visual editor
Apr 13, 2011 at 2:41 PM

I found a bug with the editor during inserting HTML code (version Composite C1 2.1). 

Hereunder the sequence to reproduce the error.

1) Insert the html code in "source mode"

<html xmlns="http://www.w3.org/1999/xhtml">
  <head></head>
  <body>
    <div class="white-box">
      <div class="vertical-box">1</div>
      <div class="vertical-box">2</div>
      <div class="white-box-bot"></div>
    </div>
    <div class="white-box">
      <div class="vertical-box">3</div>
      <div class="vertical-box">4</div>
      <div class="white-box-bot"></div>
    </div>
  </body>
</html>

2) Click on Visual

3) Click on Source.
The code has been changed with the DIV in a difference position from the original version

<html xmlns="http://www.w3.org/1999/xhtml">
  <head></head>
  <body>
    <div class="white-box">
      <div class="vertical-box">1</div>
      <div class="vertical-box">2</div>
      <div class="white-box-bot">
        <div class="white-box">
          <div class="vertical-box">3</div>
          <div class="vertical-box">4</div>
          <div class="white-box-bot" />
        </div>
      </div>
    </div>
  </body>
</html>

Workaround:

Never put empty <DIV></DIV>

<div>&#160;</div>

Apr 13, 2011 at 2:59 PM

It seems like C1 is not the only one stripping out empty divs http://wordpress.org/support/topic/how-to-stop-wp-stripping-out-empty-div-tags :) Its a good thumbrule anyway never to use empty divs though, since some browsers (mainly old IE6), and WYSIWYG editors :), does weird things with them.

It's clearly an error as well that one of the divs are changed into a self-enclosing tag, since that wont validate with W3 since div's are not self-enclosed like br or img.

Coordinator
Apr 13, 2011 at 10:05 PM

We're using Tidy.NET library for converting html -> xhtml, and the conversion isn't always perfect. Later on I'll try Html Agility Pack, if it supports html5 and good enough, using it may solve the issue

Apr 14, 2011 at 12:32 AM

The template I am working on is not mine and it's very complex with a lot a stuff for IE6 compatibility.
Anyway I was pointing out the problem just for help the development.

We are very happy with Composite and ready for the first deploy  on the Azure Platform.

The only problems are about the editor with small bugs that a can reproduce.

For example for the following one I don't have a workaround.

1) I want to display a code snipped in my page.

2) Click on Source and copy the formatted snipped using a <PRE> tag

<html xmlns="http://www.w3.org/1999/xhtml">
  <head></head>
  <body>

<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">namespace</span> Demo
{
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> InlineMethodFunction
  {
    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> MyEmptyMethod()
    {
      <span class="kwrd">return</span> <span class="kwrd">true</span>;
    }
  }
}</pre>
  
    
</body>
</html>

3) Click on Visual and click back on Source: no more formatting! And it get worse every time you switch between Visual and Source (adding more <br />)

<html xmlns="http://www.w3.org/1999/xhtml">
  <head></head>
  <body>
    <pre class="csharpcode">
  <span class="kwrd">using</span> System;
<br /><span class="kwrd">namespace</span> Demo
<br />
{
<br /><span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">class</span> InlineMethodFunction
<br />
  {
<br /><span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">bool</span> MyEmptyMethod()
<br />
    {
<br /><span class="kwrd">return</span><span class="kwrd">true</span>;
<br />
    }
<br />
  }
<br />
}</pre>
  </body>
</html>

 

Coordinator
Apr 14, 2011 at 12:42 AM

@softgens I'm sorry to hear you are running into these issues. We will process these and prioritize it - a big thanks for the good repro info.

I can't give you an estimate on when we have a fix released, but I could perhaps offer something better. It looks like you are formatting C# code and we have a C1 Function running at our docs site (like http://docs.composite.net/C1/ASP-NET/Composite-C1-API/Update-Data.aspx ) where you paste in the raw C# code and it is then formatted when rendered - we could look into packaging this and making it available to you (?)

Apr 14, 2011 at 1:36 AM

Thank you for the offer but the example was about the <PRE> tag.
I cut/paste the code from your site because I was just wondering which was the trick!

But probably you can give me an information to solve other problems with the editor.

I don't have problems saving the document but during the switch between Source and Visual. 

For other issues I create an XSLT function because in this way the editor must not deal with html code it has problem with.

It's possible to have a function with only one parameter in raw format?

In this way everybody can deal non only with editor issues but also with non valid HTML code that of course you cannot change.

I give some real life examples: Code for embedding Microsoft Video, Tradedoubler scripts, Adsense scripts, Social widget...

Thank you again

 

Dec 15, 2016 at 12:40 PM
Hello everyone. I have similar bug on the editor. I'm using orchestra CMS and i'm installing new updates. So my question is: do i can to add this solution to prevent empty divs appearance? Is this solution is suitable for problem when divs with &nbsp of 160 appears? And will it be normally updated if a change config file of visual editor? Thank you for your fast reply.