!function(a,b){"function"==typeof define&&define.amd?define("simditor",["jquery","simple-module","simple-hotkeys","simple-uploader"],function(c,d,e,f){return a.returnExportsGlobal=b(c,d,e,f)}):"object"==typeof exports?module.exports=b(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader")):a.Simditor=b(jQuery,SimpleModule,simple.hotkeys,simple.uploader)}(this,function(a,b,c,d){var e,f={}.hasOwnProperty,g=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};e=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return g(c,b),c.pluginName="Selection",c.prototype._init=function(){return this.editor=this._module,this.sel=document.getSelection()},c.prototype.clear=function(){var a;try{return this.sel.removeAllRanges()}catch(b){a=b}},c.prototype.getRange=function(){return this.editor.inputManager.focused&&this.sel.rangeCount?this.sel.getRangeAt(0):null},c.prototype.selectRange=function(a){return this.clear(),this.sel.addRange(a),this.editor.inputManager.focused||!this.editor.util.browser.firefox&&!this.editor.util.browser.msie||this.editor.body.focus(),a},c.prototype.rangeAtEndOf=function(b,c){var d,e,f;return null==c&&(c=this.getRange()),null!=c&&c.collapsed?(b=a(b)[0],d=c.endContainer,e=this.editor.util.getNodeLength(d),c.endOffset===e-1&&a(d).contents().last().is("br")||c.endOffset===e?b===d?!0:a.contains(b,d)?(f=!0,a(d).parentsUntil(b).addBack().each(function(){return function(b,c){var d,e;return e=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),d=e.last(),d.get(0)===c||d.is("br")&&d.prev().get(0)===c?void 0:(f=!1,!1)}}(this)),f):!1:!1):void 0},c.prototype.rangeAtStartOf=function(b,c){var d,e;return null==c&&(c=this.getRange()),null!=c&&c.collapsed?(b=a(b)[0],e=c.startContainer,0!==c.startOffset?!1:b===e?!0:a.contains(b,e)?(d=!0,a(e).parentsUntil(b).addBack().each(function(){return function(b,c){var e;return e=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),e.first().get(0)!==c?d=!1:void 0}}(this)),d):!1):void 0},c.prototype.insertNode=function(b,c){return null==c&&(c=this.getRange()),null!=c?(b=a(b)[0],c.insertNode(b),this.setRangeAfter(b,c)):void 0},c.prototype.setRangeAfter=function(b,c){return null==c&&(c=this.getRange()),null!=c?(b=a(b)[0],c.setEndAfter(b),c.collapse(!1),this.selectRange(c)):void 0},c.prototype.setRangeBefore=function(b,c){return null==c&&(c=this.getRange()),null!=c?(b=a(b)[0],c.setEndBefore(b),c.collapse(!1),this.selectRange(c)):void 0},c.prototype.setRangeAtStartOf=function(b,c){return null==c&&(c=this.getRange()),b=a(b).get(0),c.setEnd(b,0),c.collapse(!1),this.selectRange(c)},c.prototype.setRangeAtEndOf=function(b,c){var d,e,f,g,h,i;return null==c&&(c=this.getRange()),e=a(b),b=e.get(0),e.is("pre")?(f=e.contents(),f.length>0?(g=f.last(),h=g.text(),"\n"===h.charAt(h.length-1)?c.setEnd(g[0],this.editor.util.getNodeLength(g[0])-1):c.setEnd(g[0],this.editor.util.getNodeLength(g[0]))):c.setEnd(b,0)):(i=this.editor.util.getNodeLength(b),3!==b.nodeType&&i>0&&(d=a(b).contents().last(),d.is("br")?i-=1:3!==d[0].nodeType&&this.editor.util.isEmptyNode(d)&&(d.append(this.editor.util.phBr),b=d[0],i=0)),c.setEnd(b,i)),c.collapse(!1),this.selectRange(c)},c.prototype.deleteRangeContents=function(a){var b,c;return null==a&&(a=this.getRange()),c=a.cloneRange(),b=a.cloneRange(),c.collapse(!0),b.collapse(!1),!a.collapsed&&this.rangeAtStartOf(this.editor.body,c)&&this.rangeAtEndOf(this.editor.body,b)?(this.editor.body.empty(),a.setStart(this.editor.body[0],0),a.collapse(!0),this.selectRange(a)):a.deleteContents(),a},c.prototype.breakBlockEl=function(b,c){var d;return null==c&&(c=this.getRange()),d=a(b),c.collapsed?(c.setStartBefore(d.get(0)),c.collapsed?d:d.before(c.extractContents())):d},c.prototype.save=function(b){var c,d,e;return null==b&&(b=this.getRange()),this._selectionSaved?void 0:(d=b.cloneRange(),d.collapse(!1),e=a("").addClass("simditor-caret-start"),c=a("").addClass("simditor-caret-end"),d.insertNode(c[0]),b.insertNode(e[0]),this.clear(),this._selectionSaved=!0)},c.prototype.restore=function(){var a,b,c,d,e,f,g;return this._selectionSaved?(e=this.editor.body.find(".simditor-caret-start"),a=this.editor.body.find(".simditor-caret-end"),e.length&&a.length?(f=e.parent(),g=f.contents().index(e),b=a.parent(),c=b.contents().index(a),f[0]===b[0]&&(c-=1),d=document.createRange(),d.setStart(f.get(0),g),d.setEnd(b.get(0),c),e.remove(),a.remove(),this.selectRange(d)):(e.remove(),a.remove()),this._selectionSaved=!1,d):!1},c}(b);var h,f={}.hasOwnProperty,g=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},i=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};h=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return g(c,b),c.pluginName="Formatter",c.prototype._init=function(){return this.editor=this._module,this._allowedTags=["br","a","img","b","strong","i","u","font","p","ul","ol","li","blockquote","pre","h1","h2","h3","h4","hr"],this._allowedAttributes={img:["src","alt","width","height","data-image-src","data-image-size","data-image-name","data-non-image"],a:["href","target"],font:["color"],pre:["data-lang","class"],p:["data-indent"],h1:["data-indent"],h2:["data-indent"],h3:["data-indent"],h4:["data-indent"]},this.editor.body.on("click","a",function(){return function(){return!1}}(this))},c.prototype.decorate=function(a){return null==a&&(a=this.editor.body),this.editor.trigger("decorate",[a])},c.prototype.undecorate=function(b){return null==b&&(b=this.editor.body.clone()),this.editor.trigger("undecorate",[b]),a.trim(b.html())},c.prototype.autolink=function(b){var c,d,e,f,g,h,i,j,k,l,m;for(null==b&&(b=this.editor.body),f=[],d=function(c){return c.contents().each(function(c,e){var g,h;return g=a(e),g.is("a")||g.closest("a, pre",b).length?void 0:g.contents().length?d(g):(h=g.text())&&/https?:\/\/|www\./gi.test(h)?f.push(g):void 0})},d(b),h=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/gi,l=0,m=f.length;m>l;l++){for(c=f[l],j=c.text(),i=[],g=null,e=0;null!==(g=h.exec(j));)i.push(document.createTextNode(j.substring(e,g.index))),e=h.lastIndex,k=/^(http(s)?:\/\/|\/)/.test(g[0])?g[0]:"http://"+g[0],i.push(a('').text(g[0])[0]);i.push(document.createTextNode(j.substring(e))),c.replaceWith(a(i))}return b},c.prototype.format=function(b){var c,d,e,f,g,h,i,j,k,l;if(null==b&&(b=this.editor.body),b.is(":empty"))return b.append("

"+this.editor.util.phBr+"

"),b;for(k=b.contents(),g=0,i=k.length;i>g;g++)e=k[g],this.cleanNode(e,!0);for(l=b.contents(),h=0,j=l.length;j>h;h++)f=l[h],c=a(f),c.is("br")?("undefined"!=typeof d&&null!==d&&(d=null),c.remove()):this.editor.util.isBlockNode(f)?c.is("li")?d&&d.is("ul, ol")?d.append(f):(d=a("