为kindeditor4.1.12编辑器添加“引用”(blockquote)标签
主要参考:
https://www.myxzy.com/post-395.html
但也做了一些极小的改动。 值得提醒的是作者要添加的功能是 blockquote ,但是类名什么的却写成了 bockquote ,一开始让蒙了关天。
这里提醒大家注意一下。
然后写写我的操作过程吧。
(一)修改kindeditor-all.js 1. 263行:添加
items : [
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code','bockquote', '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', 'multiimage',
'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', 'unlink', '|', 'uploadremotephoto', 'about'
],
2. 6128行:
bockquote : '插入引用',
3.修改themes/default/default.png图片,这是原作者修改好的,感谢!
点击下载源码:
/techuf/file/20200317/20200317115754825482.zip4.修改themes/default/default.css文件
.ke-icon-bockquote {
background-position: 0px -1248px;
width: 16px;
height: 16px;
}
3和4是为了在编辑器上添加图标,到这里前端完成,进入下一步实质操作。
你也可以尝试我这种简单的添加图标的方式,不必要修改
default.png,新增一个小图标即可,这样似乎更好操作一些:
.ke-icon-bockquote {
background: url("../common/bockquote.gif") no-repeat;
color: #666;
font-size: 14px;
font-weight: bold;
height: 16px;
line-height: 16px;
padding-left: 16px;
}
(二)添加插件目录及文件 1.添加plugins/bockquote/bockquote.js文件【完全照搬原作者的】
/*******************************************************************************
* bockquote - KindEditor二次开发
*
* @author Star Yu <vip@myxzy.com>
* @site http://www.myxzy.com/
*******************************************************************************/
KindEditor.plugin('bockquote', function(K) {
var self = this, name = 'bockquote';
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = ['<div style="padding:10px 20px;">','<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>','</div>'].join(''),
dialog = self.createDialog({
name : name,
width : 450,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var type = textarea.val();
html ='<blockquote>' + K.escape(type) + '</blockquote> ';
if (K.trim(type) === '') {
alert(lang.pleaseInput);
textarea[0].focus();
return;
}
self.insertHtml(html).hideDialog().focus();
}
}
}),
textarea = K('textarea', dialog.div);
textarea[0].focus();
});
});
2.添加plugins/bockquote/bockquote.css文件,需要在前台页面引用【我做了改动】
blockquote {
border: 0;
background-color:rgb(245,245,245);
border-left: 3px solid rgb(0, 225, 225);
margin-left: 0.5em;
padding: 0.2em;
font-size: 110%;
display: block;
font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
white-space: pre-wrap;
}
(三)后台样式1.首先我的后台引用一个CSS文件,里边包含其它插件的后台样式.
KindEditor.ready(function (K) {
window.editor = K.create('#ArtContent', {
cssPath: '../techeditor/styleforadmin.css',
resizeType: 1,
allowPreviewEmoticons: false,
allowImageUpload: true,
uploadJson : '/techeditor/asp/upload_json.asp',
});
});
2.然后我的
styleforadmin.css是这样的:
@charset "utf-8";
/*prettify插件*/
.prettyprint {
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
padding-left: 5em; /*在这里添加这两句,避免影响到其他地方的样式*/
background-color: #131513;
color: #FFF;
white-space:pre-line;
}
/*blockquote插件*/
blockquote {
border: 0;
background-color:rgb(245,245,245);
border-left: 3px solid rgb(0, 225, 225);
margin-left: 0.5em;
padding: 0.5em;
font-size: 110%;
display: block;
font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
width: 630px;
white-space: pre-wrap;
}