text: !function(a,b){"use strict";var c=function(a,b){this.settings=c.util.merge(a,c.defaults),this.editor=b,this.filenameTag="{filename}",this.lastValue=null};c.editors={},c.util={merge:function(){for(var a={},b=arguments.length-1;b>=0;b--){var c=arguments[b];for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}return a},appendInItsOwnLine:function(a,b){return(a+"\n\n[[D]]"+b).replace(/(\n{2,})\[\[D\]\]/,"\n\n").replace(/^(\n*)/,"")},insertTextAtCursor:function(b,c){var d,e=b.scrollTop,f=0,g=!1;b.selectionStart||"0"===b.selectionStart?g="ff":a.selection&&(g="ie"),"ie"===g?(b.focus(),d=a.selection.createRange(),d.moveStart("character",-b.value.length),f=d.text.length):"ff"===g&&(f=b.selectionStart);var h=b.value.substring(0,f),i=b.value.substring(f,b.value.length);b.value=h+c+i,f+=c.length,"ie"===g?(b.focus(),d=a.selection.createRange(),d.moveStart("character",-b.value.length),d.moveStart("character",f),d.moveEnd("character",0),d.select()):"ff"===g&&(b.selectionStart=f,b.selectionEnd=f,b.focus()),b.scrollTop=e}},c.defaults={uploadUrl:"upload_attachment.php",uploadMethod:"POST",uploadFieldName:"file",defaultExtension:"png",jsonFieldName:"filename",allowedTypes:["image/jpeg","image/png","image/jpg","image/gif"],progressText:"![Uploading file...]()",urlText:"![file]({filename})",errorText:"Error uploading file",extraParams:{},extraHeaders:{},beforeFileUpload:function(){return!0},onFileReceived:function(){},onFileUploadResponse:function(){return!0},onFileUploadError:function(){return!0},onFileUploaded:function(){}},c.prototype.uploadFile=function(a){var b=this,c=new FormData,d=new XMLHttpRequest,e=this.settings,f=e.defaultExtension||e.defualtExtension;if("function"==typeof e.setupFormData&&e.setupFormData(c,a),a.name){var g=a.name.match(/\.(.+)$/);g&&(f=g[1])}var h="image-"+Date.now()+"."+f;if("function"==typeof e.remoteFilename&&(h=e.remoteFilename(a)),c.append(e.uploadFieldName,a,h),"object"==typeof e.extraParams)for(var i in e.extraParams)e.extraParams.hasOwnProperty(i)&&c.append(i,e.extraParams[i]);if(d.open("POST",e.uploadUrl),"object"==typeof e.extraHeaders)for(var j in e.extraHeaders)e.extraHeaders.hasOwnProperty(j)&&d.setRequestHeader(j,e.extraHeaders[j]);return d.onload=function(){200===d.status||201===d.status?b.onFileUploadResponse(d):b.onFileUploadError(d)},e.beforeFileUpload(d)!==!1&&d.send(c),d},c.prototype.isFileAllowed=function(a){return"string"===a.kind?!1:0===this.settings.allowedTypes.indexOf("*")?!0:this.settings.allowedTypes.indexOf(a.type)>=0},c.prototype.onFileUploadResponse=function(a){if(this.settings.onFileUploadResponse.call(this,a)!==!1){var b=JSON.parse(a.responseText),c=b[this.settings.jsonFieldName];if(b&&c){var d;d="function"==typeof this.settings.urlText?this.settings.urlText.call(this,c,b):this.settings.urlText.replace(this.filenameTag,c);var e=this.editor.getValue().replace(this.lastValue,d);this.editor.setValue(e),this.settings.onFileUploaded.call(this,c)}}},c.prototype.onFileUploadError=function(a){if(this.settings.onFileUploadError.call(this,a)!==!1){var b=this.editor.getValue().replace(this.lastValue,"");this.editor.setValue(b)}},c.prototype.onFileInserted=function(a){this.settings.onFileReceived.call(this,a)!==!1&&(this.lastValue=this.settings.progressText,this.editor.insertValue(this.lastValue))},c.prototype.onPaste=function(a){var b,c=!1,d=a.clipboardData;if("object"==typeof d){b=d.items||d.files||[];for(var e=0;e<b.length;e++){var f=b[e];this.isFileAllowed(f)&&(c=!0,this.onFileInserted(f.getAsFile()),this.uploadFile(f.getAsFile()))}}return c&&a.preventDefault(),c},c.prototype.onDrop=function(a){for(var b=!1,c=0;c<a.dataTransfer.files.length;c++){var d=a.dataTransfer.files[c];this.isFileAllowed(d)&&(b=!0,this.onFileInserted(d),this.uploadFile(d))}return b},b.inlineAttachment=c}(document,window),function(){"use strict";var a=function(a){if(!a.getWrapperElement)throw"Invalid CodeMirror object given";this.codeMirror=a};a.prototype.getValue=function(){return this.codeMirror.getValue()},a.prototype.insertValue=function(a){this.codeMirror.replaceSelection(a)},a.prototype.setValue=function(a){var b=this.codeMirror.getCursor();this.codeMirror.setValue(a),this.codeMirror.setCursor(b)},a.attach=function(b,c){c=c||{};var d=new a(b),e=new inlineAttachment(c,d),f=b.getWrapperElement();f.addEventListener("paste",function(a){e.onPaste(a)},!1),b.setOption("onDragEvent",function(a,b){return"drop"===b.type?(b.stopPropagation(),b.preventDefault(),e.onDrop(b)):void 0})};var b=function(b){a.call(this,b)};b.attach=function(b,c){c=c||{};var d=new a(b),e=new inlineAttachment(c,d),f=b.getWrapperElement();f.addEventListener("paste",function(a){e.onPaste(a)},!1),b.on("drop",function(a,b){return e.onDrop(b)?(b.stopPropagation(),b.preventDefault(),!0):!1})},inlineAttachment.editors.codemirror4=b}();
  