// WoltLabInsert.js
$.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 r=this.selection.block(),l=""===this.$editor[0].innerHTML.replace(/<\/?p>/g,"").replace(/<br>/g,"").replace(/\u200B/g,"").trim();if(e.call(this,i,n),l&&(r=this.$editor[0].firstElementChild),r&&"P"===r.nodeName&&r.nextElementSibling){var s=!1;0===r.childElementCount&&""===r.textContent.replace(/\u200B/g,"").trim()?s=!0:1===r.childElementCount&&"<br>"===r.innerHTML&&(s=!0),s&&elRemove(r)}}.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),this.keydown.onBackspaceAndDeleteAfter=function(t){setTimeout($.proxy(function(){this.code.syncFire=!1,this.keydown.removeEmptyLists(),this.core.editor().find("*[style]").not("span, img, #redactor-image-box, #redactor-image-editter").removeAttr("style"),this.keydown.formatEmpty(t),this.code.syncFire=!0},this),1)}.bind(this);var t=function(t){var e=this.core.callback("enter",t);if(e===!1)return t.preventDefault(),!1;if(this.keydown.blockquote&&this.keydown.exitFromBlockquote(t)===!0)return!1;if(this.keydown.pre)return this.keydown.insertNewLine(t);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(t);if(this.keydown.figure)setTimeout($.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout($.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var i=this.selection.current(),n=$(i).closest("li",this.$editor[0]),o=n.parentsUntil(this.$editor[0],"ul,ol").last();if(0!==n.length&&this.utils.isEmpty(n.html())&&0===o.next().length&&this.utils.isEmpty(o.find("li").last().html())){o.find("li").last().remove();var r=$(this.opts.emptyHtml);return o.after(r),this.caret.start(r),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(t);return this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?void this.keydown.insertBreakLine(t):void 0}.bind(this);this.keydown.onEnter=function(e){var i=this.keydown.blockquote;i&&(this.keydown.blockquote=!1);var n=t.call(this,e);return i&&(this.keydown.blockquote=i),n}.bind(this),this.keydown.replaceToParagraph=function(t){var e=this.selection.block(),i=e.innerHTML.replace(/<br\s?\/?>/gi,"");if(e.tagName===t&&this.utils.isEmpty(i)&&!$(e).hasClass("redactor-in")){var n=document.createElement("p");$(e).replaceWith(n);var o=document.createRange();o.setStart(n,0);var r=document.createTextNode("");o.insertNode(r),o.setStartAfter(r),o.collapse(!0);var s=window.getSelection();return s.removeAllRanges(),s.addRange(o),!1}"P"===e.tagName&&$(e).removeAttr("style")}.bind(this),this.keydown.onShiftEnter=function(t){return this.buffer.set(),this.keydown.pre?this.keydown.insertNewLine(t):this.insert.raw("<br>")}.bind(this);var e=this.keydown.onTab;this.keydown.onTab=function(t,i){return this.keydown.pre||0!==$(this.selection.current()).closest("ul, ol",this.core.editor()[0]).length?e.call(this,t,i):!0}.bind(this);var i=this.keydown.formatEmpty;this.keydown.formatEmpty=function(t){for(var e,n=this.$editor[0],o=0,r=n.childElementCount;r>o;o++)if(e=n.children[o],"P"!==e.nodeName&&this.utils.isBlockTag(e.nodeName))return;return i.call(this,t)}.bind(this),require(["Core","Environment"],function(t,e){if("desktop"===e.platform()){var i=this.$editor[0].closest("form, .message");if(null!==i){var n=elBySel(".formSubmit",i);if(null!==n){var o=elBySel('input[type="submit"], button[data-type="save"], button[accesskey="s"]',n);o&&(o.removeAttribute("accesskey"),this.WoltLabEvent.register("keydown",function(e){if(83===e.event.which){var i=!1;window.navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(i=!0):e.event.altKey&&!e.event.ctrlKey&&(i=!0),i&&(e.cancel=!0,"function"==typeof o.click?o.click():t.triggerEvent(o,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],i=0,n=t.length;n>i;i++)e.push(this.utils.isTag(this.keydown.current,t[i]));return e}}};
+$.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),this.keydown.onBackspaceAndDeleteAfter=function(t){setTimeout($.proxy(function(){this.code.syncFire=!1,this.keydown.removeEmptyLists(),this.core.editor().find("*[style]").not("span, img, #redactor-image-box, #redactor-image-editter").removeAttr("style"),this.keydown.formatEmpty(t),this.code.syncFire=!0},this),1)}.bind(this);var t=function(t){var e=this.core.callback("enter",t);if(e===!1)return t.preventDefault(),!1;if(this.keydown.blockquote&&this.keydown.exitFromBlockquote(t)===!0)return!1;if(this.keydown.pre)return this.keydown.insertNewLine(t);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(t);if(this.keydown.figure)setTimeout($.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout($.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var i=this.selection.current(),n=$(i).closest("li",this.$editor[0]),o=n.parentsUntil(this.$editor[0],"ul,ol").last();if(0!==n.length&&this.utils.isEmpty(n.html())&&0===o.next().length&&this.utils.isEmpty(o.find("li").last().html())){o.find("li").last().remove();var r=$(this.opts.emptyHtml);return o.after(r),this.caret.start(r),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(t);return this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?(this.keydown.insertBreakLine(t),void setTimeout(function(){for(var t=this.selection.block(),e=this.selection.inline();e&&e!==t;){if("A"===e.nodeName){var i=!1;if(0===e.childNodes.length?i=!0:""===e.textContent.replace(/\u200B/g,"")&&(i=!0,elBySelAll("*",e,function(t){"SPAN"!==t.nodeName&&(i=!1)})),i){for(;e.childNodes.length;)e.parentNode.insertBefore(e.childNodes[0],e);elRemove(e);break}}e=e.parentNode}}.bind(this),1)):void 0}.bind(this);this.keydown.onEnter=function(e){var i=this.keydown.blockquote;i&&(this.keydown.blockquote=!1);var n=t.call(this,e);return i&&(this.keydown.blockquote=i),n}.bind(this),this.keydown.replaceToParagraph=function(t){var e=this.selection.block(),i=e.innerHTML.replace(/<br\s?\/?>/gi,"");if(e.tagName===t&&this.utils.isEmpty(i)&&!$(e).hasClass("redactor-in")){var n=document.createElement("p");$(e).replaceWith(n);var o=document.createRange();o.setStart(n,0);var r=document.createTextNode("");o.insertNode(r),o.setStartAfter(r),o.collapse(!0);var s=window.getSelection();return s.removeAllRanges(),s.addRange(o),!1}"P"===e.tagName&&$(e).removeAttr("style")}.bind(this),this.keydown.onShiftEnter=function(t){return this.buffer.set(),this.keydown.pre?this.keydown.insertNewLine(t):this.insert.raw("<br>")}.bind(this);var e=this.keydown.onTab;this.keydown.onTab=function(t,i){return this.keydown.pre||0!==$(this.selection.current()).closest("ul, ol",this.core.editor()[0]).length?e.call(this,t,i):!0}.bind(this);var i=this.keydown.formatEmpty;this.keydown.formatEmpty=function(t){for(var e,n=this.$editor[0],o=0,r=n.childElementCount;r>o;o++)if(e=n.children[o],"P"!==e.nodeName&&this.utils.isBlockTag(e.nodeName))return;return i.call(this,t)}.bind(this),require(["Core","Environment"],function(t,e){if("desktop"===e.platform()){var i=this.$editor[0].closest("form, .message");if(null!==i){var n=elBySel(".formSubmit",i);if(null!==n){var o=elBySel('input[type="submit"], button[data-type="save"], button[accesskey="s"]',n);o&&(o.removeAttribute("accesskey"),this.WoltLabEvent.register("keydown",function(e){if(83===e.event.which){var i=!1;window.navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(i=!0):e.event.altKey&&!e.event.ctrlKey&&(i=!0),i&&(e.cancel=!0,"function"==typeof o.click?o.click():t.triggerEvent(o,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],i=0,n=t.length;n>i;i++)e.push(this.utils.isTag(this.keydown.current,t[i]));return e}}};
// WoltLabLink.js
$.Redactor.prototype.WoltLabLink=function(){"use strict";var i=null;return{init:function(){this.link.show=this.WoltLabLink.show.bind(this),require(["WoltLabSuite/Core/Ui/Redactor/Link"],function(t){i=t})},show:function(t){"undefined"!=typeof t&&t.preventDefault&&t.preventDefault(),this.selection.save(),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