ckeditor默认首行缩进是margin。是整段缩进、解决问题的核心是text-indent:2em
解决首行缩进
修改源码,然后让他变成上面的代码,这样点击缩进的时候就是text-indent:2em
打开ckeditor.js
文件,使用ctrl+f
进行搜索。
d.config.indentOffset||40 将40修改为2
d.config.indentUnit||"px" 将px修改为em
b.getComputedStyle("direction"))?"margin-left":"margin-right"} 将"margin-left":"margin-right"修改为"text-indent":"text-indent"
修改完成后、页面配置加上
CKEDITOR.config.extraAllowedContent = 'p{text-indent}';
网上有人说用这个config.allowedContent = true;
但是配置后期他也不会被过滤
上传文件的配置
由于插件更新以前默认上传的方式是form表单、现在默认方式为ajax
<script>
// CKEDITOR.config.filebrowserImageUploadUrl = "/admin/article/itArticle_img";
// CKEDITOR.config.filebrowserUploadMethod = 'form'; //4。9默认是xhr 的方式ajax
CKEDITOR.config.filebrowserImageUploadUrl = '/admin/article/uploadImage';
CKEDITOR.config.uploadUrl = '/admin/article/uploadImage';
CKEDITOR.config.removePlugins = "devtools,flash,about";
CKEDITOR.config.height = 390;
CKEDITOR.config.extraAllowedContent = 'p{text-indent}';
if (CKEDITOR.env.ie && CKEDITOR.env.version < 9) CKEDITOR.tools.enableHtml5Elements(document);
var tmpConfig = {
language: 'zh-cn',
filebrowserBrowseUrl: '/static/plugins/common/ckfinder/ckfinder.html',
filebrowserUploadUrl: '/static/plugins/common/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
wordcount: {
showParagraphs: false, showWordCount: false, showCharCount: true,
countSpacesAsChars: false, countHTML: false, maxWordCount: -1, maxCharCount: 16000,
filter: new CKEDITOR.htmlParser.filter({
elements: {
div: function (element) {
if (element.attributes.class == 'mediaembed') {
return false;
}
}
}
})
}
};
window.instansAnswer = CKEDITOR.replace('content', tmpConfig);
CKFinder.setupCKEditor( window.instansAnswer );
</script>