KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。
KindEditor 虽然是一套不错的HTML编辑器,但有些功能还是需要进行二次开发后,才能正常使用,比如下面所说的,增加代码高亮功能,源码是增加代码没法达到高亮功能作用的。
首先,下载一套dedecms 默认编辑器插入代码高亮插件syntaxhighlight,在这里就不多说了,互联网上搜一下:织梦高亮插件syntaxhighlight,有很多可以下载使用的。根据下载说明,很容易就可以设置在,织梦网站系统默认编辑器上使用。在织梦网站系统默认编辑器上正常使用后,就可以切换到KindEditor编辑器上设置。
经本人研究发现,很简单调试两个文件就可以使用了。
修改第一个文件
include\kindeditor\kindeditor.js (这里文件是要看你的编辑器使用那个,有些是使用的是kindeditor-min.js 或 kindeditor-all.js)
找到文件大约在6664行里的
<option value="bsh">Shell</option> |
<option value="bash">Bash(Shell)</option> |
再找到大约6681行里的
html = '<pre class="prettyprint' + cls + '">\n' + K.escape(code) + '</pre> '; |
html = '<table style="border:1px solid #EAED9C;width:100%;"><tr><td><pre class="brush:' + type + '">' + K.escape(code) + "</pre></td></tr></table>"; |
修改第二个文件
include\kindeditor\plugins\code\code.js
找到文件大约在29行里的
<option value="bsh">Shell</option> |
<option value="bash">Bash(Shell)</option> |
再找到大约46行里的
html = '<pre class="prettyprint' + cls + '">\n' + K.escape(code) + '</pre> '; |
html = '<table style="border:1px solid #EAED9C;width:100%;"><tr><td><pre class="brush:' + type + '">' + K.escape(code) + "</pre></td></tr></table>"; |
保存后,刷新一下系统后台页面,再试试就可以正常使用了。