Hi, we have some very simple HTML that we're attempting to edit with CKE that seem to be getting corrupted.
<html> <head> <title>Blank</title> <style> .bw {color:white;background:navy;} </style> </head> <body> <span class='bw'>White text on blue</span> <p><span style='color:yellow;'>Yellow text in a paragraph</span></p> </body> </html>
If I add that to a text area, convert to ckeditor (I've tried with the latest 4.4.4 CDN version), then view source, I get the following:
<html> <head> </head> <body></body> </html> <title>Blank</title> <style type="text/css">.bw {color:white;background:navy;} </style> <p>White text on blue</p> <p>Yellow text in a paragraph</p>
As you can see its essentially emtpied the head and body tags and placed everything else after them. The page that loads it all is as follows:
<!DOCTYPE html> <html> <head> <title>blank</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=8"/> <script src="http://cdn.ckeditor.com/4.4.4/standard/ckeditor.js"></script> </head> <body> <form id="editForm" action="test.htm" method="post" accept-charset="UTF-8"> <textarea cols="80" id="Editor" name="Editor" rows="10"> <html> <head> <title>Blank</title> <style> .bw {color:white;background:navy;} </style> </head> <body> <span class='bw'>White text on blue</span> <p><span style='color:yellow;'>Yellow text in a paragraph</span></p> </body> </html> </textarea> </form> <script type="text/javascript">//<![CDATA[ editor = CKEDITOR.replace( 'Editor', { fullPage : true, }); editor.on(); //]]></script> </body> </html>
Thanks in advance
Mark
As you can see in the samples
As you can see in the samples, tags inside a textarea are converted to entities. If you are using PHP, try
<?PHP
$mysource = '<html><head>...</body></html>';
?>
<textarea>
<?PHP echo htmlspecialchars($mysource); ?>
</textarea>
I tried encoding the contents
I tried encoding the contents of the textarea but it made no difference, the results are still the same, re-ordered content.
OK it seems that it was the
OK it seems that it was the HTML file I was trying to edit, it had a strange character at the start of the file, in hex it was "20EFBBBF" which just looked like a space in an editor and the page displayed ok in all browsers (Chrome, FF, and IE).
BTW This is a real problem we have, I just cut down the original HTML file to the example above, the original file was quite big.
A bit more investigation and
A bit more investigation and it seems that it's a BOM character that had been added to the original UTF-8 encoded file, probably by something like notepad, if detect and I strip it out it works fine.