How can I append text to html source in CKEditor?

后端 未结 2 1715
野的像风
野的像风 2021-02-15 20:44


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 te

2条回答
  •  走了就别回头了
    2021-02-15 21:21

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

    var imgHtml = CKEDITOR.dom.element.createFromHtml("");
    

    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.

提交回复
热议问题