`Element.scrollTo()` is not standardized
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / redactor2 / plugins / combined.min.js
CommitLineData
f0aff717 1// alignment.js
fc7d120a 2!function(t){t.Redactor.prototype.alignment=function(){return{langs:{en:{align:"Align","align-left":"Align Left","align-center":"Align Center","align-right":"Align Right","align-justify":"Align Justify"}},init:function(){var t=this,e={};e.left={title:t.lang.get("align-left"),func:t.alignment.setLeft},e.center={title:t.lang.get("align-center"),func:t.alignment.setCenter},e.right={title:t.lang.get("align-right"),func:t.alignment.setRight},e.justify={title:t.lang.get("align-justify"),func:t.alignment.setJustify};var i=this.button.add("alignment",this.lang.get("align"));this.button.setIcon(i,'<i class="re-icon-alignment"></i>'),this.button.addDropdown(i,e)},removeAlign:function(){this.block.removeClass("text-center"),this.block.removeClass("text-right"),this.block.removeClass("text-justify")},setLeft:function(){this.buffer.set(),this.alignment.removeAlign()},setCenter:function(){this.buffer.set(),this.alignment.removeAlign(),this.block.addClass("text-center"),this.core.editor().focus()},setRight:function(){this.buffer.set(),this.alignment.removeAlign(),this.block.addClass("text-right"),this.core.editor().focus()},setJustify:function(){this.buffer.set(),this.alignment.removeAlign(),this.block.addClass("text-justify"),this.core.editor().focus()}}}}(jQuery);
f0aff717 3// source.js
9ebeee46 4!function(t){t.Redactor.prototype.source=function(){return{init:function(){var e=this.button.addFirst("html","HTML");this.button.addCallback(e,this.source.toggle);var s={width:"100%",margin:"0",background:"#111","box-sizing":"border-box",color:"rgba(255, 255, 255, .8)","font-size":"14px",outline:"none",padding:"16px","line-height":"22px","font-family":'Menlo, Monaco, Consolas, "Courier New", monospace'};this.source.$textarea=t("<textarea />"),this.source.$textarea.css(s).hide(),"textarea"===this.opts.type?this.core.box().append(this.source.$textarea):this.core.box().after(this.source.$textarea),this.core.element().on("destroy.callback.redactor",t.proxy(function(){this.source.$textarea.remove()},this))},toggle:function(){return this.source.$textarea.hasClass("open")?this.source.hide():this.source.show()},setCaretOnShow:function(){this.source.offset=this.offset.get();t(window).scrollTop(),this.core.editor().innerWidth(),this.core.editor().innerHeight();this.source.start=0,this.source.end=0;var e=t("<div/>").append(t.parseHTML(this.core.editor().html(),document,!0)),s=e.find("span.redactor-selection-marker");if(s.length>0){var r=e.html().replace(/&amp;/g,"&");1===s.length?(this.source.start=this.utils.strpos(r,e.find("#selection-marker-1").prop("outerHTML")),this.source.end=this.source.start):2===s.length&&(this.source.start=this.utils.strpos(r,e.find("#selection-marker-1").prop("outerHTML")),this.source.end=this.utils.strpos(r,e.find("#selection-marker-2").prop("outerHTML"))-e.find("#selection-marker-1").prop("outerHTML").toString().length)}},setCaretOnHide:function(t){if(this.source.start=this.source.$textarea.get(0).selectionStart,this.source.end=this.source.$textarea.get(0).selectionEnd,this.source.start>this.source.end&&this.source.end>0){var e=this.source.end,s=this.source.start;this.source.start=e,this.source.end=s}if(this.source.start=this.source.enlargeOffset(t,this.source.start),this.source.end=this.source.enlargeOffset(t,this.source.end),t=t.substr(0,this.source.start)+this.marker.html(1)+t.substr(this.source.start),this.source.end>this.source.start){var r=this.marker.html(1).toString().length;t=t.substr(0,this.source.end+r)+this.marker.html(2)+t.substr(this.source.end+r)}return t},hide:function(){this.source.$textarea.removeClass("open").hide(),this.source.$textarea.off(".redactor-source");var t=this.source.$textarea.val();t=this.paragraphize.load(t),t=this.source.setCaretOnHide(t),this.code.start(t),this.button.enableAll(),this.core.editor().show().focus(),this.selection.restore(),this.code.sync()},show:function(){this.selection.save(),this.source.setCaretOnShow();var e=this.core.editor().innerHeight(),s=this.code.get();s=s.replace(/\n\n\n/g,"\n"),s=s.replace(/\n\n/g,"\n"),this.core.editor().hide(),this.button.disableAll("html"),this.source.$textarea.val(s).height(e).addClass("open").show(),this.source.$textarea.on("keyup.redactor-source",t.proxy(function(){"textarea"===this.opts.type&&this.core.textarea().val(this.source.$textarea.val())},this)),this.marker.remove(),t(window).scrollTop(scroll),this.source.$textarea[0].setSelectionRange&&this.source.$textarea[0].setSelectionRange(this.source.start,this.source.end),this.source.$textarea[0].scrollTop=0,setTimeout(t.proxy(function(){this.source.$textarea.focus()},this),0)},enlargeOffset:function(t,e){var s=t.length,r=0;if(">"===t[e])r++;else for(var o=e;s>=o&&(r++,">"!==t[o]);o++)if("<"===t[o]||o===s){r=0;break}return e+r}}}}(jQuery);
f0aff717 5// table.js
40c1e17a 6!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.setIcon(t,'<i class="re-icon-table"></i>'),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 h=this.selection.current();0!==e(h).closest("li",this.core.editor()[0]).length?e(h).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.length?!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").length)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.length&&(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);
f0aff717 7// WoltLabAttachment.js
d88694cc 8$.Redactor.prototype.WoltLabAttachment=function(){"use strict";return{init:function(){this.opts.woltlab.attachments&&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)),t.add("com.woltlab.wcf.redactor2","replaceAttachment_"+this.$element[0].id,this.WoltLabAttachment._replaceAttachment.bind(this))}.bind(this))},_insert:function(t){if(!this.WoltLabSource.isActive()){var e=t.attachmentId;if(this.buffer.set(),t.url){var a="wcfImgAttachment"+this.uuid,n=elById(a);n&&n.removeAttribute("id"),this.insert.html('<img src="'+t.url+'" class="woltlabAttachment" data-attachment-id="'+e+'" id="'+a+'">'),n=elById(a);for(var i=!0,r=n;r=r.nextSibling;)if(r.nodeType!==Node.TEXT_NODE||""!==r.textContent.replace(/\u200B/g,"").trim()){i=!1;break}i?this.caret.after(n.parentNode):window.setTimeout(function(){var t=elById(a);if(t){t.removeAttribute("id");var e=t.nextSibling;e&&e.nodeType===Node.TEXT_NODE&&"​"===e.textContent||(e=document.createTextNode("​"),t.parentNode.insertBefore(e,t.nextSibling));var n=document.createRange();n.selectNode(e),n.collapse(!1);var i=window.getSelection();i.removeAllRanges(),i.addRange(n)}}.bind(this),10)}else this.insert.text("[attach="+e+"][/attach]");this.buffer.set()}},_replaceAttachment:function(t){var e=elCreate("img");e.className="woltlabAttachment",e.src=t.src,elData(e,"attachment-id",t.attachmentId),t.img.parentNode.insertBefore(e,t.img),elRemove(t.img)},_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,r=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1),c=[];i=r.nextNode();)-1!==i.textContent.indexOf(n)&&c.push(i);for(var o=0,l=c.length;l>o;o++)c[o].textContent=c[o].textContent.replace(new RegExp("\\[attach="+e+"\\]\\[\\/attach\\]","g"),"")}}}};
66f8046c 9// WoltLabAutosave.js
3946143e 10$.Redactor.prototype.WoltLabAutosave=function(){"use strict";return{init:function(){this.opts.woltlab.autosave&&(this.opts.woltlab.autosave.watch(this),this.opts.woltlab.autosave.createOverlay(),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveDestroy_"+this.$element[0].id,this.WoltLabAutosave.destroy.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveReset_"+this.$element[0].id,this.WoltLabAutosave.reset.bind(this)))},destroy:function(){this.opts.woltlab.autosave&&this.opts.woltlab.autosave.destroy()},reset:function(){this.opts.woltlab.autosave&&this.opts.woltlab.autosave.clear()}}};
7fc2a2f0 11// WoltLabBlock.js
0af38e32 12$.Redactor.prototype.WoltLabBlock=function(){"use strict";return{init:function(){this.block.tags=["p","blockquote","pre","h1","h2","h3","h4","h5","h6","div","figure"],this.block.format=function(e,t,o,i){return e="quote"===e?"blockquote":e,-1!==$.inArray(e,this.block.tags)?("p"===e&&"undefined"==typeof t&&(t="class"),this.placeholder.hide(),this.buffer.set(),this.utils.isCollapsed()?this.block.formatCollapsed(e,t,o,i):this.block.formatUncollapsed(e,t,o,i)):void 0}.bind(this);var e=function(e,t){return!(document.activeElement!==e||t===!1||!this.utils.isRedactorParent(t))}.bind(this),t=this.block.formatCollapsed;this.block.formatCollapsed=function(o,i,s,a){var l=this.selection.block();if(!l||"LI"!==l.nodeName&&"TD"!==l.nodeName){var h=this.core.editor()[0];e(h,l)||(this.selection.restore(),document.activeElement!==h&&h.focus()),e(h,l)||(this.focus.end(),this.selection.save());for(var r=t.call(this,o,i,s,a),n=0,c=r.length;c>n;n++)this.WoltLabBlock._paragraphize(r[n]);return this.caret.end(r),r}}.bind(this);var o=this.block.formatUncollapsed;this.block.formatUncollapsed=function(e,t,i,s){this.selection.save(),this.selection.blocks().forEach(function(t){if("OL"===t.nodeName||"UL"===t.nodeName){t.parentNode.nodeName.toLowerCase()===e;var o=elCreate("div");t.parentNode.insertBefore(o,t),o.appendChild(t)}}),this.selection.restore();for(var a,l=o.call(this,e,t,i,s),h=null,r=0,n=l.length;n>r;r++)if(a=l[r][0],this.WoltLabBlock._paragraphize(a),0===r)h=a;else{for(;a.childNodes.length;)h.appendChild(a.childNodes[0]);elRemove(a)}return $(h)}.bind(this)},register:function(e,t){-1===this.block.tags.indexOf(e)&&(this.block.tags.push(e),this.opts.paragraphizeBlocks.push(e),-1===this.opts.blockTags.indexOf(e)&&(this.opts.blockTags.push(e),this.reIsBlock=new RegExp("^("+this.opts.blockTags.join("|").toUpperCase()+")$","i")),t&&this.WoltLabKeydown.register(e))},_paragraphize:function(e){if(-1===["p","pre","h1","h2","h3","h4","h5","h6","div","figure"].indexOf(e.nodeName.toLowerCase())){for(var t=elCreate("p");e.childNodes.length;)t.appendChild(e.childNodes[0]);e.appendChild(t)}}}};
b20939de 13// WoltLabButton.js
5bff8b47 14$.Redactor.prototype.WoltLabButton=function(){"use strict";var t;return{init:function(){this.button.buildButtonTooltip=function(){};var t=this.button.clickCallback;this.button.clickCallback=function(e,o,n,i){"function"==typeof e.preventDefault&&e.preventDefault(),t.call(this,e,o,n,i)}.bind(this);var e,o,n,i;for(n=0,i=this.opts.woltlab.customButtons.length;i>n;n++)o=this.opts.woltlab.customButtons[n],e=this.button.add(o,""),this.button.addCallback(e,this.WoltLabButton._handleCustomButton);var s,a,l;for(n=0,i=this.opts.buttons.length;i>n;n++)if(o=this.opts.buttons[n],"wcfSeparator"!==o){if(!this.opts.woltlab.buttons.hasOwnProperty(o))throw new Error("Missing button definition for '"+o+"'.");switch(s=this.opts.woltlab.buttons[o],"underline"===o&&(this.opts.activeButtonsStates.u="underline"),o){case"subscript":case"superscript":e=this.button.addAfter(this.opts.buttons[n-1],o,""),this.button.setEvent(e,o,{func:"inline.format"}),this.opts.activeButtonsStates["subscript"===o?"sub":"sup"]=o;break;case"redo":case"undo":e=this.button.addAfter(this.opts.buttons[n-1],o,""),this.button.addCallback(e,this.buffer[o]);break;default:e=this.button.get(o)}if(a=s.icon,l=!1,!a.match(/^fa-/)&&a.match(/\.(gif|jpe?g|png|svg)$/)&&(l=!0),this.button.setIcon(e,'<span class="icon icon16 '+(l?"redactorButtonImage":a)+'"'+(l?" style=\"background-image: url('"+WCF_PATH+"icon/"+a+"')\"":"")+"></span>"),!e[0])throw new Error("Missing button element for '"+o+"'.");if(elAttr(e[0],"title",s.title),e[0].classList.add("jsTooltip"),"lists"===o){var r=e.data("dropdown");elBySel(".redactor-dropdown-outdent span",r[0]).textContent=WCF.Language.get("wcf.editor.list.outdent"),elBySel(".redactor-dropdown-indent span",r[0]).textContent=WCF.Language.get("wcf.editor.list.indent")}}var c=this.core.toolbar()[0];elBySelAll(".re-button-tooltip",c.parentNode,elRemove);for(var d,u={},h=[];c.childElementCount;)d=c.removeChild(c.children[0]),o=elAttr(d.children[0],"rel"),u[o]=d,h.push(o);var b=!1;for(n=0,i=this.opts.buttons.length;i>n;n++)o=this.opts.buttons[n],"wcfSeparator"!==o?(d=u[o],c.appendChild(d),h.splice(h.indexOf(o),1),b&&(d.classList.add("redactor-toolbar-separator"),b=!1)):b=!0;for(n=0,i=c.childElementCount;i>n;n++)d=c.children[n],e=d.children[0],elData(d,"show-on-mobile",-1!==this.opts.woltlab.buttonMobile.indexOf(e.rel));h.forEach(function(t){c.appendChild(u[t])}),WCF.DOMNodeInsertedHandler.execute(),require(["Ui/Screen"],function(t){t.on("screen-xs",{match:this.WoltLabButton._enableToggleButton.bind(this),unmatch:this.WoltLabButton._disableToggleButton.bind(this),setup:this.WoltLabButton._setupToggleButton.bind(this)})}.bind(this)),this.$toolbar[0].addEventListener("dragstart",function(t){t.preventDefault()})},_handleCustomButton:function(t){var e={cancel:!1};if(WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","bbcode_"+t+"_"+this.$element[0].id,e),e.cancel!==!0){this.buffer.set();var o="["+t+"]"+this.selection.html()+(this.selection.is()?"":this.marker.html())+"[/"+t+"]";this.insert.html(o),this.selection.restore()}window.setTimeout(function(){document.activeElement!==this.$editor[0]&&this.$editor[0].focus()}.bind(this),10)},_enableToggleButton:function(){null===t.parentNode&&this.$toolbar[0].appendChild(t)},_disableToggleButton:function(){null!==t.parentNode&&this.$toolbar[0].removeChild(t)},_setupToggleButton:function(){t=elCreate("li"),t.className="redactorToolbarToggle",t.innerHTML='<a href="#"><span class="icon icon16 fa-caret-down"></span></a>',elData(t,"show-on-mobile",!0);var e=t.children[0].children[0],o=function(t){t instanceof Event&&t.preventDefault(),this.$toolbar[0].classList.toggle("redactorToolbarOverride")&&document.activeElement&&document.activeElement!==this.$editor[0]&&document.activeElement.blur(),e.classList.toggle("fa-caret-down"),e.classList.toggle("fa-caret-up")}.bind(this);t.children[0].addEventListener("mousedown",o),this.$toolbar[0].appendChild(t),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this.$element[0].id,function(){this.$toolbar[0].classList.contains("redactorToolbarOverride")&&o()}.bind(this))}}};
bdfb22bb 15// WoltLabCaret.js
e78dff3c 16$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var e=this.caret.after;this.caret.after=function(t){t=this.caret.prepare(t),this.utils.isBlockTag(t.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(t),e.call(this,t)}.bind(this);var t=!1;require(["Environment"],function(e){t="ios"===e.platform()});var n=this.caret.end;this.caret.end=function(e){e=this.caret.prepare(e);var i=!1;if(e.nodeType===Node.ELEMENT_NODE&&e.lastChild&&"P"===e.lastChild.nodeName)i=!0;else if(t){var r=this.core.editor()[0];e.parentNode===r&&"<p><br></p>"===r.innerHTML&&(i=!0)}else"P"===e.nodeName&&0===e.childNodes.length&&(e.innerHTML="​",i=!0);if(i){var o=window.getSelection(),a=document.createRange();return a.selectNodeContents(e.lastChild),a.collapse(!1),o.removeAllRanges(),void o.addRange(a)}return n.call(this,e)}.bind(this);var i=this.selection.nodes;this.selection.nodes=function(e){var t=i.call(this,e);if(1===t.length&&t[0]===this.$editor[0]){var n=this.selection.range(this.selection.get());if(n.startContainer===n.endContainer)return[n.startContainer]}return t}.bind(this),this.$editor[0].addEventListener(WCF_CLICK_EVENT,this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange();var r=this.selection.saveInstant;this.selection.saveInstant=function(){var e=r.call(this);if(e){e.isAtNodeStart=!1;var t=window.getSelection();if(t.rangeCount&&!t.isCollapsed){var n=t.getRangeAt(0);n.startContainer.nodeType===Node.TEXT_NODE&&0===n.startOffset&&(e.isAtNodeStart=!0)}}return e}.bind(this);var o=this.selection.restoreInstant;this.selection.restoreInstant=function(e){if("undefined"!=typeof e||this.saved){var t="undefined"!=typeof e?e:this.saved;o.call(this,e);var n=window.getSelection();if(n.rangeCount)if(t.isAtNodeStart===!0){if(!n.isCollapsed){var i=n.getRangeAt(0),r=i.startContainer;if(t.node===r)return;for(;null!==r&&"P"!==r.nodeName;)r=r.parentNode;if(null!==r&&(r=r.nextElementSibling,null!==r&&"P"===r.nodeName&&0===r.textContent.replace(/\u200B/g,"").length)){r=r.nextElementSibling;for(var a=t.node;null!==a&&a!==r;)a=a.parentNode;a===r&&(i=i.cloneRange(),i.setStart(t.node,0),n.removeAllRanges(),n.addRange(i))}}}else if(n.isCollapsed){var s=n.anchorNode,l=this.core.editor()[0];if(s.nodeType===Node.TEXT_NODE&&s.parentNode===l&&n.anchorOffset===s.textContent.length){var d=s.nextElementSibling;d&&"P"===d.nodeName&&this.caret.start(d)}}}}.bind(this),this.selection.nodes=function(e){var t="undefined"==typeof e?[]:$.isArray(e)?e:[e],n=this.selection.get(),i=this.selection.range(n),r=[],o=[];if(this.utils.isCollapsed())r=[this.selection.current()];else{var a=i.startContainer,s=i.endContainer;if(a===s)return[a];for(var l=i.commonAncestorContainer;a&&a!==s;)r.push(a=this.selection.nextNode(a,l));for(a=i.startContainer;a&&a!==l;)r.unshift(a),a=a.parentNode}return $.each(r,function(e,n){if(n){var i=1!==n.nodeType?!1:n.tagName.toLowerCase();if($(n).hasClass("redactor-script-tag")||$(n).hasClass("redactor-selection-marker"))return;if(i&&0!==t.length&&-1===$.inArray(i,t))return;o.push(n)}}),0===o.length?[]:o}.bind(this),this.selection.nextNode=function(e,t){if(e.hasChildNodes())return e.firstChild;for(;e&&!e.nextSibling;)if(e=e.parentNode,t&&e===t)return null;return e?e.nextSibling:null}},paragraphAfterBlock:function(e){var t=e.nextElementSibling;t&&"P"!==t.nodeName&&(t=elCreate("p"),t.textContent="​",e.parentNode.insertBefore(t,e.nextSibling)),this.caret.after(e)},endOfEditor:function(){var e=this.core.editor()[0];document.activeElement!==e&&e.focus();var t=e.lastElementChild;"P"===t.nodeName?this.caret.end(t):this.caret.after(t)},_initInternalRange:function(){var e=this.core.editor()[0],t=null,n=window.getSelection(),i=function(){t=n.rangeCount?n.getRangeAt(0).cloneRange():null},r=function(){if(null!==t){if(document.activeElement===e){var i=n.getRangeAt(0);if(0!==i.startOffset)return;for(var r=i.startContainer;r;){if(r.parentNode===e){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}var o={x:e.scrollLeft,y:e.scrollTop};e.focus(),e.scrollTo(o.x,o.y),n.removeAllRanges(),n.addRange(t),t=null}};e.addEventListener("keyup",i),e.addEventListener("mouseup",function(){n.rangeCount&&i()});var o=this.selection.save;this.selection.save=function(){t=null,o.call(this)}.bind(this);var a=this.selection.restore;this.selection.restore=function(){t&&null===elBySel(".redactor-selection-marker",this.$editor[0])&&(r(),n.rangeCount&&this.utils.isRedactorParent(n.getRangeAt(0).commonAncestorContainer))||a.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(t){if(document.activeElement!==e){var n=window.getSelection();n.rangeCount&&this.utils.isRedactorParent(n.anchorNode)!==!1?e.focus():r()}s.call(this,t),i()}.bind(this);var l=this.insert.html;this.insert.html=function(e,t){var n=elBySel(".redactor-selection-marker",this.$editor[0]);l.call(this,e,t),(n||null===elBySel(".redactor-selection-marker",this.$editor[0]))&&i()}.bind(this),require(["Environment"],function(t){"ios"===t.platform()&&(e.addEventListener("focus",function(){document.addEventListener("selectionchange",i)}),e.addEventListener("blur",function(){document.removeEventListener("selectionchange",i)}))}.bind(this))},_handleEditorClick:function(e){if(this.selection.get().isCollapsed){var t=this.selection.block();if(t===!1){if(this.selection.current()===this.$editor[0]){var n=this.$editor[0].childNodes[this.selection.get().anchorOffset];n.nodeType===Node.ELEMENT_NODE&&"TABLE"===n.nodeName&&(t=n)}if(t===!1)return}for(var i=e.target;i&&!this.utils.isBlockTag(i.nodeName);)i=i.parentNode;if(i&&i!==t&&("P"!==t.nodeName||(t=t.parentNode,t!==this.$editor[0]&&this.utils.isBlockTag(t.nodeName)))){if("TD"===t.nodeName)for(;"TABLE"!==t.nodeName;)t=t.parentNode;if(!t.nodeName.match(/^H\d$/)&&!$(t).closest("ol, ul",this.$editor[0]).length){for(var r,o,a=t;a;){if(o=a.getBoundingClientRect(),e.clientY<o.top)r=!0,t=a;else{if(!(e.clientY>o.bottom))break;r=!1,t=a}if(!a.parentNode||a.parentNode===this.$editor[0])break;a=a.parentNode}if(void 0!==r){var s=t[(r?"previous":"next")+"ElementSibling"];if(s&&"P"===s.nodeName)return void this.caret.end(s);this.buffer.set();var l=elCreate("p");l.textContent="​",t.parentNode.insertBefore(l,r?t:t.nextSibling),this.caret.end(l)}}}}},_addParagraphAfterBlock:function(e){var t=e.nextElementSibling;(!t||"P"!==t.nodeName&&!this.utils.isBlockTag(t.nodeName))&&(t=elCreate("p"),t.textContent="​",e.parentNode.insertBefore(t,e.nextSibling))}}};
a8b5af63 17// WoltLabClean.js
ccdd48f5 18$.Redactor.prototype.WoltLabClean=function(){"use strict";return{init:function(){var e=this.clean.onSet;this.clean.onSet=function(t){t=t.replace(/\u200B/g,""),t=t.replace(/&amp;amp;/g,"@@@WCF_LITERAL_AMP@@@"),t=t.replace(/&amp;/g,"&amp;WCF_AMPERSAND&amp;"),t=e.call(this,t),t=t.replace(/&amp;WCF_AMPERSAND&(amp;)?/g,"&amp;"),t=t.replace(/@@@WCF_LITERAL_AMP@@@/,"&amp;amp;");var n=elCreate("div");return n.innerHTML=t,elBySelAll("iframe",n,elRemove),elBySelAll("pre",n,function(e){e.classList.contains("redactor-script-tag")&&elRemove(e)}),elBySelAll("td",n,function(e){0===e.childNodes.length&&(e.innerHTML="​")}),t=n.innerHTML}.bind(this);var t=this.clean.onSync;this.clean.onSync=function(e){var n=elCreate("div");n.innerHTML=e;var r={};return elBySelAll("pre",n,function(e){var t=WCF.getUUID();r[t]=e.textContent,e.textContent=t}),elBySelAll("p",n,function(e){var t=e.lastElementChild;if(t&&"BR"===t.nodeName&&t.nextSibling&&t.nextSibling.textContent.replace(/[\r\n\t]/g,"").match(/^\u200B+$/)){var n=elCreate("p");n.innerHTML="<br>",e.parentNode.insertBefore(n,e.nextSibling),e.removeChild(t.nextSibling),e.removeChild(t)}}),e=n.innerHTML,e=e.replace(/<p>\u200B<\/p>/g,"<p><br></p>"),e=e.replace(/&amp;/g,"&amp;WCF_AMPERSAND&amp;"),e=t.call(this,e),e=e.replace(/&WCF_AMPERSAND&/g,"&amp;"),n.innerHTML=e,elBySelAll("pre",n,function(e){r.hasOwnProperty(e.textContent)&&(e.textContent=r[e.textContent])}),e=n.innerHTML}.bind(this);var n=this.clean.savePreFormatting;this.clean.savePreFormatting=function(e){var t=this.clean.encodeEntities;return this.clean.encodeEntities=function(e){return WCF.String.escapeHTML(e)},e=n.call(this,e),this.clean.encodeEntities=t,e}.bind(this);var r=this.clean.onPaste;this.clean.onPaste=function(e,t,n){if(t.pre||this.utils.isCurrentOrParent("kbd")){var l=this.clean.removeEmptyInlineTags;return this.clean.removeEmptyInlineTags=function(e){return e},e=r.call(this,e,t,n),this.clean.removeEmptyInlineTags=l,e}var i=elCreate("div");i.innerHTML=e.replace(/@@@WOLTLAB-P-ALIGN-(?:left|right|center|justify)@@@/g,"");var a,o,s,c=!0;for(o=0,s=i.childElementCount;s>o;o++){if(a=i.children[o],"DIV"!==a.nodeName||0===a.childNodes.length){c=!1;break}if(1===a.childNodes.length&&1===a.childElementCount){var h=a.children[0];if(0===h.childNodes.length&&"BR"!==h.nodeName){c=!1;break}}}if(c){var d=[];for(o=0,s=i.childElementCount;s>o;o++)d.push(i.children[o]);d.forEach(function(e){var t=elCreate("p");for(i.insertBefore(t,e);e.childNodes.length>0;)t.appendChild(e.childNodes[0]);i.removeChild(e)})}var f,p,u,m,g=null!==elBySel(".MsoNormal",i),v=elBySelAll("[style]",i);for(o=0,s=v.length;s>o;o++){a=v[o],p=[];for(var b=0,y=a.style.length;y>b;b++)if(f=a.style[b],-1===this.opts.woltlab.allowedInlineStyles.indexOf(f)){if("font-weight"===f)m=a.style.getPropertyValue(f),("bold"===m||"bolder"===m)&&(m=600),m=~~m,m>500&&(u=elCreate("strong"),a.parentNode.insertBefore(u,a),u.appendChild(a));else if(g&&"margin-bottom"===f&&"P"===a.nodeName&&(m=a.style.getPropertyValue(f),m.match(/^12(?:\.0)?pt$/))){var C=elCreate("p");C.innerHTML="<br>",a.parentNode.insertBefore(C,a.nextSibling)}p.push(f)}p.forEach(function(e){a.style.removeProperty(e)})}return elBySelAll("span",i,function(e){if(!e.hasAttribute("style")||!e.style.length){for(;e.childNodes.length;)e.parentNode.insertBefore(e.childNodes[0],e);elRemove(e)}}),elBySelAll("p",i,function(e){e.classList.contains("MsoNormal")?1===e.childElementCount&&"O:P"===e.children[0].nodeName&&" "===e.textContent&&(e.innerHTML="<br>"):e.className.match(/\btext-(left|right|center|justify)\b/)&&e.insertBefore(document.createTextNode("@@@WOLTLAB-P-ALIGN-"+RegExp.$1+"@@@"),e.firstChild),e.removeAttribute("class"),e.removeAttribute("style")}),elBySelAll("img",i,function(e){e.removeAttribute("style")}),elBySelAll("br",i,function(e){e.parentNode.insertBefore(document.createTextNode("@@@WOLTLAB-BR-MARKER@@@"),e.nextSibling)}),e=r.call(this,i.innerHTML,t,n),e=e.replace(/\n*@@@WOLTLAB-BR-MARKER@@@\n*/g,"<woltlab-br-marker></woltlab-br-marker>"),e=e.replace(/(<p>)?\s*@@@WOLTLAB-P-ALIGN-(left|right|center|justify)@@@/g,function(e,t,n){return t?'<p class="text-'+n+'">':""}),i.innerHTML=e.replace(/&amp;quot;/g,"&quot;"),elBySelAll("woltlab-br-marker",i,function(e){var t=e.parentNode;if(null!==t){if("P"===t.nodeName){var n=elCreate("p");n.innerHTML="<br>";var r=!1,l=e.nextSibling;l&&"WOLTLAB-BR-MARKER"===l.nodeName&&(r=!0);for(var i=!r;e.nextSibling;)i&&0!==e.nextSibling.textContent.replace(/\u200B/g,"").trim().length&&(i=!1),n.appendChild(e.nextSibling);i||elRemove(n.firstElementChild);var a=e.previousSibling;a&&"BR"===a.nodeName&&elRemove(a),t.parentNode.insertBefore(n,t.nextSibling),r&&(n=elCreate("p"),n.innerHTML="<br>",t.parentNode.insertBefore(n,t.nextSibling))}else t.insertBefore(elCreate("br"),e);elRemove(e)}}),elBySelAll("p",i,function(e){var t=!1;0===e.childNodes.length?t=!0:""===e.textContent?(t=!0,elBySelAll("*",e,function(e){"SPAN"!==e.nodeName&&(t=!1)})):0===e.textContent.trim().length&&(elBySelAll("span",e,function(e){if(!e.hasAttribute("style")||!e.style.length){for(;e.childNodes.length;)e.parentNode.insertBefore(e.childNodes[0],e);elRemove(e)}}),0===e.children.length&&(e.innerHTML="<br>")),t&&elRemove(e)}),i.innerHTML}.bind(this);var l=[],i=function(e,t){for(var n,r,i={},a=0,o=t.length;o>a;a++)n=t[a],r=elAttr(e,n),"style"===n&&0===e.style.length&&0===r.indexOf("font-family")&&(r=r.replace(/&quot;/g,"")),i[n]=r;l.push({element:e,attributes:i})},a=this.clean.convertTags;this.clean.convertTags=function(e,t){var n=elCreate("div");n.innerHTML=e,l=[],WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","convertTags_"+this.$element[0].id,{addToStorage:i,div:n}),elBySelAll("span",n,function(e){i(e,["style"])}),l.forEach(function(e,t){var n=e.element,r=n.parentNode;for(r.insertBefore(document.createTextNode("###custom"+t+"###"),n),r.insertBefore(document.createTextNode("###/custom"+t+"###"),n.nextSibling);n.childNodes.length;)r.insertBefore(n.childNodes[0],n);r.removeChild(n)});var r=!1;t.links&&this.opts.pasteLinks&&(elBySelAll("a",n,function(e){e.href&&(e.outerHTML='#####[a href="'+e.href+'"]#####'+e.innerHTML+"#####[/a]#####")}),r=!0,t.links=!1);var o=!1;return t.images&&this.opts.pasteImages&&(elBySelAll("img",n,function(e){if(e.src){for(var t,n='#####[img src="'+e.src+'"',r=0,l=e.attributes.length;l>r;r++)t=e.attributes.item(r),"src"!==t.name&&(n+=" "+t.name+'="'+t.value+'"');e.outerHTML=n+"]#####"}}),o=!0,t.images=!1),e=a.call(this,n.innerHTML,t),o&&(t.images=!0),r&&(t.links=!0),e}.bind(this);var o=this.clean.reconvertTags;this.clean.reconvertTags=function(e,t){if(l.length){e=e.replace(/###(\/?)custom(\d+)###/g,'<$1woltlab-custom-tag data-index="$2">');var n=elCreate("div");n.innerHTML=e,elBySelAll("woltlab-custom-tag",n,function(e){var t=~~elData(e,"index");if(l[t]){var n=l[t],r=elCreate(n.element.nodeName);for(var i in n.attributes)n.attributes.hasOwnProperty(i)&&elAttr(r,i,n.attributes[i]);for(e.parentNode.insertBefore(r,e);e.childNodes.length;)r.appendChild(e.childNodes[0])}elRemove(e)}),e=n.innerHTML}return o.call(this,e,t)}.bind(this),this.clean.removeSpans=function(e){return e};var s=this.clean.getCurrentType;this.clean.getCurrentType=function(e,t){var n=s.call(this,e,t);return this.utils.isCurrentOrParent(["kbd"])&&(n.inline=!1,n.block=!1,n.encode=!0,n.pre=!0,n.paragraphize=!1,n.images=!1,n.links=!1),n}.bind(this)}}};
7240ee09 19// WoltLabCode.js
5bff8b47 20$.Redactor.prototype.WoltLabCode=function(){"use strict";return{init:function(){require(["WoltLabSuite/Core/Ui/Redactor/Code"],function(t){new t(this)}.bind(this));var t=this.code.start;this.code.start=function(e){t.call(this,e),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","codeStart_"+this.$element[0].id),elBySelAll("kbd",this.$editor[0],function(t){var e=t.nextSibling;if(!e||e.nodeType!==Node.TEXT_NODE||"​"!==e.textContent.substr(0,1)){var i=document.createTextNode("​");t.parentNode.insertBefore(i,e)}})}.bind(this);var e=this.code.set;this.code.set=function(t,i){e.call(this,t,i),this.utils.isEmpty()&&this.observe.toolbar()}.bind(this);var i=this.code.get;this.code.get=function(){return this.code.html=!1,this.code.startSync(this.core.editor().html()),i.call(this)}.bind(this)}}};
f0aff717 21// WoltLabColor.js
ef3633f5 22$.Redactor.prototype.WoltLabColor=function(){"use strict";var o=["000000","800000","8B4513","2F4F4F","008080","000080","4B0082","696969","B22222","A52A2A","DAA520","006400","40E0D0","0000CD","800080","808080","FF0000","FF8C00","FFD700","008000","00FFFF","0000FF","EE82EE","A9A9A9","FFA07A","FFA500","FFFF00","00FF00","AFEEEE","ADD8E6","DDA0DD","D3D3D3","FFF0F5","FAEBD7","FFFFE0","F0FFF0","F0FFFF","F0F8FF","E6E6FA","FFFFFF"];return{init:function(){for(var t,e=this.WoltLabColor.setColor.bind(this),r={},F=0,i=o.length;i>F;F++)t=o[F],r["color_"+t]={title:"#"+t,func:e};r.removeColor={title:this.lang.get("remove-color"),func:this.WoltLabColor.removeColor.bind(this)};var s=this.button.add("woltlabColor","");this.button.addDropdown(s,r);var l=s.data("dropdown");l.find("a").each(function(o,t){t.className.match(/redactor-dropdown-color_([A-F0-9]{6})/)&&(t.style.setProperty("color","#"+RegExp.$1,""),t.parentNode.classList.add("woltlab-color-selection"))}),$('<li class="dropdownDivider"></li>').insertBefore(l.children("li").last())},setColor:function(o){o=o.replace(/^color_/,""),this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(t){this.buffer.set(),t.format(this.$editor[0],"color","#"+o),this.buffer.set()}.bind(this)),this.selection.restore()},removeColor:function(){this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(o){this.buffer.set(),o.removeFormat(this.$editor[0],"color"),this.buffer.set()}.bind(this)),this.selection.restore()}}};
9549ef85 23// WoltLabDragAndDrop.js
0071b6f1 24$.Redactor.prototype.WoltLabDragAndDrop=function(){"use strict";return{init:function(){this.opts.woltlab.attachments&&require(["WoltLabSuite/Core/Ui/Redactor/DragAndDrop"],function(t){t.init(this)}.bind(this))}}};
f0aff717 25// WoltLabDropdown.js
26$.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)}}};
b20939de 27// WoltLabEvent.js
ccdd48f5 28$.Redactor.prototype.WoltLabEvent=function(){"use strict";var t=0;return{init:function(){this._callbacks=[],this._elementId=this.$element[0].id,elData(this.$editor[0],"element-id",this._elementId),require(["EventHandler"],function(t){this.WoltLabEvent._setEvents(t),t.add("com.woltlab.wcf.redactor2","destroy_"+this._elementId,function(){t.removeAllBySuffix("com.woltlab.wcf.redactor2",this._elementId)}.bind(this))}.bind(this));var e=window.navigator.userAgent.toLowerCase();-1===e.indexOf("windows phone")&&-1===e.indexOf("edge/")&&(this.$editor[0].addEventListener("focus",function(){t++,document.documentElement.classList.add("redactorActive")}),this.$editor[0].addEventListener("blur",function(){t--,window.setTimeout(function(){0===t&&document.documentElement.classList.remove("redactorActive")},100)})),this.events.iterateObserver=function(t){var e=!1;(("textarea"===this.opts.type||"div"===this.opts.type)&&!this.detect.isFirefox()&&t.target===this.core.editor()[0]&&"childList"===t.type&&!t.addedNodes.length&&!t.removedNodes.length||"class"===t.attributeName&&t.target===this.core.editor()[0]||"data-vivaldi-spatnav-clickable"===t.attributeName||"attributes"===t.type&&null===t.attributeName)&&(e=!0),e||(this.observe.load(),this.events.changeHandler())}.bind(this),this.events.observer.disconnect(),this.events.createObserver(),this.events.setupObserver()},_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.redactor2","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)),t.add("com.woltlab.wcf.redactor2","reset_"+e,function(){this.code.set("")}.bind(this))},register:function(t,e){require(["EventHandler"],function(i){var n=this.uuid;-1===this._callbacks.indexOf(t)&&(this.opts.callbacks[t]=function(e){var s={cancel:!1,event:e,redactor:this};return i.fire("com.woltlab.wcf.redactor2",t+"_"+n+"_"+this.WoltLabEvent._elementId,s),s.cancel===!1}.bind(this),this._callbacks.push(t)),require(["EventHandler"],function(i){i.add("com.woltlab.wcf.redactor2",t+"_"+n+"_"+this.WoltLabEvent._elementId,e)}.bind(this))}.bind(this))}}};
d9b4ae02 29// WoltLabFont.js
ef3633f5 30$.Redactor.prototype.WoltLabFont=function(){"use strict";return{_fonts:["Arial, Helvetica, sans-serif","Comic Sans MS, Marker Felt, cursive","Consolas, Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif",'Trebuchet MS", Helvetica, sans-serif',"Verdana, Geneva, sans-serif"],init:function(){var t=this.WoltLabFont.setFont.bind(this),e={};this.WoltLabFont._fonts.forEach(function(o,i){e["fontFamily_"+i]={title:o.split(",")[0].replace(/['"]/g,""),func:t}}),e.removeFont={title:this.lang.get("remove-font"),func:this.WoltLabFont.removeFont.bind(this)};var o=this.button.add("woltlabFont","");this.button.addDropdown(o,e);var i=o.data("dropdown");i.find("a").each(function(t,e){e.className.match(/^redactor-dropdown-fontFamily_(\d+)$/)&&e.style.setProperty("font-family",this.WoltLabFont._fonts[RegExp.$1],"")}.bind(this)),$('<li class="dropdownDivider"></li>').insertBefore(i.children("li").last())},setFont:function(t){t=t.replace(/^fontFamily_/,""),this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(e){this.buffer.set(),e.format(this.$editor[0],"font-family",this.WoltLabFont._fonts[t]),this.buffer.set()}.bind(this)),this.selection.restore()},removeFont:function(){this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(t){this.buffer.set(),t.removeFormat(this.$editor[0],"font-family"),this.buffer.set()}.bind(this)),this.selection.restore()}}};
429d0c67 31// WoltLabFullscreen.js
ea02b471 32$.Redactor.prototype.WoltLabFullscreen=function(){"use strict";var e,t=!1;return{init:function(){var o=this.button.add("woltlabFullscreen","");this.button.addCallback(o,this.WoltLabFullscreen._toggle.bind(this)),e=o[0],elHide(e.parentNode),require(["Ui/Screen"],function(o){o.on("screen-sm-up",{match:function(){elShow(e.parentNode)},unmatch:function(){elHide(e.parentNode),t&&this.WoltLabFullscreen._toggle()}.bind(this),setup:function(){elShow(e.parentNode)}})}.bind(this))},_toggle:function(){e.children[0].classList.toggle("fa-compress"),e.children[0].classList.toggle("fa-expand"),this.core.box()[0].classList.toggle("redactorBoxFullscreen")?(WCF.System.DisableScrolling.disable(),this.core.editor()[0].style.setProperty("height","calc(100% - "+~~this.core.toolbar()[0].clientHeight+"px)",""),t=!0):(WCF.System.DisableScrolling.enable(),this.core.editor()[0].style.removeProperty("height"),t=!1)}}};
eb6a5ff7 33// WoltLabImage.js
d88694cc 34$.Redactor.prototype.WoltLabImage=function(){"use strict";return{init:function(){if(this.opts.woltlab.allowImages){var t=this.button.add("woltlabImage","");this.button.addCallback(t,this.WoltLabImage.add)}var e=this.image.showEdit;this.image.showEdit=function(t){var a=t[0];if(!a.classList.contains("smiley")){e(t),this.modal.setTitle(WCF.Language.get("wcf.editor.image.edit")),this.modal.getActionButton().text(WCF.Language.get("wcf.global.button.save")),this.modal.getDeleteButton().text(WCF.Language.get("wcf.global.button.delete")),elById("redactor-image-source").value=a.src;var i=elById("redactor-image-float");a.classList.contains("messageFloatObjectLeft")?i.value="left":a.classList.contains("messageFloatObjectRight")&&(i.value="right"),a.classList.contains("woltlabAttachment")&&elRemove(elById("redactor-image-source-container"))}}.bind(this);var a=this.image.update;this.image.update=function(){var t=this.observe.image[0],e=elById("redactor-image-source"),i=function(t,e){$('<small class="innerError" />').text(e).insertAfter(t)};if(!t.classList.contains("woltlabAttachment")){var o=e.value.trim();if(""===o)return i(e,WCF.Language.get("wcf.global.form.error.empty"));if(!o.match(this.opts.regexps.url))return i(e,WCF.Language.get("wcf.editor.image.source.error.invalid"));t.src=o}t.classList.remove("messageFloatObjectLeft"),t.classList.remove("messageFloatObjectRight");var r=elById("redactor-image-float").value;("left"===r||"right"===r)&&t.classList.add("messageFloatObject"+WCF.String.ucfirst(r)),a.call(this),t.removeAttribute("alt"),t.removeAttribute("title"),this.caret.after(t)}.bind(this),this.opts.modal["image-edit"]='<div class="section"><dl id="redactor-image-source-container"><dt><label for="redactor-image-source">'+WCF.Language.get("wcf.editor.image.source")+'</label></dt><dd><input type="text" id="redactor-image-source" class="long"></dd></dl><dl><dt><label for="redactor-image-link">'+WCF.Language.get("wcf.editor.image.link")+'</label></dt><dd><input type="text" id="redactor-image-link" class="long"></dd></dl><dl><dt><label for="redactor-image-float">'+WCF.Language.get("wcf.editor.image.float")+'</label></dt><dd><select id="redactor-image-float"><option value="none">'+WCF.Language.get("wcf.global.noSelection")+'</option><option value="left">'+WCF.Language.get("wcf.editor.image.float.left")+'</option><option value="right">'+WCF.Language.get("wcf.editor.image.float.right")+'</option></select></dd></dl><input id="redactor-image-title" style="display: none"><input id="redactor-image-caption" style="display: none"><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>'},add:function(){this.modal.load("image-edit",WCF.Language.get("wcf.editor.image.insert")),this.modal.show(),this.modal.getDeleteButton().hide();var t=this.modal.getActionButton()[0];t.addEventListener(WCF_CLICK_EVENT,this.WoltLabImage.insert),t.textContent=WCF.Language.get("wcf.global.button.insert"),this.WoltLabModal.rebuild()},insert:function(t){t.preventDefault(),this.modal.getModal().find(".innerError").remove();var e=elById("redactor-image-source"),a=function(t,e){$('<small class="innerError" />').text(e).insertAfter(t)},i=e.value.trim();if(""===i)return a(e,WCF.Language.get("wcf.global.form.error.empty"));if(!i.match(this.opts.regexps.url))return a(e,WCF.Language.get("wcf.editor.image.source.error.invalid"));var o=elById("redactor-image-link"),r=o.value.trim();if(""!==r&&!r.match(this.opts.regexps.url))return a(o,WCF.Language.get("wcf.editor.image.link.error.invalid"));var l=elById("redactor-image-float").value,s="";("left"===l||"right"===l)&&(s="messageFloatObject"+WCF.String.ucfirst(l));var n='<img src="'+WCF.String.escapeHTML(i)+'"'+(s?' class="'+s+'"':"")+">";r&&(n='<a href="'+WCF.String.escapeHTML(r)+'">'+n+"</a>"),this.modal.close(),this.buffer.set(),this.insert.html(n)}}};
7ba058c5 35// WoltLabIndent.js
b8bb53f0 36$.Redactor.prototype.WoltLabIndent=function(){"use strict";return{init:function(){if(this.detect.isFirefox()){var e,t,i=this.indent.decrease;this.indent.decrease=function(){if(this.list.get()){var n=$(this.selection.current()).closest("li",this.core.editor()[0]),r=n.closest("ul, ol",this.core.editor()[0]);if(0===r.parent().closest("ul, ol",this.core.editor()[0]).length){var l=n[0];if(null!==elBySel("ul, ol",l)){this.buffer.set(),this.selection.save();var o,s,a=l.previousElementSibling;if(null!==a){for(o=elCreate(l.parentNode.nodeName.toLowerCase());a.nextSibling;)o.appendChild(a.nextSibling);s=a.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}if(null!==l.nextElementSibling){for(o=elCreate(l.parentNode.nodeName.toLowerCase());l.nextSibling;)o.appendChild(l.nextSibling);s=l.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}for(s=l.parentNode;l.childNodes.length;)s.parentNode.insertBefore(l.childNodes[0],s);return elRemove(s),void this.selection.restore()}}else{elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),this.selection.save(),e=elCreate("woltlab-list-marker"),n[0].insertBefore(e,n[0].firstChild);var d=n[0].lastElementChild;if("BR"===d.nodeName){for(var h="",a=d;a=a.nextSibling;)h+=a.textContent;""===h.replace(/\u200B/g,"").trim()&&elRemove(d)}t=elCreate("woltlab-list-marker"),n[0].appendChild(t),this.selection.restore()}i.call(this)}}.bind(this);var n=this.indent.removeEmpty;this.indent.removeEmpty=function(){if(e&&e.parentNode){for(var i,r=elCreate("li");(i=e.nextSibling)&&i!==t;)r.appendChild(i);e.parentNode.insertBefore(r,e),elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),e=void 0,t=void 0}n.call(this)}.bind(this)}this.indent.repositionItem=function(e){var t=e.next();0===t.length||"UL"===t[0].tagName&&"OL"===t[0].tagName||e.append(t);var i=e.prev();if(0!==i.length&&"LI"!==i[0].tagName){this.selection.save();var n=e.closest("li",this.core.editor()[0]);n.after(e),this.selection.restore()}}.bind(this),this.indent.normalize=function(){if(this.detect.isFirefox()){var e=this.selection.block();if(e&&"P"===e.nodeName){var t=e.previousElementSibling;t&&"BR"===t.nodeName&&elRemove(t)}}this.core.editor().find("li").each($.proxy(function(e,t){var i=$(t),n="";0!==this.opts.keepStyleAttr.length&&(n=","+this.opts.keepStyleAttr.join(",")),i.find(this.opts.inlineTags.join(",")).not("img"+n).not("span").removeAttr("style");var r=i.parent();if(0!==r.length&&"LI"===r[0].tagName){for(;t.nextSibling;)t.appendChild(t.nextSibling);return void r.after(i)}var l=i.next();0===l.length||"UL"!==l[0].tagName&&"OL"!==l[0].tagName||i.append(l)},this))}.bind(this)}}};
e4005b47 37// WoltLabInlineCode.js
5bff8b47 38$.Redactor.prototype.WoltLabInlineCode=function(){"use strict";var e;return{init:function(){this.opts.activeButtonsStates.kbd="tt",require(["Environment","EventHandler"],function(t,n){e=t,n.add("com.woltlab.wcf.redactor2","bbcode_tt_"+this.$element[0].id,this.WoltLabInlineCode._toggle.bind(this))}.bind(this))},_toggle:function(t){t.cancel=!0,this.button.toggle({},"kbd","func","inline.format");var n=window.getSelection(),o=n.anchorNode;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),"KBD"===o.nodeName){var i=o.nextSibling;if("ios"===e.platform()&&"safari"===e.browser())return void(i&&"BR"===i.nodeName&&o.parentNode.insertBefore(document.createTextNode("​"),i));for(;i;){if(i.nodeType!==Node.TEXT_NODE||i.textContent.length)return;i=i.nextSibling}i?i.textContent="​":o.parentNode.appendChild(document.createTextNode("​"))}}}};
6db06f19 39// WoltLabInsert.js
7ba058c5 40$.Redactor.prototype.WoltLabInsert=function(){"use strict";return{init:function(){var e=this.opts.woltlab.placeholderCallback,t=this.insert.html;this.insert.html=function(o,r){e&&(e=e());var n=window.getSelection();if(n.rangeCount&&"IMG"===n.anchorNode.nodeName&&this.caret.after(n.anchorNode),this.placeholder.hide(),this.core.editor().focus(),this.detect.isFirefox()){var i=n.anchorNode.nodeType===Node.TEXT_NODE?n.anchorNode.parentNode:n.anchorNode;null===i.closest(".redactor-layer")&&(this.selection.restore(),i=n.anchorNode.nodeType===Node.TEXT_NODE?n.anchorNode.parentNode:n.anchorNode,null===i.closest(".redactor-layer")&&(this.WoltLabCaret.endOfEditor(),this.selection.save()))}var a=this.selection.block(),l=""===this.$editor[0].innerHTML.replace(/<\/?p>/g,"").replace(/<br>/g,"").replace(/\u200B/g,"").trim();if(t.call(this,o,r),l&&(a=this.$editor[0].firstElementChild),a&&"P"===a.nodeName&&a.nextElementSibling){var c=!1;0===a.childElementCount&&""===a.textContent.replace(/\u200B/g,"").trim()?c=!0:1===a.childElementCount&&"<br>"===a.innerHTML&&(c=!0),c&&elRemove(a)}n.rangeCount&&"IMG"===n.anchorNode.nodeName&&this.caret.after(n.anchorNode)}.bind(this);var o=this.insert.text;this.insert.text=function(t){e&&(e=e()),o.call(this,t)}.bind(this)}}};
d68d790c 41// WoltLabKeydown.js
b8bb53f0 42$.Redactor.prototype.WoltLabKeydown=function(){"use strict";var e=[];return{init:function(){var e=window.getSelection(),t=this.keydown.init;this.keydown.init=function(i){var n;if(this.detect.isFirefox()&&e.isCollapsed&&i.which===this.keyCode.BACKSPACE&&(n=e.anchorNode,n.nodeType===Node.ELEMENT_NODE&&e.anchorOffset>0&&(n=n.childNodes[e.anchorOffset]),n.nodeType===Node.TEXT_NODE&&"​"===n.textContent)){for(var o=[],r=n;r=r.previousSibling;){if(r.nodeType===Node.ELEMENT_NODE){"IMG"!==r.nodeName&&(o=[]);break}if(r.nodeType===Node.TEXT_NODE){var s=r.textContent;if(""!==s&&"​"!==s){o=[];break}o.push(r)}}o.length&&o.forEach(elRemove)}if((i.which===this.keyCode.BACKSPACE||i.which===this.keyCode.DELETE)&&e.isCollapsed){var l=e.getRangeAt(0),d=l.startContainer;if(d.nodeType===Node.TEXT_NODE&&(d=d.parentNode),"P"===d.nodeName&&1===d.childNodes.length&&"​"===d.childNodes[0].textContent){if(d.previousElementSibling!==d.nextElementSibling){var a=null,h=null;return i.which===this.keyCode.BACKSPACE?null===d.previousElementSibling?h=d.nextElementSibling:a=d.previousElementSibling:null===d.nextElementSibling?a=d.previousElementSibling:h=d.nextElementSibling,elRemove(d),null===h?this.caret.end(a):this.caret.start(h),void i.preventDefault()}}else if(this.detect.isWebkit()&&"LI"===d.nodeName&&i.which===this.keyCode.DELETE){var c=e.anchorNode;if(c.nodeType===Node.TEXT_NODE&&c.textContent.length===e.anchorOffset&&c.parentNode.lastChild===c){var f=d.nextElementSibling;if(f&&"LI"===f.nodeName){for(this.buffer.set(),this.selection.save();f.childNodes.length;)d.appendChild(f.childNodes[0]);return elRemove(f),this.selection.restore(),void i.preventDefault()}}}}if(i.which===this.keyCode.BACKSPACE&&this.detect.isFirefox()){var u=this.selection.block();if(u&&"P"===u.tagName&&this.utils.isStartOfElement(u)){var p=u.previousElementSibling;if(p&&("OL"===p.nodeName||"UL"===p.nodeName)){this.buffer.set(),this.selection.save();for(var m=p.lastElementChild;u.childNodes.length;)m.appendChild(u.childNodes[0]);return elRemove(u),this.selection.restore(),void i.preventDefault()}}}var v=t.call(this,i);if(!(v===!1||i.originalEvent.defaultPrevented||(i=i.originalEvent,39!==i.which||i.ctrlKey||i.shiftKey||i.metaKey||i.altKey))){if(!e.isCollapsed)return;var g=e.anchorNode;if(g.nodeType!==Node.TEXT_NODE||e.getRangeAt(0).startOffset!==g.textContent.length)return;var y=g.parentNode;if("KBD"!==y.nodeName)return;var k=!0;for(n=y;n&&n!==this.core.editor()[0];){if(null!==n.nextSibling){for(;n.nextSibling&&n.nextSibling.nodeType===Node.TEXT_NODE&&0===n.nextSibling.textContent.length;)n.parentNode.removeChild(n.nextSibling);if(n.nextSibling&&"BR"!==n.nextSibling.nodeName||null!==n.nextSibling.nextSibling){k=!1;break}}n=n.parentNode}k&&y.parentNode.insertBefore(document.createTextNode("​"),y.nextSibling)}}.bind(this);var i=window.navigator.userAgent.toLowerCase();-1!==i.indexOf("linux")&&-1!==i.indexOf("android")&&-1!==i.indexOf("chrome")&&(this.keydown.checkEvents=function(){this.core.addEvent(!1)}.bind(this)),this.core.editor().off("keydown.redactor"),this.core.editor().on("keydown.redactor",this.keydown.init.bind(this)),this.keydown.onArrowDown=function(){for(var e=this.WoltLabKeydown._getBlocks(),t=0;t<e.length;t++)if(e[t])return this.keydown.insertAfterLastElement(e[t]),!1}.bind(this),this.keydown.onArrowUp=function(){for(var e=this.WoltLabKeydown._getBlocks(),t=0;t<e.length;t++)if(e[t])return this.keydown.insertBeforeFirstElement(e[t]),!1}.bind(this);var n=function(e){var t=this.core.callback("enter",e);if(t===!1)return e.preventDefault(),!1;if(this.keydown.blockquote&&this.keydown.exitFromBlockquote(e)===!0)return!1;if(this.keydown.pre)return this.keydown.insertNewLine(e);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(e);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.parents("ul,ol",this.$editor[0]).last();if(0!==n.length&&this.utils.isEmpty(n.html())&&0===o.next().length&&this.utils.isEmpty(o.find("li").last().html())){var r=n[0].closest("ul,ol");if(o[0]!==r)return this.indent.decrease(),!1;o.find("li").last().remove();var s=$(this.opts.emptyHtml);return o.after(s),this.caret.start(s),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(e);return this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?(this.keydown.insertBreakLine(e),void setTimeout(function(){for(var e=this.selection.block(),t=this.selection.inline();t&&t!==e;){if("A"===t.nodeName){var i=!1;if(0===t.childNodes.length?i=!0:""===t.textContent.replace(/\u200B/g,"").trim()&&(i=!0,elBySelAll("*",t,function(e){"SPAN"!==e.nodeName&&(i=!1)})),i){for(;t.childNodes.length;)t.parentNode.insertBefore(t.childNodes[0],t);elRemove(t);break}}t=t.parentNode}}.bind(this),1)):void 0}.bind(this);this.keydown.onEnter=function(e){var t=this.keydown.blockquote;t&&(this.keydown.blockquote=!1);var i=n.call(this,e);return t&&(this.keydown.blockquote=t),i}.bind(this),this.keydown.replaceToParagraph=function(e){var t=this.selection.block(),i=t.innerHTML.replace(/<br\s?\/?>/gi,"");if(t.tagName===e&&this.utils.isEmpty(i)&&!$(t).hasClass("redactor-in")){var n=document.createElement("p");$(t).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"===t.tagName&&$(t).removeAttr("style")}.bind(this),this.keydown.onShiftEnter=function(e){return this.buffer.set(),this.keydown.pre?this.keydown.insertNewLine(e):this.insert.raw("<br>​")}.bind(this);var o=this.keydown.onTab;this.keydown.onTab=function(e,t){return this.keydown.pre||0!==$(this.selection.current()).closest("ul, ol",this.core.editor()[0]).length?o.call(this,e,t):!0}.bind(this);var r=this.keydown.formatEmpty;this.keydown.formatEmpty=function(e){for(var t,i=this.$editor[0],n=0,o=i.childElementCount;o>n;n++)if(t=i.children[n],"P"!==t.nodeName&&this.utils.isBlockTag(t.nodeName))return;return r.call(this,e)}.bind(this),require(["Core","Environment"],function(e,t){if("desktop"===t.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(t){if(83===t.event.which){var i=!1;window.navigator.platform.match(/^Mac/)?t.event.ctrlKey&&t.event.altKey&&(i=!0):t.event.altKey&&!t.event.ctrlKey&&(i=!0),i&&(t.cancel=!0,"function"==typeof o.click?o.click():e.triggerEvent(o,WCF_CLICK_EVENT))}}.bind(this)))}}}}.bind(this)),this.WoltLabKeydown._handleBackspaceAndDelete()},register:function(t){-1===e.indexOf(t)&&e.push(t)},_getBlocks:function(){for(var t=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],i=0,n=e.length;n>i;i++)t.push(this.utils.isTag(this.keydown.current,e[i]));return t},_handleBackspaceAndDelete:function(){var e=function(e){return null===elBySel("img",e)&&""===e.textContent.replace(/\u200B/g,"").trim()},t=function(t){var i,n=this.selection.block();if(n)if("TD"===n.nodeName){var o=n.innerHTML;"​"===o?t.preventDefault():""===o&&(t.preventDefault(),n.innerHTML="​")}else if(-1!==n.nodeName.indexOf("-")&&e(n))i=n.parentNode,i.insertBefore(this.marker.get(),n.nextSibling),elRemove(n),this.selection.restore();else if(i=n&&"P"===n.nodeName?n.parentNode:null,i&&-1!==i.nodeName.indexOf("-")){var r=window.getSelection().getRangeAt(0),s=document.createRange();s.setStartBefore(n),s.setEnd(r.startContainer,r.startOffset);var l=s.cloneContents(),d=elCreate("div");if(d.appendChild(l),e(d)){t.preventDefault();var a=n.previousElementSibling,h=null;if(a)h=e(a);else for(i=n;(i=i.parentNode)&&i!==this.$editor[0];)if(a=i.previousElementSibling){h=!1;break}if(h)elRemove(a);else if(null!==h){var c=n.parentNode;if("P"===a.nodeName){for(a.appendChild(this.marker.get());n.childNodes.length;)a.appendChild(n.childNodes[0]);elRemove(n),this.selection.restore()}else a.appendChild(n),n.insertBefore(this.marker.get(),n.firstChild),this.selection.restore();e(c)&&elRemove(c)}else null===h&&(i=n.parentNode,e(i)&&elRemove(i))}}}.bind(this),i=function(t){var i,n=this.selection.block();if(-1!==n.nodeName.indexOf("-")&&e(n))i=n.parentNode,i.insertBefore(this.marker.get(),n.nextSibling),elRemove(n),this.selection.restore();else if(i=n&&"P"===n.nodeName?n.parentNode:null,i&&-1!==i.nodeName.indexOf("-")){var o=window.getSelection().getRangeAt(0),r=document.createRange();r.setStart(o.startContainer,o.startOffset),r.setEndAfter(n);var s=r.cloneContents(),l=elCreate("div");if(l.appendChild(s),e(l)){t.preventDefault();var d=n.nextElementSibling,a=null;if(d)a=e(d);else for(i=n;(i=i.parentNode)&&i!==this.$editor[0];)if(d=i.nextElementSibling){a=!1;break}if(a)elRemove(d);else if(null!==a){var h=d.parentNode;if("P"===d.nodeName){for(;d.childNodes.length;)n.appendChild(d.childNodes[0]);elRemove(d)}else{if(n.appendChild(this.marker.get()),i=n.parentNode,-1!==d.nodeName.indexOf("-")){var c=d.firstElementChild;if(c&&"P"===c.nodeName){for(;c.childNodes.length;)n.appendChild(c.childNodes[0]);d.removeChild(c),e(d)&&elRemove(d)}}else i.insertBefore(d,n.nextSibling);this.selection.restore()}e(h)&&elRemove(h)}else null===a&&(i=n.parentNode,e(i)&&elRemove(i))}}}.bind(this),n=function(){return this.opts.blockTags.filter(function(e){return-1!==e.indexOf("-")}).join(",")}.bind(this),o=[],r=function(){elBySelAll(n(),this.core.editor()[0],function(e){null!==e.parentNode&&-1!==o.indexOf(e)&&["nextElementSibling","previousElementSibling"].forEach(function(t){for(var i,n=e[t];null!==n&&n.nodeName===e.nodeName&&-1===o.indexOf(n);){if("previousElementSibling"===t)for(var r=n.childNodes.length-1;r>=0;r--)e.insertBefore(n.childNodes[r],e.firstChild);else for(;n.childNodes.length>0;)e.appendChild(n.childNodes[0]);i=n[t],elRemove(n),n=i}})}),o=[]}.bind(this);this.keydown.onBackspaceAndDeleteAfter=function(e){this.detect.isFirefox()&&(this.selection.isCollapsed()?e.which===this.keyCode.BACKSPACE?t(e):e.which===this.keyCode.DELETE&&i(e):(e.which===this.keyCode.BACKSPACE||e.which===this.keyCode.DELETE)&&elBySelAll(n(),this.core.editor()[0],function(e){o.push(e)})),setTimeout($.proxy(function(){o.length>0&&r(),this.code.syncFire=!1,this.keydown.removeEmptyLists();var t="";0!==this.opts.keepStyleAttr.length&&(t=","+this.opts.keepStyleAttr.join(","));var i=this.core.editor().find("*[style]");i.not("span, img, figure, iframe, #redactor-image-box, #redactor-image-editter, [data-redactor-style-cache], [data-redactor-span]"+t).removeAttr("style"),this.keydown.formatEmpty(e);var n=this.selection.current();"KBD"===n.nodeName&&0===n.innerHTML.length&&elRemove(n),this.code.syncFire=!0},this),1)}.bind(this)}}};
60aa6eb0 43// WoltLabKeyup.js
b8bb53f0 44$.Redactor.prototype.WoltLabKeyup=function(){"use strict";return{init:function(){this.WoltLabEvent.register("keyup",function(e){e.event.originalEvent.which===this.keyCode.ENTER&&this.WoltLabKeyup._keyupEnter()}.bind(this))},_keyupEnter:function(){var e=this.$editor[0],t=window.getSelection(),r=null;if(this.detect.isFirefox()){var n=t.anchorNode;if(n.nodeType===Node.TEXT_NODE&&0===t.anchorOffset&&(r=n.parentNode,r.childNodes[0]===n&&(n=n.parentNode)),"LI"===n.nodeName){var i=n.parentNode;if(r=i.parentNode,"LI"===r.nodeName&&null===i.previousSibling)return r.insertBefore(this.marker.get(),i),r.insertBefore(elCreate("br"),i),void this.selection.restore()}}for(var o=t.anchorNode;o.parentNode;){if(o.parentNode===e){r=o;break}o=o.parentNode}null!==r&&"P"===r.nodeName&&(this.WoltLabKeyup._rebuildEmptyParagraph(r,!1),r=r.previousElementSibling,null!==r&&"P"===r.nodeName&&this.WoltLabKeyup._rebuildEmptyParagraph(r,!0))},_rebuildEmptyParagraph:function(e,t){if(!(e.textContent.replace(/\u200B/g,"").trim().length>0)){for(var r=e;r.nodeType===Node.ELEMENT_NODE&&0!==r.childNodes.length;){if(r.children.length>1)return;r=1===r.children.length?r.children[0]:r.childNodes[0]}if(r.nodeType===Node.TEXT_NODE){var n=elCreate("br");r.parentNode.appendChild(n),t&&elRemove(r)}}}}};
a2f7ab4b 45// WoltLabLine.js
46$.Redactor.prototype.WoltLabLine=function(){"use strict";return{init:function(){this.line.removeOnBackspace=function(){if(this.utils.isCollapsed()){var t=$(this.selection.block());if(0!==t.length&&this.utils.isStartOfElement(t)){var i=t.prev();i.length&&"HR"===i[0].tagName&&(e.preventDefault(),i.remove())}}}.bind(this)}}};
f0aff717 47// WoltLabLink.js
debb9641 48$.Redactor.prototype.WoltLabLink=function(){"use strict";var i=null;return{init:function(){this.link.isUrl=function(i){var t="((xn--)?[\\W\\w\\D\\d]+(-(?!-[\\W\\w\\D\\d])+)*\\.)+[\\W\\w]{2,}",e=new RegExp("^(http|ftp|https|ts3server)://"+t,"i"),s=new RegExp("^"+t,"i"),r=new RegExp(".(html|php)$","i"),n=new RegExp("^/","i"),l=new RegExp("^tel:(.*?)","i");return-1===i.search(e)&&-1!==i.search(s)&&-1===i.search(r)&&"/"!==i.substring(0,1)&&(i="http://"+i),-1!==i.search(e)||-1!==i.search(r)||-1!==i.search(n)||-1!==i.search(l)?i:!1}.bind(this),this.link.show=this.WoltLabLink.show.bind(this),this.link.parse=function(i){if(this.link.isMailto(i.url))i.url="mailto:"+i.url.replace("mailto:","");else if(0!==i.url.search("#")&&this.opts.linkValidation){var t=this.link.isUrl(i.url);t===!1&&(t="http://"+i.url),i.url=t}return this.link.isEmpty(i)||i.url===!1?!1:i}.bind(this),require(["WoltLabSuite/Core/Ui/Redactor/Link"],function(t){i=t})},show:function(t){"undefined"!=typeof t&&t.preventDefault&&t.preventDefault();var e=this.selection.is();this.selection.save(),this.observe.closeAllTooltip();var s=this.link.is();i.showDialog({insert:s===!1,submitCallback:function(){var i=this.link.buildLinkFromModal();return i===!1?!1:(this.selection.restore(),this.link.insert(i,!0),!0)}.bind(this)}),e&&this.selection.restore();var r=this.link.buildLinkFromElement(s);e&&this.selection.save(),r.url=this.link.removeSelfHostFromUrl(r.url),this.link.setModalValues(r),this.detect.isDesktop()&&$("#redactor-link-url").focus()}}};
7ba058c5 49// WoltLabList.js
ccdd48f5 50$.Redactor.prototype.WoltLabList=function(){"use strict";return{init:function(){var t=this.list.combineAfterAndBefore;this.list.combineAfterAndBefore=function(e){var i=t.call(this,e);if(i){var s=e.nextElementSibling;"OL"!==s.nodeName&&"UL"!==s.nodeName||0!==s.childElementCount||elRemove(s)}return i}.bind(this),this.list.toggle=function(t){if(!this.utils.inBlocks(["table","td","th","tr"])){t="orderedlist"===t?"ol":t,t="unorderedlist"===t?"ul":t,t=t.toLowerCase(),this.buffer.set(),this.selection.save();var e=this.list._getBlocks(),i=this.selection.block(),s=$(i).parent().closest("ol, ul",this.core.editor()[0]);return 0===e.length&&0!==s.length&&(e=[s.get(0)]),e=this.list._isUnformat(t,e)?this.list._unformat(t,e):this.list._format(t,e),this.selection.restore(),e}}.bind(this)}}};
f0aff717 51// WoltLabMedia.js
a7ed761c 52$.Redactor.prototype.WoltLabMedia=function(){"use strict";return{init:function(){var t=this.button.add("woltlabMedia","");$(t).addClass("jsMediaEditorButton");var e=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","metacode_wsm_"+this.$element[0].id,function(t){if(1!==t.attributes.length){var e="";3===t.attributes.length&&("left"===t.attributes[2]?e=" messageFloatObjectLeft":"right"===t.attributes[2]&&(e=" messageFloatObjectRight"));var a=elCreate("img");a.className="woltlabSuiteMedia"+e,a.src=this.opts.woltlab.mediaUrl.replace(/&amp;/,"&").replace("-123456789",t.attributes[0]).replace("thumbnail=void",function(){return t.attributes[1]?"thumbnail="+t.attributes[1]:""}),elData(a,"media-id",t.attributes[0]),elData(a,"media-size",t.attributes[1]);var i=t.metacode;i.parentNode.insertBefore(a,i),elRemove(i),t.cancel=!0}}.bind(this));WCF.System.Event.addListener("com.woltlab.wcf.redactor2","destroy_"+this.$element[0].id,function(){WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","metacode_wsm_"+this.$element[0].id,e)}.bind(this)),require(["WoltLabSuite/Core/Media/Manager/Editor"],function(t){new t({editor:this})}.bind(this))}}};
f0aff717 53// WoltLabMention.js
9e2faf14 54$.Redactor.prototype.WoltLabMention=function(){"use strict";return{init:function(){require(["WoltLabSuite/Core/Ui/Redactor/Mention"],function(t){new t(this)}.bind(this))}}};
eb6a5ff7 55// WoltLabModal.js
b26cd77d 56$.Redactor.prototype.WoltLabModal=function(){"use strict";var t=null,i="",e=null,o={close:function(){this.selection.restore(),e.getDialog("redactorOverlay-"+this.uuid)&&e.close("redactorOverlay-"+this.uuid)},load:function(e,o){t.innerHTML=this.modal.getTemplate(e),i=o},setTitle:function(t){e.setTitle(this,t)},show:function(){this.selection.save(),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")})}}}}},rebuild:function(){e&&e.rebuild("redactorOverlay-"+this.uuid)}}};
26192762 57// WoltLabObserve.js
7ba058c5 58$.Redactor.prototype.WoltLabObserve=function(){"use strict";return{init:function(){var t=elByClass("re-button",this.button.toolbar()[0]);this.button.setInactiveAll=function(e){for(var o,s=0,i=t.length;i>s;s++)o=t[s],o.classList.contains("re-"+e)||o.classList.remove("redactor-act")}.bind(this),this.observe.buttons=function(t,e){var o=this.selection.current();if(t!==!1?this.button.setInactiveAll():this.button.setInactiveAll(e),t===!1&&"html"!==e)return void(-1!==$.inArray(e,this.opts.activeButtons)&&this.button.toggleActive(e));if(this.utils.isRedactorParent(o)){var s=this.WoltLabSource.isActive();this.utils.isCurrentOrParentHeader()||this.utils.isCurrentOrParent(["table","pre","blockquote","li"])?this.button.disable("horizontalrule"):s||this.button.enable("horizontalrule"),this.utils.isCurrentOrParent(["table","li"])?(this.button.disable("code"),this.button.disable("spoiler"),this.button.disable("woltlabQuote")):s||(this.button.enable("code"),this.button.enable("spoiler"),this.button.enable("woltlabQuote"));var i=this.$editor[0];if(o.nodeType!==Node.ELEMENT_NODE&&(o=o.parentNode),o.closest(".redactor-layer")===i)for(var r,n=[];o!==i;)r=o.nodeName.toLowerCase(),-1===n.indexOf(r)&&(this.opts.activeButtonsStates.hasOwnProperty(r)&&this.button.setActive(this.opts.activeButtonsStates[r]),n.push(r)),o=o.parentNode}}.bind(this),this.observe.dropdowns=function(){var t=this.selection.current();t&&t.nodeType!==Node.ELEMENT_NODE&&(t=t.parentNode);var e,o=this.$editor[0],s=t&&t.closest(".redactor-layer")===o,i=[];if(s)for(;t!==o;)e=t.nodeName.toLowerCase(),-1===i.indexOf(e)&&i.push(e),t=t.parentNode;for(var r,n=null,a=0,l=this.opts.observe.dropdowns.length;l>a;a++){r=this.opts.observe.dropdowns[a];var u=r.observe,h=u.element,b=r.item,d=u.in?u.in:!1,c=u.out?u.out:!1;"a"===h&&null===n&&(n=$("<div />").html(this.selection.html()).find("a").length),-1!==i.indexOf(h)&&s||"a"===h&&0!==n?this.observe.setDropdownProperties(b,d,c):this.observe.setDropdownProperties(b,c,d)}}.bind(this)}}};
3806d9bc 59// WoltLabPage.js
9e2faf14 60$.Redactor.prototype.WoltLabPage=function(){"use strict";return{init:function(){var t=this.button.add("woltlabPage","");require(["WoltLabSuite/Core/Ui/Redactor/Page"],function(e){new e(this,t[0])}.bind(this))}}};
bcb144c7 61// WoltLabPaste.js
b8bb53f0 62$.Redactor.prototype.WoltLabPaste=function(){"use strict";return{init:function(){var t=null,e=!1,i=document.documentMode&&"object"==typeof window.clipboardData,r=null,n=!1;require(["Environment"],function(t){n="ios"===t.platform()&&"safari"===t.browser()});var a=this.paste.init;this.paste.init=function(n){r=null;var s="pre"===this.opts.type||this.utils.isCurrentOrParent("pre");if(e=!s&&this.utils.isCurrentOrParent("kbd"),s||e){t=i?window.clipboardData.getData("Text"):n.originalEvent.clipboardData.getData("text/plain");var o=this.clean.encodeEntities;this.clean.encodeEntities=function(t){return this.clean.encodeEntities=o,WCF.String.escapeHTML(t)}.bind(this)}else if(this.detect.isFirefox()){var l=n.originalEvent.clipboardData.types;if(1===l.length&&"text/plain"===l[0]){var d=WCF.String.escapeHTML(n.originalEvent.clipboardData.getData("text/plain"));r="";var h=d.split("\n");1===h.length?r=d:h.forEach(function(t){t=t.trim(),""===t&&(t="<br>"),r+="<p>"+t+"</p>"})}}a.call(this,n)}.bind(this);var s=this.paste.getPasteBoxCode;this.paste.getPasteBoxCode=function(a){var o=s.call(this,a);if(e)return t;if(a&&(!o||i))return t;if(null!==r)return r;if(n){var l=elCreate("div");if(l.innerHTML=o,1===l.childElementCount){var d=l.children[0];"A"===d.nodeName&&d.textContent===d.href&&(o=d.textContent)}}return o}.bind(this),this.core.editor().off("paste.redactor").on("paste.redactor",this.paste.init.bind(this)),this.paste.detectClipboardUpload=function(t){t=t.originalEvent||t;var e;if(i){if(!window.clipboardData.files.length)return!1;e=window.clipboardData.files.item(0)}else{if(this.detect.isFirefox())return!1;var r=t.clipboardData,n=r.types;if(Array.isArray(n)&&-1!==n.indexOf("public.tiff"))return t.preventDefault(),!1;if(!r.items||!r.items.length)return;var a=!1;if(e=r.items[0].getAsFile(),null===e&&(this.detect.isWebkit()&&r.items.length>1&&(e=r.items[1].getAsFile(),a=!0,null!==e&&t.preventDefault()),null===e))return!1}var s=new FileReader;return s.readAsDataURL(e),s.onload=this.paste.insertFromClipboard.bind(this),a===!1}.bind(this),this.paste.insertFromClipboard=function(t){window.FormData&&(this.buffer.set(),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(t.target.result)}),this.rtePaste=!1)}.bind(this);var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",l=this.paste.insert;this.paste.insert=function(t,r){if(e&&(r.pre=!0),this.utils.isCurrentOrParent("kbd")){l.call(this,t,r);var n=this.selection.current();n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);for(var a=n.closest("kbd"),s=elByTag("p",a);s.length;)s[0].outerHTML=s[0].innerHTML;var d=a.innerHTML.split(/<br\s*\/?>/);if(d.length>1){for(var h=this.selection.block(),c=1,p=d.length;p>c;c++){var u=elCreate(h.nodeName);u.innerHTML="<kbd>"+d[c]+(c===p-1?this.marker.html():"")+"</kbd>",h.parentNode.insertBefore(u,h.nextSibling),h=u}a.innerHTML=d[0],this.selection.restore()}}else{if(r.pre)return l.call(this,t,r);var f=elCreate("div");f.innerHTML=t;var b=[];r.pre||r.text||elBySelAll("img",f,function(t){var e=t.src;if(0===e.indexOf("data:image")&&e!==o){t.src=o;var i=WCF.getUUID();elData(t,"uuid",i),b.push({src:e,uuid:i}),elHide(t)}}.bind(this)),l.call(this,f.innerHTML,r);var v=window.getSelection();v.rangeCount&&"A"===v.anchorNode.nodeName&&v.anchorOffset===v.anchorNode.childNodes.length&&this.caret.after(v.anchorNode),b.length&&window.setTimeout(function(){for(var t,e,r=0,n=b.length;n>r;r++)t=b[r],e=elBySel('img[data-uuid="'+t.uuid+'"]',this.$editor[0]),e&&(i?e.parentNode.removeChild(e):WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(t.src),replace:e}))}.bind(this),50);var A,g=[],m=this.core.editor()[0];for(c=0,p=m.childNodes.length;p>c;c++)A=m.childNodes[c],A.nodeType===Node.TEXT_NODE&&"​"===A.textContent&&g.push(A);g.forEach(elRemove),this.rtePaste=!1}}.bind(this),this.paste.clipboardUpload=function(){}}}};
f0aff717 63// WoltLabQuote.js
43ef3f1b 64$.Redactor.prototype.WoltLabQuote=function(){"use strict";return{init:function(){var t=this.button.add("woltlabQuote","");this.WoltLabBlock.register("woltlab-quote",!0),this.opts.replaceTags.blockquote="woltlab-quote",this.opts.activeButtonsStates["woltlab-quote"]="woltlabQuote",require(["WoltLabSuite/Core/Ui/Redactor/Quote"],function(o){new o(this,t)}.bind(this))}}};
e7f15e7b 65// WoltLabReply.js
cc8e55a3 66$.Redactor.prototype.WoltLabReply=function(){"use strict";var t=null,e=null,s=null;return{init:function(){var i=this.$editor[0].closest(".messageContent"),o=elById("messageQuickReply");i&&i.classList.contains("messageQuickReplyContent")&&o&&o.classList.contains("messageQuickReplyCollapsed")&&(t=this.WoltLabReply._click.bind(this),e=i,s=o,WCF.System.Event.addListener("com.woltlab.wcf.redactor2","showEditor",this.WoltLabReply.showEditor.bind(this)),e.addEventListener(WCF_CLICK_EVENT,t))},showEditor:function(){return s?void(s.classList.contains("messageQuickReplyCollapsed")&&(s.classList.remove("messageQuickReplyCollapsed"),e.removeEventListener(WCF_CLICK_EVENT,t),this.WoltLabCaret.endOfEditor())):void this.WoltLabCaret.endOfEditor()},_click:function(t){t.preventDefault(),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","showEditor")}}};
f0aff717 67// WoltLabSize.js
ef3633f5 68$.Redactor.prototype.WoltLabSize=function(){"use strict";return{init:function(){for(var e,t=[8,10,12,14,18,24,36],i=this.WoltLabSize.setSize.bind(this),o={},s=0,r=t.length;r>s;s++)e=t[s],o["size_"+e]={title:e,func:i};o.removeSize={title:this.lang.get("remove-size"),func:this.WoltLabSize.removeSize.bind(this)};var n=this.button.add("woltlabSize","");this.button.addDropdown(n,o);var a=n.data("dropdown");a.find("a").each(function(e,t){t.className.match(/redactor-dropdown-size_(\d{1,2})/)&&(t.style.setProperty("font-size",RegExp.$1+"pt",""),t.parentNode.classList.add("woltlab-size-selection"))}),$('<li class="dropdownDivider"></li>').insertBefore(a.children("li").last())},setSize:function(e){this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(t){this.buffer.set(),t.format(this.$editor[0],"font-size",e.replace(/^size_/,"")+"pt"),this.buffer.set()}.bind(this)),this.selection.restore()},removeSize:function(){this.selection.save(),require(["WoltLabSuite/Core/Ui/Redactor/Format"],function(e){this.buffer.set(),e.removeFormat(this.$editor[0],"font-size"),this.buffer.set()}.bind(this)),this.selection.restore()}}};
f0aff717 69// WoltLabSmiley.js
8622f282 70$.Redactor.prototype.WoltLabSmiley=function(){"use strict";var t=0;return{init:function(){require(["EventHandler"],function(t){t.add("com.woltlab.wcf.redactor2","insertSmiley_"+this.$element[0].id,this.WoltLabSmiley._insert.bind(this))}.bind(this))},_insert:function(i){if(!this.WoltLabSource.isActive()){this.buffer.set();var e="wscSmiley_"+this.uuid+"_"+t++,r=i.img.cloneNode();r.id=e,this.insert.html(r.outerHTML),r=elById(e),r.removeAttribute("id"),this.caret.after(r),r.outerHTML=r.outerHTML}}}};
da734c30 71// WoltLabSource.js
48b080f7 72$.Redactor.prototype.WoltLabSource=function(){"use strict";return{init:function(){function e(e){elBySelAll(".icon, .fa",e,function(e){var t=e.className.split(" ");t=t.filter(function(e){return"fa"===e||"icon"===e?!1:e.match(/^icon\d{2}$/)?!1:e.match(/^fa-[a-z\-]+$/)?!1:!0}),e.className=t.join(" "),""===e.className.trim()&&""===e.innerHTML&&elRemove(e)})}var t=this.$element[0].id,n=function(e){elBySelAll("woltlab-quote",e,function(e){if(2===e.childElementCount&&"P"===e.children[0].nodeName&&"P"===e.children[1].nodeName){var t=e.children[0];if(""===t.innerHTML.trim()){var n=e.children[1];"<br>"===n.innerHTML.trim()&&e.removeChild(t)}}})},i=function(e){elBySelAll("pre, woltlab-quote, woltlab-spoiler",e,function(e){e.removeAttribute("data-title")}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","source_stripIntermediateCode_"+t,{div:e})};this.source.setCaretOnShow=function(){},this.source.setCaretOnHide=function(e){return e};var r=this.source.hide;this.source.hide=function(){var t=$("<div />").html(this.source.$textarea.val());e(t[0]),this.source.$textarea.val(t[0].innerHTML),r.call(this),setTimeout(function(){this.focus.end(),n(this.core.editor()[0])}.bind(this),100),this.placeholder.enable()}.bind(this);var o=this.source.$textarea[0];this.$element[0].parentNode.insertBefore(o,this.$element[0]);var l=this.source.show;this.source.show=function(){var e=this.$editor[0].offsetHeight,t=this.code.get();l.call(this),this.source.$textarea.val(t),o.style.setProperty("height",Math.ceil(e)+"px",""),o.style.setProperty("display","block","");var r=elCreate("div");r.innerHTML=o.value,n(r),i(r),o.value=this.WoltLabSource.format(r.innerHTML),o.selectionStart=o.selectionEnd=o.value.length}.bind(this),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","validate_"+t,function(e){o.clientHeight&&(e.api.throwError(this.$element[0],WCF.Language.get("wcf.editor.source.error.active")),e.valid=!1)}.bind(this))},isActive:function(){return"none"===this.$editor[0].style.getPropertyValue("display")},format:function(e){var t=["ul","ol","li"];this.block.tags.forEach(function(e){t.push(e)}),t=t.join("|").toLowerCase();var n=["p","li"],i="[^'\">]*(?:(?:\"[^\"]*\"|'[^']*')[^'\">]*)*",r=[];e=e.replace(new RegExp("<pre"+i+">[sS]*?</pre>","g"),function(e){return r.push(e),"@@@WCF_PRE_BACKUP_"+(r.length-1)+"@@@"}),e=e.replace(new RegExp("\\s*</("+t+")>\\s*","g"),function(e,t){return(-1===n.indexOf(t)?"\n":"")+"</"+t+">"}),e=e.replace(new RegExp("\\s*<("+t+")("+i+")>\\s*","g"),function(e,t,i){return"\n<"+t+i+">"+(-1===n.indexOf(t)?"\n":"")}),e=e.replace(/<woltlab-quote([^>]*)>\n\t*\n(\t*)<p/,"<woltlab-quote$1>\n$2<p"),e=e.replace(new RegExp("<(ol|ul)("+i+")>\\s*","g"),"<$1$2>\n");var o,l,a,s=e.split(/\n/),c=0,u=new RegExp("^<("+t+")"),h=new RegExp("^</(?:"+t+")>$"),f=!1;for(o=0,l=s.length;l>o;o++){if(a=s[o],f=!1,a.match(u)?-1===n.indexOf(RegExp.$1)&&(f=!0):a.match(h)&&c--,c>0){var d=c;for(s[o]="";d--;)s[o]+=" ";s[o]+=a}f&&c++}for(e=s.join("\n"),o=0,l=r.length;l>o;o++)e=e.replace("@@@WCF_PRE_BACKUP_"+o+"@@@",r[o]);return e.trim()}}};
7fc2a2f0 73// WoltLabSpoiler.js
43ef3f1b 74$.Redactor.prototype.WoltLabSpoiler=function(){"use strict";return{init:function(){this.WoltLabBlock.register("woltlab-spoiler",!0),this.opts.activeButtonsStates["woltlab-spoiler"]="woltlabSpoiler",require(["WoltLabSuite/Core/Ui/Redactor/Spoiler"],function(t){new t(this)}.bind(this))}}};
449c09a4 75// WoltLabTable.js
5bff8b47 76$.Redactor.prototype.WoltLabTable=function(){"use strict";return{init:function(){this.WoltLabEvent.register("insertedTable",function(){window.setTimeout(function(){var e=this.selection.block()||this.selection.current();if(e===this.$editor[0]){var t=window.getSelection();t.isCollapsed&&t.anchorNode===this.$editor[0]&&t.anchorOffset>0&&(e=t.anchorNode.childNodes[t.anchorOffset-1])}if("TBODY"===e.nodeName&&(e=e.parentNode),"TABLE"===e.nodeName){for(var o,i=[],n=0,d=e.childNodes.length;d>n;n++)o=e.childNodes[n],o.nodeType===Node.TEXT_NODE&&o.textContent.length>0&&i.push(o);i.forEach(elRemove);var r=elBySel("td",e);r&&this.caret.end(r)}}.bind(this),10)}.bind(this))}}};
a8bc4290 77// WoltLabUtils.js
78$.Redactor.prototype.WoltLabUtils=function(){"use strict";return{init:function(){var t=this.utils.replaceToTag;this.utils.replaceToTag=function(i,r){return"figure"===r?i:t.call(this,i,r)}.bind(this)}}};