o2.TinyMCEConfig = function ( mobile ) { debugger; if( typeof mobile !== "boolean" )mobile = layout.mobile; var config = { "branding": false, //skin:'oxide-dark', // language:'zh_CN', // toolbar_sticky: true, fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px', // importcss_append: true, autosave_ask_before_unload: false, //自定义文件选择器的回调内容 image_advtab: true, file_picker_types: 'image', //file image media extended_valid_elements : 'img[class|src|border|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name'+ '|style|data-id|data-orgid|data-height|data-width|onerror|data-prv|data-filename]', file_picker_callback: function (callback, value, meta) { //this 指向editor实例 if (meta.filetype === 'image') { //'file', 'media' if( this.activeO2ImageDialog && this.activeO2ImageDialog.getData().base64enable ) { var fileNode = new Element("input", { "type" : "file", "accept":"image/*", "styles" : {"display":"none"} }); fileNode.addEvent("change", function(event){ var file= fileNode.files[0]; if(!/image\/\w+/.test(file.type)){ //判断获取的是否为图片文件 MWF.xDesktop.notice('请选择图片格式文件',"error"); return false; } var reader=new FileReader(); reader.readAsDataURL(file); reader.onload = function(e){ callback( this.result, { "style": 'max-width:100%;', //width:' + width + 'px', "alt": file.name || '', "data-prv": 'true' //enablePreview ? 'true' : 'false' }) } }.bind( this )); fileNode.click(); }else{ var enablePreview = this.getParam('enablePreview', true); var localImageMaxWidth = this.getParam('localImageMaxWidth', 2000); var reference = this.getParam('reference'); var referenceType = this.getParam('referenceType'); if( !reference || !referenceType )return; MWF.require("MWF.widget.Upload", function () { var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_file_assemble_control"); var upload = new MWF.widget.Upload($(document.body), { "data": null, "parameter": { "reference": reference, "referencetype": referenceType, "scale": localImageMaxWidth || 2000 }, "action": action, "method": "uploadImageByScale", "accept": "image/*", "onEvery": function (json, index, count, file) { debugger; var id = json.data ? json.data.id : json.id; var src = MWF.xDesktop.getImageSrc( id ); new Element("img", { src : src, events : { load : function (ev) { var width = ev.target.naturalWidth; var height = ev.target.naturalHeight; //按最大宽度比率缩小 if( localImageMaxWidth && localImageMaxWidth < width ){ height = parseInt( height * (localImageMaxWidth / width) ); } width = Math.min(width, localImageMaxWidth); var attributes = { "data-id": id, "data-orgid": json.data ? json.data.origId : json.origId, "height": ''+height, "width": ''+width, "data-height": ''+height, "data-width": ''+width, "data-filename": file ? ( file.name||"" ) : '', "style": 'max-width:100%; width:' + width + 'px', "onerror": 'MWF.xDesktop.setImageSrc()', "alt": file ? ( file.name||"" ) : '', "data-prv": 'true' //enablePreview ? 'true' : 'false' }; callback( src, attributes ) } } }); }.bind(this) }); upload.load(); }.bind(this)); } } }, init_instance_defaultCallback: function(editor) { var head_zindex = editor.getParam('head_zindex', 1); if(head_zindex !== 1 && editor.editorContainer && editor.editorContainer.getElementsByClassName){ var list = editor.editorContainer.getElementsByClassName("tox-editor-header"); if( list && list.length )list[0].setStyle("z-index", head_zindex); } editor.on("ObjectResized", function(ev){ var element = ev.target; if(element.tagName && element.tagName.toUpperCase() === "IMG"){ var replaceStyles = function(str, object){ /*object 参数 { "width" : "100px", //添加或替换 "height": "" //删除 }*/ var newArray = []; Object.each(object, function (value, key) { if(value)newArray.push( key + ":" + value ) }); var styles = str.split(/\s*;\s*/gi); for(var j=0; j