CKEditor: Class or ID for editor body

后端 未结 7 1602
深忆病人
深忆病人 2020-12-03 18:10

I have an instance of CKEditor on a page. I am trying to give the CKEditor\'s body a class or ID so it matches some styles I have defined in a stylesheet.

There is a

7条回答
  •  情书的邮戳
    2020-12-03 18:23

    If you are talking about CKEditor( version 3), then there is a possibility to get any DOM instance inside the editor itself. Every CKEditor instance has reference to it's document via "document" property.

    var documentWrapper = edit.document; 
    

    This reference represent some public wrapper for all CKEditor nodes, but it also has the direct reference to its node. You can retrieve by getting ["$"] property.

    var documentNode = documentWrapper.$; // or documentWrapper['$'] ;
    

    documentNode will represent the DOM instance of the document node inside the iframe. After you have the DOM instance, you can do whatever you want to do with DOM structure, Append, remove, replace classes, rebuild, etc. For example

    documentNode.body.className = "zork";
    

    I hope this should be enough.

提交回复
热议问题