Updating minified JavaScript files
authorwoltlab.com <woltlab@woltlab.com>
Tue, 4 Jul 2017 10:03:38 +0000 (12:03 +0200)
committerwoltlab.com <woltlab@woltlab.com>
Tue, 4 Jul 2017 10:03:38 +0000 (12:03 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wcombined.min.js

index cd71834981cf830b72b933af6b0dbf4efecb1c7a..aeb75b29a15ef85070bd1f0ad145905dd497440d 100644 (file)
@@ -1,8 +1,9 @@
 // table.js
 if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.table=function(){return{getTemplate:function(){return String()+'<section id="redactor-modal-table-insert"><label>'+this.lang.get("rows")+'</label><input type="text" size="5" value="2" id="redactor-table-rows" /><label>'+this.lang.get("columns")+'</label><input type="text" size="5" value="3" id="redactor-table-columns" /></section>'},init:function(){var t={};t.insert_table={title:this.lang.get("insert_table"),func:this.table.show},t.insert_row_above={title:this.lang.get("insert_row_above"),func:this.table.addRowAbove},t.insert_row_below={title:this.lang.get("insert_row_below"),func:this.table.addRowBelow},t.insert_column_left={title:this.lang.get("insert_column_left"),func:this.table.addColumnLeft},t.insert_column_right={title:this.lang.get("insert_column_right"),func:this.table.addColumnRight},t.add_head={title:this.lang.get("add_head"),func:this.table.addHead},t.delete_head={title:this.lang.get("delete_head"),func:this.table.deleteHead},t.delete_column={title:this.lang.get("delete_column"),func:this.table.deleteColumn},t.delete_row={title:this.lang.get("delete_row"),func:this.table.deleteRow},t.delete_table={title:this.lang.get("delete_table"),func:this.table.deleteTable},this.observe.addButton("td","table"),this.observe.addButton("th","table");var e=this.button.addBefore("link","table",this.lang.get("table"));this.button.addDropdown(e,t)},show:function(){this.modal.addTemplate("table",this.table.getTemplate()),this.modal.load("table",this.lang.get("insert_table"),300),this.modal.createCancelButton();var t=this.modal.createActionButton(this.lang.get("insert"));t.on("click",this.table.insert),this.selection.save(),this.modal.show(),$("#redactor-table-rows").focus()},insert:function(){var t,e,i,a,s=$("#redactor-table-rows").val(),l=$("#redactor-table-columns").val(),n=$("<div>"),r=Math.floor(99999*Math.random()),o=$('<table id="table'+r+'"><tbody></tbody></table>');for(t=0;s>t;t++){for(e=$("<tr>"),i=0;l>i;i++)a=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===i&&a.append(this.selection.getMarker()),$(e).append(a);o.append(e)}n.append(o);var d=n.html();if(this.modal.close(),this.selection.restore(),!this.table.getTable()){this.buffer.set();var h=this.selection.getBlock()||this.selection.getCurrent();h&&"BODY"!=h.tagName?("LI"==h.tagName&&(h=$(h).closest("ul, ol")),$(h).after(d)):this.insert.html(d),this.selection.restore();var c=this.$editor.find("#table"+r);if(!this.opts.linebreaks&&(this.utils.browser("mozilla")||this.utils.browser("msie"))){var b=c.next();0===b.length&&c.after(this.opts.emptyHtml)}this.observe.buttons(),c.find("span.redactor-selection-marker").remove(),c.removeAttr("id"),this.code.sync(),this.core.setCallback("insertedTable",c)}},getTable:function(){var t=$(this.selection.getParent()).closest("table");return this.utils.isRedactorParent(t)?0===t.size()?!1:t:!1},restoreAfterDelete:function(t){this.selection.restore(),t.find("span.redactor-selection-marker").remove(),this.code.sync()},deleteTable:function(){var t=this.table.getTable();if(t){this.buffer.set();var e=t.next();this.opts.linebreaks||0===e.length?this.caret.setAfter(t):this.caret.setStart(e),t.remove(),this.code.sync()}},deleteRow:function(){var t=this.table.getTable();if(t){var e=$(this.selection.getCurrent());this.buffer.set();var i=e.closest("tr"),a=i.prev().length?i.prev():i.next();if(a.length){var s=a.children("td, th").first();s.length&&s.prepend(this.selection.getMarker())}i.remove(),this.table.restoreAfterDelete(t)}},deleteColumn:function(){var t=this.table.getTable();if(t){this.buffer.set();var e=$(this.selection.getCurrent()),i=e.closest("td, th"),a=i[0].cellIndex;t.find("tr").each($.proxy(function(t,e){var i=$(e),s=0>a-1?a+1:a-1;0===t&&i.find("td, th").eq(s).prepend(this.selection.getMarker()),i.find("td, th").eq(a).remove()},this)),this.table.restoreAfterDelete(t)}},addHead:function(){var t=this.table.getTable();if(t){if(this.buffer.set(),0!==t.find("thead").size())return void this.table.deleteHead();var e=t.find("tr").first().clone();e.find("td").html(this.opts.invisibleSpace),$thead=$("<thead></thead>").append(e),t.prepend($thead),this.code.sync()}},deleteHead:function(){var t=this.table.getTable();if(t){var e=t.find("thead");0!==e.size()&&(this.buffer.set(),e.remove(),this.code.sync())}},addRowAbove:function(){this.table.addRow("before")},addRowBelow:function(){this.table.addRow("after")},addColumnLeft:function(){this.table.addColumn("before")},addColumnRight:function(){this.table.addColumn("after")},addRow:function(t){var e=this.table.getTable();if(e){this.buffer.set();var i=$(this.selection.getCurrent()),a=i.closest("tr"),s=a.clone();s.find("th").replaceWith(function(){var t=$("<td>");return t[0].attributes=this.attributes,t.append($(this).contents())}),s.find("td").html(this.opts.invisibleSpace),"after"==t?a.after(s):a.before(s),this.code.sync()}},addColumn:function(t){var e=this.table.getTable();if(e){var i=0,a=$(this.selection.getCurrent());this.buffer.set();var s=a.closest("tr"),l=a.closest("td, th");s.find("td, th").each($.proxy(function(t,e){$(e)[0]===l[0]&&(i=t)},this)),e.find("tr").each($.proxy(function(e,a){var s=$(a).find("td, th").eq(i),l=s.clone();l.html(this.opts.invisibleSpace),"after"==t?s.after(l):s.before(l)},this)),this.code.sync()}}}};
 // wbbcode.js
-if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wbbcode=function(){"use strict";var e=!1;return{init:function(){var t=this.$textarea.wcfIdentify();this.opts.initCallback=function(){window.addEventListener("unload",function(){this.code.startSync(),this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()))}.bind(this)),$.browser.msie&&this.$editor.addClass("msie"),this.$textarea[0].setAttribute("data-is-dirty",!0);var e=$.trim(this.wutil.getOption("woltlab.originalValue"));e.length&&(this.wutil.replaceText(e),this.wutil.selectionEndOfEditor()),delete this.opts.woltlab.originalValue,$(document).trigger("resize"),this.wutil.saveSelection();var t=this.$editor[0],i=this.$textarea[0];setTimeout(function(){$.browser.iOS&&0===t.scrollHeight&&(document.activeElement===t||document.activeElement===i)&&document.activeElement.blur()},10)}.bind(this),this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this),this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var i=this.clean.onSync;this.clean.onSync=function(t){return t=t.replace(/\u200C/g,"__wcf_zwnj__"),t=t.replace(/\u200D/g,"__wcf_zwj__"),e===!0?e=!1:t=t.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>"),t=i.call(this,t),t=t.replace(/__wcf_zwnj__/g,"‌"),t.replace(/__wcf_zwj__/g,"‍")}.bind(this),this.wutil.getOption("woltlab.autosaveOnce")&&(this.wutil.saveTextToStorage(),delete this.opts.woltlab.autosaveOnce);var a=this.button.get("table");if(a.length){var r=a.data("dropdown");r.find(".redactor-dropdown-add_head").parent().remove(),r.find(".redactor-dropdown-delete_head").parent().remove(),$('<li class="dropdownDivider" />').insertBefore(r.find(".redactor-dropdown-delete_table").parent()),a.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertQuote()},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_code_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertCode(null,!0)},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+t,$.proxy(this.wbbcode._keydownCallback,this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+t,$.proxy(this.wbbcode._keyupCallback,this)),this.code.sync=function(){};var n=$(".redactor-toolbar-tooltip-html:not(.jsWbbcode)").addClass("jsWbbcode").text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),l=function(e){e.find("br").each(function(e,t){t.children.length&&$(t).empty()})};this.code.toggle=function(){if(this.opts.visual)this.code.startSync(),this.code.showCode(),this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val())),this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square"),n.text(WCF.Language.get("wcf.bbcode.button.toggleHTML"));else{if(this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val())),this.code.offset=this.$textarea.val().length,this.code.showVisual(),this.wutil.fixDOM(),this.wbbcode.fixBlockLevelElements(),this.wutil.selectionEndOfEditor(),this.wbbcode.observeQuotes(),this.wbbcode.observeCodeListings(),this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o"),n.text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),this.wutil.fixDOM(),l(this.$editor),/ Edge\//.test(navigator.userAgent)){var e=this.$editor[0];window.dtdesign=e,e.childElementCount>1&&"​"===e.children[0].innerHTML&&e.removeChild(e.children[0])}this.wutil.saveSelection()}}.bind(this),this.wutil.setOption("clickCallback",function(e){e.target===this.$editor[0]&&this.$editor[0].lastElementChild&&"BLOCKQUOTE"===this.$editor[0].lastElementChild.tagName&&this.wutil.setCaretAfter($(this.$editor[0].lastElementChild)),setTimeout(this.wutil.saveSelection.bind(this),10)}.bind(this));var o=this.opts.verifiedTags.indexOf("ul");o>-1&&this.opts.verifiedTags.splice(o,1),WCF.System.Event.addListener("com.woltlab.wcf.redactor","observe_load_"+t,function(){this.wbbcode.observeCodeListings(),this.wbbcode.observeQuotes()}.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","fixFormatting_"+t,$.proxy(this.wbbcode.fixFormatting,this))},_tableButtonClick:function(e){var t=$(e.currentTarget);if(t.hasClass("dropact")){var i=this.selection.getBlock()||this.selection.getCurrent(),a=t.data("dropdown");a.children("li").show();var r=a.find("> li > .redactor-dropdown-insert_table").parent();"TD"==i.tagName?r.hide():r.nextAll().hide()}},insertSmiley:function(e,t,i){if(i&&this.wbbcode.registerSmiley(e,t),this.opts.visual){this.wutil.restoreSelection();var a=window.getSelection();a.rangeCount&&this.utils.isRedactorParent(a.getRangeAt(0).startContainer)||this.focus.setEnd();var r=a.getRangeAt(0);r.deleteContents();var n=document.createElement("img");n.src=t,n.className="smiley",n.alt=e,r.insertNode(n);var l,o=function(e){return null===e?!1:(e.nodeType===Node.ELEMENT_NODE&&"SPAN"===e.nodeName||e.nodeType===Node.TEXT_NODE)&&" "===e.textContent?!0:!1},c=n,s=n.parentElement;o(n.previousSibling)||(l=document.createTextNode(" "),s.insertBefore(l,n)),o(n.nextSibling)||(l=document.createTextNode(" "),s.lastChild===n?s.appendChild(l):s.insertBefore(l,n.nextSibling),c=l),r=document.createRange(),r.selectNode(c),r.collapse(!1),a.removeAllRanges(),a.addRange(r),this.wutil.saveSelection()}else this.wutil.insertAtCaret(" "+e+" ")},registerSmiley:function(e,t){return __REDACTOR_SMILIES[e]?!1:(__REDACTOR_SMILIES[e]=t,!0)},convertFromHtml:function(e){var t=[],i={html:e};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",i),e=i.html,e=e.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1"),e=e.replace(/(<[^>]+?) rel="[^"]+"/g,"$1"),e=e.replace(/&#(8203|x200b);/g,""),e=e.replace(/&trade;/gi,"™"),e=e.replace(/&copy;/gi,"©"),e=e.replace(/&hellip;/gi,"…"),e=e.replace(/&mdash;/gi,"—"),e=e.replace(/&dash;/gi,"‐");var a={};e=e.replace(/<div([^>]+?)class="codeBox[^"]+"([^>]*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(e,t,i,r,n){var l=t+" "+i,o="",c="";l.match(/data-highlighter="([a-zA-Z]+)"/)&&(o=RegExp.$1),l.match(/data-filename="([^"]+)"/)&&(c=$.trim(RegExp.$1));var s=WCF.getUUID();return a[s]={codeContent:n.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:c.replace(/['"]/g,""),highlighter:"plain"===o?"":o,lineNumber:r>1?r:0},"@@@"+s+"@@@"}),e=e.replace(/\r?\n/g,""),e=e.replace(/<a[^>]*?><\/a>/g,""),e=e.replace(/<p><\/p><table/g,"<table"),e=e.replace(/<\/table><p><\/p>/g,"</table>");for(var r in a)e=e.replace(new RegExp("<p></p>@@@"+r+"@@@<p></p>"),"@@@"+r+"@@@");e=e.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>"),e=e.replace(/<br( \/)?><\/p>/g,"</p>");for(var n=e.split(/(<\/?(?:div|p)>)/),l="",o="",c=0;c<n.length;c++){var s=n[c];"<p>"!=s&&"<div>"!=s&&("</p>"==s||"</div>"==s?(o=$.trim(o),"@@@wcf_empty_line@@@"!=o&&(o+="\n"),l+=o,o=""):0==c||c+1==n.length?l+=s:o+=s)}o&&(l+=o,o=""),e=l,e=e.replace(/@@@wcf_empty_line@@@/g,"\n"),e=e.replace(/\n\n$/,"\n"),e=e.replace(/<br>$/,""),e=e.replace(/<br>/g,"\n"),e=e.replace(/<br>/g,""),e=e.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(e,t){var i,a="",r="";return t.match(/data-author="([^"]+)"/)&&(a=WCF.String.unescapeHTML(RegExp.$1)),t.match(/cite="([^"]+)"/)&&(r=WCF.String.unescapeHTML(RegExp.$1)),i=r?"[quote='"+a+"','"+r+"']":a?"[quote='"+a+"']":"[quote]"}),e=e.replace(/(?:\n*)<\/blockquote>\n?/gi,"\n[/quote]\n"),e=e.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]"),e=e.replace(/<a[^>]+><\/a>/,""),e=e.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(e,t,i,a){return i==a?"[url]"+i+"[/url]":"[url='"+i+"']"+a+"[/url]"}),e=e.replace(/<(?:b|strong)>/gi,function(){return-1===t.indexOf("b")&&t.push("b"),"[b]"}),e=e.replace(/<\/(?:b|strong)>/gi,"[/b]"),e=e.replace(/<(?:i|em)>/gi,function(){return-1===t.indexOf("i")&&t.push("i"),"[i]"}),e=e.replace(/<\/(?:i|em)>/gi,"[/i]"),e=e.replace(/<u>/gi,function(){return-1===t.indexOf("u")&&t.push("u"),"[u]"}),e=e.replace(/<\/u>/gi,"[/u]"),e=e.replace(/<sub>/gi,function(){return-1===t.indexOf("sub")&&t.push("sub"),"[sub]"}),e=e.replace(/<\/sub>/gi,"[/sub]"),e=e.replace(/<sup>/gi,function(){return-1===t.indexOf("sup")&&t.push("sup"),"[sup]"}),e=e.replace(/<\/sup>/gi,"[/sup]"),e=e.replace(/<(?:s(trike)?|del)>/gi,function(){return-1===t.indexOf("s")&&t.push("s"),"[s]"}),e=e.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");for(var d=e.split(/(<\/?span[^>]*>)/),o=[],h=[],p="",g={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36},c=0;c<d.length;c++){var u=d[c];if("</span>"==u){var f=h.pop(),l=f.start+o.pop()+f.end;o.length?o[o.length-1]+=l:p+=l}else if(u.match(/^<span/))if(u.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var m,v,b=RegExp.$1.replace(/&quot;/g,'"');if(b.match(/(?:^|;\s*)color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var w=RegExp.$1,E=RegExp.$2,C=RegExp.$3,x="0123456789ABCDEF".charAt((w-w%16)/16)+""+"0123456789ABCDEF".charAt(w%16)+("0123456789ABCDEF".charAt((E-E%16)/16)+""+"0123456789ABCDEF".charAt(E%16))+("0123456789ABCDEF".charAt((C-C%16)/16)+""+"0123456789ABCDEF".charAt(C%16));m="[color=#"+x+"]",v="[/color=#"+x+"]",-1===t.indexOf("color")&&t.push("color")}else b.match(/(?:^|;\s*)color: ?([^;]+);?/i)?(m="[color="+RegExp.$1+"]",v="[/color="+RegExp.$1+"]",-1===t.indexOf("color")&&t.push("color")):b.match(/font-size: ?(\d+)(pt|px);?/i)?"pt"==RegExp.$2?(m="[size="+RegExp.$1+"]",v="[/size="+RegExp.$1+"]",-1===t.indexOf("size")&&t.push("size")):g[RegExp.$1]?(m="[size="+g[RegExp.$1]+"]",v="[/size="+g[RegExp.$1]+"]",-1===t.indexOf("size")&&t.push("size")):(m="",v=""):b.replace(/"/g,"").match(/font-family: ?([^;]+);?/)?(m="[font='"+RegExp.$1.replace(/'/g,"")+"']",v="[/font='"+RegExp.$1.replace(/'/g,"")+"']",-1===t.indexOf("font")&&t.push("font")):(m='<span style="'+b+'">',v="</span>");o[o.length]="",h[o.length]={start:m,end:v}}else u.match(/^<span class="inlineCode">/)?(o[o.length]="",h[o.length]={start:"[tt]",end:"[/tt]"}):(o[o.length]="",h[o.length]={start:"",end:""});else o.length?o[o.length-1]+=u:p+=u}if(e=p,e=e.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(e,i,a,r){return-1===t.indexOf("align")&&t.push("align"),"[align="+a+"]"+$.trim(r)+"[/align="+a+"]\n"}),t.length){for(var y=!0;y;)y=!1,e=e.replace(new RegExp("\\[((?:"+t.join("|")+")=[^\\]]+?)\\]\n\\[\\/\\1\\]","gi"),function(e,t){return y=!0,"["+t+"][/"+t+"]"});for(y=!0;y;)y=!1,e=e.replace(new RegExp("\\[\\/((?:"+t.join("|")+")=[^\\]]+?)\\]\n\\[\\1\\]","gi"),function(){return y=!0,"\n"});e=e.replace(new RegExp("\\[\\/("+t.join("|")+")=[^\\]]+?\\]","gi"),"[/$1]")}e=e.replace(/ ?<img [^>]*?alt="([^"]+?)"[^>]*?class="smiley"[^>]*?> ?/gi," $1 "),e=e.replace(/ ?<img [^>]*?class="smiley"[^>]*?alt="([^"]+?)"[^>]*?> ?/gi," $1 "),e=e.replace(/<img([^>]*?)class="[^"]*redactorEmbeddedAttachment[^"]*"([^>]*?)>/gi,function(e,t,i){var a,r=t+" "+i;if(!r.match(/data-attachment-id="(\d+)"/))return e;a=RegExp.$1;var n="none",l=null;if(r.match(/style="([^"]+)"/)){for(var o=RegExp.$1.split(";"),c=0;c<o.length;c++){var s=$.trim(o[c]);s.match(/^float: (left|right)$/)?n=RegExp.$1:s.match(/^width: (\d+)px$/)&&(l=RegExp.$1)}if(null!==l)return"[attach="+a+","+n+","+l+"][/attach]";if("none"!==n)return"[attach="+a+","+n+"][/attach]"}return"[attach="+a+"][/attach]"}),e=e.replace(/<img([^>]*)?src=(["'])([^"']+?)\2([^>]*)?>/gi,function(e,t,i,a,r){var n=t+" "+r,l="";n.match(/style="([^"]+)"/)&&(l=RegExp.$1);for(var o="none",c=0,s=l.split(";"),d=0;d<s.length;d++){var h=s[d];h.match(/float: (left|right|none)/)?o=RegExp.$1:h.match(/width: (\d+)px/)&&(c=parseInt(RegExp.$1))}return c?"[img='"+a+"',"+o+","+c+"][/img]":"none"!==o?"[img='"+a+"',"+o+"][/img]":"[img]"+a+"[/img]"}),e=e.replace(/<li>/gi,"[*]"),e=e.replace(/<\/li>/gi,"\n"),e=e.replace(/<ul>/gi,"[list]"),e=e.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]"),e=e.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]"),e=e.replace(/<\/(ul|ol)>/gi,"[/list]"),e=e.replace(/\n?\[list\]/g,"\n[list]"),e=e.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]"),e=e.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]"),e=e.replace(/<table[^>]*>/gi,"[table]\n"),e=e.replace(/<\/table>\n?/gi,"[/table]\n"),e=e.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(e,t){return $.trim(t)}),e=e.replace(/<tr><\/tr>/gi,""),e=e.replace(/<tr>/gi,"[tr]\n"),e=e.replace(/<\/tr>/gi,"[/tr]\n"),e=e.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]"),e=e.replace(/(\t)*<td>(\t)*/gi,"[td]"),e=e.replace(/(\t)*<\/td>/gi,"[/td]\n");var S={};if(e.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(e){var t=e.hashCode();return S[t]=e.replace(/\$/g,"$$$$"),"@@"+t+"@@"}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:e}),e=e.replace(/<[^(<|>)]+>/g,""),$.getLength(S))for(var _ in S){var k=new RegExp("@@"+_+"@@","g");e=e.replace(k,S[_])}return $.getLength(a)&&$.each(a,function(t,i){var a=0;i.highlighter&&a++,i.lineNumber&&a++,i.filename&&a++;var r="";switch(a){case 1:r=i.highlighter?i.highlighter:i.filename?"'"+i.filename+"'":i.lineNumber;break;case 2:i.lineNumber&&(r=i.lineNumber),i.highlighter&&(r.length&&(r+=","),r+=i.highlighter),i.filename&&(r.length&&(r+=","),r+="'"+i.filename+"'");break;case 3:r=i.highlighter+","+i.lineNumber+",'"+i.filename+"'"}var n="[code"+(r.length?"="+r:"")+"]"+i.codeContent+"[/code]\n";e=e.replace(new RegExp("@@@"+t+"@@@\n?","g"),n.replace(/\$/g,"$$$"))}),e=e.replace(/&lt;/g,"<"),e=e.replace(/&gt;/g,">"),e=e.replace(/&amp;/g,"&"),e=e.replace(/%28/g,"("),e=e.replace(/%29/g,")"),i={html:e},WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",i),e=i.html,e=$.trim(e),e.length&&(e+="\n"),e},convertToHtml:function(e){var t={data:e};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",t),e=t.data,e=this.wutil.removeZeroWidthSpace(e),e=e.replace(/&/g,"&amp;"),e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;");var i=[],a=new RegExp("\\[("+__REDACTOR_SOURCE_BBCODES.join("|")+")([\\S\\s]+?)\\[\\/\\1\\]","gi");e=e.replace(a,function(e){var t=e.hashCode();return i.push({key:t,value:e.replace(/\$/g,"$$$$")}),"@@"+t+"@@"}),e=e.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>'+this.opts.invisibleSpace),e=e.replace(/\[url\='([^'"]+)']([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[url\=([^'"\]]+)]([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>'+this.opts.invisibleSpace),e=e.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[(b|i|s|sub|sup|u)\]\[\1\]/gi,"[$1]"),e=e.replace(/\[(\/(?:b|i|s|sub|sup|u))\]\[\1\]/gi,"[$1]"),e=e.replace(/\[(b|i|s|sub|sup|u)\]\[\/\1\]/gi,""),e=e.replace(/\[b\]([\s\S]*?)\[\/b]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<strong>","</strong>")}.bind(this)),e=e.replace(/\[i\]([\s\S]*?)\[\/i]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<em>","</em>")}.bind(this)),e=e.replace(/\[u\]([\s\S]*?)\[\/u]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<u>","</u>")}.bind(this)),e=e.replace(/\[s\]([\s\S]*?)\[\/s]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<del>","</del>")}.bind(this)),e=e.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<sub>","</sub>")}.bind(this)),e=e.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<sup>","</sup>")}.bind(this)),e=e.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />'),e=e.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,function(e,t,i){var a="float: "+i+";";return a+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px",'<img src="'+t+'" style="'+a+'" />'}),e=e.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi,function(e,t,i,a){var r="float: "+i+"; width: "+a+"px;";return r+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px",'<img src="'+t+'" style="'+r+'" />'}),e=e.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />'),e=e.replace(/\[size=(\d+)\]([\s\S]*?)\[\/size\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="font-size: '+t+'pt">',"</span>")}.bind(this)),e=e.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="color: '+t+'">',"</span>")}.bind(this)),e=e.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="font-family: '+t+'">',"</span>")}.bind(this)),e=e.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<p style="text-align: '+t+'">',"</p>")}.bind(this));var r=e.indexOf("[list");if(r>0){var n=e.substr(0,r);n=n.replace(/\[\*\]/g,""),e=n+e.substr(r)}var l=e.lastIndexOf("[/list]");if(-1===l)e=e.replace(/\[\*\]/g,""),e=e.replace(/\[list[^\]]*\]/g,"");else{var n=e.substr(l+7);n=n.replace(/\[\*\]/g,""),e=e.substr(0,l+7)+n}e=e.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi,function(e,t){return"<li>"+$.trim(t)+"</li>"}),e=e.replace(/\n*(\[list\]<\/li>)/g,"$1"),e=e.replace(/\[list\]/gi,"<ul>"),e=e.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">'),e=e.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">'),e=e.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">'),e=e.replace(/\[\/list\]/gi,"</ul>"),e=e.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(e,t){return"[table]"+$.trim(t)+"[/table]"}),e=e.replace(/\[table\]\n*/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">'),e=e.replace(/\[\/table\](\n*)?/gi,function(e,t){return t?(t.match(/\n/g).length>2&&(t=t.replace(/^\n/,"")),"</table>"+t):"</table>"}),e=e.replace(/\[tr\]\n*/gi,"<tr>"),e=e.replace(/\[\/tr\]\n*/gi,"</tr>"),e=e.replace(/\[td\]\n*/gi,"<td>"),e=e.replace(/\[\/td\]\n*/gi,"</td>"),e=e.replace(/<td>([\S\s]*?)<\/td>/gi,function(e,t){var i=$.trim(t);return i.length||(i="&#8203;"),"<td>"+i+"</td>"});var o=this.wutil.getOption("woltlab.attachmentUrl"),c=this.wutil.getOption("woltlab.attachmentThumbnailUrl");if(o){var s=this.wbbcode._getImageAttachments();e=e.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(e,t){return t=parseInt(t),void 0!==s[t]?'<img src="'+c.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+t+'" />':e}),e=e.replace(/\[attach=(\d+),(left|right|none)\]\[\/attach\]/g,function(e,t,i){if(t=parseInt(t),void 0!==s[t]){var a="";return("left"===i||"right"===i)&&(a="float: "+i+";",a+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px"),a=' style="'+a+'"','<img src="'+c.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+t+'"'+a+" />"}return e}),e=e.replace(/\[attach=(\d+),(left|right|none),(\d+)\]\[\/attach\]/g,function(e,t,i,a){if(t=parseInt(t),void 0!==s[t]){var r="width: "+a+"px; max-height: "+s[t].height+"px; max-width: "+s[t].width+"px;";return("left"===i||"right"===i)&&(r+="float: "+i+";",r+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px"),r=' style="'+r+'"','<img src="'+o.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+t+'"'+r+" />"}return e})}for(var d in __REDACTOR_SMILIES){var h=d.replace(/</g,"&lt;").replace(/>/g,"&gt;"),p=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(h)+"(?=\\s|<|$)","gi");e=e.replace(p,'$1<img src="'+__REDACTOR_SMILIES[d]+'" class="smiley" alt="'+h+'" />')}e=e.replace(/(javascript):/gi,"$1<span></span>:"),e=e.replace(/(\r|\r\n)/g,"\n");for(var g=[],u=[],f=e.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/i),m=WCF.getUUID();;){for(var v=!1,b=0;b<f.length;b++){var w=f[b];if("[/quote]"===w.toLowerCase()){v=!0;for(var E="",C=f.slice(0,b),x=!1;C.length;){var y=C.pop();if(E=y+E,y.match(/^\[quote/i)){w=E+w;var S=WCF.getUUID();g.push({hashCode:S,content:w.replace(/\$/g,"$$$$")}),u.push(S),w="@@"+S+"@@",x=!0;break}}x||(C=f.slice(0,b),w=m),f=C.concat(w,f.slice(b+1));break}}if(!v)break}e=f.join(""),e=e.replace(new RegExp(m,"g"),"[/quote]"),e=e.replace(/\n*$/,"");var _=[];e=e.replace(/(<li>[\s\S]*?<\/li>)/g,function(e){e=$.trim(e).replace(/\n/g,"<br>");var t=WCF.getUUID();return _.push({key:t,content:e}),t});var n=e.split("\n");e="";for(var b=0,k=n.length;k>b;b++){var R=$.trim(n[b]);if(R.match(/^<([a-z]+)/)||R.match(/<\/([a-z]+)>$/))e+=this.reIsBlock.test(RegExp.$1.toUpperCase())||"TABLE"===RegExp.$1.toUpperCase()?R.match(/^<([a-z]+).*<\/\1>/)?R:R+"<br />":"<p>"+R+"</p>";else{if(R){if(R.match(/^@@([0-9\-]+)@@$/)&&WCF.inArray(RegExp.$1,u)){e+=R;continue}}else R="<br>";e+="<p>"+R+"</p>"}}if(e=e.replace(/<td>([\s\S]+?)<\/td>/g,function(e,t){return t=t.replace(/<br(?: \/)?>(<[uo]l)/g,"$1"),"<td>"+t.replace(/<p><br(?: \/)?><\/p>/g,"<br>").replace(/<p>/g,"").replace(/<\/p>/g,"<br>").replace(/<br>$/,"")+"</td>"}),_.length)for(var b=_.length-1;b>=0;b--)e=e.replace(_[b].key,_[b].content);if(g.length)for(var T=function(e){return e.replace(/^['"]/,"").replace(/['"]$/,"")},L=this,F=function(e){return e.replace(/\[quote(=(['"]).+?\2)?\]([\S\s]*)\[\/quote\]/gi,function(e,t,i,a){var r="",n="";if(t){switch(t=t.substr(1),t=t.split(","),t.length){case 1:r=t[0];break;case 2:r=t[0],n=t[1]}r=WCF.String.escapeHTML(T($.trim(r))),n=WCF.String.escapeHTML(T($.trim(n)))}var l='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+n+'" data-author="'+r+'"><header contenteditable="false"><h3>'+L.wbbcode._buildQuoteHeader(r,n)+'</h3><a class="redactorQuoteEdit"></a></header>';a=$.trim(a);var o="";if(a.length){var c=[];a=a.replace(/(<(ol|ul)[^>]*>[\s\S]+?<\/\2>)/g,function(e){var t=WCF.getUUID();return c.push({hash:t,content:e}),"@@"+t+"@@"});for(var s=a.split("\n"),d=0;d<s.length;d++){var h=s[d];if(0===h.length)h=L.opts.invisibleSpace;else if(h.match(/^@@([0-9\-]+)@@$/)&&WCF.inArray(RegExp.$1,u)){o+=h;continue}o+="<div>"+h+"</div>"}if(c.length)for(var d=0,p=c.length;p>d;d++){var g=c[d].content;g=g.replace(/(<li>[\s\S]*?<\/li>)/g,function(e){return $.trim(e).replace(/\n/g,"<br>")}),o=o.replace(new RegExp("@@"+c[d].hash+"@@"),g)}}else o="<div>"+L.opts.invisibleSpace+"</div>";return l+=o,l+="</blockquote>"})},b=g.length-1;b>=0;b--){var A=g[b],O=new RegExp("@@"+A.hashCode+"@@","g");e=e.replace(O,F(A.content))}if(e=e.replace(/<(?:div|p)><(blockquote|div)/g,"<$1"),e=e.replace(/<\/(blockquote|div)><\/(?:div|p)>/g,"</$1>"),i.length)for(var b=i.length-1;b>=0;b--){var B=i[b],O=new RegExp("@@"+B.key+"@@","g"),N=B.value;N=N.replace(/^\[tt\]([\s\S]+)\[\/tt\]/,function(e,t){var i=t.split("\n");t="";for(var a=0,r=i.length;r>a;a++){var n=i[a];if(n.length)t.length&&(t+="</p><p>"),t+="[tt]"+n+"[/tt]";else{if(0===a||a+1===r)continue;t+=t.match(/\[\/tt\]$/)?"</p><p>"+this.opts.invisibleSpace:"</p><p><br>"}}return t}.bind(this)),N=N.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,function(e,t,i){var a="plain",r=0,n="";if(t){t=t.substring(1),t=t.split(",");var l=function(e){return e.match(/^\d+$/)},o=function(e){return-1!==e.indexOf(".")||e.match(/^(["']).*\1$/)},c=function(e){return void 0!==__REDACTOR_CODE_HIGHLIGHTERS[e]},s=function(e){return e.replace(/^(["'])(.*)\1$/,"$2")};switch(t.length){case 1:l(t[0])?r=parseInt(t[0])>1?t[0]:0:o(t[0])?n=s(t[0]):c(t[0])&&(a=t[0]);break;case 2:l(t[0])?(r=parseInt(t[0])>1?t[0]:0,c(t[1])?a=t[1]:o(t[1])&&(n=s(t[1]))):(c(t[0])&&(a=t[0]),o(t[1])&&(n=s(t[1])));break;case 3:c(t[0])&&(a=t[0]),l(t[1])&&(r=t[1]),o(t[2])&&(n=s(t[2]))}}i=i.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);for(var d="",h=0;h<i.length;h++){var p=i[h];p.length||(p=this.opts.invisibleSpace),d+="<li>"+p+"</li>"}return'<div class="codeBox container" contenteditable="false" data-highlighter="'+a+'"'+(n?' data-filename="'+WCF.String.escapeHTML(n)+'"':"")+"><div><div><h3>"+__REDACTOR_CODE_HIGHLIGHTERS[a]+(n?": "+WCF.String.escapeHTML(n):"")+'</h3></div><ol start="'+(r>1?r:1)+'">'+d+"</ol></div></div>"}.bind(this)),e=e.replace(O,N)}return e=e.replace(/&amp;nbsp;/g,"&amp;amp;nbsp;"),t={data:e},WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",t),e=t.data},_expandFormatting:function(e,t,i){if(!e.length)return t+this.opts.invisibleSpace+i;var a=e.indexOf("[/td]");if(-1!==a){var r=e.substring(0,a);if(-1===r.indexOf("[td]"))return t+r+i+e.substring(a)}var r=e.split("\n");e="";for(var n=0,l=r.length;l>n;n++){var o=r[n];0===o.length&&(o=this.opts.invisibleSpace),e.length&&(e+="\n"),e+=t+o+i}return e},_pasteBeforeCallback:function(e){var t={1:24,2:22,3:18,4:14,5:12,6:10};return e=e.replace(/<h([1-6])([^>]*)>/g,function(e,i,a){if(a&&a.match(/style="([^"]+?)"/)&&/font-size: ?(\d+|\d+\.\d+)(px|pt|em|rem|%)/.test(RegExp.$1)){var r=$('<div style="width: '+RegExp.$1+RegExp.$2+'; position: absolute;" />').appendTo(document.body),n=parseInt(r[0].clientWidth);r.remove();var l=-1,o=!1;$.each(t,function(e,i){-1===l?l=e:Math.abs(n-i)<Math.abs(n-t[l])&&(l=e),n==i&&(o=!0)}),o||(l=6>l?parseInt(l)+1:l),i=l}return"[size="+t[i]+"]"}),e=e.replace(/<\/h[1-6]>/g,"[/size]"),(/<p class="Mso(?:Normal|NoSpacing)/.test(e)||/margin-bottom: 0cm/.test(e))&&(e=e.replace(/([^>\s])\n([^<\s])/g,"$1 $2"),e=e.replace(/<a name="[^"]+">/g,"")),e=e.replace(/<o:p>&nbsp;<\/o:p>/g,"<br>"),e=e.replace(/<(article|header)[^>]+>/g,"<div>"),e=e.replace(/<\/(article|header)>/g,"</div>"),e=e.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>"),e=e.replace(/<\/(div|p)><\/(div|p)>/g,"</p>"),e=e.replace(/<(?:div|p|span)[^>]+>/gi,function(e){return e.replace(/ class="[^"]+"/,"")}),e=e.replace(/<\/?wbr[^>]*>/g,""),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:e}),e},_pasteCallback:function(e){return e=e.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">'),e=e.replace(/\[\/size\]/g,"</span></p>"),e=e.replace(/style="([^"]+)"/,function(e,t){for(var i=t.split(";"),a=[],r=0,n=i.length;n>r;r++){var l=i[r];l.match(/^\s*background-color/)||a.push(l)}return'style="'+a.join(";")+'"'}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:e}),e},insertAttachment:function(e,t){e=parseInt(e);var i=this.wutil.getOption("woltlab.attachment"+(t?"":"Thumbnail")+"Url"),a=this.wbbcode._getImageAttachments();if(i&&void 0!==a[e]){var r="";t&&(r=' style="width: '+a[e].width+"px; max-height: "+a[e].height+"px; max-width: "+a[e].width+'px;"'),this.wutil.insertDynamic('&#8203;<img src="'+i.replace(/987654321/,e)+'" class="redactorEmbeddedAttachment'+(t?"":" redactorDisableResize")+'" data-attachment-id="'+e+'"'+r+" />&#8203;","[attach="+e+(t?",none,"+a[e].width:"")+"][/attach]")}else this.wutil.insertDynamic("[attach="+e+"][/attach]")},removeAttachment:function(e){this.opts.visual&&this.$editor.find("img.redactorEmbeddedAttachment").each(function(t,i){var a=$(i);a.data("attachmentID")==e&&a.remove()})},_getImageAttachments:function(){var e=this.wutil.getOption("woltlab.attachmentImages")||[];if(e.length)return delete this.opts.attachmentImages,e;var t={imageAttachments:{}};return WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),t),t.imageAttachments},_keydownCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.UP:case 83:break;default:return}this.selection.get();var t=this.selection.getCurrent(),i=this.selection.getParent();i=i?$(i):i;var a=i?i.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(e.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var r=!1;if(a.length){for(var n=!0,l=0;l<a[0].children.length;l++){var o=a[0].children[l];if("DIV"===o.tagName&&o.textContent.replace(/\u200b/,"").length){n=!1;break}}if(n)r=!0;else{var c=null===this.selection.implicitRange?this.range:this.selection.implicitRange;if(0===c.startOffset)for(var s,d=c.startContainer;null!==(d=d.parentNode);)if(s=d.previousSibling,null!==s){s.nodeType===Node.ELEMENT_NODE&&"HEADER"===s.nodeName&&(r=!0);break}}}if(r){var h=window.getSelection();h.rangeCount&&h.removeAllRanges();var p=document.createRange();p.selectNode(a[0]||a),h.addRange(p),e.cancel=!0}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(t)){var g=t.nextElementSibling;if(g&&"BLOCKQUOTE"===g.tagName){var h=window.getSelection();h.rangeCount&&h.removeAllRanges();var p=document.createRange();p.selectNode(g),h.addRange(p),e.cancel=!0}}break;case $.ui.keyCode.DOWN:var u=$(t);if(u.next("blockquote").length)this.caret.setStart(u.next().children("div:first")),e.cancel=!0;else if(i)if(i.next("blockquote").length)this.caret.setStart(i.next().children("div:first")),e.cancel=!0;else if(a.length){var f=u.closest("div",a[0]);f.next().length||(a.next().length?this.caret.setStart(a.next()):this.wutil.setCaretAfter(a),e.cancel=!0)}break;case $.ui.keyCode.ENTER:a.length&&(this.keydown.blockquote=!1,this.keydown.enterWithinBlockquote=!0);break;case $.ui.keyCode.UP:if(!i||!a.length)return;var f=$(t).closest("div",a[0]),m=f.prev();if("DIV"===m[0].tagName)return;if("BLOCKQUOTE"===m[0].tagName)return;var v=a.prev();0===v.length?this.wutil.setCaretBefore(a):"BLOCKQUOTE"===v[0].tagName?this.caret.sendEnd(v.children("div:last")):(""==$.trim(v.html())&&v.html(this.opts.invisibleSpace),this.caret.setEnd(v)),e.cancel=!0;break;case 83:if($.browser.mobile||$.browser.touch)return;var b=!1;if(navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(b=!0):e.event.altKey&&!e.event.ctrlKey&&(b=!0),b){var w={cancel:!1};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),w),w.cancel&&(e.cancel=!0)}}},_keyupCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:this.$editor.find("blockquote").each(function(e,t){var i=$(t);i.children("header").length||i.remove()});break;case $.ui.keyCode.ENTER:for(var t=0,i=this.$editor[0].children.length;i>t;t++){var a=this.$editor[0].children[t];if(a.nodeType===Node.ELEMENT_NODE&&"P"===a.tagName&&!(a.textContent.length>0||a.children.length>1||"BR"===a.children[0].tagName)){for(a=a.children[0];1===a.children.length;)a=a.children[0];if(0===a.children.length&&"BR"===a.tagName){var r=a.parentNode,n=document.createTextNode("​");r.appendChild(n),r.removeChild(a)}}}}},observeQuotes:function(){this.$editor.find(".redactorQuoteEdit").off("click.wbbcode").on("click.wbbcode",$.proxy(this.wbbcode._observeQuotesClick,this))},_observeQuotesClick:function(e){var t=$(e.currentTarget).closest("header"),i=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").on("click touchstart",$.proxy(function(t){t.preventDefault(),t.stopPropagation(),this.wbbcode._openQuoteEditOverlay($(e.currentTarget).closest("blockquote.quoteBox"),!1),$(".redactor-link-tooltip").remove()},this)).appendTo(i),$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.delete")+"</a>").on("click touchstart",function(e){e.preventDefault(),e.stopPropagation();var i=t.parent(),a=i.parent();i.remove(),$(".redactor-link-tooltip").remove(),"BLOCKQUOTE"===a[0].nodeName&&0===a.children("div").length&&$("<div>​</div>").appendTo(a)}).appendTo(i);var a=t.offset();i.css({left:a.left+"px",top:a.top+20+"px"}),$(".redactor-link-tooltip").remove(),i.appendTo(document.body),this.selection.remove()},observeCodeListings:function(){this.$editor.find(".codeBox").each(function(e,t){var i=$(t),a=i.find(".redactorEditCodeBox");a.length||(a=$('<div class="redactorEditCodeBox"><div>'+WCF.Language.get("wcf.bbcode.code.edit")+"</div></div>").insertAfter(i.find("> div > div > h3"))),
-a.off("click.wbbcode").on("click.wbbcode",function(){this.wbbcode._handleInsertCode(i,!1)}.bind(this))}.bind(this))},_openQuoteEditOverlay:function(t,i){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(i?"insert":"edit")),400);var a=this.modal.createActionButton(this.lang.get("save"));i?(this.selection.save(),a.click($.proxy(function(){var t=$("#redactorQuoteAuthor").val(),i=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.selection.restore(),e=!0;var a=this.selection.getHtml();this.utils.isEmpty(a)&&(a="");var r=this.wbbcode.insertQuoteBBCode(t,i,a);null!==r&&(a.length||($.browser.mozilla&&r.children("br[type=_moz]").replaceWith("<div>"+this.opts.invisibleSpace+"</div>"),this.caret.setStart(r.children("div")[0]))),this.modal.close()},this))):($("#redactorQuoteAuthor").val(t.data("author")),$("#redactorQuoteLink").val(WCF.String.unescapeHTML(t.attr("cite"))),a.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();t.data("author",e),t.attr("data-author",e),t.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val())),this.wbbcode._updateQuoteHeader(t),this.modal.close()},this))),this.modal.show()},_updateQuoteHeader:function(e){var t=e.data("author"),i=e.attr("cite");i&&(i=WCF.String.escapeHTML(i)),e.find("> header > h3").empty().append(this.wbbcode._buildQuoteHeader(t,i))},insertQuoteBBCode:function(e,t,i,a){var r="[quote]",n="[/quote]";e&&(r=t?"[quote='"+e+"','"+t+"']":"[quote='"+e+"']");var l=null;if(this.wutil.inWysiwygMode()){var o="quote"+WCF.getUUID(),c="";a?c=this.wbbcode.convertToHtml(r+a+n):(c=this.wbbcode.convertToHtml(r+o+n),c=c.replace(o,i.replace(/^<p>/,"").replace(/<\/p>$/,""))),c=c.replace(/^<p>/,"").replace(/<\/p>$/,""),c=c.replace(/<blockquote/,'<blockquote id="'+o+'"'),window.getSelection().rangeCount||(this.wutil.restoreSelection(),window.getSelection().rangeCount||(this.$editor.focus(),window.getSelection().rangeCount||this.wutil.selectionEndOfEditor(),this.wutil.saveSelection())),window.getSelection().getRangeAt(0).deleteContents(),this.wutil.restoreSelection();for(var s=window.getSelection().getRangeAt(0),d=s.startContainer;d;){var h=d.parentNode;if(h===this.$editor[0])break;d=h}var p=-1,g=this.$editor[0];if(d&&d.parentNode===g&&d.innerHTML.length>0)for(var u=0;u<g.childNodes.length;u++)if(g.childNodes[u]===d){p=u+1;break}-1===p&&(p=g.childNodes.length);var f=document.createRange();f.setStart(g,p),f.setEnd(g,p);var m=window.getSelection();m.removeAllRanges(),m.addRange(f);var v=document.createElement("span");f.insertNode(v),c=$("<div />").html(c)[0].innerHTML;var b=v.previousElementSibling;if(b&&"P"===b.nodeName&&"​"===b.innerHTML&&g.removeChild(b),v.outerHTML=c,l=this.$editor.find("#"+o),l.length){var w=l.find("> div");if(1===w.length)""===w[0].innerHTML&&(w[0].innerHTML=this.opts.invisibleSpace);else if($.browser.mozilla){var E=l.find("> div > br[type=_moz]");E.length&&($("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(E),E.remove())}l.removeAttr("id"),this.wutil.setCaretAfter(l[0]);var C=l[0].previousElementSibling;null!==C&&"P"===C.nodeName&&"​"===C.innerHTML&&(C=C.previousElementSibling,null===C||"P"!==C.nodeName||"​"!==C.innerHTML&&"<br>"!==C.innerHTML||C.parentNode.removeChild(C.nextElementSibling))}this.wbbcode.observeQuotes(),this.wbbcode.fixBlockLevelElements(),this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else this.wutil.insertAtCaret(r+a+n);return this.wutil.saveSelection(),l},_buildQuoteHeader:function(e,t){var i="";return!e&&t&&(e=t,t=""),e?(t&&(i+='<a href="'+t+'" tabindex="-1">'),i+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(e)}),t&&(i+="</a>")):i="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>",i},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,!0)},_handleInsertCode:function(e,t){this.modal.load("code",WCF.Language.get("wcf.bbcode.code."+(t?"insert":"edit")),400);var i=this.modal.createActionButton(this.lang.get("save")).addClass("buttonPrimary");if(t){this.selection.get();var a=this.selection.getText();$.browser.mozilla&&(a=a.replace(/\r/g,"").replace(/\u200b/g,""),a=a.replace(/(\n+)/g,function(e,t){var i=t.match(/\n/g).length;for(i=~~(i/2),t="";i>0;)t+="\n",i--;return t})),this.selection.save(),this.modal.show();var r=$("#redactorCodeBox").focus();r.val(a),i.click($.proxy(function(){var e=$("#redactorCodeBox"),t=$("#redactorCodeFilename"),i=$("#redactorCodeHighlighter"),a=$("#redactorCodeLineNumber"),r=e.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(r).length)return void(e.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(e));var n=$.trim(t.val().replace(/['"]/g,"")),l="[code="+i.val()+","+a.val()+(n.length?",'"+n+"'":"")+"]";l.match(/\[code=([^,]+),(\d+)\]/)&&(l="[code="+RegExp.$2+","+RegExp.$1+"]"),l+=r,l+="[/code]",this.wutil.adjustSelectionForBlockElement(),this.wutil.saveSelection();var o=this.wbbcode.convertToHtml(l);this.buffer.set(),this.insert.html(o,!1);var e=this.$editor.find(".codeBox:not(.jsRedactorCodeBox)");this.wbbcode.observeCodeListings(),this.wbbcode.fixBlockLevelElements(),e.attr("contenteditable","false"),this.wutil.setCaretAfter(e[0]),this.modal.close()},this))}else{var n=this.modal.createActionButton(WCF.Language.get("wcf.global.button.delete"));n.click(function(){this.buffer.set(),e.remove(),this.modal.close()}.bind(this)),this.modal.show();var r=$("#redactorCodeBox").focus(),l=$("#redactorCodeFilename"),o=$("#redactorCodeHighlighter"),c=$("#redactorCodeLineNumber");o.val(e.data("highlighter")),l.val(e.data("filename")||"");var s=e.find("> div > ol");c.val(parseInt(s.prop("start")));var d="";s.children("li").each(function(e,t){d+=$(t).text().replace(/^\u200b$/,"")+"\n"}),r.val(d.replace(/^\n+/,"").replace(/\n+$/,"")),i.click($.proxy(function(){var t=r.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(t).length)return void(r.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(r));var i=o.val();e.data("highlighter",i),e.attr("data-highlighter",i);var a=__REDACTOR_CODE_HIGHLIGHTERS[i],n=$.trim(l.val().replace(/['"]/g,""));n?(a+=": "+WCF.String.escapeHTML(n),e.data("filename",n),e.attr("data-filename",n)):(e.removeAttr("data-filename"),e.removeData("filename")),e.data("highlighter",o.val()),e.find("> div > div > h3").html(a);var s=e.find("> div > ol").empty(),d=parseInt(c.val());s.prop("start",d>1?d:1),t=t.split("\n");for(var h,p="",g=0;g<t.length;g++)h=t[g],p+="<li>"+(h.length?WCF.String.escapeHTML(h):this.opts.invisibleSpace)+"</li>";s.append($(p)),this.modal.close()},this))}},fixBlockLevelElements:function(){var e=function(e,t){var i=e[t];i&&i.nodeType===Node.ELEMENT_NODE&&"P"===i.tagName&&(i.innerHTML.length||i.parentElement.removeChild(i))}.bind(this);this.$editor.find("blockquote, .codeBox").each(function(){e(this,"previousElementSibling"),e(this,"nextElementSibling")})},fixFormatting:function(){for(var e=function(t){t.style.removeProperty("text-align");for(var i=0;i<t.children.length;i++)e(t.children[i])},t=0;t<this.alignment.blocks.length;t++){var i=this.alignment.blocks[t];switch(i.tagName){case"BLOCKQUOTE":i.style.removeProperty("text-align"),e(i.children[0]);break;case"DIV":/\bcodeBox\b/.test(i.className)&&e(i)}}}}};
+if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wbbcode=function(){"use strict";var e=!1;return{init:function(){var t=this.$textarea.wcfIdentify();this.opts.initCallback=function(){window.addEventListener("unload",function(){this.code.startSync(),this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()))}.bind(this)),$.browser.msie&&this.$editor.addClass("msie"),this.$textarea[0].setAttribute("data-is-dirty",!0);var e=$.trim(this.wutil.getOption("woltlab.originalValue"));e.length&&(this.wutil.replaceText(e),this.wutil.selectionEndOfEditor()),delete this.opts.woltlab.originalValue,$(document).trigger("resize"),this.wutil.saveSelection();var t=this.$editor[0],i=this.$textarea[0];setTimeout(function(){$.browser.iOS&&0===t.scrollHeight&&(document.activeElement===t||document.activeElement===i)&&document.activeElement.blur()},10)}.bind(this),this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this),this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var i=this.clean.onSync;this.clean.onSync=function(t){return t=t.replace(/\u200C/g,"__wcf_zwnj__"),t=t.replace(/\u200D/g,"__wcf_zwj__"),e===!0?e=!1:t=t.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>"),t=i.call(this,t),t=t.replace(/__wcf_zwnj__/g,"‌"),t.replace(/__wcf_zwj__/g,"‍")}.bind(this),this.wutil.getOption("woltlab.autosaveOnce")&&(this.wutil.saveTextToStorage(),delete this.opts.woltlab.autosaveOnce);var a=this.button.get("table");if(a.length){var r=a.data("dropdown");r.find(".redactor-dropdown-add_head").parent().remove(),r.find(".redactor-dropdown-delete_head").parent().remove(),$('<li class="dropdownDivider" />').insertBefore(r.find(".redactor-dropdown-delete_table").parent()),a.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertQuote()},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_code_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertCode(null,!0)},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+t,$.proxy(this.wbbcode._keydownCallback,this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+t,$.proxy(this.wbbcode._keyupCallback,this)),this.code.sync=function(){};var n=$(".redactor-toolbar-tooltip-html:not(.jsWbbcode)").addClass("jsWbbcode").text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),l=function(e){e.find("br").each(function(e,t){t.children.length&&$(t).empty()})};this.code.toggle=function(){if(this.opts.visual)this.code.startSync(),this.code.showCode(),this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val())),this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square"),n.text(WCF.Language.get("wcf.bbcode.button.toggleHTML"));else{if(this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val())),this.code.offset=this.$textarea.val().length,this.code.showVisual(),this.wutil.fixDOM(),this.wbbcode.fixBlockLevelElements(),this.wutil.selectionEndOfEditor(),this.wbbcode.observeQuotes(),this.wbbcode.observeCodeListings(),this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o"),n.text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),this.wutil.fixDOM(),l(this.$editor),/ Edge\//.test(navigator.userAgent)){var e=this.$editor[0];window.dtdesign=e,e.childElementCount>1&&"​"===e.children[0].innerHTML&&e.removeChild(e.children[0])}this.wutil.saveSelection()}}.bind(this),this.wutil.setOption("clickCallback",function(e){e.target===this.$editor[0]&&this.$editor[0].lastElementChild&&"BLOCKQUOTE"===this.$editor[0].lastElementChild.tagName&&this.wutil.setCaretAfter($(this.$editor[0].lastElementChild)),setTimeout(this.wutil.saveSelection.bind(this),10)}.bind(this));var o=this.opts.verifiedTags.indexOf("ul");o>-1&&this.opts.verifiedTags.splice(o,1),WCF.System.Event.addListener("com.woltlab.wcf.redactor","observe_load_"+t,function(){this.wbbcode.observeCodeListings(),this.wbbcode.observeQuotes()}.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","fixFormatting_"+t,$.proxy(this.wbbcode.fixFormatting,this))},_tableButtonClick:function(e){var t=$(e.currentTarget);if(t.hasClass("dropact")){var i=this.selection.getBlock()||this.selection.getCurrent(),a=t.data("dropdown");a.children("li").show();var r=a.find("> li > .redactor-dropdown-insert_table").parent();"TD"==i.tagName?r.hide():r.nextAll().hide()}},insertSmiley:function(e,t,i){if(i&&this.wbbcode.registerSmiley(e,t),this.opts.visual){this.wutil.restoreSelection();var a=window.getSelection();a.rangeCount&&this.utils.isRedactorParent(a.getRangeAt(0).startContainer)||this.focus.setEnd();var r=a.getRangeAt(0);r.deleteContents();var n=document.createElement("img");n.src=t,n.className="smiley",n.alt=e,r.insertNode(n);var l,o=function(e){return null===e?!1:(e.nodeType===Node.ELEMENT_NODE&&"SPAN"===e.nodeName||e.nodeType===Node.TEXT_NODE)&&" "===e.textContent?!0:!1},c=n,s=n.parentElement;o(n.previousSibling)||(l=document.createTextNode(" "),s.insertBefore(l,n)),o(n.nextSibling)||(l=document.createTextNode(" "),s.lastChild===n?s.appendChild(l):s.insertBefore(l,n.nextSibling),c=l),r=document.createRange(),r.selectNode(c),r.collapse(!1),a.removeAllRanges(),a.addRange(r),this.wutil.saveSelection()}else this.wutil.insertAtCaret(" "+e+" ")},registerSmiley:function(e,t){return __REDACTOR_SMILIES[e]?!1:(__REDACTOR_SMILIES[e]=t,!0)},convertFromHtml:function(e){var t=[],i={html:e};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",i),e=i.html,e=e.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1"),e=e.replace(/(<[^>]+?) rel="[^"]+"/g,"$1"),e=e.replace(/&#(8203|x200b);/g,""),e=e.replace(/&trade;/gi,"™"),e=e.replace(/&copy;/gi,"©"),e=e.replace(/&hellip;/gi,"…"),e=e.replace(/&mdash;/gi,"—"),e=e.replace(/&dash;/gi,"‐");var a={};e=e.replace(/<div([^>]+?)class="codeBox[^"]+"([^>]*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(e,t,i,r,n){var l=t+" "+i,o="",c="";l.match(/data-highlighter="([a-zA-Z]+)"/)&&(o=RegExp.$1),l.match(/data-filename="([^"]+)"/)&&(c=$.trim(RegExp.$1));var s=WCF.getUUID();return a[s]={codeContent:n.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:c.replace(/['"]/g,""),highlighter:"plain"===o?"":o,lineNumber:r>1?r:0},"@@@"+s+"@@@"}),e=e.replace(/\r?\n/g,""),e=e.replace(/<a[^>]*?><\/a>/g,""),e=e.replace(/<p><\/p><table/g,"<table"),e=e.replace(/<\/table><p><\/p>/g,"</table>");for(var r in a)e=e.replace(new RegExp("<p></p>@@@"+r+"@@@<p></p>"),"@@@"+r+"@@@");e=e.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>"),e=e.replace(/<br( \/)?><\/p>/g,"</p>");for(var n=e.split(/(<\/?(?:div|p)>)/),l="",o="",c=0;c<n.length;c++){var s=n[c];"<p>"!=s&&"<div>"!=s&&("</p>"==s||"</div>"==s?(o=$.trim(o),"@@@wcf_empty_line@@@"!=o&&(o+="\n"),l+=o,o=""):0==c||c+1==n.length?l+=s:o+=s)}o&&(l+=o,o=""),e=l,e=e.replace(/<\/table>@@@wcf_empty_line@@@/g,"</table>@@@wcf_after_table_empty_line@@@"),e=e.replace(/@@@wcf_empty_line@@@/g,"\n"),e=e.replace(/\n\n$/,"\n"),e=e.replace(/@@@wcf_after_table_empty_line@@@/g,"\n\n"),e=e.replace(/<br>$/,""),e=e.replace(/<br>/g,"\n"),e=e.replace(/<br>/g,""),e=e.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(e,t){var i,a="",r="";return t.match(/data-author="([^"]+)"/)&&(a=WCF.String.unescapeHTML(RegExp.$1)),t.match(/cite="([^"]+)"/)&&(r=WCF.String.unescapeHTML(RegExp.$1)),i=r?"[quote='"+a+"','"+r+"']":a?"[quote='"+a+"']":"[quote]"}),e=e.replace(/(?:\n*)<\/blockquote>\n?/gi,"\n[/quote]\n"),e=e.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]"),e=e.replace(/<a[^>]+><\/a>/,""),e=e.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(e,t,i,a){return i==a?"[url]"+i+"[/url]":"[url='"+i+"']"+a+"[/url]"}),e=e.replace(/<(?:b|strong)>/gi,function(){return-1===t.indexOf("b")&&t.push("b"),"[b]"}),e=e.replace(/<\/(?:b|strong)>/gi,"[/b]"),e=e.replace(/<(?:i|em)>/gi,function(){return-1===t.indexOf("i")&&t.push("i"),"[i]"}),e=e.replace(/<\/(?:i|em)>/gi,"[/i]"),e=e.replace(/<u>/gi,function(){return-1===t.indexOf("u")&&t.push("u"),"[u]"}),e=e.replace(/<\/u>/gi,"[/u]"),e=e.replace(/<sub>/gi,function(){return-1===t.indexOf("sub")&&t.push("sub"),"[sub]"}),e=e.replace(/<\/sub>/gi,"[/sub]"),e=e.replace(/<sup>/gi,function(){return-1===t.indexOf("sup")&&t.push("sup"),"[sup]"}),e=e.replace(/<\/sup>/gi,"[/sup]"),e=e.replace(/<(?:s(trike)?|del)>/gi,function(){return-1===t.indexOf("s")&&t.push("s"),"[s]"}),e=e.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");for(var d=e.split(/(<\/?span[^>]*>)/),o=[],h=[],p="",g={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36},c=0;c<d.length;c++){var u=d[c];if("</span>"==u){var f=h.pop(),l=f.start+o.pop()+f.end;o.length?o[o.length-1]+=l:p+=l}else if(u.match(/^<span/))if(u.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var m,v,b=RegExp.$1.replace(/&quot;/g,'"');if(b.match(/(?:^|;\s*)color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var w=RegExp.$1,E=RegExp.$2,C=RegExp.$3,x="0123456789ABCDEF".charAt((w-w%16)/16)+""+"0123456789ABCDEF".charAt(w%16)+("0123456789ABCDEF".charAt((E-E%16)/16)+""+"0123456789ABCDEF".charAt(E%16))+("0123456789ABCDEF".charAt((C-C%16)/16)+""+"0123456789ABCDEF".charAt(C%16));m="[color=#"+x+"]",v="[/color=#"+x+"]",-1===t.indexOf("color")&&t.push("color")}else b.match(/(?:^|;\s*)color: ?([^;]+);?/i)?(m="[color="+RegExp.$1+"]",v="[/color="+RegExp.$1+"]",-1===t.indexOf("color")&&t.push("color")):b.match(/font-size: ?(\d+)(pt|px);?/i)?"pt"==RegExp.$2?(m="[size="+RegExp.$1+"]",v="[/size="+RegExp.$1+"]",-1===t.indexOf("size")&&t.push("size")):g[RegExp.$1]?(m="[size="+g[RegExp.$1]+"]",v="[/size="+g[RegExp.$1]+"]",-1===t.indexOf("size")&&t.push("size")):(m="",v=""):b.replace(/"/g,"").match(/font-family: ?([^;]+);?/)?(m="[font='"+RegExp.$1.replace(/'/g,"")+"']",v="[/font='"+RegExp.$1.replace(/'/g,"")+"']",-1===t.indexOf("font")&&t.push("font")):(m='<span style="'+b+'">',v="</span>");o[o.length]="",h[o.length]={start:m,end:v}}else u.match(/^<span class="inlineCode">/)?(o[o.length]="",h[o.length]={start:"[tt]",end:"[/tt]"}):(o[o.length]="",h[o.length]={start:"",end:""});else o.length?o[o.length-1]+=u:p+=u}if(e=p,e=e.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(e,i,a,r){return-1===t.indexOf("align")&&t.push("align"),"[align="+a+"]"+$.trim(r)+"[/align="+a+"]\n"}),t.length){for(var y=!0;y;)y=!1,e=e.replace(new RegExp("\\[((?:"+t.join("|")+")=[^\\]]+?)\\]\n\\[\\/\\1\\]","gi"),function(e,t){return y=!0,"["+t+"][/"+t+"]"});for(y=!0;y;)y=!1,e=e.replace(new RegExp("\\[\\/((?:"+t.join("|")+")=[^\\]]+?)\\]\n\\[\\1\\]","gi"),function(){return y=!0,"\n"});e=e.replace(new RegExp("\\[\\/("+t.join("|")+")=[^\\]]+?\\]","gi"),"[/$1]")}e=e.replace(/ ?<img [^>]*?alt="([^"]+?)"[^>]*?class="smiley"[^>]*?> ?/gi," $1 "),e=e.replace(/ ?<img [^>]*?class="smiley"[^>]*?alt="([^"]+?)"[^>]*?> ?/gi," $1 "),e=e.replace(/<img([^>]*?)class="[^"]*redactorEmbeddedAttachment[^"]*"([^>]*?)>/gi,function(e,t,i){var a,r=t+" "+i;if(!r.match(/data-attachment-id="(\d+)"/))return e;a=RegExp.$1;var n="none",l=null;if(r.match(/style="([^"]+)"/)){for(var o=RegExp.$1.split(";"),c=0;c<o.length;c++){var s=$.trim(o[c]);s.match(/^float: (left|right)$/)?n=RegExp.$1:s.match(/^width: (\d+)px$/)&&(l=RegExp.$1)}if(null!==l)return"[attach="+a+","+n+","+l+"][/attach]";if("none"!==n)return"[attach="+a+","+n+"][/attach]"}return"[attach="+a+"][/attach]"}),e=e.replace(/<img([^>]*)?src=(["'])([^"']+?)\2([^>]*)?>/gi,function(e,t,i,a,r){var n=t+" "+r,l="";n.match(/style="([^"]+)"/)&&(l=RegExp.$1);for(var o="none",c=0,s=l.split(";"),d=0;d<s.length;d++){var h=s[d];h.match(/float: (left|right|none)/)?o=RegExp.$1:h.match(/width: (\d+)px/)&&(c=parseInt(RegExp.$1))}return c?"[img='"+a+"',"+o+","+c+"][/img]":"none"!==o?"[img='"+a+"',"+o+"][/img]":"[img]"+a+"[/img]"}),e=e.replace(/<li>/gi,"[*]"),e=e.replace(/<\/li>/gi,"\n"),e=e.replace(/<ul>/gi,"[list]"),e=e.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]"),e=e.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]"),e=e.replace(/<\/(ul|ol)>/gi,"[/list]"),e=e.replace(/\n?\[list\]/g,"\n[list]"),e=e.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]"),e=e.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]"),e=e.replace(/<table[^>]*>/gi,"[table]\n"),e=e.replace(/<\/table>\n?/gi,"[/table]\n"),e=e.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(e,t){return $.trim(t)}),e=e.replace(/<tr><\/tr>/gi,""),e=e.replace(/<tr>/gi,"[tr]\n"),e=e.replace(/<\/tr>/gi,"[/tr]\n"),e=e.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]"),e=e.replace(/(\t)*<td>(\t)*/gi,"[td]"),e=e.replace(/(\t)*<\/td>/gi,"[/td]\n");var S={};if(e.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(e){var t=e.hashCode();return S[t]=e.replace(/\$/g,"$$$$"),"@@"+t+"@@"}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:e}),e=e.replace(/<[^(<|>)]+>/g,""),$.getLength(S))for(var _ in S){var k=new RegExp("@@"+_+"@@","g");e=e.replace(k,S[_])}return $.getLength(a)&&$.each(a,function(t,i){var a=0;i.highlighter&&a++,i.lineNumber&&a++,i.filename&&a++;var r="";switch(a){case 1:r=i.highlighter?i.highlighter:i.filename?"'"+i.filename+"'":i.lineNumber;break;case 2:i.lineNumber&&(r=i.lineNumber),i.highlighter&&(r.length&&(r+=","),r+=i.highlighter),i.filename&&(r.length&&(r+=","),r+="'"+i.filename+"'");break;case 3:r=i.highlighter+","+i.lineNumber+",'"+i.filename+"'"}var n="[code"+(r.length?"="+r:"")+"]"+i.codeContent+"[/code]\n";e=e.replace(new RegExp("@@@"+t+"@@@\n?","g"),n.replace(/\$/g,"$$$"))}),e=e.replace(/&lt;/g,"<"),e=e.replace(/&gt;/g,">"),e=e.replace(/&amp;/g,"&"),e=e.replace(/%28/g,"("),e=e.replace(/%29/g,")"),i={html:e},WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",i),e=i.html,e=$.trim(e),e.length&&(e+="\n"),e},convertToHtml:function(e){var t={data:e};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",t),e=t.data,e=this.wutil.removeZeroWidthSpace(e),e=e.replace(/&/g,"&amp;"),e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;");var i=[],a=new RegExp("\\[("+__REDACTOR_SOURCE_BBCODES.join("|")+")([\\S\\s]+?)\\[\\/\\1\\]","gi");e=e.replace(a,function(e){var t=e.hashCode();return i.push({key:t,value:e.replace(/\$/g,"$$$$")}),"@@"+t+"@@"}),e=e.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>'+this.opts.invisibleSpace),e=e.replace(/\[url\='([^'"]+)']([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[url\=([^'"\]]+)]([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>'+this.opts.invisibleSpace),e=e.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>'+this.opts.invisibleSpace),e=e.replace(/\[(b|i|s|sub|sup|u)\]\[\1\]/gi,"[$1]"),e=e.replace(/\[(\/(?:b|i|s|sub|sup|u))\]\[\1\]/gi,"[$1]"),e=e.replace(/\[(b|i|s|sub|sup|u)\]\[\/\1\]/gi,""),e=e.replace(/\[b\]([\s\S]*?)\[\/b]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<strong>","</strong>")}.bind(this)),e=e.replace(/\[i\]([\s\S]*?)\[\/i]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<em>","</em>")}.bind(this)),e=e.replace(/\[u\]([\s\S]*?)\[\/u]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<u>","</u>")}.bind(this)),e=e.replace(/\[s\]([\s\S]*?)\[\/s]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<del>","</del>")}.bind(this)),e=e.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<sub>","</sub>")}.bind(this)),e=e.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,function(e,t){return this.wbbcode._expandFormatting(t,"<sup>","</sup>")}.bind(this)),e=e.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />'),e=e.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,function(e,t,i){var a="float: "+i+";";return a+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px",'<img src="'+t+'" style="'+a+'" />'}),e=e.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi,function(e,t,i,a){var r="float: "+i+"; width: "+a+"px;";return r+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px",'<img src="'+t+'" style="'+r+'" />'}),e=e.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />'),e=e.replace(/\[size=(\d+)\]([\s\S]*?)\[\/size\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="font-size: '+t+'pt">',"</span>")}.bind(this)),e=e.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="color: '+t+'">',"</span>")}.bind(this)),e=e.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<span style="font-family: '+t+'">',"</span>")}.bind(this)),e=e.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,function(e,t,i){return this.wbbcode._expandFormatting(i,'<p style="text-align: '+t+'">',"</p>")}.bind(this));var r=e.indexOf("[list");if(r>0){var n=e.substr(0,r);n=n.replace(/\[\*\]/g,""),e=n+e.substr(r)}var l=e.lastIndexOf("[/list]");if(-1===l)e=e.replace(/\[\*\]/g,""),e=e.replace(/\[list[^\]]*\]/g,"");else{var n=e.substr(l+7);n=n.replace(/\[\*\]/g,""),e=e.substr(0,l+7)+n}e=e.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi,function(e,t){return"<li>"+$.trim(t)+"</li>"}),e=e.replace(/\n*(\[list\]<\/li>)/g,"$1"),e=e.replace(/\[list\]/gi,"<ul>"),e=e.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">'),e=e.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">'),e=e.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">'),e=e.replace(/\[\/list\]/gi,"</ul>"),e=e.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(e,t){return"[table]"+$.trim(t)+"[/table]"}),e=e.replace(/\[table\]\n*/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">'),e=e.replace(/\[\/table\](\n*)?/gi,function(e,t){return t?(t.match(/\n/g).length>2&&(t=t.replace(/^\n/,"")),"</table>"+t):"</table>"}),e=e.replace(/\[tr\]\n*/gi,"<tr>"),e=e.replace(/\[\/tr\]\n*/gi,"</tr>"),e=e.replace(/\[td\]\n*/gi,"<td>"),e=e.replace(/\[\/td\]\n*/gi,"</td>"),e=e.replace(/<td>([\S\s]*?)<\/td>/gi,function(e,t){var i=$.trim(t);return i.length||(i="&#8203;"),"<td>"+i+"</td>"});var o=this.wutil.getOption("woltlab.attachmentUrl"),c=this.wutil.getOption("woltlab.attachmentThumbnailUrl");if(o){var s=this.wbbcode._getImageAttachments();e=e.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(e,t){return t=parseInt(t),void 0!==s[t]?'<img src="'+c.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+t+'" />':e}),e=e.replace(/\[attach=(\d+),(left|right|none)\]\[\/attach\]/g,function(e,t,i){if(t=parseInt(t),void 0!==s[t]){var a="";return("left"===i||"right"===i)&&(a="float: "+i+";",a+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px"),a=' style="'+a+'"','<img src="'+c.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+t+'"'+a+" />"}return e}),e=e.replace(/\[attach=(\d+),(left|right|none),(\d+)\]\[\/attach\]/g,function(e,t,i,a){if(t=parseInt(t),void 0!==s[t]){var r="width: "+a+"px; max-height: "+s[t].height+"px; max-width: "+s[t].width+"px;";return("left"===i||"right"===i)&&(r+="float: "+i+";",r+="left"===i?"margin: 0 15px 7px 0":"margin: 0 0 7px 15px"),r=' style="'+r+'"','<img src="'+o.replace(/987654321/,t)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+t+'"'+r+" />"}return e})}for(var d in __REDACTOR_SMILIES){var h=d.replace(/</g,"&lt;").replace(/>/g,"&gt;"),p=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(h)+"(?=\\s|<|$)","gi");e=e.replace(p,'$1<img src="'+__REDACTOR_SMILIES[d]+'" class="smiley" alt="'+h+'" />')}e=e.replace(/(javascript):/gi,"$1<span></span>:"),e=e.replace(/(\r|\r\n)/g,"\n");for(var g=[],u=[],f=e.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/i),m=WCF.getUUID();;){for(var v=!1,b=0;b<f.length;b++){var w=f[b];if("[/quote]"===w.toLowerCase()){v=!0;for(var E="",C=f.slice(0,b),x=!1;C.length;){var y=C.pop();if(E=y+E,y.match(/^\[quote/i)){w=E+w;var S=WCF.getUUID();g.push({hashCode:S,content:w.replace(/\$/g,"$$$$")}),u.push(S),w="@@"+S+"@@",x=!0;break}}x||(C=f.slice(0,b),w=m),f=C.concat(w,f.slice(b+1));break}}if(!v)break}e=f.join(""),e=e.replace(new RegExp(m,"g"),"[/quote]"),e=e.replace(/\n*$/,"");var _=[];e=e.replace(/(<li>[\s\S]*?<\/li>)/g,function(e){e=$.trim(e).replace(/\n/g,"<br>");var t=WCF.getUUID();return _.push({key:t,content:e}),t});var n=e.split("\n");e="";for(var b=0,k=n.length;k>b;b++){var R=$.trim(n[b]);if(R.match(/^<([a-z]+)/)||R.match(/<\/([a-z]+)>$/))if(this.reIsBlock.test(RegExp.$1.toUpperCase())||"TABLE"===RegExp.$1.toUpperCase())if(R.match(/^<([a-z]+).*<\/\1>/)||R.match(/<\/table>$/))e+=R;else{if(R.match(/<\/p>$/)&&k>b+1){e+=R,0===$.trim(n[b+1]).indexOf("<p")&&(e+="<br />");continue}e+=R+"<br />"}else e+="<p>"+R+"</p>";else{if(R){if(R.match(/^@@([0-9\-]+)@@$/)&&WCF.inArray(RegExp.$1,u)){e+=R;continue}}else R="<br>";e+="<p>"+R+"</p>"}}if(e=e.replace(/<td>([\s\S]+?)<\/td>/g,function(e,t){t=t.replace(/<br(?: \/)?>(<[uo]l)/g,"$1");var i=document.createElement("div");i.innerHTML=t;var a,r,n,l=["BR","DIV","OL","P","TABLE","UL"],o=[],c=function(e){o.length>0&&(n=document.createElement("p"),o.forEach(function(e){n.appendChild(e)}),i.insertBefore(n,e),n.nextElementSibling&&"BR"===n.nextElementSibling.nodeName&&i.removeChild(n.nextElementSibling),o=[])},s=[];for(a=0,r=i.childNodes.length;r>a;a++)s.push(i.childNodes[a]);s.forEach(function(e){return e.nodeType===Node.ELEMENT_NODE&&-1!==l.indexOf(e.nodeName)?void c(e):void o.push(e)}),c(null);var d,h,p=i.querySelectorAll("p");for(a=0,r=p.length;r>a;a++)if(n=p[a],""===n.style.getPropertyValue("text-align"))if(d=document.createElement("br"),h=n.parentNode,1!==n.childElementCount||"BR"!==n.children[0].nodeName||""!==n.textContent.trim().replace(/\u200B/g,"")){for(n.appendChild(d);n.childNodes.length>0;)h.insertBefore(n.childNodes[0],n);h.removeChild(n)}else h.insertBefore(d,n),h.removeChild(n);return i.childElementCount>0&&(d=i.children[i.childElementCount-1],"BR"===d.nodeName&&i.removeChild(d)),"<td>"+i.innerHTML+"</td>"}),_.length)for(var b=_.length-1;b>=0;b--)e=e.replace(_[b].key,_[b].content);if(g.length)for(var T=function(e){return e.replace(/^['"]/,"").replace(/['"]$/,"")},L=this,F=function(e){return e.replace(/\[quote(=(['"]).+?\2)?\]([\S\s]*)\[\/quote\]/gi,function(e,t,i,a){var r="",n="";if(t){switch(t=t.substr(1),t=t.split(","),t.length){case 1:r=t[0];break;case 2:r=t[0],n=t[1]}r=WCF.String.escapeHTML(T($.trim(r))),n=WCF.String.escapeHTML(T($.trim(n)))}var l='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+n+'" data-author="'+r+'"><header contenteditable="false"><h3>'+L.wbbcode._buildQuoteHeader(r,n)+'</h3><a class="redactorQuoteEdit"></a></header>';a=$.trim(a);var o="";if(a.length){var c=[];a=a.replace(/(<(ol|ul)[^>]*>[\s\S]+?<\/\2>)/g,function(e){var t=WCF.getUUID();return c.push({hash:t,content:e}),"@@"+t+"@@"});for(var s=a.split("\n"),d=0;d<s.length;d++){var h=s[d];if(0===h.length)h=L.opts.invisibleSpace;else if(h.match(/^@@([0-9\-]+)@@$/)&&WCF.inArray(RegExp.$1,u)){o+=h;continue}o+="<div>"+h+"</div>"}if(c.length)for(var d=0,p=c.length;p>d;d++){var g=c[d].content;g=g.replace(/(<li>[\s\S]*?<\/li>)/g,function(e){return $.trim(e).replace(/\n/g,"<br>")}),o=o.replace(new RegExp("@@"+c[d].hash+"@@"),g)}}else o="<div>"+L.opts.invisibleSpace+"</div>";return l+=o,l+="</blockquote>"})},b=g.length-1;b>=0;b--){var B=g[b],N=new RegExp("@@"+B.hashCode+"@@","g");e=e.replace(N,F(B.content))}if(e=e.replace(/<(?:div|p)><(blockquote|div)/g,"<$1"),e=e.replace(/<\/(blockquote|div)><\/(?:div|p)>/g,"</$1>"),i.length)for(var b=i.length-1;b>=0;b--){var A=i[b],N=new RegExp("@@"+A.key+"@@","g"),O=A.value;O=O.replace(/^\[tt\]([\s\S]+)\[\/tt\]/,function(e,t){var i=t.split("\n");t="";for(var a=0,r=i.length;r>a;a++){var n=i[a];if(n.length)t.length&&(t+="</p><p>"),t+="[tt]"+n+"[/tt]";else{if(0===a||a+1===r)continue;t+=t.match(/\[\/tt\]$/)?"</p><p>"+this.opts.invisibleSpace:"</p><p><br>"}}return t}.bind(this)),O=O.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,function(e,t,i){var a="plain",r=0,n="";if(t){t=t.substring(1),t=t.split(",");var l=function(e){return e.match(/^\d+$/)},o=function(e){return-1!==e.indexOf(".")||e.match(/^(["']).*\1$/)},c=function(e){return void 0!==__REDACTOR_CODE_HIGHLIGHTERS[e]},s=function(e){return e.replace(/^(["'])(.*)\1$/,"$2")};switch(t.length){case 1:l(t[0])?r=parseInt(t[0])>1?t[0]:0:o(t[0])?n=s(t[0]):c(t[0])&&(a=t[0]);break;case 2:l(t[0])?(r=parseInt(t[0])>1?t[0]:0,c(t[1])?a=t[1]:o(t[1])&&(n=s(t[1]))):(c(t[0])&&(a=t[0]),o(t[1])&&(n=s(t[1])));break;case 3:c(t[0])&&(a=t[0]),l(t[1])&&(r=t[1]),o(t[2])&&(n=s(t[2]))}}i=i.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);for(var d="",h=0;h<i.length;h++){var p=i[h];p.length||(p=this.opts.invisibleSpace),d+="<li>"+p+"</li>"}return'<div class="codeBox container" contenteditable="false" data-highlighter="'+a+'"'+(n?' data-filename="'+WCF.String.escapeHTML(n)+'"':"")+"><div><div><h3>"+__REDACTOR_CODE_HIGHLIGHTERS[a]+(n?": "+WCF.String.escapeHTML(n):"")+'</h3></div><ol start="'+(r>1?r:1)+'">'+d+"</ol></div></div>"}.bind(this)),e=e.replace(N,O)}return e=e.replace(/&amp;nbsp;/g,"&amp;amp;nbsp;"),t={data:e},WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",t),e=t.data},_expandFormatting:function(e,t,i){if(!e.length)return t+this.opts.invisibleSpace+i;var a=e.indexOf("[/td]");if(-1!==a){var r=e.substring(0,a);if(-1===r.indexOf("[td]"))return t+r+i+e.substring(a)}var r=e.split("\n");e="";for(var n=0,l=r.length;l>n;n++){var o=r[n];0===o.length&&(o=this.opts.invisibleSpace),e.length&&(e+="\n"),e+=t+o+i}return e},_pasteBeforeCallback:function(e){var t={1:24,2:22,3:18,4:14,5:12,6:10};return e=e.replace(/<h([1-6])([^>]*)>/g,function(e,i,a){if(a&&a.match(/style="([^"]+?)"/)&&/font-size: ?(\d+|\d+\.\d+)(px|pt|em|rem|%)/.test(RegExp.$1)){var r=$('<div style="width: '+RegExp.$1+RegExp.$2+'; position: absolute;" />').appendTo(document.body),n=parseInt(r[0].clientWidth);r.remove();var l=-1,o=!1;$.each(t,function(e,i){-1===l?l=e:Math.abs(n-i)<Math.abs(n-t[l])&&(l=e),n==i&&(o=!0)}),o||(l=6>l?parseInt(l)+1:l),i=l}return"[size="+t[i]+"]"}),e=e.replace(/<\/h[1-6]>/g,"[/size]"),(/<p class="Mso(?:Normal|NoSpacing)/.test(e)||/margin-bottom: 0cm/.test(e))&&(e=e.replace(/([^>\s])\n([^<\s])/g,"$1 $2"),e=e.replace(/<a name="[^"]+">/g,"")),e=e.replace(/<o:p>&nbsp;<\/o:p>/g,"<br>"),e=e.replace(/<(article|header)[^>]+>/g,"<div>"),e=e.replace(/<\/(article|header)>/g,"</div>"),e=e.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>"),e=e.replace(/<\/(div|p)><\/(div|p)>/g,"</p>"),e=e.replace(/<(?:div|p|span)[^>]+>/gi,function(e){return e.replace(/ class="[^"]+"/,"")}),e=e.replace(/<\/?wbr[^>]*>/g,""),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:e}),e},_pasteCallback:function(e){return e=e.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">'),e=e.replace(/\[\/size\]/g,"</span></p>"),e=e.replace(/style="([^"]+)"/,function(e,t){for(var i=t.split(";"),a=[],r=0,n=i.length;n>r;r++){var l=i[r];l.match(/^\s*background-color/)||a.push(l)}return'style="'+a.join(";")+'"'}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:e}),e},insertAttachment:function(e,t){e=parseInt(e);var i=this.wutil.getOption("woltlab.attachment"+(t?"":"Thumbnail")+"Url"),a=this.wbbcode._getImageAttachments();if(i&&void 0!==a[e]){var r="";t&&(r=' style="width: '+a[e].width+"px; max-height: "+a[e].height+"px; max-width: "+a[e].width+'px;"'),this.wutil.insertDynamic('&#8203;<img src="'+i.replace(/987654321/,e)+'" class="redactorEmbeddedAttachment'+(t?"":" redactorDisableResize")+'" data-attachment-id="'+e+'"'+r+" />&#8203;","[attach="+e+(t?",none,"+a[e].width:"")+"][/attach]")}else this.wutil.insertDynamic("[attach="+e+"][/attach]")},removeAttachment:function(e){this.opts.visual&&this.$editor.find("img.redactorEmbeddedAttachment").each(function(t,i){var a=$(i);a.data("attachmentID")==e&&a.remove()})},_getImageAttachments:function(){var e=this.wutil.getOption("woltlab.attachmentImages")||[];if(e.length)return delete this.opts.attachmentImages,e;var t={imageAttachments:{}};return WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),t),t.imageAttachments},_keydownCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.UP:case 83:break;default:return}this.selection.get();var t=this.selection.getCurrent(),i=this.selection.getParent();i=i?$(i):i;var a=i?i.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(e.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var r=!1;if(a.length){for(var n=!0,l=0;l<a[0].children.length;l++){var o=a[0].children[l];if("DIV"===o.tagName&&o.textContent.replace(/\u200b/,"").length){n=!1;break}}if(n)r=!0;else{var c=null===this.selection.implicitRange?this.range:this.selection.implicitRange;if(0===c.startOffset)for(var s,d=c.startContainer;null!==(d=d.parentNode);)if(s=d.previousSibling,null!==s){s.nodeType===Node.ELEMENT_NODE&&"HEADER"===s.nodeName&&(r=!0);break}}}if(r){var h=window.getSelection();h.rangeCount&&h.removeAllRanges();var p=document.createRange();p.selectNode(a[0]||a),h.addRange(p),e.cancel=!0}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(t)){var g=t.nextElementSibling;if(g&&"BLOCKQUOTE"===g.tagName){var h=window.getSelection();h.rangeCount&&h.removeAllRanges();var p=document.createRange();p.selectNode(g),h.addRange(p),e.cancel=!0}}break;case $.ui.keyCode.DOWN:var u=$(t);if(u.next("blockquote").length)this.caret.setStart(u.next().children("div:first")),e.cancel=!0;else if(i)if(i.next("blockquote").length)this.caret.setStart(i.next().children("div:first")),e.cancel=!0;else if(a.length){var f=u.closest("div",a[0]);f.next().length||(a.next().length?this.caret.setStart(a.next()):this.wutil.setCaretAfter(a),e.cancel=!0)}break;case $.ui.keyCode.ENTER:a.length&&(this.keydown.blockquote=!1,this.keydown.enterWithinBlockquote=!0);break;case $.ui.keyCode.UP:if(!i||!a.length)return;var f=$(t).closest("div",a[0]),m=f.prev();if("DIV"===m[0].tagName)return;if("BLOCKQUOTE"===m[0].tagName)return;var v=a.prev();0===v.length?this.wutil.setCaretBefore(a):"BLOCKQUOTE"===v[0].tagName?this.caret.sendEnd(v.children("div:last")):(""==$.trim(v.html())&&v.html(this.opts.invisibleSpace),this.caret.setEnd(v)),e.cancel=!0;break;case 83:if($.browser.mobile||$.browser.touch)return;var b=!1;if(navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(b=!0):e.event.altKey&&!e.event.ctrlKey&&(b=!0),b){var w={cancel:!1};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),w),w.cancel&&(e.cancel=!0)}}},_keyupCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:this.$editor.find("blockquote").each(function(e,t){var i=$(t);i.children("header").length||i.remove()});break;case $.ui.keyCode.ENTER:for(var t=0,i=this.$editor[0].children.length;i>t;t++){var a=this.$editor[0].children[t];if(a.nodeType===Node.ELEMENT_NODE&&"P"===a.tagName&&!(a.textContent.length>0||a.children.length>1||"BR"===a.children[0].tagName)){for(a=a.children[0];1===a.children.length;)a=a.children[0];if(0===a.children.length&&"BR"===a.tagName){var r=a.parentNode,n=document.createTextNode("​");r.appendChild(n),r.removeChild(a)}}}}},observeQuotes:function(){this.$editor.find(".redactorQuoteEdit").off("click.wbbcode").on("click.wbbcode",$.proxy(this.wbbcode._observeQuotesClick,this));
+
+},_observeQuotesClick:function(e){var t=$(e.currentTarget).closest("header"),i=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").on("click touchstart",$.proxy(function(t){t.preventDefault(),t.stopPropagation(),this.wbbcode._openQuoteEditOverlay($(e.currentTarget).closest("blockquote.quoteBox"),!1),$(".redactor-link-tooltip").remove()},this)).appendTo(i),$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.delete")+"</a>").on("click touchstart",function(e){e.preventDefault(),e.stopPropagation();var i=t.parent(),a=i.parent();i.remove(),$(".redactor-link-tooltip").remove(),"BLOCKQUOTE"===a[0].nodeName&&0===a.children("div").length&&$("<div>​</div>").appendTo(a)}).appendTo(i);var a=t.offset();i.css({left:a.left+"px",top:a.top+20+"px"}),$(".redactor-link-tooltip").remove(),i.appendTo(document.body),this.selection.remove()},observeCodeListings:function(){this.$editor.find(".codeBox").each(function(e,t){var i=$(t),a=i.find(".redactorEditCodeBox");a.length||(a=$('<div class="redactorEditCodeBox"><div>'+WCF.Language.get("wcf.bbcode.code.edit")+"</div></div>").insertAfter(i.find("> div > div > h3"))),a.off("click.wbbcode").on("click.wbbcode",function(){this.wbbcode._handleInsertCode(i,!1)}.bind(this))}.bind(this))},_openQuoteEditOverlay:function(t,i){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(i?"insert":"edit")),400);var a=this.modal.createActionButton(this.lang.get("save"));i?(this.selection.save(),a.click($.proxy(function(){var t=$("#redactorQuoteAuthor").val(),i=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.selection.restore(),e=!0;var a=this.selection.getHtml();this.utils.isEmpty(a)&&(a="");var r=this.wbbcode.insertQuoteBBCode(t,i,a);null!==r&&(a.length||($.browser.mozilla&&r.children("br[type=_moz]").replaceWith("<div>"+this.opts.invisibleSpace+"</div>"),this.caret.setStart(r.children("div")[0]))),this.modal.close()},this))):($("#redactorQuoteAuthor").val(t.data("author")),$("#redactorQuoteLink").val(WCF.String.unescapeHTML(t.attr("cite"))),a.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();t.data("author",e),t.attr("data-author",e),t.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val())),this.wbbcode._updateQuoteHeader(t),this.modal.close()},this))),this.modal.show()},_updateQuoteHeader:function(e){var t=e.data("author"),i=e.attr("cite");i&&(i=WCF.String.escapeHTML(i)),e.find("> header > h3").empty().append(this.wbbcode._buildQuoteHeader(t,i))},insertQuoteBBCode:function(e,t,i,a){var r="[quote]",n="[/quote]";e&&(r=t?"[quote='"+e+"','"+t+"']":"[quote='"+e+"']");var l=null;if(this.wutil.inWysiwygMode()){var o="quote"+WCF.getUUID(),c="";a?c=this.wbbcode.convertToHtml(r+a+n):(c=this.wbbcode.convertToHtml(r+o+n),c=c.replace(o,i.replace(/^<p>/,"").replace(/<\/p>$/,""))),c=c.replace(/^<p>/,"").replace(/<\/p>$/,""),c=c.replace(/<blockquote/,'<blockquote id="'+o+'"'),window.getSelection().rangeCount||(this.wutil.restoreSelection(),window.getSelection().rangeCount||(this.$editor.focus(),window.getSelection().rangeCount||this.wutil.selectionEndOfEditor(),this.wutil.saveSelection())),window.getSelection().getRangeAt(0).deleteContents(),this.wutil.restoreSelection();for(var s=window.getSelection().getRangeAt(0),d=s.startContainer;d;){var h=d.parentNode;if(h===this.$editor[0])break;d=h}var p=-1,g=this.$editor[0];if(d&&d.parentNode===g&&d.innerHTML.length>0)for(var u=0;u<g.childNodes.length;u++)if(g.childNodes[u]===d){p=u+1;break}-1===p&&(p=g.childNodes.length);var f=document.createRange();f.setStart(g,p),f.setEnd(g,p);var m=window.getSelection();m.removeAllRanges(),m.addRange(f);var v=document.createElement("span");f.insertNode(v),c=$("<div />").html(c)[0].innerHTML;var b=v.previousElementSibling;if(b&&"P"===b.nodeName&&"​"===b.innerHTML&&g.removeChild(b),v.outerHTML=c,l=this.$editor.find("#"+o),l.length){var w=l.find("> div");if(1===w.length)""===w[0].innerHTML&&(w[0].innerHTML=this.opts.invisibleSpace);else if($.browser.mozilla){var E=l.find("> div > br[type=_moz]");E.length&&($("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(E),E.remove())}l.removeAttr("id"),this.wutil.setCaretAfter(l[0]);var C=l[0].previousElementSibling;null!==C&&"P"===C.nodeName&&"​"===C.innerHTML&&(C=C.previousElementSibling,null===C||"P"!==C.nodeName||"​"!==C.innerHTML&&"<br>"!==C.innerHTML||C.parentNode.removeChild(C.nextElementSibling))}this.wbbcode.observeQuotes(),this.wbbcode.fixBlockLevelElements(),this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else this.wutil.insertAtCaret(r+a+n);return this.wutil.saveSelection(),l},_buildQuoteHeader:function(e,t){var i="";return!e&&t&&(e=t,t=""),e?(t&&(i+='<a href="'+t+'" tabindex="-1">'),i+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(e)}),t&&(i+="</a>")):i="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>",i},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,!0)},_handleInsertCode:function(e,t){this.modal.load("code",WCF.Language.get("wcf.bbcode.code."+(t?"insert":"edit")),400);var i=this.modal.createActionButton(this.lang.get("save")).addClass("buttonPrimary");if(t){this.selection.get();var a=this.selection.getText();$.browser.mozilla&&(a=a.replace(/\r/g,"").replace(/\u200b/g,""),a=a.replace(/(\n+)/g,function(e,t){var i=t.match(/\n/g).length;for(i=~~(i/2),t="";i>0;)t+="\n",i--;return t})),this.selection.save(),this.modal.show();var r=$("#redactorCodeBox").focus();r.val(a),i.click($.proxy(function(){var e=$("#redactorCodeBox"),t=$("#redactorCodeFilename"),i=$("#redactorCodeHighlighter"),a=$("#redactorCodeLineNumber"),r=e.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(r).length)return void(e.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(e));var n=$.trim(t.val().replace(/['"]/g,"")),l="[code="+i.val()+","+a.val()+(n.length?",'"+n+"'":"")+"]";l.match(/\[code=([^,]+),(\d+)\]/)&&(l="[code="+RegExp.$2+","+RegExp.$1+"]"),l+=r,l+="[/code]",this.wutil.adjustSelectionForBlockElement(),this.wutil.saveSelection();var o=this.wbbcode.convertToHtml(l);this.buffer.set(),this.insert.html(o,!1);var e=this.$editor.find(".codeBox:not(.jsRedactorCodeBox)");this.wbbcode.observeCodeListings(),this.wbbcode.fixBlockLevelElements(),e.attr("contenteditable","false"),this.wutil.setCaretAfter(e[0]),this.modal.close()},this))}else{var n=this.modal.createActionButton(WCF.Language.get("wcf.global.button.delete"));n.click(function(){this.buffer.set(),e.remove(),this.modal.close()}.bind(this)),this.modal.show();var r=$("#redactorCodeBox").focus(),l=$("#redactorCodeFilename"),o=$("#redactorCodeHighlighter"),c=$("#redactorCodeLineNumber");o.val(e.data("highlighter")),l.val(e.data("filename")||"");var s=e.find("> div > ol");c.val(parseInt(s.prop("start")));var d="";s.children("li").each(function(e,t){d+=$(t).text().replace(/^\u200b$/,"")+"\n"}),r.val(d.replace(/^\n+/,"").replace(/\n+$/,"")),i.click($.proxy(function(){var t=r.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(t).length)return void(r.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(r));var i=o.val();e.data("highlighter",i),e.attr("data-highlighter",i);var a=__REDACTOR_CODE_HIGHLIGHTERS[i],n=$.trim(l.val().replace(/['"]/g,""));n?(a+=": "+WCF.String.escapeHTML(n),e.data("filename",n),e.attr("data-filename",n)):(e.removeAttr("data-filename"),e.removeData("filename")),e.data("highlighter",o.val()),e.find("> div > div > h3").html(a);var s=e.find("> div > ol").empty(),d=parseInt(c.val());s.prop("start",d>1?d:1),t=t.split("\n");for(var h,p="",g=0;g<t.length;g++)h=t[g],p+="<li>"+(h.length?WCF.String.escapeHTML(h):this.opts.invisibleSpace)+"</li>";s.append($(p)),this.modal.close()},this))}},fixBlockLevelElements:function(){var e=function(e,t){var i=e[t];i&&i.nodeType===Node.ELEMENT_NODE&&"P"===i.tagName&&(i.innerHTML.length||i.parentElement.removeChild(i))}.bind(this);this.$editor.find("blockquote, .codeBox").each(function(){e(this,"previousElementSibling"),e(this,"nextElementSibling")})},fixFormatting:function(){for(var e=function(t){t.style.removeProperty("text-align");for(var i=0;i<t.children.length;i++)e(t.children[i])},t=0;t<this.alignment.blocks.length;t++){var i=this.alignment.blocks[t];switch(i.tagName){case"BLOCKQUOTE":i.style.removeProperty("text-align"),e(i.children[0]);break;case"DIV":/\bcodeBox\b/.test(i.className)&&e(i)}}}}};
 // wbutton.js
 if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wbutton=function(){"use strict";return{_bbcodes:{},init:function(){this._bbcodes={};for(var t=0,e=__REDACTOR_BUTTONS.length;e>t;t++)this.wbutton._addBBCodeButton(__REDACTOR_BUTTONS[t]);for(var n={html:"fa-square-o",bold:"fa-bold",italic:"fa-italic",underline:"fa-underline",deleted:"fa-strikethrough",subscript:"fa-subscript",superscript:"fa-superscript",orderedlist:"fa-list-ol",unorderedlist:"fa-list-ul",outdent:"fa-outdent",indent:"fa-indent",link:"fa-link",alignment:"fa-align-left",table:"fa-table"},i={fontcolor:WCF.Language.get("wcf.bbcode.button.fontColor"),fontfamily:WCF.Language.get("wcf.bbcode.button.fontFamily"),fontsize:WCF.Language.get("wcf.bbcode.button.fontSize"),image:WCF.Language.get("wcf.bbcode.button.image"),subscript:WCF.Language.get("wcf.bbcode.button.subscript"),superscript:WCF.Language.get("wcf.bbcode.button.superscript")},a=this.wutil.getOption("buttons"),o="",t=0,e=a.length;e>t;t++){var s=a[t];if("separator"!=s){var r=this.button.get(s);r.length?(n[s]&&this.button.setAwesome(s,n[s]),"table"===s&&o&&r.parent().insertAfter(this.button.get(o).parent())):this.wbutton._addCoreButton(s,i[s]?i[s]:null,n[s]?n[s]:null,o),o=s}else this.button.get(o).parent().addClass("separator")}if(this.button.addCallback(this.button.get("image"),$.proxy(this.wbutton.insertImage,this)),this.utils.isDesktop()){var l=this.button.addAfter("html","undo",WCF.Language.get("wcf.bbcode.button.undo")),u=this.button.addAfter("undo","redo",WCF.Language.get("wcf.bbcode.button.redo"));this.button.addCallback(l,this.buffer.undo),this.button.addCallback(u,this.buffer.redo),u.parent().addClass("separator")}},_addCoreButton:function(t,e,n,i){var a={title:null===e?t:e};("subscript"===t||"superscript"===t)&&(a.command=t);var o=this.button.build(t,a);$("<li />").append(o).insertAfter(this.button.get(i).parent()),null!==n&&this.button.setAwesome(t,n)},_addBBCodeButton:function(t){var e="__wcf_"+t.name,n=this.button.add(e,t.label);this.button.addCallback(n,this.wbutton._insertBBCode),this._bbcodes[e]={name:t.name,voidElement:t.voidElement===!0},t.icon.match(/^fa\-[a-z\-]+$/)?this.button.setAwesome(e,t.icon):n.css("background-image","url("+__REDACTOR_ICON_PATH+t.icon+")")},_insertBBCode:function(t){var e=this._bbcodes[t].name,n={buttonName:t,cancel:!1,redactor:this};if(WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","insertBBCode_"+e+"_"+this.$textarea.wcfIdentify(),n),n.cancel===!1){var i=this.selection.getHtml();i=i.replace(/<p>@@@wcf_empty_line@@@<\/p>/g,"<p><br></p>");if(this.buffer.set(),this.utils.browser("mozilla")&&!i.length){var a=getSelection().getRangeAt(0).startContainer;a.nodeType===Node.ELEMENT_NODE&&"P"===a.tagName&&"<br>"===a.innerHTML&&a.removeChild(a.children[0])}this._bbcodes[t].voidElement?this.insert.html(i+this.selection.getMarkerAsHtml()+"["+e+"]",!1):this.insert.html("["+e+"]"+i+this.selection.getMarkerAsHtml()+"[/"+e+"]",!1),this.selection.restore()}},insertImage:function(){this.image.show()},_insertImage:function(){var t=$("#redactor-image-link-source"),e=t.val().trim();if(e.length){this.buffer.set();var n=$("#redactor-image-align").val(),i="";("left"===n||"right"===n)&&(i=' style="float: '+n+'"'),this.insert.html('<img src="'+e+'"'+i+">",!1),this.modal.close(),this.observe.images()}else t.next("small.innerError")||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(t)}}};
 // wfontcolor.js