Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I append text to html source in CKEditor?


I use CKEditor in my web-application. By click on one link i appends some text to CKEditor. It works fine. But when I open source tab, i can not append this text to the existing source. Can you help me how can I do it? Thank you in advance. Sorry for my english.

like image 719
Alex Pliutau Avatar asked Feb 21 '11 09:02

Alex Pliutau


1 Answers

If you are trying to append HTML text, you could use the createFromHtml method like this for example:

var imgHtml = CKEDITOR.dom.element.createFromHtml("<img src=" + imageSrcUrl + " alt='' align='right'/>");

where imageSrcUrl is the image location and then you can insert it into the ckeditor source like this:

CKEDITOR.instances.body.insertElement(imgHtml);

There are other methods like insertHtml or insertText, you can check the CKEditor APIs for more details on these.

like image 99
Maricel Avatar answered Oct 14 '22 16:10

Maricel