向CKEditor添加自定义样式 [英] Adding custom styles to CKEditor

查看:1663
本文介绍了向CKEditor添加自定义样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的应用程序中添加了CKEditor,我想在编辑器中包含我自己的CSS样式表,以便我可以在编辑器中选择它们。

I recently added CKEditor to my app and I would like to include my own CSS stylesheets within the editor so that I can select them within the editor.

如何我做到了吗?到目前为止,我的代码如下:

How do I accomplish this? My code so far looks like this:

<script type="text/javascript">

    CKEDITOR.replace( 'editor1',{
        uiColor : '#9AB8F3',
    });

</script>


推荐答案

请参阅@metavida answer for a比这更好的答案

<script type="text/javascript">

    CKEDITOR.replace( 'editor1',{

          uiColor : '#9AB8F3',
          stylesSet.add('default', [
               { name: 'My Custom Block', element: 'h3', styles: { color: 'Blue'} },
               { name: 'My Custom inline style', element: 'q'}
          ]);    
    });

</script>

虽然如果你在不止一个地方使用它,这进入stylescombo\styles\default.js文件,并根据api相应地更新你的config.js文件。

Though if you're using this in more than one place it'd be best to look at putting this into the stylescombo\styles\default.js file and updating your config.js file accordingly as per api.

这篇关于向CKEditor添加自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆