From 661caaff14e25f56fde8ec624cc8ff672f3e3dd4 Mon Sep 17 00:00:00 2001
From: Yi JiHong <0125ses@hanmail.net>
Date: Mon, 10 Apr 2023 00:51:54 +0900
Subject: [PATCH 1/2] fix: paste data
---
src/lib/core.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/core.js b/src/lib/core.js
index dc3d04db..7967d2a6 100755
--- a/src/lib/core.js
+++ b/src/lib/core.js
@@ -5447,7 +5447,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
* @returns {String}
*/
cleanHTML: function (html, whitelist, blacklist) {
- html = this._deleteDisallowedTags(this._parser.parseFromString(html, 'text/html').body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g, this._cleanTags.bind(this, true));
+ html = this._deleteDisallowedTags(this._parser.parseFromString(html, 'text/html').body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g, this._cleanTags.bind(this, true)).replace(/
$/i, '');
const dom = _d.createRange().createContextualFragment(html);
try {
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, this._htmlCheckBlacklistRegExp, true);
From e69fe07e4f1cc6cb86556e7e6fbe88683800f070 Mon Sep 17 00:00:00 2001
From: Yi JiHong <0125ses@hanmail.net>
Date: Mon, 10 Apr 2023 00:52:21 +0900
Subject: [PATCH 2/2] version fix: 2.44.8
---
dist/suneditor.min.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dist/suneditor.min.js b/dist/suneditor.min.js
index 02911c9d..f0d3fbb0 100644
--- a/dist/suneditor.min.js
+++ b/dist/suneditor.min.js
@@ -1,2 +1,2 @@
-!function(e){var t={};function n(i){if(t[i])return t[i].exports;var l=t[i]={i:i,l:!1,exports:{}};return e[i].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(i,l,function(t){return e[t]}.bind(null,l));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="XJR1")}({"1kvd":function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={name:"dialog",add:function(e){const t=e.context;t.dialog={kind:"",updateModal:!1,_closeSignal:!1};let n=e.util.createElement("DIV");n.className="se-dialog sun-editor-common";let i=e.util.createElement("DIV");i.className="se-dialog-back",i.style.display="none";let l=e.util.createElement("DIV");l.className="se-dialog-inner",l.style.display="none",n.appendChild(i),n.appendChild(l),t.dialog.modalArea=n,t.dialog.back=i,t.dialog.modal=l,t.dialog.modal.addEventListener("mousedown",this._onMouseDown_dialog.bind(e)),t.dialog.modal.addEventListener("click",this._onClick_dialog.bind(e)),t.element.relative.appendChild(n),n=null,i=null,l=null},_onMouseDown_dialog:function(e){/se-dialog-inner/.test(e.target.className)?this.context.dialog._closeSignal=!0:this.context.dialog._closeSignal=!1},_onClick_dialog:function(e){(/close/.test(e.target.getAttribute("data-command"))||this.context.dialog._closeSignal)&&this.plugins.dialog.close.call(this)},open:function(e,t){if(this.modalForm)return!1;this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null),this.plugins.dialog._bindClose=function(e){/27/.test(e.keyCode)&&this.plugins.dialog.close.call(this)}.bind(this),this._d.addEventListener("keydown",this.plugins.dialog._bindClose),this.context.dialog.updateModal=t,"full"===this.options.popupDisplay?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const n=this.context[e].focusElement;"function"==typeof this.plugins[e].on&&this.plugins[e].on.call(this,t),this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",n&&n.focus()},_bindClose:null,close:function(){this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null);const e=this.context.dialog.kind;this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.context.dialog.updateModal=!1,"function"==typeof this.plugins[e].init&&this.plugins[e].init.call(this),this.context.dialog.kind="",this.modalForm=null,this.focus()}};return void 0===t&&(e.SUNEDITOR_MODULES||Object.defineProperty(e,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(e.SUNEDITOR_MODULES,"dialog",{enumerable:!0,writable:!1,configurable:!1,value:n})),n},"object"==typeof e.exports?e.exports=i.document?l(i,!0):function(e){if(!e.document)throw new Error("SUNEDITOR_MODULES a window with a document");return l(e)}:l(i)},"3FqI":function(e,t,n){},JhlZ:function(e,t,n){"use strict";var i,l;i="undefined"!=typeof window?window:this,l=function(e,t){const n={name:"fileBrowser",_xmlHttp:null,_loading:null,add:function(e){const t=e.context;t.fileBrowser={_closeSignal:!1,area:null,header:null,tagArea:null,body:null,list:null,tagElements:null,items:[],selectedTags:[],selectorHandler:null,contextPlugin:"",columnSize:4};let n=e.util.createElement("DIV");n.className="se-file-browser sun-editor-common";let i=e.util.createElement("DIV");i.className="se-file-browser-back";let l=e.util.createElement("DIV");l.className="se-file-browser-inner",l.innerHTML=this.set_browser(e),n.appendChild(i),n.appendChild(l),this._loading=n.querySelector(".se-loading-box"),t.fileBrowser.area=n,t.fileBrowser.header=l.querySelector(".se-file-browser-header"),t.fileBrowser.titleArea=l.querySelector(".se-file-browser-title"),t.fileBrowser.tagArea=l.querySelector(".se-file-browser-tags"),t.fileBrowser.body=l.querySelector(".se-file-browser-body"),t.fileBrowser.list=l.querySelector(".se-file-browser-list"),t.fileBrowser.tagArea.addEventListener("click",this.onClickTag.bind(e)),t.fileBrowser.list.addEventListener("click",this.onClickFile.bind(e)),l.addEventListener("mousedown",this._onMouseDown_browser.bind(e)),l.addEventListener("click",this._onClick_browser.bind(e)),t.element.relative.appendChild(n),n=null,i=null,l=null},set_browser:function(e){const t=e.lang;return'
0)&&t,n=!!(n&&n.length>0)&&n;const s=!e,o=s&&!n&&!t;let c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset;if(o&&l.collapsed&&r.isFormatElement(c.parentNode)||c===u&&1===c.nodeType&&r.isNonEditable(c)){const e=c.parentNode;if(!r.isListCell(e)||!r.getValues(e.style).some(function(e){return this._listKebab.indexOf(e)>-1}.bind(this)))return}if(l.collapsed&&!o&&1===c.nodeType&&!r.isBreak(c)&&!r.isComponent(c)){let e=null;const t=c.childNodes[d];t&&(e=t.nextSibling?r.isBreak(t)?t:t.nextSibling:null);const n=r.createTextNode(r.zeroWidthSpace);c.insertBefore(n,e),this.setRange(n,1,n,1),l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset}r.isFormatElement(c)&&(c=c.childNodes[d]||c.firstChild,d=0),r.isFormatElement(u)&&(u=u.childNodes[h]||u.lastChild,h=u.textContent.length),s&&(e=r.createElement("DIV"));const g=a.RegExp,p=e.nodeName;if(!o&&c===u&&!n&&e){let t=c,n=0;const i=[],l=e.style;for(let e=0,t=l.length;e 0)&&t,n=!!(n&&n.length>0)&&n;const s=!e,o=s&&!n&&!t;let c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset;if(o&&l.collapsed&&r.isFormatElement(c.parentNode)||c===u&&1===c.nodeType&&r.isNonEditable(c)){const e=c.parentNode;if(!r.isListCell(e)||!r.getValues(e.style).some(function(e){return this._listKebab.indexOf(e)>-1}.bind(this)))return}if(l.collapsed&&!o&&1===c.nodeType&&!r.isBreak(c)&&!r.isComponent(c)){let e=null;const t=c.childNodes[d];t&&(e=t.nextSibling?r.isBreak(t)?t:t.nextSibling:null);const n=r.createTextNode(r.zeroWidthSpace);c.insertBefore(n,e),this.setRange(n,1,n,1),l=this.getRange(),c=l.startContainer,d=l.startOffset,u=l.endContainer,h=l.endOffset}r.isFormatElement(c)&&(c=c.childNodes[d]||c.firstChild,d=0),r.isFormatElement(u)&&(u=u.childNodes[h]||u.lastChild,h=u.textContent.length),s&&(e=r.createElement("DIV"));const g=a.RegExp,p=e.nodeName;if(!o&&c===u&&!n&&e){let t=c,n=0;const i=[],l=e.style;for(let e=0,t=l.length;e
"+l.defaultTag+">"},_setEditorDataToCodeView:function(){const t=this.convertHTMLForCodeView(e.element.wysiwyg,!1);let n="";if(l.fullPage){const e=r.getAttributesToString(this._wd.body,null);n="\n\n"+this._wd.head.outerHTML.replace(/>(?!\n)/g,">\n")+"\n"+t+"\n"}else n=t;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(n)},toggleFullScreen:function(t){const n=e.element.topArea,i=e.element.toolbar,s=e.element.editorArea,d=e.element.wysiwygFrame,g=e.element.code,p=this._variable;this.controllersOff();const m="none"===i.style.display||this._isInline&&!this._inlineToolbarAttr.isShow;p.isFullScreen?(p.isFullScreen=!1,d.style.cssText=p._wysiwygOriginCssText,g.style.cssText=p._codeOriginCssText,i.style.cssText="",s.style.cssText=p._editorAreaOriginCssText,n.style.cssText=p._originCssText,o.body.style.overflow=p._bodyOverflow,"auto"!==l.height||l.codeMirrorEditor||u._codeViewAutoHeight(),l.toolbarContainer&&l.toolbarContainer.appendChild(i),l.stickyToolbar>-1&&r.removeClass(i,"se-toolbar-sticky"),p._fullScreenAttrs.sticky&&!l.toolbarContainer&&(p._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",r.addClass(i,"se-toolbar-sticky")),this._isInline=p._fullScreenAttrs.inline,this._isBalloon=p._fullScreenAttrs.balloon,this._isInline&&u._showToolbarInline(),l.toolbarContainer&&r.removeClass(i,"se-toolbar-balloon"),u.onScroll_window(),t&&r.changeElement(t.firstElementChild,c.expansion),e.element.topArea.style.marginTop="",r.removeClass(this._styleCommandMap.fullScreen,"active")):(p.isFullScreen=!0,p._fullScreenAttrs.inline=this._isInline,p._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),l.toolbarContainer&&e.element.relative.insertBefore(i,s),n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.maxWidth="100%",n.style.height="100%",n.style.zIndex="2147483647",""!==e.element._stickyDummy.style.display&&(p._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",r.removeClass(i,"se-toolbar-sticky")),p._bodyOverflow=o.body.style.overflow,o.body.style.overflow="hidden",p._editorAreaOriginCssText=s.style.cssText,p._wysiwygOriginCssText=d.style.cssText,p._codeOriginCssText=g.style.cssText,s.style.cssText=i.style.cssText="",d.style.cssText=(d.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+l._editorStyles.editor,g.style.cssText=(g.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],i.style.width=d.style.height=g.style.height="100%",i.style.position="relative",i.style.display="block",p.innerHeight_fullScreen=a.innerHeight-i.offsetHeight,s.style.height=p.innerHeight_fullScreen-l.fullScreenOffset+"px",t&&r.changeElement(t.firstElementChild,c.reduction),l.iframe&&"auto"===l.height&&(s.style.overflow="auto",this._iframeAutoHeight()),e.element.topArea.style.marginTop=l.fullScreenOffset+"px",r.addClass(this._styleCommandMap.fullScreen,"active")),m&&h.toolbar.hide(),"function"==typeof h.toggleFullScreen&&h.toggleFullScreen(this._variable.isFullScreen,this)},print:function(){const e=r.createElement("IFRAME");e.style.display="none",o.body.appendChild(e);const t=l.printTemplate?l.printTemplate.replace(/\{\{\s*contents\s*\}\}/i,this.getContents(!0)):this.getContents(!0),n=r.getIframeDocument(e),i=this._wd;if(l.iframe){const e=null!==l._printClass?'class="'+l._printClass+'"':l.fullPage?r.getAttributesToString(i.body,["contenteditable"]):'class="'+l._editableClass+'"';n.write(""+i.head.innerHTML+""+t+"")}else{const e=o.head.getElementsByTagName("link"),i=o.head.getElementsByTagName("style");let s="";for(let t=0,n=e.length;t0&&(l+="<"+n+">"+r._HTMLConvertor(e)+""+n+">");return l}return 8===e.nodeType&&this._allowHTMLComments?"\x3c!--"+e.textContent.trim()+"--\x3e":""},_tagConvertor:function(e){if(!this._disallowedTextTagsRegExp)return e;const t=l._textTagsMap;return e.replace(this._disallowedTextTagsRegExp,(function(e,n,i,l){return n+("string"==typeof t[i]?t[i]:i)+(l?" "+l:"")}))},_deleteDisallowedTags:function(e){return e=e.replace(/<(script|style)[\s\S]*>[\s\S]*<\/(script|style)>/gi,"").replace(/<[a-z0-9]+\:[a-z0-9]+[^>^\/]*>[^>]*<\/[a-z0-9]+\:[a-z0-9]+>/gi,""),/\bfont\b/i.test(this.options._editorTagsWhitelist)||(e=e.replace(/(<\/?)font(\s?)/gi,"$1span$2")),e.replace(this.editorTagsWhitelistRegExp,"").replace(this.editorTagsBlacklistRegExp,"")},_convertFontSize:function(e,t){const n=this._w.Math,i=t.match(/(\d+(?:\.\d+)?)(.+)/),l=i?1*i[1]:r.fontValueMap[t],s=i?i[2]:"rem";let o=l;switch(/em/.test(s)?o=n.round(l/.0625):"pt"===s?o=n.round(1.333*l):"%"===s&&(o=l/100),e){case"em":case"rem":case"%":return(.0625*o).toFixed(2)+e;case"pt":return n.floor(o/1.333)+e;default:return o+e}},_cleanStyle:function(e,t,n){let i=(e.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/)||[])[0];if(/span/i.test(n)&&!i&&(e.match(/0&&t.push('style="'+n.join(";")+'"')}}return t},_cleanTags:function(e,t,n){if(/^<[a-z0-9]+\:[a-z0-9]+/i.test(t))return t;let i=null;const l=n.match(/(?!<)[a-zA-Z0-9\-]+/)[0].toLowerCase(),s=this._attributesTagsBlacklist[l];t=t.replace(/\s(?:on[a-z]+)\s*=\s*(")[^"]*\1/gi,""),t=s?t.replace(s,""):t.replace(this._attributesBlacklistRegExp,"");const o=this._attributesTagsWhitelist[l];if(i=o?t.match(o):t.match(e?this._attributesWhitelistRegExp:this._attributesWhitelistRegExp_all_data),e||"span"===l)if("a"===l){const e=t.match(/(?:(?:id|name)\s*=\s*(?:"|')[^"']*(?:"|'))/g);e&&(i||(i=[]),i.push(e[0]))}else i&&/style=/i.test(i.toString())||("span"===l?i=this._cleanStyle(t,i,"span"):/^(P|DIV|H[1-6]|PRE)$/i.test(l)&&(i=this._cleanStyle(t,i,"format")));else{const e=t.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);e&&!i?i=[e[0]]:e&&!i.some((function(e){return/^style/.test(e.trim())}))&&i.push(e[0])}if(r.isFigures(l)){const e=t.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);if(i||(i=[]),e){const t=e[0].match(/width\s?:\s?(\d+)(px|%)/),n=e[0].match(/height\s?:\s?(\d+)(px|%)/),l=t&&t[1]&&t[2]?t[1]+t[2]:"auto",s=n&&n[1]&&n[2]?n[1]+n[2]:"auto";i.push('style="width:'+l+"; height:"+s+';"')}}if(i)for(let e=0,t=i.length;e
")+"":r.isRangeFormatElement(n)&&!r.isTable(n)?t+=this._convertListCell(n):t+="
")+"
"+l.defaultTag+">":(i=r.htmlRemoveWhiteSpace(i),this._tagConvertor(i))},convertHTMLForCodeView:function(e,t){let n="";const i=a.RegExp,l=new i("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),s="string"==typeof e?o.createRange().createContextualFragment(e):e,c=function(e){return this.isFormatElement(e)||this.isComponent(e)}.bind(r),d=t?"":"\n";let u=t?0:1*this._variable.codeIndent;return u=u>0?new a.Array(u+1).join(" "):"",function e(t,s){const o=t.childNodes,h=l.test(t.nodeName),g=h?s:"";for(let p,m,f,_,b,v,y=0,C=o.length;y
",f.parentElement.replaceChild(e,f)}return d.nativeFocus(),!1}}if(f&&g.startContainer===g.endContainer&&3===c.nodeType&&!r.isFormatElement(c.parentNode)&&(g.collapsed?1===c.textContent.length:g.endOffset-g.startOffset===c.textContent.length)){t.preventDefault();let e=null,n=c.parentNode.previousSibling;const i=c.parentNode.nextSibling;n||(i?(n=i,e=0):(n=r.createElement("BR"),f.appendChild(n))),c.textContent="",r.removeItemAllParents(c,null,f),e="number"==typeof e?e:3===n.nodeType?n.textContent.length:1,d.setRange(n,e,n,e);break}if(u._isUneditableNode(g,!0)){t.preventDefault(),t.stopPropagation();break}!p&&d._isEdgeFormat(g.startContainer,g.startOffset,"start")&&r.isFormatElement(f.previousElementSibling)&&(d._formatAttrsTemp=f.previousElementSibling.attributes);const n=g.commonAncestorContainer;if(f=r.getFormatElement(g.startContainer,null),_=r.getRangeFormatElement(f,null),_&&f&&!r.isCell(_)&&!/^FIGCAPTION$/i.test(_.nodeName)){if(r.isListCell(f)&&r.isList(_)&&(r.isListCell(_.parentNode)||f.previousElementSibling)&&(c===f||3===c.nodeType&&(!c.previousSibling||r.isList(c.previousSibling)))&&(r.getFormatElement(g.startContainer,null)!==r.getFormatElement(g.endContainer,null)?_.contains(g.startContainer):0===g.startOffset&&g.collapsed)){if(g.startContainer!==g.endContainer)t.preventDefault(),d.removeNode(),3===g.startContainer.nodeType&&d.setRange(g.startContainer,g.startContainer.textContent.length,g.startContainer,g.startContainer.textContent.length),d.history.push(!0);else{let e=f.previousElementSibling||_.parentNode;if(r.isListCell(e)){t.preventDefault();let n=e;if(!e.contains(f)&&r.isListCell(n)&&r.isList(n.lastElementChild)){for(n=n.lastElementChild.lastElementChild;r.isListCell(n)&&r.isList(n.lastElementChild);)n=n.lastElementChild&&n.lastElementChild.lastElementChild;e=n}let i=e===_.parentNode?_.previousSibling:e.lastChild;i||(i=r.createTextNode(r.zeroWidthSpace),_.parentNode.insertBefore(i,_.parentNode.firstChild));const l=3===i.nodeType?i.textContent.length:1,s=f.childNodes;let o=i,a=s[0];for(;a=s[0];)e.insertBefore(a,o.nextSibling),o=a;r.removeItem(f),0===_.children.length&&r.removeItem(_),d.setRange(i,l,i,l),d.history.push(!0)}}break}if(!p&&0===g.startOffset){let e=!0,i=n;for(;i&&i!==_&&!r.isWysiwygDiv(i);){if(i.previousSibling&&(1===i.previousSibling.nodeType||!r.onlyZeroWidthSpace(i.previousSibling.textContent.trim()))){e=!1;break}i=i.parentNode}if(e&&_.parentNode){t.preventDefault(),d.detachRangeFormatElement(_,r.isListCell(f)?[f]:null,null,!1,!1),d.history.push(!0);break}}}if(!p&&f&&(0===g.startOffset||c===f&&f.childNodes[g.startOffset])){const e=c===f?f.childNodes[g.startOffset]:c,i=f.previousSibling,l=(3===n.nodeType||r.isBreak(n))&&!n.previousSibling&&0===g.startOffset;if(e&&!e.previousSibling&&(n&&r.isComponent(n.previousSibling)||l&&r.isComponent(i))){const e=d.getFileComponent(i);e?(t.preventDefault(),t.stopPropagation(),0===f.textContent.length&&r.removeItem(f),!1===d.selectComponent(e.target,e.pluginName)&&d.blur()):r.isComponent(i)&&(t.preventDefault(),t.stopPropagation(),r.removeItem(i));break}if(e&&r.isNonEditable(e.previousSibling)){t.preventDefault(),t.stopPropagation(),r.removeItem(e.previousSibling);break}}break;case 46:if(m){t.preventDefault(),t.stopPropagation(),d.plugins[m].destroy.call(d);break}if(p&&u._hardDelete()){t.preventDefault(),t.stopPropagation();break}if(u._isUneditableNode(g,!1)){t.preventDefault(),t.stopPropagation();break}if((r.isFormatElement(c)||null===c.nextSibling||r.onlyZeroWidthSpace(c.nextSibling)&&null===c.nextSibling.nextSibling)&&g.startOffset===c.textContent.length){const e=f.nextElementSibling;if(!e)break;if(r.isComponent(e)){if(t.preventDefault(),r.onlyZeroWidthSpace(f)&&(r.removeItem(f),r.isTable(e))){let t=r.getChildElement(e,r.isCell,!1);t=t.firstElementChild||t,d.setRange(t,0,t,0);break}const n=d.getFileComponent(e);n?(t.stopPropagation(),!1===d.selectComponent(n.target,n.pluginName)&&d.blur()):r.isComponent(e)&&(t.stopPropagation(),r.removeItem(e));break}}if(!p&&(d.isEdgePoint(g.endContainer,g.endOffset)||c===f&&f.childNodes[g.startOffset])){const e=c===f&&f.childNodes[g.startOffset]||c;if(e&&r.isNonEditable(e.nextSibling)){t.preventDefault(),t.stopPropagation(),r.removeItem(e.nextSibling);break}if(r.isComponent(e)){t.preventDefault(),t.stopPropagation(),r.removeItem(e);break}}if(!p&&d._isEdgeFormat(g.endContainer,g.endOffset,"end")&&r.isFormatElement(f.nextElementSibling)&&(d._formatAttrsTemp=f.attributes),f=r.getFormatElement(g.startContainer,null),_=r.getRangeFormatElement(f,null),r.isListCell(f)&&r.isList(_)&&(c===f||3===c.nodeType&&(!c.nextSibling||r.isList(c.nextSibling))&&(r.getFormatElement(g.startContainer,null)!==r.getFormatElement(g.endContainer,null)?_.contains(g.endContainer):g.endOffset===c.textContent.length&&g.collapsed))){g.startContainer!==g.endContainer&&d.removeNode();let e=r.getArrayItem(f.children,r.isList,!1);if(e=e||f.nextElementSibling||_.parentNode.nextElementSibling,e&&(r.isList(e)||r.getArrayItem(e.children,r.isList,!1))){let n,i;if(t.preventDefault(),r.isList(e)){const t=e.firstElementChild;for(i=t.childNodes,n=i[0];i[0];)f.insertBefore(i[0],e);r.removeItem(t)}else{for(n=e.firstChild,i=e.childNodes;i[0];)f.appendChild(i[0]);r.removeItem(e)}d.setRange(n,0,n,0),d.history.push(!0)}break}break;case 9:if(m||l.tabDisable)break;if(t.preventDefault(),s||o||r.isWysiwygDiv(c))break;const b=!g.collapsed||d.isEdgePoint(g.startContainer,g.startOffset),v=d.getSelectedElements(null);c=d.getSelectionNode();const y=[];let C=[],w=r.isListCell(v[0]),x=r.isListCell(v[v.length-1]),E={sc:g.startContainer,so:g.startOffset,ec:g.endContainer,eo:g.endOffset};for(let e,t=0,n=v.length;t
"+f.nodeName+">",!d.checkCharCount(e,"byte-html"))return t.preventDefault(),!1}if(!i){const e=d._isEdgeFormat(g.endContainer,g.endOffset,"end"),n=d._isEdgeFormat(g.startContainer,g.startOffset,"start");if(e&&(/^H[1-6]$/i.test(f.nodeName)||/^HR$/i.test(f.nodeName))){t.preventDefault();let n=null;const i=d.appendFormatTag(f,l.defaultTag);if(e&&e.length>0){n=e.pop();const t=n;for(;e.length>0;)n=n.appendChild(e.pop());i.appendChild(t)}n=n?n.appendChild(i.firstChild):i.firstChild,d.setRange(n,0,n,0);break}if(n||e){t.preventDefault();const i=r.createElement("BR"),s=r.createElement(f.nodeName);s.appendChild(i),r.copyTagAttributes(s,f,["id"].concat(l.lineAttrReset)),f.parentNode.insertBefore(s,n?f:f.nextElementSibling),e&&d.setRange(i,1,i,1);break}if(d._formatAttrsTemp=f.attributes,l.lineAttrReset&&f&&!r.isListCell(f)){let e;if(t.preventDefault(),t.stopPropagation(),g.collapsed)e=r.onlyZeroWidthSpace(f)?d.appendFormatTag(f,f.cloneNode(!1)):r.splitElement(g.endContainer,g.endOffset,0);else{const t=r.getFormatElement(g.startContainer,null)!==r.getFormatElement(g.endContainer,null),n=d.removeNode();if(t)if(e=r.getFormatElement(n.container,null),n.prevContainer)e!==f&&e.nextElementSibling===f&&(e=f);else{const t=f.cloneNode(!1);t.innerHTML="
",e.parentNode.insertBefore(t,e)}else e=r.splitElement(n.container,n.offset,0)}const n=l.lineAttrReset,i=e.attributes;let s=0;for(;i[s];)n&&n.indexOf(i[s].name.toLowerCase())>-1?s++:e.removeAttribute(i[s].name);d.setRange(e.firstChild,0,e.firstChild,0);break}if(S){t.preventDefault();const e=c===S,n=d.getSelection(),i=c.childNodes,l=n.focusOffset,s=c.previousElementSibling,o=c.nextSibling;if(!r.isClosureFreeFormatElement(S)&&i&&(e&&g.collapsed&&i.length-1<=l+1&&r.isBreak(i[l])&&(!i[l+1]||(!i[l+2]||r.onlyZeroWidthSpace(i[l+2].textContent))&&3===i[l+1].nodeType&&r.onlyZeroWidthSpace(i[l+1].textContent))&&l>0&&r.isBreak(i[l-1])||!e&&r.onlyZeroWidthSpace(c.textContent)&&r.isBreak(s)&&(r.isBreak(s.previousSibling)||!r.onlyZeroWidthSpace(s.previousSibling.textContent))&&(!o||!r.isBreak(o)&&r.onlyZeroWidthSpace(o.textContent)))){e?r.removeItem(i[l-1]):r.removeItem(c);const t=d.appendFormatTag(S,r.isFormatElement(S.nextElementSibling)&&!r.isRangeFormatElement(S.nextElementSibling)?S.nextElementSibling:null);r.copyFormatAttributes(t,S),d.setRange(t,1,t,1);break}if(e){h.insertHTML(g.collapsed&&r.isBreak(g.startContainer.childNodes[g.startOffset-1])?"
":"
",!0,!1);let e=n.focusNode;const t=n.focusOffset;S===e&&(e=e.childNodes[t-l>1?t-1:t]),d.setRange(e,1,e,1)}else{const e=n.focusNode.nextSibling,t=r.createElement("BR");d.insertNode(t,null,!1);const i=t.previousSibling,l=t.nextSibling;r.isBreak(e)||r.isBreak(i)||l&&!r.onlyZeroWidthSpace(l)?d.setRange(l,0,l,0):(t.parentNode.insertBefore(t.cloneNode(!1),t),d.setRange(t,1,t,1))}u._onShortcutKey=!0;break}}if(p)break;if(_&&f&&!r.isCell(_)&&!/^FIGCAPTION$/i.test(_.nodeName)){const e=d.getRange();if(d.isEdgePoint(e.endContainer,e.endOffset)&&r.isList(c.nextSibling)){t.preventDefault();const e=r.createElement("LI"),n=r.createElement("BR");e.appendChild(n),f.parentNode.insertBefore(e,f.nextElementSibling),e.appendChild(c.nextSibling),d.setRange(n,1,n,1);break}if((3!==e.commonAncestorContainer.nodeType||!e.commonAncestorContainer.nextElementSibling)&&r.onlyZeroWidthSpace(f.innerText.trim())){t.preventDefault();let e=null;if(r.isListCell(_.parentNode)){if(_=f.parentNode.parentNode.parentNode,e=r.splitElement(f,null,r.getElementDepth(f)-2),!e){const t=r.createElement("LI");t.innerHTML="
",_.insertBefore(t,e),e=t}}else{const t=r.isCell(_.parentNode)?"DIV":r.isList(_.parentNode)?"LI":r.isFormatElement(_.nextElementSibling)&&!r.isRangeFormatElement(_.nextElementSibling)?_.nextElementSibling.nodeName:r.isFormatElement(_.previousElementSibling)&&!r.isRangeFormatElement(_.previousElementSibling)?_.previousElementSibling.nodeName:l.defaultTag;e=r.createElement(t);const n=d.detachRangeFormatElement(_,[f],null,!0,!0);n.cc.insertBefore(e,n.ec)}e.innerHTML="
",r.removeItemAllParents(f,null,null),d.setRange(e,1,e,1);break}}if(_&&r.getParentElement(_,"FIGCAPTION")&&r.getParentElement(_,r.isList)&&(t.preventDefault(),f=d.appendFormatTag(f,null),d.setRange(f,0,f,0)),m){t.preventDefault(),t.stopPropagation();const n=e[m],i=n._container,s=i.previousElementSibling||i.nextElementSibling;let o=null;r.isListCell(i.parentNode)?o=r.createElement("BR"):(o=r.createElement(r.isFormatElement(s)&&!r.isRangeFormatElement(s)?s.nodeName:l.defaultTag),o.innerHTML="
"),i.parentNode.insertBefore(o,i),d.callPlugin(m,(function(){!1===d.selectComponent(n._element,m)&&d.blur()}),null)}break;case 27:if(m)return t.preventDefault(),t.stopPropagation(),d.controllersOff(),!1}if(i&&16===n){t.preventDefault(),t.stopPropagation();const e=d.plugins.table;if(e&&!e._shift&&!e._ref){const t=r.getParentElement(f,r.isCell);if(t)return void e.onTableCellMultiSelect.call(d,t,!0)}}else if(i&&(r.isOSX_IOS?o:s)&&32===n){t.preventDefault(),t.stopPropagation();const e=d.insertNode(r.createTextNode("Â "));if(e&&e.container)return void d.setRange(e.container,e.endOffset,e.container,e.endOffset)}if(r.isIE&&!s&&!o&&!p&&!u._nonTextKeyCode.test(n)&&r.isBreak(g.commonAncestorContainer)){const e=r.createTextNode(r.zeroWidthSpace);d.insertNode(e,null,!1),d.setRange(e,1,e,1)}},onKeyUp_wysiwyg:function(e){if(u._onShortcutKey)return;d._editorRange();const t=e.keyCode,n=e.ctrlKey||e.metaKey||91===t||92===t||224===t,i=e.altKey;if(d.isReadOnly)return void(!n&&u._directionKeyCode.test(t)&&u._applyTagEffects());const s=d.getRange();let o=d.getSelectionNode();if(d._isBalloon&&(d._isBalloonAlways&&27!==t||!s.collapsed)){if(!d._isBalloonAlways)return void u._showToolbarBalloon();27!==t&&u._showToolbarBalloonDelay()}if(8===t&&r.isWysiwygDiv(o)&&""===o.textContent&&0===o.children.length){e.preventDefault(),e.stopPropagation(),o.innerHTML="";const t=r.createElement(r.isFormatElement(d._variable.currentNodes[0])?d._variable.currentNodes[0]:l.defaultTag);return t.innerHTML="
",o.appendChild(t),d.setRange(t,0,t,0),u._applyTagEffects(),void d.history.push(!1)}const a=r.getFormatElement(o,null),c=r.getRangeFormatElement(o,null),g=d._formatAttrsTemp;if(g){for(let e=0,n=g.length;e=n+s?(d._sticky||u._onStickyToolbar(a),t.toolbar.style.top=a+n+s+l.stickyToolbar-i-d._variable.minResizingSize+"px"):i>=s&&u._onStickyToolbar(a)},_getEditorOffsets:function(t){let n=t||e.element.topArea,i=0,l=0,s=0;for(;n;)i+=n.offsetTop,l+=n.offsetLeft,s+=n.scrollTop,n=n.offsetParent;return{top:i,left:l,scroll:s}},_getPageBottomSpace:function(){return o.documentElement.scrollHeight-(u._getEditorOffsets(null).top+e.element.topArea.offsetHeight)},_onStickyToolbar:function(t){const n=e.element;d._isInline||l.toolbarContainer||(n._stickyDummy.style.height=n.toolbar.offsetHeight+"px",n._stickyDummy.style.display="block"),n.toolbar.style.top=l.stickyToolbar+t+"px",n.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:n.toolbar.offsetWidth+"px",r.addClass(n.toolbar,"se-toolbar-sticky"),d._sticky=!0},_offStickyToolbar:function(){const t=e.element;t._stickyDummy.style.display="none",t.toolbar.style.top=d._isInline?d._inlineToolbarAttr.top:"",t.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:"",t.editorArea.style.marginTop="",r.removeClass(t.toolbar,"se-toolbar-sticky"),d._sticky=!1},_codeViewAutoHeight:function(){d._variable.isFullScreen||(e.element.code.style.height=e.element.code.scrollHeight+"px")},_hardDelete:function(){const e=d.getRange(),t=e.startContainer,n=e.endContainer,i=r.getRangeFormatElement(t),l=r.getRangeFormatElement(n),s=r.isCell(i),o=r.isCell(l),a=e.commonAncestorContainer;if((s&&!i.previousElementSibling&&!i.parentElement.previousElementSibling||o&&!l.nextElementSibling&&!l.parentElement.nextElementSibling)&&i!==l)if(s){if(o)return r.removeItem(r.getParentElement(i,(function(e){return a===e.parentNode}))),d.nativeFocus(),!0;r.removeItem(r.getParentElement(i,(function(e){return a===e.parentNode})))}else r.removeItem(r.getParentElement(l,(function(e){return a===e.parentNode})));const c=1===t.nodeType?r.getParentElement(t,".se-component"):null,u=1===n.nodeType?r.getParentElement(n,".se-component"):null;return c&&r.removeItem(c),u&&r.removeItem(u),!1},onPaste_wysiwyg:function(e){const t=r.isIE?a.clipboardData:e.clipboardData;return!t||u._dataTransferAction("paste",e,t)},_setClipboardComponent:function(e,t,n){e.preventDefault(),e.stopPropagation(),n.setData("text/html",t.component.outerHTML)},onCopy_wysiwyg:function(e){const t=r.isIE?a.clipboardData:e.clipboardData;if("function"==typeof h.onCopy&&!1===h.onCopy(e,t,d))return e.preventDefault(),e.stopPropagation(),!1;const n=d.currentFileComponentInfo;n&&!r.isIE&&(u._setClipboardComponent(e,n,t),r.addClass(n.component,"se-component-copy"),a.setTimeout((function(){r.removeClass(n.component,"se-component-copy")}),150))},onSave_wysiwyg:function(e){"function"!=typeof h.onSave||h.onSave(e,d)},onCut_wysiwyg:function(e){const t=r.isIE?a.clipboardData:e.clipboardData;if("function"==typeof h.onCut&&!1===h.onCut(e,t,d))return e.preventDefault(),e.stopPropagation(),!1;const n=d.currentFileComponentInfo;n&&!r.isIE&&(u._setClipboardComponent(e,n,t),r.removeItem(n.component),d.controllersOff()),a.setTimeout((function(){d.history.push(!1)}))},onDrop_wysiwyg:function(e){if(d.isReadOnly||r.isIE)return e.preventDefault(),e.stopPropagation(),!1;const t=e.dataTransfer;return!t||(d.removeNode(),u._setDropLocationSelection(e),u._dataTransferAction("drop",e,t))},_setDropLocationSelection:function(e){if(e.rangeParent)d.setRange(e.rangeParent,e.rangeOffset,e.rangeParent,e.rangeOffset);else if(d._wd.caretRangeFromPoint){const t=d._wd.caretRangeFromPoint(e.clientX,e.clientY);d.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)}else{const e=d.getRange();d.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}},_dataTransferAction:function(t,n,i){let l,s;if(r.isIE){l=i.getData("Text");const o=d.getRange(),c=r.createElement("DIV"),h={sc:o.startContainer,so:o.startOffset,ec:o.endContainer,eo:o.endOffset};return c.setAttribute("contenteditable",!0),c.style.cssText="position:absolute; top:0; left:0; width:1px; height:1px; overflow:hidden;",e.element.relative.appendChild(c),c.focus(),a.setTimeout((function(){s=c.innerHTML,r.removeItem(c),d.setRange(h.sc,h.so,h.ec,h.eo),u._setClipboardData(t,n,l,s,i)})),!0}if(l=i.getData("text/plain"),s=i.getData("text/html"),!1===u._setClipboardData(t,n,l,s,i))return n.preventDefault(),n.stopPropagation(),!1},_setClipboardData:function(e,t,n,i,l){const s=/class=["']*Mso(Normal|List)/i.test(i)||/content=["']*Word.Document/i.test(i)||/content=["']*OneNote.File/i.test(i)||/content=["']*Excel.Sheet/i.test(i);!i?i=r._HTMLConvertor(n).replace(/\n/g,"
"):(i=i.replace(/^\r?\n?\r?\n?\x3C!--StartFragment--\>|\x3C!--EndFragment-->\r?\n?<\/body\>\r?\n?<\/html>$/g,""),s&&(i=i.replace(/\n/g," "),n=n.replace(/\n/g," ")),i=d.cleanHTML(i,d.pasteTagsWhitelistRegExp,d.pasteTagsBlacklistRegExp));const o=d._charCount(d._charTypeHTML?i:n);if("paste"===e&&"function"==typeof h.onPaste){const e=h.onPaste(t,i,o,d);if(!1===e)return!1;if("string"==typeof e){if(!e)return!1;i=e}}if("drop"===e&&"function"==typeof h.onDrop){const e=h.onDrop(t,i,o,d);if(!1===e)return!1;if("string"==typeof e){if(!e)return!1;i=e}}const a=l.files;return a.length>0&&!s?(/^image/.test(a[0].type)&&d.plugins.image&&h.insertImage(a),!1):!!o&&(i?(h.insertHTML(i,!0,!1),!1):void 0)},onMouseMove_wysiwyg:function(t){if(d.isDisabled||d.isReadOnly)return!1;const n=r.getParentElement(t.target,r.isComponent),i=d._lineBreaker.style;if(n&&!d.currentControllerName){const s=e.element;let o=0,a=s.wysiwyg;do{o+=a.scrollTop,a=a.parentElement}while(a&&!/^(BODY|HTML)$/i.test(a.nodeName));const c=s.wysiwyg.scrollTop,h=u._getEditorOffsets(null),g=r.getOffset(n,s.wysiwygFrame).top+c,p=t.pageY+o+(l.iframe&&!l.toolbarContainer?s.toolbar.offsetHeight:0),m=g+(l.iframe?o:h.top),f=r.isListCell(n.parentNode);let _="",b="";if((f?!n.previousSibling:!r.isFormatElement(n.previousElementSibling))&&p
"),d._charTypeHTML&&!d.checkCharCount(s.outerHTML,"byte-html"))return;t.parentNode.insertBefore(s,"t"===n?t:t.nextSibling),d._lineBreaker.style.display="none",d._variable._lineBreakComp=null;const o=i?s:s.firstChild;d.setRange(o,1,o,1),d.history.push(!1)},_resizeObserver:null,_toolbarObserver:null,_addEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;r.isResizeObserverSupported&&(this._resizeObserver=new a.ResizeObserver((function(e){d.__callResizeFunction(-1,e[0])}))),e.element.toolbar.addEventListener("mousedown",u._buttonsEventHandler,!1),e.element._menuTray.addEventListener("mousedown",u._buttonsEventHandler,!1),e.element.toolbar.addEventListener("click",u.onClick_toolbar,!1),t.addEventListener("mousedown",u.onMouseDown_wysiwyg,!1),t.addEventListener("click",u.onClick_wysiwyg,!1),t.addEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg,!1),t.addEventListener("keydown",u.onKeyDown_wysiwyg,!1),t.addEventListener("keyup",u.onKeyUp_wysiwyg,!1),t.addEventListener("paste",u.onPaste_wysiwyg,!1),t.addEventListener("copy",u.onCopy_wysiwyg,!1),t.addEventListener("cut",u.onCut_wysiwyg,!1),t.addEventListener("drop",u.onDrop_wysiwyg,!1),t.addEventListener("scroll",u.onScroll_wysiwyg,!1),t.addEventListener("focus",u.onFocus_wysiwyg,!1),t.addEventListener("blur",u.onBlur_wysiwyg,!1),u._lineBreakerBind={a:u._onLineBreak.bind(""),t:u._onLineBreak.bind("t"),b:u._onLineBreak.bind("b")},t.addEventListener("mousemove",u.onMouseMove_wysiwyg,!1),d._lineBreakerButton.addEventListener("mousedown",u._onMouseDown_lineBreak,!1),d._lineBreakerButton.addEventListener("click",u._lineBreakerBind.a,!1),e.element.lineBreaker_t.addEventListener("mousedown",u._lineBreakerBind.t,!1),e.element.lineBreaker_b.addEventListener("mousedown",u._lineBreakerBind.b,!1),d.plugins.table&&t.addEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),"auto"!==l.height||l.codeMirrorEditor||(e.element.code.addEventListener("keydown",u._codeViewAutoHeight,!1),e.element.code.addEventListener("keyup",u._codeViewAutoHeight,!1),e.element.code.addEventListener("paste",u._codeViewAutoHeight,!1)),e.element.resizingBar&&(/\d+/.test(l.height)&&l.resizeEnable?e.element.resizingBar.addEventListener("mousedown",u.onMouseDown_resizingBar,!1):r.addClass(e.element.resizingBar,"se-resizing-none")),u._setResponsiveToolbar(),r.isResizeObserverSupported&&(this._toolbarObserver=new a.ResizeObserver(d.resetResponsiveToolbar)),a.addEventListener("resize",u.onResize_window,!1),l.stickyToolbar>-1&&a.addEventListener("scroll",u.onScroll_window,!1)},_removeEvent:function(){const t=l.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.removeEventListener("mousedown",u._buttonsEventHandler),e.element._menuTray.removeEventListener("mousedown",u._buttonsEventHandler),e.element.toolbar.removeEventListener("click",u.onClick_toolbar),t.removeEventListener("mousedown",u.onMouseDown_wysiwyg),t.removeEventListener("click",u.onClick_wysiwyg),t.removeEventListener(r.isIE?"textinput":"input",u.onInput_wysiwyg),t.removeEventListener("keydown",u.onKeyDown_wysiwyg),t.removeEventListener("keyup",u.onKeyUp_wysiwyg),t.removeEventListener("paste",u.onPaste_wysiwyg),t.removeEventListener("copy",u.onCopy_wysiwyg),t.removeEventListener("cut",u.onCut_wysiwyg),t.removeEventListener("drop",u.onDrop_wysiwyg),t.removeEventListener("scroll",u.onScroll_wysiwyg),t.removeEventListener("mousemove",u.onMouseMove_wysiwyg),d._lineBreakerButton.removeEventListener("mousedown",u._onMouseDown_lineBreak),d._lineBreakerButton.removeEventListener("click",u._lineBreakerBind.a),e.element.lineBreaker_t.removeEventListener("mousedown",u._lineBreakerBind.t),e.element.lineBreaker_b.removeEventListener("mousedown",u._lineBreakerBind.b),u._lineBreakerBind=null,t.removeEventListener("touchstart",u.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),t.removeEventListener("focus",u.onFocus_wysiwyg),t.removeEventListener("blur",u.onBlur_wysiwyg),e.element.code.removeEventListener("keydown",u._codeViewAutoHeight),e.element.code.removeEventListener("keyup",u._codeViewAutoHeight),e.element.code.removeEventListener("paste",u._codeViewAutoHeight),e.element.resizingBar&&e.element.resizingBar.removeEventListener("mousedown",u.onMouseDown_resizingBar),u._resizeObserver&&(u._resizeObserver.unobserve(e.element.wysiwygFrame),u._resizeObserver=null),u._toolbarObserver&&(u._toolbarObserver.unobserve(e.element._toolbarShadow),u._toolbarObserver=null),a.removeEventListener("resize",u.onResize_window),a.removeEventListener("scroll",u.onScroll_window)},_setResponsiveToolbar:function(){if(0===s.length)return void(s=null);u._responsiveCurrentSize="default";const e=u._responsiveButtonSize=[],t=u._responsiveButtons={default:s[0]};for(let n,i,l=1,o=s.length;l';for(let n,i=0,l=e.length;i
",t},init:function(e,t){const n=this.plugins.colorPicker;let i=t||(n.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor);i=n.isHexColor(i)?i:n.rgb2hex(i)||i;const l=this.context.colorPicker._colorList;if(l)for(let e=0,t=l.length;e"+n+"
",e.items=t,e.menus=e.form.querySelectorAll("li")},initEvent:function(e,t){const n=t.querySelector(".se-select-list"),i=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,i)),n.addEventListener("click",this.plugins.selectMenu.onClick_list.bind(this,i))},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=1*n)},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,i=n.length,l=e.index=t>=i?0:t<0?i-1:t;for(let e=0;e'+e.icons.cancel+''+n.dialogBox.audioBox.title+''+s+"
";for(s=0,o=a.length;s
",n.innerHTML=r,n},active:function(e){const t=this.context.font.targetText,n=this.context.font.targetTooltip;if(e){if(e.style&&e.style.fontFamily.length>0){const i=e.style.fontFamily.replace(/["']/g,"");return this.util.changeTxt(t,i),this.util.changeTxt(n,this.lang.toolbar.font+" ("+i+")"),!0}}else{const e=this.hasFocus?this.wwComputedStyle.fontFamily:this.lang.toolbar.font;this.util.changeTxt(t,e),this.util.changeTxt(n,this.hasFocus?this.lang.toolbar.font+(e?" ("+e+")":""):e)}return!1},on:function(){const e=this.context.font,t=e._fontList,n=e.targetText.textContent;if(n!==e.currentFont){for(let e=0,i=t.length;e('+n.toolbar.default+")";for(let e,n=0,i=t.fontSizeUnit,o=l.length;n'+l+"
")}else{const e=n.childNodes;for(;e[0];)t.appendChild(e[0])}a.appendChild(t),r||(h=a),r&&f===p&&!s.isRangeFormatElement(_)||(d||(d=a),i&&r&&f===p||r&&s.isList(p)&&p===c||a.parentNode!==f&&f.insertBefore(a,_)),s.removeItem(n),i&&null===g&&(g=a.children.length-1),r&&(s.getRangeFormatElement(p,m)!==s.getRangeFormatElement(c,m)||s.isList(p)&&s.isList(c)&&s.getElementDepth(p)!==s.getElementDepth(c))&&(a=s.createElement(e)),b&&0===b.children.length&&s.removeItem(b)}else s.removeItem(n);g&&(d=d.children[g]),o&&(p=a.children.length-1,a.innerHTML+=c.innerHTML,h=a.children[p],s.removeItem(c))}else{if(n)for(let e=0,t=l.length;e"+t.call(this,"td",n)+" ",--i;l+="",e.innerHTML=l;if(this.insertComponent(e,!1,!0,!1)){const t=e.querySelector("td div");this.setRange(t,0,t,0),this.plugins.table.reset_table_picker.call(this)}},createCells:function(e,t,n){if(e=e.toLowerCase(),n){const t=this.util.createElement(e);return t.innerHTML=""+n.createCells.call(this,"td",i._logical_cellCnt,!1)+" ")}}if(n._ref){const e=i._tdElement,l=n._selectedCells;if(s)if(t)n.setCellInfo.call(this,"up"===t?l[0]:l[l.length-1],!0),n.editRow.call(this,t,e);else{let e=l[0].parentNode;const i=[l[0]];for(let t,n=1,s=l.length;no&&o>t&&(e[l].rowSpan=n+a,c-=i)}if(i){const e=r[s+1];if(e){const t=[];let n=r[s].cells,i=0;for(let e,l,s=0,o=n.length;s1)c.colSpan=this._w.Math.floor(e/2),l.colSpan=e-c.colSpan,o.insertBefore(c,l.nextElementSibling);else{let t=[],n=[];for(let o,r,c=0,d=i._rowCnt;c
"+a.innerHTML,r.removeItem(a)),n=l.cloneNode(!1),h=!0),c=n.innerHTML,n.innerHTML=(h||!s||!c||/
$/i.test(s)?s:s+"
")+c,0===u){t.insertBefore(n,i),a=i.nextSibling,a&&n.nodeName===a.nodeName&&r.isSameAttributes(n,a)&&(n.innerHTML+="
"+a.innerHTML,r.removeItem(a));const e=n.previousSibling;e&&n.nodeName===e.nodeName&&r.isSameAttributes(n,e)&&(e.innerHTML+="
"+n.innerHTML,r.removeItem(n))}d||r.removeItem(i),s&&(h=!1)}this.setRange(i,0,i,0)}else{for(let e,t,n=0,o=p.length;n
");const d=c.parentNode;return r&&(c=c.nextSibling),l?(this.mergeSameTags(l,null,!1),this.mergeNestedTags(l,function(e){return this.isList(e)}.bind(this)),l.childNodes.length>0?d.insertBefore(l,c):l=c,0===i.childNodes.length&&this.removeItem(i),l):c},mergeSameTags:function(e,t,n){const i=this,l=t?t.length:0;let s=null;return l&&(s=this._w.Array.apply(null,new this._w.Array(l)).map(this._w.Number.prototype.valueOf,0)),function e(o,a,r){const c=o.childNodes;for(let d,u,h=0,g=c.length;h'}return i+("auto"===e.height?"":"")}};var L=k,B={init:function(e,t){"object"!=typeof t&&(t={});const n=document;this._initOptions(e,t);const i=n.createElement("DIV");i.className="sun-editor"+(t.rtl?" se-rtl":""),e.id&&(i.id="suneditor_"+e.id);const l=n.createElement("DIV");l.className="se-container";const s=this._createToolBar(n,t.buttonList,t.plugins,t),o=s.element.cloneNode(!1);o.className+=" se-toolbar-shadow",s.element.style.visibility="hidden",s.pluginCallButtons.math&&this._checkKatexMath(t.katex);const a=n.createElement("DIV");a.className="se-arrow";const r=n.createElement("DIV");r.className="se-toolbar-sticky-dummy";const c=n.createElement("DIV");c.className="se-wrapper";const d=this._initElements(t,i,s.element,a),u=d.bottomBar,h=d.wysiwygFrame,g=d.placeholder;let p=d.codeView;const m=u.resizingBar,f=u.navigation,_=u.charWrapper,b=u.charCounter,v=n.createElement("DIV");v.className="se-loading-box sun-editor-common",v.innerHTML='';const y=n.createElement("DIV");y.className="se-line-breaker",y.innerHTML='";const C=n.createElement("DIV");C.className+="se-line-breaker-component";const w=C.cloneNode(!0);C.innerHTML=w.innerHTML=t.icons.line_break;const x=n.createElement("DIV");x.className="se-resizing-back";const E=t.toolbarContainer;E&&(E.appendChild(s.element),E.appendChild(o));const S=t.resizingBarContainer;return m&&S&&S.appendChild(m),c.appendChild(p),g&&c.appendChild(g),E||(l.appendChild(s.element),l.appendChild(o)),l.appendChild(r),l.appendChild(c),l.appendChild(x),l.appendChild(v),l.appendChild(y),l.appendChild(C),l.appendChild(w),m&&!S&&l.appendChild(m),i.appendChild(l),p=this._checkCodeMirror(t,p),{constructed:{_top:i,_relative:l,_toolBar:s.element,_toolbarShadow:o,_menuTray:s._menuTray,_editorArea:c,_wysiwygArea:h,_codeArea:p,_placeholder:g,_resizingBar:m,_navigation:f,_charWrapper:_,_charCounter:b,_loading:v,_lineBreaker:y,_lineBreaker_t:C,_lineBreaker_b:w,_resizeBack:x,_stickyDummy:r,_arrow:a},options:t,plugins:s.plugins,pluginCallButtons:s.pluginCallButtons,_responsiveButtons:s.responsiveButtons}},_checkCodeMirror:function(e,t){if(e.codeMirror){const n=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!0},e.codeMirror.options||{}].reduce((function(e,t){for(let n in t)L.hasOwn(t,n)&&(e[n]=t[n]);return e}),{});"auto"===e.height&&(n.viewportMargin=1/0,n.height="auto");const i=e.codeMirror.src.fromTextArea(t,n);i.display.wrapper.style.cssText=t.style.cssText,e.codeMirrorEditor=i,(t=i.display.wrapper).className+=" se-wrapper-code-mirror"}return t},_checkKatexMath:function(e){if(!e)throw Error('[SUNEDITOR.create.fail] To use the math button you need to add a "katex" object to the options.');const t=[{throwOnError:!1},e.options||{}].reduce((function(e,t){for(let n in t)L.hasOwn(t,n)&&(e[n]=t[n]);return e}),{});e.options=t},_setOptions:function(e,t,n){this._initOptions(t.element.originElement,e);const i=t.element,l=i.relative,s=i.editorArea,o=e.toolbarContainer&&e.toolbarContainer!==n.toolbarContainer,a=e.lang!==n.lang||e.buttonList!==n.buttonList||e.mode!==n.mode||o,r=this._createToolBar(document,a?e.buttonList:n.buttonList,e.plugins,e);r.pluginCallButtons.math&&this._checkKatexMath(e.katex);const c=document.createElement("DIV");c.className="se-arrow",a&&(r.element.style.visibility="hidden",o?(e.toolbarContainer.appendChild(r.element),i.toolbar.parentElement.removeChild(i.toolbar)):i.toolbar.parentElement.replaceChild(r.element,i.toolbar),i.toolbar=r.element,i._menuTray=r._menuTray,i._arrow=c);const d=this._initElements(e,i.topArea,a?r.element:i.toolbar,c),u=d.bottomBar,h=d.wysiwygFrame,g=d.placeholder;let p=d.codeView;return i.resizingBar&&L.removeItem(i.resizingBar),u.resizingBar&&(e.resizingBarContainer&&e.resizingBarContainer!==n.resizingBarContainer?e.resizingBarContainer.appendChild(u.resizingBar):l.appendChild(u.resizingBar)),s.innerHTML="",s.appendChild(p),g&&s.appendChild(g),p=this._checkCodeMirror(e,p),i.resizingBar=u.resizingBar,i.navigation=u.navigation,i.charWrapper=u.charWrapper,i.charCounter=u.charCounter,i.wysiwygFrame=h,i.code=p,i.placeholder=g,e.rtl?L.addClass(i.topArea,"se-rtl"):L.removeClass(i.topArea,"se-rtl"),{callButtons:r.pluginCallButtons,plugins:r.plugins,toolbar:r}},_initElements:function(e,t,n,i){t.style.cssText=e._editorStyles.top,/inline/i.test(e.mode)?(n.className+=" se-toolbar-inline",n.style.width=e.toolbarWidth):/balloon/i.test(e.mode)&&(n.className+=" se-toolbar-balloon",n.style.width=e.toolbarWidth,n.appendChild(i));const l=document.createElement(e.iframe?"IFRAME":"DIV");if(l.className="se-wrapper-inner se-wrapper-wysiwyg",e.iframe)l.allowFullscreen=!0,l.frameBorder=0,l.style.cssText=e._editorStyles.frame,l.className+=e.className;else{l.setAttribute("contenteditable",!0),l.setAttribute("scrolling","auto");for(let t in e.iframeAttributes)l.setAttribute(t,e.iframeAttributes[t]);l.className+=" "+e._editableClass,l.style.cssText=e._editorStyles.frame+e._editorStyles.editor,l.className+=e.className}const s=document.createElement("TEXTAREA");s.className="se-wrapper-inner se-wrapper-code"+e.className,s.style.cssText=e._editorStyles.frame,s.style.display="none","auto"===e.height&&(s.style.overflow="hidden");let o=null,a=null,r=null,c=null;if(e.resizingBar&&(o=document.createElement("DIV"),o.className="se-resizing-bar sun-editor-common",a=document.createElement("DIV"),a.className="se-navigation sun-editor-common",o.appendChild(a),e.charCounter)){if(r=document.createElement("DIV"),r.className="se-char-counter-wrapper",e.charCounterLabel){const t=document.createElement("SPAN");t.className="se-char-label",t.textContent=e.charCounterLabel,r.appendChild(t)}if(c=document.createElement("SPAN"),c.className="se-char-counter",c.textContent="0",r.appendChild(c),e.maxCharCount>0){const t=document.createElement("SPAN");t.textContent=" / "+e.maxCharCount,r.appendChild(t)}o.appendChild(r)}let d=null;return e.placeholder&&(d=document.createElement("SPAN"),d.className="se-placeholder",d.innerText=e.placeholder),{bottomBar:{resizingBar:o,navigation:a,charWrapper:r,charCounter:c},wysiwygFrame:l,codeView:s,placeholder:d}},_initOptions:function(e,t){const n={};if(t.plugins){const e=t.plugins,i=e.length?e:Object.keys(e).map((function(t){return e[t]}));for(let e,t=0,l=i.length;t
",i.insertBefore(s,n&&n!==i?n.nextElementSibling:i.firstElementChild),this.setRange(s.firstElementChild,0,s.firstElementChild,1),t=this._variable._range}return t},getSelection:function(){const t=this._shadowRoot&&this._shadowRoot.getSelection?this._shadowRoot.getSelection():this._ww.getSelection();return this._variable._range||e.element.wysiwyg.contains(t.focusNode)||(t.removeAllRanges(),t.addRange(this._createDefaultRange())),t},getSelectionNode:function(){if(e.element.wysiwyg.contains(this._variable._selectionNode)||this._editorRange(),!this._variable._selectionNode){const t=r.getChildElement(e.element.wysiwyg.firstChild,(function(e){return 0===e.childNodes.length||3===e.nodeType}),!1);if(t)return this._variable._selectionNode=t,t;this._editorRange()}return this._variable._selectionNode},_editorRange:function(){const e=this.getSelection();if(!e)return null;let t=null;t=e.rangeCount>0?e.getRangeAt(0):this._createDefaultRange(),r.isFormatElement(t.endContainer)&&0===t.endOffset&&(t=this.setRange(t.startContainer,t.startOffset,t.startContainer,t.startContainer.length)),this._rangeInfo(t,e)},_rangeInfo:function(e,t){let n=null;this._variable._range=e,n=e.collapsed?r.isWysiwygDiv(e.commonAncestorContainer)&&e.commonAncestorContainer.children[e.startOffset]||e.commonAncestorContainer:t.extentNode||t.anchorNode,this._variable._selectionNode=n},_createDefaultRange:function(){const t=e.element.wysiwyg,n=this._wd.createRange();let i=t.firstElementChild,s=null;return i?(s=i.firstChild,s||(s=r.createElement("BR"),i.appendChild(s))):(i=r.createElement(l.defaultTag),s=r.createElement("BR"),i.appendChild(s),t.appendChild(i)),n.setStart(s,0),n.setEnd(s,0),n},_selectionVoid:function(e){const t=e.commonAncestorContainer;return r.isWysiwygDiv(e.startContainer)&&r.isWysiwygDiv(e.endContainer)||/FIGURE/i.test(t.nodeName)||this._fileManager.regExp.test(t.nodeName)||r.isMediaComponent(t)},_resetRangeToTextNode:function(){const t=this.getRange();if(this._selectionVoid(t))return!1;let n,i,s,o=t.startContainer,a=t.startOffset,c=t.endContainer,d=t.endOffset;if(r.isFormatElement(o))for(o.childNodes[a]?(o=o.childNodes[a]||o,a=0):(o=o.lastChild||o,a=o.textContent.length);o&&1===o.nodeType&&o.firstChild;)o=o.firstChild||o,a=0;if(r.isFormatElement(c)){for(c=c.childNodes[d]||c.lastChild||c;c&&1===c.nodeType&&c.lastChild;)c=c.lastChild;d=c.textContent.length}if(n=r.isWysiwygDiv(o)?e.element.wysiwyg.firstChild:o,i=a,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType;)n=n.childNodes[i]||n.nextElementSibling||n.nextSibling,i=0;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.getParentElement(n,r.isCell)?"DIV":l.defaultTag),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,e&&o===c&&(c=n,d=1)}}if(o=n,a=i,n=r.isWysiwygDiv(c)?e.element.wysiwyg.lastChild:c,i=d,r.isBreak(n)||1===n.nodeType&&n.childNodes.length>0){const e=r.isBreak(n);if(!e){for(;n&&!r.isBreak(n)&&1===n.nodeType&&(s=n.childNodes,0!==s.length);)n=s[i>0?i-1:i]||!/FIGURE/i.test(s[0].nodeName)?s[0]:n.previousElementSibling||n.previousSibling||o,i=i>0?n.textContent.length:i;let e=r.getFormatElement(n,null);e===r.getRangeFormatElement(e,null)&&(e=r.createElement(r.isCell(e)?"DIV":l.defaultTag),n.parentNode.insertBefore(e,n),e.appendChild(n))}if(r.isBreak(n)){const t=r.createTextNode(r.zeroWidthSpace);n.parentNode.insertBefore(t,n),n=t,i=1,e&&!n.previousSibling&&r.removeItem(c)}}return c=n,d=i,this.setRange(o,a,c,d),!0},getSelectedElements:function(t){if(!this._resetRangeToTextNode())return[];let n=this.getRange();if(r.isWysiwygDiv(n.startContainer)){const t=e.element.wysiwyg.children;if(0===t.length)return[];this.setRange(t[0],0,t[t.length-1],t[t.length-1].textContent.trim().length),n=this.getRange()}const i=n.startContainer,l=n.endContainer,s=n.commonAncestorContainer,o=r.getListChildren(s,(function(e){return t?t(e):r.isFormatElement(e)}));if(r.isWysiwygDiv(s)||r.isRangeFormatElement(s)||o.unshift(r.getFormatElement(s,null)),i===l||1===o.length)return o;let a=r.getFormatElement(i,null),c=r.getFormatElement(l,null),d=null,u=null;const h=function(e){return!r.isTable(e)||/^TABLE$/i.test(e.nodeName)};let g=r.getRangeFormatElement(a,h),p=r.getRangeFormatElement(c,h);r.isTable(g)&&r.isListCell(g.parentNode)&&(g=g.parentNode),r.isTable(p)&&r.isListCell(p.parentNode)&&(p=p.parentNode);const m=g===p;for(let e,t=0,n=o.length;t
",(t&&"string"!=typeof t||!t&&r.isFormatElement(n))&&r.copyTagAttributes(i,t||n,["id"])}return r.isCell(e)?e.insertBefore(i,e.nextElementSibling):e.parentNode.insertBefore(i,e.nextElementSibling),i},insertComponent:function(e,t,n,i){if(this.isReadOnly||n&&!this.checkCharCount(e,null))return null;const l=this.removeNode();this.getRange_addLine(this.getRange(),l.container);let s=null,o=this.getSelectionNode(),a=r.getFormatElement(o,null);if(r.isListCell(a))this.insertNode(e,o===a?null:l.container.nextSibling,!1),e.nextSibling||e.parentNode.appendChild(r.createElement("BR"));else{if(this.getRange().collapsed&&(3===l.container.nodeType||r.isBreak(l.container))){const e=r.getParentElement(l.container,function(e){return this.isRangeFormatElement(e)}.bind(r));s=r.splitElement(l.container,l.offset,e?r.getElementDepth(e)+1:0),s&&(a=s.previousSibling)}this.insertNode(e,r.isRangeFormatElement(a)?null:a,!1),a&&r.onlyZeroWidthSpace(a)&&r.removeItem(a)}if(!i){this.setRange(e,0,e,0);const t=this.getFileComponent(e);t?this.selectComponent(t.target,t.pluginName):s&&(s=r.getEdgeChildNodes(s,null).sc||s,this.setRange(s,0,s,0))}return t||this.history.push(1),s||e},getFileComponent:function(e){if(!this._fileManager.queryString||!e)return null;let t,n;return(/^FIGURE$/i.test(e.nodeName)||/se-component/.test(e.className))&&(t=e.querySelector(this._fileManager.queryString)),!t&&e.nodeName&&this._fileManager.regExp.test(e.nodeName)&&(t=e),t&&(n=this._fileManager.pluginMap[t.nodeName.toLowerCase()],n)?{target:t,component:r.getParentElement(t,r.isComponent),pluginName:n}:null},selectComponent:function(e,t){if(r.isUneditableComponent(r.getParentElement(e,r.isComponent))||r.isUneditableComponent(e))return!1;this.hasFocus||this.focus();const n=this.plugins[t];n&&a.setTimeout(function(){"function"==typeof n.select&&this.callPlugin(t,n.select.bind(this,e),null),this._setComponentLineBreaker(e)}.bind(this))},_setComponentLineBreaker:function(t){this._lineBreaker.style.display="none";const n=r.getParentElement(t,r.isComponent),i=e.element.lineBreaker_t.style,l=e.element.lineBreaker_b.style,s="block"===this.context.resizing.resizeContainer.style.display?this.context.resizing.resizeContainer:t,o=r.isListCell(n.parentNode);let a,c,d;(o?n.previousSibling:r.isFormatElement(n.previousElementSibling))?i.display="none":(this._variable._lineBreakComp=n,c=e.element.wysiwyg.scrollTop,a=r.getOffset(t,e.element.wysiwygFrame).top+c,d=s.offsetWidth/2/2,i.top=a-c-12+"px",i.left=r.getOffset(s).left+d+"px",i.display="block"),(o?n.nextSibling:r.isFormatElement(n.nextElementSibling))?l.display="none":(a||(this._variable._lineBreakComp=n,c=e.element.wysiwyg.scrollTop,a=r.getOffset(t,e.element.wysiwygFrame).top+c,d=s.offsetWidth/2/2),l.top=a+s.offsetHeight-c-12+"px",l.left=r.getOffset(s).left+s.offsetWidth-d-24+"px",l.display="block")},_checkDuplicateNode:function(e,t){!function e(n){d._dupleCheck(n,t);const i=n.childNodes;for(let t=0,n=i.length;t
")}else{const e=this.removeNode(),i=e.container,o=e.prevContainer;if(i&&0===i.childNodes.length&&p&&(r.isFormatElement(i)?i.innerHTML="
":r.isRangeFormatElement(i)&&(i.innerHTML="<"+l.defaultTag+">
"+l.defaultTag+">")),r.isListCell(i)&&3===t.nodeType)s=i,n=null;else if(!p&&o)if(s=3===o.nodeType?o.parentNode:o,s.contains(i)){let e=!0;for(n=i;n.parentNode&&n.parentNode!==s;)n=n.parentNode,e=!1;e&&i===o&&(n=n.nextSibling)}else n=null;else r.isWysiwygDiv(i)&&!r.isFormatElement(t)?(s=i.appendChild(r.createElement(l.defaultTag)),n=null):s=(n=p?y:i===o?i.nextSibling:i)&&n.parentNode?n.parentNode:m;for(;n&&!r.isFormatElement(n)&&n.parentNode!==m;)n=n.parentNode}}try{if(!u){if((r.isWysiwygDiv(n)||s===e.element.wysiwyg.parentNode)&&(s=e.element.wysiwyg,n=null),r.isFormatElement(t)||r.isRangeFormatElement(t)||!r.isListCell(s)&&r.isComponent(t)){const e=s;if(r.isList(n))s=n,n=null;else if(r.isListCell(n))s=n.previousElementSibling||n;else if(!o&&!n){const e=this.removeNode(),t=3===e.container.nodeType?r.isListCell(r.getFormatElement(e.container,null))?e.container:r.getFormatElement(e.container,null)||e.container.parentNode:e.container,i=r.isWysiwygDiv(t)||r.isRangeFormatElement(t);s=i?t:t.parentNode,n=i?null:t.nextSibling}0===e.childNodes.length&&s!==e&&r.removeItem(e)}if(!p||g||r.isRangeFormatElement(s)||r.isListCell(s)||r.isWysiwygDiv(s)||(n=s.nextElementSibling,s=s.parentNode),r.isWysiwygDiv(s)&&(3===t.nodeType||r.isBreak(t))){const e=r.createElement(l.defaultTag);e.appendChild(t),t=e}}if(u?h.parentNode?(s=h,n=a):(s=e.element.wysiwyg,n=null):n=s===n?s.lastChild:n,r.isListCell(t)&&!r.isList(s)){if(r.isListCell(s))n=s.nextElementSibling,s=s.parentNode;else{const e=r.createElement("ol");s.insertBefore(e,n),s=e,n=null}u=!0}if(this._checkDuplicateNode(t,s),s.insertBefore(t,n),u)if(r.onlyZeroWidthSpace(d.textContent.trim()))r.removeItem(d),t=t.lastChild;else{const e=r.getArrayItem(d.children,r.isList);e&&(t!==e?(t.appendChild(e),t=e.previousSibling):(s.appendChild(t),t=s),r.onlyZeroWidthSpace(d.textContent.trim())&&r.removeItem(d))}}catch(e){s.appendChild(t),console.warn("[SUNEDITOR.insertNode.warn] "+e)}finally{const e=s.querySelectorAll("[data-se-duple]");if(e.length>0)for(let n,i,l,s,o=0,a=e.length;o0&&(t.textContent=i+t.textContent,r.removeItem(e)),n&&n.length>0&&(t.textContent+=l,r.removeItem(n));const s={container:t,startOffset:i.length,endOffset:t.textContent.length-l.length};return this.setRange(t,s.startOffset,t,s.endOffset),s}if(!r.isBreak(t)&&!r.isListCell(t)&&r.isFormatElement(s)){let n=null;t.previousSibling&&!r.isBreak(t.previousSibling)||(n=r.createTextNode(r.zeroWidthSpace),t.parentNode.insertBefore(n,t)),t.nextSibling&&!r.isBreak(t.nextSibling)||(n=r.createTextNode(r.zeroWidthSpace),t.parentNode.insertBefore(n,t.nextSibling)),r._isIgnoreNodeChange(t)&&(t=t.nextSibling,e=0)}this.setRange(t,e,t,e)}return this.history.push(!0),t}},_setIntoFreeFormat:function(e){const t=e.parentNode;let n,i;for(;r.isFormatElement(e)||r.isRangeFormatElement(e);){for(n=e.childNodes,i=null;n[0];)if(i=n[0],r.isFormatElement(i)||r.isRangeFormatElement(i)){if(this._setIntoFreeFormat(i),!e.parentNode)break;n=e.childNodes}else t.insertBefore(i,e);0===e.childNodes.length&&r.removeItem(e),e=r.createElement("BR"),t.insertBefore(e,i.nextSibling)}return e},removeNode:function(){this._resetRangeToTextNode();const t=this.getRange();let n,i=0,l=t.startContainer,s=t.endContainer,o=t.startOffset,a=t.endOffset;const c=3===t.commonAncestorContainer.nodeType&&t.commonAncestorContainer.parentNode===l.parentNode?l.parentNode:t.commonAncestorContainer;if(c===l&&c===s&&(l=c.children[o],s=c.children[a],o=a=0),!l||!s)return{container:c,offset:0};if(l===s&&t.collapsed&&l.textContent&&r.onlyZeroWidthSpace(l.textContent.substr(o)))return{container:l,offset:o,prevContainer:l&&l.parentNode?l:null};let d=null,u=null;const h=r.getListChildNodes(c,null);let g=r.getArrayIndex(h,l),p=r.getArrayIndex(h,s);if(h.length>0&&g>-1&&p>-1){for(let e=g+1,t=l;e>=0;e--)h[e]===t.parentNode&&h[e].firstChild===t&&0===o&&(g=e,t=t.parentNode);for(let e=p-1,t=s;e>g;e--)h[e]===t.parentNode&&1===h[e].nodeType&&(h.splice(e,1),t=t.parentNode,--p)}else{if(0===h.length){if(r.isFormatElement(c)||r.isRangeFormatElement(c)||r.isWysiwygDiv(c)||r.isBreak(c)||r.isMedia(c))return{container:c,offset:0};if(3===c.nodeType)return{container:c,offset:a};h.push(c),l=s=c}else if(l=s=h[0],r.isBreak(l)||r.onlyZeroWidthSpace(l))return{container:r.isMedia(c)?c:l,offset:0};g=p=0}for(let e=g;e<=p;e++){const t=h[e];if(0===t.length||3===t.nodeType&&void 0===t.data)this._nodeRemoveListItem(t);else if(t!==l)if(t!==s)this._nodeRemoveListItem(t);else{if(1===s.nodeType){if(r.isComponent(s))continue;u=r.createTextNode(s.textContent)}else u=r.createTextNode(s.substringData(a,s.length-a));u.length>0?s.data=u.data:this._nodeRemoveListItem(s)}else{if(1===l.nodeType){if(r.isComponent(l))continue;d=r.createTextNode(l.textContent)}else t===s?(d=r.createTextNode(l.substringData(0,o)+s.substringData(a,s.length-a)),i=o):d=r.createTextNode(l.substringData(0,o));if(d.length>0?l.data=d.data:this._nodeRemoveListItem(l),t===s)break}}const m=r.getParentElement(s,"ul"),f=r.getParentElement(l,"li");if(m&&f&&f.contains(m)?(n=m.previousSibling,i=n.textContent.length):n=s&&s.parentNode?s:l&&l.parentNode?l:t.endContainer||t.startContainer,!r.isWysiwygDiv(n)&&0===n.childNodes.length){const t=r.removeItemAllParents(n,null,null);t&&(n=t.sc||t.ec||e.element.wysiwyg)}return this.setRange(n,i,n,i),this.history.push(!0),{container:n,offset:i,prevContainer:l&&l.parentNode?l:null}},_nodeRemoveListItem:function(e){const t=r.getFormatElement(e,null);r.removeItem(e),r.isListCell(t)&&(r.removeItemAllParents(t,null,null),t&&r.isList(t.firstChild)&&t.insertBefore(r.createTextNode(r.zeroWidthSpace),t.firstChild))},applyRangeFormatElement:function(e){this.getRange_addLine(this.getRange(),null);const t=this.getSelectedElementsAndComponents(!1);if(!t||0===t.length)return;e:for(let e,n,i,l,s,o,a=0,c=t.length;a
"+l.defaultTag+">"},_setEditorDataToCodeView:function(){const t=this.convertHTMLForCodeView(e.element.wysiwyg,!1);let n="";if(l.fullPage){const e=r.getAttributesToString(this._wd.body,null);n="\n\n"+this._wd.head.outerHTML.replace(/>(?!\n)/g,">\n")+"\n"+t+"\n"}else n=t;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(n)},toggleFullScreen:function(t){const n=e.element.topArea,i=e.element.toolbar,s=e.element.editorArea,d=e.element.wysiwygFrame,g=e.element.code,p=this._variable;this.controllersOff();const m="none"===i.style.display||this._isInline&&!this._inlineToolbarAttr.isShow;p.isFullScreen?(p.isFullScreen=!1,d.style.cssText=p._wysiwygOriginCssText,g.style.cssText=p._codeOriginCssText,i.style.cssText="",s.style.cssText=p._editorAreaOriginCssText,n.style.cssText=p._originCssText,o.body.style.overflow=p._bodyOverflow,"auto"!==l.height||l.codeMirrorEditor||u._codeViewAutoHeight(),l.toolbarContainer&&l.toolbarContainer.appendChild(i),l.stickyToolbar>-1&&r.removeClass(i,"se-toolbar-sticky"),p._fullScreenAttrs.sticky&&!l.toolbarContainer&&(p._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",r.addClass(i,"se-toolbar-sticky")),this._isInline=p._fullScreenAttrs.inline,this._isBalloon=p._fullScreenAttrs.balloon,this._isInline&&u._showToolbarInline(),l.toolbarContainer&&r.removeClass(i,"se-toolbar-balloon"),u.onScroll_window(),t&&r.changeElement(t.firstElementChild,c.expansion),e.element.topArea.style.marginTop="",r.removeClass(this._styleCommandMap.fullScreen,"active")):(p.isFullScreen=!0,p._fullScreenAttrs.inline=this._isInline,p._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),l.toolbarContainer&&e.element.relative.insertBefore(i,s),n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.maxWidth="100%",n.style.height="100%",n.style.zIndex="2147483647",""!==e.element._stickyDummy.style.display&&(p._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",r.removeClass(i,"se-toolbar-sticky")),p._bodyOverflow=o.body.style.overflow,o.body.style.overflow="hidden",p._editorAreaOriginCssText=s.style.cssText,p._wysiwygOriginCssText=d.style.cssText,p._codeOriginCssText=g.style.cssText,s.style.cssText=i.style.cssText="",d.style.cssText=(d.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+l._editorStyles.editor,g.style.cssText=(g.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],i.style.width=d.style.height=g.style.height="100%",i.style.position="relative",i.style.display="block",p.innerHeight_fullScreen=a.innerHeight-i.offsetHeight,s.style.height=p.innerHeight_fullScreen-l.fullScreenOffset+"px",t&&r.changeElement(t.firstElementChild,c.reduction),l.iframe&&"auto"===l.height&&(s.style.overflow="auto",this._iframeAutoHeight()),e.element.topArea.style.marginTop=l.fullScreenOffset+"px",r.addClass(this._styleCommandMap.fullScreen,"active")),m&&h.toolbar.hide(),"function"==typeof h.toggleFullScreen&&h.toggleFullScreen(this._variable.isFullScreen,this)},print:function(){const e=r.createElement("IFRAME");e.style.display="none",o.body.appendChild(e);const t=l.printTemplate?l.printTemplate.replace(/\{\{\s*contents\s*\}\}/i,this.getContents(!0)):this.getContents(!0),n=r.getIframeDocument(e),i=this._wd;if(l.iframe){const e=null!==l._printClass?'class="'+l._printClass+'"':l.fullPage?r.getAttributesToString(i.body,["contenteditable"]):'class="'+l._editableClass+'"';n.write(""+i.head.innerHTML+""+t+"")}else{const e=o.head.getElementsByTagName("link"),i=o.head.getElementsByTagName("style");let s="";for(let t=0,n=e.length;t0&&(l+="<"+n+">"+r._HTMLConvertor(e)+""+n+">");return l}return 8===e.nodeType&&this._allowHTMLComments?"\x3c!--"+e.textContent.trim()+"--\x3e":""},_tagConvertor:function(e){if(!this._disallowedTextTagsRegExp)return e;const t=l._textTagsMap;return e.replace(this._disallowedTextTagsRegExp,(function(e,n,i,l){return n+("string"==typeof t[i]?t[i]:i)+(l?" "+l:"")}))},_deleteDisallowedTags:function(e){return e=e.replace(/<(script|style)[\s\S]*>[\s\S]*<\/(script|style)>/gi,"").replace(/<[a-z0-9]+\:[a-z0-9]+[^>^\/]*>[^>]*<\/[a-z0-9]+\:[a-z0-9]+>/gi,""),/\bfont\b/i.test(this.options._editorTagsWhitelist)||(e=e.replace(/(<\/?)font(\s?)/gi,"$1span$2")),e.replace(this.editorTagsWhitelistRegExp,"").replace(this.editorTagsBlacklistRegExp,"")},_convertFontSize:function(e,t){const n=this._w.Math,i=t.match(/(\d+(?:\.\d+)?)(.+)/),l=i?1*i[1]:r.fontValueMap[t],s=i?i[2]:"rem";let o=l;switch(/em/.test(s)?o=n.round(l/.0625):"pt"===s?o=n.round(1.333*l):"%"===s&&(o=l/100),e){case"em":case"rem":case"%":return(.0625*o).toFixed(2)+e;case"pt":return n.floor(o/1.333)+e;default:return o+e}},_cleanStyle:function(e,t,n){let i=(e.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/)||[])[0];if(/span/i.test(n)&&!i&&(e.match(/0&&t.push('style="'+n.join(";")+'"')}}return t},_cleanTags:function(e,t,n){if(/^<[a-z0-9]+\:[a-z0-9]+/i.test(t))return t;let i=null;const l=n.match(/(?!<)[a-zA-Z0-9\-]+/)[0].toLowerCase(),s=this._attributesTagsBlacklist[l];t=t.replace(/\s(?:on[a-z]+)\s*=\s*(")[^"]*\1/gi,""),t=s?t.replace(s,""):t.replace(this._attributesBlacklistRegExp,"");const o=this._attributesTagsWhitelist[l];if(i=o?t.match(o):t.match(e?this._attributesWhitelistRegExp:this._attributesWhitelistRegExp_all_data),e||"span"===l)if("a"===l){const e=t.match(/(?:(?:id|name)\s*=\s*(?:"|')[^"']*(?:"|'))/g);e&&(i||(i=[]),i.push(e[0]))}else i&&/style=/i.test(i.toString())||("span"===l?i=this._cleanStyle(t,i,"span"):/^(P|DIV|H[1-6]|PRE)$/i.test(l)&&(i=this._cleanStyle(t,i,"format")));else{const e=t.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);e&&!i?i=[e[0]]:e&&!i.some((function(e){return/^style/.test(e.trim())}))&&i.push(e[0])}if(r.isFigures(l)){const e=t.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);if(i||(i=[]),e){const t=e[0].match(/width\s?:\s?(\d+)(px|%)/),n=e[0].match(/height\s?:\s?(\d+)(px|%)/),l=t&&t[1]&&t[2]?t[1]+t[2]:"auto",s=n&&n[1]&&n[2]?n[1]+n[2]:"auto";i.push('style="width:'+l+"; height:"+s+';"')}}if(i)for(let e=0,t=i.length;e
")+"":r.isRangeFormatElement(n)&&!r.isTable(n)?t+=this._convertListCell(n):t+="
")+"
$/i,"");const i=o.createRange().createContextualFragment(e);try{r._consistencyCheckOfHTML(i,this._htmlCheckWhitelistRegExp,this._htmlCheckBlacklistRegExp,!0)}catch(e){console.warn("[SUNEDITOR.cleanHTML.consistencyCheck.fail] "+e)}if(this.managedTagsInfo&&this.managedTagsInfo.query){const e=i.querySelectorAll(this.managedTagsInfo.query);for(let t,n,i=0,l=e.length;i
"+l.defaultTag+">":(i=r.htmlRemoveWhiteSpace(i),this._tagConvertor(i))},convertHTMLForCodeView:function(e,t){let n="";const i=a.RegExp,l=new i("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),s="string"==typeof e?o.createRange().createContextualFragment(e):e,c=function(e){return this.isFormatElement(e)||this.isComponent(e)}.bind(r),d=t?"":"\n";let u=t?0:1*this._variable.codeIndent;return u=u>0?new a.Array(u+1).join(" "):"",function e(t,s){const o=t.childNodes,h=l.test(t.nodeName),g=h?s:"";for(let p,m,f,_,b,v,y=0,C=o.length;y