// table.js
!function(e){e.Redactor.prototype.table=function(){return{langs:{en:{table:"Table","insert-table":"Insert table","insert-row-above":"Insert row above","insert-row-below":"Insert row below","insert-column-left":"Insert column left","insert-column-right":"Insert column right","add-head":"Add head","delete-head":"Delete head","delete-column":"Delete column","delete-row":"Delete row","delete-table":"Delete table"}},init:function(){var e={};e.insert_table={title:this.lang.get("insert-table"),func:this.table.insert,observe:{element:"table",in:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.insert_row_above={title:this.lang.get("insert-row-above"),func:this.table.addRowAbove,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.insert_row_below={title:this.lang.get("insert-row-below"),func:this.table.addRowBelow,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.insert_column_left={title:this.lang.get("insert-column-left"),func:this.table.addColumnLeft,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.insert_column_right={title:this.lang.get("insert-column-right"),func:this.table.addColumnRight,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.add_head={title:this.lang.get("add-head"),func:this.table.addHead,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.delete_head={title:this.lang.get("delete-head"),func:this.table.deleteHead,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.delete_column={title:this.lang.get("delete-column"),func:this.table.deleteColumn,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.delete_row={title:this.lang.get("delete-row"),func:this.table.deleteRow,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},e.delete_table={title:this.lang.get("delete-table"),func:this.table.deleteTable,observe:{element:"table",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}};var t=this.button.addBefore("link","table",this.lang.get("table"));this.button.addDropdown(t,e)},insert:function(){if(!this.table.getTable()){this.placeholder.hide();for(var t=2,a=3,i=e("<div>"),r=e("<table />"),l=0;t>l;l++){for(var n=e("<tr>"),s=0;a>s;s++){var o=e("<td>"+this.opts.invisibleSpace+"</td>");0===l&&0===s&&o.append(this.marker.get()),e(n).append(o)}r.append(n)}i.append(r);var d=i.html();this.buffer.set();var c=this.selection.current();0!==e(c).closest("li").length?e(c).closest("ul, ol").first().after(d):(this.air.collapsed(),this.insert.html(d)),this.selection.restore(),this.core.callback("insertedTable",r)}},getTable:function(){var t=e(this.selection.current()).closest("table");return this.utils.isRedactorParent(t)?0===t.size()?!1:t:!1},restoreAfterDelete:function(e){this.selection.restore(),e.find("span.redactor-selection-marker").remove()},deleteTable:function(){var e=this.table.getTable();if(e){this.buffer.set();var t=e.next();this.opts.linebreaks||0===t.length?this.caret.after(e):this.caret.start(t),e.remove()}},deleteRow:function(){var t=this.table.getTable();if(t){var a=e(this.selection.current());this.buffer.set();var i=a.closest("tr"),r=i.prev().length?i.prev():i.next();if(r.length){var l=r.children("td, th").first();l.length&&l.prepend(this.marker.get())}i.remove(),this.table.restoreAfterDelete(t)}},deleteColumn:function(){var t=this.table.getTable();if(t){this.buffer.set();var a=e(this.selection.current()),i=a.closest("td, th"),r=i[0].cellIndex;t.find("tr").each(e.proxy(function(t,a){var i=e(a),l=0>r-1?r+1:r-1;0===t&&i.find("td, th").eq(l).prepend(this.marker.get()),i.find("td, th").eq(r).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 a=t.find("tr").first().clone();a.find("td").replaceWith(e.proxy(function(){return e("<th>").html(this.opts.invisibleSpace)},this)),$thead=e("<thead></thead>").append(a),t.prepend($thead)}},deleteHead:function(){var e=this.table.getTable();if(e){var t=e.find("thead");0!==t.size()&&(this.buffer.set(),t.remove())}},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 a=this.table.getTable();if(a){this.buffer.set();var i=e(this.selection.current()),r=i.closest("tr"),l=r.clone();l.find("th").replaceWith(function(){var t=e("<td>");return t[0].attributes=this.attributes,t.append(e(this).contents())}),l.find("td").html(this.opts.invisibleSpace),"after"===t?r.after(l):r.before(l)}},addColumn:function(t){var a=this.table.getTable();if(a){var i=0,r=e(this.selection.current());this.buffer.set();var l=r.closest("tr"),n=r.closest("td, th");l.find("td, th").each(e.proxy(function(t,a){e(a)[0]===n[0]&&(i=t)},this)),a.find("tr").each(e.proxy(function(a,r){var l=e(r).find("td, th").eq(i),n=l.clone();n.html(this.opts.invisibleSpace),"after"===t?l.after(n):l.before(n)},this))}}}}}(jQuery);
// WoltLabAttachment.js
-$.Redactor.prototype.WoltLabAttachment=function(){"use strict";return{init:function(){require(["EventHandler"],function(t){t.add("com.woltlab.wcf.redactor2","insertAttachment_"+this.$element[0].id,this.WoltLabAttachment._insert.bind(this)),t.add("com.woltlab.wcf.redactor2","deleteAttachment_"+this.$element[0].id,this.WoltLabAttachment._delete.bind(this))}.bind(this))},_insert:function(t){var e=t.attachmentId;t.url?this.insert.html('<img src="'+t.url+'" class="woltlabAttachment" data-attachment-id="'+e+'">'):this.insert.text("[attach="+e+"][/attach]")},_delete:function(t){var e=t.attachmentId,a=this.core.editor()[0];elBySelAll('.woltlabAttachment[data-attachment-id="'+e+'"]',a,function(t){elRemove(t)});var n="[attach="+e+"][/attach]";if(a.textContent.indexOf(n)!==!1){for(var i,c=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1),r=[];i=c.nextNode();)-1!==i.textContent.indexOf(n)&&r.push(i);for(var l=0,o=r.length;o>l;l++)r[l].textContent=r[l].textContent.replace(new RegExp("\\[attach="+e+"\\]\\[\\/attach\\]","g"),"")}}}};
+$.Redactor.prototype.WoltLabAttachment=function(){"use strict";return{init:function(){require(["EventHandler"],function(t){t.add("com.woltlab.wcf.redactor2","insertAttachment_"+this.$element[0].id,this.WoltLabAttachment._insert.bind(this)),t.add("com.woltlab.wcf.redactor2","deleteAttachment_"+this.$element[0].id,this.WoltLabAttachment._delete.bind(this))}.bind(this))},_insert:function(t){var e=t.attachmentId;this.buffer.set(),t.url?this.insert.html('<img src="'+t.url+'" class="woltlabAttachment" data-attachment-id="'+e+'">'):this.insert.text("[attach="+e+"][/attach]")},_delete:function(t){var e=t.attachmentId,a=this.core.editor()[0];elBySelAll('.woltlabAttachment[data-attachment-id="'+e+'"]',a,function(t){elRemove(t)});var n="[attach="+e+"][/attach]";if(a.textContent.indexOf(n)!==!1){for(var i,c=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1),r=[];i=c.nextNode();)-1!==i.textContent.indexOf(n)&&r.push(i);for(var l=0,o=r.length;o>l;l++)r[l].textContent=r[l].textContent.replace(new RegExp("\\[attach="+e+"\\]\\[\\/attach\\]","g"),"")}}}};
// WoltLabButton.js
$.Redactor.prototype.WoltLabButton=function(){"use strict";return{init:function(){for(var t,o,s,e=0,n=this.opts.buttons.length;n>e;e++)s=this.opts.buttons[e],"wcfSeparator"!==s&&(o=this.opts.woltlab.buttons[s],"subscript"===s||"superscript"===s?(t=this.button.addAfter(this.opts.buttons[e-1],s,""),this.button.setEvent(t,s,{func:"inline.format"})):t=this.button.get(s),this.button.setIcon(t,'<span class="icon icon16 '+o.icon+'"></span>'),t[0]||console.debug(s),elAttr(t[0],"title",o.title),t[0].classList.add("jsTooltip"));for(var i,r={},a=[],l=this.core.toolbar()[0];l.childElementCount;)i=l.removeChild(l.children[0]),s=elAttr(i.children[0],"rel"),r[s]=i,a.push(s);var c=!1;for(e=0,n=this.opts.buttons.length;n>e;e++)s=this.opts.buttons[e],"wcfSeparator"!==s?(i=r[s],l.appendChild(i),a.splice(a.indexOf(s),1),c&&(i.classList.add("redactor-toolbar-separator"),c=!1)):c=!0;a.forEach(function(t){l.appendChild(r[t])}),WCF.DOMNodeInsertedHandler.execute()}}};
// WoltLabColor.js
$.Redactor.prototype.WoltLabDropdown=function(){"use strict";return{init:function(){this.utils.disableBodyScroll=function(){},this.utils.enableBodyScroll=function(){},this.WoltLabDropdown._hideAll(),this.WoltLabDropdown._show()},_hideAll:function(){var o=this.dropdown.hideAll;this.dropdown.hideAll=function(t,i){o.call(this,t,i),$(".redactor-dropdown-"+this.uuid).stop(!0,!0).hide()}.bind(this)},_show:function(){var o=this.dropdown.show;this.dropdown.show=function(t,i){var l=this.button.get(i),d=l.data("dropdown");if(!elDataBool(d[0],"woltlab")){var n=elCreate("ul");for(n.className="dropdownMenu";d[0].childElementCount;)n.appendChild(d[0].children[0]);d[0].appendChild(n),elData(d[0],"woltlab",!0)}var s=l.hasClass("dropact");o.call(this,t,i),s||d.stop(!0).show()}.bind(this)}}};
// WoltLabEvent.js
$.Redactor.prototype.WoltLabEvent=function(){"use strict";return{init:function(){this._callbacks=[],this._elementId=this.$element[0].id,require(["EventHandler"],this.WoltLabEvent._setEvents.bind(this))},_setEvents:function(t){var e=this.$element[0].id,i=this.observe.load;this.observe.load=function(){i.call(this),t.fire("com.woltlab.wcf.redactor","observe_load_"+e,{editor:this.$editor[0]})}.bind(this),this.opts.callbacks.keyup=function(i){var n={cancel:!1,event:i};return t.fire("com.woltlab.wcf.redactor","keyup_"+e,n),n.cancel===!1},t.add("com.woltlab.wcf.redactor2","getText_"+e,function(t){t.message=this.code.get()}.bind(this))},register:function(t,e){require(["EventHandler"],function(i){-1===this._callbacks.indexOf(t)&&(this.opts.callbacks[t]=function(e){var n={cancel:!1,event:e,redactor:this};return i.fire("com.woltlab.wcf.redactor2",t+"_"+this.WoltLabEvent._elementId,n),n.cancel===!1}.bind(this),this._callbacks.push(t)),require(["EventHandler"],function(i){i.add("com.woltlab.wcf.redactor2",t+"_"+this.WoltLabEvent._elementId,e)}.bind(this))}.bind(this))}}};
+// WoltLabImage.js
+$.Redactor.prototype.WoltLabImage=function(){"use strict";return{init:function(){this.opts.modal["image-edit"]='<div class="section"><dl><dt><label>'+this.lang.get("title")+'</label></dt><dd><input type="text" id="redactor-image-title" class="long"></dd></dl><dl><dt><label>'+this.lang.get("link")+'</label></dt><dd><input type="text" id="redactor-image-link" class="long" aria-label="'+this.lang.get("link")+'"></dd></dl><div class="formSubmit"><button id="redactor-modal-button-action" class="buttonPrimary">Insert</button><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">Delete</button></div></div>'}}};
// WoltLabLink.js
$.Redactor.prototype.WoltLabLink=function(){"use strict";var i=null;return{init:function(){this.link.show=this.WoltLabLink.show.bind(this),require(["WoltLab/WCF/Ui/Redactor/Link"],function(t){i=t})},show:function(t){"undefined"!=typeof t&&t.preventDefault&&t.preventDefault(),this.observe.closeAllTooltip();var e=this.link.is();i.showDialog({insert:e===!1,submitCallback:function(){var i=this.link.buildLinkFromModal();return i===!1?!1:(this.selection.restore(),this.link.insert(i,!0),!0)}.bind(this)});var n=this.link.buildLinkFromElement(e);n.url=this.link.removeSelfHostFromUrl(n.url),this.link.setModalValues(n),this.detect.isDesktop()&&$("#redactor-link-url").focus()}}};
// WoltLabMedia.js
$.Redactor.prototype.WoltLabMedia=function(){"use strict";return{init:function(){var t=this.button.add("woltlabMedia","");$(t).addClass("jsMediaEditorButton"),require(["WoltLab/WCF/Media/Manager/Editor"],function(t){new t})}}};
// WoltLabMention.js
$.Redactor.prototype.WoltLabMention=function(){"use strict";return{init:function(){document.registerElement("woltlab-mention");require(["WoltLab/WCF/Ui/Redactor/Mention"],function(t){new t(this)}.bind(this))}}};
+// WoltLabModal.js
+$.Redactor.prototype.WoltLabModal=function(){"use strict";var t=null,i="",e=null,o={close:function(){e.close(this)},load:function(e,o){t.innerHTML=this.modal.getTemplate(e),i=o},setTitle:function(t){e.setTitle(this,t)},show:function(){e.open(this),e.setTitle(this,i)}};return{init:function(){t=elCreate("div"),t.className="redactorModalWrapper",t.id="redactorOverlay-"+this.uuid,elHide(t),document.body.appendChild(t),this.$modalBody=$(t),require(["Ui/Dialog"],function(t){e=t;for(var i in o)o.hasOwnProperty(i)&&(this.modal[i]=o[i].bind(this))}.bind(this)),this._dialogSetup=function(){return{id:"redactorOverlay-"+this.uuid,options:{onClose:function(t){var i=e.getDialog(t);elBySelAll("[id]",i.content,function(t){t.removeAttribute("id")})}}}}}}};
// WoltLabQuote.js
$.Redactor.prototype.WoltLabQuote=function(){"use strict";return{init:function(){var t=this.button.add("woltlabQuote","");this.button.addCallback(t,this.WoltLabQuote.insert),require(["WoltLab/WCF/Ui/Redactor/Quote"],function(t){t.initEditor(this.$element[0].id,this.$editor[0])}.bind(this))},insert:function(){require(["Dom/Traverse","WoltLab/WCF/Ui/Redactor/Quote"],function(t,i){var e=this.selection.current();e&&(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),"BLOCKQUOTE"===e.nodeName||t.parentByTag(e,"BLOCKQUOTE",this.$editor[0]))||i.insert(function(t){t.innerHTML=this.opts.invisibleSpace+this.selection.markerHtml(),this.insert.html(t.outerHTML)}.bind(this))}.bind(this))}}};
// WoltLabSize.js