首页 文章

单击外部按钮时将代码添加到CKeditor中

提问于
浏览
2

这是场景:用户输入CKeditor,在编辑器外面有一个按钮,当按下jQuery踢入$(“ . button”)时 . 单击(函数...并且这会附加一些文本或由按钮进入用户在CKeditor中键入的相同位置 .

如果有可能,有没有人有任何想法?

1 回答

  • 2

    可能而且简单 .

    CKEDITOR.instances.editor1.insertText("Magical ponies await!")
    CKEDITOR.instances.editor1.insertHtml("<hr/>");
    

    获取编辑器的参考是微不足道的(我希望) . 此示例适用于官方CKEditor演示 .

    CKEditor 4 API有很好的文档记录 . 请参阅http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertHtml的文档 insertHtml()


    此外,必须在CKEditor的高级内容过滤器功能中允许您添加的内容 . 请参阅http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter的文档

    如果您不关心ACF并且只是希望一切正常,则可以通过将配置值设置为 true 并使用 config.allowedContent = true; 来设置ACF配置以允许所有内容 .

相关问题