图片上传及文件上传

//上传图片,网络图片上传及本地图片上传
//编辑器
var editor;  //编辑器	
var editor2; //上传图片
var editor3; //上传文件
KindEditor.ready(function (K) {
		    editor= K.create('#newsCont', {
		      themeType: 'default',
		       items: [/*'preview',*/'cut', 'copy', 'paste',
					'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
					'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 
					'superscript', '|', 'fullscreen',
					'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
					'italic', 'underline', 'strikethrough', 'lineheight', '|', /*'image',*/'table', 'hr', 'emoticons', 'link', 'unlink'],
			   resizeType:1,
			   afterBlur: function () {this.sync();}
		 	});
		    if(detail){
		    	editor.readonly();
		    }
		   	 
		   editor2 = K.editor({
		       allowFileManager: false
		    });
		   K('.news_Img').click(function () {
			   editorDialog2(editor2,K);
		   });
		   
		   editor3 = K.editor({
		        allowFileManager: false
		    });
		    //文件上传
		  	K('.serchFile').click(function () {
				editorDialog3(editor3,K);
			});
		});



1、既可以上传网络图片也可以上传本地图片

	KindEditor.ready(function(K) {
		var editor = K.editor({
			allowFileManager : true
		});
		K('#image1').click(function() {
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					imageUrl : K('#url1').val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#url1').val(url);
						editor.hideDialog();
				}
			});
		});
	});

2、只显示网络上传

	KindEditor.ready(function(K) {
		var editor = K.editor({
			allowFileManager : true
		});
		K('#image1').click(function() {
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					showLocal : false,
					imageUrl : K('#url1').val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#url1').val(url);
						editor.hideDialog();
				}
			});
		});
	});

3、只显示本地上传

	KindEditor.ready(function(K) {
		var editor = K.editor({
			allowFileManager : true
		});
		K('#image1').click(function() {
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					showRemote : false,
					imageUrl : K('#url1').val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#url1').val(url);
						editor.hideDialog();
				}
			});
		});
	});
	
    //文件上传
	KindEditor.ready(function(K) {
		var editor = K.editor({
			allowFileManager : true
		});
		K('#insertfile').click(function() {
			editor.loadPlugin('insertfile', function() {
			editor.plugin.fileDialog({
					fileUrl : K('#url').val(),
					clickFn : function(url, title) {
						K('#url').val(url);
						editor.hideDialog();
					}
				});
			});
		});
	});

items
配置编辑器的工具栏,其中”/”表示换行,”|”表示分隔符。

数据类型: Array
默认值:
[ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', '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', '|', 'about']
source	HTML代码
preview	预览
undo	后退
redo	前进
cut	剪切
copy	复制
paste	粘贴
plainpaste	粘贴为无格式文本
wordpaste	从Word粘贴
selectall	全选
justifyleft	左对齐
justifycenter	居中
justifyright	右对齐
justifyfull	两端对齐
insertorderedlist	编号
insertunorderedlist	项目符号
indent	增加缩进
outdent	减少缩进
subscript	下标
superscript	上标
formatblock	段落
fontname	字体
fontsize	文字大小
forecolor	文字颜色
hilitecolor	文字背景
bold	粗体
italic	斜体
underline	下划线
strikethrough	删除线
removeformat	删除格式
image	图片
flash	Flash
media	视音频
table	表格
hr	插入横线
emoticons	插入表情
link	超级链接
unlink	取消超级链接
fullscreen	全屏显示
about	关于
print	打印
code	插入程序代码
map	Google地图
baidumap	百度地图
lineheight	行距
clearhtml	清理HTML代码
pagebreak	插入分页符
quickformat	一键排版
insertfile	插入文件
template	插入模板
anchor	插入锚点

猜你喜欢

转载自blog.csdn.net/xiechunhua_Blog/article/details/80949825