①从百度上下载一个 ckeditor 行距包,解压放到ckeditor/plugins目录下。
②在config.js 中添加
config.extraPlugins += (config.extraPlugins ? ',lineheight' : 'lineheight');//行距③(转载)
config.allowedContent = true; //加这个是为了不让span标签被ckeditor过滤掉,如果加了的话就不需要再加
CKEDITOR.plugins.add('lineheight', { lang: ['zh-cn'], requires : [ 'richcombo', 'styles'], init : function( editor ) .......
中的requires: ['rechcombo', 'styles'] 改为: requires: ['rechcombo']
Uncaught TypeError: Cannot read property 'editor' of undefined
editor.ui.addRichCombo( comboName, {label : lang.label,title: lang.panelTitle,className: 'cke_' + (styleType == 'size' ? 'fontSize' : 'font'),panel :{css : editor.skin.editor.css.concat( config.contentsCss ),multiSelect : false,attributes: { 'aria-label': lang.panelTitle }}, init : function(){ .......
css: [CKEDITOR.skin.getPath("editor")].concat( config.contentsCss ),
editor.ui.addRichCombo( comboName,{label : lang.label,title: lang.panelTitle,className: 'cke_' + (styleType == 'size' ? 'fontSize' : 'font'),panel :{css : [CKEDITOR.skin.getPath("editor")].concat( config.contentsCss ),multiSelect : false,attributes: { 'aria-label': lang.panelTitle }}, init : function(){this.startGroup( lang.panelTitle );
改为:
editor.ui.addRichCombo( comboName,{label : lang.lineheight.label,title: lang.lineheight.panelTitle,className: 'cke_' + (styleType == 'size' ? 'fontSize' : 'font'),panel :{css : [CKEDITOR.skin.getPath("editor")].concat( config.contentsCss ),multiSelect : false,attributes: { 'aria-label': lang.lineheight.panelTitle }}, init : function(){this.startGroup( lang.lineheight.panelTitle );
4.这样就完成了所有的配置了,当然如果想额外添加一些行距设置项,可以在/lineheight/plugin.js中添加,具体位置:
CKEDITOR.config.lineheight_sizes = 'normal;1.5em;1.75em;2em;3em;4em;5em;100%;120%;130%;150%;170%;180%;190%;200%;220%;250%;300%;400%;500%';
看到这个配置,你就会发现,这只是这个行距插件的默认配置值 ,那么如果要添加一些行距元素的话,可以在ckeditor的config.js中添加:
CKEDITOR.config.lineheight_sizes = CKEDITOR.config.lineheight_sizes + ’你添加的行距元素‘;
二、添加中文字体
打开CKeditor目录里的config.js,在
CKEDITOR.editorConfig = function( config )
{
};
里添加如下代码:
config.font_names='宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;'+ config.font_names;
以后使用的时候就可以用中文字体了。(注意,保存这个js文件的时候必须utf8,不然字体显示会是乱码)
文章转载自http://www.it610.com/article/4654053.htm
怕以后设置的时候忘记,故做个记录,希望能帮助到网友