Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#10786 closed Bug (invalid)

CKEditor change Source Code formatting

Reported by: Xuân Hùng Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

I try to edit an article, this is what i see : https://lh6.googleusercontent.com/-x-0nx7nla5w/Uib89pnPyEI/AAAAAAAAAyU/iM5uwGl4_yg/w643-h231-no/1.png

This is a part of article content from database :

<h4>index.html</h4> 
<pre>
     &lt;div id=&quot;clock&quot; class=&quot;light&quot;&gt; 
</pre>

Problem is CKeditor formatted my source code to something like :

<h4>index.html</h4> 
<pre>
     <div id="clock" class="light"> 
</pre>

and this source code is disappeared. I tried :

config.protectedSource.push( /<pre[\s\S]*?\/pre>/g );

in config.js from https://drupal.org/node/803562 but it nothing change. Any ideas for this issue ?

Change History (2)

comment:1 Changed 6 years ago by Piotrek Koszuliński

Resolution: invalid
Status: newclosed

I loaded following HTML to the editor and switched between wysiwyg and source modes few times (to simulate getting and setting data), but everything worked fine.

This is what I load and get after few modes switches:

<h4>index.html</h4> 
<pre>
     &lt;div id=&quot;clock&quot; class=&quot;light&quot;&gt; 
</pre>

I guess that you're not encoding your HTML properly when setting it in textarea. Note that this HTML:

<textarea><pre>&lt;div&gt;</pre></textarea>

Will give you (e.g. from textareaElement.value):

'<pre><div></pre>'

So you should load:

<textarea>&lt;pre&gt;&amp;lt;div&amp;gt;&lt;/pre&gt;</textarea>

Which will give what you really want to load to the editor:

'<pre>&lt;div&gt;</pre>'

comment:2 in reply to:  1 Changed 6 years ago by Xuân Hùng

I tested again. Because of the way i load Ckeditor, so it can not encoding HTML properly. Thank you very much.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy