向 CKEditor 添加自定义样式
我最近将 CKEditor 添加到我的应用程序中,我想在编辑器中包含我自己的 CSS 样式表,以便我可以在编辑器中选择它们。
我该如何实现这个目标?到目前为止我的代码如下所示:
<script type="text/javascript">
CKEDITOR.replace( 'editor1',{
uiColor : '#9AB8F3',
});
</script>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您还可以阅读
stylesSet.add
语法的完整文档:You can also read the full documentation of the
stylesSet.add
syntax:这对我有用
This works for me
正如已经提到的,有一个页面解释了如何设置一组自定义样式。该页面上隐藏的小宝石(并不是很清楚)是,您可以在配置中内联定义样式,而不是创建一组命名样式,如下所示:
As has already been mentioned, there is a page explaining how to set up a set of custom styles. What the little gem hidden on that page (and not really clear) is that rather than creating a named set of styles, you can define the styles inline in your configuration, like this:
最好的方法是使用这个插件: http://ckeditor.com/addon/stylesheetparser
粘贴进去'ckeditor/plugins' 目录,然后在你的 'ckeditor/config.js' 中包含类似的内容:
其中 '/css/inline-text-styles.css' 是你的 webroot 中你自己的 css 文件夹的路径,位于ckeditor。这样您就不必将 css 与 javascript 混合在一起。
The best way is to use this plugin: http://ckeditor.com/addon/stylesheetparser
Paste it inside the 'ckeditor/plugins' directory, then include something like this in your 'ckeditor/config.js':
Where '/css/inline-text-styles.css' is a path to your own css folder in your webroot, outside of ckeditor. That saves you having to mix css with javascript.
有点晚了,但默认样式位于
_source/plugins/styles/styles/default.js
中。您可以使用它作为样式配置并添加样式,它将有效地附加。Little late to the party here, but the default styles are in
_source/plugins/styles/styles/default.js
. You could use that as your style config and add styles and it would effectively be appending.请查看 @metavida 答案以获得比这更好的答案
不过,如果您在多个地方使用它,最好将其放入 stylescombo\styles\default.js 中文件并根据 api 相应地更新您的 config.js 文件。
Please look at @metavida answer for a better answer than this
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.