diff --git a/bower.json b/bower.json index aae327db9..350b66765 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "suneditor", - "version": "2.16.1", + "version": "2.16.2", "description": "Pure JavaScript based WYSIWYG web editor", "main": "src/suneditor.js", "keywords": [ diff --git a/dist/suneditor.min.js b/dist/suneditor.min.js index 5ba04400b..17ef370a7 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")}({"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={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:"Hilite 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",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_quote:"Quote",pre:"Code"},dialogBox:{linkBox:{title:"Insert Link",url:"URL to link",text:"Text to display",newWindowCheck:"Open in new window"},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",width:"Width",height:"Height",basic:"Basic",left:"Left",right:"Right",center:"Center"},controller:{edit:"Edit",remove:"Remove",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",insertColumnBefore:"Insert column before",insertColumnAfter:"Insert column after",deleteColumn:"Delete column",resize100:"Resize 100%",resize75:"Resize 75%",resize50:"Resize 50%",resize25:"Resize 25%",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"}};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.context.option,e.lang);t.colorPicker.colorListHTML=n,n=null},createColorList:function(e,t){const n=e.colorList?e.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 i='
"},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);const l=this.context.colorPicker._colorList;if(l)for(let e=0,t=l.length;e
",t},call_controller_resize:function(e,t){const n=this.context.resizing;n._resize_plugin=t;const i=n.resizeContainer,l=n.resizeDiv,o=this.util.getOffset(e),s=n._rotateVertical=/^(90|270)$/.test(Math.abs(e.getAttribute("data-rotate")).toString()),a=s?e.offsetHeight:e.offsetWidth,r=s?e.offsetWidth:e.offsetHeight,c=o.top,d=o.left-this.context.element.wysiwyg.scrollLeft;i.style.top=c+"px",i.style.left=d+"px",i.style.width=a+"px",i.style.height=r+"px",l.style.top="0px",l.style.left="0px",l.style.width=a+"px",l.style.height=r+"px";let u=e.getAttribute("data-align")||"basic";u="none"===u?"basic":u,this.util.changeTxt(n.resizeDisplay,this.lang.dialogBox[u]+" ("+a+" x "+r+")");const h=this.context[t]._resizing?"flex":"none",p=n.resizeHandles;n.resizeButtonGroup.style.display=h;for(let e=0,t=p.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[this.context.resizing._resize_plugin]._element,o=this.plugins[this.context.resizing._resize_plugin];if(e.preventDefault(),/percent/.test(n)){this.plugins.resizing.resetTransform.call(this,l),o.setPercentSize.call(this,100*i+"%","auto");const e=this.plugins.resizing.call_controller_resize.call(this,l,this.context.resizing._resize_plugin);o.onModifyMode.call(this,l,e)}else if(/mirror/.test(n)){const e=l.getAttribute("data-rotate")||"0";let t=l.getAttribute("data-rotateX")||"",n=l.getAttribute("data-rotateY")||"";"h"===i&&!this.context.resizing._rotateVertical||"v"===i&&this.context.resizing._rotateVertical?n=n?"":"180":t=t?"":"180",l.setAttribute("data-rotateX",t),l.setAttribute("data-rotateY",n),this.plugins.resizing._setTransForm(l,e,t,n)}else if(/rotate/.test(n)){const e=this.context.resizing,t=1*l.getAttribute("data-rotate")+1*i,n=Math.abs(t)>=360?0:t;l.setAttribute("data-rotate",n),e._rotateVertical=/^(90|270)$/.test(Math.abs(n).toString()),this.plugins.resizing.setTransformSize.call(this,l);const s=this.plugins.resizing.call_controller_resize.call(this,l,e._resize_plugin);o.onModifyMode.call(this,l,s)}else if(/revert/.test(n)){o.setAutoSize?o.setAutoSize.call(this):(o.resetAlign.call(this),this.plugins.resizing.resetTransform.call(this,l));const e=this.plugins.resizing.call_controller_resize.call(this,l,this.context.resizing._resize_plugin);o.onModifyMode.call(this,l,e)}else/update/.test(n)?(o.openModify.call(this),this.controllersOff()):/delete/.test(n)&&o.destroy.call(this);this.history.push()},resetTransform:function(e){const t=(e.getAttribute("data-origin")||"").split(",");this.context.resizing._rotateVertical=!1,e.style.transform="",e.style.transformOrigin="",e.setAttribute("data-rotate",""),e.setAttribute("data-rotateX",""),e.setAttribute("data-rotateY",""),e.style.width=t[0]+"px"||!1,e.style.height=t[1]+"px"||!1,this.plugins.resizing.setTransformSize.call(this,e)},setTransformSize:function(e){const t=this.util.getParentElement(e,"FIGURE"),n=this.context.resizing._rotateVertical,i=1*e.getAttribute("data-rotate"),l=e.offsetWidth,o=e.offsetHeight,s=n?o:l,a=n?l:o;this.plugins[this.context.resizing._resize_plugin].cancelPercentAttr.call(this),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,l,o),t.style.width=s+"px",t.style.height=this.context[this.context.resizing._resize_plugin]._caption?"":a+"px";let r="";if(n){let e=l/2+"px "+l/2+"px 0",t=o/2+"px "+o/2+"px 0";r=90===i||-270===i?t:e}e.style.transformOrigin=r,this.plugins.resizing._setTransForm(e,i.toString(),e.getAttribute("data-rotateX")||"",e.getAttribute("data-rotateY")||""),this.plugins.resizing._setCaptionPosition.call(this,e,this.util.getChildElement(this.util.getParentElement(e,"FIGURE"),"FIGCAPTION"))},_setTransForm:function(e,t,n,i){let l=(e.offsetWidth-e.offsetHeight)*(/-/.test(t)?1:-1),o="";if(/[1-9]/.test(t)&&(n||i))switch(o=n?"Y":"X",t){case"90":o=n&&i?"X":i?o:"";break;case"270":l*=-1,o=n&&i?"Y":n?o:"";break;case"-90":o=n&&i?"Y":n?o:"";break;case"-270":l*=-1,o=n&&i?"X":i?o:"";break;default:o=""}e.style.transform="rotate("+t+"deg)"+(n?" rotateX("+n+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(o?" translate"+o+"("+l+"px)":"")},_setCaptionPosition:function(e,t){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(),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 i=function(){const e=t._isChange;t._isChange=!1,document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",i),this.plugins.resizing.cancel_controller_resize.call(this),e&&this.history.push()}.bind(this),l=this.plugins.resizing.resizing_element.bind(this,t,n,this.context[t._resize_plugin]);document.addEventListener("mousemove",l),document.addEventListener("mouseup",i)},resizing_element:function(e,t,n,i){const l=i.clientX,o=i.clientY;let s=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)?o-e._resizeClientY:e._resizeClientY-o),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",s=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=s,e._resize_h=a,this.util.changeTxt(e.resizeDisplay,Math.round(s)+" x "+Math.round(a)),e._isChange=!0},cancel_controller_resize:function(){const e=this.context.resizing._rotateVertical;this.controllersOff(),this.context.element.resizeBackground.style.display="none";const t=e?this.context.resizing._resize_h:this.context.resizing._resize_w,n=e?this.context.resizing._resize_w:this.context.resizing._resize_h;this.plugins[this.context.resizing._resize_plugin].setSize.call(this,t,n,e),this.plugins.resizing.setTransformSize.call(this,this.context[this.context.resizing._resize_plugin]._element),this.plugins[this.context.resizing._resize_plugin].init.call(this)}},s={name:"notice",add:function(e){const t=e.context;t.notice={};let n=e.util.createElement("DIV"),i=e.util.createElement("SPAN"),l=e.util.createElement("BUTTON");n.className="se-notice",l.className="close",l.setAttribute("aria-label","Close"),l.setAttribute("title",e.lang.dialogBox.close),l.innerHTML='',n.appendChild(i),n.appendChild(l),t.notice.modal=n,t.notice.message=i,l.addEventListener("click",this.onClick_cancel.bind(e)),t.element.editorArea.insertBefore(n,t.element.wysiwyg),n=null},onClick_cancel:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.notice.close.call(this)},open:function(e){this.context.notice.message.textContent=e,this.context.notice.modal.style.display="block"},close:function(){this.context.notice.modal.style.display="none"}},a={align:{name:"align",add:function(e,t){const n=e.context;n.align={_alignList:null,currentAlign:""};let i=this.setSubmenu.call(e),l=i.querySelector("ul");l.addEventListener("click",this.pickup.bind(e)),n.align._alignList=l.querySelectorAll("li button"),t.parentNode.appendChild(i),i=null,l=null},setSubmenu:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-list-layer",t.style.display="none",t.innerHTML='
",t},on:function(){const e=this.context.align,t=e._alignList,n=this.commandMap.ALIGN.getAttribute("data-focus")||"left";if(n!==e.currentAlign){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(o=0,s=a.length;o";return r+=" ",r+="",n.innerHTML=r,n},on:function(){const e=this.context.font,t=e._fontList,n=this.commandMap.FONT.textContent;if(n!==e.currentFont){for(let e=0,i=t.length;e('+t.toolbar.default+")";for(let e=0,t=i.length;e"}return l+=" ",n.innerHTML=l,n},on:function(){const e=this.context.fontSize,t=e._sizeList,n=(this.commandMap.SIZE.textContent.match(/\d+/)||[""])[0];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);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,n),this.submenuOff())}},list:{name:"list",add:function(e,t){const n=e.context;n.list={_list:null,currentList:""};let i=this.setSubmenu.call(e),l=i.querySelector("ul");l.addEventListener("click",this.pickup.bind(e)),n.list._list=l.querySelectorAll("li button"),t.parentNode.appendChild(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.style.display="none",t.innerHTML='
    ",t},on:function(){const e=this.context.list,t=e._list,n=this.commandMap.LI.getAttribute("data-focus")||"";if(n!==e.currentList){for(let e=0,i=t.length;e1?this.setRange(o.sc,0,s.ec,s.ec.textContent.length):this.setRange(o.ec,o.ec.textContent.length,s.ec,s.ec.textContent.length),this.submenuOff()}},table:{name:"table",add:function(e,t){const n=e.context;n.table={_element:null,_tdElement:null,_trElement:null,_trElements:null,_tableXY:[],_maxWidth:!0,resizeIcon:null,resizeText:null,headerButton:null,mergeButton:null,splitButton:null,splitMenu:null,maxText:e.lang.controller.maxSize,minText:e.lang.controller.minSize,_physical_cellCnt:0,_logical_cellCnt:0,_rowCnt:0,_rowIndex:0,_physical_cellIndex:0,_logical_cellIndex:0,_current_colSpan:0,_current_rowSpan:0};let i=this.setSubmenu.call(e),l=i.querySelector(".se-controller-table-picker");n.table.tableHighlight=i.querySelector(".se-table-size-highlighted"),n.table.tableUnHighlight=i.querySelector(".se-table-size-unhighlighted"),n.table.tableDisplay=i.querySelector(".se-table-size-display");let o=this.setController_table.call(e);n.table.tableController=o,n.table.resizeIcon=o.querySelector("_se_table_resize > i"),n.table.resizeText=o.querySelector("_se_table_resize > span > span"),n.table.headerButton=o.querySelector(".__se__table_header"),o.addEventListener("mousedown",function(e){e.stopPropagation()},!1);let s=this.setController_tableEditor.call(e);n.table.resizeDiv=s,n.table.splitMenu=s.querySelector(".se-btn-group-sub"),n.table.mergeButton=s.querySelector("._se_table_merge_button"),n.table.splitButton=s.querySelector("._se_table_split_button"),s.addEventListener("mousedown",function(e){e.stopPropagation()},!1),l.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(e)),l.addEventListener("click",this.appendTable.bind(e)),s.addEventListener("click",this.onClick_tableController.bind(e)),o.addEventListener("click",this.onClick_tableController.bind(e)),t.parentNode.appendChild(i),n.element.relative.appendChild(s),n.element.relative.appendChild(o),i=null,l=null,s=null,o=null},setSubmenu:function(){const e=this.util.createElement("DIV");return e.className="se-submenu se-selector-table",e.style.display="none",e.innerHTML='
    1 x 1
    ',e},setController_table:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-controller se-controller-table",t.style.display="none",t.innerHTML='
    ",t},setController_tableEditor:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-controller se-controller-table-cell",t.style.display="none",t.innerHTML='
    • '+e.controller.VerticalSplit+'
    • '+e.controller.HorizontalSplit+"
    ",t},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),this.focus(),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="
    "+this.util.zeroWidthSpace+"
    ",t}{let n="";for(;t>0;)n+="<"+e+">
    "+this.util.zeroWidthSpace+"
    ",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";let i=t<5?5:t>9?10:t+1,l=n<5?5:n>9?10:n+1;this.context.table.tableUnHighlight.style.width=i+"em",this.context.table.tableUnHighlight.style.height=l+"em",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="5em",t.height="5em",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;to||(u>=e.index?(i+=e.cs,u+=e.cs,e.rs-=1,e.row=o+1,e.rs<1&&(r.splice(t,1),t--)):h===p-1&&(e.rs-=1,e.row=o+1,e.rs<1&&r.splice(t,1)));if(o===s&&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,o="row"===e;if(o){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(o)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,o=l.length;ns&&s>t&&(e[l].rowSpan=n+a,c-=i)}if(i){const e=r[o+1];if(e){const t=[];let n=r[o].cells,i=0;for(let e,l,o=0,s=n.length;o1&&(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 o,s,a=0,r=n.length;a=l.index)||(a--,i--,i+=l.cell.colSpan-1,e.insertBefore(l.cell,o),l=t.shift()));a++);if(l){e.appendChild(l.cell);for(let n=0,i=t.length;n0){const e=!o[b+1];for(let t,n=0;n_||(g>=t.index?(g=b+(f+=t.cs),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>0&&c.push({rs:n,cs:r+1,index:g,row:-1}),g>=t&&g+r<=t+s?h.push(e):g<=t+s&&g+r>=t?e.colSpan-=i.getOverlapRangeAtIndex(a,a+s,g,g+r):n>0&&(gt+s)&&p.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&&o.length>0&&(g=this.plugins.table.createCells.call(this,o[0].nodeName,0,!0),g=e.insertBefore(g,o[t]))}}if(l){let e,t;for(let n,l=0,o=h.length;l1)c.colSpan=this._w.Math.floor(e/2),l.colSpan=e-c.colSpan,s.insertBefore(c,l.nextElementSibling);else{let t=[],n=[];for(let s,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===p-1&&(e.rs-=1,e.row=c+1,e.rs<1&&n.splice(t,1)));if(u<=a&&d>0&&t.push({index:u,cs:o+1,rs:d,row:-1}),i!==l&&u<=a&&u+o>=a+e-1){i.colSpan+=1;break}if(u>a)break;r+=o}n=n.concat(t).sort(function(e,t){return e.index-t.index}),t=[]}s.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(o,s)+n;for(let e,t,n=0;n=a);c++)(o=(l=e[c]).rowSpan-1)>0&&o+n>=r&&s=h.index&&(r+=h.cs,l+=h.cs,h=i.shift()),l>=a||o===s-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=s.cells;for(let e=0,t=a.length;e0&&s+o>=i&&(e.rowSpan-=n.getOverlapRangeAtIndex(i,l,s,s+o));else o.push(e[s]);for(let e=0,t=o.length;e"+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"",i.insertBefore(t,i.firstElementChild)}e.toggleClass(t,"on"),/TH/i.test(this.context.table._tdElement.nodeName)?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,this.context.table._tdElement,!1)},resizeTable:function(){const e=this.context.table,t=e.resizeIcon,n=e.resizeText;let i="se-icon-expansion",l="se-icon-reduction",o=e.minText,s="100%";e._maxWidth||(i="se-icon-reduction",l="se-icon-expansion",o=e.maxText,s="auto"),this.util.removeClass(t,i),this.util.addClass(t,l),this.util.changeTxt(n,o),e._element.style.width=s},setActiveButton:function(e,t){const n=this.context.table;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._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._shift||(t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null),this.focus())},_onCellMultiSelect:function(e){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,o=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let e=0,t=o.length;e0)for(let e,t=0;td||(u>=e.index?(o+=e.cs,u+=e.cs,e.rs-=1,e.row=d+1,e.rs<1&&(a.splice(t,1),t--)):g===m-1&&(e.rs-=1,e.row=d+1,e.rs<1&&a.splice(t,1)));if(s){if(i!==e&&i!==t||(c.cs=null!==c.cs&&c.csu+h?c.ce:u+h,c.rs=null!==c.rs&&c.rsd+p?c.re:d+p,c._i+=1),2===c._i){s=!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+p)){const e=c.csu+h?c.ce:u+h,n=c.rsd+p?c.re:d+p;if(c.cs!==e||c.ce!==t||c.rs!==n||c.re!==o){c.cs=e,c.ce=t,c.rs=n,c.re=o,d=-1,a=[],r=[];break}l.addClass(i,"se-table-selected-cell")}p>0&&r.push({index:u,cs:h+1,rs:p,row:-1}),o+=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._bindOnSelect&&(this._d.removeEventListener("mousedown",e._bindOnSelect),this._d.removeEventListener("mousemove",e._bindOnSelect),e._bindOnSelect=null),e._bindOffSelect&&(this._d.removeEventListener("mouseup",e._bindOffSelect),e._bindOffSelect=null),e._bindOffShift&&(this._d.removeEventListener("keyup",e._bindOffShift),e._bindOffShift=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'+e.toolbar.tag_p+'
  • ",t},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null,i=null;for(;!n&&!/UL/i.test(t.tagName);)n=t.getAttribute("data-command"),i=t.getAttribute("data-value"),t=t.parentNode;if(n&&i){if("range"===n){const e=this.util.createElement(i);this.applyRangeFormatElement(e)}else{const e=this.getRange(),t=e.startOffset,n=e.endOffset;let l=this.getSelectedElementsAndComponents();if(0===l.length)return;let o=l[0],s=l[l.length-1];const a=this.util.getNodePath(e.startContainer,o),r=this.util.getNodePath(e.endContainer,s);let c={},d=!1,u=!1;const h=function(e){return!this.isComponent(e)}.bind(this.util);for(let e,t,n,i,a=0,r=l.length;a
    ",t},setController_LinkButton:function(){const e=this.lang,t=this.util.createElement("DIV");return t.className="se-controller se-controller-link",t.style.display="none",t.innerHTML='
    ",t},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.focusElement.value,t=this.context.link.linkAnchorText,n=0===t.value.length?e:t.value;if(this.context.dialog.updateModal)this.context.link._linkAnchor.href=e,this.context.link._linkAnchor.textContent=n,this.context.link._linkAnchor.target=this.context.link.linkNewWindowCheck.checked?"_blank":"",this.history.push(),this.setRange(this.context.link._linkAnchor.childNodes[0],0,this.context.link._linkAnchor.childNodes[0],this.context.link._linkAnchor.textContent.length);else{const t=this.util.createElement("A");t.href=e,t.textContent=n,t.target=this.context.link.linkNewWindowCheck.checked?"_blank":"",this.insertNode(t),this.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}this.context.link.focusElement.value="",this.context.link.linkAnchorText.value=""}.bind(this);try{t()}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.focus()}return!1},call_controller_linkButton:function(e){this.editLink=this.context.link._linkAnchor=e;const t=this.context.link.linkBtn,n=t.querySelector("a");n.href=e.href,n.title=e.textContent,n.textContent=e.textContent;const i=this.util.getOffset(e);t.style.top=i.top+e.offsetHeight+10+"px",t.style.left=i.left-this.context.element.wysiwyg.scrollLeft+"px",t.style.display="block";const l=this.context.element.wysiwyg.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)},onClick_linkBtn: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.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.dialog.open.call(this,"link",!0)):(this.util.removeItem(this.context.link._linkAnchor),this.context.link._linkAnchor=null,this.focus()),this.controllersOff())},init:function(){const e=this.context.link;e.linkBtn.style.display="none",e._linkAnchor=null,e.focusElement.value="",e.linkAnchorText.value="",e.linkNewWindowCheck.checked=!1}},image:{name:"image",add:function(e){e.addModule([l,o,s]);const t=e.context;t.image={_linkElement:null,_container:null,_cover:null,_element:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_origin_w:"auto"===t.option.imageWidth?"":t.option.imageWidth,_origin_h:"",_altText:"",_caption:null,captionCheckEl:null,_linkValue:"",_align:"none",_captionChecked:!1,_proportionChecked:!0,_floatClassRegExp:"float\\-[a-z]+",_xmlHttp:null,_resizing:t.option.imageResizing,_defaultAuto:"auto"===t.option.imageWidth,_uploadFileLength:0};let n=this.setDialog.call(e);t.image.modal=n,t.image.imgUrlFile=n.querySelector("._se_image_url"),t.image.imgInputFile=t.image.focusElement=n.querySelector("._se_image_file"),t.image.altText=n.querySelector("._se_image_alt"),t.image.imgLink=n.querySelector("._se_image_link"),t.image.imgLinkNewWindowCheck=n.querySelector("._se_image_link_check"),t.image.captionCheckEl=n.querySelector("._se_image_check_caption"),t.image.modal.querySelector(".se-dialog-tabs").addEventListener("click",this.openTab.bind(e)),t.image.modal.querySelector(".se-btn-primary").addEventListener("click",this.submit.bind(e)),t.image.imageX={},t.image.imageY={},t.option.imageResizing&&(t.image.proportion=n.querySelector("._se_image_check_proportion"),t.image.imageX=n.querySelector("._se_image_size_x"),t.image.imageY=n.querySelector("._se_image_size_y"),t.image.imageX.value=t.option.imageWidth,t.image.imageX.addEventListener("change",this.setInputSize.bind(e,"x")),t.image.imageY.addEventListener("change",this.setInputSize.bind(e,"y")),n.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),t.dialog.modal.appendChild(n),n=null},setDialog:function(){const e=this.context.option,t=this.lang,n=this.util.createElement("DIV");n.className="se-dialog-content",n.style.display="none";let i='
    ';return e.imageFileInput&&(i+='
    '),e.imageUrlInput&&(i+='
    '),i+='
    ',e.imageResizing&&(i+='
    '),i+='
    ",n.innerHTML=i,n},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,o,s;for(o=t.getElementsByClassName("_se_tab_content"),l=0;l0){const t=[];for(let n=0,i=e.length;n0){const e=new FormData;for(let n=0;n0)for(let e in i)this.context.image._xmlHttp.setRequestHeader(e,i[e]);this.context.image._xmlHttp.send(e)}else for(let e=0;e0?1:s.length;a0){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){if(!this.context.dialog.updateModal)return;const t=this.context.image;t.proportion.checked&&("x"===e?t.imageY.value=Math.round(t._element_h/t._element_w*t.imageX.value):t.imageX.value=Math.round(t._element_w/t._element_h*t.imageY.value))},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),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(),s.open.call(this,'[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"'),Error('[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},_setImagesInfo:function(e,t){let n=e.getAttribute("data-index");n?(this._variable._imagesInfo[n].name=e.getAttribute("data-file-name"),this._variable._imagesInfo[n].size=1*e.getAttribute("data-file-size")):(n=this._variable._imageIndex,e.setAttribute("data-index",n),this._variable._imagesInfo[n]={src:e.src,index:n,name:t.name,size:t.size,select:function(){const t=this.plugins.resizing.call_controller_resize.call(this,e,"image");this.plugins.image.onModifyMode.call(this,e,t),e.scrollIntoView()}.bind(this),delete:this.plugins.image.destroy.bind(this,e)},this._variable._imageIndex++,e.setAttribute("data-file-name",t.name),e.setAttribute("data-file-size",t.size)),this._imageUpload(e,n,!1,this._variable._imagesInfo[n],--this.context.image._uploadFileLength)},_onload_image:function(e,t){e.setAttribute("origin-size",e.naturalWidth+","+e.naturalHeight),e.setAttribute("data-origin",e.offsetWidth+","+e.offsetHeight),t&&this.plugins.image._setImagesInfo.call(this,e,t)},create_image:function(e,t,n,i,l,o,s,a){if(o)return void(s.src=e);const r=this.context.image;let c=this.util.createElement("IMG");c.addEventListener("load",this.plugins.image._onload_image.bind(this,c,a)),c.src=e,c.setAttribute("data-align",l),c.alt=r._altText,(c=this.plugins.image.onRender_link.call(this,c,t,n)).setAttribute("data-rotate","0"),r._resizing&&(/\d+/.test(i)&&(c.style.width=i),c.setAttribute("data-proportion",r._proportionChecked));const d=this.plugins.resizing.set_cover.call(this,c),u=this.plugins.resizing.set_container.call(this,d,"se-image-container");r._captionChecked&&(r._caption=this.plugins.resizing.create_caption.call(this),r._caption.setAttribute("contenteditable",!1),d.appendChild(r._caption)),d.style.margin="none"!==l?"auto":"0",this.util.removeClass(u,r._floatClassRegExp),this.util.addClass(u,"float-"+l),r._resizing&&/\d+/.test(i)||(this.context.resizing._resize_plugin="image",r._element=c,r._cover=d,r._container=u,this.plugins.image.setAutoSize.call(this)),this.insertComponent(u)},update_image:function(e){const t=this.context.image,n=t._linkValue;let i=t._element,l=t._cover,o=t._container,s=!1;const a=1*t.imageX.value!==i.offsetWidth||1*t.imageY.value!==i.offsetHeight;if(null===l&&(s=!0,i=t._element.cloneNode(!0),l=this.plugins.resizing.set_cover.call(this,i)),null===o&&(l=l.cloneNode(!0),s=!0,o=this.plugins.resizing.set_container.call(this,l,"se-image-container")),s&&(o.innerHTML="",o.appendChild(l)),i.alt=t._altText,t._resizing&&(i.setAttribute("data-proportion",t._proportionChecked),a&&this.plugins.image.setSize.call(this,t.imageX.value,t.imageY.value)),t._captionChecked?t._caption||(t._caption=this.plugins.resizing.create_caption.call(this),l.appendChild(t._caption)):t._caption&&(this.util.removeItem(t._caption),t._caption=null),t._align&&"none"!==t._align?l.style.margin="auto":l.style.margin="0",this.util.removeClass(o,this.context.image._floatClassRegExp),this.util.addClass(o,"float-"+t._align),i.setAttribute("data-align",t._align),n.trim().length>0)if(null!==t._linkElement)t._linkElement.href=n,t._linkElement.target=t.imgLinkNewWindowCheck.checked?"_blank":"",i.setAttribute("data-image-link",n);else{let e=this.plugins.image.onRender_link.call(this,i,n,this.context.image.imgLinkNewWindowCheck.checked);l.insertBefore(e,t._caption)}else if(null!==t._linkElement){const e=i;e.setAttribute("data-image-link","");let n=e.cloneNode(!0);l.removeChild(t._linkElement),l.insertBefore(n,t._caption),i=n}if(s){const e=this.util.isRangeFormatElement(t._element.parentNode)||this.util.isWysiwygDiv(t._element.parentNode)?t._element:this.util.getFormatElement(t._element)||t._element;e.parentNode.insertBefore(o,e),this.util.removeItem(e)}if(!e&&(/\d+/.test(i.style.height)||t._resizing&&a||this.context.resizing._rotateVertical&&t._captionChecked)&&this.plugins.resizing.setTransformSize.call(this,i),this.history.push(),e){i=o.querySelector("img"),this.plugins.image.init.call(this);const e=this.plugins.resizing.call_controller_resize.call(this,i,"image");this.plugins.image.onModifyMode.call(this,i,e)}},sizeRevert:function(){const e=this.context.image;e._origin_w&&(e.imageX.value=e._element_w=e._origin_w,e.imageY.value=e._element_h=e._origin_h)},onModifyMode:function(e,t){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,".se-image-container"),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._align=e.getAttribute("data-align")||"none",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-origin");i?(i=i.split(","),n._origin_w=1*i[0],n._origin_h=1*i[1]):(n._origin_w=t.w,n._origin_h=t.h,n._element.setAttribute("data-origin",t.w+","+t.h))},openModify:function(e){const t=this.context.image;t.imgUrlFile.value=t._element.src,t.altText.value=t._element.alt,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._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&(t.proportion.checked=t._proportionChecked="true"===t._element.getAttribute("data-proportion"),t.imageX.value=t._element.offsetWidth,t.imageY.value=t._element.offsetHeight,t.imageX.disabled=!1,t.imageY.disabled=!1,t.proportion.disabled=!1),e||this.plugins.dialog.open.call(this,"image",!0)},setSize:function(e,t){const n=this.context.image;n._element.style.width=e+"px",n._element.style.height=t+"px"},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="100%",e._element.style.width="100%",e._element.style.height="",e._cover.style.width="",e._cover.style.height=""},setPercentSize:function(e){const t=this.context.image;t._container.style.width=e,t._container.style.height="",t._cover.style.width="100%",t._cover.style.height="",t._element.style.width="100%",t._element.style.height="",/100/.test(e)&&(this.util.removeClass(t._container,this.context.image._floatClassRegExp),this.util.addClass(t._container,"float-center"))},cancelPercentAttr:function(){const e=this.context.image;e._element.style.maxWidth="none",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,"float-"+e._align)},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,".se-image-container")||t,i=t.getAttribute("data-index");this.util.removeItem(n),this.plugins.image.init.call(this),this.controllersOff(),i&&(delete this._variable._imagesInfo[i],this._imageUpload(t,i,!0,null,0))},init:function(){const e=this.context.image;if(e.imgInputFile&&(e.imgInputFile.value=""),e.imgUrlFile&&(e.imgUrlFile.value=""),e.altText.value="",e.imgLink.value="",e.imgLinkNewWindowCheck.checked=!1,e.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,e.captionCheckEl.checked=!1,e._element=null,this.plugins.image.openTab.call(this,"init"),e._resizing){const t="auto"===this.context.option.imageWidth;e.proportion.checked=!1,e.imageX.value=t?"":this.context.option.imageWidth,e.imageY.value="",e.imageX.disabled=t,e.imageY.disabled=!0,e.proportion.disabled=!0}}},video:{name:"video",add:function(e){e.addModule([l,o]);const t=e.context;t.video={_container:null,_cover:null,_element:null,_resizingDiv:null,_element_w:t.option.videoWidth,_element_h:t.option.videoHeight,_element_l:0,_element_t:0,_origin_w:t.option.videoWidth,_origin_h:t.option.videoHeight,_caption:null,captionCheckEl:null,_captionChecked:!1,_proportionChecked:!0,_align:"none",_floatClassRegExp:"float\\-[a-z]+",_resizing:t.option.videoResizing,_youtubeQuery:t.option.youtubeQuery};let n=this.setDialog.call(e);t.video.modal=n,t.video.focusElement=n.querySelector("._se_video_url"),t.video.captionCheckEl=n.querySelector("._se_video_check_caption"),n.querySelector(".se-btn-primary").addEventListener("click",this.submit.bind(e)),t.video.videoWidth={},t.video.videoHeight={},t.option.videoResizing&&(t.video.videoWidth=n.querySelector("._se_video_size_x"),t.video.videoHeight=n.querySelector("._se_video_size_y"),t.video.proportion=n.querySelector("._se_video_check_proportion"),t.video.videoWidth.value=t.option.videoWidth,t.video.videoHeight.value=t.option.videoHeight,t.video.videoWidth.addEventListener("change",this.setInputSize.bind(e,"x")),t.video.videoHeight.addEventListener("change",this.setInputSize.bind(e,"y")),n.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),t.dialog.modal.appendChild(n),n=null},setDialog:function(){const e=this.context.option,t=this.lang,n=this.util.createElement("DIV");n.className="se-dialog-content",n.style.display="none";let i='
    ';return e.videoResizing&&(i+='
    '),i+='
    ",n.innerHTML=i,n},setInputSize:function(e){this.context.video.proportion.checked&&("x"===e?this.context.video.videoHeight.value=Math.round(this.context.video._element_h/this.context.video._element_w*this.context.video.videoWidth.value):this.context.video.videoWidth.value=Math.round(this.context.video._element_w/this.context.video._element_h*this.context.video.videoHeight.value))},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation(),this.context.video._captionChecked=this.context.video.captionCheckEl.checked;const t=function(){if(0===this.context.video.focusElement.value.trim().length)return!1;const e=this.context.video,t=/^\d+$/.test(e.videoWidth.value)?e.videoWidth.value:this.context.option.videoWidth,n=/^\d+$/.test(e.videoHeight.value)?e.videoHeight.value:this.context.option.videoHeight;let i=null,l=null,o=null,s=null,a=e.focusElement.value.trim();if(e._align=e.modal.querySelector('input[name="suneditor_video_radio"]:checked').value,/^$/.test(a))l=(new DOMParser).parseFromString(a,"text/html").querySelector("iframe");else{if(l=this.util.createElement("IFRAME"),/youtu\.?be/.test(a)&&(a=a.replace("watch?v=",""),/^\/\/.+\/embed\//.test(a)||(a=a.replace(a.match(/\/\/.+\//)[0],"//www.youtube.com/embed/")),e._youtubeQuery.length>0))if(/\?/.test(a)){const t=a.split("?");a=t[0]+"?"+e._youtubeQuery+"&"+t[1]}else a+="?"+e._youtubeQuery;l.src=a}this.context.dialog.updateModal?(e._element.src=l.src,s=e._container,o=this.util.getParentElement(e._element,"FIGURE"),l=e._element,i=e._resizingDiv):(l.frameBorder="0",l.allowFullscreen=!0,l.contentDocument,l.onload=function(){this.setAttribute("origin-size",this.offsetWidth+","+this.offsetHeight),this.setAttribute("data-origin",this.offsetWidth+","+this.offsetHeight),this.style.height=this.offsetHeight+"px"}.bind(l),e._element=l,o=this.plugins.resizing.set_cover.call(this,l),e._resizingDiv=i=this.util.createElement("DIV"),i.className="se-video-inner",o.appendChild(i),s=this.plugins.resizing.set_container.call(this,o,"se-video-container"));const r=1*t!==l.offsetWidth||1*n!==l.offsetHeight;e._resizing&&(this.context.video._proportionChecked=e.proportion.checked,l.setAttribute("data-proportion",e._proportionChecked)),e._captionChecked?e._caption||(e._caption=this.plugins.resizing.create_caption.call(this),o.appendChild(e._caption)):e._caption&&(this.util.removeItem(e._caption),e._caption=null),r&&this.plugins.video.setSize.call(this,t,n),e._align&&"none"!==e._align?o.style.margin="auto":o.style.margin="0",this.util.removeClass(s,this.context.video._floatClassRegExp),this.util.addClass(s,"float-"+e._align),l.setAttribute("data-align",e._align),this.context.dialog.updateModal?(/\d+/.test(o.style.height)||e._resizing&&r||this.context.resizing._rotateVertical&&e._captionChecked)&&this.plugins.resizing.setTransformSize.call(this,l):this.insertComponent(s),this.history.push()}.bind(this);try{t()}finally{this.plugins.dialog.close.call(this),this.closeLoading()}return this.focus(),!1},sizeRevert:function(){const e=this.context.video;e._origin_w&&(e.videoWidth.value=e._element_w=e._origin_w,e.videoHeight.value=e._element_h=e._origin_h)},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,".se-video-container"),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._resizingDiv=this.util.getChildElement(n._cover,".se-video-inner"),n._align=e.getAttribute("data-align")||"none",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-origin");i?(i=i.split(","),n._origin_w=1*i[0],n._origin_h=1*i[1]):(n._origin_w=t.w,n._origin_h=t.h,n._element.setAttribute("data-origin",t.w+","+t.h))},openModify:function(){const e=this.context.video;e.focusElement.value=e._element.src,e.videoWidth.value=e._element.offsetWidth,e.videoHeight.value=e._element.offsetHeight,e._captionChecked=e.captionCheckEl.checked=!!e._caption,e.modal.querySelector('input[name="suneditor_video_radio"][value="'+e._align+'"]').checked=!0,e._resizing&&(e.proportion.checked=e._proportionChecked="true"===e._element.getAttribute("data-proportion"),e.proportion.disabled=!1),this.plugins.dialog.open.call(this,"video",!0)},setSize:function(e,t,n){const i=this.context.video;i._element.style.width=e+"px",i._element.style.height=t+"px",i._resizingDiv.style.height=(n?e:t)+"px"},setPercentSize:function(e){const t=this.context.video;t._container.style.width=e,t._container.style.height="",t._cover.style.width="100%",t._cover.style.height="",t._element.style.width="100%",t._element.style.height=t._resizingDiv.style.height=t._origin_h/t._origin_w*t._element.offsetWidth+"px",/100/.test(e)&&(this.util.removeClass(t._container,this.context.video._floatClassRegExp),this.util.addClass(t._container,"float-center"))},cancelPercentAttr:function(){const e=this.context.video;e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.video._floatClassRegExp),this.util.addClass(e._container,"float-"+e._align)},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(){this.util.removeItem(this.context.video._container),this.plugins.video.init.call(this),this.controllersOff()},init:function(){const e=this.context.video;e.focusElement.value="",e.captionCheckEl.checked=!1,e.modal.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,e._resizing&&(e.videoWidth.value=this.context.option.videoWidth,e.videoHeight.value=this.context.option.videoHeight,e.proportion.checked=!0,e.proportion.disabled=!0)}}},r=function(e,t){const n=window,i=e.context.element.wysiwyg,l=e.util,o=e.context.tool.undo,s=e.context.tool.redo;let a=null,r=0,c=[{contents:e.getContents(),s:{path:[0,0],offset:0},e:{path:[0,0],offset:0}}];function d(){const n=c[r];i.innerHTML=n.contents,e.setRange(l.getNodeFromPath(n.s.path,i),n.s.offset,l.getNodeFromPath(n.e.path,i),n.e.offset),e.focus(),0===r?(o&&o.setAttribute("disabled",!0),s&&s.removeAttribute("disabled")):r===c.length-1?(o&&o.removeAttribute("disabled"),s&&s.setAttribute("disabled",!0)):(o&&o.removeAttribute("disabled"),s&&s.removeAttribute("disabled")),t()}return{push:function(){a&&n.clearTimeout(a),a=n.setTimeout(function(){n.clearTimeout(a),a=null,function(){const n=e.getContents();if(n===c[r].contents)return;r++;const i=e.getRange();c.length>r&&(c=c.slice(0,r),s&&s.setAttribute("disabled",!0)),c[r]={contents:n,s:{path:l.getNodePath(i.startContainer),offset:i.startOffset},e:{path:l.getNodePath(i.endContainer),offset:i.endOffset}},1===r&&o&&o.removeAttribute("disabled"),t()}()},500)},undo:function(){r>0&&(r--,d())},redo:function(){c.length-1>r&&(r++,d())},reset:function(){c=c[r=0]}}};const c={_d:document,_w:window,_onlyZeroWidthRegExp:new RegExp("^"+String.fromCharCode(8203)+"+$"),_tagConvertor:function(e){const t={b:"strong",i:"em",var:"em",u:"ins",strike:"del",s:"del"};return e.replace(/(<\/?)(pre|blockquote|h[1-6]|ol|ul|dl|li|hr|b|strong|var|i|em|u|ins|s|strike|del|sub|sup)\b\s*(?:[^>^<]+)?\s*(?=>)/gi,function(e,n,i){return n+("string"==typeof t[i]?t[i]:i)})},zeroWidthSpace:"​",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",o="js"===t?"src":"href";let s="(?:";for(let t=0,n=e.length;t0?i[0][o]:""),-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},convertContentsForEditor:function(e){let t,n,i="";e=e.trim();for(let l=0,o=(t=this._d.createRange().createContextualFragment(e).childNodes).length;l0&&(i+="

    "+t+"

    ")}else i+=n;const l={"&":"&"," ":" ","'":""","<":"<",">":">"};return e=e.replace(/&|\u00A0|'|<|>/g,function(e){return"string"==typeof l[e]?l[e]:e}),0===i.length&&(i="

    "+(e.length>0?e:this.zeroWidthSpace)+"

    "),this._tagConvertor(i.replace(this._deleteExclusionTags,""))},convertHTMLForCodeView:function(e){let t="";const n=this._w.RegExp;return function e(i){const l=i.childNodes;for(let i,o=0,s=l.length;o]*>","i"))[0]+"\n",e(i),t+="\n"}else t+=3===i.nodeType?/^\n+$/.test(i.data)?"":i.data:i.outerHTML+"\n"}(e),t},isWysiwygDiv:function(e){return!(!e||1!==e.nodeType||!this.hasClass(e,"se-wrapper-wysiwyg"))},isFormatElement:function(e){return!(!e||1!==e.nodeType||!/^(P|DIV|H[1-6]|LI|TH|TD)$/i.test(e.nodeName)||this.isComponent(e)||this.isWysiwygDiv(e))},isRangeFormatElement:function(e){return!(!e||1!==e.nodeType||!/^(BLOCKQUOTE|OL|UL|PRE|FIGCAPTION|TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(e.nodeName))},isComponent:function(e){return e&&(/se-component/.test(e.className)||/^(TABLE|HR)$/.test(e.nodeName))},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},getArrayIndex:function(e,t){let n=-1;for(let i=0,l=e.length;i0&&!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){let t=0,n=0,i=3===e.nodeType?e.parentElement:e;for(;!this.isWysiwygDiv(i.parentNode);)(/^(A|TD|TH|FIGURE|FIGCAPTION|IMG|IFRAME|AUDIO|VIDEO)$/i.test(i.nodeName)||/relative/i.test(i.style.position))&&(t+=i.offsetLeft,n+=i.offsetTop),i=i.parentNode;return{left:t,top:n-i.parentNode.scrollTop}},getOverlapRangeAtIndex:function(e,t,n,i){if(e<=i?tn)return 0;const l=(e>n?e:n)-(t(\n|.)*<\/([a-zA-Z]+\:[a-zA-Z]+|script|style)>/g,"").replace(/(<[a-zA-Z0-9]+)[^>]*(?=>)/g,function(e,t){const n=e.match(/((?:colspan|rowspan|target|href|src)\s*=\s*"[^"]*")/gi);if(n)for(let e=0,i=n.length;e^<]*)>/g,"").replace(this._deleteExclusionTags,""),this._tagConvertor(i||e)},_deleteExclusionTags:function(){const e="br|p|div|pre|blockquote|h[1-6]|ol|ul|dl|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|mark".split("|");let t="<\\/?(";for(let n=0,i=e.length;n'],underline:["_se_command_underline",e.toolbar.underline+" (CTRL+U)","INS","",''],italic:["_se_command_italic",e.toolbar.italic+" (CTRL+I)","EM","",''],strike:["_se_command_strike",e.toolbar.strike+" (CTRL+SHIFT+S)","DEL","",''],subscript:["_se_command_subscript",e.toolbar.subscript,"SUB","",''],superscript:["_se_command_superscript",e.toolbar.superscript,"SUP","",''],removeFormat:["",e.toolbar.removeFormat,"removeFormat","",''],indent:["",e.toolbar.indent+" (CTRL+])","indent","",''],outdent:["_se_command_outdent",e.toolbar.outdent+" (CTRL+[)","outdent","",''],fullScreen:["code-view-enabled",e.toolbar.fullScreen,"fullScreen","",''],showBlocks:["",e.toolbar.showBlocks,"showBlocks","",''],codeView:["code-view-enabled",e.toolbar.codeView,"codeView","",''],undo:["_se_command_undo",e.toolbar.undo+" (CTRL+Z)","undo","",'',!0],redo:["_se_command_redo",e.toolbar.redo+" (CTRL+Y / CTRL+SHIFT+Z)","redo","",'',!0],preview:["",e.toolbar.preview,"preview","",''],print:["",e.toolbar.print,"print","",''],save:["_se_command_save",e.toolbar.save,"save","",'',!0],font:["se-btn-select se-btn-tool-font _se_command_font_family",e.toolbar.font,"font","submenu",''+e.toolbar.font+''],formatBlock:["se-btn-select se-btn-tool-format",e.toolbar.formats,"formatBlock","submenu",''+e.toolbar.formats+''],fontSize:["se-btn-select se-btn-tool-size",e.toolbar.fontSize,"fontSize","submenu",''+e.toolbar.fontSize+''],fontColor:["",e.toolbar.fontColor,"fontColor","submenu",''],hiliteColor:["",e.toolbar.hiliteColor,"hiliteColor","submenu",''],align:["se-btn-align",e.toolbar.align,"align","submenu",''],list:["_se_command_list",e.toolbar.list,"list","submenu",''],horizontalRule:["btn_line",e.toolbar.horizontalRule,"horizontalRule","submenu",''],table:["",e.toolbar.table,"table","submenu",''],link:["",e.toolbar.link,"link","dialog",''],image:["",e.toolbar.image,"image","dialog",''],video:["",e.toolbar.video,"video","dialog",'']}},_createModuleGroup:function(e){const t=d.createElement("DIV");t.className="se-btn-module"+(e?"":" se-btn-module-border");const n=d.createElement("UL");return n.className="se-menu-list",t.appendChild(n),{div:t,ul:n}},_createButton:function(e,t,n,i,l,o){const s=d.createElement("LI"),a=d.createElement("BUTTON");return a.setAttribute("type","button"),a.setAttribute("class","se-btn-basic"+("submenu"===i?" se-btn-submenu":"")+(e?" "+e:"")+" se-tooltip"),a.setAttribute("data-command",n),a.setAttribute("data-display",i),l+=''+t+"",o&&a.setAttribute("disabled",!0),a.innerHTML=l,s.appendChild(a),{li:s,button:a}},_createToolBar:function(e,t,n,i){const l=e.createElement("DIV");l.className="se-toolbar-separator-vertical";const o=e.createElement("DIV");o.className="se-toolbar sun-editor-common";const s=this._defaultButtons(i),a={},r={};if(n){const e=n.length?n:Object.keys(n).map(function(e){return n[e]});for(let t=0,n=e.length;t0){for(let t=0;t":n),this.history.push()},focus:function(){if("none"===e.element.wysiwyg.style.display)return;const t=a.getParentElement(this.getSelectionNode(),"figcaption");t?t.focus():e.element.wysiwyg.focus(),this._editorRange(),u._findButtonEffectTag()},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=l.createRange();s.setStart(e,t),s.setEnd(n,i);const a=o.getSelection();a.removeAllRanges&&a.removeAllRanges(),a.addRange(s),this._editorRange()},getRange:function(){return this._variable._range||this._createDefaultRange()},getSelectionNode:function(){return this._variable._selectionNode||e.element.wysiwyg.firstChild},_editorRange:function(){const e=o.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(){const t=l.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},getSelectedElements:function(t){let n=this.getRange();if(a.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,o=n.commonAncestorContainer,s=a.getListChildren(o,function(e){return t?t(e):a.isFormatElement(e)});if(a.isWysiwygDiv(o)||a.isRangeFormatElement(o)||s.unshift(a.getFormatElement(o)),i===l||1===s.length)return s;let r=a.getFormatElement(i),c=a.getFormatElement(l),d=null,u=null;const h=function(e){return!a.isTable(e)||/^TABLE$/i.test(e.nodeName)},p=a.getRangeFormatElement(r,h),g=a.getRangeFormatElement(c,h),m=p===g;for(let e,t=0,n=s.length;t=0;e--)c[e]===i.parentNode&&c[e].firstChild===i&&0===n&&(d=e,i=i.parentNode);for(let e=u-1,t=i;e>d;e--)c[e]===t.parentNode&&1===c[e].nodeType&&(c.splice(e,1),t=t.parentNode,--u);for(let e=d;e<=u;e++){const o=c[e];0===o.length||3===o.nodeType&&void 0===o.data?a.removeItem(o):o!==t?o!==i?(a.removeItem(o),this.history.push()):(r=1===i.nodeType?a.createTextNode(i.textContent):a.createTextNode(i.substringData(l,i.length-l))).length>0?i.data=r.data:a.removeItem(i):(s=1===t.nodeType?a.createTextNode(t.textContent):a.createTextNode(t.substringData(0,n))).length>0?t.data=s.data:a.removeItem(t)}},applyRangeFormatElement:function(e){const t=this.getSelectedElementsAndComponents();if(!t||0===t.length)return;let n,i,l,o=t[t.length-1];n=a.isRangeFormatElement(o)||a.isFormatElement(o)?o:a.getRangeFormatElement(o)||a.getFormatElement(o),a.isCell(n)?(i=null,l=n):(i=n.nextSibling,l=n.parentNode);let s=a.getElementDepth(n),r=null;const c=[],d=function(e,t,n){let i=null;return e===t||a.isTable(t)||(i=a.removeItemAllParents(t)),i?i.ec:n};for(let n,o,u,h,p=0,g=t.length;p=u?(s=u,(i=d(l=t.cc,o,t.ec))&&(l=i.parentNode)):l===t.cc&&(i=t.ec),l!==t.cc&&void 0!==(h=d(l,t.cc))&&(i=h),e.appendChild(r),r=null}}else s>=u&&(s=u,l=o,i=n.nextSibling),e.appendChild(n),l!==o&&void 0!==(h=d(l,o))&&(i=h);l.insertBefore(e,i),d(e,i),this.history.push();const u=this.util.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)},detachRangeFormatElement:function(e,t,n,i,l){const o=this.getRange(),s=o.startOffset,r=o.endOffset,c=e.children,d=e.parentNode;let h=null,p=null,g=e.cloneNode(!1);const m=a.isList(n);let f=!1;function _(e,t,n){a.onlyZeroWidthSpace(t)&&(t.innerHTML=a.zeroWidthSpace);const i=t.childNodes;let l=t.cloneNode(!1),o=null,s=null;for(;i[0];)s=i[0],a.isIgnoreNodeChange(s)&&!a.isListCell(l)?(l.childNodes.length>0&&(o||(o=l),e.insertBefore(l,n),l=t.cloneNode(!1)),e.insertBefore(s,n),o||(o=s)):l.appendChild(s);return l.childNodes.length>0&&(e.insertBefore(l,n),o||(o=l)),o}for(let l,o=0,s=c.length;o0&&(d.insertBefore(g,e),g=null),!m&&a.isListCell(l)){const t=l.innerHTML;(l=a.isCell(e.parentNode)?a.createElement("DIV"):a.createElement("P")).innerHTML=t}else l=l.cloneNode(!0);i||(n?(f||(d.insertBefore(n,e),f=!0),l=_(n,l,null)):l=_(d,l,e),t?(p=l,h||(h=l)):h||(h=p=l))}const b=e.parentNode,y=e.nextSibling;g&&g.children.length>0&&b.insertBefore(g,y),a.removeItem(e);const v=i?{cc:b,sc:h,ec:h&&h.parentNode?h.nextSibling:g&&g.children.length>0?g:y||null}:this.util.getEdgeChildNodes(h,p);if(l)return v;this.history.push(),!i&&v&&(t?this.setRange(v.sc,s,v.ec,r):this.setRange(v.sc,0,v.sc,0)),u._findButtonEffectTag()},nodeChange:function(t,n,i){const l=this.getRange();n=!!(n&&n.length>0)&&n,i=!!(i&&i.length>0)&&i,this._editorRange();const s=!t,r=s&&!i&&!n;let c,d,u;if(r&&l.collapsed&&a.isFormatElement(l.startContainer.parentNode)&&a.isFormatElement(l.endContainer.parentNode))return;if(s&&(t=this.util.createElement("DIV")),!r&&l.startContainer===l.endContainer){let e=l.startContainer;if(r){if(a.getFormatElement(e)===e.parentNode)return}else if(n.length>0){let i=0;for(let l=0;l=n.length)return;if(s&&0===i)return}}if(c=a.isWysiwygDiv(l.startContainer)?e.element.wysiwyg.firstChild:l.startContainer,d=l.startOffset,1===c.nodeType&&c.childNodes.length>0){for(;c&&!a.isBreak(c)&&1===c.nodeType;)c=c.childNodes[d]||c.nextElementSibling||c.nextSibling,d=0;let e=a.getFormatElement(c);if(e===a.getRangeFormatElement(e)&&(e=a.createElement(a.isCell(c)?"DIV":"P"),c.parentNode.insertBefore(e,c),e.appendChild(c)),a.isBreak(c)){const e=a.createTextNode(a.zeroWidthSpace);c.parentNode.insertBefore(e,c),c=e}}let h=c,p=d;if(c=a.isWysiwygDiv(l.endContainer)?e.element.wysiwyg.lastChild:l.endContainer,d=l.endOffset,1===c.nodeType&&c.childNodes.length>0){for(;c&&!a.isBreak(c)&&1===c.nodeType;)d=(c=(u=c.childNodes)[d-1]||!/FIGURE/i.test(u[0].nodeName)?u[0]:c.previousElementSibling||c.previousSibling||h).textContent.length;let e=a.getFormatElement(c);if(e===a.getRangeFormatElement(e)&&(e=a.createElement(a.isCell(e)?"DIV":"P"),c.parentNode.insertBefore(e,c),e.appendChild(c)),a.isBreak(c)){const e=a.createTextNode(a.zeroWidthSpace);c.parentNode.insertBefore(e,c),c=e,d=0}}let g=c,m=d;const f=t.nodeName;this.setRange(h,p,g,m);let _,b,y,v={},x={};if(n){b="(?:;|^|\\s)(?:"+n[0];for(let e=1;e0&&(n=t.replace(b,"").trim()),s){if(b&&y&&!n&&y.test(e.nodeName))return!1;if(b&&!n&&t)return!1;if(y&&y.test(e.nodeName))return!1}return!(!n&&e.nodeName===f||(b&&t.length>0&&(e.style.cssText=n),0))},w=this.getSelectedElements();a.getFormatElement(h)||(h=a.getChildElement(w[0],function(e){return 3===e.nodeType}),p=0),a.getFormatElement(g)||(m=(g=a.getChildElement(w[w.length-1],function(e){return 3===e.nodeType})).textContent.length);const E=a.getFormatElement(h)===a.getFormatElement(g),k=w.length-(E?0:1);if(_=t.cloneNode(!1),E){const e=this._nodeChange_oneLine(w[0],_,C,h,p,g,m,r,s,l.collapsed);v.container=e.startContainer,v.offset=e.startOffset,x.container=e.endContainer,x.offset=e.endOffset}else v=this._nodeChange_startLine(w[0],_,C,h,p,r,s);for(let e=1;e0&&!E?(_=t.cloneNode(!1),x=this._nodeChange_endLine(w[k],_,C,g,m,r,s)):E||(x=v),this.setRange(v.container,v.offset,x.container,x.offset),this.history.push()},_stripRemoveNode:function(e,t){if(!t||3===t.nodeType)return;const n=t.childNodes;for(;n[0];)e.insertBefore(n[0],t);e.removeChild(t)},_nodeChange_oneLine:function(e,t,n,i,l,s,r,c,d,u){const h=e,p=t,g=[t],m=e.cloneNode(!1),f=i===s;let _,b,y,v,x=i,C=l,w=s,E=r,k=!1,S=!1;function N(e){const t=new o.RegExp("(?:;|^|\\s)(?:"+v+"null)\\s*:[^;]*\\s*(?:;|$)","ig");let n="";return t&&e.style.cssText.length>0&&(n=t.test(e.style.cssText)),!n}if(function e(i,l){const o=i.childNodes;for(let i=0,s=o.length;i=C?E-C:x.data.length-C));for(e.data.length>0&&l.appendChild(e),b=s,_=[],v="";b!==m&&b!==h&&null!==b;)n(b)&&1===b.nodeType&&N(b)&&(_.push(b.cloneNode(!1)),v+=b.style.cssText.substr(0,b.style.cssText.indexOf(":"))+"|"),b=b.parentNode;const o=_.pop()||i;for(y=b=o;_.length>0;)b=_.pop(),y.appendChild(b),y=b;if(t.appendChild(o),m.appendChild(t),x=i,C=0,k=!0,b!==i&&b.appendChild(x),!f)continue}if(S||s!==w){if(k){if(1===s.nodeType&&!a.isBreak(s)){a.isIgnoreNodeChange(s)?(t=t.cloneNode(!1),m.appendChild(s),m.appendChild(t),g.push(t),i--):e(s,s);continue}for(b=s,_=[],v="";null!==b.parentNode&&b!==h&&b!==t;)1===b.nodeType&&!a.isBreak(s)&&(S||n(b))&&N(b)&&(_.push(b.cloneNode(!1)),v+=b.style.cssText.substr(0,b.style.cssText.indexOf(":"))+"|"),b=b.parentNode;const o=_.pop()||s;for(y=b=o;_.length>0;)b=_.pop(),y.appendChild(b),y=b;o===s?l=S?m:t:S?(m.appendChild(o),l=b):(t.appendChild(o),l=b)}r=s.cloneNode(!1),l.appendChild(r),1!==s.nodeType||a.isBreak(s)||(d=r),e(s,d)}else{const e=a.createTextNode(1===w.nodeType?"":w.substringData(E,w.length-E)),i=a.createTextNode(f||1===w.nodeType?"":w.substringData(0,E));if(e.data.length>0){for(b=s,v="",_=[];b!==m&&b!==h&&null!==b;)1===b.nodeType&&N(b)&&(_.push(b.cloneNode(!1)),v+=b.style.cssText.substr(0,b.style.cssText.indexOf(":"))+"|"),b=b.parentNode;for(r=y=b=_.pop()||e;_.length>0;)b=_.pop(),y.appendChild(b),y=b;m.appendChild(r),b.textContent=e.data}for(b=s,_=[],v="";b!==m&&b!==h&&null!==b;)n(b)&&1===b.nodeType&&N(b)&&(_.push(b.cloneNode(!1)),v+=b.style.cssText.substr(0,b.style.cssText.indexOf(":"))+"|"),b=b.parentNode;const l=_.pop()||i;for(y=b=l;_.length>0;)b=_.pop(),y.appendChild(b),y=b;t.appendChild(l),w=i,E=i.data.length,S=!0,!c&&u&&(t=i,i.textContent=a.zeroWidthSpace),b!==i&&b.appendChild(w)}}}(e,m),c=c&&d)for(let e=0;e0){const e=u.pop();for(p=h=e;u.length>0;)h=u.pop(),p.appendChild(h),p=h;t.appendChild(e),l=h}else l=t}if(f||s!==g){if(!f||n(s)){const e=s.cloneNode(!1);l.appendChild(e),1!==s.nodeType||a.isBreak(s)||(_=e)}e(s,_)}else{const e=a.createTextNode(1===g.nodeType?"":g.substringData(0,m)),i=a.createTextNode(1===g.nodeType?"":g.substringData(m,g.length-m));for(e.data.length>0&&l.appendChild(e),h=l,u=[];h!==d&&null!==h;)1===h.nodeType&&n(h)&&u.push(h.cloneNode(!1)),h=h.parentNode;const o=u.pop()||l;for(p=h=o;u.length>0;)h=u.pop(),p.appendChild(h),p=h;o!==l?(t.appendChild(o),l=h):l=t,a.isBreak(s)&&t.appendChild(s.cloneNode(!1)),d.appendChild(t),g=i,m=0,f=!0,l.appendChild(g)}}}(e,d),o=o&&s)for(let e=0;e0){const e=u.pop();for(p=h=e;u.length>0;)h=u.pop(),p.appendChild(h),p=h;t.insertBefore(e,t.firstChild),l=h}else l=t}if(f||s!==g){if(!f||n(s)){const e=s.cloneNode(!1);l.insertBefore(e,l.firstChild),1!==s.nodeType||a.isBreak(s)||(_=e)}e(s,_)}else{const e=a.createTextNode(1===g.nodeType?"":g.substringData(m,g.length-m)),i=a.createTextNode(1===g.nodeType?"":g.substringData(0,m));for(e.data.length>0&&l.insertBefore(e,l.firstChild),h=l,u=[];h!==d&&null!==h;)n(h)&&1===h.nodeType&&u.push(h.cloneNode(!1)),h=h.parentNode;const o=u.pop()||l;for(p=h=o;u.length>0;)h=u.pop(),p.appendChild(h),p=h;o!==l?(t.insertBefore(o,t.firstChild),l=h):l=t,a.isBreak(s)&&t.appendChild(s.cloneNode(!1)),d.insertBefore(t,d.firstChild),g=i,m=i.data.length,f=!0,l.insertBefore(g,l.firstChild)}}}(e,d),o=o&&s)for(let e=0;e0?e.element.code.scrollHeight+"px":"auto"),this._variable.wysiwygActive=!1,e.element.code.focus();else{const t=e.element.code.value.trim();e.element.wysiwyg.innerHTML=t.length>0?a.convertContentsForEditor(t):"

    "+a.zeroWidthSpace+"

    ",e.element.wysiwyg.scrollTop=0,e.element.code.style.display="none",e.element.wysiwyg.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"===e.option.height&&(e.element.code.style.height="0px"),this._variable.wysiwygActive=!0,this.focus()}},toggleFullScreen:function(t){const n=e.element.topArea,i=e.element.toolbar,s=e.element.editorArea,r=e.element.wysiwyg,c=e.element.code;this._variable.isFullScreen?(this._variable.isFullScreen=!1,r.style.cssText=this._variable._wysiwygOriginCssText,c.style.cssText=this._variable._codeOriginCssText,i.style.cssText="",s.style.cssText=this._variable._editorAreaOriginCssText,n.style.cssText=this._variable._originCssText,l.body.style.overflow=this._variable._bodyOverflow,e.option.stickyToolbar>-1&&(a.removeClass(i,"se-toolbar-sticky"),u.onScroll_window()),this._variable._fullScreenSticky&&(this._variable._fullScreenSticky=!1,e.element._stickyDummy.style.display="block",a.addClass(i,"se-toolbar-sticky")),a.removeClass(t.firstElementChild,"se-icon-reduction"),a.addClass(t.firstElementChild,"se-icon-expansion")):(this._variable.isFullScreen=!0,n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.zIndex="2147483647","none"!==e.element._stickyDummy.style.display&&(this._variable._fullScreenSticky=!0,e.element._stickyDummy.style.display="none",a.removeClass(i,"se-toolbar-sticky")),this._variable._bodyOverflow=l.body.style.overflow,l.body.style.overflow="hidden",this._variable._editorAreaOriginCssText=s.style.cssText,this._variable._wysiwygOriginCssText=r.style.cssText,this._variable._codeOriginCssText=c.style.cssText,s.style.cssText=i.style.cssText="",r.style.cssText=r.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)[0],c.style.cssText=c.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)[0],i.style.width=r.style.height=c.style.height="100%",i.style.position="relative",this._variable.innerHeight_fullScreen=o.innerHeight-i.offsetHeight,s.style.height=this._variable.innerHeight_fullScreen+"px",a.removeClass(t.firstElementChild,"se-icon-expansion"),a.addClass(t.firstElementChild,"se-icon-reduction"))},openWindowContents:function(t){const n="print"===t,l=o.open("","_blank");l.mimeType="text/html",l.document.write(''+(n?i.toolbar.print:i.toolbar.preview)+'
    '+this.getContents()+"
    "+(n?"