"+this._emptyChar+"
"},isEmpty:function(){return html=this.$editor.html(),""==html||"\0"==html||"\0
"==html||html==this._empty()},create:function(){var e=this;return t("",{"class":i.name+"-editor",data:{wysihat:this,field:this.$field},role:"application",contentEditable:"true",height:this.$field.height()>0?1.8*this.$field.height():27*this.$field.attr("rows"),dir:this.$field.attr("dir"),html:i.Formatting.getBrowserMarkupFrom(this.$field),blur:function(){e.updateField(),e.$field.trigger("blur")}})},createWrapper:function(){var e=this;this.$field.add(this.$editor).wrapAll(t("",{"class":i.name+"-container",mouseup:function(){e.$field.is(":visible")?e.$editor.outerHeight(e.$field.outerHeight()):e.$editor.is(":visible")&&e.$field.outerHeight(e.$editor.outerHeight())}}))},init:function(e){var n=this.$editor,r=this;this.Undo=new i.Undo,this.Selection=new i.Selection(n),this.Event=new i.Event(this),this.Toolbar=new i.Toolbar(n,e.buttons),this.$field.change(t.proxy(this,"updateEditor")),n.closest("form").on("submit entry:autosave",function(){r.$field.is(":visible")||r.updateField()})},updateField:function(){this.$field.val(i.Formatting.getApplicationMarkupFrom(this.$editor))},updateEditor:function(){this.$editor.html(i.Formatting.getBrowserMarkupFrom(this.$field)),this.selectEmptyParagraph()},selectEmptyParagraph:function(){var n,i=this.$editor,r=(i.html(),window.getSelection());this.isEmpty()&&(i.html(this._empty()),n=e.createRange(),r.removeAllRanges(),n.selectNodeContents(i.find("p").get(0)),t.browser.mozilla&&i.find("p").eq(0).html(""),r.addRange(n))}},i.Editor.constructor=i.Editor,i.Element=function(){function e(e){for(var t=arguments.length,n=!1;0==n&&t-- >1;)n=e.is(arguments[t].join(","));return n}var t=["blockquote","details","fieldset","figure","td"],n=["article","aside","header","footer","nav","section"],i=["blockquote","details","dl","ol","table","ul"],r=["dd","dt","li","summary","td","th"],o=["address","caption","dd","div","dt","figcaption","figure","h1","h2","h3","h4","h5","h6","hgroup","hr","p","pre","summary","small"],s=["audio","canvas","embed","iframe","img","object","param","source","track","video"],a=["a","abbr","b","br","cite","code","del","dfn","em","i","ins","kbd","mark","span","q","samp","s","strong","sub","sup","time","u","var","wbr"],l=["b","code","del","em","i","ins","kbd","span","s","strong","u","font"],d=["address","blockquote","div","dd","dt","h1","h2","h3","h4","h5","h6","p","pre"],c=["button","datalist","fieldset","form","input","keygen","label","legend","optgroup","option","output","select","textarea"];return{isRoot:function(n){return e(n,t)},isSection:function(t){return e(t,n)},isContainer:function(t){return e(t,i)},isSubContainer:function(t){return e(t,r)},isBlock:function(s){return e(s,t,n,i,r,o)},isHTML4Block:function(t){return e(t,d)},isContentElement:function(t){return e(t,r,o)},isMediaElement:function(t){return e(t,s)},isPhraseElement:function(t){return e(t,a)},isFormatter:function(t){return e(t,l)},isFormComponent:function(t){return e(t,c)},getRoots:function(){return t},getSections:function(e){return n},getContainers:function(){return i},getSubContainers:function(){return r},getBlocks:function(){return t.concat(n,i,r,o)},getHTML4Blocks:function(){return d},getContentElements:function(){return r.concat(o)},getMediaElements:function(){return s},getPhraseElements:function(){return a},getFormatters:function(){return l},getFormComponents:function(){return c}}}(),t(e).ready(function(){var n,i,r=t(e);"onselectionchange"in e&&"selection"in e?(i=function(){var n=e.selection.createRange(),i=n.parentElement();t(i).trigger("WysiHat-selection:change")},r.on("selectionchange",i)):(i=function(){var i,r,o=e.activeElement,s=o.tagName.toLowerCase();if("textarea"==s||"input"==s)n=null;else{if(i=window.getSelection(),i.rangeCount<1)return;if(r=i.getRangeAt(0),r&&r.equalRange(n))return;for(n=r,o=r.commonAncestorContainer;o.nodeType==Node.TEXT_NODE;)o=o.parentNode}t(o).trigger("WysiHat-selection:change")},r.mouseup(i),r.keyup(i))}),i.Paster=function(){var n=t('').css({width:"100%",height:10,position:"absolute",left:-9999}),r=50,o=200;return{getHandler:function(s){return function(a,l){var d=s.Commands.getRanges(),c=d[0].startContainer,h=0;return n.html("").css("top",t(e).scrollTop()),n.appendTo(e.body),n.focus(),setTimeout(function u(){if(!n.html()&&(h+=r,h/g,"\n\n").replace(/^(
)+/,"").replace(/(<\/p>)+$/,"").replace(//g,""),n.indexOf("\n")==-1?n:(n=n.replace(/\n/,"
").replace(/\n/g,"\n
"),t.trim(n)+"
")}),n.find("span").children(i.Element.getBlocks()).unwrap(),n.find(":empty").remove(),"p"!=r.toLowerCase()&&n.find(r).replaceWith(function(e,t){return t});var o,s=[];for(n.find("p ~ p").each(function(){var e=t(this),n=e.prev();o?t.trim(n.html())||(o.after("\n"),o=s.pop()):o=n,o.html(function(n,i){var r=t.trim(e.html());return i=t.trim(i),i&&r&&(i+="[ ]+
/g","").replace(/\n+<\/p>/g,"").replace(t.reBlocks,"$1\n\n").replace(/
/g,"
\n").replace(/(ul|ol|li)>\s+<(\/)?(ul|ol|li)>/g,"$1>\n<$2$3>").replace(/>
"),i.html()},getApplicationMarkupFrom:function(e){var n,i,r=e.clone();return n=t("").html(r.html()),i=n.html(),""!=i&&"
"),this.cleanup(n),this.format(n),n.html().replace(/<\/?[A-Z]+/g,function(e){return e.toLowerCase()})}};var a={init:function(e,t){return this.name=e,this.$editor=t,this.$field=t.data("field"),this},setElement:function(e){return this.$element=t(e),this},getHandler:function(){if(this.handler)return t.proxy(this,"handler");var e=this;return i.Commands.isMakeCommand(this.name)?function(){return i.Commands.make[e.name]()}:i.Commands.isValidExecCommand(this.name)?function(){return i.Commands.execCommand(e.name)}:t.noop},getStateHandler:function(){if(this.query)return t.proxy(this,"query");if(i.Commands.isValidExecCommand(this.name)){var e=this;return function(t){var n=t.data("wysihat");return n.Commands.queryCommandState(e.name)}}return t.noop},setOn:function(){return this.$element.addClass("selected").attr("aria-pressed","true").find("b").text(this["toggle-text"]?this["toggle-text"]:this.label),this},setOff:function(){return this.$element.removeClass("selected").attr("aria-pressed","false").find("b").text(this.label),this}};i.Toolbar=function(e,n){this.suspendQueries=!1,this.$editor=e,this.$toolbar=t(' '),e.before(this.$toolbar);var i,r=n.length;for(i=0;i