首页 > 代码库 > dedecms织梦富文本编辑器更换为kindeditor

dedecms织梦富文本编辑器更换为kindeditor

本站所有附件均为UTF-8版本,GBK版本的童学请自行转码。

最终效果

技术分享

 

首先,当然是先在kindeditor官方下载最新版本的kindeditor编辑器

目前最新版本是 KindEditor 4.1.10,下载解压,只要下面几个文件就行了,在你的dedecms程序include文件夹下,建个kindeditor文件夹,然后把解压出来的这几个文件放进去,最终结果是:

 

技术分享

 

2、增加kindeitor图片上传处理文件到 include/dialog

 

百度盘 密码: v9a5

技术分享

 

3、打开include/inc/inc_fun_funAdmin.php 这个是dedecms创建编辑器文件

找到

 

 

    else if($GLOBALS[‘cfg_html_editor‘]==‘ckeditor‘)
    {
中间代码省略...
    }

  在它们的下面加入

 

 

else if($GLOBALS[‘cfg_html_editor‘]==‘kindeditor‘)
{
	$fvalue =http://www.mamicode.com/htmlspecialchars($fvalue);"/include/dialog/kindeditor_post.php";
	$fileManagerJson = $GLOBALS[‘cfg_cmspath‘]."/include/dialog/kindeditor_manager.php";
	$allowFileManager = ‘true‘;
	$extendconfig = ‘‘;
	if($etype == ‘Member‘ || $etype == ‘MemberLit‘ || $etype == ‘Diy‘ || $etype == ‘Feedback‘)
	{
		$uploadJson = "";
		$fileManagerJson = "";
		$allowFileManager = ‘false‘;
		$extendconfig = ‘allowImageUpload : false,‘;
		$extendconfig .= ‘allowFlashUpload : false,‘;
		$extendconfig .= ‘allowMediaUpload : false,‘;
		$extendconfig .= ‘allowFileUpload : false,‘;
	}
	
	$items[‘Member‘] = "[
	‘source‘, ‘|‘, ‘undo‘, ‘redo‘, ‘|‘, ‘preview‘, ‘print‘, ‘template‘, ‘cut‘, ‘copy‘, ‘paste‘,
	‘plainpaste‘, ‘wordpaste‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘,
	‘justifyfull‘, ‘insertorderedlist‘, ‘insertunorderedlist‘, ‘indent‘, ‘outdent‘, ‘subscript‘,
	‘superscript‘, ‘clearhtml‘, ‘quickformat‘, ‘selectall‘, ‘|‘, ‘fullscreen‘, ‘/‘,
	‘formatblock‘, ‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘,
	‘italic‘, ‘underline‘, ‘strikethrough‘, ‘lineheight‘, ‘removeformat‘, ‘|‘, ‘image‘,
	‘flash‘, ‘media‘, ‘insertfile‘, ‘table‘, ‘hr‘, ‘emoticons‘, ‘map‘, ‘pagebreak‘,
	‘link‘, ‘unlink‘, ‘|‘, ‘about‘]";
	
	$items[‘Small‘] = $items[‘MemberLit‘] = $items[‘Diy‘] = "[
	‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘,
	‘removeformat‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘,
	‘insertunorderedlist‘, ‘|‘, ‘emoticons‘, ‘image‘, ‘link‘]";
	
	$items[‘Feedback‘]= "[
	‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘,
	‘removeformat‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘,
	‘insertunorderedlist‘, ‘|‘, ‘emoticons‘]";
	
	$itemconfig = ‘‘;
	if(isset($items[$etype]))
	{
		$itemconfig = "items :{$items[$etype]},";
	}
$session_id = session_id();
$code = <<<HTML
<link rel="stylesheet" href="http://www.mamicode.com/{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="http://www.mamicode.com/{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/plugins/code/prettify.css" />
<script src="http://www.mamicode.com/{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/kindeditor-min.js"></script>
<script src="http://www.mamicode.com/{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/lang/zh_CN.js"></script>
<script src="http://www.mamicode.com/{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript">
	KindEditor.ready(function(K) {
		var editor1 = K.create(‘textarea[name="{$fname}"]‘, {
			cssPath : ‘{$GLOBALS[‘cfg_cmspath‘]}/include/kindeditor/plugins/code/prettify.css‘,
			uploadJson : ‘$uploadJson‘,
			fileManagerJson : ‘$fileManagerJson‘,
			filterMode: false,//是否开启过滤模式
			extraFileUploadParams: {
				PHPSESSID : ‘{$session_id}‘
			},
			$extendconfig
			$itemconfig
			allowFileManager : {$allowFileManager},
			afterBlur: function(){this.sync();} 
		});
		prettyPrint();
	});
</script>
<textarea name="{$fname}" style="height:{$nheight}px;visibility:hidden;width: 100%;">{$fvalue}</textarea>
HTML;
	if($gtype=="print")
	{
		echo $code;
	}
	else
	{
		return $code;
	}
}

最后,后台-系统-系统基本参数-核心设置-Html编辑器 ,填写kindeditor

 

ps

■修复了已知问题session

■dedediy kineditor增加QQ图标

dedediy kineditor增加百度地图动态

dedecms织梦富文本编辑器更换为kindeditor