ueditor調用其中的附件上傳功能


ueditor實際上是集成了webuploader, 在做內容發布的時候想既有ueditor又有單獨的附件上傳按鈕,這時再加載一個webuploader就顯得過於臃腫了,單獨利用ueditor的上傳功能就比較合適了

首先是顯示附件上傳dialog,兩種方式

dialog = ue.ui._dialogs["attachment" + "Dialog"](推薦);

dialog.open();

dialog = parent.$EDITORUI[window.frameElement.id.replace( /_iframe$/, '' )];

再就是替換dialog的onok函數了,原先的onok會執行editor.execCommand('insertfile', list);//dialog/attachment/attatchment.js

我們重新寫一個onok函數替換掉原來的onok就可以了,只是簡單去掉editor.execCommand('insertfile', list);並且拿到file list 做自己的處理就可以了。

//in dialog.js

//在這里面結合dialog自身的id 給你新生成的iframe也賦值一個id 以_iframe作為后綴

contentHtml = '<span id="'+ this.id +'_contmask" class="dialogcontmask"></span><iframe id="'+ this.id +
'_iframe" class="%%-iframe" height="100%" width="100%" frameborder="0" src="'+ this.iframeUrl +'"></iframe>';

//下面是生成id的地方 

UIBase.prototype = {
className:'',
uiName:'',
initOptions:function (options) {
var me = this;
for (var k in options) {
me[k] = options[k];
}
this.id = this.id || 'edui' + uiUtils.uid();
},

utils.inherits(Dialog, UIBase);通過這個賦予dialog uibase的一些屬性

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM