How to prevent CKEditor from stripping < and> (greater-than/less-than)

后端 未结 2 699
醉话见心
醉话见心 2021-01-12 19:23

Every time I enter < or > in a CKEditor window, save, and then come back to it, CKEditor replaces them with whatever was typed within the bra

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 19:50

    Yeah, this is a real pain.

    The only workaround I've found so far is to use

    CKEDITOR.instances.myInst.setData(myData);
    

    This actually handles escaped vs. unescaped html correctly, so your < and > will come out correctly, as less-than and greater-than signs, instead of being interpreted as markup.

    I haven't found a way to get this to work with inlined data yet. The setData() workaround is pretty clunky.

提交回复
热议问题