From 3b99c97617e872623bd43c2ed916087f7fc8613b Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 23 Apr 2015 17:43:34 +0800 Subject: [PATCH] =?UTF-8?q?kindeditor=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=B8=80=E6=AC=A1=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/kindeditor/kindeditor.js | 43 +++++++++++++++++-- public/assets/kindeditor/lang/zh_CN.js | 1 + .../kindeditor/themes/default/default.css | 7 +++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 8ecbfef06..937631041 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -257,10 +257,10 @@ K.options = { minHeight : 100, minChangeSize : 50, zIndex : 811213, - items : ['emoticons', + items : ['emoticons','imagedirectupload', 'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|', 'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', - 'italic', 'underline', 'removeformat', '|', 'image', 'table', 'link', '|', 'fullscreen' + 'italic', 'underline', 'removeformat', '|','table', 'link', '|', 'fullscreen' ], noDisableItems : ['source', 'fullscreen'], colorTable : [ @@ -3523,6 +3523,7 @@ var html, _direction = ''; if ((html = document.getElementsByTagName('html'))) { _direction = html[0].dir; } + function _getInitHtml(themesPath, bodyClass, cssPath, cssData) { var arr = [ (_direction === '' ? '' : ''), @@ -5552,7 +5553,39 @@ _plugin('core', function(K) { self.clickToolbar('fullscreen', function() { self.fullscreen(); }); - if (self.fullscreenShortcut) { + inputObj = document.createElement("input"); + inputObj.setAttribute('id', 'jUploadFile_ef'); + inputObj.setAttribute('type', 'button'); + inputObj.setAttribute('style', 'visibility:hidden'); + document.body.appendChild(inputObj); + window.uploadButton = K.uploadbutton({ + button: inputObj, + fieldName:'imgFile', + url:K.addParam('/kindeditor/upload', 'dir=image'), + afterUpload : function(data) { + if (data.error === 0) { + var url = K.formatUrl(data.url, 'absolute'); + self.exec('insertimage', url, 'image','','','1','left'); + var asset_id = data.asset_id; + if ( asset_id != "" && parent.document.getElementById('asset_id') != null ) { + parent.document.getElementById('asset_id').value += asset_id.toString(); + parent.document.getElementById('asset_id').value += ","; + }else{ + //TODO 暂时什么也不做 + } + } else { + alert(data.message); + } + }, + afterError : function(str) { + alert('error: ' + str); + } + }); + uploadButton.fileBox.change(function(e) { + uploadButton.submit(); + }); + + if (self.fullscreenShortcut) { var loaded = false; self.afterCreate(function() { K(self.edit.doc, self.edit.textarea).keyup(function(e) { @@ -5585,6 +5618,10 @@ _plugin('core', function(K) { self[name](); }); }); + self.clickToolbar('imagedirectupload', function() { + $('.ke-upload-file').focus().trigger('click'); + + }); self.clickToolbar('formatblock', function() { var blocks = self.lang('formatblock.formatBlock'), heights = { diff --git a/public/assets/kindeditor/lang/zh_CN.js b/public/assets/kindeditor/lang/zh_CN.js index c8506f313..f2b474351 100644 --- a/public/assets/kindeditor/lang/zh_CN.js +++ b/public/assets/kindeditor/lang/zh_CN.js @@ -8,6 +8,7 @@ *******************************************************************************/ KindEditor.lang({ + imagedirectupload:'本地图片', source : 'HTML代码', preview : '预览', undo : '后退(Ctrl+Z)', diff --git a/public/assets/kindeditor/themes/default/default.css b/public/assets/kindeditor/themes/default/default.css index 428b6c8b5..06559412f 100644 --- a/public/assets/kindeditor/themes/default/default.css +++ b/public/assets/kindeditor/themes/default/default.css @@ -413,6 +413,13 @@ width: 16px; height: 16px; } + +.ke-icon-imagedirectupload +{ + background-position: 0px -1232px; + width: 16px; + height: 16px; +} /* container */ .ke-container { display: block;