// WoltLabButton.js
$.Redactor.prototype.WoltLabButton=function(){"use strict";return{init:function(){var t,o,s,e;for(s=0,e=this.opts.woltlab.customButtons.length;e>s;s++)o=this.opts.woltlab.customButtons[s],t=this.button.add(o,""),this.button.addCallback(t,this.WoltLabButton._handleCustomButton);var n;for(s=0,e=this.opts.buttons.length;e>s;s++)if(o=this.opts.buttons[s],"wcfSeparator"!==o){if(!this.opts.woltlab.buttons.hasOwnProperty(o))throw new Error("Missing button definition for '"+o+"'.");if(n=this.opts.woltlab.buttons[o],"subscript"===o||"superscript"===o?(t=this.button.addAfter(this.opts.buttons[s-1],o,""),this.button.setEvent(t,o,{func:"inline.format"})):t=this.button.get(o),this.button.setIcon(t,'<span class="icon icon16 '+n.icon+'"></span>'),!t[0])throw new Error("Missing button element for '"+o+"'.");elAttr(t[0],"title",n.title),t[0].classList.add("jsTooltip")}for(var i,r={},l=[],a=this.core.toolbar()[0];a.childElementCount;)i=a.removeChild(a.children[0]),o=elAttr(i.children[0],"rel"),r[o]=i,l.push(o);var h=!1;for(s=0,e=this.opts.buttons.length;e>s;s++)o=this.opts.buttons[s],"wcfSeparator"!==o?(i=r[o],a.appendChild(i),l.splice(l.indexOf(o),1),h&&(i.classList.add("redactor-toolbar-separator"),h=!1)):h=!0;for(s=0,e=a.childElementCount;e>s;s++)i=a.children[s],t=i.children[0],elData(i,"show-on-mobile",-1!==this.opts.woltlab.buttonMobile.indexOf(t.rel));l.forEach(function(t){a.appendChild(r[t])}),WCF.DOMNodeInsertedHandler.execute()},_handleCustomButton:function(t){var o={cancel:!1};if(WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","bbcode_"+t+"_"+this.$element[0].id,o),o.cancel!==!0){this.buffer.set();var s="["+t+"]"+this.selection.html()+(this.selection.is()?"":this.marker.html())+"[/"+t+"]";this.insert.html(s),this.selection.restore()}}}};
// WoltLabCaret.js
-$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var t=this.caret.after;this.caret.after=function(e){e=this.caret.prepare(e),this.utils.isBlockTag(e.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(e),t.call(this,e)}.bind(this),this.$editor[0].addEventListener("mouseup",this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange()},_initInternalRange:function(){var t=this.core.editor()[0],e=null,i=window.getSelection(),n=function(){e=i.getRangeAt(0).cloneRange()},r=function(){if(null!==e){if(document.activeElement===t){var n=i.getRangeAt(0);if(0!==n.startOffset)return;for(var r=n.startContainer;r;){if(r.parentNode===t){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}t.focus(),i.removeAllRanges(),i.addRange(e),e=null}};this.$editor[0].addEventListener("keyup",n),this.$editor[0].addEventListener("mouseup",function(){i.rangeCount&&n()});var a=this.selection.save;this.selection.save=function(){e=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){e&&(r(),i.rangeCount&&this.utils.isRedactorParent(i.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(e){document.activeElement!==t&&r(),s.call(this,e),n()}.bind(this);var l=this.insert.html;this.insert.html=function(t,e){l.call(this,t,e),n()}.bind(this)},_handleEditorClick:function(t){if(t.target===this.$editor[0]&&this.selection.get().isCollapsed){var e=this.selection.block();if(e!==!1&&("P"!==e.nodeName||(e=e.parentNode,e!==this.$editor[0]&&this.utils.isBlockTag(e.nodeName)))){if("TD"===e.nodeName)for(;"TABLE"!==e.nodeName;)e=e.parentNode;this.buffer.set();var i=t.clientY<e.getBoundingClientRect().top,n=elCreate("p");n.textContent="",e.parentNode.insertBefore(n,i?e:e.nextSibling),this.caret.end(n)}}},_addParagraphAfterBlock:function(t){var e=t.nextElementSibling;(!e||"P"!==e.nodeName&&!this.utils.isBlockTag(e.nodeName))&&(e=elCreate("p"),e.textContent="",t.parentNode.insertBefore(e,t.nextSibling))}}};
+$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var t=this.caret.after;this.caret.after=function(e){e=this.caret.prepare(e),this.utils.isBlockTag(e.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(e),t.call(this,e)}.bind(this),this.$editor[0].addEventListener("mouseup",this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange()},_initInternalRange:function(){var t=this.core.editor()[0],e=null,i=window.getSelection(),n=function(){e=i.rangeCount?i.getRangeAt(0).cloneRange():null},r=function(){if(null!==e){if(document.activeElement===t){var n=i.getRangeAt(0);if(0!==n.startOffset)return;for(var r=n.startContainer;r;){if(r.parentNode===t){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}t.focus(),i.removeAllRanges(),i.addRange(e),e=null}};this.$editor[0].addEventListener("keyup",n),this.$editor[0].addEventListener("mouseup",function(){i.rangeCount&&n()});var a=this.selection.save;this.selection.save=function(){e=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){e&&(r(),i.rangeCount&&this.utils.isRedactorParent(i.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(e){document.activeElement!==t&&r(),s.call(this,e),n()}.bind(this);var l=this.insert.html;this.insert.html=function(t,e){l.call(this,t,e),n()}.bind(this)},_handleEditorClick:function(t){if(t.target===this.$editor[0]&&this.selection.get().isCollapsed){var e=this.selection.block();if(e!==!1&&("P"!==e.nodeName||(e=e.parentNode,e!==this.$editor[0]&&this.utils.isBlockTag(e.nodeName)))){if("TD"===e.nodeName)for(;"TABLE"!==e.nodeName;)e=e.parentNode;this.buffer.set();var i=t.clientY<e.getBoundingClientRect().top,n=elCreate("p");n.textContent="",e.parentNode.insertBefore(n,i?e:e.nextSibling),this.caret.end(n)}}},_addParagraphAfterBlock:function(t){var e=t.nextElementSibling;(!e||"P"!==e.nodeName&&!this.utils.isBlockTag(e.nodeName))&&(e=elCreate("p"),e.textContent="",t.parentNode.insertBefore(e,t.nextSibling))}}};
// WoltLabClean.js
$.Redactor.prototype.WoltLabClean=function(){"use strict";return{init:function(){var n=this.clean.onSet;this.clean.onSet=function(t){return n.call(this,t.replace(/\u200B/g,""))}.bind(this);var t=this.clean.onSync;this.clean.onSync=function(n){var e,i={};return-1!==n.indexOf("<pre")&&(e=elCreate("div"),e.innerHTML=n,elBySelAll("pre",e,function(n){var t=WCF.getUUID();i[t]=n.textContent,n.textContent=t}),n=e.innerHTML),n=t.call(this,n),e&&(e.innerHTML=n,elBySelAll("pre",e,function(n){n.textContent=i[n.textContent]}),n=e.innerHTML),n}.bind(this);var e=this.clean.savePreFormatting;this.clean.savePreFormatting=function(n){var t=this.clean.encodeEntities;return this.clean.encodeEntities=function(n){return WCF.String.escapeHTML(n)},n=e.call(this,n),this.clean.encodeEntities=t,n}.bind(this)}}};
// WoltLabCode.js
// WoltLabInlineCode.js
$.Redactor.prototype.WoltLabInlineCode=function(){"use strict";return{init:function(){this.opts.activeButtonsStates.kbd="tt",require(["EventHandler"],function(t){t.add("com.woltlab.wcf.redactor2","bbcode_tt_"+this.$element[0].id,function(t){t.cancel=!0,this.button.toggle({},"kbd","func","inline.format")}.bind(this))}.bind(this))}}};
// WoltLabInsert.js
-$.Redactor.prototype.WoltLabInsert=function(){"use strict";return{init:function(){var t=this.insert.html;this.insert.html=function(e,i){this.placeholder.hide(),this.core.editor().focus();var n=this.selection.block();t.call(this,e,i),n&&"P"===n.nodeName&&n.nextElementSibling&&!n.childElementCount&&""===n.textContent.replace(/\u200B/g,"").trim()&&elRemove(n)}.bind(this)}}};
+$.Redactor.prototype.WoltLabInsert=function(){"use strict";return{init:function(){var t=this.opts.woltlab.placeholderCallback,e=this.insert.html;this.insert.html=function(i,n){t&&(t=t()),this.placeholder.hide(),this.core.editor().focus();var l=this.selection.block();e.call(this,i,n),l&&"P"===l.nodeName&&l.nextElementSibling&&!l.childElementCount&&""===l.textContent.replace(/\u200B/g,"").trim()&&elRemove(l)}.bind(this);var i=this.insert.text;this.insert.text=function(e){t&&(t=t()),i.call(this,e)}.bind(this)}}};
// WoltLabKeydown.js
$.Redactor.prototype.WoltLabKeydown=function(){"use strict";var t=[];return{init:function(){this.keydown.onArrowDown=function(){for(var t=this.WoltLabKeydown._getBlocks(),e=0;e<t.length;e++)if(t[e])return this.keydown.insertAfterLastElement(t[e]),!1}.bind(this),this.keydown.onArrowUp=function(){for(var t=this.WoltLabKeydown._getBlocks(),e=0;e<t.length;e++)if(t[e])return this.keydown.insertBeforeFirstElement(t[e]),!1}.bind(this);var t=this.keydown.onEnter;this.keydown.onEnter=function(e){var n=this.keydown.blockquote;n&&(this.keydown.blockquote=!1),t.call(this,e),n&&(this.keydown.blockquote=n)}.bind(this);var e=this.keydown.onTab;this.keydown.onTab=function(t,n){return this.keydown.pre||0!==$(this.selection.current()).closest("ul, ol",this.core.editor()[0]).length?e.call(this,t,n):!0}.bind(this),require(["Core","Environment"],function(t,e){if("desktop"===e.platform()){var n=this.$editor[0].closest("form, .message");if(null!==n){var o=elBySel(".formSubmit",n);if(null!==o){var i=elBySel('input[type="submit"], button[data-type="save"], button[accesskey="s"]',o);i&&(i.removeAttribute("accesskey"),this.WoltLabEvent.register("keydown",function(e){if(83===e.event.which){var n=!1;window.navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(n=!0):e.event.altKey&&!e.event.ctrlKey&&(n=!0),n&&(e.cancel=!0,t.triggerEvent(i,WCF_CLICK_EVENT))}}.bind(this)))}}}}.bind(this))},register:function(e){-1===t.indexOf(e)&&t.push(e)},_getBlocks:function(){for(var e=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],n=0,o=t.length;o>n;n++)e.push(this.utils.isTag(this.keydown.current,t[n]));return e}}};
// WoltLabLink.js