diff --git a/dist/suneditor.min.js b/dist/suneditor.min.js index e44a94486..88a9ea0c5 100644 --- a/dist/suneditor.min.js +++ b/dist/suneditor.min.js @@ -1 +1 @@ -!function(e){var t={};function n(i){if(t[i])return t[i].exports;var l=t[i]={i:i,l:!1,exports:{}};return e[i].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(i,l,function(t){return e[t]}.bind(null,l));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="XJR1")}({"1kvd":function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={name:"dialog",add:function(e){const t=e.context;t.dialog={kind:"",updateModal:!1,_closeSignal:!1};let n=e.util.createElement("DIV");n.className="se-dialog sun-editor-common";let i=e.util.createElement("DIV");i.className="se-dialog-back",i.style.display="none";let l=e.util.createElement("DIV");l.className="se-dialog-inner",l.style.display="none",n.appendChild(i),n.appendChild(l),t.dialog.modalArea=n,t.dialog.back=i,t.dialog.modal=l,t.dialog.modal.addEventListener("mousedown",this.onMouseDown_dialog.bind(e)),t.dialog.modal.addEventListener("click",this.onClick_dialog.bind(e)),t.element.relative.appendChild(n),n=null,i=null,l=null},onMouseDown_dialog:function(e){/se-dialog-inner/.test(e.target.className)?this.context.dialog._closeSignal=!0:this.context.dialog._closeSignal=!1},onClick_dialog:function(e){e.stopPropagation(),(/close/.test(e.target.getAttribute("data-command"))||this.context.dialog._closeSignal)&&this.plugins.dialog.close.call(this)},open:function(e,t){if(this.modalForm)return!1;this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null),this.plugins.dialog._bindClose=function(e){/27/.test(e.keyCode)&&this.plugins.dialog.close.call(this)}.bind(this),this._d.addEventListener("keydown",this.plugins.dialog._bindClose),this.context.dialog.updateModal=t,"full"===this.context.option.popupDisplay?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const n=this.context[e].focusElement;"function"==typeof this.plugins[e].on&&this.plugins[e].on.call(this,t),this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",n&&n.focus()},_bindClose:null,close:function(){this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null);const e=this.context.dialog.kind;this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.context.dialog.updateModal=!1,this.plugins[e].init.call(this),this.context.dialog.kind="",this.modalForm=null,this.focus()}};return void 0===t&&(e.SUNEDITOR_MODULES||(e.SUNEDITOR_MODULES={}),e.SUNEDITOR_MODULES.dialog=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_MODULES a window with a document");return l(e)}:l(i)},"3FqI":function(e,t,n){},P6u4:function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={code:"en",toolbar:{default:"Default",save:"Save",font:"Font",formats:"Formats",fontSize:"Size",bold:"Bold",underline:"Underline",italic:"Italic",strike:"Strike",subscript:"Subscript",superscript:"Superscript",removeFormat:"Remove Format",fontColor:"Font Color",hiliteColor:"Highlight Color",indent:"Indent",outdent:"Outdent",align:"Align",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",alignJustify:"Align justify",list:"List",orderList:"Ordered list",unorderList:"Unordered list",horizontalRule:"Horizontal line",hr_solid:"Solid",hr_dotted:"Dotted",hr_dashed:"Dashed",table:"Table",link:"Link",math:"Math",image:"Image",video:"Video",fullScreen:"Full screen",showBlocks:"Show blocks",codeView:"Code view",undo:"Undo",redo:"Redo",preview:"Preview",print:"print",tag_p:"Paragraph",tag_div:"Normal (DIV)",tag_h:"Header",tag_blockquote:"Quote",tag_pre:"Code",template:"Template",lineHeight:"Line height",paragraphStyle:"Paragraph style",textStyle:"Text style"},dialogBox:{linkBox:{title:"Insert Link",url:"URL to link",text:"Text to display",newWindowCheck:"Open in new window"},mathBox:{title:"Math",inputLabel:"Mathematical Notation",fontSizeLabel:"Font Size",previewLabel:"Preview"},imageBox:{title:"Insert image",file:"Select from files",url:"Image URL",altText:"Alternative text"},videoBox:{title:"Insert Video",url:"Media embed URL, YouTube"},caption:"Insert description",close:"Close",submitButton:"Submit",revertButton:"Revert",proportion:"Constrain proportions",basic:"Basic",left:"Left",right:"Right",center:"Center",width:"Width",height:"Height",size:"Size",ratio:"Ratio"},controller:{edit:"Edit",unlink:"Unlink",remove:"Remove",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",insertColumnBefore:"Insert column before",insertColumnAfter:"Insert column after",deleteColumn:"Delete column",fixedColumnWidth:"Fixed column width",resize100:"Resize 100%",resize75:"Resize 75%",resize50:"Resize 50%",resize25:"Resize 25%",autoSize:"Auto size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",rotateLeft:"Rotate left",rotateRight:"Rotate right",maxSize:"Max size",minSize:"Min size",tableHeader:"Table header",mergeCells:"Merge cells",splitCells:"Split Cells",HorizontalSplit:"Horizontal split",VerticalSplit:"Vertical split"},menu:{spaced:"Spaced",bordered:"Bordered",neon:"Neon",translucent:"Translucent",shadow:"Shadow"}};return void 0===t&&(e.SUNEDITOR_LANG||(e.SUNEDITOR_LANG={}),e.SUNEDITOR_LANG.en=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_LANG a window with a document");return l(e)}:l(i)},WUQj:function(e,t,n){},XJR1:function(e,t,n){"use strict";n.r(t);n("3FqI"),n("WUQj");var i={name:"colorPicker",add:function(e){const t=e.context;t.colorPicker={colorListHTML:"",_colorInput:"",_defaultColor:"#000",_styleProperty:"color",_currentColor:"",_colorList:[]};let n=this.createColorList(e,this._makeColorList);t.colorPicker.colorListHTML=n,n=null},createColorList:function(e,t){const n=e.context.option,i=e.lang,l=n.colorList&&0!==n.colorList.length?n.colorList:["#ff0000","#ff5e00","#ffe400","#abf200","#00d8ff","#0055ff","#6600ff","#ff00dd","#000000","#ffd8d8","#fae0d4","#faf4c0","#e4f7ba","#d4f4fa","#d9e5ff","#e8d9ff","#ffd9fa","#f1f1f1","#ffa7a7","#ffc19e","#faed7d","#cef279","#b2ebf4","#b2ccff","#d1b2ff","#ffb2f5","#bdbdbd","#f15f5f","#f29661","#e5d85c","#bce55c","#5cd1e5","#6699ff","#a366ff","#f261df","#8c8c8c","#980000","#993800","#998a00","#6b9900","#008299","#003399","#3d0099","#990085","#353535","#670000","#662500","#665c00","#476600","#005766","#002266","#290066","#660058","#222222"];let s=[],o='
';for(let e,n=0,i=l.length;n0&&(o+='
'+t(s)+"
",s=[]),"object"==typeof e&&(o+='
'+t(e)+"
")));return o+='
",o},_makeColorList:function(e){let t="";t+='",t},init:function(e,t){const n=this.plugins.colorPicker;let i=t||(n.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor);i=n.isHexColor(i)?i:n.rgb2hex(i)||i;const l=this.context.colorPicker._colorList;if(l)for(let e=0,t=l.length;e=3&&"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).substr(1)}},l={name:"fontColor",display:"submenu",add:function(e,t){e.addModule([i]);const n=e.context;n.fontColor={previewEl:null,colorInput:null,colorList:null};let l=this.setSubmenu.call(e);n.fontColor.colorInput=l.querySelector("._se_color_picker_input"),n.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),l.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),l.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),l.addEventListener("click",this.pickup.bind(e)),n.fontColor.colorList=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null},setSubmenu:function(){const e=this.context.colorPicker.colorListHTML,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker,t=this.context.fontColor;e._colorInput=t.colorInput,e._defaultColor="#333333",e._styleProperty="color",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"],null,null),this.submenuOff()}},s={name:"hiliteColor",display:"submenu",add:function(e,t){e.addModule([i]);const n=e.context;n.hiliteColor={previewEl:null,colorInput:null,colorList:null};let l=this.setSubmenu.call(e);n.hiliteColor.colorInput=l.querySelector("._se_color_picker_input"),n.hiliteColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),l.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),l.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),l.addEventListener("click",this.pickup.bind(e)),n.hiliteColor.colorList=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null},setSubmenu:function(){const e=this.context.colorPicker.colorListHTML,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker,t=this.context.hiliteColor;e._colorInput=t.colorInput,e._defaultColor="#FFFFFF",e._styleProperty="backgroundColor",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.hiliteColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.hiliteColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["background-color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.backgroundColor=e,this.nodeChange(t,["background-color"],null,null),this.submenuOff()}},o={name:"template",display:"submenu",add:function(e,t){e.context.template={};let n=this.setSubmenu.call(e);n.querySelector("ul").addEventListener("click",this.pickup.bind(e)),e.initMenuTarget(this.name,t,n),n=null},setSubmenu:function(){const e=this.context.option.templates;if(!e||0===e.length)throw Error('[SUNEDITOR.plugins.template.fail] To use the "template" plugin, please define the "templates" option.');const t=this.util.createElement("DIV");t.className="se-list-layer";let n='
",t.innerHTML=n,t},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=this.context.option.templates[e.target.getAttribute("data-value")];if(!t.html)throw this.submenuOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.setContents(t.html),this.submenuOff()}},a=n("1kvd"),r=n.n(a),c={name:"link",display:"dialog",add:function(e){e.addModule([r.a]);const t=e.context;t.link={focusElement:null,linkNewWindowCheck:null,linkAnchorText:null,_linkAnchor:null};let n=this.setDialog.call(e);t.link.modal=n,t.link.focusElement=n.querySelector("._se_link_url"),t.link.linkAnchorText=n.querySelector("._se_link_text"),t.link.linkNewWindowCheck=n.querySelector("._se_link_check");let i=this.setController_LinkButton.call(e);t.link.linkController=i,t.link._linkAnchor=null,i.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1),n.querySelector(".se-btn-primary").addEventListener("click",this.submit.bind(e)),i.addEventListener("click",this.onClick_linkController.bind(e)),t.dialog.modal.appendChild(n),t.element.relative.appendChild(i),n=null,i=null},setDialog:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-dialog-content",t.style.display="none",t.innerHTML='",t},setController_LinkButton:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-link",n.innerHTML='
",n},open:function(){this.plugins.dialog.open.call(this,"link","link"===this.currentControllerName)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=function(){if(0===this.context.link.focusElement.value.trim().length)return!1;const e=this.context.link,t=e.focusElement.value,n=e.linkAnchorText,i=0===n.value.length?t:n.value;if(this.context.dialog.updateModal){e._linkAnchor.href=t,e._linkAnchor.textContent=i,e._linkAnchor.target=e.linkNewWindowCheck.checked?"_blank":"";const n=e._linkAnchor.childNodes[0];this.setRange(n,0,n,n.textContent.length)}else{const n=this.util.createElement("A");n.href=t,n.textContent=i,n.target=e.linkNewWindowCheck.checked?"_blank":"";const l=this.getSelectedElements();if(l.length>1){const e=this.util.createElement(l[0].nodeName);e.appendChild(n),this.insertNode(e)}else this.insertNode(n);this.setRange(n.childNodes[0],0,n.childNodes[0],n.textContent.length)}this.history.push(!1),e.focusElement.value="",e.linkAnchorText.value=""}.bind(this);try{t()}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.focus()}return!1},active:function(e){if(e){if(this.util.isAnchor(e)&&null===e.getAttribute("data-image-link"))return this.controllerArray.indexOf(this.context.link.linkController)<0&&this.plugins.link.call_controller.call(this,e),!0}else this.controllerArray.indexOf(this.context.link.linkController)>-1&&this.controllersOff();return!1},on:function(e){e?this.context.link._linkAnchor&&(this.context.dialog.updateModal=!0,this.context.link.focusElement.value=this.context.link._linkAnchor.href,this.context.link.linkAnchorText.value=this.context.link._linkAnchor.textContent,this.context.link.linkNewWindowCheck.checked=!!/_blank/i.test(this.context.link._linkAnchor.target)):(this.plugins.link.init.call(this),this.context.link.linkAnchorText.value=this.getSelection().toString())},call_controller:function(e){this.editLink=this.context.link._linkAnchor=e;const t=this.context.link.linkController,n=t.querySelector("a");n.href=e.href,n.title=e.textContent,n.textContent=e.textContent;const i=this.util.getOffset(e,this.context.element.wysiwygFrame);t.style.top=i.top+e.offsetHeight+10+"px",t.style.left=i.left-this.context.element.wysiwygFrame.scrollLeft+"px",t.style.display="block";const l=this.context.element.wysiwygFrame.offsetWidth-(t.offsetLeft+t.offsetWidth);l<0?(t.style.left=t.offsetLeft+l+"px",t.firstElementChild.style.left=20-l+"px"):t.firstElementChild.style.left="20px",this.controllersOn(t,e,"link")},onClick_linkController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");if(t){if(e.preventDefault(),/update/.test(t)){const e=this.context.link;e.focusElement.value=e._linkAnchor.href,e.linkAnchorText.value=e._linkAnchor.textContent,e.linkNewWindowCheck.checked=!!/_blank/i.test(e._linkAnchor.target),this.plugins.dialog.open.call(this,"link",!0)}else if(/unlink/.test(t)){const e=this.util.getChildElement(this.context.link._linkAnchor,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!1),t=this.util.getChildElement(this.context.link._linkAnchor,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!0);this.setRange(e,0,t,t.textContent.length),this.nodeChange(null,null,["A"],!1)}else this.util.removeItem(this.context.link._linkAnchor),this.context.link._linkAnchor=null,this.focus(),this.history.push(!1);this.controllersOff()}},init:function(){const e=this.context.link;e.linkController.style.display="none",e._linkAnchor=null,e.focusElement.value="",e.linkAnchorText.value="",e.linkNewWindowCheck.checked=!1}},d=n("ee5k"),u=n.n(d),h={blockquote:{name:"blockquote",display:"command",add:function(e,t){e.context.blockquote={targetButton:t,tag:e.util.createElement("BLOCKQUOTE")}},active:function(e){if(e){if(/blockquote/i.test(e.nodeName))return this.util.addClass(this.context.blockquote.targetButton,"active"),!0}else this.util.removeClass(this.context.blockquote.targetButton,"active");return!1},action:function(){const e=this.util.getParentElement(this.getSelectionNode(),"blockquote");e?this.detachRangeFormatElement(e,null,null,!1,!1):this.applyRangeFormatElement(this.context.blockquote.tag.cloneNode(!1))}},align:{name:"align",display:"submenu",add:function(e,t){const n=e.icons,i=e.context;i.align={targetButton:t,_alignList:null,currentAlign:"",icons:{justify:n.align_justify,left:n.align_left,right:n.align_right,center:n.align_center}};let l=this.setSubmenu.call(e),s=l.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),i.align._alignList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null,s=null},setSubmenu:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-list-layer",n.innerHTML='
",n},active:function(e){const t=this.context.align.targetButton,n=t.querySelector("svg");if(e){if(this.util.isFormatElement(e)){const i=e.style.textAlign;if(i)return this.util.changeElement(n,this.context.align.icons[i]),t.setAttribute("data-focus",i),!0}}else this.util.changeElement(n,this.context.align.icons.left),t.removeAttribute("data-focus");return!1},on:function(){const e=this.context.align,t=e._alignList,n=e.targetButton.getAttribute("data-focus")||"left";if(n!==e.currentAlign){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(s=0,o=a.length;s";return r+="",n.innerHTML=r,n},active:function(e){const t=this.context.font.targetText,n=this.context.font.targetTooltip;if(e){if(e.style&&e.style.fontFamily.length>0){const i=e.style.fontFamily.replace(/["']/g,"");return this.util.changeTxt(t,i),this.util.changeTxt(n,i),!0}}else{const e=this.lang.toolbar.font;this.util.changeTxt(t,e),this.util.changeTxt(n,e)}return!1},on:function(){const e=this.context.font,t=e._fontList,n=e.targetText.textContent;if(n!==e.currentFont){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(let t,n=0,s=e.fontSizeUnit,o=i.length;n";return l+="",n.innerHTML=l,n},active:function(e){if(e){if(e.style&&e.style.fontSize.length>0)return this.util.changeTxt(this.context.fontSize.targetText,e.style.fontSize),!0}else this.util.changeTxt(this.context.fontSize.targetText,this.lang.toolbar.fontSize);return!1},on:function(){const e=this.context.fontSize,t=e._sizeList,n=e.targetText.textContent;if(n!==e.currentSize){for(let e=0,i=t.length;e
  • ",t},appendHr:function(e){const t=this.util.createElement("HR");t.className=e,this.focus();let n=this.insertComponent(t,!1);this.setRange(n,0,n,0)},horizontalRulePick:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!n&&!/UL/i.test(t.tagName);)n=t.getAttribute("data-value"),t=t.parentNode;n&&(this.plugins.horizontalRule.appendHr.call(this,"__se__"+n),this.submenuOff())}},list:{name:"list",display:"submenu",add:function(e,t){const n=e.context;n.list={targetButton:t,_list:null,currentList:"",icons:{bullets:e.icons.list_bullets,number:e.icons.list_number}};let i=this.setSubmenu.call(e),l=i.querySelector("ul");l.addEventListener("click",this.pickup.bind(e)),n.list._list=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,l=null},setSubmenu:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML='
    ",t},active:function(e){const t=this.context.list.targetButton,n=t.querySelector("svg"),i=this.util;if(e){if(i.isList(e)){const l=e.nodeName;return t.setAttribute("data-focus",l),i.addClass(t,"active"),/UL/i.test(l)?i.changeElement(n,this.context.list.icons.bullets):i.changeElement(n,this.context.list.icons.number),!0}}else t.removeAttribute("data-focus"),i.changeElement(n,this.context.list.icons.number),i.removeClass(t,"active");return!1},on:function(){const e=this.context.list,t=e._list,n=e.targetButton.getAttribute("data-focus")||"";if(n!==e.currentList){for(let e=0,i=t.length;e"),t.innerHTML+=n.outerHTML,e&&(t.innerHTML+="
    ")}else{const e=n.childNodes;for(;e[0];)t.appendChild(e[0])}c.appendChild(t),a||(u=c),a&&m===g&&!l.isRangeFormatElement(f)||(d||(d=c),s&&a&&m===g||a&&l.isList(g)&&g===r||c.parentNode!==m&&m.insertBefore(c,f)),l.removeItem(n),s&&null===h&&(h=c.children.length-1),a&&(l.getRangeFormatElement(g,p)!==l.getRangeFormatElement(r,p)||l.isList(g)&&l.isList(r)&&l.getElementDepth(g)!==l.getElementDepth(r))&&(c=l.createElement(e)),_&&0===_.children.length&&l.removeItem(_)}else l.removeItem(n);h&&(d=d.children[h]),o&&(g=c.children.length-1,c.innerHTML+=r.innerHTML,u=c.children[g],l.removeItem(r))}else{if(n)for(let e=0,t=i.length;e=0;n--)if(i[n].contains(i[e])){i.splice(e,1),e--,t--;break}const t=l.getRangeFormatElement(s),o=t&&t.tagName===e;let a,r;const c=function(e){return!this.isComponent(e)}.bind(l);o||(r=l.createElement(e));for(let t,s,d=0,u=i.length;d0){const e=l.cloneNode(!1),t=l.childNodes,s=this.util.getPositionIndex(i);for(;t[s];)e.appendChild(t[s]);n.appendChild(e)}0===l.children.length&&this.util.removeItem(l),this.util.mergeSameTags(o);const a=this.util.getEdgeChildNodes(t,n);return{cc:t.parentNode,sc:a.sc,ec:a.ec}},editInsideList:function(e,t){const n=(t=t||this.getSelectedElements().filter(function(e){return this.isListCell(e)}.bind(this.util))).length;if(0===n||!e&&!this.util.isListCell(t[0].previousElementSibling)&&!this.util.isListCell(t[n-1].nextElementSibling))return{sc:t[0],so:0,ec:t[n-1],eo:1};let i=t[0].parentNode,l=t[n-1],s=null;if(e){if(i!==l.parentNode&&this.util.isList(l.parentNode.parentNode)&&l.nextElementSibling)for(l=l.nextElementSibling;l;)t.push(l),l=l.nextElementSibling;s=this.plugins.list.editList.call(this,i.nodeName.toUpperCase(),t,!0)}else{let e=this.util.createElement(i.nodeName),o=t[0].previousElementSibling,a=l.nextElementSibling;const r={s:null,e:null,sl:i,el:i};for(let l,s=0,c=n;s span > span"),n.table.columnFixedButton=s.querySelector("._se_table_fixed_column"),n.table.headerButton=s.querySelector("._se_table_header"),s.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1);let o=this.setController_tableEditor.call(e);n.table.resizeDiv=o,n.table.splitMenu=o.querySelector(".se-btn-group-sub"),n.table.mergeButton=o.querySelector("._se_table_merge_button"),n.table.splitButton=o.querySelector("._se_table_split_button"),n.table.insertRowAboveButton=o.querySelector("._se_table_insert_row_a"),n.table.insertRowBelowButton=o.querySelector("._se_table_insert_row_b"),o.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1),l.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(e)),l.addEventListener("click",this.appendTable.bind(e)),o.addEventListener("click",this.onClick_tableController.bind(e)),s.addEventListener("click",this.onClick_tableController.bind(e)),e.initMenuTarget(this.name,t,i),n.element.relative.appendChild(o),n.element.relative.appendChild(s),i=null,l=null,o=null,s=null},setSubmenu:function(){const e=this.util.createElement("DIV");return e.className="se-submenu se-selector-table",e.innerHTML='
    1 x 1
    ',e},setController_table:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-table",n.innerHTML='
    ",n},setController_tableEditor:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-table-cell",n.innerHTML='
    • '+e.controller.VerticalSplit+'
    • '+e.controller.HorizontalSplit+"
    ",n},appendTable:function(){const e=this.util.createElement("TABLE"),t=this.plugins.table.createCells,n=this.context.table._tableXY[0];let i=this.context.table._tableXY[1],l="";for(;i>0;)l+=""+t.call(this,"td",n)+"",--i;l+="",e.innerHTML=l,this.insertComponent(e,!1);const s=e.querySelector("td div");this.setRange(s,0,s,0),this.plugins.table.reset_table_picker.call(this)},createCells:function(e,t,n){if(e=e.toLowerCase(),n){const t=this.util.createElement(e);return t.innerHTML="

    ",t}{let n="";for(;t>0;)n+="<"+e+">

    ",t--;return n}},onMouseMove_tablePicker:function(e){e.stopPropagation();let t=this._w.Math.ceil(e.offsetX/18),n=this._w.Math.ceil(e.offsetY/18);t=t<1?1:t,n=n<1?1:n,this.context.table.tableHighlight.style.width=t+"em",this.context.table.tableHighlight.style.height=n+"em";this.context.table.tableUnHighlight.style.width="10em",this.context.table.tableUnHighlight.style.height="10em",this.util.changeTxt(this.context.table.tableDisplay,t+" x "+n),this.context.table._tableXY=[t,n]},reset_table_picker:function(){if(!this.context.table.tableHighlight)return;const e=this.context.table.tableHighlight.style,t=this.context.table.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="10em",t.height="10em",this.util.changeTxt(this.context.table.tableDisplay,"1 x 1"),this.submenuOff()},init:function(){const e=this.context.table,t=this.plugins.table;if(t._removeEvents.call(this),t._selectedTable){const e=t._selectedTable.querySelectorAll(".se-table-selected-cell");for(let t=0,n=e.length;t0)for(let e,t=0;ts||(u>=e.index?(i+=e.cs,u+=e.cs,e.rs-=1,e.row=s+1,e.rs<1&&(r.splice(t,1),t--)):h===g-1&&(e.rs-=1,e.row=s+1,e.rs<1&&(r.splice(t,1),t--)));if(s===o&&h===l){n._logical_cellIndex=u;break}d>0&&a.push({index:u,cs:c+1,rs:d,row:-1}),i+=c}r=r.concat(a).sort((function(e,t){return e.index-t.index})),a=[]}a=null,r=null}},editTable:function(e,t){const n=this.plugins.table,i=this.context.table,l=i._element,s="row"===e;if(s){const e=i._trElement.parentNode;if(/^THEAD$/i.test(e.nodeName)){if("up"===t)return;if(!e.nextElementSibling||!/^TBODY$/i.test(e.nextElementSibling.nodeName))return void(l.innerHTML+=""+n.createCells.call(this,"td",i._logical_cellCnt,!1)+"")}}if(n._ref){const e=i._tdElement,l=n._selectedCells;if(s)if(t)n.setCellInfo.call(this,"up"===t?l[0]:l[l.length-1],!0),n.editRow.call(this,t,e);else{let e=l[0].parentNode;const i=[l[0]];for(let t,n=1,s=l.length;no&&o>t&&(e[l].rowSpan=n+a,c-=i)}if(i){const e=r[s+1];if(e){const t=[];let n=r[s].cells,i=0;for(let e,l,s=0,o=n.length;s1&&(e.rowSpan-=1,t.push({cell:e.cloneNode(!1),index:l}));if(t.length>0){let l=t.shift();n=e.cells,i=0;for(let s,o,a=0,r=n.length;a=l.index)||(a--,i--,i+=l.cell.colSpan-1,e.insertBefore(l.cell,s),l=t.shift(),l));a++);if(l){e.appendChild(l.cell);for(let n=0,i=t.length;n0){const e=!s[b+1];for(let t,n=0;n_||(p>=t.index?(f+=t.cs,p=b+f,t.rs-=1,t.row=_+1,t.rs<1&&(d.splice(n,1),n--)):e&&(t.rs-=1,t.row=_+1,t.rs<1&&(d.splice(n,1),n--)))}n>0&&c.push({rs:n,cs:r+1,index:p,row:-1}),p>=t&&p+r<=t+o?h.push(e):p<=t+o&&p+r>=t?e.colSpan-=i.getOverlapRangeAtIndex(a,a+o,p,p+r):n>0&&(pt+o)&&g.push({cell:e,i:_,rs:_+n}),f+=r}else{if(b>=t)break;if(r>0){if(u<1&&r+b>=t){e.colSpan+=1,t=null,u=n+1;break}t-=r}if(!m){for(let e,n=0;n0){u-=1;continue}null!==t&&s.length>0&&(p=this.plugins.table.createCells.call(this,s[0].nodeName,0,!0),p=e.insertBefore(p,s[t]))}}if(l){let e,t;for(let n,l=0,s=h.length;l1)c.colSpan=this._w.Math.floor(e/2),l.colSpan=e-c.colSpan,o.insertBefore(c,l.nextElementSibling);else{let t=[],n=[];for(let o,r,c=0,d=i._rowCnt;c0)for(let e,t=0;tc||(u>=e.index?(r+=e.cs,u+=e.cs,e.rs-=1,e.row=c+1,e.rs<1&&(n.splice(t,1),t--)):h===g-1&&(e.rs-=1,e.row=c+1,e.rs<1&&(n.splice(t,1),t--)));if(u<=a&&d>0&&t.push({index:u,cs:s+1,rs:d,row:-1}),i!==l&&u<=a&&u+s>=a+e-1){i.colSpan+=1;break}if(u>a)break;r+=s}n=n.concat(t).sort((function(e,t){return e.index-t.index})),t=[]}o.insertBefore(c,l.nextElementSibling)}}else{const e=l.rowSpan;if(c.colSpan=l.colSpan,e>1){c.rowSpan=this._w.Math.floor(e/2);const n=e-c.rowSpan,i=[],r=t.getArrayIndex(s,o)+n;for(let e,t,n=0;n=a));c++)l=e[c],s=l.rowSpan-1,s>0&&s+n>=r&&o=h.index&&(r+=h.cs,l+=h.cs,h=i.shift()),l>=a||s===o-1){d.insertBefore(c,e.nextElementSibling);break}r+=t}l.rowSpan=n}else{c.rowSpan=l.rowSpan;const e=t.createElement("TR");e.appendChild(c);for(let e,t=0;t=r&&(e[n].rowSpan+=1)}const n=i._physical_cellIndex,a=o.cells;for(let e=0,t=a.length;e0&&o+s>=i&&(e.rowSpan-=n.getOverlapRangeAtIndex(i,l,o,o+s));else s.push(e[o]);for(let e=0,t=s.length;e"+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"",i.insertBefore(t,i.firstElementChild)}e.toggleClass(t,"active"),/TH/i.test(this.context.table._tdElement.nodeName)?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,this.context.table._tdElement,!1)},setTableStyle:function(e){const t=this.context.table,n=t._element;let i,l,s,o;e.indexOf("width")>-1&&(i=t.resizeButton.querySelector("svg"),l=t.resizeText,t._maxWidth?(s=t.icons.reduction,o=t.minText,t.columnFixedButton.style.display="block",this.util.removeClass(n,"se-table-size-auto"),this.util.addClass(n,"se-table-size-100")):(s=t.icons.expansion,o=t.maxText,t.columnFixedButton.style.display="none",this.util.removeClass(n,"se-table-size-100"),this.util.addClass(n,"se-table-size-auto")),this.util.changeElement(i,s),this.util.changeTxt(l,o)),e.indexOf("column")>-1&&(t._fixedColumn?(this.util.removeClass(n,"se-table-layout-auto"),this.util.addClass(n,"se-table-layout-fixed"),this.util.addClass(t.columnFixedButton,"active")):(this.util.removeClass(n,"se-table-layout-fixed"),this.util.addClass(n,"se-table-layout-auto"),this.util.removeClass(t.columnFixedButton,"active")))},setActiveButton:function(e,t){const n=this.context.table;/^TH$/i.test(e.nodeName)?(n.insertRowAboveButton.setAttribute("disabled",!0),n.insertRowBelowButton.setAttribute("disabled",!0)):(n.insertRowAboveButton.removeAttribute("disabled"),n.insertRowBelowButton.removeAttribute("disabled")),t&&e!==t?(n.splitButton.setAttribute("disabled",!0),n.mergeButton.removeAttribute("disabled")):(n.splitButton.removeAttribute("disabled"),n.mergeButton.setAttribute("disabled",!0))},_bindOnSelect:null,_bindOffSelect:null,_bindOffShift:null,_selectedCells:null,_shift:!1,_fixedCell:null,_fixedCellName:null,_selectedCell:null,_selectedTable:null,_ref:null,_toggleEditor:function(e){this.context.element.wysiwyg.setAttribute("contenteditable",e),e?this.util.removeClass(this.context.element.wysiwyg,"se-disabled"):this.util.addClass(this.context.element.wysiwyg,"se-disabled")},_offCellMultiSelect:function(e){e.stopPropagation();const t=this.plugins.table;t._shift?t._initBind&&(this._wd.removeEventListener("touchmove",t._initBind),t._initBind=null):(t._removeEvents.call(this),t._toggleEditor.call(this,!0)),t._fixedCell&&t._selectedTable&&(t.setActiveButton.call(this,t._fixedCell,t._selectedCell),t.call_controller_tableEdit.call(this,t._selectedCell||t._fixedCell),t._selectedCells=t._selectedTable.querySelectorAll(".se-table-selected-cell"),t._selectedCell&&t._fixedCell&&this.focusEdge(t._selectedCell),t._shift||(t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null))},_onCellMultiSelect:function(e){this._antiBlur=!0;const t=this.plugins.table,n=this.util.getParentElement(e.target,this.util.isCell);if(t._shift)n===t._fixedCell?t._toggleEditor.call(this,!0):t._toggleEditor.call(this,!1);else if(!t._ref){if(n===t._fixedCell)return;t._toggleEditor.call(this,!1)}n&&n!==t._selectedCell&&t._fixedCellName===n.nodeName&&t._selectedTable===this.util.getParentElement(n,"TABLE")&&(t._selectedCell=n,t._setMultiCells.call(this,t._fixedCell,n))},_setMultiCells:function(e,t){const n=this.plugins.table,i=n._selectedTable.rows,l=this.util,s=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let e=0,t=s.length;e0)for(let e,t=0;td||(u>=e.index?(s+=e.cs,u+=e.cs,e.rs-=1,e.row=d+1,e.rs<1&&(a.splice(t,1),t--)):p===m-1&&(e.rs-=1,e.row=d+1,e.rs<1&&(a.splice(t,1),t--)));if(o){if(i!==e&&i!==t||(c.cs=null!==c.cs&&c.csu+h?c.ce:u+h,c.rs=null!==c.rs&&c.rsd+g?c.re:d+g,c._i+=1),2===c._i){o=!1,a=[],r=[],d=-1;break}}else if(l.getOverlapRangeAtIndex(c.cs,c.ce,u,u+h)&&l.getOverlapRangeAtIndex(c.rs,c.re,d,d+g)){const e=c.csu+h?c.ce:u+h,n=c.rsd+g?c.re:d+g;if(c.cs!==e||c.ce!==t||c.rs!==n||c.re!==s){c.cs=e,c.ce=t,c.rs=n,c.re=s,d=-1,a=[],r=[];break}l.addClass(i,"se-table-selected-cell")}g>0&&r.push({index:u,cs:h+1,rs:g,row:-1}),s+=i.colSpan-1}a=a.concat(r).sort((function(e,t){return e.index-t.index})),r=[]}},_removeEvents:function(){const e=this.plugins.table;e._initBind&&(this._wd.removeEventListener("touchmove",e._initBind),e._initBind=null),e._bindOnSelect&&(this._wd.removeEventListener("mousedown",e._bindOnSelect),this._wd.removeEventListener("mousemove",e._bindOnSelect),e._bindOnSelect=null),e._bindOffSelect&&(this._wd.removeEventListener("mouseup",e._bindOffSelect),e._bindOffSelect=null),e._bindOffShift&&(this._wd.removeEventListener("keyup",e._bindOffShift),e._bindOffShift=null)},_initBind:null,onTableCellMultiSelect:function(e,t){const n=this.plugins.table;n._removeEvents.call(this),this.controllersOff(),n._shift=t,n._fixedCell=e,n._fixedCellName=e.nodeName,n._selectedTable=this.util.getParentElement(e,"TABLE");const i=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let e=0,t=i.length;e-1?(n=e.toLowerCase(),o="blockquote"===n?"range":"pre"===n?"free":"replace",r=/^h/.test(n)?n.match(/\d+/)[0]:"",a=t["tag_"+(r?"h":n)]+r,d="",c=""):(n=e.tag.toLowerCase(),o=e.command,a=e.name||n,d=e.class,c=d?' class="'+d+'"':""),s+='
  • ";return s+="",n.innerHTML=s,n},active:function(e){let t=this.lang.toolbar.formats;const n=this.context.formatBlock.targetText,i=this.context.formatBlock.targetTooltip;if(e){if(this.util.isFormatElement(e)){const l=this.context.formatBlock._formatList,s=e.nodeName.toLowerCase(),o=(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let e,n=0,i=l.length;n=0;u--)if(i=p[u],i!==(p[u+1]?p[u+1].parentNode:null)){if(d=a.isComponent(i),s=d?"":i.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),o=a.getParentElement(i,(function(e){return e.parentNode===t})),(t!==i.parentNode||d)&&(a.isFormatElement(t)?(t.parentNode.insertBefore(n,t.nextSibling),t=t.parentNode):(t.insertBefore(n,o?o.nextSibling:null),t=i.parentNode),r=n.nextSibling,r&&n.nodeName===r.nodeName&&a.isSameAttributes(n,r)&&(n.innerHTML+="
    "+r.innerHTML,a.removeItem(r)),n=l.cloneNode(!1),h=!0),c=n.innerHTML,n.innerHTML=(h||!s||!c||/
    $/i.test(s)?s:s+"
    ")+c,0===u){t.insertBefore(n,i),r=i.nextSibling,r&&n.nodeName===r.nodeName&&a.isSameAttributes(n,r)&&(n.innerHTML+="
    "+r.innerHTML,a.removeItem(r));const e=n.previousSibling;e&&n.nodeName===e.nodeName&&a.isSameAttributes(n,e)&&(e.innerHTML+="
    "+n.innerHTML,a.removeItem(n))}d||a.removeItem(i),s&&(h=!1)}this.setRange(i,0,i,0)}else{for(let e,t,n=0,o=p.length;n('+t.toolbar.default+")";for(let e,t=0,n=i.length;t";return l+="",n.innerHTML=l,n},on:function(){const e=this.context.lineHeight,t=e._sizeList,n=this.util.getFormatElement(this.getSelectionNode()).style.lineHeight+"";if(n!==e.currentSize){for(let e=0,i=t.length;e"}return s+="",t.innerHTML=s,t},on:function(){const e=this.context.paragraphStyle._classList,t=this.util.getFormatElement(this.getSelectionNode());for(let n=0,i=e.length;n"}return l+="",t.innerHTML=l,t},on:function(){const e=this.util,t=this.context.textStyle._styleList,n=this.getSelectionNode();for(let i,l,s,o=0,a=t.length;o'+this.icons.cancel+''+t.dialogBox.imageBox.title+'
    ';if(e.imageFileInput&&(i+='
    "),e.imageUrlInput&&(i+='
    '),i+='
    ',e.imageResizing){const n=e.imageSizeOnlyPercentage,l=n?' style="display: none !important;"':"",s=e.imageHeightShow?"":' style="display: none !important;"';i+='
    ',n||!e.imageHeightShow?i+='
    ":i+='
    ",i+=' '+t.dialogBox.proportion+'
    "}return i+='
    ",n.innerHTML=i,n},_fileInputChange:function(){this.imgInputFile.value?this.imgUrlFile.setAttribute("disabled",!0):this.imgUrlFile.removeAttribute("disabled")},_removeSelectedFiles:function(e,t){e.value="",t&&t.removeAttribute("disabled")},open:function(){this.plugins.dialog.open.call(this,"image","image"===this.currentControllerName)},openTab:function(e){const t=this.context.image.modal,n="init"===e?t.querySelector("._se_tab_link"):e.target;if(!/^BUTTON$/i.test(n.tagName))return!1;const i=n.getAttribute("data-tab-link");let l,s,o;for(s=t.getElementsByClassName("_se_tab_content"),l=0;l0){let t=0;const n=[];for(let i=0,l=e.length;i0){let e=0;const n=this.context.image._imagesInfo;for(let t=0,i=n.length;ti){const n="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+i/1e3+"KB";return this._imageUploadError(n,{limitSize:i,currentSize:e,uploadSize:t})&&this.functions.noticeOpen(n),void this.closeLoading()}}const l=this.context.image;l._uploadFileLength=n.length;const s=this.context.option.imageUploadUrl,o=this.context.option.imageUploadHeader,a=this.context.dialog.updateModal?1:n.length,r={linkValue:l._linkValue,linkNewWindow:l.imgLinkNewWindowCheck.checked,inputWidth:l.inputX.value,inputHeight:l.inputY.value,align:l._align,isUpdate:this.context.dialog.updateModal,currentImage:l._element};if(!this._imageUploadBefore(n,r))return;if("string"==typeof s&&s.length>0){const e=new FormData;for(let t=0;t0)for(let e in o)l._xmlHttp.setRequestHeader(e,o[e]);l._xmlHttp.send(e)}else for(let e=0;e0){const i=this.util.createElement("A");return i.href=/^https?:\/\//.test(t)?t:"http://"+t,i.target=n?"_blank":"",i.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t),i.appendChild(e),i}return e},setInputSize:function(e,t){t&&32===t.keyCode?t.preventDefault():this.plugins.resizing._module_setInputSize.call(this,this.context.image,e)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.image)},submit:function(e){const t=this.context.image,n=this.plugins.image;this.showLoading(),e.preventDefault(),e.stopPropagation(),t._linkValue=t.imgLink.value,t._altText=t.altText.value,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked,t._resizing&&(t._proportionChecked=t.proportion.checked);try{this.context.dialog.updateModal&&n.update_image.call(this,!1,!1,!1),t.imgInputFile&&t.imgInputFile.files.length>0?n.onRender_imgInput.call(this):t.imgUrlFile&&t.imgUrlFile.value.trim().length>0?n.onRender_imgUrl.call(this):this.closeLoading()}catch(e){throw this.closeLoading(),Error('[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},setImagesInfo:function(e,t){const n=this.context.resizing._resize_plugin;this.context.resizing._resize_plugin="image";const i=this.context.image._imagesInfo;let l=e.getAttribute("data-index"),s=null,o="";if(!l||this._componentsInfoInit)o="create",l=this.context.image._imageIndex++,e.setAttribute("data-index",l),e.setAttribute("data-file-name",t.name),e.setAttribute("data-file-size",t.size),s={src:e.src,index:1*l,name:t.name,size:t.size},i.push(s);else{o="update",l*=1;for(let e=0,t=i.length;e-1||(n.splice(t,1),this._imageUpload(null,e,"delete",null,0),t--);this.context.resizing._resize_plugin=i},resetComponentInfo:function(){this.context.image._imagesInfo=[],this.context.image._imageIndex=0},create_image:function(e,t,n,i,l,s,o){const a=this.context.image;this.context.resizing._resize_plugin="image";let r=this.util.createElement("IMG");r.src=e,r.alt=a._altText,r=this.plugins.image.onRender_link.call(this,r,t,n),r.setAttribute("data-rotate","0"),a._resizing&&r.setAttribute("data-proportion",a._proportionChecked);const c=this.plugins.resizing.set_cover.call(this,r),d=this.plugins.resizing.set_container.call(this,c,"se-image-container");a._captionChecked&&(a._caption=this.plugins.resizing.create_caption.call(this),a._caption.setAttribute("contenteditable",!1),c.appendChild(a._caption)),a._element=r,a._cover=c,a._container=d,this.plugins.image.applySize.call(this,i,l),this.plugins.image.setAlign.call(this,s,r,c,d),this.insertComponent(d,!0),this.plugins.image.setImagesInfo.call(this,r,o||{name:r.getAttribute("data-file-name")||r.src.split("/").pop(),size:r.getAttribute("data-file-size")||0}),this.context.resizing._resize_plugin=""},update_image:function(e,t,n){const i=this.context.image,l=i._linkValue;let s,o=i._element,a=i._cover,r=i._container,c=!1;null===a&&(c=!0,o=i._element.cloneNode(!0),a=this.plugins.resizing.set_cover.call(this,o)),null===r?(a=a.cloneNode(!0),o=a.querySelector("img"),c=!0,r=this.plugins.resizing.set_container.call(this,a,"se-image-container")):c&&(r.innerHTML="",r.appendChild(a));const d=this.util.isNumber(i.inputX.value)?i.inputX.value+i.sizeUnit:i.inputX.value,u=this.util.isNumber(i.inputY.value)?i.inputY.value+i.sizeUnit:i.inputY.value;if(s=/%$/.test(o.style.width)?d!==r.style.width||u!==r.style.height:d!==o.style.width||u!==o.style.height,o.alt=i._altText,i._captionChecked?i._caption||(i._caption=this.plugins.resizing.create_caption.call(this),a.appendChild(i._caption)):i._caption&&(this.util.removeItem(i._caption),i._caption=null),l.trim().length>0)if(null!==i._linkElement&&a.contains(i._linkElement))i._linkElement.href=l,i._linkElement.target=i.imgLinkNewWindowCheck.checked?"_blank":"",o.setAttribute("data-image-link",l);else{let e=this.plugins.image.onRender_link.call(this,o,l,this.context.image.imgLinkNewWindowCheck.checked);a.insertBefore(e,i._caption)}else if(null!==i._linkElement){const e=o;e.setAttribute("data-image-link","");let t=e.cloneNode(!0);a.removeChild(i._linkElement),a.insertBefore(t,i._caption),o=t}if(c){const e=this.util.isRangeFormatElement(i._element.parentNode)||this.util.isWysiwygDiv(i._element.parentNode)?i._element:/^A$/i.test(i._element.parentNode.nodeName)?i._element.parentNode:this.util.getFormatElement(i._element)||i._element;e.parentNode.replaceChild(r,e),o=r.querySelector("img"),i._element=o,i._cover=a,i._container=r}!i._onlyPercentage&&s&&!e&&(/\d+/.test(o.style.height)||this.context.resizing._rotateVertical&&i._captionChecked)&&(/%$/.test(i.inputX.value)||/%$/.test(i.inputY.value)?this.plugins.resizing.resetTransform.call(this,o):this.plugins.resizing.setTransformSize.call(this,o,this.util.getNumber(i.inputX.value,0),this.util.getNumber(i.inputY.value,0)));if(i._resizing&&(o.setAttribute("data-proportion",i._proportionChecked),s&&this.plugins.image.applySize.call(this)),this.plugins.image.setAlign.call(this,null,o,null,null),e&&this.plugins.image.setImagesInfo.call(this,o,{name:o.getAttribute("data-file-name")||o.src.split("/").pop(),size:o.getAttribute("data-file-size")||0}),t){this.plugins.image.init.call(this);const e=this.plugins.resizing.call_controller_resize.call(this,o,"image");this.plugins.image.onModifyMode.call(this,o,e)}n||this.history.push(!1)},update_src:function(e,t,n){t.src=e,this._w.setTimeout(this.plugins.image.setImagesInfo.bind(this,t,n))},onModifyMode:function(e,t){if(!e)return;const n=this.context.image;n._linkElement=/^A$/i.test(e.parentNode.nodeName)?e.parentNode:null,n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._align=e.getAttribute("data-align")||"none",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin");i?(i=i.split(","),n._origin_w=i[0],n._origin_h=i[1]):t&&(n._origin_w=t.w,n._origin_h=t.h)},openModify:function(e){const t=this.context.image;t.imgUrlFile.value=t._element.src,t._altText=t.altText.value=t._element.alt,t._linkValue=t.imgLink.value=null===t._linkElement?"":t._linkElement.href,t.imgLinkNewWindowCheck.checked=t._linkElement&&"_blank"===t._linkElement.target,t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]').checked=!0,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.image),e||this.plugins.dialog.open.call(this,"image",!0)},on:function(e){const t=this.context.image;e?t.imgInputFile&&t.imgInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.context.option.imageWidth===t._defaultSizeX?"":this.context.option.imageWidth,t.inputY.value=t._origin_h=this.context.option.imageHeight===t._defaultSizeY?"":this.context.option.imageHeight,t.imgInputFile&&t.imgInputFile.setAttribute("multiple","multiple"))},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.image)},applySize:function(e,t){const n=this.context.image;return e||(e=n.inputX.value),t||(t=n.inputY.value),n._onlyPercentage&&e||/%$/.test(e)?(this.plugins.image.setPercentSize.call(this,e,t),!0):(e&&"auto"!==e||t&&"auto"!==t?this.plugins.image.setSize.call(this,e,t,!1):this.plugins.image.setAutoSize.call(this),!1)},setSize:function(e,t,n,i){const l=this.context.image,s=/^(rw|lw)$/.test(i),o=/^(th|bh)$/.test(i);this.plugins.image.cancelPercentAttr.call(this),o||(l._element.style.width=this.util.isNumber(e)?e+l.sizeUnit:e),s||(l._element.style.height=this.util.isNumber(t)?t+l.sizeUnit:/%$/.test(t)?"":t),"center"===l._align&&this.plugins.image.setAlign.call(this,null,null,null,null),n||l._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,l)},setAutoSize:function(){const e=this.context.image;this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="",e._element.style.width="",e._element.style.height="",e._cover.style.width="",e._cover.style.height="",this.plugins.image.setAlign.call(this,null,null,null,null),e._element.setAttribute("data-percentage","auto,auto"),this.plugins.resizing._module_saveCurrentSize.call(this,e)},setOriginSize:function(){const e=this.context.image;e._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this);const t=(e._element.getAttribute("data-origin")||"").split(","),n=t[0],i=t[1];t&&(e._onlyPercentage||/%$/.test(n)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.image.setPercentSize.call(this,n,i):this.plugins.image.setSize.call(this,n,i),this.plugins.resizing._module_saveCurrentSize.call(this,e))},setPercentSize:function(e,t){const n=this.context.image;t=!t||/%$/.test(t)||this.util.getNumber(t,0)?this.util.isNumber(t)?t+n.sizeUnit:t||"":this.util.isNumber(t)?t+"%":t;const i=/%$/.test(t);n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=i?t:"",n._element.style.width="100%",n._element.style.height=i?"":t,n._element.style.maxWidth="","center"===n._align&&this.plugins.image.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing.setCaptionPosition.call(this,n._element),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.image;e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.image._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),"center"===e._align&&this.plugins.image.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const l=this.context.image;e||(e=l._align),t||(t=l._element),n||(n=l._cover),i||(i=l._container),n.style.margin=e&&"none"!==e?"auto":"0",/%$/.test(t.style.width)&&"center"===e?(i.style.minWidth="100%",n.style.width=i.style.width):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width&&"auto"!==t.style.width?t.style.width||"100%":""),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,l._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},resetAlign:function(){const e=this.context.image;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",this.util.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.image._element,n=this.util.getParentElement(t,this.util.isMediaComponent)||t,i=1*t.getAttribute("data-index");let l=n.previousElementSibling||n.nextElementSibling;const s=n.parentNode;if(this.util.removeItem(n),this.plugins.image.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,(function(e){return 0===e.childNodes.length}),null),this.focusEdge(l),i>=0){const e=this.context.image._imagesInfo;for(let t=0,n=e.length;t'+this.icons.cancel+''+t.dialogBox.videoBox.title+'
    ';if(e.videoResizing){const n=e.videoRatioList||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285}],l=e.videoRatio,s=e.videoSizeOnlyPercentage,o=s?' style="display: none !important;"':"",a=e.videoHeightShow?"":' style="display: none !important;"',r=e.videoRatioShow?"":' style="display: none !important;"',c=s||e.videoHeightShow||e.videoRatioShow?"":' style="display: none !important;"';i+='
    "}return i+='
    ",n.innerHTML=i,n},open:function(){this.plugins.dialog.open.call(this,"video","video"===this.currentControllerName)},setVideoRatio:function(e){const t=this.context.video,n=e.target.options[e.target.selectedIndex].value;t._defaultSizeY=t._videoRatio=n?100*n+"%":t._defaultSizeY,t.inputY.placeholder=n?100*n+"%":"",t.inputY.value=""},setInputSize:function(e,t){if(t&&32===t.keyCode)return void t.preventDefault();const n=this.context.video;this.plugins.resizing._module_setInputSize.call(this,n,e),"y"===e&&this.plugins.video.setVideoRatioSelect.call(this,t.target.value||n._defaultRatio)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.video)},submitAction:function(){if(0===this.context.video.focusElement.value.trim().length)return!1;this.context.resizing._resize_plugin="video";const e=this.context.video;let t=null,n=null,i=null,l=e.focusElement.value.trim();if(e._align=e.modal.querySelector('input[name="suneditor_video_radio"]:checked').value,/^$/.test(l))t=(new this._w.DOMParser).parseFromString(l,"text/html").querySelector("iframe");else{if(t=this.util.createElement("IFRAME"),/youtu\.?be/.test(l)&&(/^http/.test(l)||(l="https://"+l),l=l.replace("watch?v=",""),/^\/\/.+\/embed\//.test(l)||(l=l.replace(l.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),e._youtubeQuery.length>0))if(/\?/.test(l)){const t=l.split("?");l=t[0]+"?"+e._youtubeQuery+"&"+t[1]}else l+="?"+e._youtubeQuery;t.src=l}let s=!1;this.context.dialog.updateModal?(e._element.src!==t.src&&(e._element.src=t.src,s=!0),i=e._container,n=this.util.getParentElement(e._element,"FIGURE"),t=e._element):(s=!0,t.frameBorder="0",t.allowFullscreen=!0,e._element=t,n=this.plugins.resizing.set_cover.call(this,t),i=this.plugins.resizing.set_container.call(this,n,"se-video-container")),e._cover=n,e._container=i;const o=this.plugins.resizing._module_getSizeX.call(this,e)!==(e.inputX.value||e._defaultSizeX)||this.plugins.resizing._module_getSizeY.call(this,e)!==(e.inputY.value||e._videoRatio),a=!this.context.dialog.updateModal||o;e._resizing&&(this.context.video._proportionChecked=e.proportion.checked,t.setAttribute("data-proportion",e._proportionChecked));let r=!1;a&&(r=this.plugins.video.applySize.call(this)),r&&"center"===e._align||this.plugins.video.setAlign.call(this,null,t,n,i),this.context.dialog.updateModal?e._resizing&&this.context.resizing._rotateVertical&&a&&this.plugins.resizing.setTransformSize.call(this,t,null,null):this.insertComponent(i,!1),s&&this.plugins.video.setVideosInfo.call(this,t),this.context.resizing._resize_plugin="",this.context.dialog.updateModal&&this.history.push(!1)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();try{this.plugins.video.submitAction.call(this)}finally{this.plugins.dialog.close.call(this),this.closeLoading()}return this.focus(),!1},_update_videoCover:function(e){if(!e)return;const t=this.context.video;e.frameBorder="0",e.allowFullscreen=!0;const n=this.util.getParentElement(e,this.util.isMediaComponent)||this.util.getParentElement(e,function(e){return this.isWysiwygDiv(e.parentNode)}.bind(this.util));t._element=e=e.cloneNode(!1);const i=t._cover=this.plugins.resizing.set_cover.call(this,e),l=t._container=this.plugins.resizing.set_container.call(this,i,"se-video-container"),s=n.querySelector("figcaption");let o=null;s&&(o=this.util.createElement("DIV"),o.innerHTML=s.innerHTML,this.util.removeItem(s));const a=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.plugins.video.applySize.call(this,a[0]||this.context.option.videoWidth,a[1]||this.context.option.videoHeight),n.parentNode.replaceChild(l,n),o&&n.parentNode.insertBefore(o,l.nextElementSibling),this.plugins.video.setVideosInfo.call(this,e)},onModifyMode:function(e,t){const n=this.context.video;n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._align=e.getAttribute("data-align")||"none",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin");i?(i=i.split(","),n._origin_w=i[0],n._origin_h=i[1]):t&&(n._origin_w=t.w,n._origin_h=t.h)},openModify:function(e){const t=this.context.video;if(t.focusElement.value=t._element.src,t.modal.querySelector('input[name="suneditor_video_radio"][value="'+t._align+'"]').checked=!0,t._resizing){this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.video);const e=t._videoRatio=this.plugins.resizing._module_getSizeY.call(this,t);this.plugins.video.setVideoRatioSelect.call(this,e)||(t.inputY.value=t._onlyPercentage?this.util.getNumber(e,2):e)}e||this.plugins.dialog.open.call(this,"video",!0)},on:function(e){const t=this.context.video;e||(t.inputX.value=t._origin_w=this.context.option.videoWidth===t._defaultSizeX?"":this.context.option.videoWidth,t.inputY.value=t._origin_h=this.context.option.videoHeight===t._defaultSizeY?"":this.context.option.videoHeight,t.proportion.disabled=!0),t._resizing&&this.plugins.video.setVideoRatioSelect.call(this,t._origin_h||t._defaultRatio)},setVideoRatioSelect:function(e){let t=!1;const n=this.context.video,i=n.videoRatioOption.options;/%$/.test(e)||n._onlyPercentage?e=this.util.getNumber(e,2)/100+"":(!this.util.isNumber(e)||1*e>=1)&&(e=""),n.inputY.placeholder="";for(let l=0,s=i.length;l0?(l.push(this.context.video._videoIndex),t._update_videoCover.call(this,n)):!n.getAttribute("data-index")||s.indexOf(1*n.getAttribute("data-index"))<0?(l.push(this.context.video._videoIndex),n.removeAttribute("data-index"),t.setVideosInfo.call(this,n)):l.push(1*n.getAttribute("data-index"));for(let e,t=0;t-1||(n.splice(t,1),this._videoUpload(null,e,"delete",null,0),t--);this.context.resizing._resize_plugin=i},resetComponentInfo:function(){this.context.video._videosInfo=[],this.context.video._videoIndex=0},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.video)},applySize:function(e,t){const n=this.context.video;return e||(e=n.inputX.value),t||(t=n.inputY.value),n._onlyPercentage||/%$/.test(e)||!e?(this.plugins.video.setPercentSize.call(this,e||"100%",t||(/%$/.test(n._videoRatio)?n._videoRatio:n._defaultRatio)),!0):(e&&"auto"!==e||t&&"auto"!==t?this.plugins.video.setSize.call(this,e,t||n._videoRatio||n._defaultRatio,!1):this.plugins.video.setAutoSize.call(this),!1)},setSize:function(e,t,n,i){const l=this.context.video,s=/^(rw|lw)$/.test(i),o=/^(th|bh)$/.test(i);o||(e=this.util.getNumber(e,0)),s||(t=this.util.isNumber(t)?t+l.sizeUnit:t||""),o||(l._element.style.width=e?e+l.sizeUnit:""),s||(l._cover.style.paddingBottom=l._cover.style.height=t),o||/%$/.test(e)||(l._cover.style.width="",l._container.style.width=""),s||/%$/.test(t)?l._element.style.height="":l._element.style.height=t,n||l._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,l)},setAutoSize:function(){this.plugins.video.setPercentSize.call(this,100,this.context.video._defaultRatio)},setOriginSize:function(e){const t=this.context.video;t._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,t._element),this.plugins.video.cancelPercentAttr.call(this);const n=((e?t._element.getAttribute("data-size"):"")||t._element.getAttribute("data-origin")||"").split(",");if(n){const e=n[0],i=n[1];t._onlyPercentage||/%$/.test(e)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.video.setPercentSize.call(this,e,i):this.plugins.video.setSize.call(this,e,i),this.plugins.resizing._module_saveCurrentSize.call(this,t)}},setPercentSize:function(e,t){const n=this.context.video;t=!t||/%$/.test(t)||this.util.getNumber(t,0)?this.util.isNumber(t)?t+n.sizeUnit:t||n._defaultRatio:this.util.isNumber(t)?t+"%":t,n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=t,n._cover.style.paddingBottom=t,n._element.style.width="100%",n._element.style.height="100%",n._element.style.maxWidth="","center"===n._align&&this.plugins.video.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.video;e._cover.style.width="",e._cover.style.height="",e._cover.style.paddingBottom="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.video._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),"center"===e._align&&this.plugins.video.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const l=this.context.video;e||(e=l._align),t||(t=l._element),n||(n=l._cover),i||(i=l._container),n.style.margin=e&&"none"!==e?"auto":"0",/%$/.test(t.style.width)&&"center"===e?(i.style.minWidth="100%",n.style.width=i.style.width,n.style.height=n.style.height,n.style.paddingBottom=/%$/.test(n.style.height)?this.util.getNumber(this.util.getNumber(n.style.height,2)/100*this.util.getNumber(n.style.width,2),2)+"%":n.style.height):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width||"100%",n.style.paddingBottom=n.style.height),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,l._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},resetAlign:function(){const e=this.context.video;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",this.util.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.video._element,n=this.context.video._container,i=1*t.getAttribute("data-index");let l=n.previousElementSibling||n.nextElementSibling;const s=n.parentNode;if(this.util.removeItem(n),this.plugins.video.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,(function(e){return 0===e.childNodes.length}),null),this.focusEdge(l),i>=0){const e=this.context.video._videosInfo;for(let t=0,n=e.length;t'+this.icons.cancel+''+e.dialogBox.mathBox.title+'

    ",t},setController_MathButton:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-controller se-controller-link",t.innerHTML='
    ",t},open:function(){this.plugins.dialog.open.call(this,"math","math"===this.currentControllerName)},_renderMathExp:function(e){this.previewElement.innerHTML=this._renderer(e.target.value)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=function(){if(0===this.context.math.focusElement.value.trim().length)return!1;const e=this.context.math,t=e.focusElement.value,n=e.previewElement.querySelector(".katex");if(!n)return!1;if(n.setAttribute("contenteditable",!1),n.setAttribute("data-exp",t),n.setAttribute("data-font-size",e.fontSizeElement.value),n.style.fontSize=e.fontSizeElement.value,this.context.dialog.updateModal){const t=function(e,n){if(e.classList.contains(n))return e;const i=e.parentNode;return i!==document.body?i.classList.contains(n)?i:void t(i,n):void 0},i=t(e._mathExp,"katex");i.parentNode.replaceChild(n,i),this.setRange(n,0,n,1)}else{const e=this.getSelectedElements();if(e.length>1){const t=this.util.createElement(e[0].nodeName);t.appendChild(n),this.insertNode(t)}else this.insertNode(n);const t=this.util.createTextNode(this.util.zeroWidthSpace);n.parentNode.insertBefore(t,n.nextSibling),this.setRange(n,0,n,1)}return e.focusElement.value="",e.fontSizeElement.value="1em",e.previewElement.style.fontSize="1em",e.previewElement.innerHTML="",!0}.bind(this);try{t()&&(this.plugins.dialog.close.call(this),this.history.push(!1))}catch(e){this.plugins.dialog.close.call(this)}finally{this.closeLoading()}return!1},active:function(e){if(e){if(e.getAttribute("data-exp"))return this.controllerArray.indexOf(this.context.math.mathController)<0&&(this.setRange(e,0,e,1),this.plugins.math.call_controller.call(this,e)),!0}else this.controllerArray.indexOf(this.context.math.mathController)>-1&&this.controllersOff();return!1},on:function(e){if(e){const e=this.context.math;if(e._mathExp){const t=e._mathExp.getAttribute("data-exp"),n=e._mathExp.getAttribute("data-font-size")||"1em";this.context.dialog.updateModal=!0,e.focusElement.value=t,e.fontSizeElement.value=n,e.previewElement.innerHTML=e._renderer(t),e.previewElement.style.fontSize=n}}else this.plugins.math.init.call(this)},call_controller:function(e){this.context.math._mathExp=e;const t=this.context.math.mathController,n=this.util.getOffset(e,this.context.element.wysiwygFrame);t.style.top=n.top+e.offsetHeight+10+"px",t.style.left=n.left-this.context.element.wysiwygFrame.scrollLeft+"px",t.style.display="block";const i=this.context.element.wysiwygFrame.offsetWidth-(t.offsetLeft+t.offsetWidth);i<0?(t.style.left=t.offsetLeft+i+"px",t.firstElementChild.style.left=20-i+"px"):t.firstElementChild.style.left="20px",this.controllersOn(t,e,"math")},onClick_mathController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?(this.context.math.focusElement.value=this.context.math._mathExp.getAttribute("data-exp"),this.plugins.dialog.open.call(this,"math",!0)):(this.util.removeItem(this.context.math._mathExp),this.context.math._mathExp=null,this.focus(),this.history.push(!1)),this.controllersOff())},init:function(){const e=this.context.math;e.mathController.style.display="none",e._mathExp=null,e.focusElement.value="",e.previewElement.innerHTML=""}}},g={redo:'',undo:'',bold:'',underline:'',italic:'',strike:'',subscript:'',superscript:'',erase:'',indent:'',outdent:'',expansion:'',reduction:'',code_view:'',preview:'',print:'',template:'',line_height:'',paragraph_style:'',text_style:'',save:'',blockquote:'',arrow_down:'',align_justify:'',align_left:'',align_right:'',align_center:'',font_color:'',highlight_color:'',list_bullets:'',list_number:'',table:'',horizontal_rule:'',show_blocks:'',cancel:'',image:'',video:'',link:'',math:'',unlink:'',table_header:'',merge_cell:'',split_cell:'',caption:'',edit:'',delete:'',modify:'',revert:'',auto_size:'',insert_row_below:'',insert_row_above:'',insert_column_left:'',insert_column_right:'',delete_row:'',delete_column:'',fixed_column_width:'',rotate_left:'',rotate_right:'',mirror_horizontal:'',mirror_vertical:'',checked:'',line_break:'',attachment:'',map:'',magic_stick:'',empty_file:'',more_horizontal:'',more_vertical:''},p=n("P6u4"),m=n.n(p);const f={_d:document,_w:window,isIE:null!==window.navigator.userAgent.match(/(MSIE|Trident.*rv[ :])([0-9]+)/),isIE_Edge:null!==window.navigator.userAgent.match(/(MSIE|Trident.*rv[ :])([0-9]+)/)||window.navigator.appVersion.indexOf("Edge")>-1,_tagConvertor:function(e){const t={b:"strong",i:"em",ins:"u",strike:"del",s:"del"};return e.replace(/(<\/?)(b|strong|i|em|ins|u|s|strike|del)\b\s*(?:[^>^<]+)?\s*(?=>)/gi,(function(e,n,i){return n+("string"==typeof t[i]?t[i]:i)}))},_HTMLConvertor:function(e){const t={"&":"&"," ":" ","'":""","<":"<",">":">"};return e.replace(/&|\u00A0|'|<|>/g,(function(e){return"string"==typeof t[e]?t[e]:e}))},zeroWidthSpace:"​",zeroWidthRegExp:new RegExp(String.fromCharCode(8203),"g"),onlyZeroWidthRegExp:new RegExp("^"+String.fromCharCode(8203)+"+$"),onlyZeroWidthSpace:function(e){return"string"!=typeof e&&(e=e.textContent),""===e||this.onlyZeroWidthRegExp.test(e)},getXMLHttpRequest:function(){if(!this._w.ActiveXObject)return this._w.XMLHttpRequest?new XMLHttpRequest:null;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return null}}},createElement:function(e){return this._d.createElement(e)},createTextNode:function(e){return this._d.createTextNode(e||"")},getIncludePath:function(e,t){let n="";const i=[],l="js"===t?"script":"link",s="js"===t?"src":"href";let o="(?:";for(let t=0,n=e.length;t0?i[0][s]:""),-1===n.indexOf(":/")&&"//"!==n.slice(0,2)&&(n=0===n.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+n:location.href.match(/^[^\?]*\/(?:)/)[0]+n),!n)throw"[SUNEDITOR.util.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (name: +"+name+", extension: "+t+")";return n},getPageStyle:function(e){let t="";const n=(e||this._d).styleSheets;for(let e,i=0,l=n.length;i-1||(i+=n[e].name+'="'+n[e].value+'" ');return i},getByteLength:function(e){const t=this._w.encodeURIComponent;let n,i;return this.isIE_Edge?(i=this._w.unescape(t(e.toString())).length,n=0,null!==t(e.toString()).match(/(%0A|%0D)/gi)&&(n=t(e.toString()).match(/(%0A|%0D)/gi).length),i+n):(i=new this._w.TextEncoder("utf-8").encode(e.toString()).length,n=0,null!==t(e.toString()).match(/(%0A|%0D)/gi)&&(n=t(e.toString()).match(/(%0A|%0D)/gi).length),i+n)},isWysiwygDiv:function(e){return!(!e||1!==e.nodeType||!this.hasClass(e,"se-wrapper-wysiwyg")&&!/^BODY$/i.test(e.nodeName))},isTextStyleElement:function(e){return e&&3!==e.nodeType&&/^(strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label)$/i.test(e.nodeName)},isFormatElement:function(e){return e&&1===e.nodeType&&(/^(P|DIV|H[1-6]|PRE|LI|TD|TH)$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__replace_.+(\\s|$)|(\\s|^)__se__format__free_.+(\\s|$)"))&&!this.isComponent(e)&&!this.isWysiwygDiv(e)},isRangeFormatElement:function(e){return e&&1===e.nodeType&&(/^(BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__range_.+(\\s|$)"))},isFreeFormatElement:function(e){return e&&1===e.nodeType&&(/^PRE$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__free_.+(\\s|$)"))&&!this.isComponent(e)&&!this.isWysiwygDiv(e)},isComponent:function(e){return e&&(/se-component/.test(e.className)||/^(TABLE|HR)$/.test(e.nodeName))},isMediaComponent:function(e){return e&&/se-component/.test(e.className)},getFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isRangeFormatElement(e)&&e.firstElementChild,this.isFormatElement(e)&&t(e))return e;e=e.parentNode}return null},getRangeFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isRangeFormatElement(e)&&!/^(THEAD|TBODY|TR)$/i.test(e.nodeName)&&t(e))return e;e=e.parentNode}return null},getFreeFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isFreeFormatElement(e)&&t(e))return e;e=e.parentNode}return null},copyTagAttributes:function(e,t){t.style.cssText&&(e.style.cssText+=t.style.cssText);const n=t.classList;for(let t=0,i=n.length;t0&&!this.isBreak(e);)e=e.firstChild;for(;t&&1===t.nodeType&&t.childNodes.length>0&&!this.isBreak(t);)t=t.lastChild;return{sc:e,ec:t||e}}},getOffset:function(e,t){let n=0,i=0,l=3===e.nodeType?e.parentElement:e;const s=this.getParentElement(e,this.isWysiwygDiv.bind(this));for(;l&&!this.hasClass(l,"se-container")&&l!==s;)n+=l.offsetLeft,i+=l.offsetTop,l=l.offsetParent;const o=t&&/iframe/i.test(t.nodeName);return{left:n+(o?t.parentElement.offsetLeft:0),top:i-s.scrollTop+(o?t.parentElement.offsetTop:0)}},getOverlapRangeAtIndex:function(e,t,n,i){if(e<=i?tn)return 0;const l=(e>n?e:n)-(t0?" ":"")+t)},removeClass:function(e,t){if(!e)return;const n=new this._w.RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").trim(),e.className.trim()||e.removeAttribute("class")},toggleClass:function(e,t){if(!e)return;const n=new this._w.RegExp("(\\s|^)"+t+"(\\s|$)");n.test(e.className)?e.className=e.className.replace(n," ").trim():e.className+=" "+t,e.className.trim()||e.removeAttribute("class")},toggleDisabledButtons:function(e,t){for(let n=0,i=t.length;n=0){e.splitText(t);const n=this.getNodeFromPath([a+1],i);this.onlyZeroWidthSpace(n)&&(n.data=this.zeroWidthSpace)}}else 1===e.nodeType&&(e.previousSibling?e=e.previousSibling:this.getElementDepth(e)===n&&(r=!1));let c=e;for(;this.getElementDepth(c)>n;)for(a=this.getPositionIndex(c)+1,c=c.parentNode,o=l,l=c.cloneNode(!1),s=c.childNodes,o&&(this.isListCell(l)&&this.isList(o)&&o.firstElementChild&&(l.innerHTML=o.firstElementChild.innerHTML,f.removeItem(o.firstElementChild),o.children.length>0&&l.appendChild(o)),l.appendChild(o));s[a];)l.appendChild(s[a]);c.childNodes.length<=1&&(!c.firstChild||0===c.firstChild.textContent.length)&&(c.innerHTML="
    ");const d=c.parentNode;return r&&(c=c.nextSibling),l?(this.mergeSameTags(l,null,!1),this.mergeNestedTags(l,function(e){return this.isList(e)}.bind(this)),l.childNodes.length>0?d.insertBefore(l,c):l=c,0===i.childNodes.length&&this.removeItem(i),l):c},mergeSameTags:function(e,t,n){const i=this;let l=null;return t&&t.length>0&&(l=this._w.Array.apply(null,new this._w.Array(t.length)).map(this._w.Number.prototype.valueOf,0)),function e(s,o,a){const r=s.childNodes;for(let c,d,u=0,h=r.length;u=0;){if(i.getArrayIndex(l.childNodes,n)!==e[a]){r=!1;break}n=c.parentNode,l=n.parentNode,a--}r&&(e.splice(o,1),e[o]=u)}}i.copyTagAttributes(c,s),s.parentNode.insertBefore(c,s),i.removeItem(s)}if(!d){1===c.nodeType&&e(c,o+1,u);break}if(c.nodeName===d.nodeName&&i.isSameAttributes(c,d)&&c.href===d.href){const e=c.childNodes;let n=0;for(let t=0,i=e.length;t0&&n++;const s=c.lastChild,r=d.firstChild;let h=0;if(s&&r){const e=3===s.nodeType&&3===r.nodeType;h=s.textContent.length;let i=s.previousSibling;for(;i&&3===i.nodeType;)h+=i.textContent.length,i=i.previousSibling;if(n>0&&3===s.nodeType&&3===r.nodeType&&(s.textContent.length>0||r.textContent.length>0)&&n--,t){let i=null;for(let c in t)if(i=t[c],i&&i[o]>u){if(o>0&&i[o-1]!==a)continue;i[o]-=1,i[o+1]>=0&&i[o]===u&&(i[o+1]+=n,e&&s&&3===s.nodeType&&r&&3===r.nodeType&&(l[c]+=h))}}}if(3===c.nodeType){if(h=c.textContent.length,c.textContent+=d.textContent,t){let e=null;for(let i in t)if(e=t[i],e&&e[o]>u){if(o>0&&e[o-1]!==a)continue;e[o]-=1,e[o+1]>=0&&e[o]===u&&(e[o+1]+=n,l[i]+=h)}}}else c.innerHTML+=d.innerHTML;i.removeItem(d),u--}else 1===c.nodeType&&e(c,o+1,u)}}(e,0,0),l},mergeNestedTags:function(e,t){"string"==typeof t?t=function(e){return this.test(e.tagName)}.bind(new this._w.RegExp("^("+(t||".+")+")$","i")):"function"!=typeof t&&(t=function(){return!0}),function e(n){let i=n.children;if(1===i.length&&i[0].nodeName===n.nodeName&&t(n)){const e=i[0];for(i=e.children;i[0];)n.appendChild(i[0]);n.removeChild(e)}for(let t=0,i=n.children.length;t")},htmlRemoveWhiteSpace:function(e){return e?e.trim().replace(/<\/?(?!strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label)[^>^<]+>\s+(?=<)/gi,(function(e){return e.trim()})):""},sortByDepth:function(e,t){const n=t?1:-1,i=-1*n;e.sort(function(e,t){return this.isListCell(e)&&this.isListCell(t)?(e=this.getElementDepth(e))>(t=this.getElementDepth(t))?n:e'+this.icons.line_break+"";const y=n.createElement("DIV");return y.className="se-resizing-back",r.appendChild(u),r.appendChild(g),h&&r.appendChild(h),l.appendChild(s.element),l.appendChild(a),l.appendChild(r),l.appendChild(y),l.appendChild(b),l.appendChild(v),p&&l.appendChild(p),i.appendChild(l),g=this._checkCodeMirror(t,g),{constructed:{_top:i,_relative:l,_toolBar:s.element,_editorArea:r,_wysiwygArea:u,_codeArea:g,_placeholder:h,_resizingBar:p,_navigation:m,_charWrapper:f,_charCounter:_,_loading:b,_lineBreaker:v,_resizeBack:y,_stickyDummy:a,_arrow:o},options:t,plugins:s.plugins,pluginCallButtons:s.pluginCallButtons,_icons:this.icons}},_checkCodeMirror:function(e,t){if(e.codeMirror){const n=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!0},e.codeMirror.options||{}].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{});"auto"===e.height&&(n.viewportMargin=1/0,n.height="auto");const i=e.codeMirror.src.fromTextArea(t,n);i.display.wrapper.style.cssText=t.style.cssText,e.codeMirrorEditor=i,(t=i.display.wrapper).className+=" se-wrapper-code-mirror"}return t},_checkKatexMath:function(e){if(!e)throw Error('[SUNEDITOR.create.fail] To use the math button you need to add a "katex" object to the options.');const t=[{throwOnError:!1},e.options||{}].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{});e.options=t},_setOptions:function(e,t,n,i){this._initOptions(t.element.originElement,e);const l=t.element,s=l.relative,o=l.editorArea,a=!!e.buttonList||e.mode!==i.mode,r=!!e.plugins,c=this._createToolBar(document,a?e.buttonList:i.buttonList,r?e.plugins:n,e.lang);c.pluginCallButtons.math&&this._checkKatexMath(e.katex);const d=document.createElement("DIV");d.className="se-arrow",a&&(s.replaceChild(c.element,l.toolbar),l.toolbar=c.element,l._arrow=d);const u=this._initElements(e,l.topArea,a?c.element:l.toolbar,d),h=u.bottomBar,g=u.wysiwygFrame,p=u.placeholder;let m=u.codeView;return l.resizingBar&&s.removeChild(l.resizingBar),h.resizingBar&&s.appendChild(h.resizingBar),l.resizingBar=h.resizingBar,l.navigation=h.navigation,l.charWrapper=h.charWrapper,l.charCounter=h.charCounter,o.removeChild(l.wysiwygFrame),o.removeChild(l.code),o.appendChild(g),o.appendChild(m),l.placeholder&&o.removeChild(l.placeholder),p&&o.appendChild(p),m=this._checkCodeMirror(e,m),l.wysiwygFrame=g,l.code=m,l.placeholder=p,{callButtons:a?c.pluginCallButtons:null,plugins:a||r?c.plugins:null}},_initElements:function(e,t,n,i){t.style.width=e.width,t.style.minWidth=e.minWidth,t.style.maxWidth=e.maxWidth,t.style.display=e.display,"string"==typeof e.position&&(t.style.position=e.position),/inline/i.test(e.mode)?(n.className+=" se-toolbar-inline",n.style.width=e.toolbarWidth):/balloon/i.test(e.mode)&&(n.className+=" se-toolbar-balloon",n.style.width=e.toolbarWidth,n.appendChild(i));const l=document.createElement(e.iframe?"IFRAME":"DIV");if(l.className="se-wrapper-inner se-wrapper-wysiwyg",e.iframe){const t=function(){const t=e.iframeCSSFileName;let n="";for(let e,i=0,l=t.length;i'}return n}()+("auto"===e.height?"":"");l.allowFullscreen=!0,l.frameBorder=0,l.addEventListener("load",(function(){this.setAttribute("scrolling","auto"),this.contentDocument.head.innerHTML=''+t,this.contentDocument.body.className="sun-editor-editable",this.contentDocument.body.setAttribute("contenteditable",!0)}))}else l.setAttribute("contenteditable",!0),l.setAttribute("scrolling","auto"),l.className+=" sun-editor-editable";l.style.cssText=_._setDefaultOptionStyle(e);const s=document.createElement("TEXTAREA");s.className="se-wrapper-inner se-wrapper-code",s.style.display="none",s.style.height=e.height,s.style.minHeight=e.minHeight,s.style.maxHeight=e.maxHeight,"auto"===e.height&&(s.style.overflow="hidden");let o=null,a=null,r=null,c=null;if(e.resizingBar&&(o=document.createElement("DIV"),o.className="se-resizing-bar sun-editor-common",a=document.createElement("DIV"),a.className="se-navigation sun-editor-common",o.appendChild(a),e.charCounter)){if(r=document.createElement("DIV"),r.className="se-char-counter-wrapper",e.charCounterLabel){const t=document.createElement("SPAN");t.className="se-char-label",t.textContent=e.charCounterLabel,r.appendChild(t)}if(c=document.createElement("SPAN"),c.className="se-char-counter",c.textContent="0",r.appendChild(c),e.maxCharCount>0){const t=document.createElement("SPAN");t.textContent=" / "+e.maxCharCount,r.appendChild(t)}o.appendChild(r)}let d=null;return e.placeholder&&(d=document.createElement("SPAN"),d.className="se-placeholder",d.innerText=e.placeholder),{bottomBar:{resizingBar:o,navigation:a,charWrapper:r,charCounter:c},wysiwygFrame:l,codeView:s,placeholder:d}},_initOptions:function(e,t){t.lang=t.lang||m.a,t._defaultTagsWhitelist="string"==typeof t._defaultTagsWhitelist?t._defaultTagsWhitelist:"br|p|div|pre|blockquote|h[1-6]|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup",t._editorTagsWhitelist=t._defaultTagsWhitelist+("string"==typeof t.addTagsWhitelist&&t.addTagsWhitelist.length>0?"|"+t.addTagsWhitelist:""),t.pasteTagsWhitelist="string"==typeof t.pasteTagsWhitelist?t.pasteTagsWhitelist:t._editorTagsWhitelist,t.attributesWhitelist=t.attributesWhitelist&&"object"==typeof t.attributesWhitelist?t.attributesWhitelist:null,t.mode=t.mode||"classic",t.toolbarWidth=t.toolbarWidth?_.isNumber(t.toolbarWidth)?t.toolbarWidth+"px":t.toolbarWidth:"auto",t.stickyToolbar=/balloon/i.test(t.mode)?-1:void 0===t.stickyToolbar?0:/^\d+/.test(t.stickyToolbar)?_.getNumber(t.stickyToolbar,0):-1,t.iframe=t.fullPage||t.iframe,t.iframeCSSFileName=t.iframe?"string"==typeof t.iframeCSSFileName?[t.iframeCSSFileName]:t.iframeCSSFileName||["suneditor"]:null,t.codeMirror=t.codeMirror?t.codeMirror.src?t.codeMirror:{src:t.codeMirror}:null,t.display=t.display||("none"!==e.style.display&&e.style.display?e.style.display:"block"),t.popupDisplay=t.popupDisplay||"full",t.resizingBar=void 0===t.resizingBar?!/inline|balloon/i.test(t.mode):t.resizingBar,t.showPathLabel=!!t.resizingBar&&("boolean"!=typeof t.showPathLabel||t.showPathLabel),t.charCounter=t.maxCharCount>0||"boolean"==typeof t.charCounter&&t.charCounter,t.charCounterType="string"==typeof t.charCounterType?t.charCounterType:"char",t.charCounterLabel="string"==typeof t.charCounterLabel?t.charCounterLabel.trim():null,t.maxCharCount=_.isNumber(t.maxCharCount)&&t.maxCharCount>-1?1*t.maxCharCount:null,t.width=t.width?_.isNumber(t.width)?t.width+"px":t.width:e.clientWidth?e.clientWidth+"px":"100%",t.minWidth=(_.isNumber(t.minWidth)?t.minWidth+"px":t.minWidth)||"",t.maxWidth=(_.isNumber(t.maxWidth)?t.maxWidth+"px":t.maxWidth)||"",t.height=t.height?_.isNumber(t.height)?t.height+"px":t.height:e.clientHeight?e.clientHeight+"px":"auto",t.minHeight=(_.isNumber(t.minHeight)?t.minHeight+"px":t.minHeight)||"",t.maxHeight=(_.isNumber(t.maxHeight)?t.maxHeight+"px":t.maxHeight)||"",t.defaultStyle=_._setDefaultOptionStyle(t)+("string"==typeof t.defaultStyle?t.defaultStyle:""),t.font=t.font?t.font:null,t.fontSize=t.fontSize?t.fontSize:null,t.formats=t.formats?t.formats:null,t.colorList=t.colorList?t.colorList:null,t.lineHeights=t.lineHeights?t.lineHeights:null,t.paragraphStyles=t.paragraphStyles?t.paragraphStyles:null,t.textStyles=t.textStyles?t.textStyles:null,t.fontSizeUnit="string"==typeof t.fontSizeUnit&&t.fontSizeUnit.trim()||"px",t.imageResizing=void 0===t.imageResizing||t.imageResizing,t.imageHeightShow=void 0===t.imageHeightShow||!!t.imageHeightShow,t.imageWidth=t.imageWidth?_.isNumber(t.imageWidth)?t.imageWidth+"px":t.imageWidth:"auto",t.imageHeight=t.imageHeight?_.isNumber(t.imageHeight)?t.imageHeight+"px":t.imageHeight:"auto",t.imageSizeOnlyPercentage=!!t.imageSizeOnlyPercentage,t._imageSizeUnit=t.imageSizeOnlyPercentage?"%":"px",t.imageRotation=void 0!==t.imageRotation?t.imageRotation:!(t.imageSizeOnlyPercentage||!t.imageHeightShow),t.imageFileInput=void 0===t.imageFileInput||t.imageFileInput,t.imageUrlInput=void 0===t.imageUrlInput||!t.imageFileInput||t.imageUrlInput,t.imageUploadHeader=t.imageUploadHeader||null,t.imageUploadUrl=t.imageUploadUrl||null,t.imageUploadSizeLimit=/\d+/.test(t.imageUploadSizeLimit)?_.getNumber(t.imageUploadSizeLimit,0):null,t.videoResizing=void 0===t.videoResizing||t.videoResizing,t.videoHeightShow=void 0===t.videoHeightShow||!!t.videoHeightShow,t.videoRatioShow=void 0===t.videoRatioShow||!!t.videoRatioShow,t.videoWidth=t.videoWidth&&_.getNumber(t.videoWidth,0)?_.isNumber(t.videoWidth)?t.videoWidth+"px":t.videoWidth:"",t.videoHeight=t.videoHeight&&_.getNumber(t.videoHeight,0)?_.isNumber(t.videoHeight)?t.videoHeight+"px":t.videoHeight:"",t.videoSizeOnlyPercentage=!!t.videoSizeOnlyPercentage,t._videoSizeUnit=t.videoSizeOnlyPercentage?"%":"px",t.videoRotation=void 0!==t.videoRotation?t.videoRotation:!(t.videoSizeOnlyPercentage||!t.videoHeightShow),t.videoRatio=_.getNumber(t.videoRatio,4)||.5625,t.videoRatioList=t.videoRatioList?t.videoRatioList:null,t.youtubeQuery=(t.youtubeQuery||"").replace("?",""),t.callBackSave=t.callBackSave?t.callBackSave:null,t.templates=t.templates?t.templates:null,t.placeholder="string"==typeof t.placeholder?t.placeholder:null,t.katex=t.katex?t.katex.src?t.katex:{src:t.katex}:null,t.buttonList=t.buttonList||[["undo","redo"],["bold","underline","italic","strike","subscript","superscript"],["removeFormat"],["outdent","indent"],["fullScreen","showBlocks","codeView"],["preview","print"]],this.icons=t.icons&&"object"==typeof t.icons?[g,t.icons].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{}):g},_defaultButtons:function(e){const t=this.icons;return{bold:["_se_command_bold",e.toolbar.bold+" (CTRL+B)","STRONG","",t.bold],underline:["_se_command_underline",e.toolbar.underline+" (CTRL+U)","U","",t.underline],italic:["_se_command_italic",e.toolbar.italic+" (CTRL+I)","EM","",t.italic],strike:["_se_command_strike",e.toolbar.strike+" (CTRL+SHIFT+S)","DEL","",t.strike],subscript:["_se_command_subscript",e.toolbar.subscript,"SUB","",t.subscript],superscript:["_se_command_superscript",e.toolbar.superscript,"SUP","",t.superscript],removeFormat:["",e.toolbar.removeFormat,"removeFormat","",t.erase],indent:["_se_command_indent",e.toolbar.indent+" (CTRL+])","indent","",t.outdent],outdent:["_se_command_outdent",e.toolbar.outdent+" (CTRL+[)","outdent","",t.indent],fullScreen:["se-code-view-enabled se-resizing-enabled",e.toolbar.fullScreen,"fullScreen","",t.expansion],showBlocks:["",e.toolbar.showBlocks,"showBlocks","",t.show_blocks],codeView:["se-code-view-enabled se-resizing-enabled",e.toolbar.codeView,"codeView","",t.code_view],undo:["_se_command_undo se-resizing-enabled",e.toolbar.undo+" (CTRL+Z)","undo","",t.undo],redo:["_se_command_redo se-resizing-enabled",e.toolbar.redo+" (CTRL+Y / CTRL+SHIFT+Z)","redo","",t.redo],preview:["se-resizing-enabled",e.toolbar.preview,"preview","",t.preview],print:["se-resizing-enabled",e.toolbar.print,"print","",t.print],save:["_se_command_save se-resizing-enabled",e.toolbar.save,"save","",t.save],blockquote:["",e.toolbar.tag_blockquote,"blockquote","command",t.blockquote],font:["se-btn-select se-btn-tool-font",e.toolbar.font,"font","submenu",''+e.toolbar.font+""+t.arrow_down],formatBlock:["se-btn-select se-btn-tool-format",e.toolbar.formats,"formatBlock","submenu",''+e.toolbar.formats+""+t.arrow_down],fontSize:["se-btn-select se-btn-tool-size",e.toolbar.fontSize,"fontSize","submenu",''+e.toolbar.fontSize+""+t.arrow_down],fontColor:["",e.toolbar.fontColor,"fontColor","submenu",t.font_color],hiliteColor:["",e.toolbar.hiliteColor,"hiliteColor","submenu",t.highlight_color],align:["se-btn-align",e.toolbar.align,"align","submenu",t.align_left],list:["",e.toolbar.list,"list","submenu",t.list_number],horizontalRule:["btn_line",e.toolbar.horizontalRule,"horizontalRule","submenu",t.horizontal_rule],table:["",e.toolbar.table,"table","submenu",t.table],lineHeight:["",e.toolbar.lineHeight,"lineHeight","submenu",t.line_height],template:["",e.toolbar.template,"template","submenu",t.template],paragraphStyle:["",e.toolbar.paragraphStyle,"paragraphStyle","submenu",t.paragraph_style],textStyle:["",e.toolbar.textStyle,"textStyle","submenu",t.text_style],link:["",e.toolbar.link,"link","dialog",t.link],image:["",e.toolbar.image,"image","dialog",t.image],video:["",e.toolbar.video,"video","dialog",t.video],math:["",e.toolbar.math,"math","dialog",t.math]}},_createModuleGroup:function(e){const t=_.createElement("DIV");t.className="se-btn-module"+(e?"":" se-btn-module-border");const n=_.createElement("UL");return n.className="se-menu-list",t.appendChild(n),{div:t,ul:n}},_createButton:function(e,t,n,i,l,s){const o=_.createElement("LI"),a=_.createElement("BUTTON");return a.setAttribute("type","button"),a.setAttribute("class","se-btn"+(e?" "+e:"")+" se-tooltip"),a.setAttribute("data-command",n),a.setAttribute("data-display",i),l||(l='!'),l+=''+(t||n)+"",s&&a.setAttribute("disabled",!0),a.innerHTML=l,o.appendChild(a),{li:o,button:a}},_createToolBar:function(e,t,n,i){const l=e.createElement("DIV");l.className="se-toolbar-separator-vertical";const s=e.createElement("DIV");s.className="se-toolbar sun-editor-common";const o=this._defaultButtons(i),a={},r={};if(n){const e=n.length?n:Object.keys(n).map((function(e){return n[e]}));for(let t,n=0,i=e.length;n0&&u._getPageBottomSpace()0){for(let e=0;e":n),this.history.push(!0)},nativeFocus:function(){const t=r.getParentElement(this.getSelectionNode(),"figcaption");t?t.focus():e.element.wysiwyg.focus(),this._editorRange()},focus:function(){if("none"!==e.element.wysiwygFrame.style.display){if(l.iframe)this.nativeFocus();else try{const e=this.getRange();if(e.startContainer===e.endContainer&&r.isWysiwygDiv(e.startContainer)){const e=r.createElement("P"),t=r.createElement("BR");e.appendChild(t),this.setRange(t,0,t,0)}else this.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}catch(e){this.nativeFocus()}u._applyTagEffects(),d._isBalloon&&u._toggleToolbarBalloon()}},focusEdge:function(t){if(t||(t=e.element.wysiwyg.lastElementChild),r.isComponent(t)){const e=t.querySelector("IMG"),n=t.querySelector("IFRAME");e?this.selectComponent(e,"image"):n&&this.selectComponent(n,"video")}else t&&(t=r.getChildElement(t,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!0))?this.setRange(t,t.textContent.length,t,t.textContent.length):this.nativeFocus()},setRange:function(e,t,n,i){if(!e||!n)return;t>e.textContent.length&&(t=e.textContent.length),i>n.textContent.length&&(i=n.textContent.length);const s=this._wd.createRange();try{s.setStart(e,t),s.setEnd(n,i)}catch(e){this.nativeFocus()}const o=this.getSelection();o.removeAllRanges&&o.removeAllRanges(),o.addRange(s),this._editorRange(),l.iframe&&this.nativeFocus()},removeRange:function(){this._variable._range=null,this._variable._selectionNode=null,this.getSelection().removeAllRanges();const e=this.commandMap,t=this.activePlugins;for(let i in e)t.indexOf(i)>-1?n[i].active.call(d,null):e.OUTDENT&&/^OUTDENT$/i.test(i)?e.OUTDENT.setAttribute("disabled",!0):e.INDENT&&/^INDENT$/i.test(i)?e.INDENT.removeAttribute("disabled"):r.removeClass(e[i],"active")},getRange:function(){return this._variable._range||this._createDefaultRange()},getSelection:function(){return this._ww.getSelection()},getSelectionNode:function(){return this._variable._selectionNode&&!r.isWysiwygDiv(this._variable._selectionNode)||this._editorRange(),this._variable._selectionNode||e.element.wysiwyg.firstChild},_editorRange:function(){const e=this.getSelection();let t=null,n=null;t=e.rangeCount>0?e.getRangeAt(0):this._createDefaultRange(),this._variable._range=t,n=t.collapsed?t.commonAncestorContainer:e.extentNode||e.anchorNode,this._variable._selectionNode=n},_createDefaultRange:function(){e.element.wysiwyg.focus();const t=this._wd.createRange();return e.element.wysiwyg.firstChild||this.execCommand("formatBlock",!1,"P"),t.setStart(e.element.wysiwyg.firstChild,0),t.setEnd(e.element.wysiwyg.firstChild,0),t},_resetRangeToTextNode:function(){const t=this.getRange();let n,i,l,s=t.startContainer,o=t.startOffset,a=t.endContainer,c=t.endOffset;if(r.isFormatElement(s)&&(s=s.childNodes[o],o=0),r.isFormatElement(a)&&(a=a.childNodes[c],c=0),n=r.isWysiwygDiv(s)?e.element.wysiwyg.firstChild:s,i=o,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType;)n=n.childNodes[i]||n.nextElementSibling||n.nextSibling,i=0;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.getParentElement(n,r.isCell)?"DIV":"P"),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,e&&s===a&&(a=n,c=1)}}if(s=n,o=i,n=r.isWysiwygDiv(a)?e.element.wysiwyg.lastChild:a,i=c,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType&&(l=n.childNodes,0!==l.length);)n=l[i>0?i-1:i]||!/FIGURE/i.test(l[0].nodeName)?l[0]:n.previousElementSibling||n.previousSibling||s,i=i>0?n.textContent.length:i;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.isCell(e)?"DIV":"P"),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,i=1,e&&!n.previousSibling&&r.removeItem(a)}}a=n,c=i,this.setRange(s,o,a,c)},getSelectedElements:function(t){this._resetRangeToTextNode();let n=this.getRange();if(r.isWysiwygDiv(n.startContainer)){const t=e.element.wysiwyg.children;if(0===t.length)return null;this.setRange(t[0],0,t[t.length-1],t[t.length-1].textContent.trim().length),n=this.getRange()}const i=n.startContainer,l=n.endContainer,s=n.commonAncestorContainer,o=r.getListChildren(s,(function(e){return t?t(e):r.isFormatElement(e)}));if(r.isWysiwygDiv(s)||r.isRangeFormatElement(s)||o.unshift(r.getFormatElement(s,null)),i===l||1===o.length)return o;let a=r.getFormatElement(i,null),c=r.getFormatElement(l,null),d=null,u=null;const h=function(e){return!r.isTable(e)||/^TABLE$/i.test(e.nodeName)};let g=r.getRangeFormatElement(a,h),p=r.getRangeFormatElement(c,h);r.isTable(g)&&r.isListCell(g.parentNode)&&(g=g.parentNode),r.isTable(p)&&r.isListCell(p.parentNode)&&(p=p.parentNode);const m=g===p;for(let e,t=0,n=o.length;t=0;n--)if(i[n].contains(i[e])){i.splice(e,1),e--,t--;break}return i},isEdgePoint:function(e,t){return 0===t||!e.nodeValue&&1===t||t===e.nodeValue.length},showLoading:function(){e.element.loading.style.display="block"},closeLoading:function(){e.element.loading.style.display="none"},appendFormatTag:function(e,t){const n=r.getFormatElement(this.getSelectionNode(),null),i=t?"string"==typeof t?t:t.nodeName:r.isFormatElement(n)&&!r.isFreeFormatElement(n)?n.nodeName:"P",l=r.createElement(i);return l.innerHTML="
    ",(t&&"string"!=typeof t||!t&&r.isFormatElement(n))&&r.copyTagAttributes(l,t||n),r.isCell(e)?e.insertBefore(l,e.nextElementSibling):e.parentNode.insertBefore(l,e.nextElementSibling),l},insertComponent:function(e,t){const n=this.removeNode();let i=null,l=this.getSelectionNode(),s=r.getFormatElement(l,null);if(r.isListCell(s))if(/^HR$/i.test(e.nodeName)){const t=r.createElement("LI"),n=r.createTextNode(r.zeroWidthSpace);t.appendChild(e),t.appendChild(n),s.parentNode.insertBefore(t,s.nextElementSibling),this.setRange(n,1,n,1)}else this.insertNode(e,l===s?null:n.container.nextSibling),e.nextSibling||e.parentNode.appendChild(r.createElement("BR")),i=r.createElement("LI"),s.parentNode.insertBefore(i,s.nextElementSibling);else{if(this.getRange().collapsed&&(3===n.container.nodeType||r.isBreak(n.container))){const e=r.getParentElement(n.container,function(e){return this.isRangeFormatElement(e)}.bind(r));i=r.splitElement(n.container,n.offset,e?r.getElementDepth(e)+1:0),i&&(s=i.previousSibling)}this.insertNode(e,s),i||(i=this.appendFormatTag(e,r.isFormatElement(s)?s:null))}return i=r.getEdgeChildNodes(i,null).sc||i,this.setRange(i,0,i,0),t||this.history.push(1),i},selectComponent:function(e,t){if("image"===t){if(!d.plugins.image)return;d.removeRange(),d.callPlugin("image",(function(){const t=d.plugins.resizing.call_controller_resize.call(d,e,"image");d.plugins.image.onModifyMode.call(d,e,t),r.getParentElement(e,".se-image-container")||(d.plugins.image.openModify.call(d,!0),d.plugins.image.update_image.call(d,!0,!0,!0))}),null)}else if("video"===t){if(!d.plugins.video)return;d.removeRange(),d.callPlugin("video",(function(){const t=d.plugins.resizing.call_controller_resize.call(d,e,"video");d.plugins.video.onModifyMode.call(d,e,t)}),null)}},insertNode:function(e,t){const n=r.isFormatElement(e)||r.isRangeFormatElement(e)||r.isComponent(e);if(!t&&n){const e=this.removeNode();if(3===e.container.nodeType||r.isBreak(e.container)){const n=r.getParentElement(e.container,function(e){return this.isRangeFormatElement(e)}.bind(r));(t=r.splitElement(e.container,e.offset,n?r.getElementDepth(n)+1:0))&&(t=t.previousSibling)}}const i=this.getRange(),l=i.startContainer,s=i.startOffset,o=i.endContainer,a=i.endOffset,c=i.commonAncestorContainer;let d,u=null;if(t)d=t.parentNode,t=t.nextSibling,u=!0;else if(d=l,3===l.nodeType&&(d=l.parentNode),i.collapsed)if(3===c.nodeType)t=c.textContent.length>a?c.splitText(a):c.nextSibling;else if(r.isBreak(d))t=d,d=d.parentNode;else{let n=d.childNodes[s];const i=n&&3===n.nodeType&&r.onlyZeroWidthSpace(n)&&r.isBreak(n.nextSibling)?n.nextSibling:n;i?i.nextSibling?t=r.isBreak(i)&&!r.isBreak(e)?i:i.nextSibling:(d.removeChild(i),t=null):t=null}else{if(l===o){t=this.isEdgePoint(o,a)?o.nextSibling:o.splitText(a);let e=l;this.isEdgePoint(l,s)||(e=l.splitText(s)),d.removeChild(e),0===d.childNodes.length&&n&&(d.innerHTML="
    ")}else{const e=this.removeNode(),i=e.container,l=e.prevContainer;if(i&&0===i.childNodes.length&&n&&(r.isFormatElement(i)?i.innerHTML="
    ":r.isRangeFormatElement(i)&&(i.innerHTML="


    ")),!n&&l)if(d=3===l.nodeType?l.parentNode:l,d.contains(i))for(t=i;t.parentNode===d;)t=t.parentNode;else t=null;else d=n?c:i,t=n?o:null;for(;t&&t.parentNode!==c;)t=t.parentNode}}try{if(r.isFormatElement(e)||r.isRangeFormatElement(e)||!r.isListCell(d)&&r.isComponent(e)){const e=d;if(r.isList(t))d=t,t=null;else if(!u&&!t){const e=this.removeNode(),n=3===e.container.nodeType?r.isListCell(r.getFormatElement(e.container,null))?e.container:r.getFormatElement(e.container,null)||e.container.parentNode:e.container,i=r.isWysiwygDiv(n)||r.isRangeFormatElement(n);d=i?n:n.parentNode,t=i?null:n.nextSibling}0===e.childNodes.length&&d!==e&&r.removeItem(e)}!n||r.isRangeFormatElement(d)||r.isListCell(d)||r.isWysiwygDiv(d)||(t=d.nextElementSibling,d=d.parentNode),d.insertBefore(e,t)}catch(t){d.appendChild(e)}finally{let t=1;if(3===e.nodeType){const t=e.previousSibling,n=e.nextSibling,i=!t||3!==t.nodeType||r.onlyZeroWidthSpace(t)?"":t.textContent,l=!n||3!==n.nodeType||r.onlyZeroWidthSpace(n)?"":n.textContent;return t&&i.length>0&&(e.textContent=i+e.textContent,r.removeItem(t)),n&&n.length>0&&(e.textContent+=l,r.removeItem(n)),{startOffset:i.length,endOffset:e.textContent.length-l.length}}if(!r.isBreak(e)&&r.isFormatElement(d)){let n=null;e.previousSibling||(n=r.createTextNode(r.zeroWidthSpace),e.parentNode.insertBefore(n,e)),e.nextSibling||(n=r.createTextNode(r.zeroWidthSpace),e.parentNode.appendChild(n)),r._isIgnoreNodeChange(e)&&(e=e.nextSibling,t=0)}this.setRange(e,t,e,t),this.history.push(!0)}},removeNode:function(){const t=this.getRange();let n,i=0,l=t.startContainer,s=t.endContainer;const o=t.startOffset,a=t.endOffset,c=t.commonAncestorContainer;let d=null,u=null;const h=r.getListChildNodes(c,null);let g=r.getArrayIndex(h,l),p=r.getArrayIndex(h,s);if(h.length>0&&g>-1&&p>-1){for(let e=g+1,t=l;e>=0;e--)h[e]===t.parentNode&&h[e].firstChild===t&&0===o&&(g=e,t=t.parentNode);for(let e=p-1,t=s;e>g;e--)h[e]===t.parentNode&&1===h[e].nodeType&&(h.splice(e,1),t=t.parentNode,--p)}else{if(0===h.length){if(r.isFormatElement(c)||r.isRangeFormatElement(c)||r.isWysiwygDiv(c)||r.isBreak(c)||r.isMedia(c))return{container:c,offset:0};h.push(c),l=s=c}else if(l=s=h[0],r.isBreak(l))return{container:l,offset:0};g=p=0}function m(e){const t=r.getFormatElement(e,null);if(r.removeItem(e),r.isListCell(t)){const e=r.getArrayItem(t.children,r.isList,!1);if(e){const n=e.firstElementChild,i=n.childNodes;for(;i[0];)t.insertBefore(i[0],e);r.removeItemAllParents(n,null,null)}}}for(let e=g;e<=p;e++){const t=h[e];if(0===t.length||3===t.nodeType&&void 0===t.data)m(t);else if(t!==l)t!==s?m(t):(u=1===s.nodeType?r.createTextNode(s.textContent):r.createTextNode(s.substringData(a,s.length-a)),u.length>0?s.data=u.data:m(s));else if(1===l.nodeType?d=r.createTextNode(l.textContent):t===s?(d=r.createTextNode(l.substringData(0,o)+s.substringData(a,s.length-a)),i=o):d=r.createTextNode(l.substringData(0,o)),d.length>0?l.data=d.data:m(l),t===s)break}if(n=s&&s.parentNode?s:l&&l.parentNode?l:t.endContainer||t.startContainer,!r.isWysiwygDiv(n)){const t=r.removeItemAllParents(n,null,null);t&&(n=t.sc||t.ec||e.element.wysiwyg)}return this.setRange(n,i,n,i),this.history.push(!0),{container:n,offset:i,prevContainer:l&&l.parentNode?l:null}},applyRangeFormatElement:function(e){const t=this.getSelectedElementsAndComponents(!1);if(!t||0===t.length)return;e:for(let e,n,i,l,s,o,a=0,c=t.length;a-1&&(l=n.lastElementChild,t.indexOf(l)>-1)){let e=null;for(;e=l.lastElementChild;)if(r.isList(e)){if(!(t.indexOf(e.lastElementChild)>-1))continue e;l=e.lastElementChild}i=n.firstElementChild,s=t.indexOf(i),o=t.indexOf(l),t.splice(s,o-s+1),c=t.length}else;let n,i,l,s=t[t.length-1];n=r.isRangeFormatElement(s)||r.isFormatElement(s)?s:r.getRangeFormatElement(s,null)||r.getFormatElement(s,null),r.isCell(n)?(i=null,l=n):(i=n.nextSibling,l=n.parentNode);let o=r.getElementDepth(n),a=null;const c=[],d=function(e,t,n){let i=null;if(e!==t&&!r.isTable(t)){if(t&&r.getElementDepth(e)===r.getElementDepth(t))return n;i=r.removeItemAllParents(t,null,e)}return i?i.ec:n};for(let n,s,u,h,g,p,m,f=0,_=t.length;f<_;f++)if(n=t[f],s=n.parentNode,s&&!e.contains(s))if(u=r.getElementDepth(n),r.isList(s)){if(null===a&&(p?(a=p,m=!0,p=null):a=s.cloneNode(!1)),c.push(n),g=t[f+1],f===_-1||g&&g.parentNode!==s){g&&n.contains(g.parentNode)&&(p=g.parentNode.cloneNode(!1));let t,f=s.parentNode;for(;r.isList(f);)t=r.createElement(f.nodeName),t.appendChild(a),a=t,f=f.parentNode;const _=this.detachRangeFormatElement(s,c,null,!0,!0);o>=u?(o=u,l=_.cc,i=d(l,s,_.ec),i&&(l=i.parentNode)):l===_.cc&&(i=_.ec),l!==_.cc&&(h=d(l,_.cc,h),i=void 0!==h?h:_.cc);for(let e=0,t=_.removeArray.length;e=u&&(o=u,l=s,i=n.nextSibling),e.appendChild(n),l!==s&&(h=d(l,s),void 0!==h&&(i=h));if(this.effectNode=null,r.mergeSameTags(e,null,!1),r.mergeNestedTags(e,function(e){return this.isList(e)}.bind(r)),i&&r.getElementDepth(i)>0&&(r.isList(i.parentNode)||r.isList(i.parentNode.parentNode))){const t=r.getParentElement(i,function(e){return this.isRangeFormatElement(e)&&!this.isList(e)}.bind(r)),n=r.splitElement(i,null,t?r.getElementDepth(t)+1:0);n.parentNode.insertBefore(e,n)}else l.insertBefore(e,i),d(e,i);const u=r.getEdgeChildNodes(e.firstElementChild,e.lastElementChild);t.length>1?this.setRange(u.sc,0,u.ec,u.ec.textContent.length):this.setRange(u.ec,u.ec.textContent.length,u.ec,u.ec.textContent.length),this.history.push(!1)},detachRangeFormatElement:function(e,t,n,i,l){const s=this.getRange(),o=s.startOffset,a=s.endOffset;let c=r.getListChildNodes(e,(function(t){return t.parentNode===e})),d=e.parentNode,u=null,h=null,g=e.cloneNode(!1);const p=[],m=r.isList(n);let f=!1,_=!1,b=!1;function v(t,n,i,l){if(r.onlyZeroWidthSpace(n)&&(n.innerHTML=r.zeroWidthSpace),3===n.nodeType)return t.insertBefore(n,i),n;const s=(b?n:l).childNodes;let o=n.cloneNode(!1),a=null,c=null;for(;s[0];)c=s[0],!r._notTextNode(c)||r.isBreak(c)||r.isListCell(o)?o.appendChild(c):(o.childNodes.length>0&&(a||(a=o),t.insertBefore(o,i),o=n.cloneNode(!1)),t.insertBefore(c,i),a||(a=c));if(o.childNodes.length>0){if(r.isListCell(t)&&r.isListCell(o)&&r.isList(i))if(m){for(a=i;i;)o.appendChild(i),i=i.nextSibling;t.parentNode.insertBefore(o,t.nextElementSibling)}else{const t=l.nextElementSibling,n=r.detachNestedList(l,!1);e===n&&t===l.nextElementSibling||(e=n,_=!0)}else t.insertBefore(o,i);a||(a=o)}return a}for(let l,s,o,a=0,y=c.length;a0&&(d.insertBefore(g,e),g=null),!m&&r.isListCell(l))if(o&&r.getElementDepth(l)!==r.getElementDepth(o)&&(r.isListCell(d)||r.getArrayItem(l.children,r.isList,!1))){const t=l.nextElementSibling,n=r.detachNestedList(l,!1);e===n&&t===l.nextElementSibling||(e=n,_=!0)}else{const t=l;l=r.createElement(i?t.nodeName:r.isList(e.parentNode)||r.isListCell(e.parentNode)?"LI":r.isCell(e.parentNode)?"DIV":"P");const n=r.isListCell(l),s=t.childNodes;for(;s[0]&&(!r.isList(s[0])||n);)l.appendChild(s[0]);r.copyFormatAttributes(l,t),b=!0}else l=l.cloneNode(!1);if(_){_=b=!1,c=r.getListChildNodes(e,(function(t){return t.parentNode===e})),g=e.cloneNode(!1),d=e.parentNode,a=-1,y=c.length;continue}i?(p.push(l),r.removeItem(c[a])):(n?(f||(d.insertBefore(n,e),f=!0),l=v(n,l,null,c[a])):l=v(d,l,e,c[a]),t?(h=l,u||(u=l)):u||(u=h=l))}const y=e.parentNode;let x=e.nextSibling;g&&g.children.length>0&&y.insertBefore(g,x),n?u=n.previousSibling:u||(u=e.previousSibling),x=e.nextSibling,0===e.children.length||0===e.textContent.length?r.removeItem(e):r.removeEmptyNode(e,null);let C=null;if(i)C={cc:y,sc:u,ec:x,removeArray:p};else{u||(u=h),h||(h=u);const e=r.getEdgeChildNodes(u,h.parentNode?u:h);C={cc:(e.sc||e.ec).parentNode,sc:e.sc,ec:e.ec}}if(this.effectNode=null,l)return C;!i&&C&&(t?this.setRange(C.sc,o,C.ec,a):this.setRange(C.sc,0,C.sc,0)),this.history.push(!1)},detachList:function(e,t){let n={},i=!1,l=!1,s=null,o=null;const a=function(e){return!this.isComponent(e)}.bind(r);for(let c,d,u,h,g=0,p=e.length;g0)&&t,n=!!(n&&n.length>0)&&n;const s=!e,o=s&&!n&&!t;let c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset;if(o&&l.collapsed&&r.isFormatElement(c.parentNode)&&r.isFormatElement(u.parentNode)||c===u&&1===c.nodeType&&"false"===c.getAttribute("contenteditable"))return;if(l.collapsed&&!o&&1===c.nodeType&&!r.isBreak(c)){let e=null;const t=c.childNodes[d];t&&(t.nextSibling?e=r.isBreak(t)?t:t.nextSibling:(c.removeChild(t),e=null));const n=r.createTextNode(r.zeroWidthSpace);c.insertBefore(n,e),this.setRange(n,1,n,1),l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset}r.isFormatElement(c)&&(c=c.childNodes[d],d=0),r.isFormatElement(u)&&(u=u.childNodes[h],h=u.textContent.length),s&&(e=r.createElement("DIV"));const g=e.nodeName;if(!o&&c===u&&!n&&e){let t=c,n=0;const i=[],l=e.style;for(let e=0,t=l.length;e0){for(;!r.isFormatElement(t)&&!r.isWysiwygDiv(t);){for(let l=0;l=i.length)return}}let p,m={},f={},_="",b="",v="";if(t){for(let e,n=0,i=t.length;n0&&(c=l.replace(_,"").trim(),c!==l&&(y.v=!0));const d=t.className;let u="";return b&&d.length>0&&(u=d.replace(b,"").trim(),u!==d&&(y.v=!0)),(!s||!b&&d||!_&&l||c||u||!n)&&(c||u||t.nodeName!==g||a.Boolean(_)!==a.Boolean(l)||a.Boolean(b)!==a.Boolean(d))?(_&&l.length>0&&(t.style.cssText=c),t.style.cssText||t.removeAttribute("style"),b&&d.length>0&&(t.className=u.trim()),t.className.trim()||t.removeAttribute("class"),t.style.cssText||t.className||t.nodeName!==g&&!n?t:(y.v=!0,null)):(y.v=!0,null)},C=this.getSelectedElements(null);l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset,r.getFormatElement(c,null)||(c=r.getChildElement(C[0],(function(e){return 3===e.nodeType}),!1),d=0),r.getFormatElement(u,null)||(u=r.getChildElement(C[C.length-1],(function(e){return 3===e.nodeType}),!1),h=u.textContent.length);const w=r.getFormatElement(c,null)===r.getFormatElement(u,null),E=C.length-(w?0:1);p=e.cloneNode(!1);const N=o||s&&function(e,t){for(let n=0,i=e.length;n0&&(p=e.cloneNode(!1),f=this._nodeChange_endLine(C[E],p,x,u,h,o,s,y,S,T));for(let t=E-1;t>0;t--)p=e.cloneNode(!1),this._nodeChange_middleLine(C[t],p,x,o,s,y);p=e.cloneNode(!1),m=this._nodeChange_startLine(C[0],p,x,c,d,o,s,y,S,T),E<=0?f=m:f.container||(f.container=m.container,f.offset=m.container.textContent.length)}this.controllersOff(),this.setRange(m.container,m.offset,f.container,f.offset),this.history.push(!1)},_stripRemoveNode:function(e){const t=e.parentNode;if(!e||3===e.nodeType||!t)return;const n=e.childNodes;for(;n[0];)t.insertBefore(n[0],e);t.removeChild(e)},_util_getMaintainedNode:function(e,t){return t&&!e?this.getParentElement(t,function(e){return this._isMaintainedNode(e)}.bind(this)):null},_util_isMaintainedNode:function(e,t){return t&&!e&&3!==t.nodeType&&this._isMaintainedNode(t)},_nodeChange_oneLine:function(e,t,n,i,l,s,o,c,d,u,h,g,p){let m=i.parentNode;for(;!(m.nextSibling||m.previousSibling||r.isFormatElement(m.parentNode)||r.isWysiwygDiv(m.parentNode))&&m.nodeName!==t.nodeName;)m=m.parentNode;if(!d&&m===s.parentNode&&m.nodeName===t.nodeName&&r.onlyZeroWidthSpace(i.textContent.slice(0,l))&&r.onlyZeroWidthSpace(s.textContent.slice(o))){const e=m.childNodes;let n=!0;for(let t,l,o,a,c=0,d=e.length;c0&&(n=t.test(e.style.cssText)),!n}if(function e(i,l){const s=i.childNodes;for(let i,o=0,a=s.length;o=S?L-S:N.data.length-S));if(E){const t=g(l);if(t&&t.parentNode!==e){let n=t,i=null;for(;n.parentNode!==e;){for(l=i=n.parentNode.cloneNode(!1);n.childNodes[0];)i.appendChild(n.childNodes[0]);n.appendChild(i),n=n.parentNode}n.parentNode.appendChild(t)}E=E.cloneNode(!1)}r.onlyZeroWidthSpace(s)||l.appendChild(s);const c=g(l);for(c&&(E=c),E&&(e=E),x=a,y=[],w="";x!==e&&x!==f&&null!==x;)i=p(x)?null:n(x),i&&1===x.nodeType&&A(x)&&(y.push(i),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;const d=y.pop()||o;for(C=x=d;y.length>0;)x=y.pop(),C.appendChild(x),C=x;if(t.appendChild(d),e.appendChild(t),E&&!g(T)&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),N=o,S=0,k=!0,x!==o&&x.appendChild(N),!v)continue}if(z||a!==T){if(k){if(1===a.nodeType&&!r.isBreak(a)){r._isIgnoreNodeChange(a)?(b.appendChild(a.cloneNode(!0)),u||(t=t.cloneNode(!1),b.appendChild(t),_.push(t))):e(a,a);continue}x=a,y=[],w="";const s=[];for(;null!==x.parentNode&&x!==f&&x!==t;)i=z?x.cloneNode(!1):n(x),1===x.nodeType&&!r.isBreak(a)&&i&&A(x)&&(i&&(p(i)?E||s.push(i):y.push(i)),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;y=y.concat(s);const o=y.pop()||a;for(C=x=o;y.length>0;)x=y.pop(),C.appendChild(x),C=x;if(p(t.parentNode)&&!p(o)&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),z||E||!p(o))o===a?l=z?b:t:z?(b.appendChild(o),l=x):(t.appendChild(o),l=x);else{t=t.cloneNode(!1);const e=o.childNodes;for(let n=0,i=e.length;n0?x:t}if(E&&3===a.nodeType)if(g(a)){const e=r.getParentElement(l,function(e){return this._isMaintainedNode(e.parentNode)||e.parentNode===b}.bind(r));E.appendChild(e),t=e.cloneNode(!1),_.push(t),b.appendChild(t)}else E=null}d=a.cloneNode(!1),l.appendChild(d),1!==a.nodeType||r.isBreak(a)||(h=d),e(a,h)}else{E=g(a);const e=r.createTextNode(1===T.nodeType?"":T.substringData(L,T.length-L)),l=r.createTextNode(v||1===T.nodeType?"":T.substringData(0,L));if(E?E=E.cloneNode(!1):p(t.parentNode)&&!E&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),!r.onlyZeroWidthSpace(e)){x=a,w="",y=[];const t=[];for(;x!==b&&x!==f&&null!==x;)1===x.nodeType&&A(x)&&(p(x)?t.push(x.cloneNode(!1)):y.push(x.cloneNode(!1)),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;for(y=y.concat(t),d=C=x=y.pop()||e;y.length>0;)x=y.pop(),C.appendChild(x),C=x;b.appendChild(d),x.textContent=e.data}if(E&&d){const e=g(d);e&&(E=e)}for(x=a,y=[],w="";x!==b&&x!==f&&null!==x;)i=p(x)?null:n(x),i&&1===x.nodeType&&A(x)&&(y.push(i),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;const s=y.pop()||l;for(C=x=s;y.length>0;)x=y.pop(),C.appendChild(x),C=x;E?((t=t.cloneNode(!1)).appendChild(s),E.insertBefore(t,E.firstChild),b.appendChild(E),_.push(t),E=null):t.appendChild(s),T=l,L=l.data.length,z=!0,!c&&u&&(t=l,l.textContent=r.zeroWidthSpace),x!==l&&x.appendChild(T)}}}(e,b),d&&!c&&!h.v)return{startContainer:i,startOffset:l,endContainer:s,endOffset:o};if(c=c&&d)for(let e=0;e<_.length;e++){let t,n,i,l=_[e];if(u)t=r.createTextNode(r.zeroWidthSpace),b.replaceChild(t,l);else{const e=l.childNodes;for(n=e[0];e[0];)i=e[0],b.insertBefore(i,l);r.removeItem(l)}0===e&&(u?N=T=t:(N=n,T=i))}else{if(d)for(let e=0;e<_.length;e++)this._stripRemoveNode(_[e]);u&&(N=T=t)}r.removeEmptyNode(b,t),u&&(S=N.textContent.length,L=T.textContent.length);const B=c||0===T.textContent.length;r.isBreak(T)||0!==T.textContent.length||(r.removeItem(T),T=N),L=B?T.textContent.length:L;const H={s:0,e:0},M=r.getNodePath(N,b,H),I=!T.parentNode;I&&(T=N);const R={s:0,e:0},D=r.getNodePath(T,b,I||B?null:R);S+=H.s,L=u?S:I?N.textContent.length:B?L+H.s:L+R.s;const O=r.mergeSameTags(b,[M,D],!0);return e.parentNode.replaceChild(b,e),N=r.getNodeFromPath(M,b),T=r.getNodeFromPath(D,b),{startContainer:N,startOffset:S+O[0],endContainer:T,endOffset:L+O[1]}},_nodeChange_startLine:function(e,t,n,i,l,s,o,a,c,d){let u=i.parentNode;for(;!(u.nextSibling||u.previousSibling||r.isFormatElement(u.parentNode)||r.isWysiwygDiv(u.parentNode))&&u.nodeName!==t.nodeName;)u=u.parentNode;if(!o&&u.nodeName===t.nodeName&&!r.isFormatElement(u)&&!u.nextSibling&&r.onlyZeroWidthSpace(i.textContent.slice(0,l))){let e=!0,n=i.previousSibling;for(;n;){if(!r.onlyZeroWidthSpace(n)){e=!1;break}n=n.previousSibling}if(e)return r.copyTagAttributes(u,t),{container:i,offset:l}}a.v=!1;const h=e,g=[t],p=e.cloneNode(!1);let m,f,_,b,v=i,y=l,x=!1;if(function e(i,l){const s=i.childNodes;for(let i,o=0,a=s.length;o0,u=m.pop()||a;for(_=f=u;m.length>0;)f=m.pop(),_.appendChild(f),_=f;if(d(t.parentNode)&&!d(u)&&(t=t.cloneNode(!1),p.appendChild(t),g.push(t)),!b&&d(u)){t=t.cloneNode(!1);const e=u.childNodes;for(let n=0,i=e.length;n0;)f=m.pop(),_.appendChild(f),_=f;u!==l?(t.appendChild(u),l=f):l=t,r.isBreak(a)&&t.appendChild(a.cloneNode(!1)),e.appendChild(t),v=o,y=0,x=!0,l.appendChild(v)}}}(e,p),o&&!s&&!a.v)return{container:i,offset:l};if(s=s&&o)for(let e=0;e0&&c===d)return void(e.innerHTML=n.innerHTML)}s.v=!1;const o=e.cloneNode(!1),a=[t];let c=!0;if(function e(i,l){const s=i.childNodes;for(let i,d=0,u=s.length;d0&&(o.appendChild(t),t=t.cloneNode(!1)),o.appendChild(u.cloneNode(!0)),o.appendChild(t),a.push(t),l=t)}}(e,t),!c&&(!l||i||s.v)){if(o.appendChild(t),i&&l)for(let e=0;e0,u=m.pop()||a;for(_=f=u;m.length>0;)f=m.pop(),_.appendChild(f),_=f;if(d(t.parentNode)&&!d(u)&&(t=t.cloneNode(!1),p.insertBefore(t,p.firstChild),g.push(t)),!b&&d(u)){t=t.cloneNode(!1);const e=u.childNodes;for(let n=0,i=e.length;n0?f:t}else o?(t.insertBefore(u,t.firstChild),l=f):l=t;if(b&&3===a.nodeType)if(c(a)){const e=r.getParentElement(l,function(e){return this._isMaintainedNode(e.parentNode)||e.parentNode===p}.bind(r));b.appendChild(e),t=e.cloneNode(!1),g.push(t),p.insertBefore(t,p.firstChild)}else b=null}if(x||a!==v)i=x?n(a):a.cloneNode(!1),i&&(l.insertBefore(i,l.firstChild),1!==a.nodeType||r.isBreak(a)||(u=i)),e(a,u);else{b=c(a);const e=r.createTextNode(1===v.nodeType?"":v.substringData(y,v.length-y)),s=r.createTextNode(1===v.nodeType?"":v.substringData(0,y));if(b){b=b.cloneNode(!1);const e=c(l);if(e&&e.parentNode!==p){let t=e,n=null;for(;t.parentNode!==p;){for(l=n=t.parentNode.cloneNode(!1);t.childNodes[0];)n.appendChild(t.childNodes[0]);t.appendChild(n),t=t.parentNode}t.parentNode.insertBefore(e,t.parentNode.firstChild)}b=b.cloneNode(!1)}else d(t.parentNode)&&!b&&(t=t.cloneNode(!1),p.appendChild(t),g.push(t));for(r.onlyZeroWidthSpace(e)||l.insertBefore(e,l.firstChild),f=l,m=[];f!==p&&null!==f;)i=d(f)?null:n(f),i&&1===f.nodeType&&m.push(i),f=f.parentNode;const o=m.pop()||l;for(_=f=o;m.length>0;)f=m.pop(),_.appendChild(f),_=f;o!==l?(t.insertBefore(o,t.firstChild),l=f):l=t,r.isBreak(a)&&t.appendChild(a.cloneNode(!1)),b?(b.insertBefore(t,b.firstChild),p.insertBefore(b,p.firstChild),b=null):p.insertBefore(t,p.firstChild),v=s,y=s.data.length,x=!0,l.insertBefore(v,l.firstChild)}}}(e,p),o&&!s&&!a.v)return{container:i,offset:l};if(s=s&&o)for(let e=0;e0&&this.plugins.list.editInsideList.call(this,l,i),this.effectNode=null,this.setRange(s,a,o,c),this.history.push(!1)},toggleDisplayBlocks:function(){r.toggleClass(e.element.wysiwyg,"se-show-block"),this._resourcesStateChange()},toggleCodeView:function(){const t=this._variable.isCodeView;this.controllersOff(),r.toggleDisabledButtons(!t,this.codeViewDisabledButtons),t?(this._setCodeDataToEditor(),e.element.wysiwygFrame.scrollTop=0,e.element.code.style.display="none",e.element.wysiwygFrame.style.display="block",this._variable._codeOriginCssText=this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: none"),this._variable._wysiwygOriginCssText=this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: block"),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.style.height="0px"),this._variable.isCodeView=!1,this._variable.isFullScreen||(this._notHideToolbar=!1,/balloon|balloon-always/i.test(l.mode)&&(e.element._arrow.style.display="",this._isInline=!1,this._isBalloon=!0,u._hideToolbar())),this.nativeFocus(),this.history.push(!1)):(this._setEditorDataToCodeView(),this._variable._codeOriginCssText=this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: block"),this._variable._wysiwygOriginCssText=this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: none"),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.style.height=e.element.code.scrollHeight>0?e.element.code.scrollHeight+"px":"auto"),l.codeMirrorEditor&&l.codeMirrorEditor.refresh(),this._variable.isCodeView=!0,this._variable.isFullScreen||(this._notHideToolbar=!0,this._isBalloon&&(e.element._arrow.style.display="none",e.element.toolbar.style.left="",this._isInline=!0,this._isBalloon=!1,u._showToolbarInline())),this._variable._range=null,e.element.code.focus()),this._checkPlaceholder()},_setCodeDataToEditor:function(){const t=this._getCodeView();if(l.fullPage){const e=this._parser.parseFromString(t,"text/html"),n=e.head.children;for(let t=0,i=n.length;t0?this.convertContentsForEditor(t):"


    "},_setEditorDataToCodeView:function(){const t=this.convertHTMLForCodeView(e.element.wysiwyg);let n="";if(l.fullPage){const e=r.getAttributesToString(this._wd.body,null);n="\n\n"+this._wd.head.outerHTML.replace(/>(?!\n)/g,">\n")+"\n"+t+"\n"}else n=t;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(n)},toggleFullScreen:function(t){const n=e.element.topArea,i=e.element.toolbar,s=e.element.editorArea,d=e.element.wysiwygFrame,h=e.element.code,g=this._variable;this.controllersOff(),g.isFullScreen?(g.isFullScreen=!1,d.style.cssText=g._wysiwygOriginCssText,h.style.cssText=g._codeOriginCssText,i.style.cssText="",s.style.cssText=g._editorAreaOriginCssText,n.style.cssText=g._originCssText,o.body.style.overflow=g._bodyOverflow,l.stickyToolbar>-1&&r.removeClass(i,"se-toolbar-sticky"),g._fullScreenAttrs.sticky&&(g._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",r.addClass(i,"se-toolbar-sticky")),this._isInline=g._fullScreenAttrs.inline,this._isBalloon=g._fullScreenAttrs.balloon,this._isInline&&u._showToolbarInline(),u.onScroll_window(),r.changeElement(t.querySelector("svg"),c.expansion)):(g.isFullScreen=!0,g._fullScreenAttrs.inline=this._isInline,g._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.zIndex="2147483647",""!==e.element._stickyDummy.style.display&&(g._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",r.removeClass(i,"se-toolbar-sticky")),g._bodyOverflow=o.body.style.overflow,o.body.style.overflow="hidden",g._editorAreaOriginCssText=s.style.cssText,g._wysiwygOriginCssText=d.style.cssText,g._codeOriginCssText=h.style.cssText,s.style.cssText=i.style.cssText="",d.style.cssText=(d.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],h.style.cssText=(h.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],i.style.width=d.style.height=h.style.height="100%",i.style.position="relative",i.style.display="block",g.innerHeight_fullScreen=a.innerHeight-i.offsetHeight,s.style.height=g.innerHeight_fullScreen+"px",r.changeElement(t.querySelector("svg"),c.reduction),l.iframe&&"auto"===l.height&&(s.style.overflow="auto",this._iframeAutoHeight()))},print:function(){const e=r.createElement("IFRAME");e.style.display="none",o.body.appendChild(e);const t=r.getIframeDocument(e),n=this.getContents(!0),i=this._wd;if(l.iframe){const e=l.fullPage?r.getAttributesToString(i.body,["contenteditable"]):'class="sun-editor-editable"';t.write(""+i.head.innerHTML+""+n+"")}else{const e=r.createElement("DIV"),l=r.createElement("STYLE");l.innerHTML=r.getPageStyle(i),e.className="sun-editor-editable",e.innerHTML=n,t.head.appendChild(l),t.body.appendChild(e)}try{if(e.focus(),r.isIE_Edge||o.documentMode||a.StyleMedia)try{e.contentWindow.document.execCommand("print",!1,null)}catch(t){e.contentWindow.print()}else e.contentWindow.print()}catch(e){throw Error("[SUNEDITOR.core.print.fail] error: "+e)}finally{r.removeItem(e)}},preview:function(){const e=this.getContents(!0),t=a.open("","_blank");t.mimeType="text/html";const n=this._wd;if(l.iframe){const i=l.fullPage?r.getAttributesToString(n.body,["contenteditable"]):'class="sun-editor-editable"';t.document.write(""+n.head.innerHTML+""+e+"")}else t.document.write(''+i.toolbar.preview+"'+e+"")},setContents:function(t){const n=this.convertContentsForEditor(t);if(this._resetComponents(),d._variable.isCodeView){const e=this.convertHTMLForCodeView(n);d._setCodeView(e)}else e.element.wysiwyg.innerHTML=n,d.history.push(!1)},getContents:function(t){const n=e.element.wysiwyg.innerHTML,i=r.createElement("DIV");i.innerHTML=n;const s=r.getListChildren(i,(function(e){return/FIGCAPTION/i.test(e.nodeName)}));for(let e=0,t=s.length;e"+this._wd.head.outerHTML+""+i.innerHTML+""}return i.innerHTML},_makeLine:function(e,t){if(1===e.nodeType)return r._notAllowedTags(e)?"":!t||r.isFormatElement(e)||r.isRangeFormatElement(e)||r.isComponent(e)||r.isMedia(e)||r.isAnchor(e)&&r.isMedia(e.firstElementChild)?e.outerHTML:"

    "+e.outerHTML+"

    ";if(3===e.nodeType){if(!t)return e.textContent;const n=e.textContent.split(/\n/g);let i="";for(let e,t=0,l=n.length;t0&&(i+="

    "+e+"

    ");return i}return 8===e.nodeType&&this._allowHTMLComments?"<__comment__>"+e.textContent.trim()+"":""},cleanHTML:function(e,t){const n=o.createRange().createContextualFragment(e);try{r._consistencyCheckOfHTML(n,this._htmlCheckWhitelistRegExp)}catch(e){console.warn("[SUNEDITOR.cleanHTML.consistencyCheck.fail] "+e)}const i=n.childNodes;let l="",s=!1;for(let e,t=0,n=i.length;t(\n|.)*<\/(script|style)>/g,"").replace(this.editorTagsWhitelistRegExp,"").replace(/<__comment__>/g,"\x3c!-- ").replace(/<\/__comment__>/g," --\x3e").replace(/(<[a-zA-Z0-9]+)[^>]*(?=>)/g,function(e,t){let n=null;const i=this._attributesTagsWhitelist[t.match(/(?!<)[a-zA-Z]+/)[0].toLowerCase()];if(n=i?e.match(i):e.match(this._attributesWhitelistRegExp),n)for(let e=0,i=n.length;e^<]*)>/g,"")),l=r.htmlRemoveWhiteSpace(l),r._tagConvertor(l?t?l.replace("string"==typeof t?r.createTagsWhitelist(t):t,""):l:e)},convertContentsForEditor:function(e){const t=o.createRange().createContextualFragment(e);try{r._consistencyCheckOfHTML(t,this._htmlCheckWhitelistRegExp)}catch(e){console.warn("[SUNEDITOR.convertContentsForEditor.consistencyCheck.fail] "+e)}let n="";const i=t.childNodes;for(let e=0,t=i.length;e

    ":(n=r.htmlRemoveWhiteSpace(n),n=n.replace(this.editorTagsWhitelistRegExp,"").replace(/\n/g,"").replace(/<__comment__>/g,"\x3c!-- ").replace(/<\/__comment__>/g," --\x3e"),r._tagConvertor(n))},convertHTMLForCodeView:function(e){let t="";const n=a.RegExp,i=new n("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),l=r.isFormatElement.bind(r),s="string"==typeof e?o.createRange().createContextualFragment(e):e;let c=1*this._variable.codeIndent;return c=c>0?new a.Array(c+1).join(" "):"",function e(s,o,a){const d=s.childNodes,u=i.test(s.nodeName),h=u?o:"";for(let g,p,m,f=0,_=d.length;f<_;f++){if(g=d[f],m=i.test(g.nodeName),p=m?"\n":"",a=!l(g)||u||/^(TH|TD)$/i.test(s.nodeName)?"":"\n",8===g.nodeType){t+="\n\x3c!-- "+g.textContent.trim()+" --\x3e"+p;continue}if(3===g.nodeType){t+=r._HTMLConvertor(/^\n+$/.test(g.data)?"":g.data);continue}if(0===g.childNodes.length){t+=(/^(HR)$/i.test(g.nodeName)?"\n":"")+h+g.outerHTML+p;continue}g.innerHTML=g.innerHTML;const _=g.nodeName.toLowerCase();t+=(a||(u?"":p))+(h||m?o:"")+g.outerHTML.match(n("<"+_+"[^>]*>","i"))[0]+p,e(g,o+c,""),t+=(m?o:"")+""+(a||p||u||/^(TH|TD)$/i.test(g.nodeName)?"\n":"")}}(s,"","\n"),t.trim()+"\n"},addDocEvent:function(e,t,n){o.addEventListener(e,t,n),l.iframe&&this._wd.addEventListener(e,t)},removeDocEvent:function(e,t){o.removeEventListener(e,t),l.iframe&&this._wd.removeEventListener(e,t)},_charCount:function(t){const n=e.element.charCounter,i=l.maxCharCount;let s=0;if(t&&(s=d._getCharLength(t,l.charCounterType)),n&&a.setTimeout((function(){n.textContent=h.getCharCount(null)})),i>0){let t=!1;const n=h.getCharCount(null);if(n>i){if(t=!0,s>0){this._editorRange();const e=this.getRange(),t=e.endOffset-1,l=this.getSelectionNode().textContent,s=e.endOffset-(n-i);this.getSelectionNode().textContent=l.slice(0,s<0?0:s)+l.slice(e.endOffset,l.length),this.setRange(e.endContainer,t,e.endContainer,t)}}else n+s>i&&(t=!0);if(t){const t=e.element.charWrapper;if(t&&!r.hasClass(t,"se-blink")&&(r.addClass(t,"se-blink"),a.setTimeout((function(){r.removeClass(t,"se-blink")}),600)),s>0)return!1}}return!0},_getCharLength:function(e,t){return/byte/.test(t)?r.getByteLength(e):e.length},_checkComponents:function(){for(let e in this.componentInfoPlugins)this.componentInfoPlugins[e].checkComponentInfo.call(this)},_resetComponents:function(){for(let e in this.componentInfoPlugins)this.componentInfoPlugins[e].resetComponentInfo.call(this)},_setCodeView:function(t){l.codeMirrorEditor?l.codeMirrorEditor.getDoc().setValue(t):e.element.code.value=t},_getCodeView:function(){return l.codeMirrorEditor?l.codeMirrorEditor.getDoc().getValue():e.element.code.value},_init:function(i,s){this._ww=l.iframe?e.element.wysiwygFrame.contentWindow:a,this._wd=o,l.iframe&&"auto"===l.height&&(this._iframeAuto=this._wd.body),this._allowHTMLComments=l._editorTagsWhitelist.indexOf("//")>-1,this._htmlCheckWhitelistRegExp=new a.RegExp("^("+l._editorTagsWhitelist.replace("|//","")+")$","i"),this.editorTagsWhitelistRegExp=r.createTagsWhitelist(l._editorTagsWhitelist.replace("|//","|__comment__")),this.pasteTagsWhitelistRegExp=r.createTagsWhitelist(l.pasteTagsWhitelist);const c=l.attributesWhitelist,d={};let g,p,m="";if(c)for(let e in c)"all"===e?m=c[e]+"|":d[e]=new a.RegExp("((?:"+c[e]+')s*=s*"[^"]*")',"ig");this._attributesWhitelistRegExp=new a.RegExp("((?:"+m+'contenteditable|colspan|rowspan|target|href|src|class|type|data-format|data-size|data-file-size|data-file-name|data-origin|data-align|data-image-link|data-rotate|data-proportion|data-percentage|origin-size)s*=s*"[^"]*")',"ig"),this._attributesTagsWhitelist=d,this.codeViewDisabledButtons=e.element.toolbar.querySelectorAll('.se-toolbar button:not([class~="se-code-view-enabled"])'),this.resizingDisabledButtons=e.element.toolbar.querySelectorAll('.se-toolbar button:not([class~="se-resizing-enabled"])'),this._isInline=/inline/i.test(l.mode),this._isBalloon=/balloon|balloon-always/i.test(l.mode),this._isBalloonAlways=/balloon-always/i.test(l.mode),this.commandMap={STRONG:e.tool.bold,U:e.tool.underline,EM:e.tool.italic,DEL:e.tool.strike,SUB:e.tool.subscript,SUP:e.tool.superscript,OUTDENT:e.tool.outdent,INDENT:e.tool.indent},this.activePlugins=[],this.componentInfoPlugins=[];for(let e in n)g=n[e],p=t[e],g.active&&p&&this.callPlugin(e,null,p),"function"==typeof g.checkComponentInfo&&"function"==typeof g.resetComponentInfo&&(this.callPlugin(e,null,p),this.componentInfoPlugins.push(g));this._variable._originCssText=e.element.topArea.style.cssText,this._placeholder=e.element.placeholder,this._lineBreaker=e.element.lineBreaker,this._lineBreakerButton=this._lineBreaker.querySelector("button"),this.history=function(e,t){const n=window,i=e.context.element,l=e.util,s=e.context.tool.undo,o=e.context.tool.redo;let a=null,r=0,c=[];function d(){const n=c[r];i.wysiwyg.innerHTML=n.contents,e.setRange(l.getNodeFromPath(n.s.path,i.wysiwyg),n.s.offset,l.getNodeFromPath(n.e.path,i.wysiwyg),n.e.offset),e.focus(),0===r?(s&&s.setAttribute("disabled",!0),o&&o.removeAttribute("disabled")):r===c.length-1?(s&&s.removeAttribute("disabled"),o&&o.setAttribute("disabled",!0)):(s&&s.removeAttribute("disabled"),o&&o.removeAttribute("disabled")),e.controllersOff(),e._checkComponents(),e._charCount(""),e._resourcesStateChange(),t()}function u(){e._checkComponents();const n=e.getContents(!0);if(c[r]&&n===c[r].contents)return;r++;const i=e._variable._range;c.length>r&&(c=c.slice(0,r),o&&o.setAttribute("disabled",!0)),c[r]=i?{contents:n,s:{path:l.getNodePath(i.startContainer,null,null),offset:i.startOffset},e:{path:l.getNodePath(i.endContainer,null,null),offset:i.endOffset}}:{contents:n,s:{path:[0,0],offset:[0,0]},e:{path:0,offset:0}},1===r&&s&&s.removeAttribute("disabled"),e._charCount(""),t()}return{stack:c,push:function(t){n.setTimeout(e._resourcesStateChange);const i="number"==typeof t?t>0?t:0:t?400:0;i&&!a||(n.clearTimeout(a),i)?a=n.setTimeout((function(){n.clearTimeout(a),a=null,u()}),i):u()},undo:function(){r>0&&(r--,d())},redo:function(){c.length-1>r&&(r++,d())},go:function(e){r=e<0?c.length-1:e,d()},reset:function(n){s&&s.setAttribute("disabled",!0),o&&o.setAttribute("disabled",!0),e.context.tool.save&&e.context.tool.save.setAttribute("disabled",!0),c.splice(0),r=0,c[r]={contents:e.getContents(!0),s:{path:[0,0],offset:0},e:{path:[0,0],offset:0}},n||t()},_destroy:function(){a&&n.clearTimeout(a),c=null}}}(this,u._onChange_historyStack),l.iframe||this._initWysiwygArea(i,s),a.setTimeout(function(){if(l.iframe&&(this._wd=e.element.wysiwygFrame.contentDocument,e.element.wysiwyg=this._wd.body,this._initWysiwygArea(i,s),"auto"===l.height&&(this._iframeAuto=this._wd.body)),this._checkComponents(),this._componentsInfoInit=!1,this._componentsInfoReset=!1,this.history.reset(!0),this._resourcesStateChange(),"function"==typeof h.onload)return h.onload(this,i)}.bind(this))},_initWysiwygArea:function(t,n){l.defaultStyle&&(e.element.wysiwyg.style.cssText=l.defaultStyle),t?n&&(e.element.wysiwyg.innerHTML=n):e.element.wysiwyg.innerHTML=this.convertContentsForEditor(e.element.originElement.value)},_resourcesStateChange:function(){d._iframeAutoHeight(),d._checkPlaceholder()},_iframeAutoHeight:function(){this._iframeAuto&&a.setTimeout((function(){e.element.wysiwygFrame.style.height=d._iframeAuto.offsetHeight+"px"}))},_checkPlaceholder:function(){if(this._placeholder){if(this._variable.isCodeView)return void(this._placeholder.style.display="none");const t=e.element.wysiwyg;!r.onlyZeroWidthSpace(t.textContent)||t.querySelector(".se-component, pre, blockquote, hr, li, table, img, iframe, video")||(t.innerText.match(/\n/g)||"").length>1?this._placeholder.style.display="none":this._placeholder.style.display="block"}},_setDefaultFormat:function(e){if(this._resizingName)return;const t=this.getRange(),n=t.commonAncestorContainer,i=t.startContainer,l=r.getRangeFormatElement(n,null);let s,o,a;if(!(r.getParentElement(n,r.isComponent)||(r.isRangeFormatElement(i)||r.isWysiwygDiv(i))&&r.isComponent(i.childNodes[t.startOffset]))){if(l)return a=r.createElement(e||"P"),a.innerHTML=l.innerHTML,0===a.childNodes.length&&(a.innerHTML=r.zeroWidthSpace),l.innerHTML=a.outerHTML,a=l.firstChild,s=r.getEdgeChildNodes(a,null).sc,s||(s=r.createTextNode(r.zeroWidthSpace),a.insertBefore(s,a.firstChild)),o=s.textContent.length,void this.setRange(s,o,s,o);if(r.isRangeFormatElement(n)&&n.childNodes.length<=1){let e=null;1===n.childNodes.length&&r.isBreak(n.firstChild)?e=n.firstChild:(e=r.createTextNode(r.zeroWidthSpace),n.appendChild(e)),this.setRange(e,1,e,1)}if(this.execCommand("formatBlock",!1,e||"P"),s=r.getEdgeChildNodes(n,n),s=s?s.ec:n,a=r.getFormatElement(s,null),!a)return this.removeRange(),void this._editorRange();if(r.isBreak(a.nextSibling)&&r.removeItem(a.nextSibling),r.isBreak(a.previousSibling)&&r.removeItem(a.previousSibling),r.isBreak(s)){const e=r.createTextNode(r.zeroWidthSpace);s.parentNode.insertBefore(e,s),s=e}o=3===s.nodeType?s.textContent.length:1,this.effectNode=null,this.setRange(s,o,s,o)}}},u={_directionKeyCode:new a.RegExp("^(8|13|3[2-9]|40|46)$"),_nonTextKeyCode:new a.RegExp("^(8|13|1[6-9]|20|27|3[3-9]|40|45|46|11[2-9]|12[0-3]|144|145)$"),_historyIgnoreKeyCode:new a.RegExp("^(1[6-9]|20|27|3[3-9]|40|45|11[2-9]|12[0-3]|144|145)$"),_onButtonsCheck:new a.RegExp("^(STRONG|U|EM|DEL|SUB|SUP)$"),_frontZeroWidthReg:new a.RegExp(r.zeroWidthSpace+"+",""),_keyCodeShortcut:{65:"A",66:"B",83:"S",85:"U",73:"I",89:"Y",90:"Z",219:"[",221:"]"},_shortcutCommand:function(e,t){let n=null;switch(u._keyCodeShortcut[e]){case"A":n="selectAll";break;case"B":n="STRONG";break;case"S":t&&(n="DEL");break;case"U":n="U";break;case"I":n="EM";break;case"Z":n=t?"redo":"undo";break;case"Y":n="redo";break;case"[":n="outdent";break;case"]":n="indent"}return!!n&&(d.commandHandler(d.commandMap[n],n),!0)},_applyTagEffects:function(){let t=d.getSelectionNode();if(t===d.effectNode)return;d.effectNode=t;const i=d.commandMap,s=this._onButtonsCheck,o=[],a=[],c=d.activePlugins,u=c.length;let h="";for(;t.firstChild;)t=t.firstChild;for(let e=t;!r.isWysiwygDiv(e)&&e;e=e.parentNode)if(1===e.nodeType&&!r.isBreak(e)){h=e.nodeName.toUpperCase(),a.push(h);for(let t,i=0;i0)&&(o.push("OUTDENT"),i.OUTDENT.removeAttribute("disabled")),-1===o.indexOf("INDENT")&&i.INDENT&&r.isListCell(e)&&!e.previousElementSibling&&(o.push("INDENT"),i.INDENT.setAttribute("disabled",!0))):s.test(h)&&(o.push(h),r.addClass(i[h],"active"))}for(let e in i)o.indexOf(e)>-1||(c.indexOf(e)>-1?n[e].active.call(d,null):i.OUTDENT&&/^OUTDENT$/i.test(e)?i.OUTDENT.setAttribute("disabled",!0):i.INDENT&&/^INDENT$/i.test(e)?i.INDENT.removeAttribute("disabled"):r.removeClass(i[e],"active"));d._variable.currentNodes=a.reverse(),l.showPathLabel&&(e.element.navigation.textContent=d._variable.currentNodes.join(" > "))},_cancelCaptionEdit:function(){this.setAttribute("contenteditable",!1),this.removeEventListener("blur",u._cancelCaptionEdit)},onMouseDown_toolbar:function(e){let t=e.target;if(d._bindControllersOff&&e.stopPropagation(),/^(input|textarea|select|option)$/i.test(t.nodeName)?d._antiBlur=!1:e.preventDefault(),r.getParentElement(t,".se-submenu"))e.stopPropagation(),d._notHideToolbar=!0;else{let n=t.getAttribute("data-command"),i=t.className;for(;!n&&!/se-menu-list/.test(i)&&!/se-toolbar/.test(i);)t=t.parentNode,n=t.getAttribute("data-command"),i=t.className;n!==d._submenuName&&n!==d._containerName||e.stopPropagation()}},onClick_toolbar:function(e){let t=e.target,n=t.getAttribute("data-display"),i=t.getAttribute("data-command"),l=t.className;for(;t.parentNode&&!i&&!/se-menu-list/.test(l)&&!/se-toolbar/.test(l);)t=t.parentNode,i=t.getAttribute("data-command"),n=t.getAttribute("data-display"),l=t.className;(i||n)&&(t.disabled||(d.hasFocus||d.nativeFocus(),d._variable.isCodeView||d._editorRange(),d.actionCall(i,n,t)))},onMouseDown_wysiwyg:function(t){if("false"===e.element.wysiwyg.getAttribute("contenteditable"))return;const n=r.getParentElement(t.target,r.isCell);if(n){const e=d.plugins.table;e&&n!==e._fixedCell&&!e._shift&&d.callPlugin("table",(function(){e.onTableCellMultiSelect.call(d,n,!1)}),null)}d._isBalloon&&u._hideToolbar(),h.onMouseDown&&h.onMouseDown(t,d)},onClick_wysiwyg:function(t){const n=t.target;if("false"===e.element.wysiwyg.getAttribute("contenteditable"))return;if(/^FIGURE$/i.test(n.nodeName)){const e=n.querySelector("IMG"),i=n.querySelector("IFRAME");if(e)return t.preventDefault(),void d.selectComponent(e,"image");if(i)return t.preventDefault(),void d.selectComponent(i,"video")}const i=r.getParentElement(n,"FIGCAPTION");if(i&&(!i.getAttribute("contenteditable")||"false"===i.getAttribute("contenteditable"))&&(t.preventDefault(),i.setAttribute("contenteditable",!0),i.focus(),d._isInline&&!d._inlineToolbarAttr.isShow)){u._showToolbarInline();const e=function(){u._hideToolbar(),i.removeEventListener("blur",e)};i.addEventListener("blur",e)}a.setTimeout(d._editorRange.bind(d)),d._editorRange();const l=d.getSelectionNode(),s=r.getFormatElement(l,null),o=r.getRangeFormatElement(l,null);if(s&&s!==o||"false"===n.getAttribute("contenteditable"))u._applyTagEffects();else{if(r.isList(o)){const e=r.createElement("LI"),t=l.nextElementSibling;e.appendChild(l),o.insertBefore(e,t)}else r.isWysiwygDiv(l)||r.isComponent(l)||d._setDefaultFormat(r.isRangeFormatElement(o)?"DIV":"P");t.preventDefault(),d.focus()}d._isBalloon&&a.setTimeout(u._toggleToolbarBalloon),h.onClick&&h.onClick(t,d)},_balloonDelay:null,_showToolbarBalloonDelay:function(){u._balloonDelay&&a.clearTimeout(u._balloonDelay),u._balloonDelay=a.setTimeout(function(){a.clearTimeout(this._balloonDelay),this._balloonDelay=null,this._showToolbarBalloon()}.bind(u),350)},_toggleToolbarBalloon:function(){d._editorRange();const e=d.getRange();"table"===d.currentControllerName||!d._isBalloonAlways&&e.collapsed?u._hideToolbar():u._showToolbarBalloon(e)},_showToolbarBalloon:function(t){if(!d._isBalloon)return;const n=t||d.getRange(),i=e.element.toolbar,l=d.getSelection();let s;if(d._isBalloonAlways&&n.collapsed)s=!0;else if(l.focusNode===l.anchorNode)s=l.focusOffset0&&u._getPageBottomSpace()x&&(t=!1,y=!0),y&&(b=(t?n.top-m-g:n.bottom+g)-(n.noText?0:h)+d),i.style.left=a.Math.floor(v)+"px",i.style.top=a.Math.floor(b)+"px",t?(r.removeClass(e.element._arrow,"se-arrow-up"),r.addClass(e.element._arrow,"se-arrow-down"),e.element._arrow.style.top=m+"px"):(r.removeClass(e.element._arrow,"se-arrow-down"),r.addClass(e.element._arrow,"se-arrow-up"),e.element._arrow.style.top=-g+"px");const C=a.Math.floor(p/2+(f-v));e.element._arrow.style.left=(C+g>i.offsetWidth?i.offsetWidth-g:C";const e=m.attributes;for(;e[0];)m.removeAttribute(e[0].name);return d.nativeFocus(),!1}if(m&&c.startContainer===c.endContainer&&3===o.nodeType&&!r.isFormatElement(o.parentNode)&&(c.collapsed?1===o.textContent.length:c.endOffset-c.startOffset===o.textContent.length)){t.preventDefault();let e=null,n=o.parentNode.previousSibling;const i=o.parentNode.nextSibling;n||(i?(n=i,e=0):(n=r.createElement("BR"),m.appendChild(n))),o.textContent="",r.removeItemAllParents(o,null,m),e="number"==typeof e?e:3===n.nodeType?n.textContent.length:1,d.setRange(n,e,n,e);break}const n=c.commonAncestorContainer;if(m=r.getFormatElement(c.startContainer,null),f=r.getRangeFormatElement(m,null),f&&m&&!r.isCell(f)&&!/^FIGCAPTION$/i.test(f.nodeName)){if(r.isListCell(m)&&r.isList(f)&&(r.isListCell(f.parentNode)||m.previousElementSibling)&&(o===m||3===o.nodeType&&(!o.previousSibling||r.isList(o.previousSibling)))&&(r.getFormatElement(c.startContainer,null)!==r.getFormatElement(c.endContainer,null)?f.contains(c.startContainer):0===c.startOffset&&c.collapsed)){if(c.startContainer!==c.endContainer)t.preventDefault(),d.removeNode(),3===c.startContainer.nodeType&&d.setRange(c.startContainer,c.startContainer.textContent.length,c.startContainer,c.startContainer.textContent.length),d.history.push(!0);else{let e=m.previousElementSibling||f.parentNode;if(r.isListCell(e)){t.preventDefault();let n=e;if(!e.contains(m)&&r.isListCell(n)&&r.isList(n.lastElementChild)){for(n=n.lastElementChild.lastElementChild;r.isListCell(n)&&r.isList(n.lastElementChild);)n=n.lastElementChild&&n.lastElementChild.lastElementChild;e=n}let i=e===f.parentNode?f.previousSibling:e.lastChild;i||(i=r.createTextNode(r.zeroWidthSpace),f.parentNode.insertBefore(i,f.parentNode.firstChild));const l=3===i.nodeType?i.textContent.length:1,s=m.childNodes;let o=i,a=s[0];for(;a=s[0];)e.insertBefore(a,o.nextSibling),o=a;r.removeItem(m),0===f.children.length&&r.removeItem(f),d.setRange(i,l,i,l),d.history.push(!0)}}break}if(!g&&0===c.startOffset){let e=!0,i=n;for(;i&&i!==f&&!r.isWysiwygDiv(i);){if(i.previousSibling&&(1===i.previousSibling.nodeType||!r.onlyZeroWidthSpace(i.previousSibling.textContent.trim()))){e=!1;break}i=i.parentNode}if(e&&f.parentNode){t.preventDefault(),d.detachRangeFormatElement(f,r.isListCell(m)?[m]:null,null,!1,!1),d.history.push(!0);break}}}if(!g&&0===c.startOffset&&(r.isComponent(n.previousSibling)||3===n.nodeType&&!n.previousSibling&&0===c.startOffset&&0===c.endOffset&&r.isComponent(m.previousSibling))){let e=m.previousSibling;r.hasClass(e,"se-image-container")||/^IMG$/i.test(e.nodeName)?(e=/^IMG$/i.test(e.nodeName)?e:e.querySelector("img"),d.selectComponent(e,"image"),0===m.textContent.length&&r.removeItem(m)):r.hasClass(e,"se-video-container")&&(d.selectComponent(e.querySelector("iframe"),"video"),0===m.textContent.length&&r.removeItem(m));break}break;case 46:if(p){t.preventDefault(),t.stopPropagation(),d.plugins[p].destroy.call(d);break}if((r.isFormatElement(o)||null===o.nextSibling)&&c.startOffset===o.textContent.length){let e=m.nextElementSibling;if(!e){t.preventDefault();break}if(r.isComponent(e)){if(t.preventDefault(),r.onlyZeroWidthSpace(m)&&(r.removeItem(m),r.isTable(e))){let t=r.getChildElement(e,r.isCell,!1);t=t.firstElementChild||t,d.setRange(t,0,t,0);break}(r.hasClass(e,"se-component")||/^(IMG|IFRAME)$/i.test(e.nodeName))&&(t.stopPropagation(),r.hasClass(e,"se-image-container")||/^IMG$/i.test(e.nodeName)?(e=/^IMG$/i.test(e.nodeName)?e:e.querySelector("img"),d.selectComponent(e,"image")):r.hasClass(e,"se-video-container")&&d.selectComponent(e.querySelector("iframe"),"video"));break}}if(m=r.getFormatElement(c.startContainer,null),f=r.getRangeFormatElement(m,null),r.isListCell(m)&&r.isList(f)&&(o===m||3===o.nodeType&&(!o.nextSibling||r.isList(o.nextSibling))&&(r.getFormatElement(c.startContainer,null)!==r.getFormatElement(c.endContainer,null)?f.contains(c.endContainer):c.endOffset===o.textContent.length&&c.collapsed))){c.startContainer!==c.endContainer&&d.removeNode();let e=r.getArrayItem(m.children,r.isList,!1);if(e=e||m.nextElementSibling||f.parentNode.nextElementSibling,e&&(r.isList(e)||r.getArrayItem(e.children,r.isList,!1))){let n,i;if(t.preventDefault(),r.isList(e)){const t=e.firstElementChild;for(i=t.childNodes,n=i[0];i[0];)m.insertBefore(i[0],e);r.removeItem(t)}else{for(n=e.firstChild,i=e.childNodes;i[0];)m.appendChild(i[0]);r.removeItem(e)}d.setRange(n,0,n,0),d.history.push(!0)}break}break;case 9:if(p)break;if(t.preventDefault(),l||s||r.isWysiwygDiv(o))break;const _=!c.collapsed||d.isEdgePoint(c.startContainer,c.startOffset),b=d.getSelectedElements(null);o=d.getSelectionNode();const v=[];let y=[],x=r.isListCell(b[0]),C=r.isListCell(b[b.length-1]),w={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset};for(let e,t=0,n=b.length;t0&&_&&d.plugins.list)w=d.plugins.list.editInsideList.call(d,i,v);else{const e=r.getParentElement(o,r.isCell);if(e&&_){const t=r.getParentElement(e,"table"),n=r.getListChildren(t,r.isCell);let l=i?r.prevIdx(n,e):r.nextIdx(n,e);l!==n.length||i||(l=0),-1===l&&i&&(l=n.length-1);let s=n[l];if(!s)break;s=s.firstElementChild||s,d.setRange(s,0,s,0);break}y=y.concat(v),x=C=null}if(y.length>0)if(i){const e=y.length-1;for(let t,n=0;n<=e;n++){t=y[n].childNodes;for(let e,n=0,i=t.length;n0&&r.isBreak(i[l-1])||!e&&r.onlyZeroWidthSpace(o.textContent)&&r.isBreak(s)&&(r.isBreak(s.previousSibling)||!r.onlyZeroWidthSpace(s.previousSibling.textContent))&&(!a||!r.isBreak(a)&&r.onlyZeroWidthSpace(a.textContent)))){e?r.removeItem(i[l-1]):r.removeItem(o);const t=d.appendFormatTag(E,r.isFormatElement(E.nextElementSibling)?E.nextElementSibling:null);r.copyFormatAttributes(t,E),d.setRange(t,1,t,1);break}if(e){h.insertHTML(c.collapsed&&r.isBreak(c.startContainer.childNodes[c.startOffset-1])?"
    ":"

    ",!0);let e=n.focusNode;const t=n.focusOffset;E===e&&(e=e.childNodes[t-l>1?t-1:t]),d.setRange(e,1,e,1)}else{const e=n.focusNode.nextSibling,t=r.createElement("BR");d.insertNode(t,null);const i=t.previousSibling,l=t.nextSibling;r.isBreak(e)||r.isBreak(i)||l&&!r.onlyZeroWidthSpace(l)?d.setRange(l,0,l,0):(t.parentNode.insertBefore(t.cloneNode(!1),t),d.setRange(t,1,t,1))}u._onShortcutKey=!0;break}if(g)break;if(f&&m&&!r.isCell(f)&&!/^FIGCAPTION$/i.test(f.nodeName)){const e=d.getRange();if((3!==e.commonAncestorContainer.nodeType||!e.commonAncestorContainer.nextElementSibling)&&r.onlyZeroWidthSpace(m.innerText.trim())){t.preventDefault();let e=null;if(r.isListCell(f.parentNode)){f=m.parentNode.parentNode.parentNode;const t=r.splitElement(m,null,r.getElementDepth(m)-2);e=r.createElement("LI"),f.insertBefore(e,t)}else{const t=r.isCell(f.parentNode)?"DIV":r.isList(f.parentNode)?"LI":r.isFormatElement(f.nextElementSibling)?f.nextElementSibling.nodeName:r.isFormatElement(f.previousElementSibling)?f.previousElementSibling.nodeName:"P";e=r.createElement(t);const n=d.detachRangeFormatElement(f,[m],null,!0,!0);n.cc.insertBefore(e,n.ec)}e.innerHTML="
    ",r.copyFormatAttributes(e,m),r.removeItemAllParents(m,null,null),d.setRange(e,1,e,1);break}}if(f&&r.getParentElement(f,"FIGCAPTION")&&r.getParentElement(f,r.isList)&&(t.preventDefault(),m=d.appendFormatTag(m,null),d.setRange(m,0,m,0)),p){t.preventDefault(),t.stopPropagation();const n=e[p],i=n._container,l=i.previousElementSibling||i.nextElementSibling;let s=null;r.isListCell(i.parentNode)?s=r.createElement("BR"):(s=r.createElement(r.isFormatElement(l)?l.nodeName:"P"),s.innerHTML="
    "),i.parentNode.insertBefore(s,i),d.callPlugin(p,(function(){const e=d.plugins.resizing.call_controller_resize.call(d,n._element,p);d.plugins[p].onModifyMode.call(d,n._element,e)}),null)}break;case 27:if(p)return t.preventDefault(),t.stopPropagation(),d.controllersOff(),!1}if(i&&/16/.test(n)){t.preventDefault(),t.stopPropagation();const e=d.plugins.table;if(e&&!e._shift&&!e._ref){const t=r.getParentElement(m,r.isCell);if(t)return void e.onTableCellMultiSelect.call(d,t,!0)}}if(!(l||s||g||u._nonTextKeyCode.test(n))&&c.collapsed&&c.startContainer===c.endContainer&&r.isBreak(c.commonAncestorContainer)){const e=r.createTextNode(r.zeroWidthSpace);d.insertNode(e,null),d.setRange(e,1,e,1)}h.onKeyDown&&h.onKeyDown(t,d)},onKeyUp_wysiwyg:function(e){if(u._onShortcutKey)return;d._editorRange();const t=d.getRange(),n=e.keyCode,i=e.ctrlKey||e.metaKey||91===n||92===n,l=e.altKey;let s=d.getSelectionNode();if(d._isBalloon&&(d._isBalloonAlways&&27!==n||!t.collapsed)){if(!d._isBalloonAlways)return void u._showToolbarBalloon();27!==n&&u._showToolbarBalloonDelay()}if(8===n&&r.isWysiwygDiv(s)&&""===s.textContent){e.preventDefault(),e.stopPropagation(),s.innerHTML="";const t=r.createElement(r.isFormatElement(d._variable.currentNodes[0])?d._variable.currentNodes[0]:"P");return t.innerHTML="
    ",s.appendChild(t),d.setRange(t,0,t,0),u._applyTagEffects(),void d.history.push(!1)}const o=r.getFormatElement(s,null),a=r.getRangeFormatElement(s,null);if((o||!t.collapsed)&&o!==a||r.isComponent(s)||(d._setDefaultFormat(r.isRangeFormatElement(a)?"DIV":"P"),s=d.getSelectionNode()),u._directionKeyCode.test(n)&&u._applyTagEffects(),!i&&!l&&!u._nonTextKeyCode.test(n)&&3===s.nodeType&&r.zeroWidthRegExp.test(s.textContent)&&r.getByteLength(e.key)<3){let e=t.startOffset,n=t.endOffset;const i=(s.textContent.substring(0,n).match(u._frontZeroWidthReg)||"").length;e=t.startOffset-i,n=t.endOffset-i,s.textContent=s.textContent.replace(r.zeroWidthRegExp,""),d.setRange(s,e<0?0:e,s,n<0?0:n)}d._charCount(""),d.history.push(!0),h.onKeyUp&&h.onKeyUp(e,d)},onScroll_wysiwyg:function(e){d.controllersOff(),d._lineBreaker.style.display="none",d._isBalloon&&u._hideToolbar(),h.onScroll&&h.onScroll(e,d)},onFocus_wysiwyg:function(e){d._antiBlur||(d.hasFocus=!0,d._isInline&&u._showToolbarInline(),h.onFocus&&h.onFocus(e,d))},onBlur_wysiwyg:function(e){d._antiBlur||(d.hasFocus=!1,d.controllersOff(),(d._isInline||d._isBalloon)&&u._hideToolbar(),h.onBlur&&h.onBlur(e,d))},onMouseDown_resizingBar:function(t){t.stopPropagation(),d._variable.resizeClientY=t.clientY,e.element.resizeBackground.style.display="block",o.addEventListener("mousemove",u._resize_editor),o.addEventListener("mouseup",(function t(){e.element.resizeBackground.style.display="none",o.removeEventListener("mousemove",u._resize_editor),o.removeEventListener("mouseup",t)}))},_resize_editor:function(t){const n=e.element.editorArea.offsetHeight+(t.clientY-d._variable.resizeClientY);e.element.wysiwygFrame.style.height=e.element.code.style.height=(n=n+s?(d._sticky||u._onStickyToolbar(),t.toolbar.style.top=n+s+l.stickyToolbar-i-d._variable.minResizingSize+"px"):i>=s&&u._onStickyToolbar()},_getEditorOffsets:function(){let t=e.element.topArea,n=0,i=0,l=0;for(;t;)n+=t.offsetTop,i+=t.offsetLeft,l+=t.scrollTop,t=t.offsetParent;return{top:n,left:i,scroll:l}},_getPageBottomSpace:function(){return o.documentElement.scrollHeight-(u._getEditorOffsets().top+e.element.topArea.offsetHeight)},_onStickyToolbar:function(){const t=e.element;d._isInline||(t._stickyDummy.style.height=t.toolbar.offsetHeight+"px",t._stickyDummy.style.display="block"),t.toolbar.style.top=l.stickyToolbar+"px",t.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:t.toolbar.offsetWidth+"px",r.addClass(t.toolbar,"se-toolbar-sticky"),d._sticky=!0},_offStickyToolbar:function(){const t=e.element;t._stickyDummy.style.display="none",t.toolbar.style.top=d._isInline?d._inlineToolbarAttr.top:"",t.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:"",t.editorArea.style.marginTop="",r.removeClass(t.toolbar,"se-toolbar-sticky"),d._sticky=!1},_codeViewAutoHeight:function(){e.element.code.style.height=e.element.code.scrollHeight+"px"},onPaste_wysiwyg:function(e){const t=e.clipboardData;if(!t)return!0;const n=t.getData("text/plain").replace(/\n/g,""),i=d.cleanHTML(t.getData("text/html"),d.pasteTagsWhitelistRegExp),s=d._charCount("byte-html"===l.charCounterType?i:n);return("function"!=typeof h.onPaste||h.onPaste(e,i,s,d))&&s?void(i?(e.stopPropagation(),e.preventDefault(),h.insertHTML(i,!0)):d.history.push(!0)):(e.preventDefault(),e.stopPropagation(),!1)},onCut_wysiwyg:function(){a.setTimeout((function(){d.history.push(!1)}))},onDragOver_wysiwyg:function(e){e.preventDefault()},onDrop_wysiwyg:function(t){const n=t.dataTransfer;if(!n)return!0;const i=n.files;if(i.length>0&&d.plugins.image)u._setDropLocationSelection(t),d.callPlugin("image",(function(){e.image.imgInputFile.files=i,d.plugins.image.onRender_imgInput.call(d),e.image.imgInputFile.files=null}),null);else{if(!d._charCount(n.getData("text/plain")))return t.preventDefault(),t.stopPropagation(),!1;{const e=d.cleanHTML(n.getData("text/html"),d.pasteTagsWhitelistRegExp);e&&(u._setDropLocationSelection(t),h.insertHTML(e,!0))}}h.onDrop&&h.onDrop(t,d)},onmouseMove_wysiwyg:function(t){const n=r.getParentElement(t.target,r.isComponent),i=d._lineBreaker.style;if(n){let s=0,o=e.element.wysiwyg;do{s+=o.scrollTop,o=o.parentElement}while(o&&!/^(BODY|HTML)$/i.test(o.nodeName));const a=e.element.wysiwyg.scrollTop,c=u._getEditorOffsets(),h=r.getOffset(n,e.element.wysiwygFrame).top+a,g=t.pageY+s+(l.iframe?e.element.toolbar.offsetHeight:0),p=h+(l.iframe?s:c.top);let m="",f="";if(!r.isFormatElement(n.previousElementSibling)&&gp+n.offsetHeight-20))return void(i.display="none");f=h+n.offsetHeight,m="b"}d._variable._lineBreakComp=n,d._variable._lineBreakDir=m,i.top=f-a+"px",i.visibility="hidden",i.display="block",d._lineBreakerButton.style.left=n.offsetLeft+n.offsetWidth/2-d._lineBreakerButton.offsetWidth/2+"px",i.visibility=""}else"none"!==i.display&&(i.display="none")},_onMouseDown_lineBreak:function(e){e.preventDefault()},_onLineBreak:function(){const e=d._variable._lineBreakComp,t=r.createElement("P");t.innerHTML="
    ",e.parentNode.insertBefore(t,"t"===d._variable._lineBreakDir?e:e.nextSibling),d._lineBreaker.style.display="none",d._variable._lineBreakComp=null,d.setRange(t.firstChild,1,t.firstChild,1),d.history.push(!1)},_setDropLocationSelection:function(e){e.stopPropagation(),e.preventDefault();const t=d.getRange();d.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)},_onChange_historyStack:function(){u._applyTagEffects(),e.tool.save&&e.tool.save.removeAttribute("disabled"),h.onChange&&h.onChange(d.getContents(!0),d)},_addEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.addEventListener("mousedown",u.onMouseDown_toolbar,!1),e.element.toolbar.addEventListener("click",u.onClick_toolbar,!1),t.addEventListener("mousedown",u.onMouseDown_wysiwyg,!1),t.addEventListener("click",u.onClick_wysiwyg,!1),t.addEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg,!1),t.addEventListener("keydown",u.onKeyDown_wysiwyg,!1),t.addEventListener("keyup",u.onKeyUp_wysiwyg,!1),t.addEventListener("paste",u.onPaste_wysiwyg,!1),t.addEventListener("cut",u.onCut_wysiwyg,!1),t.addEventListener("dragover",u.onDragOver_wysiwyg,!1),t.addEventListener("drop",u.onDrop_wysiwyg,!1),t.addEventListener("scroll",u.onScroll_wysiwyg,!1),t.addEventListener("focus",u.onFocus_wysiwyg,!1),t.addEventListener("blur",u.onBlur_wysiwyg,!1),t.addEventListener("mousemove",u.onmouseMove_wysiwyg,!1),d._lineBreakerButton.addEventListener("mousedown",u._onMouseDown_lineBreak,!1),d._lineBreakerButton.addEventListener("click",u._onLineBreak,!1),d.plugins.table&&t.addEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.addEventListener("keydown",u._codeViewAutoHeight,!1),e.element.code.addEventListener("keyup",u._codeViewAutoHeight,!1),e.element.code.addEventListener("paste",u._codeViewAutoHeight,!1)),e.element.resizingBar&&(/\d+/.test(l.height)?e.element.resizingBar.addEventListener("mousedown",u.onMouseDown_resizingBar,!1):r.addClass(e.element.resizingBar,"se-resizing-none")),a.removeEventListener("resize",u.onResize_window),a.removeEventListener("scroll",u.onScroll_window),a.addEventListener("resize",u.onResize_window,!1),l.stickyToolbar>-1&&a.addEventListener("scroll",u.onScroll_window,!1)},_removeEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.removeEventListener("mousedown",u.onMouseDown_toolbar),e.element.toolbar.removeEventListener("click",u.onClick_toolbar),t.removeEventListener("mousedown",u.onMouseDown_wysiwyg),t.removeEventListener("click",u.onClick_wysiwyg),t.removeEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg),t.removeEventListener("keydown",u.onKeyDown_wysiwyg),t.removeEventListener("keyup",u.onKeyUp_wysiwyg),t.removeEventListener("paste",u.onPaste_wysiwyg),t.removeEventListener("cut",u.onCut_wysiwyg),t.removeEventListener("dragover",u.onDragOver_wysiwyg),t.removeEventListener("drop",u.onDrop_wysiwyg),t.removeEventListener("scroll",u.onScroll_wysiwyg),t.removeEventListener("mousemove",u.onmouseMove_wysiwyg),d._lineBreakerButton.removeEventListener("mousedown",u._onMouseDown_lineBreak),d._lineBreakerButton.removeEventListener("click",u._onLineBreak),t.removeEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),t.removeEventListener("focus",u.onFocus_wysiwyg),t.removeEventListener("blur",u.onBlur_wysiwyg),e.element.code.removeEventListener("keydown",u._codeViewAutoHeight),e.element.code.removeEventListener("keyup",u._codeViewAutoHeight),e.element.code.removeEventListener("paste",u._codeViewAutoHeight),e.element.resizingBar&&e.element.resizingBar.removeEventListener("mousedown",u.onMouseDown_resizingBar),a.removeEventListener("resize",u.onResize_window),a.removeEventListener("scroll",u.onScroll_window)}},h={core:d,util:r,onload:null,onScroll:null,onMouseDown:null,onClick:null,onInput:null,onKeyDown:null,onKeyUp:null,onDrop:null,onChange:null,onPaste:null,onFocus:null,onBlur:null,showInline:null,showController:null,imageUploadHandler:null,onImageUploadBefore:null,onImageUpload:null,onImageUploadError:null,onVideoUpload:null,setOptions:function(s){u._removeEvent(),d.plugins=s.plugins||d.plugins;const o=[s,s].reduce((function(e,t){for(let n in t)if("plugins"===n&&t[n]&&e[n]){let i=e[n],l=t[n];i=i.length?i:a.Object.keys(i).map((function(e){return i[e]})),l=l.length?l:a.Object.keys(l).map((function(e){return l[e]})),e[n]=l.filter((function(e){return-1===i.indexOf(e)})).concat(i)}else e[n]=t[n];return e}),{}),r=b._setOptions(o,e,d.plugins,s);r.callButtons&&(t=r.callButtons,d.initPlugins={}),r.plugins&&(d.plugins=n=r.plugins);const c=e.element.wysiwyg.innerHTML,h=e.element,g={_top:h.topArea,_relative:h.relative,_toolBar:h.toolbar,_editorArea:h.editorArea,_wysiwygArea:h.wysiwygFrame,_codeArea:h.code,_placeholder:h.placeholder,_resizingBar:h.resizingBar,_navigation:h.navigation,_charCounter:h.charCounter,_charWrapper:h.charWrapper,_loading:h.loading,_lineBreaker:h.lineBreaker,_resizeBack:h.resizeBackground,_stickyDummy:h._stickyDummy,_arrow:h._arrow};l=o,d.lang=i=l.lang,d.context=e=v(e.element.originElement,g,l),d._componentsInfoReset=!0,d._init(!0,c),u._addEvent(),d._charCount(""),u._offStickyToolbar(),u.onResize_window()},setDefaultStyle:function(t){const n=r._setDefaultOptionStyle(l);"string"==typeof t&&t.trim().length>0?e.element.wysiwyg.style.cssText=n+t:e.element.wysiwyg.style.cssText=n},noticeOpen:function(e){d.notice.open.call(d,e)},noticeClose:function(){d.notice.close.call(d)},save:function(){e.element.originElement.value=d.getContents(!1)},getContext:function(){return e},getContents:function(e){return d.getContents(e)},getCharCount:function(t){return t="string"==typeof t?t:l.charCounterType,d._getCharLength("byte-html"===t?e.element.wysiwyg.innerHTML:e.element.wysiwyg.textContent,t)},getImagesInfo:function(){return e.image?e.image._imagesInfo:[]},getVideosInfo:function(){return e.video?e.video._videosInfo:[]},insertImage:function(e){d.plugins.image&&e&&(d.initPlugins.image?d.plugins.image.submitAction.call(d,e):d.callPlugin("image",d.plugins.image.submitAction.bind(d,e),null),d.focus())},insertHTML:function(e,t){if("string"==typeof e){t||(e=d.cleanHTML(e,null));try{const t=o.createRange().createContextualFragment(e).childNodes;let n,i,l;for(;n=t[0];)l=d.insertNode(n,i),i=n;const s=3===i.nodeType?l.endOffset||i.textContent.length:i.childNodes.length;d.setRange(i,s,i,s)}catch(t){d.execCommand("insertHTML",!1,e)}}else if(r.isComponent(e))d.insertComponent(e,!1);else{let t=null;(r.isFormatElement(e)||r.isMedia(e))&&(t=r.getFormatElement(d.getSelectionNode(),null)),d.insertNode(e,t)}d.effectNode=null,d.focus(),d.history.push(!1)},setContents:function(e){d.setContents(e)},appendContents:function(t){const n=d.convertContentsForEditor(t);if(d._variable.isCodeView)d._setCodeView(d._getCodeView()+"\n"+d.convertHTMLForCodeView(n));else{const t=r.createElement("DIV");t.innerHTML=n;const i=e.element.wysiwyg,l=t.children;for(let e=0,t=l.length;e
    ",n},_module_getSizeX:function(e,t,n,i){return t||(t=e._element),n||(n=e._cover),i||(i=e._container),i&&n&&t?/%$/.test(t.style.width)?(this.util.getNumber(i.style.width,2)||100)+"%":t.style.width:""},_module_getSizeY:function(e,t,n,i){return t||(t=e._element),n||(n=e._cover),i||(i=e._container),i&&n&&t?this.util.getNumber(n.style.paddingBottom,0)>0&&!this.context.resizing._rotateVertical?n.style.height:/%$/.test(t.style.height)&&/%$/.test(t.style.width)?(this.util.getNumber(i.style.height,2)||100)+"%":t.style.height:""},_module_setModifyInputSize:function(e,t){const n=e._onlyPercentage&&this.context.resizing._rotateVertical;e.proportion.checked=e._proportionChecked="false"!==e._element.getAttribute("data-proportion");let i=n?"":this.plugins.resizing._module_getSizeX.call(this,e);if(i===e._defaultSizeX&&(i=""),e._onlyPercentage&&(i=this.util.getNumber(i,2)),e.inputX.value=i,t.setInputSize.call(this,"x"),!e._onlyPercentage){let t=n?"":this.plugins.resizing._module_getSizeY.call(this,e);t===e._defaultSizeY&&(t=""),e._onlyPercentage&&(t=this.util.getNumber(t,2)),e.inputY.value=t}e.inputX.disabled=!!n,e.inputY.disabled=!!n,e.proportion.disabled=!!n,t.setRatio.call(this)},_module_setInputSize:function(e,t){if(e._onlyPercentage)"x"===t&&e.inputX.value>100&&(e.inputX.value=100);else if(e.proportion.checked&&e._ratio&&/\d/.test(e.inputX.value)&&/\d/.test(e.inputY.value)){const n=e.inputX.value.replace(/\d+|\./g,"")||e.sizeUnit,i=e.inputY.value.replace(/\d+|\./g,"")||e.sizeUnit;if(n!==i)return;const l="%"===n?2:0;"x"===t?e.inputY.value=this.util.getNumber(e._ratioY*this.util.getNumber(e.inputX.value,l),l)+i:e.inputX.value=this.util.getNumber(e._ratioX*this.util.getNumber(e.inputY.value,l),l)+n}},_module_setRatio:function(e){const t=e.inputX.value,n=e.inputY.value;if(e.proportion.checked&&/\d+/.test(t)&&/\d+/.test(n)){if((t.replace(/\d+|\./g,"")||e.sizeUnit)!==(n.replace(/\d+|\./g,"")||e.sizeUnit))e._ratio=!1;else if(!e._ratio){const i=this.util.getNumber(t,0),l=this.util.getNumber(n,0);e._ratio=!0,e._ratioX=i/l,e._ratioY=l/i}}else e._ratio=!1},_module_sizeRevert:function(e){e._onlyPercentage?e.inputX.value=e._origin_w>100?100:e._origin_w:(e.inputX.value=e._origin_w,e.inputY.value=e._origin_h)},_module_saveCurrentSize:function(e){const t=this.plugins.resizing._module_getSizeX.call(this,e),n=this.plugins.resizing._module_getSizeY.call(this,e);e._element.setAttribute("data-size",t+","+n),e._videoRatio&&(e._videoRatio=n)},call_controller_resize:function(e,t){const n=this.context.resizing,i=this.context[t];n._resize_plugin=t;const l=n.resizeContainer,s=n.resizeDiv,o=this.util.getOffset(e,this.context.element.wysiwygFrame),a=n._rotateVertical=/^(90|270)$/.test(Math.abs(e.getAttribute("data-rotate")).toString()),r=a?e.offsetHeight:e.offsetWidth,c=a?e.offsetWidth:e.offsetHeight,d=o.top,u=o.left-this.context.element.wysiwygFrame.scrollLeft;l.style.top=d+"px",l.style.left=u+"px",l.style.width=r+"px",l.style.height=c+"px",s.style.top="0px",s.style.left="0px",s.style.width=r+"px",s.style.height=c+"px";let h=e.getAttribute("data-align")||"basic";h="none"===h?"basic":h;const g=this.util.getParentElement(e,this.util.isComponent),p=this.util.getParentElement(e,"FIGURE"),m=this.plugins.resizing._module_getSizeX.call(this,i,e,p,g)||"auto",f=i._onlyPercentage&&"image"===t?"":", "+(this.plugins.resizing._module_getSizeY.call(this,i,e,p,g)||"auto");this.util.changeTxt(n.resizeDisplay,this.lang.dialogBox[h]+" ("+m+f+")"),n.resizeButtonGroup.style.display=i._resizing?"":"none";const _=!i._resizing||i._resizeDotHide||i._onlyPercentage?"none":"flex",b=n.resizeHandles;for(let e=0,t=b.length;e",e},set_cover:function(e){const t=this.util.createElement("FIGURE");return t.appendChild(e),t},set_container:function(e,t){const n=this.util.createElement("DIV");return n.className="se-component "+t,n.setAttribute("contenteditable",!1),n.appendChild(e),n},onClick_resizeButton:function(e){e.stopPropagation();const t=e.target,n=t.getAttribute("data-command")||t.parentNode.getAttribute("data-command");if(!n)return;const i=t.getAttribute("data-value")||t.parentNode.getAttribute("data-value"),l=this.context.resizing._resize_plugin,s=this.context[l],o=s._element,a=this.plugins[l];if(e.preventDefault(),"function"!=typeof this.plugins.resizing._closeAlignMenu||(this.plugins.resizing._closeAlignMenu(),"onalign"!==n)){switch(n){case"auto":a.setAutoSize.call(this),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"percent":let e=this.plugins.resizing._module_getSizeY.call(this,s);if(this.context.resizing._rotateVertical){const t=o.getAttribute("data-percentage");t&&(e=t.split(",")[1])}this.plugins.resizing.resetTransform.call(this,o),a.setPercentSize.call(this,100*i,null!==this.util.getNumber(e,0)&&/%$/.test(e)?e:""),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"mirror":const t=o.getAttribute("data-rotate")||"0";let n=o.getAttribute("data-rotateX")||"",r=o.getAttribute("data-rotateY")||"";"h"===i&&!this.context.resizing._rotateVertical||"v"===i&&this.context.resizing._rotateVertical?r=r?"":"180":n=n?"":"180",o.setAttribute("data-rotateX",n),o.setAttribute("data-rotateY",r),this.plugins.resizing._setTransForm(o,t,n,r);break;case"rotate":const c=this.context.resizing,d=1*o.getAttribute("data-rotate")+1*i,u=this._w.Math.abs(d)>=360?0:d;o.setAttribute("data-rotate",u),c._rotateVertical=/^(90|270)$/.test(this._w.Math.abs(u).toString()),this.plugins.resizing.setTransformSize.call(this,o,null,null),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"onalign":return void this.plugins.resizing.openAlignMenu.call(this);case"align":const h="basic"===i?"none":i;a.setAlign.call(this,h,null,null,null),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"caption":const g=!s._captionChecked;if(a.openModify.call(this,!0),s._captionChecked=s.captionCheckEl.checked=g,"image"===l?a.update_image.call(this,!1,!1,!1):"video"===l&&(this.context.dialog.updateModal=!0,a.submitAction.call(this)),g){const e=this.util.getChildElement(s._caption,(function(e){return 3===e.nodeType}));e?this.setRange(e,0,e,e.textContent.length):s._caption.focus(),this.controllersOff()}else a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l)),a.openModify.call(this,!0);break;case"revert":a.setOriginSize.call(this),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"update":a.openModify.call(this),this.controllersOff();break;case"delete":a.destroy.call(this)}this.history.push(!1)}},resetTransform:function(e){const t=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.context.resizing._rotateVertical=!1,e.style.maxWidth="",e.style.transform="",e.style.transformOrigin="",e.setAttribute("data-rotate",""),e.setAttribute("data-rotateX",""),e.setAttribute("data-rotateY",""),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,t[0]?t[0]:"auto",t[1]?t[1]:"",!0)},setTransformSize:function(e,t,n){let i=e.getAttribute("data-percentage");const l=this.context.resizing._rotateVertical,s=1*e.getAttribute("data-rotate");let o="";if(i&&!l)i=i.split(","),"auto"===i[0]&&"auto"===i[1]?this.plugins[this.context.resizing._resize_plugin].setAutoSize.call(this):this.plugins[this.context.resizing._resize_plugin].setPercentSize.call(this,i[0],i[1]);else{const i=this.util.getParentElement(e,"FIGURE"),a=t||e.offsetWidth,r=n||e.offsetHeight,c=(l?r:a)+"px",d=(l?a:r)+"px";if(this.plugins[this.context.resizing._resize_plugin].cancelPercentAttr.call(this),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,a+"px",r+"px",!0),i.style.width=c,i.style.height=this.context[this.context.resizing._resize_plugin]._caption?"":d,l){let e=a/2+"px "+a/2+"px 0",t=r/2+"px "+r/2+"px 0";o=90===s||-270===s?t:e}}e.style.transformOrigin=o,this.plugins.resizing._setTransForm(e,s.toString(),e.getAttribute("data-rotateX")||"",e.getAttribute("data-rotateY")||""),e.style.maxWidth=l?"none":"",this.plugins.resizing.setCaptionPosition.call(this,e)},_setTransForm:function(e,t,n,i){let l=(e.offsetWidth-e.offsetHeight)*(/-/.test(t)?1:-1),s="";if(/[1-9]/.test(t)&&(n||i))switch(s=n?"Y":"X",t){case"90":s=n&&i?"X":i?s:"";break;case"270":l*=-1,s=n&&i?"Y":n?s:"";break;case"-90":s=n&&i?"Y":n?s:"";break;case"-270":l*=-1,s=n&&i?"X":i?s:"";break;default:s=""}t%180==0&&(e.style.maxWidth=""),e.style.transform="rotate("+t+"deg)"+(n?" rotateX("+n+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(s?" translate"+s+"("+l+"px)":"")},setCaptionPosition:function(e){const t=this.util.getChildElement(this.util.getParentElement(e,"FIGURE"),"FIGCAPTION");t&&(t.style.marginTop=(this.context.resizing._rotateVertical?e.offsetWidth-e.offsetHeight:0)+"px")},onMouseDown_resize_handle:function(e){const t=this.context.resizing,n=t._resize_direction=e.target.classList[0];e.stopPropagation(),e.preventDefault();const i=this.context.resizing._resize_plugin,l=this.context[i]._element,s=this.plugins[i];t._resizeClientX=e.clientX,t._resizeClientY=e.clientY,this.context.element.resizeBackground.style.display="block",t.resizeButton.style.display="none",t.resizeDiv.style.float=/l/.test(n)?"right":/r/.test(n)?"left":"none";const o=function(e){if("keydown"===e.type&&27!==e.keyCode)return;const i=t._isChange;t._isChange=!1,this.removeDocEvent("mousemove",a),this.removeDocEvent("mouseup",o),this.removeDocEvent("keydown",o),"keydown"===e.type?(this.controllersOff(),this.context.element.resizeBackground.style.display="none",this.plugins[this.context.resizing._resize_plugin].init.call(this)):(this.plugins.resizing.cancel_controller_resize.call(this,n),i&&this.history.push(!1)),s.onModifyMode.call(this,l,this.plugins.resizing.call_controller_resize.call(this,l,t._resize_plugin))}.bind(this),a=this.plugins.resizing.resizing_element.bind(this,t,n,this.context[t._resize_plugin]);this.addDocEvent("mousemove",a),this.addDocEvent("mouseup",o),this.addDocEvent("keydown",o)},resizing_element:function(e,t,n,i){const l=i.clientX,s=i.clientY;let o=n._element_w,a=n._element_h;const r=n._element_w+(/r/.test(t)?l-e._resizeClientX:e._resizeClientX-l),c=n._element_h+(/b/.test(t)?s-e._resizeClientY:e._resizeClientY-s),d=n._element_h/n._element_w*r;/t/.test(t)&&(e.resizeDiv.style.top=n._element_h-(/h/.test(t)?c:d)+"px"),/l/.test(t)&&(e.resizeDiv.style.left=n._element_w-r+"px"),/r|l/.test(t)&&(e.resizeDiv.style.width=r+"px",o=r),/^(t|b)[^h]$/.test(t)?(e.resizeDiv.style.height=d+"px",a=d):/^(t|b)h$/.test(t)&&(e.resizeDiv.style.height=c+"px",a=c),e._resize_w=o,e._resize_h=a,this.util.changeTxt(e.resizeDisplay,this._w.Math.round(o)+" x "+this._w.Math.round(a)),e._isChange=!0},cancel_controller_resize:function(e){const t=this.context.resizing._rotateVertical;this.controllersOff(),this.context.element.resizeBackground.style.display="none";let n=this._w.Math.round(t?this.context.resizing._resize_h:this.context.resizing._resize_w),i=this._w.Math.round(t?this.context.resizing._resize_w:this.context.resizing._resize_h);if(!t&&!/%$/.test(n)){const e=16,t=this.context.element.wysiwygFrame.clientWidth-2*e-2;this.util.getNumber(n,0)>t&&(i=this._w.Math.round(i/n*t),n=t)}this.plugins[this.context.resizing._resize_plugin].setSize.call(this,n,i,!1,e),this.plugins[this.context.resizing._resize_plugin].init.call(this)}};return void 0===t&&(e.SUNEDITOR_MODULES||(e.SUNEDITOR_MODULES={}),e.SUNEDITOR_MODULES.resizing=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_MODULES a window with a document");return l(e)}:l(i)}}); \ No newline at end of file +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var l=t[i]={i:i,l:!1,exports:{}};return e[i].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(i,l,function(t){return e[t]}.bind(null,l));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="XJR1")}({"1kvd":function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={name:"dialog",add:function(e){const t=e.context;t.dialog={kind:"",updateModal:!1,_closeSignal:!1};let n=e.util.createElement("DIV");n.className="se-dialog sun-editor-common";let i=e.util.createElement("DIV");i.className="se-dialog-back",i.style.display="none";let l=e.util.createElement("DIV");l.className="se-dialog-inner",l.style.display="none",n.appendChild(i),n.appendChild(l),t.dialog.modalArea=n,t.dialog.back=i,t.dialog.modal=l,t.dialog.modal.addEventListener("mousedown",this.onMouseDown_dialog.bind(e)),t.dialog.modal.addEventListener("click",this.onClick_dialog.bind(e)),t.element.relative.appendChild(n),n=null,i=null,l=null},onMouseDown_dialog:function(e){/se-dialog-inner/.test(e.target.className)?this.context.dialog._closeSignal=!0:this.context.dialog._closeSignal=!1},onClick_dialog:function(e){e.stopPropagation(),(/close/.test(e.target.getAttribute("data-command"))||this.context.dialog._closeSignal)&&this.plugins.dialog.close.call(this)},open:function(e,t){if(this.modalForm)return!1;this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null),this.plugins.dialog._bindClose=function(e){/27/.test(e.keyCode)&&this.plugins.dialog.close.call(this)}.bind(this),this._d.addEventListener("keydown",this.plugins.dialog._bindClose),this.context.dialog.updateModal=t,"full"===this.context.option.popupDisplay?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const n=this.context[e].focusElement;"function"==typeof this.plugins[e].on&&this.plugins[e].on.call(this,t),this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",n&&n.focus()},_bindClose:null,close:function(){this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null);const e=this.context.dialog.kind;this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.context.dialog.updateModal=!1,this.plugins[e].init.call(this),this.context.dialog.kind="",this.modalForm=null,this.focus()}};return void 0===t&&(e.SUNEDITOR_MODULES||(e.SUNEDITOR_MODULES={}),e.SUNEDITOR_MODULES.dialog=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_MODULES a window with a document");return l(e)}:l(i)},"3FqI":function(e,t,n){},P6u4:function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={code:"en",toolbar:{default:"Default",save:"Save",font:"Font",formats:"Formats",fontSize:"Size",bold:"Bold",underline:"Underline",italic:"Italic",strike:"Strike",subscript:"Subscript",superscript:"Superscript",removeFormat:"Remove Format",fontColor:"Font Color",hiliteColor:"Highlight Color",indent:"Indent",outdent:"Outdent",align:"Align",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",alignJustify:"Align justify",list:"List",orderList:"Ordered list",unorderList:"Unordered list",horizontalRule:"Horizontal line",hr_solid:"Solid",hr_dotted:"Dotted",hr_dashed:"Dashed",table:"Table",link:"Link",math:"Math",image:"Image",video:"Video",fullScreen:"Full screen",showBlocks:"Show blocks",codeView:"Code view",undo:"Undo",redo:"Redo",preview:"Preview",print:"print",tag_p:"Paragraph",tag_div:"Normal (DIV)",tag_h:"Header",tag_blockquote:"Quote",tag_pre:"Code",template:"Template",lineHeight:"Line height",paragraphStyle:"Paragraph style",textStyle:"Text style"},dialogBox:{linkBox:{title:"Insert Link",url:"URL to link",text:"Text to display",newWindowCheck:"Open in new window"},mathBox:{title:"Math",inputLabel:"Mathematical Notation",fontSizeLabel:"Font Size",previewLabel:"Preview"},imageBox:{title:"Insert image",file:"Select from files",url:"Image URL",altText:"Alternative text"},videoBox:{title:"Insert Video",url:"Media embed URL, YouTube"},caption:"Insert description",close:"Close",submitButton:"Submit",revertButton:"Revert",proportion:"Constrain proportions",basic:"Basic",left:"Left",right:"Right",center:"Center",width:"Width",height:"Height",size:"Size",ratio:"Ratio"},controller:{edit:"Edit",unlink:"Unlink",remove:"Remove",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",insertColumnBefore:"Insert column before",insertColumnAfter:"Insert column after",deleteColumn:"Delete column",fixedColumnWidth:"Fixed column width",resize100:"Resize 100%",resize75:"Resize 75%",resize50:"Resize 50%",resize25:"Resize 25%",autoSize:"Auto size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",rotateLeft:"Rotate left",rotateRight:"Rotate right",maxSize:"Max size",minSize:"Min size",tableHeader:"Table header",mergeCells:"Merge cells",splitCells:"Split Cells",HorizontalSplit:"Horizontal split",VerticalSplit:"Vertical split"},menu:{spaced:"Spaced",bordered:"Bordered",neon:"Neon",translucent:"Translucent",shadow:"Shadow"}};return void 0===t&&(e.SUNEDITOR_LANG||(e.SUNEDITOR_LANG={}),e.SUNEDITOR_LANG.en=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_LANG a window with a document");return l(e)}:l(i)},WUQj:function(e,t,n){},XJR1:function(e,t,n){"use strict";n.r(t);n("3FqI"),n("WUQj");var i={name:"colorPicker",add:function(e){const t=e.context;t.colorPicker={colorListHTML:"",_colorInput:"",_defaultColor:"#000",_styleProperty:"color",_currentColor:"",_colorList:[]};let n=this.createColorList(e,this._makeColorList);t.colorPicker.colorListHTML=n,n=null},createColorList:function(e,t){const n=e.context.option,i=e.lang,l=n.colorList&&0!==n.colorList.length?n.colorList:["#ff0000","#ff5e00","#ffe400","#abf200","#00d8ff","#0055ff","#6600ff","#ff00dd","#000000","#ffd8d8","#fae0d4","#faf4c0","#e4f7ba","#d4f4fa","#d9e5ff","#e8d9ff","#ffd9fa","#f1f1f1","#ffa7a7","#ffc19e","#faed7d","#cef279","#b2ebf4","#b2ccff","#d1b2ff","#ffb2f5","#bdbdbd","#f15f5f","#f29661","#e5d85c","#bce55c","#5cd1e5","#6699ff","#a366ff","#f261df","#8c8c8c","#980000","#993800","#998a00","#6b9900","#008299","#003399","#3d0099","#990085","#353535","#670000","#662500","#665c00","#476600","#005766","#002266","#290066","#660058","#222222"];let s=[],o='
    ';for(let e,n=0,i=l.length;n0&&(o+='
    '+t(s)+"
    ",s=[]),"object"==typeof e&&(o+='
    '+t(e)+"
    ")));return o+='
    ",o},_makeColorList:function(e){let t="";t+='
      ';for(let n,i=0,l=e.length;i');return t+="
    ",t},init:function(e,t){const n=this.plugins.colorPicker;let i=t||(n.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor);i=n.isHexColor(i)?i:n.rgb2hex(i)||i;const l=this.context.colorPicker._colorList;if(l)for(let e=0,t=l.length;e=3&&"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).substr(1)}},l={name:"fontColor",display:"submenu",add:function(e,t){e.addModule([i]);const n=e.context;n.fontColor={previewEl:null,colorInput:null,colorList:null};let l=this.setSubmenu.call(e);n.fontColor.colorInput=l.querySelector("._se_color_picker_input"),n.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),l.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),l.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),l.addEventListener("click",this.pickup.bind(e)),n.fontColor.colorList=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null},setSubmenu:function(){const e=this.context.colorPicker.colorListHTML,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker,t=this.context.fontColor;e._colorInput=t.colorInput,e._defaultColor="#333333",e._styleProperty="color",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"],null,null),this.submenuOff()}},s={name:"hiliteColor",display:"submenu",add:function(e,t){e.addModule([i]);const n=e.context;n.hiliteColor={previewEl:null,colorInput:null,colorList:null};let l=this.setSubmenu.call(e);n.hiliteColor.colorInput=l.querySelector("._se_color_picker_input"),n.hiliteColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),l.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),l.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),l.addEventListener("click",this.pickup.bind(e)),n.hiliteColor.colorList=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null},setSubmenu:function(){const e=this.context.colorPicker.colorListHTML,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker,t=this.context.hiliteColor;e._colorInput=t.colorInput,e._defaultColor="#FFFFFF",e._styleProperty="backgroundColor",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.hiliteColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.hiliteColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["background-color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.backgroundColor=e,this.nodeChange(t,["background-color"],null,null),this.submenuOff()}},o={name:"template",display:"submenu",add:function(e,t){e.context.template={};let n=this.setSubmenu.call(e);n.querySelector("ul").addEventListener("click",this.pickup.bind(e)),e.initMenuTarget(this.name,t,n),n=null},setSubmenu:function(){const e=this.context.option.templates;if(!e||0===e.length)throw Error('[SUNEDITOR.plugins.template.fail] To use the "template" plugin, please define the "templates" option.');const t=this.util.createElement("DIV");t.className="se-list-layer";let n='
      ';for(let t,i=0,l=e.length;i";return n+="
    ",t.innerHTML=n,t},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=this.context.option.templates[e.target.getAttribute("data-value")];if(!t.html)throw this.submenuOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.setContents(t.html),this.submenuOff()}},a=n("1kvd"),r=n.n(a),c={name:"link",display:"dialog",add:function(e){e.addModule([r.a]);const t=e.context;t.link={focusElement:null,linkNewWindowCheck:null,linkAnchorText:null,_linkAnchor:null};let n=this.setDialog.call(e);t.link.modal=n,t.link.focusElement=n.querySelector("._se_link_url"),t.link.linkAnchorText=n.querySelector("._se_link_text"),t.link.linkNewWindowCheck=n.querySelector("._se_link_check");let i=this.setController_LinkButton.call(e);t.link.linkController=i,t.link._linkAnchor=null,i.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1),n.querySelector(".se-btn-primary").addEventListener("click",this.submit.bind(e)),i.addEventListener("click",this.onClick_linkController.bind(e)),t.dialog.modal.appendChild(n),t.element.relative.appendChild(i),n=null,i=null},setDialog:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-dialog-content",t.style.display="none",t.innerHTML='",t},setController_LinkButton:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-link",n.innerHTML='
    ",n},open:function(){this.plugins.dialog.open.call(this,"link","link"===this.currentControllerName)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=function(){if(0===this.context.link.focusElement.value.trim().length)return!1;const e=this.context.link,t=e.focusElement.value,n=e.linkAnchorText,i=0===n.value.length?t:n.value;if(this.context.dialog.updateModal){e._linkAnchor.href=t,e._linkAnchor.textContent=i,e._linkAnchor.target=e.linkNewWindowCheck.checked?"_blank":"";const n=e._linkAnchor.childNodes[0];this.setRange(n,0,n,n.textContent.length)}else{const n=this.util.createElement("A");n.href=t,n.textContent=i,n.target=e.linkNewWindowCheck.checked?"_blank":"";const l=this.getSelectedElements();if(l.length>1){const e=this.util.createElement(l[0].nodeName);e.appendChild(n),this.insertNode(e)}else this.insertNode(n);this.setRange(n.childNodes[0],0,n.childNodes[0],n.textContent.length)}this.history.push(!1),e.focusElement.value="",e.linkAnchorText.value=""}.bind(this);try{t()}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.focus()}return!1},active:function(e){if(e){if(this.util.isAnchor(e)&&null===e.getAttribute("data-image-link"))return this.controllerArray.indexOf(this.context.link.linkController)<0&&this.plugins.link.call_controller.call(this,e),!0}else this.controllerArray.indexOf(this.context.link.linkController)>-1&&this.controllersOff();return!1},on:function(e){e?this.context.link._linkAnchor&&(this.context.dialog.updateModal=!0,this.context.link.focusElement.value=this.context.link._linkAnchor.href,this.context.link.linkAnchorText.value=this.context.link._linkAnchor.textContent,this.context.link.linkNewWindowCheck.checked=!!/_blank/i.test(this.context.link._linkAnchor.target)):(this.plugins.link.init.call(this),this.context.link.linkAnchorText.value=this.getSelection().toString())},call_controller:function(e){this.editLink=this.context.link._linkAnchor=e;const t=this.context.link.linkController,n=t.querySelector("a");n.href=e.href,n.title=e.textContent,n.textContent=e.textContent;const i=this.util.getOffset(e,this.context.element.wysiwygFrame);t.style.top=i.top+e.offsetHeight+10+"px",t.style.left=i.left-this.context.element.wysiwygFrame.scrollLeft+"px",t.style.display="block";const l=this.context.element.wysiwygFrame.offsetWidth-(t.offsetLeft+t.offsetWidth);l<0?(t.style.left=t.offsetLeft+l+"px",t.firstElementChild.style.left=20-l+"px"):t.firstElementChild.style.left="20px",this.controllersOn(t,e,"link")},onClick_linkController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");if(t){if(e.preventDefault(),/update/.test(t)){const e=this.context.link;e.focusElement.value=e._linkAnchor.href,e.linkAnchorText.value=e._linkAnchor.textContent,e.linkNewWindowCheck.checked=!!/_blank/i.test(e._linkAnchor.target),this.plugins.dialog.open.call(this,"link",!0)}else if(/unlink/.test(t)){const e=this.util.getChildElement(this.context.link._linkAnchor,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!1),t=this.util.getChildElement(this.context.link._linkAnchor,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!0);this.setRange(e,0,t,t.textContent.length),this.nodeChange(null,null,["A"],!1)}else this.util.removeItem(this.context.link._linkAnchor),this.context.link._linkAnchor=null,this.focus(),this.history.push(!1);this.controllersOff()}},init:function(){const e=this.context.link;e.linkController.style.display="none",e._linkAnchor=null,e.focusElement.value="",e.linkAnchorText.value="",e.linkNewWindowCheck.checked=!1}},d=n("ee5k"),u=n.n(d),h={blockquote:{name:"blockquote",display:"command",add:function(e,t){e.context.blockquote={targetButton:t,tag:e.util.createElement("BLOCKQUOTE")}},active:function(e){if(e){if(/blockquote/i.test(e.nodeName))return this.util.addClass(this.context.blockquote.targetButton,"active"),!0}else this.util.removeClass(this.context.blockquote.targetButton,"active");return!1},action:function(){const e=this.util.getParentElement(this.getSelectionNode(),"blockquote");e?this.detachRangeFormatElement(e,null,null,!1,!1):this.applyRangeFormatElement(this.context.blockquote.tag.cloneNode(!1))}},align:{name:"align",display:"submenu",add:function(e,t){const n=e.icons,i=e.context;i.align={targetButton:t,_alignList:null,currentAlign:"",icons:{justify:n.align_justify,left:n.align_left,right:n.align_right,center:n.align_center}};let l=this.setSubmenu.call(e),s=l.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),i.align._alignList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,l),l=null,s=null},setSubmenu:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-list-layer",n.innerHTML='
    ",n},active:function(e){const t=this.context.align.targetButton,n=t.querySelector("svg");if(e){if(this.util.isFormatElement(e)){const i=e.style.textAlign;if(i)return this.util.changeElement(n,this.context.align.icons[i]),t.setAttribute("data-focus",i),!0}}else this.util.changeElement(n,this.context.align.icons.left),t.removeAttribute("data-focus");return!1},on:function(){const e=this.context.align,t=e._alignList,n=e.targetButton.getAttribute("data-focus")||"left";if(n!==e.currentAlign){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(s=0,o=a.length;s";return r+="",n.innerHTML=r,n},active:function(e){const t=this.context.font.targetText,n=this.context.font.targetTooltip;if(e){if(e.style&&e.style.fontFamily.length>0){const i=e.style.fontFamily.replace(/["']/g,"");return this.util.changeTxt(t,i),this.util.changeTxt(n,i),!0}}else{const e=this.lang.toolbar.font;this.util.changeTxt(t,e),this.util.changeTxt(n,e)}return!1},on:function(){const e=this.context.font,t=e._fontList,n=e.targetText.textContent;if(n!==e.currentFont){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(let t,n=0,s=e.fontSizeUnit,o=i.length;n";return l+="",n.innerHTML=l,n},active:function(e){if(e){if(e.style&&e.style.fontSize.length>0)return this.util.changeTxt(this.context.fontSize.targetText,e.style.fontSize),!0}else this.util.changeTxt(this.context.fontSize.targetText,this.lang.toolbar.fontSize);return!1},on:function(){const e=this.context.fontSize,t=e._sizeList,n=e.targetText.textContent;if(n!==e.currentSize){for(let e=0,i=t.length;e
  • ",t},appendHr:function(e){const t=this.util.createElement("HR");t.className=e,this.focus();let n=this.insertComponent(t,!1);this.setRange(n,0,n,0)},horizontalRulePick:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!n&&!/UL/i.test(t.tagName);)n=t.getAttribute("data-value"),t=t.parentNode;n&&(this.plugins.horizontalRule.appendHr.call(this,"__se__"+n),this.submenuOff())}},list:{name:"list",display:"submenu",add:function(e,t){const n=e.context;n.list={targetButton:t,_list:null,currentList:"",icons:{bullets:e.icons.list_bullets,number:e.icons.list_number}};let i=this.setSubmenu.call(e),l=i.querySelector("ul");l.addEventListener("click",this.pickup.bind(e)),n.list._list=l.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,l=null},setSubmenu:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-submenu se-list-layer",t.innerHTML='
    ",t},active:function(e){const t=this.context.list.targetButton,n=t.querySelector("svg"),i=this.util;if(e){if(i.isList(e)){const l=e.nodeName;return t.setAttribute("data-focus",l),i.addClass(t,"active"),/UL/i.test(l)?i.changeElement(n,this.context.list.icons.bullets):i.changeElement(n,this.context.list.icons.number),!0}}else t.removeAttribute("data-focus"),i.changeElement(n,this.context.list.icons.number),i.removeClass(t,"active");return!1},on:function(){const e=this.context.list,t=e._list,n=e.targetButton.getAttribute("data-focus")||"";if(n!==e.currentList){for(let e=0,i=t.length;e"),t.innerHTML+=n.outerHTML,e&&(t.innerHTML+="
    ")}else{const e=n.childNodes;for(;e[0];)t.appendChild(e[0])}c.appendChild(t),a||(u=c),a&&m===g&&!l.isRangeFormatElement(f)||(d||(d=c),s&&a&&m===g||a&&l.isList(g)&&g===r||c.parentNode!==m&&m.insertBefore(c,f)),l.removeItem(n),s&&null===h&&(h=c.children.length-1),a&&(l.getRangeFormatElement(g,p)!==l.getRangeFormatElement(r,p)||l.isList(g)&&l.isList(r)&&l.getElementDepth(g)!==l.getElementDepth(r))&&(c=l.createElement(e)),_&&0===_.children.length&&l.removeItem(_)}else l.removeItem(n);h&&(d=d.children[h]),o&&(g=c.children.length-1,c.innerHTML+=r.innerHTML,u=c.children[g],l.removeItem(r))}else{if(n)for(let e=0,t=i.length;e=0;n--)if(i[n].contains(i[e])){i.splice(e,1),e--,t--;break}const t=l.getRangeFormatElement(s),o=t&&t.tagName===e;let a,r;const c=function(e){return!this.isComponent(e)}.bind(l);o||(r=l.createElement(e));for(let t,s,d=0,u=i.length;d0){const e=l.cloneNode(!1),t=l.childNodes,s=this.util.getPositionIndex(i);for(;t[s];)e.appendChild(t[s]);n.appendChild(e)}0===l.children.length&&this.util.removeItem(l),this.util.mergeSameTags(o);const a=this.util.getEdgeChildNodes(t,n);return{cc:t.parentNode,sc:a.sc,ec:a.ec}},editInsideList:function(e,t){const n=(t=t||this.getSelectedElements().filter(function(e){return this.isListCell(e)}.bind(this.util))).length;if(0===n||!e&&!this.util.isListCell(t[0].previousElementSibling)&&!this.util.isListCell(t[n-1].nextElementSibling))return{sc:t[0],so:0,ec:t[n-1],eo:1};let i=t[0].parentNode,l=t[n-1],s=null;if(e){if(i!==l.parentNode&&this.util.isList(l.parentNode.parentNode)&&l.nextElementSibling)for(l=l.nextElementSibling;l;)t.push(l),l=l.nextElementSibling;s=this.plugins.list.editList.call(this,i.nodeName.toUpperCase(),t,!0)}else{let e=this.util.createElement(i.nodeName),o=t[0].previousElementSibling,a=l.nextElementSibling;const r={s:null,e:null,sl:i,el:i};for(let l,s=0,c=n;s span > span"),n.table.columnFixedButton=s.querySelector("._se_table_fixed_column"),n.table.headerButton=s.querySelector("._se_table_header"),s.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1);let o=this.setController_tableEditor.call(e);n.table.resizeDiv=o,n.table.splitMenu=o.querySelector(".se-btn-group-sub"),n.table.mergeButton=o.querySelector("._se_table_merge_button"),n.table.splitButton=o.querySelector("._se_table_split_button"),n.table.insertRowAboveButton=o.querySelector("._se_table_insert_row_a"),n.table.insertRowBelowButton=o.querySelector("._se_table_insert_row_b"),o.addEventListener("mousedown",(function(e){e.stopPropagation()}),!1),l.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(e)),l.addEventListener("click",this.appendTable.bind(e)),o.addEventListener("click",this.onClick_tableController.bind(e)),s.addEventListener("click",this.onClick_tableController.bind(e)),e.initMenuTarget(this.name,t,i),n.element.relative.appendChild(o),n.element.relative.appendChild(s),i=null,l=null,o=null,s=null},setSubmenu:function(){const e=this.util.createElement("DIV");return e.className="se-submenu se-selector-table",e.innerHTML='
    1 x 1
    ',e},setController_table:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-table",n.innerHTML='
    ",n},setController_tableEditor:function(){const e=this.lang,t=this.icons,n=this.util.createElement("DIV");return n.className="se-controller se-controller-table-cell",n.innerHTML='
    • '+e.controller.VerticalSplit+'
    • '+e.controller.HorizontalSplit+"
    ",n},appendTable:function(){const e=this.util.createElement("TABLE"),t=this.plugins.table.createCells,n=this.context.table._tableXY[0];let i=this.context.table._tableXY[1],l="";for(;i>0;)l+=""+t.call(this,"td",n)+"",--i;l+="",e.innerHTML=l,this.insertComponent(e,!1);const s=e.querySelector("td div");this.setRange(s,0,s,0),this.plugins.table.reset_table_picker.call(this)},createCells:function(e,t,n){if(e=e.toLowerCase(),n){const t=this.util.createElement(e);return t.innerHTML="

    ",t}{let n="";for(;t>0;)n+="<"+e+">

    ",t--;return n}},onMouseMove_tablePicker:function(e){e.stopPropagation();let t=this._w.Math.ceil(e.offsetX/18),n=this._w.Math.ceil(e.offsetY/18);t=t<1?1:t,n=n<1?1:n,this.context.table.tableHighlight.style.width=t+"em",this.context.table.tableHighlight.style.height=n+"em";this.context.table.tableUnHighlight.style.width="10em",this.context.table.tableUnHighlight.style.height="10em",this.util.changeTxt(this.context.table.tableDisplay,t+" x "+n),this.context.table._tableXY=[t,n]},reset_table_picker:function(){if(!this.context.table.tableHighlight)return;const e=this.context.table.tableHighlight.style,t=this.context.table.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="10em",t.height="10em",this.util.changeTxt(this.context.table.tableDisplay,"1 x 1"),this.submenuOff()},init:function(){const e=this.context.table,t=this.plugins.table;if(t._removeEvents.call(this),t._selectedTable){const e=t._selectedTable.querySelectorAll(".se-table-selected-cell");for(let t=0,n=e.length;t0)for(let e,t=0;ts||(u>=e.index?(i+=e.cs,u+=e.cs,e.rs-=1,e.row=s+1,e.rs<1&&(r.splice(t,1),t--)):h===g-1&&(e.rs-=1,e.row=s+1,e.rs<1&&(r.splice(t,1),t--)));if(s===o&&h===l){n._logical_cellIndex=u;break}d>0&&a.push({index:u,cs:c+1,rs:d,row:-1}),i+=c}r=r.concat(a).sort((function(e,t){return e.index-t.index})),a=[]}a=null,r=null}},editTable:function(e,t){const n=this.plugins.table,i=this.context.table,l=i._element,s="row"===e;if(s){const e=i._trElement.parentNode;if(/^THEAD$/i.test(e.nodeName)){if("up"===t)return;if(!e.nextElementSibling||!/^TBODY$/i.test(e.nextElementSibling.nodeName))return void(l.innerHTML+=""+n.createCells.call(this,"td",i._logical_cellCnt,!1)+"")}}if(n._ref){const e=i._tdElement,l=n._selectedCells;if(s)if(t)n.setCellInfo.call(this,"up"===t?l[0]:l[l.length-1],!0),n.editRow.call(this,t,e);else{let e=l[0].parentNode;const i=[l[0]];for(let t,n=1,s=l.length;no&&o>t&&(e[l].rowSpan=n+a,c-=i)}if(i){const e=r[s+1];if(e){const t=[];let n=r[s].cells,i=0;for(let e,l,s=0,o=n.length;s1&&(e.rowSpan-=1,t.push({cell:e.cloneNode(!1),index:l}));if(t.length>0){let l=t.shift();n=e.cells,i=0;for(let s,o,a=0,r=n.length;a=l.index)||(a--,i--,i+=l.cell.colSpan-1,e.insertBefore(l.cell,s),l=t.shift(),l));a++);if(l){e.appendChild(l.cell);for(let n=0,i=t.length;n0){const e=!s[b+1];for(let t,n=0;n_||(p>=t.index?(f+=t.cs,p=b+f,t.rs-=1,t.row=_+1,t.rs<1&&(d.splice(n,1),n--)):e&&(t.rs-=1,t.row=_+1,t.rs<1&&(d.splice(n,1),n--)))}n>0&&c.push({rs:n,cs:r+1,index:p,row:-1}),p>=t&&p+r<=t+o?h.push(e):p<=t+o&&p+r>=t?e.colSpan-=i.getOverlapRangeAtIndex(a,a+o,p,p+r):n>0&&(pt+o)&&g.push({cell:e,i:_,rs:_+n}),f+=r}else{if(b>=t)break;if(r>0){if(u<1&&r+b>=t){e.colSpan+=1,t=null,u=n+1;break}t-=r}if(!m){for(let e,n=0;n0){u-=1;continue}null!==t&&s.length>0&&(p=this.plugins.table.createCells.call(this,s[0].nodeName,0,!0),p=e.insertBefore(p,s[t]))}}if(l){let e,t;for(let n,l=0,s=h.length;l1)c.colSpan=this._w.Math.floor(e/2),l.colSpan=e-c.colSpan,o.insertBefore(c,l.nextElementSibling);else{let t=[],n=[];for(let o,r,c=0,d=i._rowCnt;c0)for(let e,t=0;tc||(u>=e.index?(r+=e.cs,u+=e.cs,e.rs-=1,e.row=c+1,e.rs<1&&(n.splice(t,1),t--)):h===g-1&&(e.rs-=1,e.row=c+1,e.rs<1&&(n.splice(t,1),t--)));if(u<=a&&d>0&&t.push({index:u,cs:s+1,rs:d,row:-1}),i!==l&&u<=a&&u+s>=a+e-1){i.colSpan+=1;break}if(u>a)break;r+=s}n=n.concat(t).sort((function(e,t){return e.index-t.index})),t=[]}o.insertBefore(c,l.nextElementSibling)}}else{const e=l.rowSpan;if(c.colSpan=l.colSpan,e>1){c.rowSpan=this._w.Math.floor(e/2);const n=e-c.rowSpan,i=[],r=t.getArrayIndex(s,o)+n;for(let e,t,n=0;n=a));c++)l=e[c],s=l.rowSpan-1,s>0&&s+n>=r&&o=h.index&&(r+=h.cs,l+=h.cs,h=i.shift()),l>=a||s===o-1){d.insertBefore(c,e.nextElementSibling);break}r+=t}l.rowSpan=n}else{c.rowSpan=l.rowSpan;const e=t.createElement("TR");e.appendChild(c);for(let e,t=0;t=r&&(e[n].rowSpan+=1)}const n=i._physical_cellIndex,a=o.cells;for(let e=0,t=a.length;e0&&o+s>=i&&(e.rowSpan-=n.getOverlapRangeAtIndex(i,l,o,o+s));else s.push(e[o]);for(let e=0,t=s.length;e"+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"",i.insertBefore(t,i.firstElementChild)}e.toggleClass(t,"active"),/TH/i.test(this.context.table._tdElement.nodeName)?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,this.context.table._tdElement,!1)},setTableStyle:function(e){const t=this.context.table,n=t._element;let i,l,s,o;e.indexOf("width")>-1&&(i=t.resizeButton.querySelector("svg"),l=t.resizeText,t._maxWidth?(s=t.icons.reduction,o=t.minText,t.columnFixedButton.style.display="block",this.util.removeClass(n,"se-table-size-auto"),this.util.addClass(n,"se-table-size-100")):(s=t.icons.expansion,o=t.maxText,t.columnFixedButton.style.display="none",this.util.removeClass(n,"se-table-size-100"),this.util.addClass(n,"se-table-size-auto")),this.util.changeElement(i,s),this.util.changeTxt(l,o)),e.indexOf("column")>-1&&(t._fixedColumn?(this.util.removeClass(n,"se-table-layout-auto"),this.util.addClass(n,"se-table-layout-fixed"),this.util.addClass(t.columnFixedButton,"active")):(this.util.removeClass(n,"se-table-layout-fixed"),this.util.addClass(n,"se-table-layout-auto"),this.util.removeClass(t.columnFixedButton,"active")))},setActiveButton:function(e,t){const n=this.context.table;/^TH$/i.test(e.nodeName)?(n.insertRowAboveButton.setAttribute("disabled",!0),n.insertRowBelowButton.setAttribute("disabled",!0)):(n.insertRowAboveButton.removeAttribute("disabled"),n.insertRowBelowButton.removeAttribute("disabled")),t&&e!==t?(n.splitButton.setAttribute("disabled",!0),n.mergeButton.removeAttribute("disabled")):(n.splitButton.removeAttribute("disabled"),n.mergeButton.setAttribute("disabled",!0))},_bindOnSelect:null,_bindOffSelect:null,_bindOffShift:null,_selectedCells:null,_shift:!1,_fixedCell:null,_fixedCellName:null,_selectedCell:null,_selectedTable:null,_ref:null,_toggleEditor:function(e){this.context.element.wysiwyg.setAttribute("contenteditable",e),e?this.util.removeClass(this.context.element.wysiwyg,"se-disabled"):this.util.addClass(this.context.element.wysiwyg,"se-disabled")},_offCellMultiSelect:function(e){e.stopPropagation();const t=this.plugins.table;t._shift?t._initBind&&(this._wd.removeEventListener("touchmove",t._initBind),t._initBind=null):(t._removeEvents.call(this),t._toggleEditor.call(this,!0)),t._fixedCell&&t._selectedTable&&(t.setActiveButton.call(this,t._fixedCell,t._selectedCell),t.call_controller_tableEdit.call(this,t._selectedCell||t._fixedCell),t._selectedCells=t._selectedTable.querySelectorAll(".se-table-selected-cell"),t._selectedCell&&t._fixedCell&&this.focusEdge(t._selectedCell),t._shift||(t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null))},_onCellMultiSelect:function(e){this._antiBlur=!0;const t=this.plugins.table,n=this.util.getParentElement(e.target,this.util.isCell);if(t._shift)n===t._fixedCell?t._toggleEditor.call(this,!0):t._toggleEditor.call(this,!1);else if(!t._ref){if(n===t._fixedCell)return;t._toggleEditor.call(this,!1)}n&&n!==t._selectedCell&&t._fixedCellName===n.nodeName&&t._selectedTable===this.util.getParentElement(n,"TABLE")&&(t._selectedCell=n,t._setMultiCells.call(this,t._fixedCell,n))},_setMultiCells:function(e,t){const n=this.plugins.table,i=n._selectedTable.rows,l=this.util,s=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let e=0,t=s.length;e0)for(let e,t=0;td||(u>=e.index?(s+=e.cs,u+=e.cs,e.rs-=1,e.row=d+1,e.rs<1&&(a.splice(t,1),t--)):p===m-1&&(e.rs-=1,e.row=d+1,e.rs<1&&(a.splice(t,1),t--)));if(o){if(i!==e&&i!==t||(c.cs=null!==c.cs&&c.csu+h?c.ce:u+h,c.rs=null!==c.rs&&c.rsd+g?c.re:d+g,c._i+=1),2===c._i){o=!1,a=[],r=[],d=-1;break}}else if(l.getOverlapRangeAtIndex(c.cs,c.ce,u,u+h)&&l.getOverlapRangeAtIndex(c.rs,c.re,d,d+g)){const e=c.csu+h?c.ce:u+h,n=c.rsd+g?c.re:d+g;if(c.cs!==e||c.ce!==t||c.rs!==n||c.re!==s){c.cs=e,c.ce=t,c.rs=n,c.re=s,d=-1,a=[],r=[];break}l.addClass(i,"se-table-selected-cell")}g>0&&r.push({index:u,cs:h+1,rs:g,row:-1}),s+=i.colSpan-1}a=a.concat(r).sort((function(e,t){return e.index-t.index})),r=[]}},_removeEvents:function(){const e=this.plugins.table;e._initBind&&(this._wd.removeEventListener("touchmove",e._initBind),e._initBind=null),e._bindOnSelect&&(this._wd.removeEventListener("mousedown",e._bindOnSelect),this._wd.removeEventListener("mousemove",e._bindOnSelect),e._bindOnSelect=null),e._bindOffSelect&&(this._wd.removeEventListener("mouseup",e._bindOffSelect),e._bindOffSelect=null),e._bindOffShift&&(this._wd.removeEventListener("keyup",e._bindOffShift),e._bindOffShift=null)},_initBind:null,onTableCellMultiSelect:function(e,t){const n=this.plugins.table;n._removeEvents.call(this),this.controllersOff(),n._shift=t,n._fixedCell=e,n._fixedCellName=e.nodeName,n._selectedTable=this.util.getParentElement(e,"TABLE");const i=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let e=0,t=i.length;e-1?(n=e.toLowerCase(),o="blockquote"===n?"range":"pre"===n?"free":"replace",r=/^h/.test(n)?n.match(/\d+/)[0]:"",a=t["tag_"+(r?"h":n)]+r,d="",c=""):(n=e.tag.toLowerCase(),o=e.command,a=e.name||n,d=e.class,c=d?' class="'+d+'"':""),s+='
  • ";return s+="",n.innerHTML=s,n},active:function(e){let t=this.lang.toolbar.formats;const n=this.context.formatBlock.targetText,i=this.context.formatBlock.targetTooltip;if(e){if(this.util.isFormatElement(e)){const l=this.context.formatBlock._formatList,s=e.nodeName.toLowerCase(),o=(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let e,n=0,i=l.length;n=0;u--)if(i=p[u],i!==(p[u+1]?p[u+1].parentNode:null)){if(d=a.isComponent(i),s=d?"":i.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),o=a.getParentElement(i,(function(e){return e.parentNode===t})),(t!==i.parentNode||d)&&(a.isFormatElement(t)?(t.parentNode.insertBefore(n,t.nextSibling),t=t.parentNode):(t.insertBefore(n,o?o.nextSibling:null),t=i.parentNode),r=n.nextSibling,r&&n.nodeName===r.nodeName&&a.isSameAttributes(n,r)&&(n.innerHTML+="
    "+r.innerHTML,a.removeItem(r)),n=l.cloneNode(!1),h=!0),c=n.innerHTML,n.innerHTML=(h||!s||!c||/
    $/i.test(s)?s:s+"
    ")+c,0===u){t.insertBefore(n,i),r=i.nextSibling,r&&n.nodeName===r.nodeName&&a.isSameAttributes(n,r)&&(n.innerHTML+="
    "+r.innerHTML,a.removeItem(r));const e=n.previousSibling;e&&n.nodeName===e.nodeName&&a.isSameAttributes(n,e)&&(e.innerHTML+="
    "+n.innerHTML,a.removeItem(n))}d||a.removeItem(i),s&&(h=!1)}this.setRange(i,0,i,0)}else{for(let e,t,n=0,o=p.length;n('+t.toolbar.default+")";for(let e,t=0,n=i.length;t";return l+="",n.innerHTML=l,n},on:function(){const e=this.context.lineHeight,t=e._sizeList,n=this.util.getFormatElement(this.getSelectionNode()).style.lineHeight+"";if(n!==e.currentSize){for(let e=0,i=t.length;e"}return s+="",t.innerHTML=s,t},on:function(){const e=this.context.paragraphStyle._classList,t=this.util.getFormatElement(this.getSelectionNode());for(let n=0,i=e.length;n"}return l+="",t.innerHTML=l,t},on:function(){const e=this.util,t=this.context.textStyle._styleList,n=this.getSelectionNode();for(let i,l,s,o=0,a=t.length;o'+this.icons.cancel+''+t.dialogBox.imageBox.title+'
    ';if(e.imageFileInput&&(i+='
    "),e.imageUrlInput&&(i+='
    '),i+='
    ',e.imageResizing){const n=e.imageSizeOnlyPercentage,l=n?' style="display: none !important;"':"",s=e.imageHeightShow?"":' style="display: none !important;"';i+='
    ',n||!e.imageHeightShow?i+='
    ":i+='
    ",i+=' '+t.dialogBox.proportion+'
    "}return i+='
    ",n.innerHTML=i,n},_fileInputChange:function(){this.imgInputFile.value?this.imgUrlFile.setAttribute("disabled",!0):this.imgUrlFile.removeAttribute("disabled")},_removeSelectedFiles:function(e,t){e.value="",t&&t.removeAttribute("disabled")},open:function(){this.plugins.dialog.open.call(this,"image","image"===this.currentControllerName)},openTab:function(e){const t=this.context.image.modal,n="init"===e?t.querySelector("._se_tab_link"):e.target;if(!/^BUTTON$/i.test(n.tagName))return!1;const i=n.getAttribute("data-tab-link");let l,s,o;for(s=t.getElementsByClassName("_se_tab_content"),l=0;l0){let t=0;const n=[];for(let i=0,l=e.length;i0){let e=0;const n=this.context.image._imagesInfo;for(let t=0,i=n.length;ti){const n="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+i/1e3+"KB";return this._imageUploadError(n,{limitSize:i,currentSize:e,uploadSize:t})&&this.functions.noticeOpen(n),void this.closeLoading()}}const l=this.context.image;l._uploadFileLength=n.length;const s=this.context.option.imageUploadUrl,o=this.context.option.imageUploadHeader,a=this.context.dialog.updateModal?1:n.length,r={linkValue:l._linkValue,linkNewWindow:l.imgLinkNewWindowCheck.checked,inputWidth:l.inputX.value,inputHeight:l.inputY.value,align:l._align,isUpdate:this.context.dialog.updateModal,currentImage:l._element};if(!this._imageUploadBefore(n,r))return;if("string"==typeof s&&s.length>0){const e=new FormData;for(let t=0;t0)for(let e in o)l._xmlHttp.setRequestHeader(e,o[e]);l._xmlHttp.send(e)}else for(let e=0;e0){const i=this.util.createElement("A");return i.href=/^https?:\/\//.test(t)?t:"http://"+t,i.target=n?"_blank":"",i.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t),i.appendChild(e),i}return e},setInputSize:function(e,t){t&&32===t.keyCode?t.preventDefault():this.plugins.resizing._module_setInputSize.call(this,this.context.image,e)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.image)},submit:function(e){const t=this.context.image,n=this.plugins.image;this.showLoading(),e.preventDefault(),e.stopPropagation(),t._linkValue=t.imgLink.value,t._altText=t.altText.value,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked,t._resizing&&(t._proportionChecked=t.proportion.checked);try{this.context.dialog.updateModal&&n.update_image.call(this,!1,!1,!1),t.imgInputFile&&t.imgInputFile.files.length>0?n.onRender_imgInput.call(this):t.imgUrlFile&&t.imgUrlFile.value.trim().length>0?n.onRender_imgUrl.call(this):this.closeLoading()}catch(e){throw this.closeLoading(),Error('[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},setImagesInfo:function(e,t){const n=this.context.resizing._resize_plugin;this.context.resizing._resize_plugin="image";const i=this.context.image._imagesInfo;let l=e.getAttribute("data-index"),s=null,o="";if(!l||this._componentsInfoInit)o="create",l=this.context.image._imageIndex++,e.setAttribute("data-index",l),e.setAttribute("data-file-name",t.name),e.setAttribute("data-file-size",t.size),s={src:e.src,index:1*l,name:t.name,size:t.size},i.push(s);else{o="update",l*=1;for(let e=0,t=i.length;e-1||(n.splice(t,1),this._imageUpload(null,e,"delete",null,0),t--);this.context.resizing._resize_plugin=i},resetComponentInfo:function(){this.context.image._imagesInfo=[],this.context.image._imageIndex=0},create_image:function(e,t,n,i,l,s,o){const a=this.context.image;this.context.resizing._resize_plugin="image";let r=this.util.createElement("IMG");r.src=e,r.alt=a._altText,r=this.plugins.image.onRender_link.call(this,r,t,n),r.setAttribute("data-rotate","0"),a._resizing&&r.setAttribute("data-proportion",a._proportionChecked);const c=this.plugins.resizing.set_cover.call(this,r),d=this.plugins.resizing.set_container.call(this,c,"se-image-container");a._captionChecked&&(a._caption=this.plugins.resizing.create_caption.call(this),a._caption.setAttribute("contenteditable",!1),c.appendChild(a._caption)),a._element=r,a._cover=c,a._container=d,this.plugins.image.applySize.call(this,i,l),this.plugins.image.setAlign.call(this,s,r,c,d),this.insertComponent(d,!0),this.plugins.image.setImagesInfo.call(this,r,o||{name:r.getAttribute("data-file-name")||r.src.split("/").pop(),size:r.getAttribute("data-file-size")||0}),this.context.resizing._resize_plugin=""},update_image:function(e,t,n){const i=this.context.image,l=i._linkValue;let s,o=i._element,a=i._cover,r=i._container,c=!1;null===a&&(c=!0,o=i._element.cloneNode(!0),a=this.plugins.resizing.set_cover.call(this,o)),null===r?(a=a.cloneNode(!0),o=a.querySelector("img"),c=!0,r=this.plugins.resizing.set_container.call(this,a,"se-image-container")):c&&(r.innerHTML="",r.appendChild(a));const d=this.util.isNumber(i.inputX.value)?i.inputX.value+i.sizeUnit:i.inputX.value,u=this.util.isNumber(i.inputY.value)?i.inputY.value+i.sizeUnit:i.inputY.value;if(s=/%$/.test(o.style.width)?d!==r.style.width||u!==r.style.height:d!==o.style.width||u!==o.style.height,o.alt=i._altText,i._captionChecked?i._caption||(i._caption=this.plugins.resizing.create_caption.call(this),a.appendChild(i._caption)):i._caption&&(this.util.removeItem(i._caption),i._caption=null),l.trim().length>0)if(null!==i._linkElement&&a.contains(i._linkElement))i._linkElement.href=l,i._linkElement.target=i.imgLinkNewWindowCheck.checked?"_blank":"",o.setAttribute("data-image-link",l);else{let e=this.plugins.image.onRender_link.call(this,o,l,this.context.image.imgLinkNewWindowCheck.checked);a.insertBefore(e,i._caption)}else if(null!==i._linkElement){const e=o;e.setAttribute("data-image-link","");let t=e.cloneNode(!0);a.removeChild(i._linkElement),a.insertBefore(t,i._caption),o=t}if(c){const e=this.util.isRangeFormatElement(i._element.parentNode)||this.util.isWysiwygDiv(i._element.parentNode)?i._element:/^A$/i.test(i._element.parentNode.nodeName)?i._element.parentNode:this.util.getFormatElement(i._element)||i._element;e.parentNode.replaceChild(r,e),o=r.querySelector("img"),i._element=o,i._cover=a,i._container=r}!i._onlyPercentage&&s&&!e&&(/\d+/.test(o.style.height)||this.context.resizing._rotateVertical&&i._captionChecked)&&(/%$/.test(i.inputX.value)||/%$/.test(i.inputY.value)?this.plugins.resizing.resetTransform.call(this,o):this.plugins.resizing.setTransformSize.call(this,o,this.util.getNumber(i.inputX.value,0),this.util.getNumber(i.inputY.value,0)));if(i._resizing&&(o.setAttribute("data-proportion",i._proportionChecked),s&&this.plugins.image.applySize.call(this)),this.plugins.image.setAlign.call(this,null,o,null,null),e&&this.plugins.image.setImagesInfo.call(this,o,{name:o.getAttribute("data-file-name")||o.src.split("/").pop(),size:o.getAttribute("data-file-size")||0}),t){this.plugins.image.init.call(this);const e=this.plugins.resizing.call_controller_resize.call(this,o,"image");this.plugins.image.onModifyMode.call(this,o,e)}n||this.history.push(!1)},update_src:function(e,t,n){t.src=e,this._w.setTimeout(this.plugins.image.setImagesInfo.bind(this,t,n))},onModifyMode:function(e,t){if(!e)return;const n=this.context.image;n._linkElement=/^A$/i.test(e.parentNode.nodeName)?e.parentNode:null,n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._align=e.getAttribute("data-align")||"none",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin");i?(i=i.split(","),n._origin_w=i[0],n._origin_h=i[1]):t&&(n._origin_w=t.w,n._origin_h=t.h)},openModify:function(e){const t=this.context.image;t.imgUrlFile.value=t._element.src,t._altText=t.altText.value=t._element.alt,t._linkValue=t.imgLink.value=null===t._linkElement?"":t._linkElement.href,t.imgLinkNewWindowCheck.checked=t._linkElement&&"_blank"===t._linkElement.target,t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]').checked=!0,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.image),e||this.plugins.dialog.open.call(this,"image",!0)},on:function(e){const t=this.context.image;e?t.imgInputFile&&t.imgInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.context.option.imageWidth===t._defaultSizeX?"":this.context.option.imageWidth,t.inputY.value=t._origin_h=this.context.option.imageHeight===t._defaultSizeY?"":this.context.option.imageHeight,t.imgInputFile&&t.imgInputFile.setAttribute("multiple","multiple"))},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.image)},applySize:function(e,t){const n=this.context.image;return e||(e=n.inputX.value),t||(t=n.inputY.value),n._onlyPercentage&&e||/%$/.test(e)?(this.plugins.image.setPercentSize.call(this,e,t),!0):(e&&"auto"!==e||t&&"auto"!==t?this.plugins.image.setSize.call(this,e,t,!1):this.plugins.image.setAutoSize.call(this),!1)},setSize:function(e,t,n,i){const l=this.context.image,s=/^(rw|lw)$/.test(i),o=/^(th|bh)$/.test(i);this.plugins.image.cancelPercentAttr.call(this),o||(l._element.style.width=this.util.isNumber(e)?e+l.sizeUnit:e),s||(l._element.style.height=this.util.isNumber(t)?t+l.sizeUnit:/%$/.test(t)?"":t),"center"===l._align&&this.plugins.image.setAlign.call(this,null,null,null,null),n||l._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,l)},setAutoSize:function(){const e=this.context.image;this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="",e._element.style.width="",e._element.style.height="",e._cover.style.width="",e._cover.style.height="",this.plugins.image.setAlign.call(this,null,null,null,null),e._element.setAttribute("data-percentage","auto,auto"),this.plugins.resizing._module_saveCurrentSize.call(this,e)},setOriginSize:function(){const e=this.context.image;e._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this);const t=(e._element.getAttribute("data-origin")||"").split(","),n=t[0],i=t[1];t&&(e._onlyPercentage||/%$/.test(n)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.image.setPercentSize.call(this,n,i):this.plugins.image.setSize.call(this,n,i),this.plugins.resizing._module_saveCurrentSize.call(this,e))},setPercentSize:function(e,t){const n=this.context.image;t=!t||/%$/.test(t)||this.util.getNumber(t,0)?this.util.isNumber(t)?t+n.sizeUnit:t||"":this.util.isNumber(t)?t+"%":t;const i=/%$/.test(t);n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=i?t:"",n._element.style.width="100%",n._element.style.height=i?"":t,n._element.style.maxWidth="","center"===n._align&&this.plugins.image.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing.setCaptionPosition.call(this,n._element),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.image;e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.image._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),"center"===e._align&&this.plugins.image.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const l=this.context.image;e||(e=l._align),t||(t=l._element),n||(n=l._cover),i||(i=l._container),n.style.margin=e&&"none"!==e?"auto":"0",/%$/.test(t.style.width)&&"center"===e?(i.style.minWidth="100%",n.style.width=i.style.width):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width&&"auto"!==t.style.width?t.style.width||"100%":""),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,l._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},resetAlign:function(){const e=this.context.image;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",this.util.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.image._element,n=this.util.getParentElement(t,this.util.isMediaComponent)||t,i=1*t.getAttribute("data-index");let l=n.previousElementSibling||n.nextElementSibling;const s=n.parentNode;if(this.util.removeItem(n),this.plugins.image.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,(function(e){return 0===e.childNodes.length}),null),this.focusEdge(l),i>=0){const e=this.context.image._imagesInfo;for(let t=0,n=e.length;t'+this.icons.cancel+''+t.dialogBox.videoBox.title+'
    ';if(e.videoResizing){const n=e.videoRatioList||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285}],l=e.videoRatio,s=e.videoSizeOnlyPercentage,o=s?' style="display: none !important;"':"",a=e.videoHeightShow?"":' style="display: none !important;"',r=e.videoRatioShow?"":' style="display: none !important;"',c=s||e.videoHeightShow||e.videoRatioShow?"":' style="display: none !important;"';i+='
    "}return i+='
    ",n.innerHTML=i,n},open:function(){this.plugins.dialog.open.call(this,"video","video"===this.currentControllerName)},setVideoRatio:function(e){const t=this.context.video,n=e.target.options[e.target.selectedIndex].value;t._defaultSizeY=t._videoRatio=n?100*n+"%":t._defaultSizeY,t.inputY.placeholder=n?100*n+"%":"",t.inputY.value=""},setInputSize:function(e,t){if(t&&32===t.keyCode)return void t.preventDefault();const n=this.context.video;this.plugins.resizing._module_setInputSize.call(this,n,e),"y"===e&&this.plugins.video.setVideoRatioSelect.call(this,t.target.value||n._defaultRatio)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.video)},submitAction:function(){if(0===this.context.video.focusElement.value.trim().length)return!1;this.context.resizing._resize_plugin="video";const e=this.context.video;let t=null,n=null,i=null,l=e.focusElement.value.trim();if(e._align=e.modal.querySelector('input[name="suneditor_video_radio"]:checked').value,/^$/.test(l))t=(new this._w.DOMParser).parseFromString(l,"text/html").querySelector("iframe");else{if(t=this.util.createElement("IFRAME"),/youtu\.?be/.test(l)&&(/^http/.test(l)||(l="https://"+l),l=l.replace("watch?v=",""),/^\/\/.+\/embed\//.test(l)||(l=l.replace(l.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),e._youtubeQuery.length>0))if(/\?/.test(l)){const t=l.split("?");l=t[0]+"?"+e._youtubeQuery+"&"+t[1]}else l+="?"+e._youtubeQuery;t.src=l}let s=!1;this.context.dialog.updateModal?(e._element.src!==t.src&&(e._element.src=t.src,s=!0),i=e._container,n=this.util.getParentElement(e._element,"FIGURE"),t=e._element):(s=!0,t.frameBorder="0",t.allowFullscreen=!0,e._element=t,n=this.plugins.resizing.set_cover.call(this,t),i=this.plugins.resizing.set_container.call(this,n,"se-video-container")),e._cover=n,e._container=i;const o=this.plugins.resizing._module_getSizeX.call(this,e)!==(e.inputX.value||e._defaultSizeX)||this.plugins.resizing._module_getSizeY.call(this,e)!==(e.inputY.value||e._videoRatio),a=!this.context.dialog.updateModal||o;e._resizing&&(this.context.video._proportionChecked=e.proportion.checked,t.setAttribute("data-proportion",e._proportionChecked));let r=!1;a&&(r=this.plugins.video.applySize.call(this)),r&&"center"===e._align||this.plugins.video.setAlign.call(this,null,t,n,i),this.context.dialog.updateModal?e._resizing&&this.context.resizing._rotateVertical&&a&&this.plugins.resizing.setTransformSize.call(this,t,null,null):this.insertComponent(i,!1),s&&this.plugins.video.setVideosInfo.call(this,t),this.context.resizing._resize_plugin="",this.context.dialog.updateModal&&this.history.push(!1)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();try{this.plugins.video.submitAction.call(this)}finally{this.plugins.dialog.close.call(this),this.closeLoading()}return this.focus(),!1},_update_videoCover:function(e){if(!e)return;const t=this.context.video;e.frameBorder="0",e.allowFullscreen=!0;const n=this.util.getParentElement(e,this.util.isMediaComponent)||this.util.getParentElement(e,function(e){return this.isWysiwygDiv(e.parentNode)}.bind(this.util));t._element=e=e.cloneNode(!1);const i=t._cover=this.plugins.resizing.set_cover.call(this,e),l=t._container=this.plugins.resizing.set_container.call(this,i,"se-video-container"),s=n.querySelector("figcaption");let o=null;s&&(o=this.util.createElement("DIV"),o.innerHTML=s.innerHTML,this.util.removeItem(s));const a=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.plugins.video.applySize.call(this,a[0]||this.context.option.videoWidth,a[1]||this.context.option.videoHeight),n.parentNode.replaceChild(l,n),o&&n.parentNode.insertBefore(o,l.nextElementSibling),this.plugins.video.setVideosInfo.call(this,e)},onModifyMode:function(e,t){const n=this.context.video;n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._align=e.getAttribute("data-align")||"none",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin");i?(i=i.split(","),n._origin_w=i[0],n._origin_h=i[1]):t&&(n._origin_w=t.w,n._origin_h=t.h)},openModify:function(e){const t=this.context.video;if(t.focusElement.value=t._element.src,t.modal.querySelector('input[name="suneditor_video_radio"][value="'+t._align+'"]').checked=!0,t._resizing){this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.video);const e=t._videoRatio=this.plugins.resizing._module_getSizeY.call(this,t);this.plugins.video.setVideoRatioSelect.call(this,e)||(t.inputY.value=t._onlyPercentage?this.util.getNumber(e,2):e)}e||this.plugins.dialog.open.call(this,"video",!0)},on:function(e){const t=this.context.video;e||(t.inputX.value=t._origin_w=this.context.option.videoWidth===t._defaultSizeX?"":this.context.option.videoWidth,t.inputY.value=t._origin_h=this.context.option.videoHeight===t._defaultSizeY?"":this.context.option.videoHeight,t.proportion.disabled=!0),t._resizing&&this.plugins.video.setVideoRatioSelect.call(this,t._origin_h||t._defaultRatio)},setVideoRatioSelect:function(e){let t=!1;const n=this.context.video,i=n.videoRatioOption.options;/%$/.test(e)||n._onlyPercentage?e=this.util.getNumber(e,2)/100+"":(!this.util.isNumber(e)||1*e>=1)&&(e=""),n.inputY.placeholder="";for(let l=0,s=i.length;l0?(l.push(this.context.video._videoIndex),t._update_videoCover.call(this,n)):!n.getAttribute("data-index")||s.indexOf(1*n.getAttribute("data-index"))<0?(l.push(this.context.video._videoIndex),n.removeAttribute("data-index"),t.setVideosInfo.call(this,n)):l.push(1*n.getAttribute("data-index"));for(let e,t=0;t-1||(n.splice(t,1),this._videoUpload(null,e,"delete",null,0),t--);this.context.resizing._resize_plugin=i},resetComponentInfo:function(){this.context.video._videosInfo=[],this.context.video._videoIndex=0},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.video)},applySize:function(e,t){const n=this.context.video;return e||(e=n.inputX.value),t||(t=n.inputY.value),n._onlyPercentage||/%$/.test(e)||!e?(this.plugins.video.setPercentSize.call(this,e||"100%",t||(/%$/.test(n._videoRatio)?n._videoRatio:n._defaultRatio)),!0):(e&&"auto"!==e||t&&"auto"!==t?this.plugins.video.setSize.call(this,e,t||n._videoRatio||n._defaultRatio,!1):this.plugins.video.setAutoSize.call(this),!1)},setSize:function(e,t,n,i){const l=this.context.video,s=/^(rw|lw)$/.test(i),o=/^(th|bh)$/.test(i);o||(e=this.util.getNumber(e,0)),s||(t=this.util.isNumber(t)?t+l.sizeUnit:t||""),o||(l._element.style.width=e?e+l.sizeUnit:""),s||(l._cover.style.paddingBottom=l._cover.style.height=t),o||/%$/.test(e)||(l._cover.style.width="",l._container.style.width=""),s||/%$/.test(t)?l._element.style.height="":l._element.style.height=t,n||l._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,l)},setAutoSize:function(){this.plugins.video.setPercentSize.call(this,100,this.context.video._defaultRatio)},setOriginSize:function(e){const t=this.context.video;t._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,t._element),this.plugins.video.cancelPercentAttr.call(this);const n=((e?t._element.getAttribute("data-size"):"")||t._element.getAttribute("data-origin")||"").split(",");if(n){const e=n[0],i=n[1];t._onlyPercentage||/%$/.test(e)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.video.setPercentSize.call(this,e,i):this.plugins.video.setSize.call(this,e,i),this.plugins.resizing._module_saveCurrentSize.call(this,t)}},setPercentSize:function(e,t){const n=this.context.video;t=!t||/%$/.test(t)||this.util.getNumber(t,0)?this.util.isNumber(t)?t+n.sizeUnit:t||n._defaultRatio:this.util.isNumber(t)?t+"%":t,n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=t,n._cover.style.paddingBottom=t,n._element.style.width="100%",n._element.style.height="100%",n._element.style.maxWidth="","center"===n._align&&this.plugins.video.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.video;e._cover.style.width="",e._cover.style.height="",e._cover.style.paddingBottom="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.video._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),"center"===e._align&&this.plugins.video.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const l=this.context.video;e||(e=l._align),t||(t=l._element),n||(n=l._cover),i||(i=l._container),n.style.margin=e&&"none"!==e?"auto":"0",/%$/.test(t.style.width)&&"center"===e?(i.style.minWidth="100%",n.style.width=i.style.width,n.style.height=n.style.height,n.style.paddingBottom=/%$/.test(n.style.height)?this.util.getNumber(this.util.getNumber(n.style.height,2)/100*this.util.getNumber(n.style.width,2),2)+"%":n.style.height):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width||"100%",n.style.paddingBottom=n.style.height),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,l._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},resetAlign:function(){const e=this.context.video;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",this.util.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.video._element,n=this.context.video._container,i=1*t.getAttribute("data-index");let l=n.previousElementSibling||n.nextElementSibling;const s=n.parentNode;if(this.util.removeItem(n),this.plugins.video.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,(function(e){return 0===e.childNodes.length}),null),this.focusEdge(l),i>=0){const e=this.context.video._videosInfo;for(let t=0,n=e.length;t'+this.icons.cancel+''+e.dialogBox.mathBox.title+'

    ",t},setController_MathButton:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-controller se-controller-link",t.innerHTML='
    ",t},open:function(){this.plugins.dialog.open.call(this,"math","math"===this.currentControllerName)},_renderMathExp:function(e){this.previewElement.innerHTML=this._renderer(e.target.value)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=function(){if(0===this.context.math.focusElement.value.trim().length)return!1;const e=this.context.math,t=e.focusElement.value,n=e.previewElement.querySelector(".katex");if(!n)return!1;if(n.setAttribute("contenteditable",!1),n.setAttribute("data-exp",t),n.setAttribute("data-font-size",e.fontSizeElement.value),n.style.fontSize=e.fontSizeElement.value,this.context.dialog.updateModal){const t=function(e,n){if(e.classList.contains(n))return e;const i=e.parentNode;return i!==document.body?i.classList.contains(n)?i:void t(i,n):void 0},i=t(e._mathExp,"katex");i.parentNode.replaceChild(n,i),this.setRange(n,0,n,1)}else{const e=this.getSelectedElements();if(e.length>1){const t=this.util.createElement(e[0].nodeName);t.appendChild(n),this.insertNode(t)}else this.insertNode(n);const t=this.util.createTextNode(this.util.zeroWidthSpace);n.parentNode.insertBefore(t,n.nextSibling),this.setRange(n,0,n,1)}return e.focusElement.value="",e.fontSizeElement.value="1em",e.previewElement.style.fontSize="1em",e.previewElement.innerHTML="",!0}.bind(this);try{t()&&(this.plugins.dialog.close.call(this),this.history.push(!1))}catch(e){this.plugins.dialog.close.call(this)}finally{this.closeLoading()}return!1},active:function(e){if(e){if(e.getAttribute("data-exp"))return this.controllerArray.indexOf(this.context.math.mathController)<0&&(this.setRange(e,0,e,1),this.plugins.math.call_controller.call(this,e)),!0}else this.controllerArray.indexOf(this.context.math.mathController)>-1&&this.controllersOff();return!1},on:function(e){if(e){const e=this.context.math;if(e._mathExp){const t=e._mathExp.getAttribute("data-exp"),n=e._mathExp.getAttribute("data-font-size")||"1em";this.context.dialog.updateModal=!0,e.focusElement.value=t,e.fontSizeElement.value=n,e.previewElement.innerHTML=e._renderer(t),e.previewElement.style.fontSize=n}}else this.plugins.math.init.call(this)},call_controller:function(e){this.context.math._mathExp=e;const t=this.context.math.mathController,n=this.util.getOffset(e,this.context.element.wysiwygFrame);t.style.top=n.top+e.offsetHeight+10+"px",t.style.left=n.left-this.context.element.wysiwygFrame.scrollLeft+"px",t.style.display="block";const i=this.context.element.wysiwygFrame.offsetWidth-(t.offsetLeft+t.offsetWidth);i<0?(t.style.left=t.offsetLeft+i+"px",t.firstElementChild.style.left=20-i+"px"):t.firstElementChild.style.left="20px",this.controllersOn(t,e,"math")},onClick_mathController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?(this.context.math.focusElement.value=this.context.math._mathExp.getAttribute("data-exp"),this.plugins.dialog.open.call(this,"math",!0)):(this.util.removeItem(this.context.math._mathExp),this.context.math._mathExp=null,this.focus(),this.history.push(!1)),this.controllersOff())},init:function(){const e=this.context.math;e.mathController.style.display="none",e._mathExp=null,e.focusElement.value="",e.previewElement.innerHTML=""}}},g={redo:'',undo:'',bold:'',underline:'',italic:'',strike:'',subscript:'',superscript:'',erase:'',indent:'',outdent:'',expansion:'',reduction:'',code_view:'',preview:'',print:'',template:'',line_height:'',paragraph_style:'',text_style:'',save:'',blockquote:'',arrow_down:'',align_justify:'',align_left:'',align_right:'',align_center:'',font_color:'',highlight_color:'',list_bullets:'',list_number:'',table:'',horizontal_rule:'',show_blocks:'',cancel:'',image:'',video:'',link:'',math:'',unlink:'',table_header:'',merge_cell:'',split_cell:'',caption:'',edit:'',delete:'',modify:'',revert:'',auto_size:'',insert_row_below:'',insert_row_above:'',insert_column_left:'',insert_column_right:'',delete_row:'',delete_column:'',fixed_column_width:'',rotate_left:'',rotate_right:'',mirror_horizontal:'',mirror_vertical:'',checked:'',line_break:'',attachment:'',map:'',magic_stick:'',empty_file:'',more_horizontal:'',more_vertical:''},p=n("P6u4"),m=n.n(p);const f={_d:document,_w:window,isIE:null!==window.navigator.userAgent.match(/(MSIE|Trident.*rv[ :])([0-9]+)/),isIE_Edge:null!==window.navigator.userAgent.match(/(MSIE|Trident.*rv[ :])([0-9]+)/)||window.navigator.appVersion.indexOf("Edge")>-1,_tagConvertor:function(e){const t={b:"strong",i:"em",ins:"u",strike:"del",s:"del"};return e.replace(/(<\/?)(b|strong|i|em|ins|u|s|strike|del)\b\s*(?:[^>^<]+)?\s*(?=>)/gi,(function(e,n,i){return n+("string"==typeof t[i]?t[i]:i)}))},_HTMLConvertor:function(e){const t={"&":"&"," ":" ","'":""","<":"<",">":">"};return e.replace(/&|\u00A0|'|<|>/g,(function(e){return"string"==typeof t[e]?t[e]:e}))},zeroWidthSpace:"​",zeroWidthRegExp:new RegExp(String.fromCharCode(8203),"g"),onlyZeroWidthRegExp:new RegExp("^"+String.fromCharCode(8203)+"+$"),onlyZeroWidthSpace:function(e){return"string"!=typeof e&&(e=e.textContent),""===e||this.onlyZeroWidthRegExp.test(e)},getXMLHttpRequest:function(){if(!this._w.ActiveXObject)return this._w.XMLHttpRequest?new XMLHttpRequest:null;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){return null}}},createElement:function(e){return this._d.createElement(e)},createTextNode:function(e){return this._d.createTextNode(e||"")},getIncludePath:function(e,t){let n="";const i=[],l="js"===t?"script":"link",s="js"===t?"src":"href";let o="(?:";for(let t=0,n=e.length;t0?i[0][s]:""),-1===n.indexOf(":/")&&"//"!==n.slice(0,2)&&(n=0===n.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+n:location.href.match(/^[^\?]*\/(?:)/)[0]+n),!n)throw"[SUNEDITOR.util.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (name: +"+name+", extension: "+t+")";return n},getPageStyle:function(e){let t="";const n=(e||this._d).styleSheets;for(let e,i=0,l=n.length;i-1||(i+=n[e].name+'="'+n[e].value+'" ');return i},getByteLength:function(e){const t=this._w.encodeURIComponent;let n,i;return this.isIE_Edge?(i=this._w.unescape(t(e.toString())).length,n=0,null!==t(e.toString()).match(/(%0A|%0D)/gi)&&(n=t(e.toString()).match(/(%0A|%0D)/gi).length),i+n):(i=new this._w.TextEncoder("utf-8").encode(e.toString()).length,n=0,null!==t(e.toString()).match(/(%0A|%0D)/gi)&&(n=t(e.toString()).match(/(%0A|%0D)/gi).length),i+n)},isWysiwygDiv:function(e){return!(!e||1!==e.nodeType||!this.hasClass(e,"se-wrapper-wysiwyg")&&!/^BODY$/i.test(e.nodeName))},isTextStyleElement:function(e){return e&&3!==e.nodeType&&/^(strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label)$/i.test(e.nodeName)},isFormatElement:function(e){return e&&1===e.nodeType&&(/^(P|DIV|H[1-6]|PRE|LI|TD|TH)$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__replace_.+(\\s|$)|(\\s|^)__se__format__free_.+(\\s|$)"))&&!this.isComponent(e)&&!this.isWysiwygDiv(e)},isRangeFormatElement:function(e){return e&&1===e.nodeType&&(/^(BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__range_.+(\\s|$)"))},isFreeFormatElement:function(e){return e&&1===e.nodeType&&(/^PRE$/i.test(e.nodeName)||this.hasClass(e,"(\\s|^)__se__format__free_.+(\\s|$)"))&&!this.isComponent(e)&&!this.isWysiwygDiv(e)},isComponent:function(e){return e&&(/se-component/.test(e.className)||/^(TABLE|HR)$/.test(e.nodeName))},isMediaComponent:function(e){return e&&/se-component/.test(e.className)},getFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isRangeFormatElement(e)&&e.firstElementChild,this.isFormatElement(e)&&t(e))return e;e=e.parentNode}return null},getRangeFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isRangeFormatElement(e)&&!/^(THEAD|TBODY|TR)$/i.test(e.nodeName)&&t(e))return e;e=e.parentNode}return null},getFreeFormatElement:function(e,t){if(!e)return null;for(t||(t=function(){return!0});e;){if(this.isWysiwygDiv(e))return null;if(this.isFreeFormatElement(e)&&t(e))return e;e=e.parentNode}return null},copyTagAttributes:function(e,t){t.style.cssText&&(e.style.cssText+=t.style.cssText);const n=t.classList;for(let t=0,i=n.length;t0&&!this.isBreak(e);)e=e.firstChild;for(;t&&1===t.nodeType&&t.childNodes.length>0&&!this.isBreak(t);)t=t.lastChild;return{sc:e,ec:t||e}}},getOffset:function(e,t){let n=0,i=0,l=3===e.nodeType?e.parentElement:e;const s=this.getParentElement(e,this.isWysiwygDiv.bind(this));for(;l&&!this.hasClass(l,"se-container")&&l!==s;)n+=l.offsetLeft,i+=l.offsetTop,l=l.offsetParent;const o=t&&/iframe/i.test(t.nodeName);return{left:n+(o?t.parentElement.offsetLeft:0),top:i-s.scrollTop+(o?t.parentElement.offsetTop:0)}},getOverlapRangeAtIndex:function(e,t,n,i){if(e<=i?tn)return 0;const l=(e>n?e:n)-(t0?" ":"")+t)},removeClass:function(e,t){if(!e)return;const n=new this._w.RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").trim(),e.className.trim()||e.removeAttribute("class")},toggleClass:function(e,t){if(!e)return;const n=new this._w.RegExp("(\\s|^)"+t+"(\\s|$)");n.test(e.className)?e.className=e.className.replace(n," ").trim():e.className+=" "+t,e.className.trim()||e.removeAttribute("class")},toggleDisabledButtons:function(e,t){for(let n=0,i=t.length;n=0){e.splitText(t);const n=this.getNodeFromPath([a+1],i);this.onlyZeroWidthSpace(n)&&(n.data=this.zeroWidthSpace)}}else 1===e.nodeType&&(e.previousSibling?e=e.previousSibling:this.getElementDepth(e)===n&&(r=!1));let c=e;for(;this.getElementDepth(c)>n;)for(a=this.getPositionIndex(c)+1,c=c.parentNode,o=l,l=c.cloneNode(!1),s=c.childNodes,o&&(this.isListCell(l)&&this.isList(o)&&o.firstElementChild&&(l.innerHTML=o.firstElementChild.innerHTML,f.removeItem(o.firstElementChild),o.children.length>0&&l.appendChild(o)),l.appendChild(o));s[a];)l.appendChild(s[a]);c.childNodes.length<=1&&(!c.firstChild||0===c.firstChild.textContent.length)&&(c.innerHTML="
    ");const d=c.parentNode;return r&&(c=c.nextSibling),l?(this.mergeSameTags(l,null,!1),this.mergeNestedTags(l,function(e){return this.isList(e)}.bind(this)),l.childNodes.length>0?d.insertBefore(l,c):l=c,0===i.childNodes.length&&this.removeItem(i),l):c},mergeSameTags:function(e,t,n){const i=this;let l=null;return t&&t.length>0&&(l=this._w.Array.apply(null,new this._w.Array(t.length)).map(this._w.Number.prototype.valueOf,0)),function e(s,o,a){const r=s.childNodes;for(let c,d,u=0,h=r.length;u=0;){if(i.getArrayIndex(l.childNodes,n)!==e[a]){r=!1;break}n=c.parentNode,l=n.parentNode,a--}r&&(e.splice(o,1),e[o]=u)}}i.copyTagAttributes(c,s),s.parentNode.insertBefore(c,s),i.removeItem(s)}if(!d){1===c.nodeType&&e(c,o+1,u);break}if(c.nodeName===d.nodeName&&i.isSameAttributes(c,d)&&c.href===d.href){const e=c.childNodes;let n=0;for(let t=0,i=e.length;t0&&n++;const s=c.lastChild,r=d.firstChild;let h=0;if(s&&r){const e=3===s.nodeType&&3===r.nodeType;h=s.textContent.length;let i=s.previousSibling;for(;i&&3===i.nodeType;)h+=i.textContent.length,i=i.previousSibling;if(n>0&&3===s.nodeType&&3===r.nodeType&&(s.textContent.length>0||r.textContent.length>0)&&n--,t){let i=null;for(let c in t)if(i=t[c],i&&i[o]>u){if(o>0&&i[o-1]!==a)continue;i[o]-=1,i[o+1]>=0&&i[o]===u&&(i[o+1]+=n,e&&s&&3===s.nodeType&&r&&3===r.nodeType&&(l[c]+=h))}}}if(3===c.nodeType){if(h=c.textContent.length,c.textContent+=d.textContent,t){let e=null;for(let i in t)if(e=t[i],e&&e[o]>u){if(o>0&&e[o-1]!==a)continue;e[o]-=1,e[o+1]>=0&&e[o]===u&&(e[o+1]+=n,l[i]+=h)}}}else c.innerHTML+=d.innerHTML;i.removeItem(d),u--}else 1===c.nodeType&&e(c,o+1,u)}}(e,0,0),l},mergeNestedTags:function(e,t){"string"==typeof t?t=function(e){return this.test(e.tagName)}.bind(new this._w.RegExp("^("+(t||".+")+")$","i")):"function"!=typeof t&&(t=function(){return!0}),function e(n){let i=n.children;if(1===i.length&&i[0].nodeName===n.nodeName&&t(n)){const e=i[0];for(i=e.children;i[0];)n.appendChild(i[0]);n.removeChild(e)}for(let t=0,i=n.children.length;t")},htmlRemoveWhiteSpace:function(e){return e?e.trim().replace(/<\/?(?!strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label)[^>^<]+>\s+(?=<)/gi,(function(e){return e.trim()})):""},sortByDepth:function(e,t){const n=t?1:-1,i=-1*n;e.sort(function(e,t){return this.isListCell(e)&&this.isListCell(t)?(e=this.getElementDepth(e))>(t=this.getElementDepth(t))?n:e'+this.icons.line_break+"";const y=n.createElement("DIV");return y.className="se-resizing-back",r.appendChild(u),r.appendChild(g),h&&r.appendChild(h),l.appendChild(s.element),l.appendChild(a),l.appendChild(r),l.appendChild(y),l.appendChild(b),l.appendChild(v),p&&l.appendChild(p),i.appendChild(l),g=this._checkCodeMirror(t,g),{constructed:{_top:i,_relative:l,_toolBar:s.element,_editorArea:r,_wysiwygArea:u,_codeArea:g,_placeholder:h,_resizingBar:p,_navigation:m,_charWrapper:f,_charCounter:_,_loading:b,_lineBreaker:v,_resizeBack:y,_stickyDummy:a,_arrow:o},options:t,plugins:s.plugins,pluginCallButtons:s.pluginCallButtons,_icons:this.icons}},_checkCodeMirror:function(e,t){if(e.codeMirror){const n=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!0},e.codeMirror.options||{}].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{});"auto"===e.height&&(n.viewportMargin=1/0,n.height="auto");const i=e.codeMirror.src.fromTextArea(t,n);i.display.wrapper.style.cssText=t.style.cssText,e.codeMirrorEditor=i,(t=i.display.wrapper).className+=" se-wrapper-code-mirror"}return t},_checkKatexMath:function(e){if(!e)throw Error('[SUNEDITOR.create.fail] To use the math button you need to add a "katex" object to the options.');const t=[{throwOnError:!1},e.options||{}].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{});e.options=t},_setOptions:function(e,t,n,i){this._initOptions(t.element.originElement,e);const l=t.element,s=l.relative,o=l.editorArea,a=!!e.buttonList||e.mode!==i.mode,r=!!e.plugins,c=this._createToolBar(document,a?e.buttonList:i.buttonList,r?e.plugins:n,e.lang);c.pluginCallButtons.math&&this._checkKatexMath(e.katex);const d=document.createElement("DIV");d.className="se-arrow",a&&(s.replaceChild(c.element,l.toolbar),l.toolbar=c.element,l._arrow=d);const u=this._initElements(e,l.topArea,a?c.element:l.toolbar,d),h=u.bottomBar,g=u.wysiwygFrame,p=u.placeholder;let m=u.codeView;return l.resizingBar&&s.removeChild(l.resizingBar),h.resizingBar&&s.appendChild(h.resizingBar),l.resizingBar=h.resizingBar,l.navigation=h.navigation,l.charWrapper=h.charWrapper,l.charCounter=h.charCounter,o.removeChild(l.wysiwygFrame),o.removeChild(l.code),o.appendChild(g),o.appendChild(m),l.placeholder&&o.removeChild(l.placeholder),p&&o.appendChild(p),m=this._checkCodeMirror(e,m),l.wysiwygFrame=g,l.code=m,l.placeholder=p,{callButtons:a?c.pluginCallButtons:null,plugins:a||r?c.plugins:null}},_initElements:function(e,t,n,i){t.style.width=e.width,t.style.minWidth=e.minWidth,t.style.maxWidth=e.maxWidth,t.style.display=e.display,"string"==typeof e.position&&(t.style.position=e.position),/inline/i.test(e.mode)?(n.className+=" se-toolbar-inline",n.style.width=e.toolbarWidth):/balloon/i.test(e.mode)&&(n.className+=" se-toolbar-balloon",n.style.width=e.toolbarWidth,n.appendChild(i));const l=document.createElement(e.iframe?"IFRAME":"DIV");if(l.className="se-wrapper-inner se-wrapper-wysiwyg",e.iframe){const t=function(){const t=e.iframeCSSFileName;let n="";for(let e,i=0,l=t.length;i'}return n}()+("auto"===e.height?"":"");l.allowFullscreen=!0,l.frameBorder=0,l.addEventListener("load",(function(){this.setAttribute("scrolling","auto"),this.contentDocument.head.innerHTML=''+t,this.contentDocument.body.className="sun-editor-editable",this.contentDocument.body.setAttribute("contenteditable",!0)}))}else l.setAttribute("contenteditable",!0),l.setAttribute("scrolling","auto"),l.className+=" sun-editor-editable";l.style.cssText=_._setDefaultOptionStyle(e);const s=document.createElement("TEXTAREA");s.className="se-wrapper-inner se-wrapper-code",s.style.display="none",s.style.height=e.height,s.style.minHeight=e.minHeight,s.style.maxHeight=e.maxHeight,"auto"===e.height&&(s.style.overflow="hidden");let o=null,a=null,r=null,c=null;if(e.resizingBar&&(o=document.createElement("DIV"),o.className="se-resizing-bar sun-editor-common",a=document.createElement("DIV"),a.className="se-navigation sun-editor-common",o.appendChild(a),e.charCounter)){if(r=document.createElement("DIV"),r.className="se-char-counter-wrapper",e.charCounterLabel){const t=document.createElement("SPAN");t.className="se-char-label",t.textContent=e.charCounterLabel,r.appendChild(t)}if(c=document.createElement("SPAN"),c.className="se-char-counter",c.textContent="0",r.appendChild(c),e.maxCharCount>0){const t=document.createElement("SPAN");t.textContent=" / "+e.maxCharCount,r.appendChild(t)}o.appendChild(r)}let d=null;return e.placeholder&&(d=document.createElement("SPAN"),d.className="se-placeholder",d.innerText=e.placeholder),{bottomBar:{resizingBar:o,navigation:a,charWrapper:r,charCounter:c},wysiwygFrame:l,codeView:s,placeholder:d}},_initOptions:function(e,t){t.lang=t.lang||m.a,t._defaultTagsWhitelist="string"==typeof t._defaultTagsWhitelist?t._defaultTagsWhitelist:"br|p|div|pre|blockquote|h[1-6]|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup",t._editorTagsWhitelist=t._defaultTagsWhitelist+("string"==typeof t.addTagsWhitelist&&t.addTagsWhitelist.length>0?"|"+t.addTagsWhitelist:""),t.pasteTagsWhitelist="string"==typeof t.pasteTagsWhitelist?t.pasteTagsWhitelist:t._editorTagsWhitelist,t.attributesWhitelist=t.attributesWhitelist&&"object"==typeof t.attributesWhitelist?t.attributesWhitelist:null,t.mode=t.mode||"classic",t.toolbarWidth=t.toolbarWidth?_.isNumber(t.toolbarWidth)?t.toolbarWidth+"px":t.toolbarWidth:"auto",t.stickyToolbar=/balloon/i.test(t.mode)?-1:void 0===t.stickyToolbar?0:/^\d+/.test(t.stickyToolbar)?_.getNumber(t.stickyToolbar,0):-1,t.iframe=t.fullPage||t.iframe,t.iframeCSSFileName=t.iframe?"string"==typeof t.iframeCSSFileName?[t.iframeCSSFileName]:t.iframeCSSFileName||["suneditor"]:null,t.codeMirror=t.codeMirror?t.codeMirror.src?t.codeMirror:{src:t.codeMirror}:null,t.display=t.display||("none"!==e.style.display&&e.style.display?e.style.display:"block"),t.popupDisplay=t.popupDisplay||"full",t.resizingBar=void 0===t.resizingBar?!/inline|balloon/i.test(t.mode):t.resizingBar,t.showPathLabel=!!t.resizingBar&&("boolean"!=typeof t.showPathLabel||t.showPathLabel),t.charCounter=t.maxCharCount>0||"boolean"==typeof t.charCounter&&t.charCounter,t.charCounterType="string"==typeof t.charCounterType?t.charCounterType:"char",t.charCounterLabel="string"==typeof t.charCounterLabel?t.charCounterLabel.trim():null,t.maxCharCount=_.isNumber(t.maxCharCount)&&t.maxCharCount>-1?1*t.maxCharCount:null,t.width=t.width?_.isNumber(t.width)?t.width+"px":t.width:e.clientWidth?e.clientWidth+"px":"100%",t.minWidth=(_.isNumber(t.minWidth)?t.minWidth+"px":t.minWidth)||"",t.maxWidth=(_.isNumber(t.maxWidth)?t.maxWidth+"px":t.maxWidth)||"",t.height=t.height?_.isNumber(t.height)?t.height+"px":t.height:e.clientHeight?e.clientHeight+"px":"auto",t.minHeight=(_.isNumber(t.minHeight)?t.minHeight+"px":t.minHeight)||"",t.maxHeight=(_.isNumber(t.maxHeight)?t.maxHeight+"px":t.maxHeight)||"",t.defaultStyle=_._setDefaultOptionStyle(t)+("string"==typeof t.defaultStyle?t.defaultStyle:""),t.font=t.font?t.font:null,t.fontSize=t.fontSize?t.fontSize:null,t.formats=t.formats?t.formats:null,t.colorList=t.colorList?t.colorList:null,t.lineHeights=t.lineHeights?t.lineHeights:null,t.paragraphStyles=t.paragraphStyles?t.paragraphStyles:null,t.textStyles=t.textStyles?t.textStyles:null,t.fontSizeUnit="string"==typeof t.fontSizeUnit&&t.fontSizeUnit.trim()||"px",t.imageResizing=void 0===t.imageResizing||t.imageResizing,t.imageHeightShow=void 0===t.imageHeightShow||!!t.imageHeightShow,t.imageWidth=t.imageWidth?_.isNumber(t.imageWidth)?t.imageWidth+"px":t.imageWidth:"auto",t.imageHeight=t.imageHeight?_.isNumber(t.imageHeight)?t.imageHeight+"px":t.imageHeight:"auto",t.imageSizeOnlyPercentage=!!t.imageSizeOnlyPercentage,t._imageSizeUnit=t.imageSizeOnlyPercentage?"%":"px",t.imageRotation=void 0!==t.imageRotation?t.imageRotation:!(t.imageSizeOnlyPercentage||!t.imageHeightShow),t.imageFileInput=void 0===t.imageFileInput||t.imageFileInput,t.imageUrlInput=void 0===t.imageUrlInput||!t.imageFileInput||t.imageUrlInput,t.imageUploadHeader=t.imageUploadHeader||null,t.imageUploadUrl=t.imageUploadUrl||null,t.imageUploadSizeLimit=/\d+/.test(t.imageUploadSizeLimit)?_.getNumber(t.imageUploadSizeLimit,0):null,t.videoResizing=void 0===t.videoResizing||t.videoResizing,t.videoHeightShow=void 0===t.videoHeightShow||!!t.videoHeightShow,t.videoRatioShow=void 0===t.videoRatioShow||!!t.videoRatioShow,t.videoWidth=t.videoWidth&&_.getNumber(t.videoWidth,0)?_.isNumber(t.videoWidth)?t.videoWidth+"px":t.videoWidth:"",t.videoHeight=t.videoHeight&&_.getNumber(t.videoHeight,0)?_.isNumber(t.videoHeight)?t.videoHeight+"px":t.videoHeight:"",t.videoSizeOnlyPercentage=!!t.videoSizeOnlyPercentage,t._videoSizeUnit=t.videoSizeOnlyPercentage?"%":"px",t.videoRotation=void 0!==t.videoRotation?t.videoRotation:!(t.videoSizeOnlyPercentage||!t.videoHeightShow),t.videoRatio=_.getNumber(t.videoRatio,4)||.5625,t.videoRatioList=t.videoRatioList?t.videoRatioList:null,t.youtubeQuery=(t.youtubeQuery||"").replace("?",""),t.callBackSave=t.callBackSave?t.callBackSave:null,t.templates=t.templates?t.templates:null,t.placeholder="string"==typeof t.placeholder?t.placeholder:null,t.katex=t.katex?t.katex.src?t.katex:{src:t.katex}:null,t.buttonList=t.buttonList||[["undo","redo"],["bold","underline","italic","strike","subscript","superscript"],["removeFormat"],["outdent","indent"],["fullScreen","showBlocks","codeView"],["preview","print"]],this.icons=t.icons&&"object"==typeof t.icons?[g,t.icons].reduce((function(e,t){for(let n in t)e[n]=t[n];return e}),{}):g},_defaultButtons:function(e){const t=this.icons;return{bold:["_se_command_bold",e.toolbar.bold+" (CTRL+B)","STRONG","",t.bold],underline:["_se_command_underline",e.toolbar.underline+" (CTRL+U)","U","",t.underline],italic:["_se_command_italic",e.toolbar.italic+" (CTRL+I)","EM","",t.italic],strike:["_se_command_strike",e.toolbar.strike+" (CTRL+SHIFT+S)","DEL","",t.strike],subscript:["_se_command_subscript",e.toolbar.subscript,"SUB","",t.subscript],superscript:["_se_command_superscript",e.toolbar.superscript,"SUP","",t.superscript],removeFormat:["",e.toolbar.removeFormat,"removeFormat","",t.erase],indent:["_se_command_indent",e.toolbar.indent+" (CTRL+])","indent","",t.outdent],outdent:["_se_command_outdent",e.toolbar.outdent+" (CTRL+[)","outdent","",t.indent],fullScreen:["se-code-view-enabled se-resizing-enabled",e.toolbar.fullScreen,"fullScreen","",t.expansion],showBlocks:["",e.toolbar.showBlocks,"showBlocks","",t.show_blocks],codeView:["se-code-view-enabled se-resizing-enabled",e.toolbar.codeView,"codeView","",t.code_view],undo:["_se_command_undo se-resizing-enabled",e.toolbar.undo+" (CTRL+Z)","undo","",t.undo],redo:["_se_command_redo se-resizing-enabled",e.toolbar.redo+" (CTRL+Y / CTRL+SHIFT+Z)","redo","",t.redo],preview:["se-resizing-enabled",e.toolbar.preview,"preview","",t.preview],print:["se-resizing-enabled",e.toolbar.print,"print","",t.print],save:["_se_command_save se-resizing-enabled",e.toolbar.save,"save","",t.save],blockquote:["",e.toolbar.tag_blockquote,"blockquote","command",t.blockquote],font:["se-btn-select se-btn-tool-font",e.toolbar.font,"font","submenu",''+e.toolbar.font+""+t.arrow_down],formatBlock:["se-btn-select se-btn-tool-format",e.toolbar.formats,"formatBlock","submenu",''+e.toolbar.formats+""+t.arrow_down],fontSize:["se-btn-select se-btn-tool-size",e.toolbar.fontSize,"fontSize","submenu",''+e.toolbar.fontSize+""+t.arrow_down],fontColor:["",e.toolbar.fontColor,"fontColor","submenu",t.font_color],hiliteColor:["",e.toolbar.hiliteColor,"hiliteColor","submenu",t.highlight_color],align:["se-btn-align",e.toolbar.align,"align","submenu",t.align_left],list:["",e.toolbar.list,"list","submenu",t.list_number],horizontalRule:["btn_line",e.toolbar.horizontalRule,"horizontalRule","submenu",t.horizontal_rule],table:["",e.toolbar.table,"table","submenu",t.table],lineHeight:["",e.toolbar.lineHeight,"lineHeight","submenu",t.line_height],template:["",e.toolbar.template,"template","submenu",t.template],paragraphStyle:["",e.toolbar.paragraphStyle,"paragraphStyle","submenu",t.paragraph_style],textStyle:["",e.toolbar.textStyle,"textStyle","submenu",t.text_style],link:["",e.toolbar.link,"link","dialog",t.link],image:["",e.toolbar.image,"image","dialog",t.image],video:["",e.toolbar.video,"video","dialog",t.video],math:["",e.toolbar.math,"math","dialog",t.math]}},_createModuleGroup:function(e){const t=_.createElement("DIV");t.className="se-btn-module"+(e?"":" se-btn-module-border");const n=_.createElement("UL");return n.className="se-menu-list",t.appendChild(n),{div:t,ul:n}},_createButton:function(e,t,n,i,l,s){const o=_.createElement("LI"),a=_.createElement("BUTTON");return a.setAttribute("type","button"),a.setAttribute("class","se-btn"+(e?" "+e:"")+" se-tooltip"),a.setAttribute("data-command",n),a.setAttribute("data-display",i),l||(l='!'),l+=''+(t||n)+"",s&&a.setAttribute("disabled",!0),a.innerHTML=l,o.appendChild(a),{li:o,button:a}},_createToolBar:function(e,t,n,i){const l=e.createElement("DIV");l.className="se-toolbar-separator-vertical";const s=e.createElement("DIV");s.className="se-toolbar sun-editor-common";const o=this._defaultButtons(i),a={},r={};if(n){const e=n.length?n:Object.keys(n).map((function(e){return n[e]}));for(let t,n=0,i=e.length;n0&&u._getPageBottomSpace()0){for(let e=0;e":n),this.history.push(!0)},nativeFocus:function(){const t=r.getParentElement(this.getSelectionNode(),"figcaption");t?t.focus():e.element.wysiwyg.focus(),this._editorRange()},focus:function(){if("none"!==e.element.wysiwygFrame.style.display){if(l.iframe)this.nativeFocus();else try{const e=this.getRange();if(e.startContainer===e.endContainer&&r.isWysiwygDiv(e.startContainer)){const e=r.createElement("P"),t=r.createElement("BR");e.appendChild(t),this.setRange(t,0,t,0)}else this.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}catch(e){this.nativeFocus()}u._applyTagEffects(),d._isBalloon&&u._toggleToolbarBalloon()}},focusEdge:function(t){if(t||(t=e.element.wysiwyg.lastElementChild),r.isComponent(t)){const e=t.querySelector("IMG"),n=t.querySelector("IFRAME");e?this.selectComponent(e,"image"):n&&this.selectComponent(n,"video")}else t&&(t=r.getChildElement(t,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!0))?this.setRange(t,t.textContent.length,t,t.textContent.length):this.nativeFocus()},setRange:function(e,t,n,i){if(!e||!n)return;t>e.textContent.length&&(t=e.textContent.length),i>n.textContent.length&&(i=n.textContent.length);const s=this._wd.createRange();try{s.setStart(e,t),s.setEnd(n,i)}catch(e){this.nativeFocus()}const o=this.getSelection();o.removeAllRanges&&o.removeAllRanges(),o.addRange(s),this._editorRange(),l.iframe&&this.nativeFocus()},removeRange:function(){this._variable._range=null,this._variable._selectionNode=null,this.getSelection().removeAllRanges();const e=this.commandMap,t=this.activePlugins;for(let i in e)t.indexOf(i)>-1?n[i].active.call(d,null):e.OUTDENT&&/^OUTDENT$/i.test(i)?e.OUTDENT.setAttribute("disabled",!0):e.INDENT&&/^INDENT$/i.test(i)?e.INDENT.removeAttribute("disabled"):r.removeClass(e[i],"active")},getRange:function(){return this._variable._range||this._createDefaultRange()},getSelection:function(){return this._ww.getSelection()},getSelectionNode:function(){return this._variable._selectionNode&&!r.isWysiwygDiv(this._variable._selectionNode)||this._editorRange(),this._variable._selectionNode||e.element.wysiwyg.firstChild},_editorRange:function(){const e=this.getSelection();let t=null,n=null;t=e.rangeCount>0?e.getRangeAt(0):this._createDefaultRange(),this._variable._range=t,n=t.collapsed?t.commonAncestorContainer:e.extentNode||e.anchorNode,this._variable._selectionNode=n},_createDefaultRange:function(){e.element.wysiwyg.focus();const t=this._wd.createRange();return e.element.wysiwyg.firstChild||this.execCommand("formatBlock",!1,"P"),t.setStart(e.element.wysiwyg.firstChild,0),t.setEnd(e.element.wysiwyg.firstChild,0),t},_resetRangeToTextNode:function(){const t=this.getRange();let n,i,l,s=t.startContainer,o=t.startOffset,a=t.endContainer,c=t.endOffset;if(r.isFormatElement(s)&&(s=s.childNodes[o],o=0),r.isFormatElement(a)&&(a=a.childNodes[c],c=0),n=r.isWysiwygDiv(s)?e.element.wysiwyg.firstChild:s,i=o,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType;)n=n.childNodes[i]||n.nextElementSibling||n.nextSibling,i=0;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.getParentElement(n,r.isCell)?"DIV":"P"),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,e&&s===a&&(a=n,c=1)}}if(s=n,o=i,n=r.isWysiwygDiv(a)?e.element.wysiwyg.lastChild:a,i=c,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType&&(l=n.childNodes,0!==l.length);)n=l[i>0?i-1:i]||!/FIGURE/i.test(l[0].nodeName)?l[0]:n.previousElementSibling||n.previousSibling||s,i=i>0?n.textContent.length:i;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.isCell(e)?"DIV":"P"),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,i=1,e&&!n.previousSibling&&r.removeItem(a)}}a=n,c=i,this.setRange(s,o,a,c)},getSelectedElements:function(t){this._resetRangeToTextNode();let n=this.getRange();if(r.isWysiwygDiv(n.startContainer)){const t=e.element.wysiwyg.children;if(0===t.length)return null;this.setRange(t[0],0,t[t.length-1],t[t.length-1].textContent.trim().length),n=this.getRange()}const i=n.startContainer,l=n.endContainer,s=n.commonAncestorContainer,o=r.getListChildren(s,(function(e){return t?t(e):r.isFormatElement(e)}));if(r.isWysiwygDiv(s)||r.isRangeFormatElement(s)||o.unshift(r.getFormatElement(s,null)),i===l||1===o.length)return o;let a=r.getFormatElement(i,null),c=r.getFormatElement(l,null),d=null,u=null;const h=function(e){return!r.isTable(e)||/^TABLE$/i.test(e.nodeName)};let g=r.getRangeFormatElement(a,h),p=r.getRangeFormatElement(c,h);r.isTable(g)&&r.isListCell(g.parentNode)&&(g=g.parentNode),r.isTable(p)&&r.isListCell(p.parentNode)&&(p=p.parentNode);const m=g===p;for(let e,t=0,n=o.length;t=0;n--)if(i[n].contains(i[e])){i.splice(e,1),e--,t--;break}return i},isEdgePoint:function(e,t){return 0===t||!e.nodeValue&&1===t||t===e.nodeValue.length},showLoading:function(){e.element.loading.style.display="block"},closeLoading:function(){e.element.loading.style.display="none"},appendFormatTag:function(e,t){const n=r.getFormatElement(this.getSelectionNode(),null),i=t?"string"==typeof t?t:t.nodeName:r.isFormatElement(n)&&!r.isFreeFormatElement(n)?n.nodeName:"P",l=r.createElement(i);return l.innerHTML="
    ",(t&&"string"!=typeof t||!t&&r.isFormatElement(n))&&r.copyTagAttributes(l,t||n),r.isCell(e)?e.insertBefore(l,e.nextElementSibling):e.parentNode.insertBefore(l,e.nextElementSibling),l},insertComponent:function(e,t){const n=this.removeNode();let i=null,l=this.getSelectionNode(),s=r.getFormatElement(l,null);if(r.isListCell(s))if(/^HR$/i.test(e.nodeName)){const t=r.createElement("LI"),n=r.createTextNode(r.zeroWidthSpace);t.appendChild(e),t.appendChild(n),s.parentNode.insertBefore(t,s.nextElementSibling),this.setRange(n,1,n,1)}else this.insertNode(e,l===s?null:n.container.nextSibling),e.nextSibling||e.parentNode.appendChild(r.createElement("BR")),i=r.createElement("LI"),s.parentNode.insertBefore(i,s.nextElementSibling);else{if(this.getRange().collapsed&&(3===n.container.nodeType||r.isBreak(n.container))){const e=r.getParentElement(n.container,function(e){return this.isRangeFormatElement(e)}.bind(r));i=r.splitElement(n.container,n.offset,e?r.getElementDepth(e)+1:0),i&&(s=i.previousSibling)}this.insertNode(e,s),i||(i=this.appendFormatTag(e,r.isFormatElement(s)?s:null))}return i=r.getEdgeChildNodes(i,null).sc||i,this.setRange(i,0,i,0),t||this.history.push(1),i},selectComponent:function(e,t){if("image"===t){if(!d.plugins.image)return;d.removeRange(),d.callPlugin("image",(function(){const t=d.plugins.resizing.call_controller_resize.call(d,e,"image");d.plugins.image.onModifyMode.call(d,e,t),r.getParentElement(e,".se-image-container")||(d.plugins.image.openModify.call(d,!0),d.plugins.image.update_image.call(d,!0,!0,!0))}),null)}else if("video"===t){if(!d.plugins.video)return;d.removeRange(),d.callPlugin("video",(function(){const t=d.plugins.resizing.call_controller_resize.call(d,e,"video");d.plugins.video.onModifyMode.call(d,e,t)}),null)}},insertNode:function(e,t){const n=r.isFormatElement(e)||r.isRangeFormatElement(e)||r.isComponent(e);if(!t&&n){const e=this.removeNode();if(3===e.container.nodeType||r.isBreak(e.container)){const n=r.getParentElement(e.container,function(e){return this.isRangeFormatElement(e)}.bind(r));(t=r.splitElement(e.container,e.offset,n?r.getElementDepth(n)+1:0))&&(t=t.previousSibling)}}const i=this.getRange(),l=i.startContainer,s=i.startOffset,o=i.endContainer,a=i.endOffset,c=i.commonAncestorContainer;let d,u=null;if(t)d=t.parentNode,t=t.nextSibling,u=!0;else if(d=l,3===l.nodeType&&(d=l.parentNode),i.collapsed)if(3===c.nodeType)t=c.textContent.length>a?c.splitText(a):c.nextSibling;else if(r.isBreak(d))t=d,d=d.parentNode;else{let n=d.childNodes[s];const i=n&&3===n.nodeType&&r.onlyZeroWidthSpace(n)&&r.isBreak(n.nextSibling)?n.nextSibling:n;i?i.nextSibling?t=r.isBreak(i)&&!r.isBreak(e)?i:i.nextSibling:(d.removeChild(i),t=null):t=null}else{if(l===o){t=this.isEdgePoint(o,a)?o.nextSibling:o.splitText(a);let e=l;this.isEdgePoint(l,s)||(e=l.splitText(s)),d.removeChild(e),0===d.childNodes.length&&n&&(d.innerHTML="
    ")}else{const e=this.removeNode(),i=e.container,l=e.prevContainer;if(i&&0===i.childNodes.length&&n&&(r.isFormatElement(i)?i.innerHTML="
    ":r.isRangeFormatElement(i)&&(i.innerHTML="


    ")),!n&&l)if(d=3===l.nodeType?l.parentNode:l,d.contains(i))for(t=i;t.parentNode===d;)t=t.parentNode;else t=null;else d=n?c:i,t=n?o:null;for(;t&&t.parentNode!==c;)t=t.parentNode}}try{if(r.isFormatElement(e)||r.isRangeFormatElement(e)||!r.isListCell(d)&&r.isComponent(e)){const e=d;if(r.isList(t))d=t,t=null;else if(!u&&!t){const e=this.removeNode(),n=3===e.container.nodeType?r.isListCell(r.getFormatElement(e.container,null))?e.container:r.getFormatElement(e.container,null)||e.container.parentNode:e.container,i=r.isWysiwygDiv(n)||r.isRangeFormatElement(n);d=i?n:n.parentNode,t=i?null:n.nextSibling}0===e.childNodes.length&&d!==e&&r.removeItem(e)}!n||r.isRangeFormatElement(d)||r.isListCell(d)||r.isWysiwygDiv(d)||(t=d.nextElementSibling,d=d.parentNode),d.insertBefore(e,t)}catch(t){d.appendChild(e)}finally{let t=1;if(3===e.nodeType){const t=e.previousSibling,n=e.nextSibling,i=!t||3!==t.nodeType||r.onlyZeroWidthSpace(t)?"":t.textContent,l=!n||3!==n.nodeType||r.onlyZeroWidthSpace(n)?"":n.textContent;return t&&i.length>0&&(e.textContent=i+e.textContent,r.removeItem(t)),n&&n.length>0&&(e.textContent+=l,r.removeItem(n)),{startOffset:i.length,endOffset:e.textContent.length-l.length}}if(!r.isBreak(e)&&r.isFormatElement(d)){let n=null;e.previousSibling||(n=r.createTextNode(r.zeroWidthSpace),e.parentNode.insertBefore(n,e)),e.nextSibling||(n=r.createTextNode(r.zeroWidthSpace),e.parentNode.appendChild(n)),r._isIgnoreNodeChange(e)&&(e=e.nextSibling,t=0)}this.setRange(e,t,e,t),this.history.push(!0)}},removeNode:function(){const t=this.getRange();let n,i=0,l=t.startContainer,s=t.endContainer;const o=t.startOffset,a=t.endOffset,c=t.commonAncestorContainer;let d=null,u=null;const h=r.getListChildNodes(c,null);let g=r.getArrayIndex(h,l),p=r.getArrayIndex(h,s);if(h.length>0&&g>-1&&p>-1){for(let e=g+1,t=l;e>=0;e--)h[e]===t.parentNode&&h[e].firstChild===t&&0===o&&(g=e,t=t.parentNode);for(let e=p-1,t=s;e>g;e--)h[e]===t.parentNode&&1===h[e].nodeType&&(h.splice(e,1),t=t.parentNode,--p)}else{if(0===h.length){if(r.isFormatElement(c)||r.isRangeFormatElement(c)||r.isWysiwygDiv(c)||r.isBreak(c)||r.isMedia(c))return{container:c,offset:0};h.push(c),l=s=c}else if(l=s=h[0],r.isBreak(l))return{container:l,offset:0};g=p=0}function m(e){const t=r.getFormatElement(e,null);if(r.removeItem(e),r.isListCell(t)){const e=r.getArrayItem(t.children,r.isList,!1);if(e){const n=e.firstElementChild,i=n.childNodes;for(;i[0];)t.insertBefore(i[0],e);r.removeItemAllParents(n,null,null)}}}for(let e=g;e<=p;e++){const t=h[e];if(0===t.length||3===t.nodeType&&void 0===t.data)m(t);else if(t!==l)t!==s?m(t):(u=1===s.nodeType?r.createTextNode(s.textContent):r.createTextNode(s.substringData(a,s.length-a)),u.length>0?s.data=u.data:m(s));else if(1===l.nodeType?d=r.createTextNode(l.textContent):t===s?(d=r.createTextNode(l.substringData(0,o)+s.substringData(a,s.length-a)),i=o):d=r.createTextNode(l.substringData(0,o)),d.length>0?l.data=d.data:m(l),t===s)break}if(n=s&&s.parentNode?s:l&&l.parentNode?l:t.endContainer||t.startContainer,!r.isWysiwygDiv(n)){const t=r.removeItemAllParents(n,null,null);t&&(n=t.sc||t.ec||e.element.wysiwyg)}return this.setRange(n,i,n,i),this.history.push(!0),{container:n,offset:i,prevContainer:l&&l.parentNode?l:null}},applyRangeFormatElement:function(e){const t=this.getSelectedElementsAndComponents(!1);if(!t||0===t.length)return;e:for(let e,n,i,l,s,o,a=0,c=t.length;a-1&&(l=n.lastElementChild,t.indexOf(l)>-1)){let e=null;for(;e=l.lastElementChild;)if(r.isList(e)){if(!(t.indexOf(e.lastElementChild)>-1))continue e;l=e.lastElementChild}i=n.firstElementChild,s=t.indexOf(i),o=t.indexOf(l),t.splice(s,o-s+1),c=t.length}else;let n,i,l,s=t[t.length-1];n=r.isRangeFormatElement(s)||r.isFormatElement(s)?s:r.getRangeFormatElement(s,null)||r.getFormatElement(s,null),r.isCell(n)?(i=null,l=n):(i=n.nextSibling,l=n.parentNode);let o=r.getElementDepth(n),a=null;const c=[],d=function(e,t,n){let i=null;if(e!==t&&!r.isTable(t)){if(t&&r.getElementDepth(e)===r.getElementDepth(t))return n;i=r.removeItemAllParents(t,null,e)}return i?i.ec:n};for(let n,s,u,h,g,p,m,f=0,_=t.length;f<_;f++)if(n=t[f],s=n.parentNode,s&&!e.contains(s))if(u=r.getElementDepth(n),r.isList(s)){if(null===a&&(p?(a=p,m=!0,p=null):a=s.cloneNode(!1)),c.push(n),g=t[f+1],f===_-1||g&&g.parentNode!==s){g&&n.contains(g.parentNode)&&(p=g.parentNode.cloneNode(!1));let t,f=s.parentNode;for(;r.isList(f);)t=r.createElement(f.nodeName),t.appendChild(a),a=t,f=f.parentNode;const _=this.detachRangeFormatElement(s,c,null,!0,!0);o>=u?(o=u,l=_.cc,i=d(l,s,_.ec),i&&(l=i.parentNode)):l===_.cc&&(i=_.ec),l!==_.cc&&(h=d(l,_.cc,h),i=void 0!==h?h:_.cc);for(let e=0,t=_.removeArray.length;e=u&&(o=u,l=s,i=n.nextSibling),e.appendChild(n),l!==s&&(h=d(l,s),void 0!==h&&(i=h));if(this.effectNode=null,r.mergeSameTags(e,null,!1),r.mergeNestedTags(e,function(e){return this.isList(e)}.bind(r)),i&&r.getElementDepth(i)>0&&(r.isList(i.parentNode)||r.isList(i.parentNode.parentNode))){const t=r.getParentElement(i,function(e){return this.isRangeFormatElement(e)&&!this.isList(e)}.bind(r)),n=r.splitElement(i,null,t?r.getElementDepth(t)+1:0);n.parentNode.insertBefore(e,n)}else l.insertBefore(e,i),d(e,i);const u=r.getEdgeChildNodes(e.firstElementChild,e.lastElementChild);t.length>1?this.setRange(u.sc,0,u.ec,u.ec.textContent.length):this.setRange(u.ec,u.ec.textContent.length,u.ec,u.ec.textContent.length),this.history.push(!1)},detachRangeFormatElement:function(e,t,n,i,l){const s=this.getRange(),o=s.startOffset,a=s.endOffset;let c=r.getListChildNodes(e,(function(t){return t.parentNode===e})),d=e.parentNode,u=null,h=null,g=e.cloneNode(!1);const p=[],m=r.isList(n);let f=!1,_=!1,b=!1;function v(t,n,i,l){if(r.onlyZeroWidthSpace(n)&&(n.innerHTML=r.zeroWidthSpace),3===n.nodeType)return t.insertBefore(n,i),n;const s=(b?n:l).childNodes;let o=n.cloneNode(!1),a=null,c=null;for(;s[0];)c=s[0],!r._notTextNode(c)||r.isBreak(c)||r.isListCell(o)?o.appendChild(c):(o.childNodes.length>0&&(a||(a=o),t.insertBefore(o,i),o=n.cloneNode(!1)),t.insertBefore(c,i),a||(a=c));if(o.childNodes.length>0){if(r.isListCell(t)&&r.isListCell(o)&&r.isList(i))if(m){for(a=i;i;)o.appendChild(i),i=i.nextSibling;t.parentNode.insertBefore(o,t.nextElementSibling)}else{const t=l.nextElementSibling,n=r.detachNestedList(l,!1);e===n&&t===l.nextElementSibling||(e=n,_=!0)}else t.insertBefore(o,i);a||(a=o)}return a}for(let l,s,o,a=0,y=c.length;a0&&(d.insertBefore(g,e),g=null),!m&&r.isListCell(l))if(o&&r.getElementDepth(l)!==r.getElementDepth(o)&&(r.isListCell(d)||r.getArrayItem(l.children,r.isList,!1))){const t=l.nextElementSibling,n=r.detachNestedList(l,!1);e===n&&t===l.nextElementSibling||(e=n,_=!0)}else{const t=l;l=r.createElement(i?t.nodeName:r.isList(e.parentNode)||r.isListCell(e.parentNode)?"LI":r.isCell(e.parentNode)?"DIV":"P");const n=r.isListCell(l),s=t.childNodes;for(;s[0]&&(!r.isList(s[0])||n);)l.appendChild(s[0]);r.copyFormatAttributes(l,t),b=!0}else l=l.cloneNode(!1);if(_){_=b=!1,c=r.getListChildNodes(e,(function(t){return t.parentNode===e})),g=e.cloneNode(!1),d=e.parentNode,a=-1,y=c.length;continue}i?(p.push(l),r.removeItem(c[a])):(n?(f||(d.insertBefore(n,e),f=!0),l=v(n,l,null,c[a])):l=v(d,l,e,c[a]),t?(h=l,u||(u=l)):u||(u=h=l))}const y=e.parentNode;let x=e.nextSibling;g&&g.children.length>0&&y.insertBefore(g,x),n?u=n.previousSibling:u||(u=e.previousSibling),x=e.nextSibling,0===e.children.length||0===e.textContent.length?r.removeItem(e):r.removeEmptyNode(e,null);let C=null;if(i)C={cc:y,sc:u,ec:x,removeArray:p};else{u||(u=h),h||(h=u);const e=r.getEdgeChildNodes(u,h.parentNode?u:h);C={cc:(e.sc||e.ec).parentNode,sc:e.sc,ec:e.ec}}if(this.effectNode=null,l)return C;!i&&C&&(t?this.setRange(C.sc,o,C.ec,a):this.setRange(C.sc,0,C.sc,0)),this.history.push(!1)},detachList:function(e,t){let n={},i=!1,l=!1,s=null,o=null;const a=function(e){return!this.isComponent(e)}.bind(r);for(let c,d,u,h,g=0,p=e.length;g0)&&t,n=!!(n&&n.length>0)&&n;const s=!e,o=s&&!n&&!t;let c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset;if(o&&l.collapsed&&r.isFormatElement(c.parentNode)&&r.isFormatElement(u.parentNode)||c===u&&1===c.nodeType&&"false"===c.getAttribute("contenteditable"))return;if(l.collapsed&&!o&&1===c.nodeType&&!r.isBreak(c)){let e=null;const t=c.childNodes[d];t&&(t.nextSibling?e=r.isBreak(t)?t:t.nextSibling:(c.removeChild(t),e=null));const n=r.createTextNode(r.zeroWidthSpace);c.insertBefore(n,e),this.setRange(n,1,n,1),l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset}r.isFormatElement(c)&&(c=c.childNodes[d],d=0),r.isFormatElement(u)&&(u=u.childNodes[h],h=u.textContent.length),s&&(e=r.createElement("DIV"));const g=e.nodeName;if(!o&&c===u&&!n&&e){let t=c,n=0;const i=[],l=e.style;for(let e=0,t=l.length;e0){for(;!r.isFormatElement(t)&&!r.isWysiwygDiv(t);){for(let l=0;l=i.length)return}}let p,m={},f={},_="",b="",v="";if(t){for(let e,n=0,i=t.length;n0&&(c=l.replace(_,"").trim(),c!==l&&(y.v=!0));const d=t.className;let u="";return b&&d.length>0&&(u=d.replace(b,"").trim(),u!==d&&(y.v=!0)),(!s||!b&&d||!_&&l||c||u||!n)&&(c||u||t.nodeName!==g||a.Boolean(_)!==a.Boolean(l)||a.Boolean(b)!==a.Boolean(d))?(_&&l.length>0&&(t.style.cssText=c),t.style.cssText||t.removeAttribute("style"),b&&d.length>0&&(t.className=u.trim()),t.className.trim()||t.removeAttribute("class"),t.style.cssText||t.className||t.nodeName!==g&&!n?t:(y.v=!0,null)):(y.v=!0,null)},C=this.getSelectedElements(null);l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset,r.getFormatElement(c,null)||(c=r.getChildElement(C[0],(function(e){return 3===e.nodeType}),!1),d=0),r.getFormatElement(u,null)||(u=r.getChildElement(C[C.length-1],(function(e){return 3===e.nodeType}),!1),h=u.textContent.length);const w=r.getFormatElement(c,null)===r.getFormatElement(u,null),E=C.length-(w?0:1);p=e.cloneNode(!1);const N=o||s&&function(e,t){for(let n=0,i=e.length;n0&&(p=e.cloneNode(!1),f=this._nodeChange_endLine(C[E],p,x,u,h,o,s,y,S,T));for(let t=E-1;t>0;t--)p=e.cloneNode(!1),this._nodeChange_middleLine(C[t],p,x,o,s,y);p=e.cloneNode(!1),m=this._nodeChange_startLine(C[0],p,x,c,d,o,s,y,S,T),E<=0?f=m:f.container||(f.container=m.container,f.offset=m.container.textContent.length)}this.controllersOff(),this.setRange(m.container,m.offset,f.container,f.offset),this.history.push(!1)},_stripRemoveNode:function(e){const t=e.parentNode;if(!e||3===e.nodeType||!t)return;const n=e.childNodes;for(;n[0];)t.insertBefore(n[0],e);t.removeChild(e)},_util_getMaintainedNode:function(e,t){return t&&!e?this.getParentElement(t,function(e){return this._isMaintainedNode(e)}.bind(this)):null},_util_isMaintainedNode:function(e,t){return t&&!e&&3!==t.nodeType&&this._isMaintainedNode(t)},_nodeChange_oneLine:function(e,t,n,i,l,s,o,c,d,u,h,g,p){let m=i.parentNode;for(;!(m.nextSibling||m.previousSibling||r.isFormatElement(m.parentNode)||r.isWysiwygDiv(m.parentNode))&&m.nodeName!==t.nodeName;)m=m.parentNode;if(!d&&m===s.parentNode&&m.nodeName===t.nodeName&&r.onlyZeroWidthSpace(i.textContent.slice(0,l))&&r.onlyZeroWidthSpace(s.textContent.slice(o))){const e=m.childNodes;let n=!0;for(let t,l,o,a,c=0,d=e.length;c0&&(n=t.test(e.style.cssText)),!n}if(function e(i,l){const s=i.childNodes;for(let i,o=0,a=s.length;o=S?L-S:N.data.length-S));if(E){const t=g(l);if(t&&t.parentNode!==e){let n=t,i=null;for(;n.parentNode!==e;){for(l=i=n.parentNode.cloneNode(!1);n.childNodes[0];)i.appendChild(n.childNodes[0]);n.appendChild(i),n=n.parentNode}n.parentNode.appendChild(t)}E=E.cloneNode(!1)}r.onlyZeroWidthSpace(s)||l.appendChild(s);const c=g(l);for(c&&(E=c),E&&(e=E),x=a,y=[],w="";x!==e&&x!==f&&null!==x;)i=p(x)?null:n(x),i&&1===x.nodeType&&A(x)&&(y.push(i),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;const d=y.pop()||o;for(C=x=d;y.length>0;)x=y.pop(),C.appendChild(x),C=x;if(t.appendChild(d),e.appendChild(t),E&&!g(T)&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),N=o,S=0,k=!0,x!==o&&x.appendChild(N),!v)continue}if(z||a!==T){if(k){if(1===a.nodeType&&!r.isBreak(a)){r._isIgnoreNodeChange(a)?(b.appendChild(a.cloneNode(!0)),u||(t=t.cloneNode(!1),b.appendChild(t),_.push(t))):e(a,a);continue}x=a,y=[],w="";const s=[];for(;null!==x.parentNode&&x!==f&&x!==t;)i=z?x.cloneNode(!1):n(x),1===x.nodeType&&!r.isBreak(a)&&i&&A(x)&&(i&&(p(i)?E||s.push(i):y.push(i)),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;y=y.concat(s);const o=y.pop()||a;for(C=x=o;y.length>0;)x=y.pop(),C.appendChild(x),C=x;if(p(t.parentNode)&&!p(o)&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),z||E||!p(o))o===a?l=z?b:t:z?(b.appendChild(o),l=x):(t.appendChild(o),l=x);else{t=t.cloneNode(!1);const e=o.childNodes;for(let n=0,i=e.length;n0?x:t}if(E&&3===a.nodeType)if(g(a)){const e=r.getParentElement(l,function(e){return this._isMaintainedNode(e.parentNode)||e.parentNode===b}.bind(r));E.appendChild(e),t=e.cloneNode(!1),_.push(t),b.appendChild(t)}else E=null}d=a.cloneNode(!1),l.appendChild(d),1!==a.nodeType||r.isBreak(a)||(h=d),e(a,h)}else{E=g(a);const e=r.createTextNode(1===T.nodeType?"":T.substringData(L,T.length-L)),l=r.createTextNode(v||1===T.nodeType?"":T.substringData(0,L));if(E?E=E.cloneNode(!1):p(t.parentNode)&&!E&&(t=t.cloneNode(!1),b.appendChild(t),_.push(t)),!r.onlyZeroWidthSpace(e)){x=a,w="",y=[];const t=[];for(;x!==b&&x!==f&&null!==x;)1===x.nodeType&&A(x)&&(p(x)?t.push(x.cloneNode(!1)):y.push(x.cloneNode(!1)),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;for(y=y.concat(t),d=C=x=y.pop()||e;y.length>0;)x=y.pop(),C.appendChild(x),C=x;b.appendChild(d),x.textContent=e.data}if(E&&d){const e=g(d);e&&(E=e)}for(x=a,y=[],w="";x!==b&&x!==f&&null!==x;)i=p(x)?null:n(x),i&&1===x.nodeType&&A(x)&&(y.push(i),w+=x.style.cssText.substr(0,x.style.cssText.indexOf(":"))+"|"),x=x.parentNode;const s=y.pop()||l;for(C=x=s;y.length>0;)x=y.pop(),C.appendChild(x),C=x;E?((t=t.cloneNode(!1)).appendChild(s),E.insertBefore(t,E.firstChild),b.appendChild(E),_.push(t),E=null):t.appendChild(s),T=l,L=l.data.length,z=!0,!c&&u&&(t=l,l.textContent=r.zeroWidthSpace),x!==l&&x.appendChild(T)}}}(e,b),d&&!c&&!h.v)return{startContainer:i,startOffset:l,endContainer:s,endOffset:o};if(c=c&&d)for(let e=0;e<_.length;e++){let t,n,i,l=_[e];if(u)t=r.createTextNode(r.zeroWidthSpace),b.replaceChild(t,l);else{const e=l.childNodes;for(n=e[0];e[0];)i=e[0],b.insertBefore(i,l);r.removeItem(l)}0===e&&(u?N=T=t:(N=n,T=i))}else{if(d)for(let e=0;e<_.length;e++)this._stripRemoveNode(_[e]);u&&(N=T=t)}r.removeEmptyNode(b,t),u&&(S=N.textContent.length,L=T.textContent.length);const B=c||0===T.textContent.length;r.isBreak(T)||0!==T.textContent.length||(r.removeItem(T),T=N),L=B?T.textContent.length:L;const H={s:0,e:0},M=r.getNodePath(N,b,H),I=!T.parentNode;I&&(T=N);const R={s:0,e:0},D=r.getNodePath(T,b,I||B?null:R);S+=H.s,L=u?S:I?N.textContent.length:B?L+H.s:L+R.s;const O=r.mergeSameTags(b,[M,D],!0);return e.parentNode.replaceChild(b,e),N=r.getNodeFromPath(M,b),T=r.getNodeFromPath(D,b),{startContainer:N,startOffset:S+O[0],endContainer:T,endOffset:L+O[1]}},_nodeChange_startLine:function(e,t,n,i,l,s,o,a,c,d){let u=i.parentNode;for(;!(u.nextSibling||u.previousSibling||r.isFormatElement(u.parentNode)||r.isWysiwygDiv(u.parentNode))&&u.nodeName!==t.nodeName;)u=u.parentNode;if(!o&&u.nodeName===t.nodeName&&!r.isFormatElement(u)&&!u.nextSibling&&r.onlyZeroWidthSpace(i.textContent.slice(0,l))){let e=!0,n=i.previousSibling;for(;n;){if(!r.onlyZeroWidthSpace(n)){e=!1;break}n=n.previousSibling}if(e)return r.copyTagAttributes(u,t),{container:i,offset:l}}a.v=!1;const h=e,g=[t],p=e.cloneNode(!1);let m,f,_,b,v=i,y=l,x=!1;if(function e(i,l){const s=i.childNodes;for(let i,o=0,a=s.length;o0,u=m.pop()||a;for(_=f=u;m.length>0;)f=m.pop(),_.appendChild(f),_=f;if(d(t.parentNode)&&!d(u)&&(t=t.cloneNode(!1),p.appendChild(t),g.push(t)),!b&&d(u)){t=t.cloneNode(!1);const e=u.childNodes;for(let n=0,i=e.length;n0;)f=m.pop(),_.appendChild(f),_=f;u!==l?(t.appendChild(u),l=f):l=t,r.isBreak(a)&&t.appendChild(a.cloneNode(!1)),e.appendChild(t),v=o,y=0,x=!0,l.appendChild(v)}}}(e,p),o&&!s&&!a.v)return{container:i,offset:l};if(s=s&&o)for(let e=0;e0&&c===d)return void(e.innerHTML=n.innerHTML)}s.v=!1;const o=e.cloneNode(!1),a=[t];let c=!0;if(function e(i,l){const s=i.childNodes;for(let i,d=0,u=s.length;d0&&(o.appendChild(t),t=t.cloneNode(!1)),o.appendChild(u.cloneNode(!0)),o.appendChild(t),a.push(t),l=t)}}(e,t),!c&&(!l||i||s.v)){if(o.appendChild(t),i&&l)for(let e=0;e0,u=m.pop()||a;for(_=f=u;m.length>0;)f=m.pop(),_.appendChild(f),_=f;if(d(t.parentNode)&&!d(u)&&(t=t.cloneNode(!1),p.insertBefore(t,p.firstChild),g.push(t)),!b&&d(u)){t=t.cloneNode(!1);const e=u.childNodes;for(let n=0,i=e.length;n0?f:t}else o?(t.insertBefore(u,t.firstChild),l=f):l=t;if(b&&3===a.nodeType)if(c(a)){const e=r.getParentElement(l,function(e){return this._isMaintainedNode(e.parentNode)||e.parentNode===p}.bind(r));b.appendChild(e),t=e.cloneNode(!1),g.push(t),p.insertBefore(t,p.firstChild)}else b=null}if(x||a!==v)i=x?n(a):a.cloneNode(!1),i&&(l.insertBefore(i,l.firstChild),1!==a.nodeType||r.isBreak(a)||(u=i)),e(a,u);else{b=c(a);const e=r.createTextNode(1===v.nodeType?"":v.substringData(y,v.length-y)),s=r.createTextNode(1===v.nodeType?"":v.substringData(0,y));if(b){b=b.cloneNode(!1);const e=c(l);if(e&&e.parentNode!==p){let t=e,n=null;for(;t.parentNode!==p;){for(l=n=t.parentNode.cloneNode(!1);t.childNodes[0];)n.appendChild(t.childNodes[0]);t.appendChild(n),t=t.parentNode}t.parentNode.insertBefore(e,t.parentNode.firstChild)}b=b.cloneNode(!1)}else d(t.parentNode)&&!b&&(t=t.cloneNode(!1),p.appendChild(t),g.push(t));for(r.onlyZeroWidthSpace(e)||l.insertBefore(e,l.firstChild),f=l,m=[];f!==p&&null!==f;)i=d(f)?null:n(f),i&&1===f.nodeType&&m.push(i),f=f.parentNode;const o=m.pop()||l;for(_=f=o;m.length>0;)f=m.pop(),_.appendChild(f),_=f;o!==l?(t.insertBefore(o,t.firstChild),l=f):l=t,r.isBreak(a)&&t.appendChild(a.cloneNode(!1)),b?(b.insertBefore(t,b.firstChild),p.insertBefore(b,p.firstChild),b=null):p.insertBefore(t,p.firstChild),v=s,y=s.data.length,x=!0,l.insertBefore(v,l.firstChild)}}}(e,p),o&&!s&&!a.v)return{container:i,offset:l};if(s=s&&o)for(let e=0;e0&&this.plugins.list.editInsideList.call(this,l,i),this.effectNode=null,this.setRange(s,a,o,c),this.history.push(!1)},toggleDisplayBlocks:function(){r.toggleClass(e.element.wysiwyg,"se-show-block"),this._resourcesStateChange()},toggleCodeView:function(){const t=this._variable.isCodeView;this.controllersOff(),r.toggleDisabledButtons(!t,this.codeViewDisabledButtons),t?(this._setCodeDataToEditor(),e.element.wysiwygFrame.scrollTop=0,e.element.code.style.display="none",e.element.wysiwygFrame.style.display="block",this._variable._codeOriginCssText=this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: none"),this._variable._wysiwygOriginCssText=this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: block"),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.style.height="0px"),this._variable.isCodeView=!1,this._variable.isFullScreen||(this._notHideToolbar=!1,/balloon|balloon-always/i.test(l.mode)&&(e.element._arrow.style.display="",this._isInline=!1,this._isBalloon=!0,u._hideToolbar())),this.nativeFocus(),this.history.push(!1)):(this._setEditorDataToCodeView(),this._variable._codeOriginCssText=this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: block"),this._variable._wysiwygOriginCssText=this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/,"display: none"),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.style.height=e.element.code.scrollHeight>0?e.element.code.scrollHeight+"px":"auto"),l.codeMirrorEditor&&l.codeMirrorEditor.refresh(),this._variable.isCodeView=!0,this._variable.isFullScreen||(this._notHideToolbar=!0,this._isBalloon&&(e.element._arrow.style.display="none",e.element.toolbar.style.left="",this._isInline=!0,this._isBalloon=!1,u._showToolbarInline())),this._variable._range=null,e.element.code.focus()),this._checkPlaceholder()},_setCodeDataToEditor:function(){const t=this._getCodeView();if(l.fullPage){const e=this._parser.parseFromString(t,"text/html"),n=e.head.children;for(let t=0,i=n.length;t0?this.convertContentsForEditor(t):"


    "},_setEditorDataToCodeView:function(){const t=this.convertHTMLForCodeView(e.element.wysiwyg);let n="";if(l.fullPage){const e=r.getAttributesToString(this._wd.body,null);n="\n\n"+this._wd.head.outerHTML.replace(/>(?!\n)/g,">\n")+"\n"+t+"\n"}else n=t;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(n)},toggleFullScreen:function(t){const n=e.element.topArea,i=e.element.toolbar,s=e.element.editorArea,d=e.element.wysiwygFrame,h=e.element.code,g=this._variable;this.controllersOff(),g.isFullScreen?(g.isFullScreen=!1,d.style.cssText=g._wysiwygOriginCssText,h.style.cssText=g._codeOriginCssText,i.style.cssText="",s.style.cssText=g._editorAreaOriginCssText,n.style.cssText=g._originCssText,o.body.style.overflow=g._bodyOverflow,l.stickyToolbar>-1&&r.removeClass(i,"se-toolbar-sticky"),g._fullScreenAttrs.sticky&&(g._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",r.addClass(i,"se-toolbar-sticky")),this._isInline=g._fullScreenAttrs.inline,this._isBalloon=g._fullScreenAttrs.balloon,this._isInline&&u._showToolbarInline(),u.onScroll_window(),r.changeElement(t.querySelector("svg"),c.expansion)):(g.isFullScreen=!0,g._fullScreenAttrs.inline=this._isInline,g._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.zIndex="2147483647",""!==e.element._stickyDummy.style.display&&(g._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",r.removeClass(i,"se-toolbar-sticky")),g._bodyOverflow=o.body.style.overflow,o.body.style.overflow="hidden",g._editorAreaOriginCssText=s.style.cssText,g._wysiwygOriginCssText=d.style.cssText,g._codeOriginCssText=h.style.cssText,s.style.cssText=i.style.cssText="",d.style.cssText=(d.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],h.style.cssText=(h.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],i.style.width=d.style.height=h.style.height="100%",i.style.position="relative",i.style.display="block",g.innerHeight_fullScreen=a.innerHeight-i.offsetHeight,s.style.height=g.innerHeight_fullScreen+"px",r.changeElement(t.querySelector("svg"),c.reduction),l.iframe&&"auto"===l.height&&(s.style.overflow="auto",this._iframeAutoHeight()))},print:function(){const e=r.createElement("IFRAME");e.style.display="none",o.body.appendChild(e);const t=r.getIframeDocument(e),n=this.getContents(!0),i=this._wd;if(l.iframe){const e=l.fullPage?r.getAttributesToString(i.body,["contenteditable"]):'class="sun-editor-editable"';t.write(""+i.head.innerHTML+""+n+"")}else{const e=r.createElement("DIV"),l=r.createElement("STYLE");l.innerHTML=r.getPageStyle(i),e.className="sun-editor-editable",e.innerHTML=n,t.head.appendChild(l),t.body.appendChild(e)}try{if(e.focus(),r.isIE_Edge||o.documentMode||a.StyleMedia)try{e.contentWindow.document.execCommand("print",!1,null)}catch(t){e.contentWindow.print()}else e.contentWindow.print()}catch(e){throw Error("[SUNEDITOR.core.print.fail] error: "+e)}finally{r.removeItem(e)}},preview:function(){const e=this.getContents(!0),t=a.open("","_blank");t.mimeType="text/html";const n=this._wd;if(l.iframe){const i=l.fullPage?r.getAttributesToString(n.body,["contenteditable"]):'class="sun-editor-editable"';t.document.write(""+n.head.innerHTML+""+e+"")}else t.document.write(''+i.toolbar.preview+"'+e+"")},setContents:function(t){const n=this.convertContentsForEditor(t);if(this._resetComponents(),d._variable.isCodeView){const e=this.convertHTMLForCodeView(n);d._setCodeView(e)}else e.element.wysiwyg.innerHTML=n,d.history.push(!1)},getContents:function(t){const n=e.element.wysiwyg.innerHTML,i=r.createElement("DIV");i.innerHTML=n;const s=r.getListChildren(i,(function(e){return/FIGCAPTION/i.test(e.nodeName)}));for(let e=0,t=s.length;e"+this._wd.head.outerHTML+""+i.innerHTML+""}return i.innerHTML},_makeLine:function(e,t){if(1===e.nodeType)return r._notAllowedTags(e)?"":!t||r.isFormatElement(e)||r.isRangeFormatElement(e)||r.isComponent(e)||r.isMedia(e)||r.isAnchor(e)&&r.isMedia(e.firstElementChild)?e.outerHTML:"

    "+e.outerHTML+"

    ";if(3===e.nodeType){if(!t)return e.textContent;const n=e.textContent.split(/\n/g);let i="";for(let e,t=0,l=n.length;t0&&(i+="

    "+e+"

    ");return i}return 8===e.nodeType&&this._allowHTMLComments?"<__comment__>"+e.textContent.trim()+"":""},cleanHTML:function(e,t){const n=o.createRange().createContextualFragment(e);try{r._consistencyCheckOfHTML(n,this._htmlCheckWhitelistRegExp)}catch(e){console.warn("[SUNEDITOR.cleanHTML.consistencyCheck.fail] "+e)}const i=n.childNodes;let l="",s=!1;for(let e,t=0,n=i.length;t(\n|.)*<\/(script|style)>/g,"").replace(this.editorTagsWhitelistRegExp,"").replace(/<__comment__>/g,"\x3c!-- ").replace(/<\/__comment__>/g," --\x3e").replace(/(<[a-zA-Z0-9]+)[^>]*(?=>)/g,function(e,t){let n=null;const i=this._attributesTagsWhitelist[t.match(/(?!<)[a-zA-Z]+/)[0].toLowerCase()];if(n=i?e.match(i):e.match(this._attributesWhitelistRegExp),n)for(let e=0,i=n.length;e^<]*)>/g,"")),l=r.htmlRemoveWhiteSpace(l),r._tagConvertor(l?t?l.replace("string"==typeof t?r.createTagsWhitelist(t):t,""):l:e)},convertContentsForEditor:function(e){const t=o.createRange().createContextualFragment(e);try{r._consistencyCheckOfHTML(t,this._htmlCheckWhitelistRegExp)}catch(e){console.warn("[SUNEDITOR.convertContentsForEditor.consistencyCheck.fail] "+e)}let n="";const i=t.childNodes;for(let e=0,t=i.length;e

    ":(n=r.htmlRemoveWhiteSpace(n),n=n.replace(this.editorTagsWhitelistRegExp,"").replace(/\n/g,"").replace(/<__comment__>/g,"\x3c!-- ").replace(/<\/__comment__>/g," --\x3e"),r._tagConvertor(n))},convertHTMLForCodeView:function(e){let t="";const n=a.RegExp,i=new n("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),l=r.isFormatElement.bind(r),s="string"==typeof e?o.createRange().createContextualFragment(e):e;let c=1*this._variable.codeIndent;return c=c>0?new a.Array(c+1).join(" "):"",function e(s,o,a){const d=s.childNodes,u=i.test(s.nodeName),h=u?o:"";for(let g,p,m,f=0,_=d.length;f<_;f++){if(g=d[f],m=i.test(g.nodeName),p=m?"\n":"",a=!l(g)||u||/^(TH|TD)$/i.test(s.nodeName)?"":"\n",8===g.nodeType){t+="\n\x3c!-- "+g.textContent.trim()+" --\x3e"+p;continue}if(3===g.nodeType){t+=r._HTMLConvertor(/^\n+$/.test(g.data)?"":g.data);continue}if(0===g.childNodes.length){t+=(/^(HR)$/i.test(g.nodeName)?"\n":"")+h+g.outerHTML+p;continue}g.innerHTML=g.innerHTML;const _=g.nodeName.toLowerCase();t+=(a||(u?"":p))+(h||m?o:"")+g.outerHTML.match(n("<"+_+"[^>]*>","i"))[0]+p,e(g,o+c,""),t+=(m?o:"")+""+(a||p||u||/^(TH|TD)$/i.test(g.nodeName)?"\n":"")}}(s,"","\n"),t.trim()+"\n"},addDocEvent:function(e,t,n){o.addEventListener(e,t,n),l.iframe&&this._wd.addEventListener(e,t)},removeDocEvent:function(e,t){o.removeEventListener(e,t),l.iframe&&this._wd.removeEventListener(e,t)},_charCount:function(t){const n=e.element.charCounter,i=l.maxCharCount;let s=0;if(t&&(s=d._getCharLength(t,l.charCounterType)),n&&a.setTimeout((function(){n.textContent=h.getCharCount(null)})),i>0){let t=!1;const n=h.getCharCount(null);if(n>i){if(t=!0,s>0){this._editorRange();const e=this.getRange(),t=e.endOffset-1,l=this.getSelectionNode().textContent,s=e.endOffset-(n-i);this.getSelectionNode().textContent=l.slice(0,s<0?0:s)+l.slice(e.endOffset,l.length),this.setRange(e.endContainer,t,e.endContainer,t)}}else n+s>i&&(t=!0);if(t){const t=e.element.charWrapper;if(t&&!r.hasClass(t,"se-blink")&&(r.addClass(t,"se-blink"),a.setTimeout((function(){r.removeClass(t,"se-blink")}),600)),s>0)return!1}}return!0},_getCharLength:function(e,t){return/byte/.test(t)?r.getByteLength(e):e.length},_checkComponents:function(){for(let e in this.componentInfoPlugins)this.componentInfoPlugins[e].checkComponentInfo.call(this)},_resetComponents:function(){for(let e in this.componentInfoPlugins)this.componentInfoPlugins[e].resetComponentInfo.call(this)},_setCodeView:function(t){l.codeMirrorEditor?l.codeMirrorEditor.getDoc().setValue(t):e.element.code.value=t},_getCodeView:function(){return l.codeMirrorEditor?l.codeMirrorEditor.getDoc().getValue():e.element.code.value},_init:function(i,s){this._ww=l.iframe?e.element.wysiwygFrame.contentWindow:a,this._wd=o,l.iframe&&"auto"===l.height&&(this._iframeAuto=this._wd.body),this._allowHTMLComments=l._editorTagsWhitelist.indexOf("//")>-1,this._htmlCheckWhitelistRegExp=new a.RegExp("^("+l._editorTagsWhitelist.replace("|//","")+")$","i"),this.editorTagsWhitelistRegExp=r.createTagsWhitelist(l._editorTagsWhitelist.replace("|//","|__comment__")),this.pasteTagsWhitelistRegExp=r.createTagsWhitelist(l.pasteTagsWhitelist);const c=l.attributesWhitelist,d={};let g,p,m="";if(c)for(let e in c)"all"===e?m=c[e]+"|":d[e]=new a.RegExp("((?:"+c[e]+')s*=s*"[^"]*")',"ig");this._attributesWhitelistRegExp=new a.RegExp("((?:"+m+'contenteditable|colspan|rowspan|target|href|src|class|type|data-format|data-size|data-file-size|data-file-name|data-origin|data-align|data-image-link|data-rotate|data-proportion|data-percentage|origin-size)s*=s*"[^"]*")',"ig"),this._attributesTagsWhitelist=d,this.codeViewDisabledButtons=e.element.toolbar.querySelectorAll('.se-toolbar button:not([class~="se-code-view-enabled"])'),this.resizingDisabledButtons=e.element.toolbar.querySelectorAll('.se-toolbar button:not([class~="se-resizing-enabled"])'),this._isInline=/inline/i.test(l.mode),this._isBalloon=/balloon|balloon-always/i.test(l.mode),this._isBalloonAlways=/balloon-always/i.test(l.mode),this.commandMap={STRONG:e.tool.bold,U:e.tool.underline,EM:e.tool.italic,DEL:e.tool.strike,SUB:e.tool.subscript,SUP:e.tool.superscript,OUTDENT:e.tool.outdent,INDENT:e.tool.indent},this.activePlugins=[],this.componentInfoPlugins=[];for(let e in n)g=n[e],p=t[e],g.active&&p&&this.callPlugin(e,null,p),"function"==typeof g.checkComponentInfo&&"function"==typeof g.resetComponentInfo&&(this.callPlugin(e,null,p),this.componentInfoPlugins.push(g));this._variable._originCssText=e.element.topArea.style.cssText,this._placeholder=e.element.placeholder,this._lineBreaker=e.element.lineBreaker,this._lineBreakerButton=this._lineBreaker.querySelector("button"),this.history=function(e,t){const n=window,i=e.context.element,l=e.util,s=e.context.tool.undo,o=e.context.tool.redo;let a=null,r=0,c=[];function d(){const n=c[r];i.wysiwyg.innerHTML=n.contents,e.setRange(l.getNodeFromPath(n.s.path,i.wysiwyg),n.s.offset,l.getNodeFromPath(n.e.path,i.wysiwyg),n.e.offset),e.focus(),0===r?(s&&s.setAttribute("disabled",!0),o&&o.removeAttribute("disabled")):r===c.length-1?(s&&s.removeAttribute("disabled"),o&&o.setAttribute("disabled",!0)):(s&&s.removeAttribute("disabled"),o&&o.removeAttribute("disabled")),e.controllersOff(),e._checkComponents(),e._charCount(""),e._resourcesStateChange(),t()}function u(){e._checkComponents();const n=e.getContents(!0);if(c[r]&&n===c[r].contents)return;r++;const i=e._variable._range;c.length>r&&(c=c.slice(0,r),o&&o.setAttribute("disabled",!0)),c[r]=i?{contents:n,s:{path:l.getNodePath(i.startContainer,null,null),offset:i.startOffset},e:{path:l.getNodePath(i.endContainer,null,null),offset:i.endOffset}}:{contents:n,s:{path:[0,0],offset:[0,0]},e:{path:0,offset:0}},1===r&&s&&s.removeAttribute("disabled"),e._charCount(""),t()}return{stack:c,push:function(t){n.setTimeout(e._resourcesStateChange);const i="number"==typeof t?t>0?t:0:t?400:0;i&&!a||(n.clearTimeout(a),i)?a=n.setTimeout((function(){n.clearTimeout(a),a=null,u()}),i):u()},undo:function(){r>0&&(r--,d())},redo:function(){c.length-1>r&&(r++,d())},go:function(e){r=e<0?c.length-1:e,d()},reset:function(n){s&&s.setAttribute("disabled",!0),o&&o.setAttribute("disabled",!0),e.context.tool.save&&e.context.tool.save.setAttribute("disabled",!0),c.splice(0),r=0,c[r]={contents:e.getContents(!0),s:{path:[0,0],offset:0},e:{path:[0,0],offset:0}},n||t()},_destroy:function(){a&&n.clearTimeout(a),c=null}}}(this,u._onChange_historyStack),l.iframe||this._initWysiwygArea(i,s),a.setTimeout(function(){if(l.iframe&&(this._wd=e.element.wysiwygFrame.contentDocument,e.element.wysiwyg=this._wd.body,this._initWysiwygArea(i,s),"auto"===l.height&&(this._iframeAuto=this._wd.body)),this._checkComponents(),this._componentsInfoInit=!1,this._componentsInfoReset=!1,this.history.reset(!0),this._resourcesStateChange(),"function"==typeof h.onload)return h.onload(this,i)}.bind(this))},_initWysiwygArea:function(t,n){l.defaultStyle&&(e.element.wysiwyg.style.cssText=l.defaultStyle),t?n&&(e.element.wysiwyg.innerHTML=n):e.element.wysiwyg.innerHTML=this.convertContentsForEditor(e.element.originElement.value)},_resourcesStateChange:function(){d._iframeAutoHeight(),d._checkPlaceholder()},_iframeAutoHeight:function(){this._iframeAuto&&a.setTimeout((function(){e.element.wysiwygFrame.style.height=d._iframeAuto.offsetHeight+"px"}))},_checkPlaceholder:function(){if(this._placeholder){if(this._variable.isCodeView)return void(this._placeholder.style.display="none");const t=e.element.wysiwyg;!r.onlyZeroWidthSpace(t.textContent)||t.querySelector(".se-component, pre, blockquote, hr, li, table, img, iframe, video")||(t.innerText.match(/\n/g)||"").length>1?this._placeholder.style.display="none":this._placeholder.style.display="block"}},_setDefaultFormat:function(e){if(this._resizingName)return;const t=this.getRange(),n=t.commonAncestorContainer,i=t.startContainer,l=r.getRangeFormatElement(n,null);let s,o,a;if(!(r.getParentElement(n,r.isComponent)||(r.isRangeFormatElement(i)||r.isWysiwygDiv(i))&&r.isComponent(i.childNodes[t.startOffset]))){if(l)return a=r.createElement(e||"P"),a.innerHTML=l.innerHTML,0===a.childNodes.length&&(a.innerHTML=r.zeroWidthSpace),l.innerHTML=a.outerHTML,a=l.firstChild,s=r.getEdgeChildNodes(a,null).sc,s||(s=r.createTextNode(r.zeroWidthSpace),a.insertBefore(s,a.firstChild)),o=s.textContent.length,void this.setRange(s,o,s,o);if(r.isRangeFormatElement(n)&&n.childNodes.length<=1){let e=null;1===n.childNodes.length&&r.isBreak(n.firstChild)?e=n.firstChild:(e=r.createTextNode(r.zeroWidthSpace),n.appendChild(e)),this.setRange(e,1,e,1)}if(this.execCommand("formatBlock",!1,e||"P"),s=r.getEdgeChildNodes(n,n),s=s?s.ec:n,a=r.getFormatElement(s,null),!a)return this.removeRange(),void this._editorRange();if(r.isBreak(a.nextSibling)&&r.removeItem(a.nextSibling),r.isBreak(a.previousSibling)&&r.removeItem(a.previousSibling),r.isBreak(s)){const e=r.createTextNode(r.zeroWidthSpace);s.parentNode.insertBefore(e,s),s=e}o=3===s.nodeType?s.textContent.length:1,this.effectNode=null,this.setRange(s,o,s,o)}}},u={_directionKeyCode:new a.RegExp("^(8|13|3[2-9]|40|46)$"),_nonTextKeyCode:new a.RegExp("^(8|13|1[6-9]|20|27|3[3-9]|40|45|46|11[2-9]|12[0-3]|144|145)$"),_historyIgnoreKeyCode:new a.RegExp("^(1[6-9]|20|27|3[3-9]|40|45|11[2-9]|12[0-3]|144|145)$"),_onButtonsCheck:new a.RegExp("^(STRONG|U|EM|DEL|SUB|SUP)$"),_frontZeroWidthReg:new a.RegExp(r.zeroWidthSpace+"+",""),_keyCodeShortcut:{65:"A",66:"B",83:"S",85:"U",73:"I",89:"Y",90:"Z",219:"[",221:"]"},_shortcutCommand:function(e,t){let n=null;switch(u._keyCodeShortcut[e]){case"A":n="selectAll";break;case"B":n="STRONG";break;case"S":t&&(n="DEL");break;case"U":n="U";break;case"I":n="EM";break;case"Z":n=t?"redo":"undo";break;case"Y":n="redo";break;case"[":n="outdent";break;case"]":n="indent"}return!!n&&(d.commandHandler(d.commandMap[n],n),!0)},_applyTagEffects:function(){let t=d.getSelectionNode();if(t===d.effectNode)return;d.effectNode=t;const i=d.commandMap,s=this._onButtonsCheck,o=[],a=[],c=d.activePlugins,u=c.length;let h="";for(;t.firstChild;)t=t.firstChild;for(let e=t;!r.isWysiwygDiv(e)&&e;e=e.parentNode)if(1===e.nodeType&&!r.isBreak(e)){h=e.nodeName.toUpperCase(),a.push(h);for(let t,i=0;i0)&&(o.push("OUTDENT"),i.OUTDENT.removeAttribute("disabled")),-1===o.indexOf("INDENT")&&i.INDENT&&r.isListCell(e)&&!e.previousElementSibling&&(o.push("INDENT"),i.INDENT.setAttribute("disabled",!0))):s.test(h)&&(o.push(h),r.addClass(i[h],"active"))}for(let e in i)o.indexOf(e)>-1||(c.indexOf(e)>-1?n[e].active.call(d,null):i.OUTDENT&&/^OUTDENT$/i.test(e)?i.OUTDENT.setAttribute("disabled",!0):i.INDENT&&/^INDENT$/i.test(e)?i.INDENT.removeAttribute("disabled"):r.removeClass(i[e],"active"));d._variable.currentNodes=a.reverse(),l.showPathLabel&&(e.element.navigation.textContent=d._variable.currentNodes.join(" > "))},_cancelCaptionEdit:function(){this.setAttribute("contenteditable",!1),this.removeEventListener("blur",u._cancelCaptionEdit)},onMouseDown_toolbar:function(e){let t=e.target;if(d._bindControllersOff&&e.stopPropagation(),/^(input|textarea|select|option)$/i.test(t.nodeName)?d._antiBlur=!1:e.preventDefault(),r.getParentElement(t,".se-submenu"))e.stopPropagation(),d._notHideToolbar=!0;else{let n=t.getAttribute("data-command"),i=t.className;for(;!n&&!/se-menu-list/.test(i)&&!/se-toolbar/.test(i);)t=t.parentNode,n=t.getAttribute("data-command"),i=t.className;n!==d._submenuName&&n!==d._containerName||e.stopPropagation()}},onClick_toolbar:function(e){let t=e.target,n=t.getAttribute("data-display"),i=t.getAttribute("data-command"),l=t.className;for(;t.parentNode&&!i&&!/se-menu-list/.test(l)&&!/se-toolbar/.test(l);)t=t.parentNode,i=t.getAttribute("data-command"),n=t.getAttribute("data-display"),l=t.className;(i||n)&&(t.disabled||(d.hasFocus||d.nativeFocus(),d._variable.isCodeView||d._editorRange(),d.actionCall(i,n,t)))},onMouseDown_wysiwyg:function(t){if("false"===e.element.wysiwyg.getAttribute("contenteditable"))return;const n=r.getParentElement(t.target,r.isCell);if(n){const e=d.plugins.table;e&&n!==e._fixedCell&&!e._shift&&d.callPlugin("table",(function(){e.onTableCellMultiSelect.call(d,n,!1)}),null)}d._isBalloon&&u._hideToolbar(),h.onMouseDown&&h.onMouseDown(t,d)},onClick_wysiwyg:function(t){const n=t.target;if("false"===e.element.wysiwyg.getAttribute("contenteditable"))return;if(/^FIGURE$/i.test(n.nodeName)){const e=n.querySelector("IMG"),i=n.querySelector("IFRAME");if(e)return t.preventDefault(),void d.selectComponent(e,"image");if(i)return t.preventDefault(),void d.selectComponent(i,"video")}const i=r.getParentElement(n,"FIGCAPTION");if(i&&(!i.getAttribute("contenteditable")||"false"===i.getAttribute("contenteditable"))&&(t.preventDefault(),i.setAttribute("contenteditable",!0),i.focus(),d._isInline&&!d._inlineToolbarAttr.isShow)){u._showToolbarInline();const e=function(){u._hideToolbar(),i.removeEventListener("blur",e)};i.addEventListener("blur",e)}a.setTimeout(d._editorRange.bind(d)),d._editorRange();const l=d.getSelectionNode(),s=r.getFormatElement(l,null),o=r.getRangeFormatElement(l,null);if(s&&s!==o||"false"===n.getAttribute("contenteditable"))u._applyTagEffects();else{if(r.isList(o)){const e=r.createElement("LI"),t=l.nextElementSibling;e.appendChild(l),o.insertBefore(e,t)}else r.isWysiwygDiv(l)||r.isComponent(l)||d._setDefaultFormat(r.isRangeFormatElement(o)?"DIV":"P");t.preventDefault(),d.focus()}d._isBalloon&&a.setTimeout(u._toggleToolbarBalloon),h.onClick&&h.onClick(t,d)},_balloonDelay:null,_showToolbarBalloonDelay:function(){u._balloonDelay&&a.clearTimeout(u._balloonDelay),u._balloonDelay=a.setTimeout(function(){a.clearTimeout(this._balloonDelay),this._balloonDelay=null,this._showToolbarBalloon()}.bind(u),350)},_toggleToolbarBalloon:function(){d._editorRange();const e=d.getRange();"table"===d.currentControllerName||!d._isBalloonAlways&&e.collapsed?u._hideToolbar():u._showToolbarBalloon(e)},_showToolbarBalloon:function(t){if(!d._isBalloon)return;const n=t||d.getRange(),i=e.element.toolbar,l=d.getSelection();let s;if(d._isBalloonAlways&&n.collapsed)s=!0;else if(l.focusNode===l.anchorNode)s=l.focusOffset0&&u._getPageBottomSpace()x&&(t=!1,y=!0),y&&(b=(t?n.top-m-g:n.bottom+g)-(n.noText?0:h)+d),i.style.left=a.Math.floor(v)+"px",i.style.top=a.Math.floor(b)+"px",t?(r.removeClass(e.element._arrow,"se-arrow-up"),r.addClass(e.element._arrow,"se-arrow-down"),e.element._arrow.style.top=m+"px"):(r.removeClass(e.element._arrow,"se-arrow-down"),r.addClass(e.element._arrow,"se-arrow-up"),e.element._arrow.style.top=-g+"px");const C=a.Math.floor(p/2+(f-v));e.element._arrow.style.left=(C+g>i.offsetWidth?i.offsetWidth-g:C";const e=m.attributes;for(;e[0];)m.removeAttribute(e[0].name);return d.nativeFocus(),!1}if(m&&c.startContainer===c.endContainer&&3===o.nodeType&&!r.isFormatElement(o.parentNode)&&(c.collapsed?1===o.textContent.length:c.endOffset-c.startOffset===o.textContent.length)){t.preventDefault();let e=null,n=o.parentNode.previousSibling;const i=o.parentNode.nextSibling;n||(i?(n=i,e=0):(n=r.createElement("BR"),m.appendChild(n))),o.textContent="",r.removeItemAllParents(o,null,m),e="number"==typeof e?e:3===n.nodeType?n.textContent.length:1,d.setRange(n,e,n,e);break}const n=c.commonAncestorContainer;if(m=r.getFormatElement(c.startContainer,null),f=r.getRangeFormatElement(m,null),f&&m&&!r.isCell(f)&&!/^FIGCAPTION$/i.test(f.nodeName)){if(r.isListCell(m)&&r.isList(f)&&(r.isListCell(f.parentNode)||m.previousElementSibling)&&(o===m||3===o.nodeType&&(!o.previousSibling||r.isList(o.previousSibling)))&&(r.getFormatElement(c.startContainer,null)!==r.getFormatElement(c.endContainer,null)?f.contains(c.startContainer):0===c.startOffset&&c.collapsed)){if(c.startContainer!==c.endContainer)t.preventDefault(),d.removeNode(),3===c.startContainer.nodeType&&d.setRange(c.startContainer,c.startContainer.textContent.length,c.startContainer,c.startContainer.textContent.length),d.history.push(!0);else{let e=m.previousElementSibling||f.parentNode;if(r.isListCell(e)){t.preventDefault();let n=e;if(!e.contains(m)&&r.isListCell(n)&&r.isList(n.lastElementChild)){for(n=n.lastElementChild.lastElementChild;r.isListCell(n)&&r.isList(n.lastElementChild);)n=n.lastElementChild&&n.lastElementChild.lastElementChild;e=n}let i=e===f.parentNode?f.previousSibling:e.lastChild;i||(i=r.createTextNode(r.zeroWidthSpace),f.parentNode.insertBefore(i,f.parentNode.firstChild));const l=3===i.nodeType?i.textContent.length:1,s=m.childNodes;let o=i,a=s[0];for(;a=s[0];)e.insertBefore(a,o.nextSibling),o=a;r.removeItem(m),0===f.children.length&&r.removeItem(f),d.setRange(i,l,i,l),d.history.push(!0)}}break}if(!g&&0===c.startOffset){let e=!0,i=n;for(;i&&i!==f&&!r.isWysiwygDiv(i);){if(i.previousSibling&&(1===i.previousSibling.nodeType||!r.onlyZeroWidthSpace(i.previousSibling.textContent.trim()))){e=!1;break}i=i.parentNode}if(e&&f.parentNode){t.preventDefault(),d.detachRangeFormatElement(f,r.isListCell(m)?[m]:null,null,!1,!1),d.history.push(!0);break}}}if(!g&&0===c.startOffset&&(r.isComponent(n.previousSibling)||3===n.nodeType&&!n.previousSibling&&0===c.startOffset&&0===c.endOffset&&r.isComponent(m.previousSibling))){let e=m.previousSibling;r.hasClass(e,"se-image-container")||/^IMG$/i.test(e.nodeName)?(e=/^IMG$/i.test(e.nodeName)?e:e.querySelector("img"),d.selectComponent(e,"image"),0===m.textContent.length&&r.removeItem(m)):r.hasClass(e,"se-video-container")&&(d.selectComponent(e.querySelector("iframe"),"video"),0===m.textContent.length&&r.removeItem(m));break}break;case 46:if(p){t.preventDefault(),t.stopPropagation(),d.plugins[p].destroy.call(d);break}if((r.isFormatElement(o)||null===o.nextSibling)&&c.startOffset===o.textContent.length){let e=m.nextElementSibling;if(!e){t.preventDefault();break}if(r.isComponent(e)){if(t.preventDefault(),r.onlyZeroWidthSpace(m)&&(r.removeItem(m),r.isTable(e))){let t=r.getChildElement(e,r.isCell,!1);t=t.firstElementChild||t,d.setRange(t,0,t,0);break}(r.hasClass(e,"se-component")||/^(IMG|IFRAME)$/i.test(e.nodeName))&&(t.stopPropagation(),r.hasClass(e,"se-image-container")||/^IMG$/i.test(e.nodeName)?(e=/^IMG$/i.test(e.nodeName)?e:e.querySelector("img"),d.selectComponent(e,"image")):r.hasClass(e,"se-video-container")&&d.selectComponent(e.querySelector("iframe"),"video"));break}}if(m=r.getFormatElement(c.startContainer,null),f=r.getRangeFormatElement(m,null),r.isListCell(m)&&r.isList(f)&&(o===m||3===o.nodeType&&(!o.nextSibling||r.isList(o.nextSibling))&&(r.getFormatElement(c.startContainer,null)!==r.getFormatElement(c.endContainer,null)?f.contains(c.endContainer):c.endOffset===o.textContent.length&&c.collapsed))){c.startContainer!==c.endContainer&&d.removeNode();let e=r.getArrayItem(m.children,r.isList,!1);if(e=e||m.nextElementSibling||f.parentNode.nextElementSibling,e&&(r.isList(e)||r.getArrayItem(e.children,r.isList,!1))){let n,i;if(t.preventDefault(),r.isList(e)){const t=e.firstElementChild;for(i=t.childNodes,n=i[0];i[0];)m.insertBefore(i[0],e);r.removeItem(t)}else{for(n=e.firstChild,i=e.childNodes;i[0];)m.appendChild(i[0]);r.removeItem(e)}d.setRange(n,0,n,0),d.history.push(!0)}break}break;case 9:if(p)break;if(t.preventDefault(),l||s||r.isWysiwygDiv(o))break;const _=!c.collapsed||d.isEdgePoint(c.startContainer,c.startOffset),b=d.getSelectedElements(null);o=d.getSelectionNode();const v=[];let y=[],x=r.isListCell(b[0]),C=r.isListCell(b[b.length-1]),w={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset};for(let e,t=0,n=b.length;t0&&_&&d.plugins.list)w=d.plugins.list.editInsideList.call(d,i,v);else{const e=r.getParentElement(o,r.isCell);if(e&&_){const t=r.getParentElement(e,"table"),n=r.getListChildren(t,r.isCell);let l=i?r.prevIdx(n,e):r.nextIdx(n,e);l!==n.length||i||(l=0),-1===l&&i&&(l=n.length-1);let s=n[l];if(!s)break;s=s.firstElementChild||s,d.setRange(s,0,s,0);break}y=y.concat(v),x=C=null}if(y.length>0)if(i){const e=y.length-1;for(let t,n=0;n<=e;n++){t=y[n].childNodes;for(let e,n=0,i=t.length;n0&&r.isBreak(i[l-1])||!e&&r.onlyZeroWidthSpace(o.textContent)&&r.isBreak(s)&&(r.isBreak(s.previousSibling)||!r.onlyZeroWidthSpace(s.previousSibling.textContent))&&(!a||!r.isBreak(a)&&r.onlyZeroWidthSpace(a.textContent)))){e?r.removeItem(i[l-1]):r.removeItem(o);const t=d.appendFormatTag(E,r.isFormatElement(E.nextElementSibling)?E.nextElementSibling:null);r.copyFormatAttributes(t,E),d.setRange(t,1,t,1);break}if(e){h.insertHTML(c.collapsed&&r.isBreak(c.startContainer.childNodes[c.startOffset-1])?"
    ":"

    ",!0);let e=n.focusNode;const t=n.focusOffset;E===e&&(e=e.childNodes[t-l>1?t-1:t]),d.setRange(e,1,e,1)}else{const e=n.focusNode.nextSibling,t=r.createElement("BR");d.insertNode(t,null);const i=t.previousSibling,l=t.nextSibling;r.isBreak(e)||r.isBreak(i)||l&&!r.onlyZeroWidthSpace(l)?d.setRange(l,0,l,0):(t.parentNode.insertBefore(t.cloneNode(!1),t),d.setRange(t,1,t,1))}u._onShortcutKey=!0;break}if(g)break;if(f&&m&&!r.isCell(f)&&!/^FIGCAPTION$/i.test(f.nodeName)){const e=d.getRange();if((3!==e.commonAncestorContainer.nodeType||!e.commonAncestorContainer.nextElementSibling)&&r.onlyZeroWidthSpace(m.innerText.trim())){t.preventDefault();let e=null;if(r.isListCell(f.parentNode)){f=m.parentNode.parentNode.parentNode;const t=r.splitElement(m,null,r.getElementDepth(m)-2);e=r.createElement("LI"),f.insertBefore(e,t)}else{const t=r.isCell(f.parentNode)?"DIV":r.isList(f.parentNode)?"LI":r.isFormatElement(f.nextElementSibling)?f.nextElementSibling.nodeName:r.isFormatElement(f.previousElementSibling)?f.previousElementSibling.nodeName:"P";e=r.createElement(t);const n=d.detachRangeFormatElement(f,[m],null,!0,!0);n.cc.insertBefore(e,n.ec)}e.innerHTML="
    ",r.copyFormatAttributes(e,m),r.removeItemAllParents(m,null,null),d.setRange(e,1,e,1);break}}if(f&&r.getParentElement(f,"FIGCAPTION")&&r.getParentElement(f,r.isList)&&(t.preventDefault(),m=d.appendFormatTag(m,null),d.setRange(m,0,m,0)),p){t.preventDefault(),t.stopPropagation();const n=e[p],i=n._container,l=i.previousElementSibling||i.nextElementSibling;let s=null;r.isListCell(i.parentNode)?s=r.createElement("BR"):(s=r.createElement(r.isFormatElement(l)?l.nodeName:"P"),s.innerHTML="
    "),i.parentNode.insertBefore(s,i),d.callPlugin(p,(function(){const e=d.plugins.resizing.call_controller_resize.call(d,n._element,p);d.plugins[p].onModifyMode.call(d,n._element,e)}),null)}break;case 27:if(p)return t.preventDefault(),t.stopPropagation(),d.controllersOff(),!1}if(i&&/16/.test(n)){t.preventDefault(),t.stopPropagation();const e=d.plugins.table;if(e&&!e._shift&&!e._ref){const t=r.getParentElement(m,r.isCell);if(t)return void e.onTableCellMultiSelect.call(d,t,!0)}}if(!(l||s||g||u._nonTextKeyCode.test(n))&&c.collapsed&&c.startContainer===c.endContainer&&r.isBreak(c.commonAncestorContainer)){const e=r.createTextNode(r.zeroWidthSpace);d.insertNode(e,null),d.setRange(e,1,e,1)}h.onKeyDown&&h.onKeyDown(t,d)},onKeyUp_wysiwyg:function(e){if(u._onShortcutKey)return;d._editorRange();const t=d.getRange(),n=e.keyCode,i=e.ctrlKey||e.metaKey||91===n||92===n,l=e.altKey;let s=d.getSelectionNode();if(d._isBalloon&&(d._isBalloonAlways&&27!==n||!t.collapsed)){if(!d._isBalloonAlways)return void u._showToolbarBalloon();27!==n&&u._showToolbarBalloonDelay()}if(8===n&&r.isWysiwygDiv(s)&&""===s.textContent){e.preventDefault(),e.stopPropagation(),s.innerHTML="";const t=r.createElement(r.isFormatElement(d._variable.currentNodes[0])?d._variable.currentNodes[0]:"P");return t.innerHTML="
    ",s.appendChild(t),d.setRange(t,0,t,0),u._applyTagEffects(),void d.history.push(!1)}const o=r.getFormatElement(s,null),a=r.getRangeFormatElement(s,null);if((o||!t.collapsed)&&o!==a||r.isComponent(s)||(d._setDefaultFormat(r.isRangeFormatElement(a)?"DIV":"P"),s=d.getSelectionNode()),u._directionKeyCode.test(n)&&u._applyTagEffects(),!i&&!l&&!u._nonTextKeyCode.test(n)&&3===s.nodeType&&r.zeroWidthRegExp.test(s.textContent)&&r.getByteLength(e.key)<3){let e=t.startOffset,n=t.endOffset;const i=(s.textContent.substring(0,n).match(u._frontZeroWidthReg)||"").length;e=t.startOffset-i,n=t.endOffset-i,s.textContent=s.textContent.replace(r.zeroWidthRegExp,""),d.setRange(s,e<0?0:e,s,n<0?0:n)}d._charCount(""),d.history.push(!0),h.onKeyUp&&h.onKeyUp(e,d)},onScroll_wysiwyg:function(e){d.controllersOff(),d._lineBreaker.style.display="none",d._isBalloon&&u._hideToolbar(),h.onScroll&&h.onScroll(e,d)},onFocus_wysiwyg:function(e){d._antiBlur||(d.hasFocus=!0,d._isInline&&u._showToolbarInline(),h.onFocus&&h.onFocus(e,d))},onBlur_wysiwyg:function(e){d._antiBlur||(d.hasFocus=!1,d.controllersOff(),(d._isInline||d._isBalloon)&&u._hideToolbar(),h.onBlur&&h.onBlur(e,d))},onMouseDown_resizingBar:function(t){t.stopPropagation(),d._variable.resizeClientY=t.clientY,e.element.resizeBackground.style.display="block",o.addEventListener("mousemove",u._resize_editor),o.addEventListener("mouseup",(function t(){e.element.resizeBackground.style.display="none",o.removeEventListener("mousemove",u._resize_editor),o.removeEventListener("mouseup",t)}))},_resize_editor:function(t){const n=e.element.editorArea.offsetHeight+(t.clientY-d._variable.resizeClientY);e.element.wysiwygFrame.style.height=e.element.code.style.height=(n=n+s?(d._sticky||u._onStickyToolbar(),t.toolbar.style.top=n+s+l.stickyToolbar-i-d._variable.minResizingSize+"px"):i>=s&&u._onStickyToolbar()},_getEditorOffsets:function(){let t=e.element.topArea,n=0,i=0,l=0;for(;t;)n+=t.offsetTop,i+=t.offsetLeft,l+=t.scrollTop,t=t.offsetParent;return{top:n,left:i,scroll:l}},_getPageBottomSpace:function(){return o.documentElement.scrollHeight-(u._getEditorOffsets().top+e.element.topArea.offsetHeight)},_onStickyToolbar:function(){const t=e.element;d._isInline||(t._stickyDummy.style.height=t.toolbar.offsetHeight+"px",t._stickyDummy.style.display="block"),t.toolbar.style.top=l.stickyToolbar+"px",t.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:t.toolbar.offsetWidth+"px",r.addClass(t.toolbar,"se-toolbar-sticky"),d._sticky=!0},_offStickyToolbar:function(){const t=e.element;t._stickyDummy.style.display="none",t.toolbar.style.top=d._isInline?d._inlineToolbarAttr.top:"",t.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:"",t.editorArea.style.marginTop="",r.removeClass(t.toolbar,"se-toolbar-sticky"),d._sticky=!1},_codeViewAutoHeight:function(){e.element.code.style.height=e.element.code.scrollHeight+"px"},onPaste_wysiwyg:function(e){const t=e.clipboardData;if(!t)return!0;const n=t.getData("text/plain").replace(/\n/g,""),i=d.cleanHTML(t.getData("text/html"),d.pasteTagsWhitelistRegExp),s=d._charCount("byte-html"===l.charCounterType?i:n);return("function"!=typeof h.onPaste||h.onPaste(e,i,s,d))&&s?void(i?(e.stopPropagation(),e.preventDefault(),h.insertHTML(i,!0)):d.history.push(!0)):(e.preventDefault(),e.stopPropagation(),!1)},onCut_wysiwyg:function(){a.setTimeout((function(){d.history.push(!1)}))},onDragOver_wysiwyg:function(e){e.preventDefault()},onDrop_wysiwyg:function(t){const n=t.dataTransfer;if(!n)return!0;const i=n.files;if(i.length>0&&d.plugins.image)u._setDropLocationSelection(t),d.callPlugin("image",(function(){e.image.imgInputFile.files=i,d.plugins.image.onRender_imgInput.call(d),e.image.imgInputFile.files=null}),null);else{if(!d._charCount(n.getData("text/plain")))return t.preventDefault(),t.stopPropagation(),!1;{const e=d.cleanHTML(n.getData("text/html"),d.pasteTagsWhitelistRegExp);e&&(u._setDropLocationSelection(t),h.insertHTML(e,!0))}}h.onDrop&&h.onDrop(t,d)},onmouseMove_wysiwyg:function(t){const n=r.getParentElement(t.target,r.isComponent),i=d._lineBreaker.style;if(n){let s=0,o=e.element.wysiwyg;do{s+=o.scrollTop,o=o.parentElement}while(o&&!/^(BODY|HTML)$/i.test(o.nodeName));const a=e.element.wysiwyg.scrollTop,c=u._getEditorOffsets(),h=r.getOffset(n,e.element.wysiwygFrame).top+a,g=t.pageY+s+(l.iframe?e.element.toolbar.offsetHeight:0),p=h+(l.iframe?s:c.top);let m="",f="";if(!r.isFormatElement(n.previousElementSibling)&&gp+n.offsetHeight-20))return void(i.display="none");f=h+n.offsetHeight,m="b"}d._variable._lineBreakComp=n,d._variable._lineBreakDir=m,i.top=f-a+"px",i.visibility="hidden",i.display="block",d._lineBreakerButton.style.left=n.offsetLeft+n.offsetWidth/2-d._lineBreakerButton.offsetWidth/2+"px",i.visibility=""}else"none"!==i.display&&(i.display="none")},_onMouseDown_lineBreak:function(e){e.preventDefault()},_onLineBreak:function(){const e=d._variable._lineBreakComp,t=r.createElement("P");t.innerHTML="
    ",e.parentNode.insertBefore(t,"t"===d._variable._lineBreakDir?e:e.nextSibling),d._lineBreaker.style.display="none",d._variable._lineBreakComp=null,d.setRange(t.firstChild,1,t.firstChild,1),d.history.push(!1)},_setDropLocationSelection:function(e){e.stopPropagation(),e.preventDefault();const t=d.getRange();d.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)},_onChange_historyStack:function(){u._applyTagEffects(),e.tool.save&&e.tool.save.removeAttribute("disabled"),h.onChange&&h.onChange(d.getContents(!0),d)},_addEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.addEventListener("mousedown",u.onMouseDown_toolbar,!1),e.element.toolbar.addEventListener("click",u.onClick_toolbar,!1),t.addEventListener("mousedown",u.onMouseDown_wysiwyg,!1),t.addEventListener("click",u.onClick_wysiwyg,!1),t.addEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg,!1),t.addEventListener("keydown",u.onKeyDown_wysiwyg,!1),t.addEventListener("keyup",u.onKeyUp_wysiwyg,!1),t.addEventListener("paste",u.onPaste_wysiwyg,!1),t.addEventListener("cut",u.onCut_wysiwyg,!1),t.addEventListener("dragover",u.onDragOver_wysiwyg,!1),t.addEventListener("drop",u.onDrop_wysiwyg,!1),t.addEventListener("scroll",u.onScroll_wysiwyg,!1),t.addEventListener("focus",u.onFocus_wysiwyg,!1),t.addEventListener("blur",u.onBlur_wysiwyg,!1),t.addEventListener("mousemove",u.onmouseMove_wysiwyg,!1),d._lineBreakerButton.addEventListener("mousedown",u._onMouseDown_lineBreak,!1),d._lineBreakerButton.addEventListener("click",u._onLineBreak,!1),d.plugins.table&&t.addEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.addEventListener("keydown",u._codeViewAutoHeight,!1),e.element.code.addEventListener("keyup",u._codeViewAutoHeight,!1),e.element.code.addEventListener("paste",u._codeViewAutoHeight,!1)),e.element.resizingBar&&(/\d+/.test(l.height)?e.element.resizingBar.addEventListener("mousedown",u.onMouseDown_resizingBar,!1):r.addClass(e.element.resizingBar,"se-resizing-none")),a.removeEventListener("resize",u.onResize_window),a.removeEventListener("scroll",u.onScroll_window),a.addEventListener("resize",u.onResize_window,!1),l.stickyToolbar>-1&&a.addEventListener("scroll",u.onScroll_window,!1)},_removeEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.removeEventListener("mousedown",u.onMouseDown_toolbar),e.element.toolbar.removeEventListener("click",u.onClick_toolbar),t.removeEventListener("mousedown",u.onMouseDown_wysiwyg),t.removeEventListener("click",u.onClick_wysiwyg),t.removeEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg),t.removeEventListener("keydown",u.onKeyDown_wysiwyg),t.removeEventListener("keyup",u.onKeyUp_wysiwyg),t.removeEventListener("paste",u.onPaste_wysiwyg),t.removeEventListener("cut",u.onCut_wysiwyg),t.removeEventListener("dragover",u.onDragOver_wysiwyg),t.removeEventListener("drop",u.onDrop_wysiwyg),t.removeEventListener("scroll",u.onScroll_wysiwyg),t.removeEventListener("mousemove",u.onmouseMove_wysiwyg),d._lineBreakerButton.removeEventListener("mousedown",u._onMouseDown_lineBreak),d._lineBreakerButton.removeEventListener("click",u._onLineBreak),t.removeEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),t.removeEventListener("focus",u.onFocus_wysiwyg),t.removeEventListener("blur",u.onBlur_wysiwyg),e.element.code.removeEventListener("keydown",u._codeViewAutoHeight),e.element.code.removeEventListener("keyup",u._codeViewAutoHeight),e.element.code.removeEventListener("paste",u._codeViewAutoHeight),e.element.resizingBar&&e.element.resizingBar.removeEventListener("mousedown",u.onMouseDown_resizingBar),a.removeEventListener("resize",u.onResize_window),a.removeEventListener("scroll",u.onScroll_window)}},h={core:d,util:r,onload:null,onScroll:null,onMouseDown:null,onClick:null,onInput:null,onKeyDown:null,onKeyUp:null,onDrop:null,onChange:null,onPaste:null,onFocus:null,onBlur:null,showInline:null,showController:null,imageUploadHandler:null,onImageUploadBefore:null,onImageUpload:null,onImageUploadError:null,onVideoUpload:null,setOptions:function(s){u._removeEvent(),d.plugins=s.plugins||d.plugins;const o=[s,s].reduce((function(e,t){for(let n in t)if("plugins"===n&&t[n]&&e[n]){let i=e[n],l=t[n];i=i.length?i:a.Object.keys(i).map((function(e){return i[e]})),l=l.length?l:a.Object.keys(l).map((function(e){return l[e]})),e[n]=l.filter((function(e){return-1===i.indexOf(e)})).concat(i)}else e[n]=t[n];return e}),{}),r=b._setOptions(o,e,d.plugins,s);r.callButtons&&(t=r.callButtons,d.initPlugins={}),r.plugins&&(d.plugins=n=r.plugins);const c=e.element.wysiwyg.innerHTML,h=e.element,g={_top:h.topArea,_relative:h.relative,_toolBar:h.toolbar,_editorArea:h.editorArea,_wysiwygArea:h.wysiwygFrame,_codeArea:h.code,_placeholder:h.placeholder,_resizingBar:h.resizingBar,_navigation:h.navigation,_charCounter:h.charCounter,_charWrapper:h.charWrapper,_loading:h.loading,_lineBreaker:h.lineBreaker,_resizeBack:h.resizeBackground,_stickyDummy:h._stickyDummy,_arrow:h._arrow};l=o,d.lang=i=l.lang,d.context=e=v(e.element.originElement,g,l),d._componentsInfoReset=!0,d._init(!0,c),u._addEvent(),d._charCount(""),u._offStickyToolbar(),u.onResize_window()},setDefaultStyle:function(t){const n=r._setDefaultOptionStyle(l);"string"==typeof t&&t.trim().length>0?e.element.wysiwyg.style.cssText=n+t:e.element.wysiwyg.style.cssText=n},noticeOpen:function(e){d.notice.open.call(d,e)},noticeClose:function(){d.notice.close.call(d)},save:function(){e.element.originElement.value=d.getContents(!1)},getContext:function(){return e},getContents:function(e){return d.getContents(e)},getCharCount:function(t){return t="string"==typeof t?t:l.charCounterType,d._getCharLength("byte-html"===t?e.element.wysiwyg.innerHTML:e.element.wysiwyg.textContent,t)},getImagesInfo:function(){return e.image?e.image._imagesInfo:[]},getVideosInfo:function(){return e.video?e.video._videosInfo:[]},insertImage:function(e){d.plugins.image&&e&&(d.initPlugins.image?d.plugins.image.submitAction.call(d,e):d.callPlugin("image",d.plugins.image.submitAction.bind(d,e),null),d.focus())},insertHTML:function(e,t){if("string"==typeof e){t||(e=d.cleanHTML(e,null));try{const t=o.createRange().createContextualFragment(e).childNodes;let n,i,l;for(;n=t[0];)l=d.insertNode(n,i),i=n;const s=3===i.nodeType?l.endOffset||i.textContent.length:i.childNodes.length;d.setRange(i,s,i,s)}catch(t){d.execCommand("insertHTML",!1,e)}}else if(r.isComponent(e))d.insertComponent(e,!1);else{let t=null;(r.isFormatElement(e)||r.isMedia(e))&&(t=r.getFormatElement(d.getSelectionNode(),null)),d.insertNode(e,t)}d.effectNode=null,d.focus(),d.history.push(!1)},setContents:function(e){d.setContents(e)},appendContents:function(t){const n=d.convertContentsForEditor(t);if(d._variable.isCodeView)d._setCodeView(d._getCodeView()+"\n"+d.convertHTMLForCodeView(n));else{const t=r.createElement("DIV");t.innerHTML=n;const i=e.element.wysiwyg,l=t.children;for(let e=0,t=l.length;e
    ",n},_module_getSizeX:function(e,t,n,i){return t||(t=e._element),n||(n=e._cover),i||(i=e._container),i&&n&&t?/%$/.test(t.style.width)?(this.util.getNumber(i.style.width,2)||100)+"%":t.style.width:""},_module_getSizeY:function(e,t,n,i){return t||(t=e._element),n||(n=e._cover),i||(i=e._container),i&&n&&t?this.util.getNumber(n.style.paddingBottom,0)>0&&!this.context.resizing._rotateVertical?n.style.height:/%$/.test(t.style.height)&&/%$/.test(t.style.width)?(this.util.getNumber(i.style.height,2)||100)+"%":t.style.height:""},_module_setModifyInputSize:function(e,t){const n=e._onlyPercentage&&this.context.resizing._rotateVertical;e.proportion.checked=e._proportionChecked="false"!==e._element.getAttribute("data-proportion");let i=n?"":this.plugins.resizing._module_getSizeX.call(this,e);if(i===e._defaultSizeX&&(i=""),e._onlyPercentage&&(i=this.util.getNumber(i,2)),e.inputX.value=i,t.setInputSize.call(this,"x"),!e._onlyPercentage){let t=n?"":this.plugins.resizing._module_getSizeY.call(this,e);t===e._defaultSizeY&&(t=""),e._onlyPercentage&&(t=this.util.getNumber(t,2)),e.inputY.value=t}e.inputX.disabled=!!n,e.inputY.disabled=!!n,e.proportion.disabled=!!n,t.setRatio.call(this)},_module_setInputSize:function(e,t){if(e._onlyPercentage)"x"===t&&e.inputX.value>100&&(e.inputX.value=100);else if(e.proportion.checked&&e._ratio&&/\d/.test(e.inputX.value)&&/\d/.test(e.inputY.value)){const n=e.inputX.value.replace(/\d+|\./g,"")||e.sizeUnit,i=e.inputY.value.replace(/\d+|\./g,"")||e.sizeUnit;if(n!==i)return;const l="%"===n?2:0;"x"===t?e.inputY.value=this.util.getNumber(e._ratioY*this.util.getNumber(e.inputX.value,l),l)+i:e.inputX.value=this.util.getNumber(e._ratioX*this.util.getNumber(e.inputY.value,l),l)+n}},_module_setRatio:function(e){const t=e.inputX.value,n=e.inputY.value;if(e.proportion.checked&&/\d+/.test(t)&&/\d+/.test(n)){if((t.replace(/\d+|\./g,"")||e.sizeUnit)!==(n.replace(/\d+|\./g,"")||e.sizeUnit))e._ratio=!1;else if(!e._ratio){const i=this.util.getNumber(t,0),l=this.util.getNumber(n,0);e._ratio=!0,e._ratioX=i/l,e._ratioY=l/i}}else e._ratio=!1},_module_sizeRevert:function(e){e._onlyPercentage?e.inputX.value=e._origin_w>100?100:e._origin_w:(e.inputX.value=e._origin_w,e.inputY.value=e._origin_h)},_module_saveCurrentSize:function(e){const t=this.plugins.resizing._module_getSizeX.call(this,e),n=this.plugins.resizing._module_getSizeY.call(this,e);e._element.setAttribute("data-size",t+","+n),e._videoRatio&&(e._videoRatio=n)},call_controller_resize:function(e,t){const n=this.context.resizing,i=this.context[t];n._resize_plugin=t;const l=n.resizeContainer,s=n.resizeDiv,o=this.util.getOffset(e,this.context.element.wysiwygFrame),a=n._rotateVertical=/^(90|270)$/.test(Math.abs(e.getAttribute("data-rotate")).toString()),r=a?e.offsetHeight:e.offsetWidth,c=a?e.offsetWidth:e.offsetHeight,d=o.top,u=o.left-this.context.element.wysiwygFrame.scrollLeft;l.style.top=d+"px",l.style.left=u+"px",l.style.width=r+"px",l.style.height=c+"px",s.style.top="0px",s.style.left="0px",s.style.width=r+"px",s.style.height=c+"px";let h=e.getAttribute("data-align")||"basic";h="none"===h?"basic":h;const g=this.util.getParentElement(e,this.util.isComponent),p=this.util.getParentElement(e,"FIGURE"),m=this.plugins.resizing._module_getSizeX.call(this,i,e,p,g)||"auto",f=i._onlyPercentage&&"image"===t?"":", "+(this.plugins.resizing._module_getSizeY.call(this,i,e,p,g)||"auto");this.util.changeTxt(n.resizeDisplay,this.lang.dialogBox[h]+" ("+m+f+")"),n.resizeButtonGroup.style.display=i._resizing?"":"none";const _=!i._resizing||i._resizeDotHide||i._onlyPercentage?"none":"flex",b=n.resizeHandles;for(let e=0,t=b.length;e",e},set_cover:function(e){const t=this.util.createElement("FIGURE");return t.appendChild(e),t},set_container:function(e,t){const n=this.util.createElement("DIV");return n.className="se-component "+t,n.setAttribute("contenteditable",!1),n.appendChild(e),n},onClick_resizeButton:function(e){e.stopPropagation();const t=e.target,n=t.getAttribute("data-command")||t.parentNode.getAttribute("data-command");if(!n)return;const i=t.getAttribute("data-value")||t.parentNode.getAttribute("data-value"),l=this.context.resizing._resize_plugin,s=this.context[l],o=s._element,a=this.plugins[l];if(e.preventDefault(),"function"!=typeof this.plugins.resizing._closeAlignMenu||(this.plugins.resizing._closeAlignMenu(),"onalign"!==n)){switch(n){case"auto":a.setAutoSize.call(this),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"percent":let e=this.plugins.resizing._module_getSizeY.call(this,s);if(this.context.resizing._rotateVertical){const t=o.getAttribute("data-percentage");t&&(e=t.split(",")[1])}this.plugins.resizing.resetTransform.call(this,o),a.setPercentSize.call(this,100*i,null!==this.util.getNumber(e,0)&&/%$/.test(e)?e:""),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"mirror":const t=o.getAttribute("data-rotate")||"0";let n=o.getAttribute("data-rotateX")||"",r=o.getAttribute("data-rotateY")||"";"h"===i&&!this.context.resizing._rotateVertical||"v"===i&&this.context.resizing._rotateVertical?r=r?"":"180":n=n?"":"180",o.setAttribute("data-rotateX",n),o.setAttribute("data-rotateY",r),this.plugins.resizing._setTransForm(o,t,n,r);break;case"rotate":const c=this.context.resizing,d=1*o.getAttribute("data-rotate")+1*i,u=this._w.Math.abs(d)>=360?0:d;o.setAttribute("data-rotate",u),c._rotateVertical=/^(90|270)$/.test(this._w.Math.abs(u).toString()),this.plugins.resizing.setTransformSize.call(this,o,null,null),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"onalign":return void this.plugins.resizing.openAlignMenu.call(this);case"align":const h="basic"===i?"none":i;a.setAlign.call(this,h,null,null,null),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"caption":const g=!s._captionChecked;if(a.openModify.call(this,!0),s._captionChecked=s.captionCheckEl.checked=g,"image"===l?a.update_image.call(this,!1,!1,!1):"video"===l&&(this.context.dialog.updateModal=!0,a.submitAction.call(this)),g){const e=this.util.getChildElement(s._caption,(function(e){return 3===e.nodeType}));e?this.setRange(e,0,e,e.textContent.length):s._caption.focus(),this.controllersOff()}else a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l)),a.openModify.call(this,!0);break;case"revert":a.setOriginSize.call(this),a.onModifyMode.call(this,o,this.plugins.resizing.call_controller_resize.call(this,o,l));break;case"update":a.openModify.call(this),this.controllersOff();break;case"delete":a.destroy.call(this)}this.history.push(!1)}},resetTransform:function(e){const t=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.context.resizing._rotateVertical=!1,e.style.maxWidth="",e.style.transform="",e.style.transformOrigin="",e.setAttribute("data-rotate",""),e.setAttribute("data-rotateX",""),e.setAttribute("data-rotateY",""),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,t[0]?t[0]:"auto",t[1]?t[1]:"",!0)},setTransformSize:function(e,t,n){let i=e.getAttribute("data-percentage");const l=this.context.resizing._rotateVertical,s=1*e.getAttribute("data-rotate");let o="";if(i&&!l)i=i.split(","),"auto"===i[0]&&"auto"===i[1]?this.plugins[this.context.resizing._resize_plugin].setAutoSize.call(this):this.plugins[this.context.resizing._resize_plugin].setPercentSize.call(this,i[0],i[1]);else{const i=this.util.getParentElement(e,"FIGURE"),a=t||e.offsetWidth,r=n||e.offsetHeight,c=(l?r:a)+"px",d=(l?a:r)+"px";if(this.plugins[this.context.resizing._resize_plugin].cancelPercentAttr.call(this),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,a+"px",r+"px",!0),i.style.width=c,i.style.height=this.context[this.context.resizing._resize_plugin]._caption?"":d,l){let e=a/2+"px "+a/2+"px 0",t=r/2+"px "+r/2+"px 0";o=90===s||-270===s?t:e}}e.style.transformOrigin=o,this.plugins.resizing._setTransForm(e,s.toString(),e.getAttribute("data-rotateX")||"",e.getAttribute("data-rotateY")||""),e.style.maxWidth=l?"none":"",this.plugins.resizing.setCaptionPosition.call(this,e)},_setTransForm:function(e,t,n,i){let l=(e.offsetWidth-e.offsetHeight)*(/-/.test(t)?1:-1),s="";if(/[1-9]/.test(t)&&(n||i))switch(s=n?"Y":"X",t){case"90":s=n&&i?"X":i?s:"";break;case"270":l*=-1,s=n&&i?"Y":n?s:"";break;case"-90":s=n&&i?"Y":n?s:"";break;case"-270":l*=-1,s=n&&i?"X":i?s:"";break;default:s=""}t%180==0&&(e.style.maxWidth=""),e.style.transform="rotate("+t+"deg)"+(n?" rotateX("+n+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(s?" translate"+s+"("+l+"px)":"")},setCaptionPosition:function(e){const t=this.util.getChildElement(this.util.getParentElement(e,"FIGURE"),"FIGCAPTION");t&&(t.style.marginTop=(this.context.resizing._rotateVertical?e.offsetWidth-e.offsetHeight:0)+"px")},onMouseDown_resize_handle:function(e){const t=this.context.resizing,n=t._resize_direction=e.target.classList[0];e.stopPropagation(),e.preventDefault();const i=this.context.resizing._resize_plugin,l=this.context[i]._element,s=this.plugins[i];t._resizeClientX=e.clientX,t._resizeClientY=e.clientY,this.context.element.resizeBackground.style.display="block",t.resizeButton.style.display="none",t.resizeDiv.style.float=/l/.test(n)?"right":/r/.test(n)?"left":"none";const o=function(e){if("keydown"===e.type&&27!==e.keyCode)return;const i=t._isChange;t._isChange=!1,this.removeDocEvent("mousemove",a),this.removeDocEvent("mouseup",o),this.removeDocEvent("keydown",o),"keydown"===e.type?(this.controllersOff(),this.context.element.resizeBackground.style.display="none",this.plugins[this.context.resizing._resize_plugin].init.call(this)):(this.plugins.resizing.cancel_controller_resize.call(this,n),i&&this.history.push(!1)),s.onModifyMode.call(this,l,this.plugins.resizing.call_controller_resize.call(this,l,t._resize_plugin))}.bind(this),a=this.plugins.resizing.resizing_element.bind(this,t,n,this.context[t._resize_plugin]);this.addDocEvent("mousemove",a),this.addDocEvent("mouseup",o),this.addDocEvent("keydown",o)},resizing_element:function(e,t,n,i){const l=i.clientX,s=i.clientY;let o=n._element_w,a=n._element_h;const r=n._element_w+(/r/.test(t)?l-e._resizeClientX:e._resizeClientX-l),c=n._element_h+(/b/.test(t)?s-e._resizeClientY:e._resizeClientY-s),d=n._element_h/n._element_w*r;/t/.test(t)&&(e.resizeDiv.style.top=n._element_h-(/h/.test(t)?c:d)+"px"),/l/.test(t)&&(e.resizeDiv.style.left=n._element_w-r+"px"),/r|l/.test(t)&&(e.resizeDiv.style.width=r+"px",o=r),/^(t|b)[^h]$/.test(t)?(e.resizeDiv.style.height=d+"px",a=d):/^(t|b)h$/.test(t)&&(e.resizeDiv.style.height=c+"px",a=c),e._resize_w=o,e._resize_h=a,this.util.changeTxt(e.resizeDisplay,this._w.Math.round(o)+" x "+this._w.Math.round(a)),e._isChange=!0},cancel_controller_resize:function(e){const t=this.context.resizing._rotateVertical;this.controllersOff(),this.context.element.resizeBackground.style.display="none";let n=this._w.Math.round(t?this.context.resizing._resize_h:this.context.resizing._resize_w),i=this._w.Math.round(t?this.context.resizing._resize_w:this.context.resizing._resize_h);if(!t&&!/%$/.test(n)){const e=16,t=this.context.element.wysiwygFrame.clientWidth-2*e-2;this.util.getNumber(n,0)>t&&(i=this._w.Math.round(i/n*t),n=t)}this.plugins[this.context.resizing._resize_plugin].setSize.call(this,n,i,!1,e),this.plugins[this.context.resizing._resize_plugin].init.call(this)}};return void 0===t&&(e.SUNEDITOR_MODULES||(e.SUNEDITOR_MODULES={}),e.SUNEDITOR_MODULES.resizing=n),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_MODULES a window with a document");return l(e)}:l(i)}}); \ No newline at end of file diff --git a/src/plugins/submenu/table.js b/src/plugins/submenu/table.js index 52b139bda..610bae6fa 100644 --- a/src/plugins/submenu/table.js +++ b/src/plugins/submenu/table.js @@ -317,17 +317,21 @@ export default { tablePlugin.setPositionControllerDiv.call(this, tdElement, tablePlugin._shift); const tableElement = contextTable._element; - const offset = this.util.getOffset(tableElement, this.context.element.wysiwygFrame); - contextTable._maxWidth = this.util.hasClass(tableElement, 'se-table-size-100') || tableElement.style.width === '100%' || (!tableElement.style.width && !this.util.hasClass(tableElement, 'se-table-size-auto')); contextTable._fixedColumn = this.util.hasClass(tableElement, 'se-table-layout-fixed') || tableElement.style.tableLayout === 'fixed'; tablePlugin.setTableStyle.call(this, contextTable._maxWidth ? 'width|column' : 'width'); + tablePlugin.setPositionControllerTop.call(this, tableElement); + + if (!tablePlugin._shift) this.controllersOn(contextTable.resizeDiv, tableController, tablePlugin.init.bind(this), tdElement, 'table'); + }, + + setPositionControllerTop: function (tableElement) { + const tableController = this.context.table.tableController; + const offset = this.util.getOffset(tableElement, this.context.element.wysiwygFrame); tableController.style.left = offset.left + 'px'; tableController.style.display = 'block'; tableController.style.top = (offset.top - tableController.offsetHeight - 2) + 'px'; - - if (!tablePlugin._shift) this.controllersOn(contextTable.resizeDiv, tableController, tablePlugin.init.bind(this), tdElement, 'table'); }, setPositionControllerDiv: function (tdElement, reset) { @@ -1411,11 +1415,13 @@ export default { case 'resize': contextTable._maxWidth = !contextTable._maxWidth; tablePlugin.setTableStyle.call(this, 'width'); + tablePlugin.setPositionControllerTop.call(this, contextTable._element); tablePlugin.setPositionControllerDiv.call(this, contextTable._tdElement, tablePlugin._shift); break; case 'layout': contextTable._fixedColumn = !contextTable._fixedColumn; tablePlugin.setTableStyle.call(this, 'column'); + tablePlugin.setPositionControllerTop.call(this, contextTable._element); tablePlugin.setPositionControllerDiv.call(this, contextTable._tdElement, tablePlugin._shift); break; case 'remove':