Reputation: 670
I use CKEditor to insert some content in 'wysiwyg' mode. I input "Hello World!" in the editor, and the real context inserted into database is
"<p>Hello World!</p>".
Now I load the data from database and set it into CKEditor:
String content = loadFromDb();
// --> <p>Hello, world!</p>
CKEditor.instances['test'].setData(content);
But in the CKEditor, it shows:
<p>Hello, world!</p>
in 'wysiwyg' mode. When I click 'source' button, it shows:
<p> <p&rt;Hello, world!</p></p>
How can I set the data as html code, and I can see only "Hello, world!" in CKEditor on 'wysiwyg' mode?
Do I need to use some type of Html encoder?
PS: I have reposted this question because no one answered it in 2012 and it was very important for me to get the answer for this.
Upvotes: 0
Views: 3570
Reputation: 1080
You could use the insertHtml
function.
CKEDITOR.instances.editor1.insertHtml( '<p>Hello, world!</p>' );
The documentation can be found here
Upvotes: 1