繁体   English   中英

如何将多个CSS文件添加到CKEditor编辑器区域

[英]How to add multiple css files to CKEditor editorarea

我使用Ckeditor创建了一个小型mvc应用程序,该应用程序应使用存储在本地服务器上的一些CSS文件

<head>
<link href="http://fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/new/all.css?v=1" media="all" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/new/templates.css?v=1" media="all" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/pre_review/colors.css?v=1" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/pre_review/paged_test.css?v=2" media="paged" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/pre_review/bootstrap.min.css?v=1" media="all" rel="stylesheet" type="text/css" />
<link href="http://192.168.0.50/css/pre_review/main.css?v=1" rel="stylesheet" type="text/css" />
<style type="text/css">html { -ro-editable: true; }
</style>
</head>

在编辑器初始化时,我调用setData并传入带有html块的字符串,以将远程CSS文件应用于编辑器的内容。 但是,它们未正确应用

如果我将config.fullPage = true设置为,则html块将被放置在body标签之间,因此,如果用户足够按下Backspace键,则可以将其删除。

我也尝试设置config.fullPage = false,这可以很好地插入内容,但是会从块中剥离head标记,因此如果用户按退格键,也可以将其删除。

无论如何,有没有让这个html块专门放在头部,以便不能对其进行编辑?

我建议在ckeditor配置中使用config.contentsCss属性,以设置特定的CSS文件或CSS文件列表。 请参阅API文档: http : //docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-contentsCss

从4.4版开始,还可以在运行时使用editor.addContentsCss()将多个样式表添加到编辑器实例,请参见http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-addContentsCss更多信息。

愿消息来源与您同在。 玩得开心。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM