":"p";o.doc.execCommand("formatBlock",!1,t),o.syncCode()}),0)})).on("cut drop",(function(){setTimeout((function(){o.semanticCode(!1,!0),o.$c.trigger("tbwchange")}),0)})).on("paste",(function(e){if(o.o.removeformatPasted){e.preventDefault(),t.getSelection&&t.getSelection().deleteFromDocument&&t.getSelection().deleteFromDocument();try{var i=t.clipboardData.getData("Text");try{o.doc.selection.createRange().pasteHTML(i)}catch(t){o.doc.getSelection().getRangeAt(0).insertNode(o.doc.createTextNode(i))}o.$c.trigger("tbwchange",e)}catch(t){o.execCmd("insertText",(e.originalEvent||e).clipboardData.getData("text/plain"))}}r.each(o.pasteHandlers,(function(o,t){t(e)})),setTimeout((function(){o.semanticCode(!1,!0),o.$c.trigger("tbwpaste",e),o.$c.trigger("tbwchange")}),0)})),o.$ta.on("keyup",(function(){o.$c.trigger("tbwchange")})).on("paste",(function(){setTimeout((function(){o.$c.trigger("tbwchange")}),0)})),r(o.doc.body).on("keydown."+o.eventNamespace,(function(t){if(27===t.which&&r("."+e+"modal-box").length>=1)return o.closeModal(),!1}))},autogrowEditorOnEnter:function(){var o=this;o.$ed.removeClass("autogrow-on-enter");var t=o.$ed[0].clientHeight;o.$edBox.height("auto");var e=o.$ed[0].scrollHeight;o.$ed.addClass("autogrow-on-enter"),t!==e&&(o.$edBox.height(t),setTimeout((function(){o.$edBox.css({height:e}),o.$c.trigger("tbwresize")}),0))},buildBtnPane:function(){var o=this,t=o.o.prefix,e=o.$btnPane=r("
",{class:t+"button-pane"});r.each(o.o.btns,(function(i,n){Array.isArray(n)||(n=[n]);var a=r("",{class:t+"button-group "+(n.indexOf("fullscreen")>=0?t+"right":"")});r.each(n,(function(t,e){try{o.isSupportedBtn(e)&&a.append(o.buildBtn(e))}catch(o){}})),a.html().trim().length>0&&e.append(a)})),o.$box.prepend(e)},buildBtn:function(o){var t=this,e=t.o.prefix,i=t.btnsDef[o],n=i.dropdown,a=null==i.hasIcon||i.hasIcon,A=t.lang[o]||o,l=r("",{type:"button",class:e+o+"-button "+(i.class||"")+(a?"":" "+e+"textual-button"),html:t.hasSvg&&a?'':t.hideButtonTexts?"":i.text||i.title||t.lang[o]||o,title:(i.title||i.text||A)+(i.key?" ("+(t.isMac?"Cmd":"Ctrl")+" + "+i.key+")":""),tabindex:-1,mousedown:function(){return n&&!r("."+o+"-"+e+"dropdown",t.$box).is(":hidden")||r("body",t.doc).trigger("mousedown"),!((t.$btnPane.hasClass(e+"disable")||t.$box.hasClass(e+"disabled"))&&!r(this).hasClass(e+"active")&&!r(this).hasClass(e+"not-disable")||(t.execCmd((n?"dropdown":i.fn)||o,i.param||o,i.forceCss),1))}});if(n){l.addClass(e+"open-dropdown");var s=e+"dropdown",d={class:s+"-"+o+" "+s+" "+e+"fixed-top "+(i.dropdownClass||"")};d["data-"+s]=o;var u=r("",d);r.each(n,(function(o,e){t.btnsDef[e]&&t.isSupportedBtn(e)&&u.append(t.buildSubBtn(e))})),t.$box.append(u.hide())}else i.key&&(t.keys[i.key]={fn:i.fn||o,param:i.param||o});return n||(t.tagToButton[(i.tag||o).toLowerCase()]=o),l},buildSubBtn:function(o){var t=this,e=t.o.prefix,i=t.btnsDef[o],n=null==i.hasIcon||i.hasIcon;return i.key&&(t.keys[i.key]={fn:i.fn||o,param:i.param||o}),t.tagToButton[(i.tag||o).toLowerCase()]=o,r("",{type:"button",class:e+o+"-dropdown-button "+(i.class||"")+(i.ico?" "+e+i.ico+"-button":""),html:t.hasSvg&&n?''+(i.text||i.title||t.lang[o]||o):i.text||i.title||t.lang[o]||o,title:i.key?"("+(t.isMac?"Cmd":"Ctrl")+" + "+i.key+")":null,style:i.style||null,mousedown:function(){return r("body",t.doc).trigger("mousedown"),t.execCmd(i.fn||o,i.param||o,i.forceCss),!1}})},isSupportedBtn:function(o){try{return this.btnsDef[o].isSupported()}catch(o){}return!0},buildOverlay:function(){var o=this;return o.$overlay=r("",{class:o.o.prefix+"overlay"}).appendTo(o.$box),o.$overlay},showOverlay:function(){var o=this;r(t).trigger("scroll"),o.$overlay.fadeIn(200),o.$box.addClass(o.o.prefix+"box-blur")},hideOverlay:function(){var o=this;o.$overlay.fadeOut(50),o.$box.removeClass(o.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var o=this,e=o.o.fixedFullWidth,i=o.$box;o.o.fixedBtnPane&&(o.isFixed=!1,r(t).on("scroll."+o.eventNamespace+" resize."+o.eventNamespace,(function(){if(i){o.syncCode();var n=r(t).scrollTop(),a=i.offset().top+1,A=o.$btnPane,l=A.outerHeight()-2;n-a>0&&n-a-o.height<0?(o.isFixed||(o.isFixed=!0,A.css({position:"fixed",top:0,left:e?0:"auto",zIndex:7}),o.$box.css({paddingTop:A.height()})),A.css({width:e?"100%":i.width()-1}),r("."+o.o.prefix+"fixed-top",i).css({position:e?"fixed":"absolute",top:e?l:l+(n-a),zIndex:15})):o.isFixed&&(o.isFixed=!1,A.removeAttr("style"),o.$box.css({paddingTop:0}),r("."+o.o.prefix+"fixed-top",i).css({position:"absolute",top:l}))}})))},setDisabled:function(o){var t=this,e=t.o.prefix;t.disabled=o,o?t.$ta.attr("disabled",!0):t.$ta.removeAttr("disabled"),t.$box.toggleClass(e+"disabled",o),t.$ed.attr("contenteditable",!o)},destroy:function(){var o=this,e=o.o.prefix;o.isTextarea?o.$box.after(o.$ta.css({height:""}).val(o.html()).removeClass(e+"textarea").show()):o.$box.after(o.$edBox.css({height:""}).removeClass(e+"editor").removeAttr("contenteditable").removeAttr("dir").html(o.html()).show()),o.$ed.off("dblclick","img"),o.destroyPlugins(),o.$box.remove(),o.$c.removeData("trumbowyg"),r("body").removeClass(e+"body-fullscreen"),o.$c.trigger("tbwclose"),r(t).off("scroll."+o.eventNamespace+" resize."+o.eventNamespace),r(o.doc.body).off("keydown."+o.eventNamespace)},empty:function(){this.doc.execCommand("insertHTML",!1,""),this.$ta.val(""),this.syncCode(!0)},toggle:function(){var o=this,t=o.o.prefix;o.o.autogrowOnEnter&&(o.autogrowOnEnterDontClose=!o.$box.hasClass(t+"editor-hidden")),o.semanticCode(!1,!0),o.$c.trigger("tbwchange"),setTimeout((function(){o.doc.activeElement.blur(),o.$box.toggleClass(t+"editor-hidden "+t+"editor-visible"),o.$btnPane.toggleClass(t+"disable"),r("."+t+"viewHTML-button",o.$btnPane).toggleClass(t+"active"),o.$box.hasClass(t+"editor-visible")?o.$ta.attr("tabindex",-1):o.$ta.removeAttr("tabindex"),o.o.autogrowOnEnter&&!o.autogrowOnEnterDontClose&&o.autogrowEditorOnEnter()}),0)},toggleSpan:function(o){this.$ed.find("span").each((function(){!0===o?r(this).attr("data-tbw-flag",!0):r(this).attr("data-tbw-flag")?r(this).removeAttr("data-tbw-flag"):r(this).contents().unwrap()}))},dropdown:function(o){var e=this,i=r("body",e.doc),n=e.o.prefix,a=r("[data-"+n+"dropdown="+o+"]",e.$box),A=r("."+n+o+"-button",e.$btnPane),l=a.is(":hidden");if(i.trigger("mousedown"),l){var s=A.offset().left;A.addClass(n+"active"),a.css({position:"absolute",top:A.offset().top-e.$btnPane.offset().top+A.outerHeight(),left:e.o.fixedFullWidth&&e.isFixed?s:s-e.$btnPane.offset().left}).show(),r(t).trigger("scroll"),i.on("mousedown."+e.eventNamespace,(function(o){a.is(o.target)||(r("."+n+"dropdown",e.$box).hide(),r("."+n+"active",e.$btnPane).removeClass(n+"active"),i.off("mousedown."+e.eventNamespace))}))}},html:function(o){var t=this;return null!=o?(t.$ta.val(o),t.syncCode(!0),t.$c.trigger("tbwchange"),t):t.$ta.val()},syncTextarea:function(){var o=this;o.$ta.val(o.$ed.text().trim().length>0||o.$ed.find(o.o.tagsToKeep.join(",")).length>0?o.$ed.html():"")},syncCode:function(o){var t=this;if(!o&&t.$ed.is(":visible"))t.syncTextarea();else{var e=r("