p+o)&&w.push({cell:C,i:v,rs:v+T}),N+=D}else{if(_>=p)break;if(D>0){if(g<1&&D+_>=p){C.colSpan+=1,p=null,g=T+1;break}p-=D}if(!k){for(let M=0,O;M 1)d.colSpan=this._w.Math.floor(u/2),r.colSpan=u-d.colSpan,o.insertBefore(d,r.nextElementSibling);else{let g=[],y=[];for(let w=0,v=a._rowCnt,S,m;w "+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"",a.insertBefore(r,a.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 a,r,i,o;e.indexOf("width")>-1&&(a=t.resizeButton.firstElementChild,r=t.resizeText,t._maxWidth?(i=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")):(i=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(a,i),this.util.changeTxt(r,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.removeAttribute("disabled"),n.mergeButton.setAttribute("disabled",!0)):(n.splitButton.setAttribute("disabled",!0),n.mergeButton.removeAttribute("disabled"))},_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,a=n._selectedTable.rows,r=this.util,i=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let u=0,g=i.length;u p+b?d.ce:p+b,d.rs=d.rs!==null&&d.rsu+x?d.re:u+x,d._i+=1),d._i===2){o=!1,c=[],l=[],u=-1;break}}else if(r.getOverlapRangeAtIndex(d.cs,d.ce,p,p+b)&&r.getOverlapRangeAtIndex(d.rs,d.re,u,u+x)){const k=d.cs p+b?d.ce:p+b,_=d.rsu+x?d.re:u+x;if(d.cs!==k||d.ce!==N||d.rs!==_||d.re!==C){d.cs=k,d.ce=N,d.rs=_,d.re=C,u=-1,c=[],l=[];break}r.addClass(m,"se-table-selected-cell")}x>0&&l.push({index:p,cs:b+1,rs:x,row:-1}),w+=m.colSpan-1}c=c.concat(l).sort(function(v,S){return v.index-S.index}),l=[]}},_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 a=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let r=0,i=a.length;r-1?(u=d.toLowerCase(),g=u==="blockquote"?"range":u==="pre"?"free":"replace",w=/^h/.test(u)?u.match(/\d+/)[0]:"",y=n["tag_"+(w?"h":u)]+w,S="",v=""):(u=d.tag.toLowerCase(),g=d.command,y=d.name||u,S=d.class,v=S?' class="'+S+'"':""),o+='";return o+="",a.innerHTML=o,a},active:function(e){let t=this.lang.toolbar.formats;const n=this.context.formatBlock.targetText;if(!e)this.util.changeTxt(n,t);else if(this.util.isFormatElement(e)){const r=this.context.formatBlock._formatList,i=e.nodeName.toLowerCase(),o=(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let c=0,l=r.length,d;c =0){const c=this.context[r]._infoList;for(let l=0,d=c.length;l O?(p.style.height=H+"px",F=-1*(H-T+3)):(p.style.height=O+"px",F=T+m.parentElement.offsetHeight),p.style.top=F+"px"}else p.style.top=T+m.parentElement.offsetHeight+"px";p.style.visibility=""},controllersOn:function(){this._bindControllersOff&&this._bindControllersOff(),this.controllerArray=[];for(let m=0,p;m 0){for(let b=0;b E?C-E:0,P=D>0?0:E-C;m.style.left=_-D+P+"px",D>0&&T&&(T.style.left=(C-14<10+D?C-14:10+D)+"px");const M=e.element.wysiwygFrame.offsetLeft-m.offsetLeft;M>0&&(m.style.left="0px",T&&(T.style.left=M+"px"))}else{m.style.left=_+"px";const D=e.element.wysiwygFrame.offsetWidth-(m.offsetLeft+C);D<0?(m.style.left=m.offsetLeft+D+"px",T&&(T.style.left=20-D+"px")):T&&(T.style.left="20px")}m.style.visibility=""},execCommand:function(m,p,b){this._wd.execCommand(m,p,m==="formatBlock"?"<"+b+">":b),this.history.push(!0)},nativeFocus:function(){this.__focus(),this._editorRange()},__focus:function(){const m=l.getParentElement(this.getSelectionNode(),"figcaption");m?m.focus():e.element.wysiwyg.focus()},focus:function(){if(e.element.wysiwygFrame.style.display!=="none"){if(r.iframe)this.nativeFocus();else try{const m=this.getRange();if(m.startContainer===m.endContainer&&l.isWysiwygDiv(m.startContainer)){const p=m.commonAncestorContainer.children[m.startOffset];if(!l.isFormatElement(p)&&!l.isComponent(p)){const b=l.createElement(r.defaultTag),x=l.createElement("BR");b.appendChild(x),e.element.wysiwyg.insertBefore(b,p),this.setRange(x,0,x,0);return}}this.setRange(m.startContainer,m.startOffset,m.endContainer,m.endOffset)}catch{this.nativeFocus()}g._applyTagEffects(),this._isBalloon&&g._toggleToolbarBalloon()}},focusEdge:function(m){m||(m=e.element.wysiwyg.lastElementChild);const p=this.getFileComponent(m);p?this.selectComponent(p.target,p.pluginName):m?(m=l.getChildElement(m,function(b){return b.childNodes.length===0||b.nodeType===3},!0),m?this.setRange(m,m.textContent.length,m,m.textContent.length):this.nativeFocus()):this.focus()},blur:function(){r.iframe?e.element.wysiwygFrame.blur():e.element.wysiwyg.blur()},setRange:function(m,p,b,x){if(!m||!b)return;p>m.textContent.length&&(p=m.textContent.length),x>b.textContent.length&&(x=b.textContent.length),l.isFormatElement(m)&&(m=m.childNodes[p]||m.childNodes[p-1]||m,p=p>0?m.nodeType===1?1:m.textContent?m.textContent.length:0:0),l.isFormatElement(b)&&(b=b.childNodes[x]||b.childNodes[x-1]||b,x=x>0?b.nodeType===1?1:b.textContent?b.textContent.length:0:0);const k=this._wd.createRange();try{k.setStart(m,p),k.setEnd(b,x)}catch(_){console.warn("[SUNEDITOR.core.focus.error] "+_),this.nativeFocus();return}const N=this.getSelection();return N.removeAllRanges&&N.removeAllRanges(),N.addRange(k),this._rangeInfo(k,this.getSelection()),r.iframe&&this.__focus(),k},removeRange:function(){this._variable._range=null,this._variable._selectionNode=null,this.hasFocus&&this.getSelection().removeAllRanges(),this._setKeyEffect([])},getRange:function(){const m=this._variable._range||this._createDefaultRange(),p=this.getSelection();if(m.collapsed===p.isCollapsed||!e.element.wysiwyg.contains(p.focusNode))return m;if(p.rangeCount>0)return this._variable._range=p.getRangeAt(0),this._variable._range;{const b=p.anchorNode,x=p.focusNode,k=p.anchorOffset,N=p.focusOffset,_=l.compareElements(b,x),C=_.ancestor&&(_.result===0?k<=N:_.result>1);return this.setRange(C?b:x,C?k:N,C?x:b,C?N:k)}},getRange_addLine:function(m,p){if(this._selectionVoid(m)){const b=e.element.wysiwyg,x=l.createElement(r.defaultTag);x.innerHTML=" 0&&this.plugins.list.editInsideList.call(this,k,x),this.effectNode=null,this.setRange(_,E,C,T),this.history.push(!1)},toggleDisplayBlocks:function(){const m=e.element.wysiwyg;l.toggleClass(m,"se-show-block"),l.hasClass(m,"se-show-block")?l.addClass(this._styleCommandMap.showBlocks,"active"):l.removeClass(this._styleCommandMap.showBlocks,"active"),this._resourcesStateChange()},toggleCodeView:function(){const m=this._variable.isCodeView;this.controllersOff(),l.setDisabledButtons(!m,this.codeViewDisabledButtons),m?(l.isNonEditable(e.element.wysiwygFrame)||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"),r.height==="auto"&&!r.codeMirrorEditor&&(e.element.code.style.height="0px"),this._variable.isCodeView=!1,this._variable.isFullScreen||(this._notHideToolbar=!1,/balloon|balloon-always/i.test(r.mode)&&(e.element._arrow.style.display="",this._isInline=!1,this._isBalloon=!0,g._hideToolbar())),this.nativeFocus(),l.removeClass(this._styleCommandMap.codeView,"active"),l.isNonEditable(e.element.wysiwygFrame)||(this.history.push(!1),this.history._resetCachingButton())):(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"),this._variable.isFullScreen?e.element.code.style.height="100%":r.height==="auto"&&!r.codeMirrorEditor&&(e.element.code.style.height=e.element.code.scrollHeight>0?e.element.code.scrollHeight+"px":"auto"),r.codeMirrorEditor&&r.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,g._showToolbarInline())),this._variable._range=null,e.element.code.focus(),l.addClass(this._styleCommandMap.codeView,"active")),this._checkPlaceholder(),this.isReadOnly&&l.setDisabledButtons(!0,this.resizingDisabledButtons),typeof y.toggleCodeView=="function"&&y.toggleCodeView(this._variable.isCodeView,this)},_setCodeDataToEditor:function(){const m=this._getCodeView();if(r.fullPage){const p=this._parser.parseFromString(m,"text/html");if(!this.options.__allowedScriptTag){const k=p.head.children;for(let N=0,_=k.length;N<_;N++)/^script$/i.test(k[N].tagName)&&(p.head.removeChild(k[N]),N--,_--)}let b=p.head.innerHTML;(!p.head.querySelector('link[rel="stylesheet"]')||this.options.height==="auto"&&!p.head.querySelector("style"))&&(b+=l._setIframeCssTags(this.options)),this._wd.head.innerHTML=b,this._wd.body.innerHTML=this.convertContentsForEditor(p.body.innerHTML);const x=p.body.attributes;for(let k=0,N=x.length;k0&&m+N>=w&&(k.rowSpan-=n.getOverlapRangeAtIndex(w,v,m,m+N))}for(let m=0,p=S.length;m
"+T.innerHTML,u.removeItem(T)),x=r.cloneNode(!1),M=!0),D=x.innerHTML,x.innerHTML=(M||!C||!D||/
$/i.test(C)?C:C+"
")+D,N===0){b.insertBefore(x,_),T=_.nextSibling,T&&x.nodeName===T.nodeName&&u.isSameAttributes(x,T)&&(x.innerHTML+="
"+T.innerHTML,u.removeItem(T));const O=x.previousSibling;O&&x.nodeName===O.nodeName&&u.isSameAttributes(x,O)&&(O.innerHTML+="
"+x.innerHTML,u.removeItem(x))}P||u.removeItem(_),C&&(M=!1)}this.setRange(k,0,k,0)}else{for(let p=0,b=m.length,x,k;p('+n.toolbar.default+")";for(let o=0,c=r.length,l;o';for(let c=0,l=i.length,d,u,g,y;c
"+n+"
",e.items=t,e.menus=e.form.querySelectorAll("li")},initEvent:function(e,t){const n=t.querySelector(".se-select-list"),a=this.context.selectMenu.caller[e]={form:n,items:[],menus:[],index:-1,item:null,clickMethod:null,callerName:e};n.addEventListener("mousedown",this.plugins.selectMenu.onMousedown_list),n.addEventListener("mousemove",this.plugins.selectMenu.onMouseMove_list.bind(this,a)),n.addEventListener("click",this.plugins.selectMenu.onClick_list.bind(this,a))},onMousedown_list:function(e){e.preventDefault(),e.stopPropagation()},onMouseMove_list:function(e,t){this.util.addClass(e.form,"__se_select-menu-mouse-move");const n=t.target.getAttribute("data-index");!n||(e.index=n*1)},onClick_list:function(e,t){const n=t.target.getAttribute("data-index");!n||e.clickMethod.call(this,e.items[n])},moveItem:function(e,t){this.util.removeClass(e.form,"__se_select-menu-mouse-move"),t=e.index+t;const n=e.menus,a=n.length,r=e.index=t>=a?0:t<0?a-1:t;for(let i=0;i
");const g=u.parentNode;return o&&(u=u.nextSibling),c?(this.mergeSameTags(c,null,!1),this.mergeNestedTags(c,function(y){return this.isList(y)}.bind(this)),c.childNodes.length>0?g.insertBefore(c,u):c=u,this.isListCell(c)&&c.children&&this.isList(c.children[0])&&c.insertBefore(this.createElement("BR"),c.children[0]),a.childNodes.length===0&&this.removeItem(a),c):u},mergeSameTags:function(e,t,n){const a=this,r=t?t.length:0;let i=null;return r&&(i=this._w.Array.apply(null,new this._w.Array(r)).map(this._w.Number.prototype.valueOf,0)),function o(c,l,d){const u=c.childNodes;for(let g=0,y=u.length,w,v;g
",b.insertBefore(x,p&&p!==b?p.nextElementSibling:b.firstElementChild),this.setRange(x.firstElementChild,0,x.firstElementChild,1),m=this._variable._range}return m},getSelection:function(){const m=this._shadowRoot&&this._shadowRoot.getSelection?this._shadowRoot.getSelection():this._ww.getSelection();return!this._variable._range&&!e.element.wysiwyg.contains(m.focusNode)&&(m.removeAllRanges(),m.addRange(this._createDefaultRange())),m},getSelectionNode:function(){if(e.element.wysiwyg.contains(this._variable._selectionNode)||this._editorRange(),!this._variable._selectionNode){const m=l.getChildElement(e.element.wysiwyg.firstChild,function(p){return p.childNodes.length===0||p.nodeType===3},!1);if(!m)this._editorRange();else return this._variable._selectionNode=m,m}return this._variable._selectionNode},_editorRange:function(){const m=this._wd.activeElement;if(l.isInputElement(m))return this._variable._selectionNode=m,m;const p=this.getSelection();if(!p)return null;let b=null;p.rangeCount>0?b=p.getRangeAt(0):b=this._createDefaultRange(),this._rangeInfo(b,p)},_rangeInfo:function(m,p){let b=null;this._variable._range=m,m.collapsed?l.isWysiwygDiv(m.commonAncestorContainer)?b=m.commonAncestorContainer.children[m.startOffset]||m.commonAncestorContainer:b=m.commonAncestorContainer:b=p.extentNode||p.anchorNode,this._variable._selectionNode=b},_createDefaultRange:function(){const m=e.element.wysiwyg,p=this._wd.createRange();let b=m.firstElementChild,x=null;return b?(x=b.firstChild,x||(x=l.createElement("BR"),b.appendChild(x))):(b=l.createElement(r.defaultTag),x=l.createElement("BR"),b.appendChild(x),m.appendChild(b)),p.setStart(x,0),p.setEnd(x,0),p},_selectionVoid:function(m){const p=m.commonAncestorContainer;return l.isWysiwygDiv(m.startContainer)&&l.isWysiwygDiv(m.endContainer)||/FIGURE/i.test(p.nodeName)||this._fileManager.regExp.test(p.nodeName)||l.isMediaComponent(p)},_resetRangeToTextNode:function(){const m=this.getRange();if(this._selectionVoid(m))return!1;let p=m.startContainer,b=m.startOffset,x=m.endContainer,k=m.endOffset,N,_,C;if(l.isFormatElement(p))for(p.childNodes[b]?(p=p.childNodes[b]||p,b=0):(p=p.lastChild||p,b=p.textContent.length);p&&p.nodeType===1&&p.firstChild;)p=p.firstChild||p,b=0;if(l.isFormatElement(x)){for(x=x.childNodes[k]||x.lastChild||x;x&&x.nodeType===1&&x.lastChild;)x=x.lastChild;k=x.textContent.length}if(N=l.isWysiwygDiv(p)?e.element.wysiwyg.firstChild:p,_=b,l.isBreak(N)||N.nodeType===1&&N.childNodes.length>0){const E=l.isBreak(N);if(!E){for(;N&&!l.isBreak(N)&&N.nodeType===1;)N=N.childNodes[_]||N.nextElementSibling||N.nextSibling,_=0;let T=l.getFormatElement(N,null);T===l.getRangeFormatElement(T,null)&&(T=l.createElement(l.getParentElement(N,l.isCell)?"DIV":r.defaultTag),N.parentNode.insertBefore(T,N),T.appendChild(N))}if(l.isBreak(N)){const T=l.createTextNode(l.zeroWidthSpace);N.parentNode.insertBefore(T,N),N=T,E&&p===x&&(x=N,k=1)}}if(p=N,b=_,N=l.isWysiwygDiv(x)?e.element.wysiwyg.lastChild:x,_=k,l.isBreak(N)||N.nodeType===1&&N.childNodes.length>0){const E=l.isBreak(N);if(!E){for(;N&&!l.isBreak(N)&&N.nodeType===1&&(C=N.childNodes,C.length!==0);)N=C[_>0?_-1:_]||!/FIGURE/i.test(C[0].nodeName)?C[0]:N.previousElementSibling||N.previousSibling||p,_=_>0?N.textContent.length:_;let T=l.getFormatElement(N,null);T===l.getRangeFormatElement(T,null)&&(T=l.createElement(l.isCell(T)?"DIV":r.defaultTag),N.parentNode.insertBefore(T,N),T.appendChild(N))}if(l.isBreak(N)){const T=l.createTextNode(l.zeroWidthSpace);N.parentNode.insertBefore(T,N),N=T,_=1,E&&!N.previousSibling&&l.removeItem(x)}}return x=N,k=_,this.setRange(p,b,x,k),!0},getSelectedElements:function(m){if(!this._resetRangeToTextNode())return[];let p=this.getRange();if(l.isWysiwygDiv(p.startContainer)){const F=e.element.wysiwyg.children;if(F.length===0)return[];this.setRange(F[0],0,F[F.length-1],F[F.length-1].textContent.trim().length),p=this.getRange()}const b=p.startContainer,x=p.endContainer,k=p.commonAncestorContainer,N=l.getListChildren(k,function(F){return m?m(F):l.isFormatElement(F)});if(!l.isWysiwygDiv(k)&&!l.isRangeFormatElement(k)&&N.unshift(l.getFormatElement(k,null)),b===x||N.length===1)return N;let _=l.getFormatElement(b,null),C=l.getFormatElement(x,null),E=null,T=null;const D=function(F){return l.isTable(F)?/^TABLE$/i.test(F.nodeName):!0};let P=l.getRangeFormatElement(_,D),M=l.getRangeFormatElement(C,D);l.isTable(P)&&l.isListCell(P.parentNode)&&(P=P.parentNode),l.isTable(M)&&l.isListCell(M.parentNode)&&(M=M.parentNode);const O=P===M;for(let F=0,z=N.length,H;F
",(p&&typeof p!="string"||!p&&l.isFormatElement(b))&&l.copyTagAttributes(x,p||b,["id"])}return l.isCell(m)?m.insertBefore(x,m.nextElementSibling):m.parentNode.insertBefore(x,m.nextElementSibling),x},insertComponent:function(m,p,b,x){if(this.isReadOnly||b&&!this.checkCharCount(m,null))return null;const k=this.removeNode();this.getRange_addLine(this.getRange(),k.container);let N=null,_=this.getSelectionNode(),C=l.getFormatElement(_,null);if(l.isListCell(C))this.insertNode(m,_===C?null:k.container.nextSibling,!1),m.nextSibling||m.parentNode.appendChild(l.createElement("BR"));else{if(this.getRange().collapsed&&(k.container.nodeType===3||l.isBreak(k.container))){const E=l.getParentElement(k.container,function(T){return this.isRangeFormatElement(T)}.bind(l));N=l.splitElement(k.container,k.offset,E?l.getElementDepth(E)+1:0),N&&(C=N.previousSibling)}this.insertNode(m,l.isRangeFormatElement(C)?null:C,!1),C&&l.onlyZeroWidthSpace(C)&&l.removeItem(C)}if(!x){this.setRange(m,0,m,0);const E=this.getFileComponent(m);E?this.selectComponent(E.target,E.pluginName):N&&(N=l.getEdgeChildNodes(N,null).sc||N,this.setRange(N,0,N,0))}return p||this.history.push(1),N||m},getFileComponent:function(m){if(!this._fileManager.queryString||!m)return null;let p,b;return(/^FIGURE$/i.test(m.nodeName)||/se-component/.test(m.className))&&(p=m.querySelector(this._fileManager.queryString)),!p&&m.nodeName&&this._fileManager.regExp.test(m.nodeName)&&(p=m),p&&(b=this._fileManager.pluginMap[p.nodeName.toLowerCase()],b)?{target:p,component:l.getParentElement(p,l.isComponent),pluginName:b}:null},selectComponent:function(m,p){if(l.isUneditableComponent(l.getParentElement(m,l.isComponent))||l.isUneditableComponent(m))return!1;this.hasFocus||this.focus();const b=this.plugins[p];!b||c.setTimeout(function(){typeof b.select=="function"&&this.callPlugin(p,b.select.bind(this,m),null),this._setComponentLineBreaker(m)}.bind(this))},_setComponentLineBreaker:function(m){this._lineBreaker.style.display="none";const p=l.getParentElement(m,l.isComponent),b=e.element.lineBreaker_t.style,x=e.element.lineBreaker_b.style,k=this.context.resizing.resizeContainer.style.display==="block"?this.context.resizing.resizeContainer:m,N=l.isListCell(p.parentNode);let _,C,E;(N?!p.previousSibling:!l.isFormatElement(p.previousElementSibling))?(this._variable._lineBreakComp=p,C=e.element.wysiwyg.scrollTop,_=l.getOffset(m,e.element.wysiwygFrame).top+C,E=k.offsetWidth/2/2,b.top=_-C-12+"px",b.left=l.getOffset(k).left+E+"px",b.display="block"):b.display="none",(N?!p.nextSibling:!l.isFormatElement(p.nextElementSibling))?(_||(this._variable._lineBreakComp=p,C=e.element.wysiwyg.scrollTop,_=l.getOffset(m,e.element.wysiwygFrame).top+C,E=k.offsetWidth/2/2),x.top=_+k.offsetHeight-C-12+"px",x.left=l.getOffset(k).left+k.offsetWidth-E-24+"px",x.display="block"):x.display="none"},_checkDuplicateNode:function(m,p){(function b(x){u._dupleCheck(x,p);const k=x.childNodes;for(let N=0,_=k.length;N<_;N++)b(k[N])})(m)},_dupleCheck:function(m,p){if(!l.isTextStyleElement(m))return;const b=(m.style.cssText.match(/[^;]+;/g)||[]).map(function(N){return N.trim()}),x=m.nodeName;if(/^span$/i.test(x)&&b.length===0)return m;let k=!1;return function N(_){if(!(l.isWysiwygDiv(_)||!l.isTextStyleElement(_))){if(_.nodeName===x){k=!0;const C=_.style.cssText.match(/[^;]+;/g)||[];for(let E=0,T=C.length,D;E
")}else{const I=this.removeNode(),B=I.container,Y=I.prevContainer;if(B&&B.childNodes.length===0&&P&&(l.isFormatElement(B)?B.innerHTML="
":l.isRangeFormatElement(B)&&(B.innerHTML="<"+r.defaultTag+">
"+r.defaultTag+">")),l.isListCell(B)&&m.nodeType===3)_=B,p=null;else if(!P&&Y)if(_=Y.nodeType===3?Y.parentNode:Y,_.contains(B)){let U=!0;for(p=B;p.parentNode&&p.parentNode!==_;)p=p.parentNode,U=!1;U&&B===Y&&(p=p.nextSibling)}else p=null;else l.isWysiwygDiv(B)&&!l.isFormatElement(m)?(_=B.appendChild(l.createElement(r.defaultTag)),p=null):(p=P?A:B===Y?B.nextSibling:B,_=!p||!p.parentNode?M:p.parentNode);for(;p&&!l.isFormatElement(p)&&p.parentNode!==M;)p=p.parentNode}try{if(!N){if((l.isWysiwygDiv(p)||_===e.element.wysiwyg.parentNode)&&(_=e.element.wysiwyg,p=null),l.isFormatElement(m)||l.isRangeFormatElement(m)||!l.isListCell(_)&&l.isComponent(m)){const j=_;if(l.isList(p))_=p,p=null;else if(l.isListCell(p))_=p.previousElementSibling||p;else if(!C&&!p){const I=this.removeNode(),B=I.container.nodeType===3?l.isListCell(l.getFormatElement(I.container,null))?I.container:l.getFormatElement(I.container,null)||I.container.parentNode:I.container,Y=l.isWysiwygDiv(B)||l.isRangeFormatElement(B);_=Y?B:B.parentNode,p=Y?null:B.nextSibling}j.childNodes.length===0&&_!==j&&l.removeItem(j)}if(P&&!D&&!l.isRangeFormatElement(_)&&!l.isListCell(_)&&!l.isWysiwygDiv(_)&&(p=_.nextElementSibling,_=_.parentNode),l.isWysiwygDiv(_)&&(m.nodeType===3||l.isBreak(m))){const j=l.createElement(r.defaultTag);j.appendChild(m),m=j}}if(N?T.parentNode?(_=T,p=E):(_=e.element.wysiwyg,p=null):p=_===p?_.lastChild:p,l.isListCell(m)&&!l.isList(_)){if(l.isListCell(_))p=_.nextElementSibling,_=_.parentNode;else{const j=l.createElement("ol");_.insertBefore(j,p),_=j,p=null}N=!0}if(this._checkDuplicateNode(m,_),_.insertBefore(m,p),N)if(l.onlyZeroWidthSpace(k.textContent.trim()))l.removeItem(k),m=m.lastChild;else{const j=l.getArrayItem(k.children,l.isList);j&&(m!==j?(m.appendChild(j),m=j.previousSibling):(_.appendChild(m),m=_),l.onlyZeroWidthSpace(k.textContent.trim())&&l.removeItem(k))}}catch(j){_.appendChild(m),console.warn("[SUNEDITOR.insertNode.warn] "+j)}finally{const j=_.querySelectorAll("[data-se-duple]");if(j.length>0)for(let I=0,B=j.length,Y,U,W,V;I0&&(m.textContent=U+m.textContent,l.removeItem(B)),Y&&Y.length>0&&(m.textContent+=W,l.removeItem(Y));const V={container:m,startOffset:U.length,endOffset:m.textContent.length-W.length};return this.setRange(m,V.startOffset,m,V.endOffset),V}else if(!l.isBreak(m)&&!l.isListCell(m)&&l.isFormatElement(_)){let B=null;(!m.previousSibling||l.isBreak(m.previousSibling))&&(B=l.createTextNode(l.zeroWidthSpace),m.parentNode.insertBefore(B,m)),(!m.nextSibling||l.isBreak(m.nextSibling))&&(B=l.createTextNode(l.zeroWidthSpace),m.parentNode.insertBefore(B,m.nextSibling)),l._isIgnoreNodeChange(m)&&(m=m.nextSibling,I=0)}this.setRange(m,I,m,I)}return this.history.push(!0),m}},_setIntoFreeFormat:function(m){const p=m.parentNode;let b,x;for(;l.isFormatElement(m)||l.isRangeFormatElement(m);){for(b=m.childNodes,x=null;b[0];){if(x=b[0],l.isFormatElement(x)||l.isRangeFormatElement(x)){if(this._setIntoFreeFormat(x),!m.parentNode)break;b=m.childNodes;continue}p.insertBefore(x,m)}m.childNodes.length===0&&l.removeItem(m),m=l.createElement("BR"),p.insertBefore(m,x.nextSibling)}return m},removeNode:function(){this._resetRangeToTextNode();const m=this.getRange();if(m.startContainer===m.endContainer){const B=l.getParentElement(m.startContainer,l.isMediaComponent);if(B){const Y=l.createElement("BR"),U=l.createElement(r.defaultTag);return U.appendChild(Y),l.changeElement(B,U),u.setRange(U,0,U,0),this.history.push(!0),{container:U,offset:0,prevContainer:null}}}const p=m.startOffset===0,b=u.isEdgePoint(m.endContainer,m.endOffset,"end");let x=null,k=null,N=null;p&&(k=l.getFormatElement(m.startContainer),k&&(x=k.previousElementSibling,k=x)),b&&(N=l.getFormatElement(m.endContainer),N=N&&N.nextElementSibling);let _,C=0,E=m.startContainer,T=m.endContainer,D=m.startOffset,P=m.endOffset;const M=m.commonAncestorContainer.nodeType===3&&m.commonAncestorContainer.parentNode===E.parentNode?E.parentNode:m.commonAncestorContainer;if(M===E&&M===T&&(E=M.children[D],T=M.children[P],D=P=0),!E||!T)return{container:M,offset:0};if(E===T&&m.collapsed&&E.textContent&&l.onlyZeroWidthSpace(E.textContent.substr(D)))return{container:E,offset:D,prevContainer:E&&E.parentNode?E:null};let O=null,F=null;const z=l.getListChildNodes(M,null);let H=l.getArrayIndex(z,E),A=l.getArrayIndex(z,T);if(z.length>0&&H>-1&&A>-1){for(let B=H+1,Y=E;B>=0;B--)z[B]===Y.parentNode&&z[B].firstChild===Y&&D===0&&(H=B,Y=Y.parentNode);for(let B=A-1,Y=T;B>H;B--)z[B]===Y.parentNode&&z[B].nodeType===1&&(z.splice(B,1),Y=Y.parentNode,--A)}else{if(z.length===0){if(l.isFormatElement(M)||l.isRangeFormatElement(M)||l.isWysiwygDiv(M)||l.isBreak(M)||l.isMedia(M))return{container:M,offset:0};if(M.nodeType===3)return{container:M,offset:P};z.push(M),E=T=M}else if(E=T=z[0],l.isBreak(E)||l.onlyZeroWidthSpace(E))return{container:l.isMedia(M)?M:E,offset:0};H=A=0}for(let B=H;B<=A;B++){const Y=z[B];if(Y.length===0||Y.nodeType===3&&Y.data===void 0){this._nodeRemoveListItem(Y);continue}if(Y===E){if(E.nodeType===1){if(l.isComponent(E))continue;O=l.createTextNode(E.textContent)}else Y===T?(O=l.createTextNode(E.substringData(0,D)+T.substringData(P,T.length-P)),C=D):O=l.createTextNode(E.substringData(0,D));if(O.length>0?E.data=O.data:this._nodeRemoveListItem(E),Y===T)break;continue}if(Y===T){if(T.nodeType===1){if(l.isComponent(T))continue;F=l.createTextNode(T.textContent)}else F=l.createTextNode(T.substringData(P,T.length-P));F.length>0?T.data=F.data:this._nodeRemoveListItem(T);continue}this._nodeRemoveListItem(Y)}const j=l.getParentElement(T,"ul"),I=l.getParentElement(E,"li");if(j&&I&&I.contains(j)?(_=j.previousSibling,C=_.textContent.length):(_=T&&T.parentNode?T:E&&E.parentNode?E:m.endContainer||m.startContainer,C=!p&&!b?C:b?_.textContent.length:0),!l.isWysiwygDiv(_)&&_.childNodes.length===0){const B=l.removeItemAllParents(_,null,null);B&&(_=B.sc||B.ec||e.element.wysiwyg)}return!l.getFormatElement(_)&&!(E&&E.parentNode)&&(N?(_=N,C=0):k&&(_=k,C=1)),this.setRange(_,C,_,C),this.history.push(!0),{container:_,offset:C,prevContainer:x}},_nodeRemoveListItem:function(m){const p=l.getFormatElement(m,null);l.removeItem(m),l.isListCell(p)&&(l.removeItemAllParents(p,null,null),p&&l.isList(p.firstChild)&&p.insertBefore(l.createTextNode(l.zeroWidthSpace),p.firstChild))},applyRangeFormatElement:function(m){this.getRange_addLine(this.getRange(),null);const p=this.getSelectedElementsAndComponents(!1);if(!p||p.length===0)return;e:for(let P=0,M=p.length,O,F,z,H,A,j;P
"+r.defaultTag+">"},_setEditorDataToCodeView:function(){const m=this.convertHTMLForCodeView(e.element.wysiwyg,!1);let p="";if(r.fullPage){const b=l.getAttributesToString(this._wd.body,null);p=`
+
+`+this._wd.head.outerHTML.replace(/>(?!\n)/g,`>
+`)+"
+`+m+`
+`}else p=m;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(p)},toggleFullScreen:function(m){const p=e.element.topArea,b=e.element.toolbar,x=e.element.editorArea,k=e.element.wysiwygFrame,N=e.element.code,_=this._variable;this.controllersOff();const C=b.style.display==="none"||this._isInline&&!this._inlineToolbarAttr.isShow;_.isFullScreen?(_.isFullScreen=!1,k.style.cssText=_._wysiwygOriginCssText,N.style.cssText=_._codeOriginCssText,b.style.cssText="",x.style.cssText=_._editorAreaOriginCssText,p.style.cssText=_._originCssText,o.body.style.overflow=_._bodyOverflow,r.height==="auto"&&!r.codeMirrorEditor&&g._codeViewAutoHeight(),r.toolbarContainer&&r.toolbarContainer.appendChild(b),r.stickyToolbar>-1&&l.removeClass(b,"se-toolbar-sticky"),_._fullScreenAttrs.sticky&&!r.toolbarContainer&&(_._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",l.addClass(b,"se-toolbar-sticky")),this._isInline=_._fullScreenAttrs.inline,this._isBalloon=_._fullScreenAttrs.balloon,this._isInline&&g._showToolbarInline(),r.toolbarContainer&&l.removeClass(b,"se-toolbar-balloon"),g.onScroll_window(),m&&l.changeElement(m.firstElementChild,d.expansion),e.element.topArea.style.marginTop="",l.removeClass(this._styleCommandMap.fullScreen,"active")):(_.isFullScreen=!0,_._fullScreenAttrs.inline=this._isInline,_._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),r.toolbarContainer&&e.element.relative.insertBefore(b,x),p.style.position="fixed",p.style.top="0",p.style.left="0",p.style.width="100%",p.style.maxWidth="100%",p.style.height="100%",p.style.zIndex="2147483647",e.element._stickyDummy.style.display!==""&&(_._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",l.removeClass(b,"se-toolbar-sticky")),_._bodyOverflow=o.body.style.overflow,o.body.style.overflow="hidden",_._editorAreaOriginCssText=x.style.cssText,_._wysiwygOriginCssText=k.style.cssText,_._codeOriginCssText=N.style.cssText,x.style.cssText=b.style.cssText="",k.style.cssText=(k.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+r._editorStyles.editor,N.style.cssText=(N.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],b.style.width=k.style.height=N.style.height="100%",b.style.position="relative",b.style.display="block",_.innerHeight_fullScreen=c.innerHeight-b.offsetHeight,x.style.height=_.innerHeight_fullScreen-r.fullScreenOffset+"px",m&&l.changeElement(m.firstElementChild,d.reduction),r.iframe&&r.height==="auto"&&(x.style.overflow="auto",this._iframeAutoHeight()),e.element.topArea.style.marginTop=r.fullScreenOffset+"px",l.addClass(this._styleCommandMap.fullScreen,"active")),C&&y.toolbar.hide(),typeof y.toggleFullScreen=="function"&&y.toggleFullScreen(this._variable.isFullScreen,this)},print:function(){const m=l.createElement("IFRAME");m.style.display="none",o.body.appendChild(m);const p=r.printTemplate?r.printTemplate.replace(/\{\{\s*contents\s*\}\}/i,this.getContents(!0)):this.getContents(!0),b=l.getIframeDocument(m),x=this._wd;if(r.iframe){const k=r._printClass!==null?'class="'+r._printClass+'"':r.fullPage?l.getAttributesToString(x.body,["contenteditable"]):'class="'+r._editableClass+'"';b.write(""+x.head.innerHTML+""+p+"")}else{const k=o.head.getElementsByTagName("link"),N=o.head.getElementsByTagName("style");let _="";for(let C=0,E=k.length;C
")+"":l.isRangeFormatElement(k)&&!l.isTable(k)?p+=this._convertListCell(k):p+="
")+"
$/i,"");const x=o.createRange().createContextualFragment(m);try{l._consistencyCheckOfHTML(x,this._htmlCheckWhitelistRegExp,this._htmlCheckBlacklistRegExp,this._classNameFilter)}catch(C){console.warn("[SUNEDITOR.cleanHTML.consistencyCheck.fail] "+C)}if(this.managedTagsInfo&&this.managedTagsInfo.query){const C=x.querySelectorAll(this.managedTagsInfo.query);for(let E=0,T=C.length,D,P;E
"+r.defaultTag+">":(x=l.htmlRemoveWhiteSpace(x),this._tagConvertor(x))},convertHTMLForCodeView:function(m,p){let b="";const x=c.RegExp,k=new x("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),N=typeof m=="string"?o.createRange().createContextualFragment(m):m,_=function(T){return this.isFormatElement(T)||this.isComponent(T)}.bind(l),C=p?"":`
+`;let E=p?0:this._variable.codeIndent*1;return E=E>0?new c.Array(E+1).join(" "):"",function T(D,P){const M=D.childNodes,O=k.test(D.nodeName),F=O?P:"";for(let z=0,H=M.length,A,j,I,B,Y,U;z