/**
* Sun editor min.js code from cdn if needed to update then paste the code in this section below the
* latest code from suneditor cdn i.e suneditor.min.js
*/
!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) { return '
' }, _onMouseDown_browser: function (e) { /se-file-browser-inner/.test(e.target.className) ? this.context.fileBrowser._closeSignal = !0 : this.context.fileBrowser._closeSignal = !1 }, _onClick_browser: function (e) { e.stopPropagation(), (/close/.test(e.target.getAttribute("data-command")) || this.context.fileBrowser._closeSignal) && this.plugins.fileBrowser.close.call(this) }, open: function (e, t) { this.plugins.fileBrowser._bindClose && (this._d.removeEventListener("keydown", this.plugins.fileBrowser._bindClose), this.plugins.fileBrowser._bindClose = null), this.plugins.fileBrowser._bindClose = function (e) { /27/.test(e.keyCode) && this.plugins.fileBrowser.close.call(this) }.bind(this), this._d.addEventListener("keydown", this.plugins.fileBrowser._bindClose); const n = this.context.fileBrowser; n.contextPlugin = e, n.selectorHandler = t; const i = this.context[e], l = i.listClass; this.util.hasClass(n.list, l) || (n.list.className = "se-file-browser-list " + l), "full" === this.options.popupDisplay ? n.area.style.position = "fixed" : n.area.style.position = "absolute", n.titleArea.textContent = i.title, n.area.style.display = "block", this.plugins.fileBrowser._drawFileList.call(this, this.context[e].url, this.context[e].header) }, _bindClose: null, close: function () { const e = this.plugins.fileBrowser; e._xmlHttp && e._xmlHttp.abort(), e._bindClose && (this._d.removeEventListener("keydown", e._bindClose), e._bindClose = null); const t = this.context.fileBrowser; t.area.style.display = "none", t.selectorHandler = null, t.selectedTags = [], t.items = [], t.list.innerHTML = t.tagArea.innerHTML = t.titleArea.textContent = "", "function" == typeof this.plugins[t.contextPlugin].init && this.plugins[t.contextPlugin].init.call(this), t.contextPlugin = "" }, showBrowserLoading: function () { this._loading.style.display = "block" }, closeBrowserLoading: function () { this._loading.style.display = "none" }, _drawFileList: function (e, t) { const n = this.plugins.fileBrowser, i = n._xmlHttp = this.util.getXMLHttpRequest(); if (i.onreadystatechange = n._callBackGet.bind(this, i), i.open("get", e, !0), null !== t && "object" == typeof t && this._w.Object.keys(t).length > 0) for (let e in t) i.setRequestHeader(e, t[e]); i.send(null), this.plugins.fileBrowser.showBrowserLoading() }, _callBackGet: function (e) { if (4 === e.readyState) if (this.plugins.fileBrowser._xmlHttp = null, 200 === e.status) try { this.plugins.fileBrowser._drawListItem.call(this, JSON.parse(e.responseText).result, !0) } catch (e) { throw Error('[SUNEDITOR.fileBrowser.drawList.fail] cause : "' + e.message + '"') } finally { this.plugins.fileBrowser.closeBrowserLoading(), this.context.fileBrowser.body.style.maxHeight = this._w.innerHeight - this.context.fileBrowser.header.offsetHeight - 50 + "px" } else if (this.plugins.fileBrowser.closeBrowserLoading(), 0 !== e.status) { const t = e.responseText ? JSON.parse(e.responseText) : e, n = "[SUNEDITOR.fileBrowser.get.serverException] status: " + e.status + ", response: " + (t.errorMessage || e.responseText); throw Error(n) } }, _drawListItem: function (e, t) { const n = this.context.fileBrowser, i = this.context[n.contextPlugin], l = [], o = e.length, s = i.columnSize || n.columnSize, a = s <= 1 ? 1 : Math.round(o / s) || 1, r = i.itemTemplateHandler; let c = "", d = '
', u = 1; for (let n, i, h = 0; h < o; h++)if (n = e[h], i = n.tag ? "string" == typeof n.tag ? n.tag.split(",") : n.tag : [], i = n.tag = i.map((function (e) { return e.trim() })), d += r(n), (h + 1) % a == 0 && u < s && h + 1 < o && (u++, d += '
'), t && i.length > 0) for (let e, t = 0, n = i.length; t < n; t++)e = i[t], e && -1 === l.indexOf(e) && (l.push(e), c += '' + e + ""); d += "
", i.innerHTML = l, i }, _fileInputChange: function () { this.imgInputFile.value ? (this.imgUrlFile.setAttribute("disabled", !0), this.previewSrc.style.textDecoration = "line-through") : (this.imgUrlFile.removeAttribute("disabled"), this.previewSrc.style.textDecoration = "") }, _removeSelectedFiles: function (e, t) { this.value = "", e && (e.removeAttribute("disabled"), t.style.textDecoration = "") }, _openGallery: function () { this.callPlugin("imageGallery", this.plugins.imageGallery.open.bind(this, this.plugins.image._setUrlInput.bind(this.context.image)), null) }, _setUrlInput: function (e) { this.altText.value = e.alt, this._v_src._linkValue = this.previewSrc.textContent = this.imgUrlFile.value = e.src, this.imgUrlFile.focus() }, _onLinkPreview: function (e, t, n) { const i = n.target.value.trim(); e._linkValue = this.textContent = i ? t && -1 === i.indexOf("://") && 0 !== i.indexOf("#") ? t + i : -1 === i.indexOf("://") ? "/" + i : i : "" }, fileTags: ["img"], select: function (e) { this.plugins.image.onModifyMode.call(this, e, this.plugins.resizing.call_controller_resize.call(this, e, "image")) }, destroy: function (e) { const t = e || this.context.image._element, n = this.util.getParentElement(t, this.util.isMediaComponent) || t, i = 1 * t.getAttribute("data-index"); let l = n.previousElementSibling || n.nextElementSibling; const o = n.parentNode; this.util.removeItem(n), this.plugins.image.init.call(this), this.controllersOff(), o !== this.context.element.wysiwyg && this.util.removeItemAllParents(o, (function (e) { return 0 === e.childNodes.length }), null), this.focusEdge(l), this.plugins.fileManager.deleteInfo.call(this, "image", i, this.functions.onImageUpload), this.history.push(!1) }, on: function (e) { const t = this.context.image; e ? t.imgInputFile && this.options.imageMultipleFile && t.imgInputFile.removeAttribute("multiple") : (t.inputX.value = t._origin_w = this.options.imageWidth === t._defaultSizeX ? "" : this.options.imageWidth, t.inputY.value = t._origin_h = this.options.imageHeight === t._defaultSizeY ? "" : this.options.imageHeight, t.imgInputFile && this.options.imageMultipleFile && t.imgInputFile.setAttribute("multiple", "multiple")), this.plugins.anchor.on.call(this, t.anchorCtx, e) }, open: function () { this.plugins.dialog.open.call(this, "image", "image" === this.currentControllerName) }, openTab: function (e) { const t = this.context.image.modal, n = "init" === e ? t.querySelector("._se_tab_link") : e.target; if (!/^BUTTON$/i.test(n.tagName)) return !1; const i = n.getAttribute("data-tab-link"); let l, o, s; for (o = t.getElementsByClassName("_se_tab_content"), l = 0; l < o.length; l++)o[l].style.display = "none"; for (s = t.getElementsByClassName("_se_tab_link"), l = 0; l < s.length; l++)this.util.removeClass(s[l], "active"); return t.querySelector("._se_tab_content_" + i).style.display = "block", this.util.addClass(n, "active"), "image" === i && this.context.image.focusElement ? this.context.image.focusElement.focus() : "url" === i && this.context.anchor.caller.image.urlInput.focus(), !1 }, submit: function (e) { const t = this.context.image, n = this.plugins.image; e.preventDefault(), e.stopPropagation(), t._altText = t.altText.value, t._align = t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value, t._captionChecked = t.captionCheckEl.checked, t._resizing && (t._proportionChecked = t.proportion.checked); try { this.context.dialog.updateModal && n.update_image.call(this, !1, !0, !1), t.imgInputFile && t.imgInputFile.files.length > 0 ? (this.showLoading(), n.submitAction.call(this, this.context.image.imgInputFile.files)) : t.imgUrlFile && t._v_src._linkValue.length > 0 && (this.showLoading(), n.onRender_imgUrl.call(this)) } catch (e) { throw this.closeLoading(), Error('[SUNEDITOR.image.submit.fail] cause : "' + e.message + '"') } finally { this.plugins.dialog.close.call(this) } return !1 }, submitAction: function (e) { if (0 === e.length) return; let t = 0, n = []; for (let i = 0, l = e.length; i < l; i++)/image/i.test(e[i].type) && (n.push(e[i]), t += e[i].size); const i = this.options.imageUploadSizeLimit; if (i > 0) { let e = 0; const n = this.context.image._infoList; for (let t = 0, i = n.length; t < i; t++)e += 1 * n[t].size; if (t + e > i) { this.closeLoading(); const n = "[SUNEDITOR.imageUpload.fail] Size of uploadable total images: " + i / 1e3 + "KB"; return void (("function" != typeof this.functions.onImageUploadError || this.functions.onImageUploadError(n, { limitSize: i, currentSize: e, uploadSize: t }, this)) && this.functions.noticeOpen(n)) } } const l = this.context.image; l._uploadFileLength = n.length; const o = { anchor: this.plugins.anchor.createAnchor.call(this, l.anchorCtx, !0), inputWidth: l.inputX.value, inputHeight: l.inputY.value, align: l._align, isUpdate: this.context.dialog.updateModal, element: l._element }; if ("function" == typeof this.functions.onImageUploadBefore) { const e = this.functions.onImageUploadBefore(n, o, this, function (e) { e && this._w.Array.isArray(e.result) ? this.plugins.image.register.call(this, o, e) : this.plugins.image.upload.call(this, o, e) }.bind(this)); if (void 0 === e) return; if (!e) return void this.closeLoading(); this._w.Array.isArray(e) && e.length > 0 && (n = e) } this.plugins.image.upload.call(this, o, n) }, error: function (e, t) { if (this.closeLoading(), "function" != typeof this.functions.onImageUploadError || this.functions.onImageUploadError(e, t, this)) throw this.functions.noticeOpen(e), Error("[SUNEDITOR.plugin.image.error] response: " + e) }, upload: function (e, t) { if (!t) return void this.closeLoading(); if ("string" == typeof t) return void this.plugins.image.error.call(this, t, null); const n = this.options.imageUploadUrl, i = this.context.dialog.updateModal ? 1 : t.length; if ("string" == typeof n && n.length > 0) { const l = new FormData; for (let e = 0; e < i; e++)l.append("file-" + e, t[e]); this.plugins.fileManager.upload.call(this, n, this.options.imageUploadHeader, l, this.plugins.image.callBack_imgUpload.bind(this, e), this.functions.onImageUploadError) } else this.plugins.image.setup_reader.call(this, t, e.anchor, e.inputWidth, e.inputHeight, e.align, i, e.isUpdate) }, callBack_imgUpload: function (e, t) { if ("function" == typeof this.functions.imageUploadHandler) this.functions.imageUploadHandler(t, e, this); else { const n = JSON.parse(t.responseText); n.errorMessage ? this.plugins.image.error.call(this, n.errorMessage, n) : this.plugins.image.register.call(this, e, n) } }, register: function (e, t) { const n = t.result; for (let t, i = 0, l = n.length; i < l; i++) { if (t = { name: n[i].name, size: n[i].size }, e.isUpdate) { this.plugins.image.update_src.call(this, n[i].url, e.element, t); break } this.plugins.image.create_image.call(this, n[i].url, e.anchor, e.inputWidth, e.inputHeight, e.align, t) } this.closeLoading() }, setup_reader: function (e, t, n, i, l, o, s) { try { this.context.image.base64RenderIndex = o; const a = this._w.FileReader, r = [o]; this.context.image.inputX.value = n, this.context.image.inputY.value = i; for (let c, d, u = 0; u < o; u++)c = new a, d = e[u], c.onload = function (e, o, s, a, c) { r[c] = { result: e.result, file: a }, 0 == --this.context.image.base64RenderIndex && (this.plugins.image.onRender_imgBase64.call(this, o, r, s, t, n, i, l), this.closeLoading()) }.bind(this, c, s, this.context.image._element, d, u), c.readAsDataURL(d) } catch (e) { throw this.closeLoading(), Error('[SUNEDITOR.image.setup_reader.fail] cause : "' + e.message + '"') } }, onRender_imgBase64: function (e, t, n, i, l, o, s) { const a = this.plugins.image.update_src, r = this.plugins.image.create_image; for (let c = 0, d = t.length; c < d; c++)e ? (this.context.image._element.setAttribute("data-file-name", t[c].file.name), this.context.image._element.setAttribute("data-file-size", t[c].file.size), a.call(this, t[c].result, n, t[c].file)) : r.call(this, t[c].result, i, l, o, s, t[c].file) }, onRender_imgUrl: function () { const e = this.context.image; if (0 === e._v_src._linkValue.length) return !1; try { const t = { name: e._v_src._linkValue.split("/").pop(), size: 0 }; this.context.dialog.updateModal ? this.plugins.image.update_src.call(this, e._v_src._linkValue, e._element, t) : this.plugins.image.create_image.call(this, e._v_src._linkValue, this.plugins.anchor.createAnchor.call(this, e.anchorCtx, !0), e.inputX.value, e.inputY.value, e._align, t) } catch (e) { throw Error('[SUNEDITOR.image.URLRendering.fail] cause : "' + e.message + '"') } finally { this.closeLoading() } }, onRender_link: function (e, t) { return t ? (t.setAttribute("data-image-link", "image"), e.setAttribute("data-image-link", t.href), t.appendChild(e), t) : e }, setInputSize: function (e, t) { t && 32 === t.keyCode ? t.preventDefault() : this.plugins.resizing._module_setInputSize.call(this, this.context.image, e) }, setRatio: function () { this.plugins.resizing._module_setRatio.call(this, this.context.image) }, checkFileInfo: function () { const e = this.plugins.image, t = this.context.image, n = function (n) { e.onModifyMode.call(this, n, null), e.openModify.call(this, !0), t.inputX.value = t._origin_w, t.inputY.value = t._origin_h; const i = this.util.getFormatElement(n); i && (t._align = i.style.textAlign || i.style.float); this.util.getParentElement(n, this.util.isAnchor) && !t.anchorCtx.linkValue && (t.anchorCtx.linkValue = " "), e.update_image.call(this, !0, !1, !0) }.bind(this); this.plugins.fileManager.checkInfo.call(this, "image", ["img"], this.functions.onImageUpload, n, !0) }, resetFileInfo: function () { this.plugins.fileManager.resetInfo.call(this, "image", this.functions.onImageUpload) }, create_image: function (e, t, n, i, l, o) { const s = this.plugins.image, a = this.context.image; this.context.resizing._resize_plugin = "image"; let r = this.util.createElement("IMG"); r.src = e, r.alt = a._altText, r.setAttribute("data-rotate", "0"), t = s.onRender_link.call(this, r, t), a._resizing && r.setAttribute("data-proportion", a._proportionChecked); const c = this.plugins.component.set_cover.call(this, t), d = this.plugins.component.set_container.call(this, c, "se-image-container"); a._captionChecked && (a._caption = this.plugins.component.create_caption.call(this), a._caption.setAttribute("contenteditable", !1), c.appendChild(a._caption)), a._element = r, a._cover = c, a._container = d, s.applySize.call(this, n, i), s.setAlign.call(this, l, r, c, d), r.onload = s._image_create_onload.bind(this, r, a.svgDefaultSize, d), this.insertComponent(d, !0, !0, !0) && this.plugins.fileManager.setInfo.call(this, "image", r, this.functions.onImageUpload, o, !0), this.context.resizing._resize_plugin = "" }, _image_create_onload: function (e, t, n) { if (0 === e.offsetWidth && this.plugins.image.applySize.call(this, t, ""), this.options.mediaAutoSelect) this.selectComponent(e, "image"); else { const e = this.appendFormatTag(n, null); this.setRange(e, 0, e, 0) } }, update_image: function (e, t, n) { const i = this.context.image; let l, o = i._element, s = i._cover, a = i._container, r = !1; null === s && (r = !0, o = i._element.cloneNode(!0), s = this.plugins.component.set_cover.call(this, o)), null === a ? (s = s.cloneNode(!0), o = s.querySelector("img"), r = !0, a = this.plugins.component.set_container.call(this, s, "se-image-container")) : r && (a.innerHTML = "", a.appendChild(s), i._cover = s, i._element = o, r = !1); const c = this.util.isNumber(i.inputX.value) ? i.inputX.value + i.sizeUnit : i.inputX.value, d = this.util.isNumber(i.inputY.value) ? i.inputY.value + i.sizeUnit : i.inputY.value; l = /%$/.test(o.style.width) ? c !== a.style.width || d !== a.style.height : c !== o.style.width || d !== o.style.height, o.alt = i._altText; let u = !1; i._captionChecked ? i._caption || (i._caption = this.plugins.component.create_caption.call(this), s.appendChild(i._caption), u = !0) : i._caption && (this.util.removeItem(i._caption), i._caption = null, u = !0); const h = this.plugins.anchor.createAnchor.call(this, i.anchorCtx, !0); if (h) i._linkElement = i._linkElement === h ? h.cloneNode(!1) : h, s.insertBefore(this.plugins.image.onRender_link.call(this, o, i._linkElement), i._caption); else if (null !== i._linkElement) { const e = o; if (e.setAttribute("data-image-link", ""), s.contains(i._linkElement)) { const t = e.cloneNode(!0); s.removeChild(i._linkElement), s.insertBefore(t, i._caption), o = t } } if (r) { const e = this.util.isRangeFormatElement(i._element.parentNode) || this.util.isWysiwygDiv(i._element.parentNode) ? i._element : /^A$/i.test(i._element.parentNode.nodeName) ? i._element.parentNode : this.util.getFormatElement(i._element) || i._element; if (this.util.isFormatElement(e) && e.childNodes.length > 0) e.parentNode.insertBefore(a, e), this.util.removeItem(i._element), this.util.removeEmptyNode(e, null), 0 === e.children.length && (e.innerHTML = this.util.htmlRemoveWhiteSpace(e.innerHTML)); else if (this.util.isFormatElement(e.parentNode)) { const t = e.parentNode; t.parentNode.insertBefore(a, e.previousSibling ? t.nextElementSibling : t), this.util.removeItem(e) } else e.parentNode.replaceChild(a, e); o = a.querySelector("img"), i._element = o, i._cover = s, i._container = a } (u || !i._onlyPercentage && l) && !e && (/\d+/.test(o.style.height) || this.context.resizing._rotateVertical && i._captionChecked) && (/%$/.test(i.inputX.value) || /%$/.test(i.inputY.value) ? this.plugins.resizing.resetTransform.call(this, o) : this.plugins.resizing.setTransformSize.call(this, o, this.util.getNumber(i.inputX.value, 0), this.util.getNumber(i.inputY.value, 0))), i._resizing && (o.setAttribute("data-proportion", i._proportionChecked), l && this.plugins.image.applySize.call(this)), this.plugins.image.setAlign.call(this, null, o, null, null), e && this.plugins.fileManager.setInfo.call(this, "image", o, this.functions.onImageUpload, null, !0), t && this.selectComponent(o, "image"), n || this.history.push(!1) }, update_src: function (e, t, n) { t.src = e, this._w.setTimeout(this.plugins.fileManager.setInfo.bind(this, "image", t, this.functions.onImageUpload, n, !0)), this.selectComponent(t, "image") }, onModifyMode: function (e, t) { if (!e) return; const n = this.context.image; n._linkElement = n.anchorCtx.linkAnchor = /^A$/i.test(e.parentNode.nodeName) ? e.parentNode : null, n._element = e, n._cover = this.util.getParentElement(e, "FIGURE"), n._container = this.util.getParentElement(e, this.util.isMediaComponent), n._caption = this.util.getChildElement(n._cover, "FIGCAPTION"), n._align = e.style.float || e.getAttribute("data-align") || "none", e.style.float = "", this.plugins.anchor.setCtx(n._linkElement, n.anchorCtx), t && (n._element_w = t.w, n._element_h = t.h, n._element_t = t.t, n._element_l = t.l); let i, l, o = n._element.getAttribute("data-size") || n._element.getAttribute("data-origin"); o ? (o = o.split(","), i = o[0], l = o[1]) : t && (i = t.w, l = t.h), n._origin_w = i || e.style.width || e.width || "", n._origin_h = l || e.style.height || e.height || "" }, openModify: function (e) { const t = this.context.image; t.imgUrlFile && (t._v_src._linkValue = t.previewSrc.textContent = t.imgUrlFile.value = t._element.src), t._altText = t.altText.value = t._element.alt, t.modal.querySelector('input[name="suneditor_image_radio"][value="' + t._align + '"]').checked = !0, t._align = t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value, t._captionChecked = t.captionCheckEl.checked = !!t._caption, t._resizing && this.plugins.resizing._module_setModifyInputSize.call(this, t, this.plugins.image), e || this.plugins.dialog.open.call(this, "image", !0) }, applySize: function (e, t) { const n = this.context.image; return e || (e = n.inputX.value || this.options.imageWidth), t || (t = n.inputY.value || this.options.imageHeight), n._onlyPercentage && e || /%$/.test(e) ? (this.plugins.image.setPercentSize.call(this, e, t), !0) : (e && "auto" !== e || t && "auto" !== t ? this.plugins.image.setSize.call(this, e, t, !1) : this.plugins.image.setAutoSize.call(this), !1) }, sizeRevert: function () { this.plugins.resizing._module_sizeRevert.call(this, this.context.image) }, setSize: function (e, t, n, i) { const l = this.context.image, o = /^(rw|lw)$/.test(i); /^(th|bh)$/.test(i) || (l._element.style.width = this.util.isNumber(e) ? e + l.sizeUnit : e, this.plugins.image.cancelPercentAttr.call(this)), o || (l._element.style.height = this.util.isNumber(t) ? t + l.sizeUnit : /%$/.test(t) ? "" : t), "center" === l._align && this.plugins.image.setAlign.call(this, null, null, null, null), n || l._element.removeAttribute("data-percentage"), this.plugins.resizing._module_saveCurrentSize.call(this, l) }, setAutoSize: function () { const e = this.context.image; this.plugins.resizing.resetTransform.call(this, e._element), this.plugins.image.cancelPercentAttr.call(this), e._element.style.maxWidth = "", e._element.style.width = "", e._element.style.height = "", e._cover.style.width = "", e._cover.style.height = "", this.plugins.image.setAlign.call(this, null, null, null, null), e._element.setAttribute("data-percentage", "auto,auto"), this.plugins.resizing._module_saveCurrentSize.call(this, e) }, setOriginSize: function () { const e = this.context.image; e._element.removeAttribute("data-percentage"), this.plugins.resizing.resetTransform.call(this, e._element), this.plugins.image.cancelPercentAttr.call(this); const t = (e._element.getAttribute("data-origin") || "").split(","), n = t[0], i = t[1]; t && (e._onlyPercentage || /%$/.test(n) && (/%$/.test(i) || !/\d/.test(i)) ? this.plugins.image.setPercentSize.call(this, n, i) : this.plugins.image.setSize.call(this, n, i), this.plugins.resizing._module_saveCurrentSize.call(this, e)) }, setPercentSize: function (e, t) { const n = this.context.image; t = !t || /%$/.test(t) || this.util.getNumber(t, 0) ? this.util.isNumber(t) ? t + n.sizeUnit : t || "" : this.util.isNumber(t) ? t + "%" : t; const i = /%$/.test(t); n._container.style.width = this.util.isNumber(e) ? e + "%" : e, n._container.style.height = "", n._cover.style.width = "100%", n._cover.style.height = i ? t : "", n._element.style.width = "100%", n._element.style.height = i ? "" : t, n._element.style.maxWidth = "", "center" === n._align && this.plugins.image.setAlign.call(this, null, null, null, null), n._element.setAttribute("data-percentage", e + "," + t), this.plugins.resizing.setCaptionPosition.call(this, n._element), this.plugins.resizing._module_saveCurrentSize.call(this, n) }, cancelPercentAttr: function () { const e = this.context.image; e._cover.style.width = "", e._cover.style.height = "", e._container.style.width = "", e._container.style.height = "", this.util.removeClass(e._container, this.context.image._floatClassRegExp), this.util.addClass(e._container, "__se__float-" + e._align), "center" === e._align && this.plugins.image.setAlign.call(this, null, null, null, null) }, setAlign: function (e, t, n, i) { const l = this.context.image; e || (e = l._align), t || (t = l._element), n || (n = l._cover), i || (i = l._container), n.style.margin = e && "none" !== e ? "auto" : "0", /%$/.test(t.style.width) && "center" === e ? (i.style.minWidth = "100%", n.style.width = i.style.width) : (i.style.minWidth = "", n.style.width = this.context.resizing._rotateVertical ? t.style.height || t.offsetHeight : t.style.width && "auto" !== t.style.width ? t.style.width || "100%" : ""), this.util.hasClass(i, "__se__float-" + e) || (this.util.removeClass(i, l._floatClassRegExp), this.util.addClass(i, "__se__float-" + e)), t.setAttribute("data-align", e) }, init: function () { const e = this.context.image; e.imgInputFile && (e.imgInputFile.value = ""), e.imgUrlFile && (e._v_src._linkValue = e.previewSrc.textContent = e.imgUrlFile.value = ""), e.imgInputFile && e.imgUrlFile && (e.imgUrlFile.removeAttribute("disabled"), e.previewSrc.style.textDecoration = ""), e.altText.value = "", 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 && (e.inputX.value = this.options.imageWidth === e._defaultSizeX ? "" : this.options.imageWidth, e.inputY.value = this.options.imageHeight === e._defaultSizeY ? "" : this.options.imageHeight, e.proportion.checked = !0, e._ratio = !1, e._ratioX = 1, e._ratioY = 1), this.plugins.anchor.init.call(this, e.anchorCtx) } }, v = { name: "video", display: "dialog", add: function (e) { e.addModule([r.a, p.a, m.a, _.a]); const t = e.options, n = e.context, i = n.video = { _infoList: [], _infoIndex: 0, _uploadFileLength: 0, focusElement: null, sizeUnit: t._videoSizeUnit, _align: "none", _floatClassRegExp: "__se__float\\-[a-z]+", _youtubeQuery: t.youtubeQuery, _videoRatio: 100 * t.videoRatio + "%", _defaultRatio: 100 * t.videoRatio + "%", _linkValue: "", _element: null, _cover: null, _container: null, inputX: null, inputY: null, _element_w: 1, _element_h: 1, _element_l: 0, _element_t: 0, _defaultSizeX: "100%", _defaultSizeY: 100 * t.videoRatio + "%", _origin_w: "100%" === t.videoWidth ? "" : t.videoWidth, _origin_h: "56.25%" === t.videoHeight ? "" : t.videoHeight, _proportionChecked: !0, _resizing: t.videoResizing, _resizeDotHide: !t.videoHeightShow, _rotation: t.videoRotation, _onlyPercentage: t.videoSizeOnlyPercentage, _ratio: !1, _ratioX: 1, _ratioY: 1, _captionShow: !1 }; let l = this.setDialog(e); i.modal = l, i.videoInputFile = l.querySelector("._se_video_file"), i.videoUrlFile = l.querySelector(".se-input-url"), i.focusElement = i.videoUrlFile || i.videoInputFile, i.preview = l.querySelector(".se-link-preview"), l.querySelector("form").addEventListener("submit", this.submit.bind(e)), i.videoInputFile && l.querySelector(".se-dialog-files-edge-button").addEventListener("click", this._removeSelectedFiles.bind(i.videoInputFile, i.videoUrlFile, i.preview)), i.videoInputFile && i.videoUrlFile && i.videoInputFile.addEventListener("change", this._fileInputChange.bind(i)), i.videoUrlFile && i.videoUrlFile.addEventListener("input", this._onLinkPreview.bind(i.preview, i, t.linkProtocol)), i.proportion = {}, i.videoRatioOption = {}, i.inputX = {}, i.inputY = {}, t.videoResizing && (i.proportion = l.querySelector("._se_video_check_proportion"), i.videoRatioOption = l.querySelector(".se-video-ratio"), i.inputX = l.querySelector("._se_video_size_x"), i.inputY = l.querySelector("._se_video_size_y"), i.inputX.value = t.videoWidth, i.inputY.value = t.videoHeight, i.inputX.addEventListener("keyup", this.setInputSize.bind(e, "x")), i.inputY.addEventListener("keyup", this.setInputSize.bind(e, "y")), i.inputX.addEventListener("change", this.setRatio.bind(e)), i.inputY.addEventListener("change", this.setRatio.bind(e)), i.proportion.addEventListener("change", this.setRatio.bind(e)), i.videoRatioOption.addEventListener("change", this.setVideoRatio.bind(e)), l.querySelector(".se-dialog-btn-revert").addEventListener("click", this.sizeRevert.bind(e))), n.dialog.modal.appendChild(l), l = null }, setDialog: function (e) { const t = e.options, n = e.lang, i = e.util.createElement("DIV"); i.className = "se-dialog-content", i.style.display = "none"; let l = '", i.innerHTML = l, i }, _fileInputChange: function () { this.videoInputFile.value ? (this.videoUrlFile.setAttribute("disabled", !0), this.preview.style.textDecoration = "line-through") : (this.videoUrlFile.removeAttribute("disabled"), this.preview.style.textDecoration = "") }, _removeSelectedFiles: function (e, t) { this.value = "", e && (e.removeAttribute("disabled"), t.style.textDecoration = "") }, _onLinkPreview: function (e, t, n) { const i = n.target.value.trim(); /^$/.test(i) ? (e._linkValue = i, this.textContent = '') : e._linkValue = this.textContent = i ? t && -1 === i.indexOf("://") && 0 !== i.indexOf("#") ? t + i : -1 === i.indexOf("://") ? "/" + i : i : "" }, _setTagAttrs: function (e) { e.setAttribute("controls", !0); const t = this.options.videoTagAttrs; if (t) for (let n in t) this.util.hasOwn(t, n) && e.setAttribute(n, t[n]) }, createVideoTag: function () { const e = this.util.createElement("VIDEO"); return this.plugins.video._setTagAttrs.call(this, e), e }, _setIframeAttrs: function (e) { e.frameBorder = "0", e.allowFullscreen = !0; const t = this.options.videoIframeAttrs; if (t) for (let n in t) this.util.hasOwn(t, n) && e.setAttribute(n, t[n]) }, createIframeTag: function () { const e = this.util.createElement("IFRAME"); return this.plugins.video._setIframeAttrs.call(this, e), e }, fileTags: ["iframe", "video"], select: function (e) { this.plugins.video.onModifyMode.call(this, e, this.plugins.resizing.call_controller_resize.call(this, e, "video")) }, destroy: function (e) { const t = e || this.context.video._element, n = this.context.video._container, i = 1 * t.getAttribute("data-index"); let l = n.previousElementSibling || n.nextElementSibling; const o = n.parentNode; this.util.removeItem(n), this.plugins.video.init.call(this), this.controllersOff(), o !== this.context.element.wysiwyg && this.util.removeItemAllParents(o, (function (e) { return 0 === e.childNodes.length }), null), this.focusEdge(l), this.plugins.fileManager.deleteInfo.call(this, "video", i, this.functions.onVideoUpload), this.history.push(!1) }, on: function (e) { const t = this.context.video; e ? t.videoInputFile && this.options.videoMultipleFile && t.videoInputFile.removeAttribute("multiple") : (t.inputX.value = t._origin_w = this.options.videoWidth === t._defaultSizeX ? "" : this.options.videoWidth, t.inputY.value = t._origin_h = this.options.videoHeight === t._defaultSizeY ? "" : this.options.videoHeight, t.proportion.disabled = !0, t.videoInputFile && this.options.videoMultipleFile && t.videoInputFile.setAttribute("multiple", "multiple")), t._resizing && this.plugins.video.setVideoRatioSelect.call(this, t._origin_h || t._defaultRatio) }, open: function () { this.plugins.dialog.open.call(this, "video", "video" === this.currentControllerName) }, setVideoRatio: function (e) { const t = this.context.video, n = e.target.options[e.target.selectedIndex].value; t._defaultSizeY = t._videoRatio = n ? 100 * n + "%" : t._defaultSizeY, t.inputY.placeholder = n ? 100 * n + "%" : "", t.inputY.value = "" }, setInputSize: function (e, t) { if (t && 32 === t.keyCode) return void t.preventDefault(); const n = this.context.video; this.plugins.resizing._module_setInputSize.call(this, n, e), "y" === e && this.plugins.video.setVideoRatioSelect.call(this, t.target.value || n._defaultRatio) }, setRatio: function () { this.plugins.resizing._module_setRatio.call(this, this.context.video) }, submit: function (e) { const t = this.context.video, n = this.plugins.video; e.preventDefault(), e.stopPropagation(), t._align = t.modal.querySelector('input[name="suneditor_video_radio"]:checked').value; try { t.videoInputFile && t.videoInputFile.files.length > 0 ? (this.showLoading(), n.submitAction.call(this, this.context.video.videoInputFile.files)) : t.videoUrlFile && t._linkValue.length > 0 && (this.showLoading(), n.setup_url.call(this)) } catch (e) { throw this.closeLoading(), Error('[SUNEDITOR.video.submit.fail] cause : "' + e.message + '"') } finally { this.plugins.dialog.close.call(this) } return !1 }, submitAction: function (e) { if (0 === e.length) return; let t = 0, n = []; for (let i = 0, l = e.length; i < l; i++)/video/i.test(e[i].type) && (n.push(e[i]), t += e[i].size); const i = this.options.videoUploadSizeLimit; if (i > 0) { let e = 0; const n = this.context.video._infoList; for (let t = 0, i = n.length; t < i; t++)e += 1 * n[t].size; if (t + e > i) { this.closeLoading(); const n = "[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: " + i / 1e3 + "KB"; return void (("function" != typeof this.functions.onVideoUploadError || this.functions.onVideoUploadError(n, { limitSize: i, currentSize: e, uploadSize: t }, this)) && this.functions.noticeOpen(n)) } } const l = this.context.video; l._uploadFileLength = n.length; const o = { inputWidth: l.inputX.value, inputHeight: l.inputY.value, align: l._align, isUpdate: this.context.dialog.updateModal, element: l._element }; if ("function" == typeof this.functions.onVideoUploadBefore) { const e = this.functions.onVideoUploadBefore(n, o, this, function (e) { e && this._w.Array.isArray(e.result) ? this.plugins.video.register.call(this, o, e) : this.plugins.video.upload.call(this, o, e) }.bind(this)); if (void 0 === e) return; if (!e) return void this.closeLoading(); "object" == typeof e && e.length > 0 && (n = e) } this.plugins.video.upload.call(this, o, n) }, error: function (e, t) { if (this.closeLoading(), "function" != typeof this.functions.onVideoUploadError || this.functions.onVideoUploadError(e, t, this)) throw this.functions.noticeOpen(e), Error("[SUNEDITOR.plugin.video.error] response: " + e) }, upload: function (e, t) { if (!t) return void this.closeLoading(); if ("string" == typeof t) return void this.plugins.video.error.call(this, t, null); const n = this.options.videoUploadUrl, i = this.context.dialog.updateModal ? 1 : t.length; if (!("string" == typeof n && n.length > 0)) throw Error('[SUNEDITOR.videoUpload.fail] cause : There is no "videoUploadUrl" option.'); { const l = new FormData; for (let e = 0; e < i; e++)l.append("file-" + e, t[e]); this.plugins.fileManager.upload.call(this, n, this.options.videoUploadHeader, l, this.plugins.video.callBack_videoUpload.bind(this, e), this.functions.onVideoUploadError) } }, callBack_videoUpload: function (e, t) { if ("function" == typeof this.functions.videoUploadHandler) this.functions.videoUploadHandler(t, e, this); else { const n = JSON.parse(t.responseText); n.errorMessage ? this.plugins.video.error.call(this, n.errorMessage, n) : this.plugins.video.register.call(this, e, n) } }, register: function (e, t) { const n = t.result, i = this.plugins.video.createVideoTag.call(this); for (let t, l = 0, o = n.length; l < o; l++)t = { name: n[l].name, size: n[l].size }, this.plugins.video.create_video.call(this, e.isUpdate ? e.element : i.cloneNode(!1), n[l].url, e.inputWidth, e.inputHeight, e.align, t, e.isUpdate); this.closeLoading() }, setup_url: function () { try { const e = this.context.video; let t = e._linkValue; if (0 === t.length) return !1; if (/^$/.test(t)) { if (t = (new this._w.DOMParser).parseFromString(t, "text/html").querySelector("iframe").src, 0 === t.length) return !1 } if (/youtu\.?be/.test(t)) { if (/^http/.test(t) || (t = "https://" + t), t = t.replace("watch?v=", ""), /^\/\/.+\/embed\//.test(t) || (t = t.replace(t.match(/\/\/.+\//)[0], "//www.youtube.com/embed/").replace("&", "?&")), e._youtubeQuery.length > 0) if (/\?/.test(t)) { const n = t.split("?"); t = n[0] + "?" + e._youtubeQuery + "&" + n[1] } else t += "?" + e._youtubeQuery } else /vimeo\.com/.test(t) && (t.endsWith("/") && (t = t.slice(0, -1)), t = "https://player.vimeo.com/video/" + t.slice(t.lastIndexOf("/") + 1)); this.plugins.video.create_video.call(this, this.plugins.video.createIframeTag.call(this), t, e.inputX.value, e.inputY.value, e._align, null, this.context.dialog.updateModal) } catch (e) { throw Error('[SUNEDITOR.video.upload.fail] cause : "' + e.message + '"') } finally { this.closeLoading() } }, create_video: function (e, t, n, i, l, o, s) { this.context.resizing._resize_plugin = "video"; const a = this.context.video; let r = null, c = null, d = !1; if (s) { if ((e = a._element).src !== t) { d = !0; const n = /youtu\.?be/.test(t), i = /vimeo\.com/.test(t); if (!n && !i || /^iframe$/i.test(e.nodeName)) if (n || i || /^videoo$/i.test(e.nodeName)) e.src = t; else { const n = this.plugins.video.createVideoTag.call(this); n.src = t, e.parentNode.replaceChild(n, e), a._element = e = n } else { const n = this.plugins.video.createIframeTag.call(this); n.src = t, e.parentNode.replaceChild(n, e), a._element = e = n } } c = a._container, r = this.util.getParentElement(e, "FIGURE") } else d = !0, e.src = t, a._element = e, r = this.plugins.component.set_cover.call(this, e), c = this.plugins.component.set_container.call(this, r, "se-video-container"); a._cover = r, a._container = c; const u = this.plugins.resizing._module_getSizeX.call(this, a) !== (n || a._defaultSizeX) || this.plugins.resizing._module_getSizeY.call(this, a) !== (i || a._videoRatio), h = !s || u; a._resizing && (this.context.video._proportionChecked = a.proportion.checked, e.setAttribute("data-proportion", a._proportionChecked)); let p = !1; h && (p = this.plugins.video.applySize.call(this)), p && "center" === l || this.plugins.video.setAlign.call(this, null, e, r, c); let g = !0; if (s) a._resizing && this.context.resizing._rotateVertical && h && this.plugins.resizing.setTransformSize.call(this, e, null, null); else if (g = this.insertComponent(c, !1, !0, !this.options.mediaAutoSelect), !this.options.mediaAutoSelect) { const e = this.appendFormatTag(c, null); this.setRange(e, 0, e, 0) } g && (d && this.plugins.fileManager.setInfo.call(this, "video", e, this.functions.onVideoUpload, o, !0), s && (this.selectComponent(e, "video"), this.history.push(!1))), this.context.resizing._resize_plugin = "" }, _update_videoCover: function (e) { if (!e) return; const t = this.context.video; /^video$/i.test(e.nodeName) ? this.plugins.video._setTagAttrs.call(this, e) : this.plugins.video._setIframeAttrs.call(this, e); const n = this.util.getParentElement(e, this.util.isMediaComponent) || this.util.getParentElement(e, function (e) { return this.isWysiwygDiv(e.parentNode) }.bind(this.util)), i = e; t._element = e = e.cloneNode(!0); const l = t._cover = this.plugins.component.set_cover.call(this, e), o = t._container = this.plugins.component.set_container.call(this, l, "se-video-container"); try { const s = n.querySelector("figcaption"); let a = null; s && (a = this.util.createElement("DIV"), a.innerHTML = s.innerHTML, this.util.removeItem(s)); const r = (e.getAttribute("data-size") || e.getAttribute("data-origin") || "").split(","); this.plugins.video.applySize.call(this, r[0] || i.style.width || i.width || "", r[1] || i.style.height || i.height || ""); const c = this.util.getFormatElement(i); c && (t._align = c.style.textAlign || c.style.float), this.plugins.video.setAlign.call(this, null, e, l, o), this.util.isFormatElement(n) && n.childNodes.length > 0 ? (n.parentNode.insertBefore(o, n), this.util.removeItem(i), this.util.removeEmptyNode(n, null), 0 === n.children.length && (n.innerHTML = this.util.htmlRemoveWhiteSpace(n.innerHTML))) : n.parentNode.replaceChild(o, n), a && n.parentNode.insertBefore(a, o.nextElementSibling) } catch (e) { console.warn("[SUNEDITOR.video.error] Maybe the video tag is nested.", e) } this.plugins.fileManager.setInfo.call(this, "video", e, this.functions.onVideoUpload, null, !0) }, onModifyMode: function (e, t) { const n = this.context.video; n._element = e, n._cover = this.util.getParentElement(e, "FIGURE"), n._container = this.util.getParentElement(e, this.util.isMediaComponent), n._align = e.style.float || e.getAttribute("data-align") || "none", e.style.float = "", t && (n._element_w = t.w, n._element_h = t.h, n._element_t = t.t, n._element_l = t.l); let i, l, o = n._element.getAttribute("data-size") || n._element.getAttribute("data-origin"); o ? (o = o.split(","), i = o[0], l = o[1]) : t && (i = t.w, l = t.h), n._origin_w = i || e.style.width || e.width || "", n._origin_h = l || e.style.height || e.height || "" }, openModify: function (e) { const t = this.context.video; if (t.videoUrlFile && (t._linkValue = t.preview.textContent = t.videoUrlFile.value = t._element.src || (t._element.querySelector("source") || "").src || ""), t.modal.querySelector('input[name="suneditor_video_radio"][value="' + t._align + '"]').checked = !0, t._resizing) { this.plugins.resizing._module_setModifyInputSize.call(this, t, this.plugins.video); const e = t._videoRatio = this.plugins.resizing._module_getSizeY.call(this, t); this.plugins.video.setVideoRatioSelect.call(this, e) || (t.inputY.value = t._onlyPercentage ? this.util.getNumber(e, 2) : e) } e || this.plugins.dialog.open.call(this, "video", !0) }, setVideoRatioSelect: function (e) { let t = !1; const n = this.context.video, i = n.videoRatioOption.options; /%$/.test(e) || n._onlyPercentage ? e = this.util.getNumber(e, 2) / 100 + "" : (!this.util.isNumber(e) || 1 * e >= 1) && (e = ""), n.inputY.placeholder = ""; for (let l = 0, o = i.length; l < o; l++)i[l].value === e ? (t = i[l].selected = !0, n.inputY.placeholder = e ? 100 * e + "%" : "") : i[l].selected = !1; return t }, checkFileInfo: function () { this.plugins.fileManager.checkInfo.call(this, "video", ["iframe", "video"], this.functions.onVideoUpload, this.plugins.video._update_videoCover.bind(this), !0) }, resetFileInfo: function () { this.plugins.fileManager.resetInfo.call(this, "video", this.functions.onVideoUpload) }, applySize: function (e, t) { const n = this.context.video; return e || (e = n.inputX.value || this.options.videoWidth), t || (t = n.inputY.value || this.options.videoHeight), n._onlyPercentage || /%$/.test(e) || !e ? (this.plugins.video.setPercentSize.call(this, e || "100%", t || (/%$/.test(n._videoRatio) ? n._videoRatio : n._defaultRatio)), !0) : (e && "auto" !== e || t && "auto" !== t ? this.plugins.video.setSize.call(this, e, t || n._videoRatio || n._defaultRatio, !1) : this.plugins.video.setAutoSize.call(this), !1) }, sizeRevert: function () { this.plugins.resizing._module_sizeRevert.call(this, this.context.video) }, setSize: function (e, t, n, i) { const l = this.context.video, o = /^(rw|lw)$/.test(i), s = /^(th|bh)$/.test(i); s || (e = this.util.getNumber(e, 0)), o || (t = this.util.isNumber(t) ? t + l.sizeUnit : t || ""), s || (l._element.style.width = e ? e + l.sizeUnit : ""), o || (l._cover.style.paddingBottom = l._cover.style.height = t), s || /%$/.test(e) || (l._cover.style.width = "", l._container.style.width = ""), o || /%$/.test(t) ? l._element.style.height = "" : l._element.style.height = t, n || l._element.removeAttribute("data-percentage"), this.plugins.resizing._module_saveCurrentSize.call(this, l) }, setAutoSize: function () { this.plugins.video.setPercentSize.call(this, 100, this.context.video._defaultRatio) }, setOriginSize: function (e) { const t = this.context.video; t._element.removeAttribute("data-percentage"), this.plugins.resizing.resetTransform.call(this, t._element), this.plugins.video.cancelPercentAttr.call(this); const n = ((e ? t._element.getAttribute("data-size") : "") || t._element.getAttribute("data-origin") || "").split(","); if (n) { const e = n[0], i = n[1]; t._onlyPercentage || /%$/.test(e) && (/%$/.test(i) || !/\d/.test(i)) ? this.plugins.video.setPercentSize.call(this, e, i) : this.plugins.video.setSize.call(this, e, i), this.plugins.resizing._module_saveCurrentSize.call(this, t) } }, setPercentSize: function (e, t) { const n = this.context.video; t = !t || /%$/.test(t) || this.util.getNumber(t, 0) ? this.util.isNumber(t) ? t + n.sizeUnit : t || n._defaultRatio : this.util.isNumber(t) ? t + "%" : t, n._container.style.width = this.util.isNumber(e) ? e + "%" : e, n._container.style.height = "", n._cover.style.width = "100%", n._cover.style.height = t, n._cover.style.paddingBottom = t, n._element.style.width = "100%", n._element.style.height = "100%", n._element.style.maxWidth = "", "center" === n._align && this.plugins.video.setAlign.call(this, null, null, null, null), n._element.setAttribute("data-percentage", e + "," + t), this.plugins.resizing._module_saveCurrentSize.call(this, n) }, cancelPercentAttr: function () { const e = this.context.video; e._cover.style.width = "", e._cover.style.height = "", e._cover.style.paddingBottom = "", e._container.style.width = "", e._container.style.height = "", this.util.removeClass(e._container, this.context.video._floatClassRegExp), this.util.addClass(e._container, "__se__float-" + e._align), "center" === e._align && this.plugins.video.setAlign.call(this, null, null, null, null) }, setAlign: function (e, t, n, i) { const l = this.context.video; e || (e = l._align), t || (t = l._element), n || (n = l._cover), i || (i = l._container), n.style.margin = e && "none" !== e ? "auto" : "0", /%$/.test(t.style.width) && "center" === e ? (i.style.minWidth = "100%", n.style.width = i.style.width, n.style.height = n.style.height, n.style.paddingBottom = /%$/.test(n.style.height) ? this.util.getNumber(this.util.getNumber(n.style.height, 2) / 100 * this.util.getNumber(n.style.width, 2), 2) + "%" : n.style.height) : (i.style.minWidth = "", n.style.width = this.context.resizing._rotateVertical ? t.style.height || t.offsetHeight : t.style.width || "100%", n.style.paddingBottom = n.style.height), this.util.hasClass(i, "__se__float-" + e) || (this.util.removeClass(i, l._floatClassRegExp), this.util.addClass(i, "__se__float-" + e)), t.setAttribute("data-align", e) }, init: function () { const e = this.context.video; e.videoInputFile && (e.videoInputFile.value = ""), e.videoUrlFile && (e._linkValue = e.preview.textContent = e.videoUrlFile.value = ""), e.videoInputFile && e.videoUrlFile && (e.videoUrlFile.removeAttribute("disabled"), e.preview.style.textDecoration = ""), e._origin_w = this.options.videoWidth, e._origin_h = this.options.videoHeight, e.modal.querySelector('input[name="suneditor_video_radio"][value="none"]').checked = !0, e._resizing && (e.inputX.value = this.options.videoWidth === e._defaultSizeX ? "" : this.options.videoWidth, e.inputY.value = this.options.videoHeight === e._defaultSizeY ? "" : this.options.videoHeight, e.proportion.checked = !0, e.proportion.disabled = !0, this.plugins.video.setVideoRatioSelect.call(this, e._defaultRatio)) } }, y = { name: "audio", display: "dialog", add: function (e) { e.addModule([r.a, p.a, _.a]); const t = e.context, n = t.audio = { _infoList: [], _infoIndex: 0, _uploadFileLength: 0, focusElement: null, targetSelect: null, _origin_w: e.options.audioWidth, _origin_h: e.options.audioHeight, _linkValue: "", _element: null, _cover: null, _container: null }; let i = this.setDialog(e); n.modal = i, n.audioInputFile = i.querySelector("._se_audio_files"), n.audioUrlFile = i.querySelector(".se-input-url"), n.focusElement = n.audioInputFile || n.audioUrlFile, n.preview = i.querySelector(".se-link-preview"); let l = this.setController(e); n.controller = l, i.querySelector("form").addEventListener("submit", this.submit.bind(e)), n.audioInputFile && i.querySelector(".se-dialog-files-edge-button").addEventListener("click", this._removeSelectedFiles.bind(n.audioInputFile, n.audioUrlFile, n.preview)), n.audioInputFile && n.audioUrlFile && n.audioInputFile.addEventListener("change", this._fileInputChange.bind(n)), l.addEventListener("click", this.onClick_controller.bind(e)), n.audioUrlFile && n.audioUrlFile.addEventListener("input", this._onLinkPreview.bind(n.preview, n, e.options.linkProtocol)), t.dialog.modal.appendChild(i), t.element.relative.appendChild(l), i = null, l = null }, setDialog: function (e) { const t = e.options, n = e.lang, i = e.util.createElement("DIV"); i.className = "se-dialog-content", i.style.display = "none"; let l = '", i.innerHTML = l, i }, setController: function (e) { const t = e.lang, n = e.icons, i = e.util.createElement("DIV"); return i.className = "se-controller se-controller-link", i.innerHTML = '
", i }, _fileInputChange: function () { this.audioInputFile.value ? (this.audioUrlFile.setAttribute("disabled", !0), this.preview.style.textDecoration = "line-through") : (this.audioUrlFile.removeAttribute("disabled"), this.preview.style.textDecoration = "") }, _removeSelectedFiles: function (e, t) { this.value = "", e && (e.removeAttribute("disabled"), t.style.textDecoration = "") }, _createAudioTag: function () { const e = this.util.createElement("AUDIO"); this.plugins.audio._setTagAttrs.call(this, e); const t = this.context.audio._origin_w, n = this.context.audio._origin_h; return e.setAttribute("origin-size", t + "," + n), e.style.cssText = (t ? "width:" + t + "; " : "") + (n ? "height:" + n + ";" : ""), e }, _setTagAttrs: function (e) { e.setAttribute("controls", !0); const t = this.options.audioTagAttrs; if (t) for (let n in t) this.util.hasOwn(t, n) && e.setAttribute(n, t[n]) }, _onLinkPreview: function (e, t, n) { const i = n.target.value.trim(); e._linkValue = this.textContent = i ? t && -1 === i.indexOf("://") && 0 !== i.indexOf("#") ? t + i : -1 === i.indexOf("://") ? "/" + i : i : "" }, fileTags: ["audio"], select: function (e) { this.plugins.audio.onModifyMode.call(this, e) }, destroy: function (e) { e = e || this.context.audio._element; const t = this.util.getParentElement(e, this.util.isComponent) || e, n = 1 * e.getAttribute("data-index"), i = t.previousElementSibling || t.nextElementSibling, l = t.parentNode; this.util.removeItem(t), this.plugins.audio.init.call(this), this.controllersOff(), l !== this.context.element.wysiwyg && this.util.removeItemAllParents(l, (function (e) { return 0 === e.childNodes.length }), null), this.focusEdge(i), this.plugins.fileManager.deleteInfo.call(this, "audio", n, this.functions.onAudioUpload), this.history.push(!1) }, checkFileInfo: function () { this.plugins.fileManager.checkInfo.call(this, "audio", ["audio"], this.functions.onAudioUpload, this.plugins.audio.updateCover.bind(this), !1) }, resetFileInfo: function () { this.plugins.fileManager.resetInfo.call(this, "audio", this.functions.onAudioUpload) }, on: function (e) { const t = this.context.audio; e ? t._element ? (this.context.dialog.updateModal = !0, t._linkValue = t.preview.textContent = t.audioUrlFile.value = t._element.src, t.audioInputFile && this.options.audioMultipleFile && t.audioInputFile.removeAttribute("multiple")) : t.audioInputFile && this.options.audioMultipleFile && t.audioInputFile.removeAttribute("multiple") : (this.plugins.audio.init.call(this), t.audioInputFile && this.options.audioMultipleFile && t.audioInputFile.setAttribute("multiple", "multiple")) }, open: function () { this.plugins.dialog.open.call(this, "audio", "audio" === this.currentControllerName) }, submit: function (e) { const t = this.context.audio; e.preventDefault(), e.stopPropagation(); try { t.audioInputFile && t.audioInputFile.files.length > 0 ? (this.showLoading(), this.plugins.audio.submitAction.call(this, t.audioInputFile.files)) : t.audioUrlFile && t._linkValue.length > 0 && (this.showLoading(), this.plugins.audio.setupUrl.call(this, t._linkValue)) } catch (e) { throw this.closeLoading(), Error('[SUNEDITOR.audio.submit.fail] cause : "' + e.message + '"') } finally { this.plugins.dialog.close.call(this) } return !1 }, submitAction: function (e) { if (0 === e.length) return; let t = 0, n = []; for (let i = 0, l = e.length; i < l; i++)/audio/i.test(e[i].type) && (n.push(e[i]), t += e[i].size); const i = this.options.audioUploadSizeLimit; if (i > 0) { let e = 0; const n = this.context.audio._infoList; for (let t = 0, i = n.length; t < i; t++)e += 1 * n[t].size; if (t + e > i) { this.closeLoading(); const n = "[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: " + i / 1e3 + "KB"; return void (("function" != typeof this.functions.onAudioUploadError || this.functions.onAudioUploadError(n, { limitSize: i, currentSize: e, uploadSize: t }, this)) && this.functions.noticeOpen(n)) } } const l = this.context.audio; l._uploadFileLength = n.length; const o = { isUpdate: this.context.dialog.updateModal, element: l._element }; if ("function" == typeof this.functions.onAudioUploadBefore) { const e = this.functions.onAudioUploadBefore(n, o, this, function (e) { e && this._w.Array.isArray(e.result) ? this.plugins.audio.register.call(this, o, e) : this.plugins.audio.upload.call(this, o, e) }.bind(this)); if (void 0 === e) return; if (!e) return void this.closeLoading(); "object" == typeof e && e.length > 0 && (n = e) } this.plugins.audio.upload.call(this, o, n) }, error: function (e, t) { if (this.closeLoading(), "function" != typeof this.functions.onAudioUploadError || this.functions.onAudioUploadError(e, t, this)) throw this.functions.noticeOpen(e), Error("[SUNEDITOR.plugin.audio.exception] response: " + e) }, upload: function (e, t) { if (!t) return void this.closeLoading(); if ("string" == typeof t) return void this.plugins.audio.error.call(this, t, null); const n = this.options.audioUploadUrl, i = this.context.dialog.updateModal ? 1 : t.length, l = new FormData; for (let e = 0; e < i; e++)l.append("file-" + e, t[e]); this.plugins.fileManager.upload.call(this, n, this.options.audioUploadHeader, l, this.plugins.audio.callBack_upload.bind(this, e), this.functions.onAudioUploadError) }, callBack_upload: function (e, t) { if ("function" == typeof this.functions.audioUploadHandler) this.functions.audioUploadHandler(t, e, this); else { const n = JSON.parse(t.responseText); n.errorMessage ? this.plugins.audio.error.call(this, n.errorMessage, n) : this.plugins.audio.register.call(this, e, n) } }, register: function (e, t) { const n = t.result; for (let t, i, l = 0, o = n.length; l < o; l++)i = e.isUpdate ? e.element : this.plugins.audio._createAudioTag.call(this), t = { name: n[l].name, size: n[l].size }, this.plugins.audio.create_audio.call(this, i, n[l].url, t, e.isUpdate); this.closeLoading() }, setupUrl: function (e) { try { if (0 === e.length) return !1; this.plugins.audio.create_audio.call(this, this.plugins.audio._createAudioTag.call(this), e, null, this.context.dialog.updateModal) } catch (e) { throw Error('[SUNEDITOR.audio.audio.fail] cause : "' + e.message + '"') } finally { this.closeLoading() } }, create_audio: function (e, t, n, i) { const l = this.context.audio; if (i) { if (l._element && (e = l._element), !e || e.src === t) return void this.selectComponent(e, "audio"); e.src = t, this.selectComponent(e, "audio") } else { e.src = t; const n = this.plugins.component.set_cover.call(this, e), i = this.plugins.component.set_container.call(this, n, ""); if (!this.insertComponent(i, !1, !0, !this.options.mediaAutoSelect)) return void this.focus(); if (!this.options.mediaAutoSelect) { const e = this.appendFormatTag(i, null); this.setRange(e, 0, e, 0) } } this.plugins.fileManager.setInfo.call(this, "audio", e, this.functions.onAudioUpload, n, !1), i && this.history.push(!1) }, updateCover: function (e) { const t = this.context.audio; this.plugins.audio._setTagAttrs.call(this, e); const n = this.util.getParentElement(e, this.util.isMediaComponent) || this.util.getParentElement(e, function (e) { return this.isWysiwygDiv(e.parentNode) }.bind(this.util)), i = e; t._element = e = e.cloneNode(!1); const l = this.plugins.component.set_cover.call(this, e), o = this.plugins.component.set_container.call(this, l, "se-audio-container"); try { this.util.isFormatElement(n) && n.childNodes.length > 0 ? (n.parentNode.insertBefore(o, n), this.util.removeItem(i), this.util.removeEmptyNode(n, null), 0 === n.children.length && (n.innerHTML = this.util.htmlRemoveWhiteSpace(n.innerHTML))) : n.parentNode.replaceChild(o, n) } catch (e) { console.warn("[SUNEDITOR.audio.error] Maybe the audio tag is nested.", e) } this.plugins.fileManager.setInfo.call(this, "audio", e, this.functions.onAudioUpload, null, !1) }, onModifyMode: function (e) { const t = this.context.audio; this.setControllerPosition(t.controller, e, "bottom", { left: 0, top: 0 }), this.controllersOn(t.controller, e, this.plugins.audio.onControllerOff.bind(this, e), "audio"), this.util.addClass(e, "active"), t._element = e, t._cover = this.util.getParentElement(e, "FIGURE"), t._container = this.util.getParentElement(e, this.util.isComponent) }, openModify: function (e) { if (this.context.audio.audioUrlFile) { const e = this.context.audio; e._linkValue = e.preview.textContent = e.audioUrlFile.value = e._element.src } e || this.plugins.dialog.open.call(this, "audio", !0) }, onClick_controller: function (e) { e.stopPropagation(); const t = e.target.getAttribute("data-command"); t && (e.preventDefault(), /update/.test(t) ? this.plugins.audio.openModify.call(this, !1) : this.plugins.audio.destroy.call(this, this.context.audio._element), this.controllersOff()) }, onControllerOff: function (e) { this.util.removeClass(e, "active"), this.context.audio.controller.style.display = "none" }, init: function () { if (this.context.dialog.updateModal) return; const e = this.context.audio; e.audioInputFile && (e.audioInputFile.value = ""), e.audioUrlFile && (e._linkValue = e.preview.textContent = e.audioUrlFile.value = ""), e.audioInputFile && e.audioUrlFile && (e.audioUrlFile.removeAttribute("disabled"), e.preview.style.textDecoration = ""), e._element = null } }, C = { name: "math", display: "dialog", add: function (e) { e.addModule([r.a]); const t = e.context; t.math = { focusElement: null, previewElement: null, fontSizeElement: null, defaultFontSize: "", _mathExp: null }; let n = this.setDialog(e); t.math.modal = n, t.math.focusElement = n.querySelector(".se-math-exp"), t.math.previewElement = n.querySelector(".se-math-preview"), t.math.fontSizeElement = n.querySelector(".se-math-size"), t.math.focusElement.addEventListener("keyup", this._renderMathExp.bind(e, t.math), !1), t.math.focusElement.addEventListener("change", this._renderMathExp.bind(e, t.math), !1), t.math.fontSizeElement.addEventListener("change", function (e) { this.fontSize = e.target.value }.bind(t.math.previewElement.style), !1); let i = this.setController_MathButton(e); t.math.mathController = i, t.math._mathExp = null, n.querySelector("form").addEventListener("submit", this.submit.bind(e), !1), i.addEventListener("click", this.onClick_mathController.bind(e)), t.math.previewElement.style.fontSize = t.math.defaultFontSize, t.dialog.modal.appendChild(n), t.element.relative.appendChild(i), n = null, i = null }, setDialog: function (e) { const t = e.lang, n = e.util.createElement("DIV"), i = e.options.mathFontSize; let l = i[0].value; n.className = "se-dialog-content", n.style.display = "none"; let o = '", e.context.math.defaultFontSize = l, n.innerHTML = o, n }, setController_MathButton: function (e) { const t = e.lang, n = e.util.createElement("DIV"); return n.className = "se-controller se-controller-link", n.innerHTML = '
", n }, open: function () { this.plugins.dialog.open.call(this, "math", "math" === this.currentControllerName) }, managedTags: function () { return { className: "katex", method: function (e) { if (!e.getAttribute("data-exp") || !this.options.katex) return; const t = this._d.createRange().createContextualFragment(this.plugins.math._renderer.call(this, this.util.HTMLDecoder(e.getAttribute("data-exp")))); e.innerHTML = t.querySelector(".katex").innerHTML } } }, _renderer: function (e) { const t = this.options.katex; return t.src.renderToString(e, t.options) }, _renderMathExp: function (e, t) { e.previewElement.innerHTML = this.plugins.math._renderer.call(this, t.target.value) }, submit: function (e) { this.showLoading(), e.preventDefault(), e.stopPropagation(); const t = function () { if (0 === this.context.math.focusElement.value.trim().length) return !1; const e = this.context.math, t = e.focusElement.value, n = e.previewElement.querySelector(".katex"); if (!n) return !1; if (n.className = "__se__katex " + n.className, n.setAttribute("contenteditable", !1), n.setAttribute("data-exp", this.util.HTMLEncoder(t)), n.setAttribute("data-font-size", e.fontSizeElement.value), n.style.fontSize = e.fontSizeElement.value, this.context.dialog.updateModal) { const t = this.util.getParentElement(e._mathExp, ".katex"); t.parentNode.replaceChild(n, t), this.setRange(n, 0, n, 1) } else { const e = this.getSelectedElements(); if (e.length > 1) { const t = this.util.createElement(e[0].nodeName); if (t.appendChild(n), !this.insertNode(t, null, !0)) return !1 } else if (!this.insertNode(n, null, !0)) return !1; const t = this.util.createTextNode(this.util.zeroWidthSpace); n.parentNode.insertBefore(t, n.nextSibling), this.setRange(n, 0, n, 1) } return e.focusElement.value = "", e.fontSizeElement.value = "1em", e.previewElement.style.fontSize = "1em", e.previewElement.innerHTML = "", !0 }.bind(this); try { t() && (this.plugins.dialog.close.call(this), this.history.push(!1)) } catch (e) { this.plugins.dialog.close.call(this) } finally { this.closeLoading() } return !1 }, active: function (e) { if (e) { if (e.getAttribute("data-exp")) return this.controllerArray.indexOf(this.context.math.mathController) < 0 && (this.setRange(e, 0, e, 1), this.plugins.math.call_controller.call(this, e)), !0 } else this.controllerArray.indexOf(this.context.math.mathController) > -1 && this.controllersOff(); return !1 }, on: function (e) { if (e) { const e = this.context.math; if (e._mathExp) { const t = this.util.HTMLDecoder(e._mathExp.getAttribute("data-exp")), n = e._mathExp.getAttribute("data-font-size") || "1em"; this.context.dialog.updateModal = !0, e.focusElement.value = t, e.fontSizeElement.value = n, e.previewElement.innerHTML = this.plugins.math._renderer.call(this, t), e.previewElement.style.fontSize = n } } else this.plugins.math.init.call(this) }, call_controller: function (e) { this.context.math._mathExp = e; const t = this.context.math.mathController; this.setControllerPosition(t, e, "bottom", { left: 0, top: 0 }), this.controllersOn(t, e, "math") }, onClick_mathController: function (e) { e.stopPropagation(); const t = e.target.getAttribute("data-command") || e.target.parentNode.getAttribute("data-command"); t && (e.preventDefault(), /update/.test(t) ? (this.context.math.focusElement.value = this.util.HTMLDecoder(this.context.math._mathExp.getAttribute("data-exp")), this.plugins.dialog.open.call(this, "math", !0)) : (this.util.removeItem(this.context.math._mathExp), this.context.math._mathExp = null, this.focus(), this.history.push(!1)), this.controllersOff()) }, init: function () { const e = this.context.math; e.mathController.style.display = "none", e._mathExp = null, e.focusElement.value = "", e.previewElement.innerHTML = "" } }, w = n("JhlZ"), x = n.n(w), E = { blockquote: { name: "blockquote", display: "command", add: function (e, t) { e.context.blockquote = { targetButton: t, tag: e.util.createElement("BLOCKQUOTE") } }, active: function (e) { if (e) { if (/blockquote/i.test(e.nodeName)) return this.util.addClass(this.context.blockquote.targetButton, "active"), !0 } else this.util.removeClass(this.context.blockquote.targetButton, "active"); return !1 }, action: function () { const e = this.util.getParentElement(this.getSelectionNode(), "blockquote"); e ? this.detachRangeFormatElement(e, null, null, !1, !1) : this.applyRangeFormatElement(this.context.blockquote.tag.cloneNode(!1)) } }, align: { name: "align", display: "submenu", add: function (e, t) { const n = e.icons, i = e.context; i.align = { targetButton: t, _alignList: null, currentAlign: "", defaultDir: e.options.rtl ? "right" : "left", icons: { justify: n.align_justify, left: n.align_left, right: n.align_right, center: n.align_center } }; let l = this.setSubmenu(e), o = l.querySelector("ul"); o.addEventListener("click", this.pickup.bind(e)), i.align._alignList = o.querySelectorAll("li button"), e.initMenuTarget(this.name, t, l), l = null, o = null }, setSubmenu: function (e) { const t = e.lang, n = e.icons, i = e.util.createElement("DIV"), l = "left" === e.context.align.defaultDir, o = '", s = '"; return i.className = "se-submenu se-list-layer se-list-align", i.innerHTML = '
' + (l ? o : s) + '" + (l ? s : o) + '
", i }, active: function (e) { const t = this.context.align, n = t.targetButton, i = n.firstElementChild; if (e) { if (this.util.isFormatElement(e)) { const l = e.style.textAlign; if (l) return this.util.changeElement(i, t.icons[l] || t.icons[t.defaultDir]), n.setAttribute("data-focus", l), !0 } } else this.util.changeElement(i, t.icons[t.defaultDir]), n.removeAttribute("data-focus"); return !1 }, on: function () { const e = this.context.align, t = e._alignList, n = e.targetButton.getAttribute("data-focus") || e.defaultDir; if (n !== e.currentAlign) { for (let e = 0, i = t.length; e < i; e++)n === t[e].getAttribute("data-value") ? this.util.addClass(t[e], "active") : this.util.removeClass(t[e], "active"); e.currentAlign = n } }, pickup: 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; if (!n) return; const i = this.context.align.defaultDir, l = this.getSelectedElements(); for (let e = 0, t = l.length; e < t; e++)this.util.setStyle(l[e], "textAlign", n === i ? "" : n); this.effectNode = null, this.submenuOff(), this.focus(), this.history.push(!1) } }, font: { name: "font", display: "submenu", add: function (e, t) { const n = e.context; n.font = { targetText: t.querySelector(".txt"), targetTooltip: t.parentNode.querySelector(".se-tooltip-text"), _fontList: null, currentFont: "" }; let i = this.setSubmenu(e); i.querySelector(".se-list-inner").addEventListener("click", this.pickup.bind(e)), n.font._fontList = i.querySelectorAll("ul li button"), e.initMenuTarget(this.name, t, i), i = null }, setSubmenu: function (e) { const t = e.options, n = e.lang, i = e.util.createElement("DIV"); let l, o, s, a; i.className = "se-submenu se-list-layer se-list-font-family"; let r = t.font ? t.font : ["Arial", "Comic Sans MS", "Courier New", "Impact", "Georgia", "tahoma", "Trebuchet MS", "Verdana"], c = '
"; for (s = 0, a = r.length; s < a; s++)l = r[s], o = l.split(",")[0], c += '"; return c += "
", i.innerHTML = c, i }, 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) } 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 < i; e++)n === t[e].getAttribute("data-value") ? this.util.addClass(t[e], "active") : this.util.removeClass(t[e], "active"); e.currentFont = n } }, pickup: function (e) { if (!/^BUTTON$/i.test(e.target.tagName)) return !1; e.preventDefault(), e.stopPropagation(); const t = e.target.getAttribute("data-value"); if (t) { const e = this.util.createElement("SPAN"); e.style.fontFamily = t, this.nodeChange(e, ["font-family"], null, null) } else this.nodeChange(null, ["font-family"], ["span"], !0); this.submenuOff() } }, fontSize: { name: "fontSize", display: "submenu", add: function (e, t) { const n = e.context; n.fontSize = { targetText: t.querySelector(".txt"), _sizeList: null, currentSize: "" }; let i = this.setSubmenu(e), l = i.querySelector("ul"); l.addEventListener("click", this.pickup.bind(e)), n.fontSize._sizeList = l.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null, l = null }, setSubmenu: function (e) { const t = e.options, n = e.lang, i = e.util.createElement("DIV"); i.className = "se-submenu se-list-layer se-list-font-size"; const l = t.fontSize ? t.fontSize : [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72]; let o = '
"; for (let e, n = 0, i = t.fontSizeUnit, s = l.length; n < s; n++)e = l[n], o += '"; return o += "
", i.innerHTML = o, i }, active: function (e) { if (e) { if (e.style && e.style.fontSize.length > 0) return this.util.changeTxt(this.context.fontSize.targetText, e.style.fontSize), !0 } else this.util.changeTxt(this.context.fontSize.targetText, this.hasFocus ? this.wwComputedStyle.fontSize : this.lang.toolbar.fontSize); return !1 }, on: function () { const e = this.context.fontSize, t = e._sizeList, n = e.targetText.textContent; if (n !== e.currentSize) { for (let e = 0, i = t.length; e < i; e++)n === t[e].getAttribute("data-value") ? this.util.addClass(t[e], "active") : this.util.removeClass(t[e], "active"); e.currentSize = n } }, pickup: function (e) { if (!/^BUTTON$/i.test(e.target.tagName)) return !1; e.preventDefault(), e.stopPropagation(); const t = e.target.getAttribute("data-value"); if (t) { const e = this.util.createElement("SPAN"); e.style.fontSize = t, this.nodeChange(e, ["font-size"], null, null) } else this.nodeChange(null, ["font-size"], ["span"], !0); this.submenuOff() } }, fontColor: l, hiliteColor: o, horizontalRule: { name: "horizontalRule", display: "submenu", add: function (e, t) { e.context.horizontalRule = { currentHR: null }; let n = this.setSubmenu(e); n.querySelector("ul").addEventListener("click", this.horizontalRulePick.bind(e)), e.initMenuTarget(this.name, t, n), n = null }, setSubmenu: function (e) { const t = e.lang, n = e.util.createElement("DIV"); return n.className = "se-submenu se-list-layer se-list-line", n.innerHTML = '
', n }, active: function (e) { if (e) { if (/HR/i.test(e.nodeName)) return this.context.horizontalRule.currentHR = e, this.util.hasClass(e, "on") || (this.util.addClass(e, "on"), this.controllersOn("hr", this.util.removeClass.bind(this.util, e, "on"))), !0 } else this.util.hasClass(this.context.horizontalRule.currentHR, "on") && this.controllersOff(); return !1 }, appendHr: function (e) { const t = this.util.createElement("HR"); return t.className = e, this.focus(), this.insertComponent(t, !1, !0, !1) }, 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; if (!n) return; const i = this.plugins.horizontalRule.appendHr.call(this, "__se__" + n); i && (this.setRange(i, 0, i, 0), this.submenuOff()) } }, list: { name: "list", display: "submenu", add: function (e, t) { const n = e.context; n.list = { targetButton: t, _list: null, currentList: "", icons: { bullets: e.icons.list_bullets, number: e.icons.list_number } }; let i = this.setSubmenu(e), l = i.querySelector("ul"); l.addEventListener("click", this.pickup.bind(e)), n.list._list = l.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null, l = null }, setSubmenu: function (e) { const t = e.lang, n = e.util.createElement("DIV"); return n.className = "se-submenu se-list-layer", n.innerHTML = '
", n }, active: function (e) { const t = this.context.list.targetButton, n = t.firstElementChild, i = this.util; if (e) { if (i.isList(e)) { const l = e.nodeName; return t.setAttribute("data-focus", l), i.addClass(t, "active"), /UL/i.test(l) ? i.changeElement(n, this.context.list.icons.bullets) : i.changeElement(n, this.context.list.icons.number), !0 } } else t.removeAttribute("data-focus"), i.changeElement(n, this.context.list.icons.number), i.removeClass(t, "active"); return !1 }, on: function () { const e = this.context.list, t = e._list, n = e.targetButton.getAttribute("data-focus") || ""; if (n !== e.currentList) { for (let e = 0, i = t.length; e < i; e++)n === t[e].getAttribute("data-command") ? this.util.addClass(t[e], "active") : this.util.removeClass(t[e], "active"); e.currentList = n } }, editList: function (e, t, n) { let i = this.getRange(), l = t || this.getSelectedElementsAndComponents(!1); if (0 === l.length) { if (t) return; if (i = this.getRange_addLine(i, null), l = this.getSelectedElementsAndComponents(!1), 0 === l.length) return } const o = this.util; o.sortByDepth(l, !0); let s = l[0], a = l[l.length - 1], r = !o.isListCell(s) && !o.isComponent(s) || s.previousElementSibling ? s.previousElementSibling : s.parentNode.previousElementSibling, c = !o.isListCell(a) && !o.isComponent(a) || a.nextElementSibling ? a.nextElementSibling : a.parentNode.nextElementSibling; const d = { sc: i.startContainer, so: i.startOffset, ec: i.endContainer, eo: i.endOffset }; let u = !0; for (let e = 0, t = l.length; e < t; e++)if (!o.isList(o.getRangeFormatElement(l[e], function (t) { return this.getRangeFormatElement(t) && t !== l[e] }.bind(o)))) { u = !1; break } if (!u || r && s.tagName === r.tagName && e === r.tagName.toUpperCase() || c && a.tagName === c.tagName && e === c.tagName.toUpperCase()) { const t = r ? r.parentNode : r, n = c ? c.parentNode : c; r = t && !o.isWysiwygDiv(t) && t.nodeName === e ? t : r, c = n && !o.isWysiwygDiv(n) && n.nodeName === e ? n : c; const i = r && r.tagName === e, s = c && c.tagName === e; let a = i ? r : o.createElement(e), d = null, u = null, h = null, p = null; const g = function (e) { return !this.isComponent(e) && !this.isList(e) }.bind(o); for (let t, n, s, r, c, p, m, f, _, b = 0, v = l.length; b < v; b++)if (n = l[b], 0 !== n.childNodes.length || o._isIgnoreNodeChange(n)) { if (r = l[b + 1], c = n.parentNode, p = r ? r.parentNode : null, s = o.isListCell(n), _ = o.isRangeFormatElement(c) ? c : null, m = s && !o.isWysiwygDiv(c) ? c.parentNode : c, f = s && !o.isWysiwygDiv(c) ? !r || o.isListCell(m) ? c : c.nextSibling : n.nextSibling, t = o.createElement("LI"), o.copyFormatAttributes(t, n), o.isComponent(n)) { const e = /^HR$/i.test(n.nodeName); e || (t.innerHTML = " "), t.innerHTML += n.outerHTML, e && (t.innerHTML += " ") } else { const e = n.childNodes; for (; e[0];)t.appendChild(e[0]) } a.appendChild(t), r || (u = a), r && m === p && !o.isRangeFormatElement(f) || (d || (d = a), i && r && m === p || r && o.isList(p) && p === c || a.parentNode !== m && m.insertBefore(a, f)), o.removeItem(n), i && null === h && (h = a.children.length - 1), r && (o.getRangeFormatElement(p, g) !== o.getRangeFormatElement(c, g) || o.isList(p) && o.isList(c) && o.getElementDepth(p) !== o.getElementDepth(c)) && (a = o.createElement(e)), _ && 0 === _.children.length && o.removeItem(_) } else o.removeItem(n); h && (d = d.children[h]), s && (p = a.children.length - 1, a.innerHTML += c.innerHTML, u = a.children[p], o.removeItem(c)) } else { if (n) for (let e = 0, t = l.length; e < t; e++)for (let n = e - 1; n >= 0; n--)if (l[n].contains(l[e])) { l.splice(e, 1), e--, t--; break } const t = o.getRangeFormatElement(s), i = t && t.tagName === e; let a, r; const c = function (e) { return !this.isComponent(e) }.bind(o); i || (r = o.createElement(e)); for (let t, s, d = 0, u = l.length; d < u; d++)s = o.getRangeFormatElement(l[d], c), s && o.isList(s) && (t ? t !== s ? (n && o.isListCell(s.parentNode) ? this.plugins.list._detachNested.call(this, a.f) : this.detachRangeFormatElement(a.f[0].parentNode, a.f, r, !1, !0), s = l[d].parentNode, i || (r = o.createElement(e)), t = s, a = { r: t, f: [o.getParentElement(l[d], "LI")] }) : a.f.push(o.getParentElement(l[d], "LI")) : (t = s, a = { r: t, f: [o.getParentElement(l[d], "LI")] }), d === u - 1 && (n && o.isListCell(s.parentNode) ? this.plugins.list._detachNested.call(this, a.f) : this.detachRangeFormatElement(a.f[0].parentNode, a.f, r, !1, !0))) } return this.effectNode = null, d }, _detachNested: function (e) { const t = e[0], n = e[e.length - 1], i = n.nextElementSibling, l = t.parentNode, o = l.parentNode.nextElementSibling, s = l.parentNode.parentNode; for (let t = 0, n = e.length; t < n; t++)s.insertBefore(e[t], o); if (i && l.children.length > 0) { const e = l.cloneNode(!1), t = l.childNodes, o = this.util.getPositionIndex(i); for (; t[o];)e.appendChild(t[o]); n.appendChild(e) } 0 === l.children.length && this.util.removeItem(l), this.util.mergeSameTags(s); const a = this.util.getEdgeChildNodes(t, n); return { cc: t.parentNode, sc: a.sc, ec: a.ec } }, editInsideList: function (e, t) { const n = (t = t || this.getSelectedElements().filter(function (e) { return this.isListCell(e) }.bind(this.util))).length; if (0 === n || !e && !this.util.isListCell(t[0].previousElementSibling) && !this.util.isListCell(t[n - 1].nextElementSibling)) return { sc: t[0], so: 0, ec: t[n - 1], eo: 1 }; let i = t[0].parentNode, l = t[n - 1], o = null; if (e) { if (i !== l.parentNode && this.util.isList(l.parentNode.parentNode) && l.nextElementSibling) for (l = l.nextElementSibling; l;)t.push(l), l = l.nextElementSibling; o = this.plugins.list.editList.call(this, i.nodeName.toUpperCase(), t, !0) } else { let e = this.util.createElement(i.nodeName), s = t[0].previousElementSibling, a = l.nextElementSibling; const r = { s: null, e: null, sl: i, el: i }; for (let l, o = 0, c = n; o < c; o++)l = t[o], l.parentNode !== i && (this.plugins.list._insiedList.call(this, i, e, s, a, r), i = l.parentNode, e = this.util.createElement(i.nodeName)), s = l.previousElementSibling, a = l.nextElementSibling, e.appendChild(l); this.plugins.list._insiedList.call(this, i, e, s, a, r); const c = this.util.getNodeFromPath(r.s, r.sl), d = this.util.getNodeFromPath(r.e, r.el); o = { sc: c, so: 0, ec: d, eo: d.textContent.length } } return o }, _insiedList: function (e, t, n, i, l) { let o = !1; if (n && t.tagName === n.tagName) { const e = t.children; for (; e[0];)n.appendChild(e[0]); t = n, o = !0 } if (i && t.tagName === i.tagName) { const e = i.children; for (; e[0];)t.appendChild(e[0]); const n = i.nextElementSibling; i.parentNode.removeChild(i), i = n } if (!o) { this.util.isListCell(n) && (e = n, i = null), e.insertBefore(t, i), l.s || (l.s = this.util.getNodePath(t.firstElementChild.firstChild, e, null), l.sl = e); const o = e.contains(l.sl) ? this.util.getNodePath(l.sl, e) : null; l.e = this.util.getNodePath(t.lastElementChild.firstChild, e, null), l.el = e, this.util.mergeSameTags(e, [l.s, l.e, o], !1), this.util.mergeNestedTags(e), o && (l.sl = this.util.getNodeFromPath(o, e)) } return t }, pickup: function (e) { e.preventDefault(), e.stopPropagation(); let t = e.target, n = ""; for (; !n && !/^UL$/i.test(t.tagName);)n = t.getAttribute("data-command"), t = t.parentNode; if (!n) return; const i = this.plugins.list.editList.call(this, n, null, !1); i && this.setRange(i.sc, i.so, i.ec, i.eo), this.submenuOff(), this.history.push(!1) } }, table: { name: "table", display: "submenu", add: function (e, t) { const n = e.context; let i = n.table = { _element: null, _tdElement: null, _trElement: null, _trElements: null, _tableXY: [], _maxWidth: !0, _fixedColumn: !1, _rtl: e.options.rtl, cellControllerTop: "top" === e.options.tableCellControllerPosition, 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, icons: { expansion: e.icons.expansion, reduction: e.icons.reduction } }, l = this.setSubmenu(e), o = l.querySelector(".se-controller-table-picker"); i.tableHighlight = l.querySelector(".se-table-size-highlighted"), i.tableUnHighlight = l.querySelector(".se-table-size-unhighlighted"), i.tableDisplay = l.querySelector(".se-table-size-display"), e.options.rtl && (i.tableHighlight.style.left = "167px"); let s = this.setController_table(e); i.tableController = s, i.resizeButton = s.querySelector("._se_table_resize"), i.resizeText = s.querySelector("._se_table_resize > span > span"), i.columnFixedButton = s.querySelector("._se_table_fixed_column"), i.headerButton = s.querySelector("._se_table_header"); let a = this.setController_tableEditor(e, i.cellControllerTop); i.resizeDiv = a, i.splitMenu = a.querySelector(".se-btn-group-sub"), i.mergeButton = a.querySelector("._se_table_merge_button"), i.splitButton = a.querySelector("._se_table_split_button"), i.insertRowAboveButton = a.querySelector("._se_table_insert_row_a"), i.insertRowBelowButton = a.querySelector("._se_table_insert_row_b"), o.addEventListener("mousemove", this.onMouseMove_tablePicker.bind(e, i)), o.addEventListener("click", this.appendTable.bind(e)), a.addEventListener("click", this.onClick_tableController.bind(e)), s.addEventListener("click", this.onClick_tableController.bind(e)), e.initMenuTarget(this.name, t, l), n.element.relative.appendChild(a), n.element.relative.appendChild(s), l = null, o = null, a = null, s = null, i = null }, setSubmenu: function (e) { const t = e.util.createElement("DIV"); return t.className = "se-submenu se-selector-table", t.innerHTML = '
1 x 1
', t }, setController_table: function (e) { const t = e.lang, n = e.icons, i = e.util.createElement("DIV"); return i.className = "se-controller se-controller-table", i.innerHTML = '
", i }, setController_tableEditor: function (e, t) { const n = e.lang, i = e.icons, l = e.util.createElement("DIV"); return l.className = "se-controller se-controller-table-cell", l.innerHTML = (t ? "" : '') + '
' + n.controller.VerticalSplit + '
' + n.controller.HorizontalSplit + "
", l }, 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; 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 = "
", t } { let n = ""; for (; t > 0;)n += "<" + e + ">
" + e + ">", t--; return n } }, onMouseMove_tablePicker: function (e, t) { t.stopPropagation(); let n = this._w.Math.ceil(t.offsetX / 18), i = this._w.Math.ceil(t.offsetY / 18); n = n < 1 ? 1 : n, i = i < 1 ? 1 : i, e._rtl && (e.tableHighlight.style.left = 18 * n - 13 + "px", n = 11 - n), e.tableHighlight.style.width = n + "em", e.tableHighlight.style.height = i + "em", this.util.changeTxt(e.tableDisplay, n + " x " + i), e._tableXY = [n, i] }, reset_table_picker: function () { if (!this.context.table.tableHighlight) return; const e = this.context.table.tableHighlight.style, t = this.context.table.tableUnHighlight.style; e.width = "1em", e.height = "1em", t.width = "10em", t.height = "10em", this.util.changeTxt(this.context.table.tableDisplay, "1 x 1"), this.submenuOff() }, init: function () { const e = this.context.table, t = this.plugins.table; if (t._removeEvents.call(this), t._selectedTable) { const e = t._selectedTable.querySelectorAll(".se-table-selected-cell"); for (let t = 0, n = e.length; t < n; t++)this.util.removeClass(e[t], "se-table-selected-cell") } t._toggleEditor.call(this, !0), e._element = null, e._tdElement = null, e._trElement = null, e._trElements = null, e._tableXY = [], e._maxWidth = !0, e._fixedColumn = !1, e._physical_cellCnt = 0, e._logical_cellCnt = 0, e._rowCnt = 0, e._rowIndex = 0, e._physical_cellIndex = 0, e._logical_cellIndex = 0, e._current_colSpan = 0, e._current_rowSpan = 0, t._shift = !1, t._selectedCells = null, t._selectedTable = null, t._ref = null, t._fixedCell = null, t._selectedCell = null, t._fixedCellName = null }, call_controller_tableEdit: function (e) { const t = this.plugins.table, n = this.context.table; if (!this.getSelection().isCollapsed && !t._selectedCell) return this.controllersOff(), void this.util.removeClass(e, "se-table-selected-cell"); const i = n._element || this.plugins.table._selectedTable || this.util.getParentElement(e, "TABLE"); n._maxWidth = this.util.hasClass(i, "se-table-size-100") || "100%" === i.style.width || !i.style.width && !this.util.hasClass(i, "se-table-size-auto"), n._fixedColumn = this.util.hasClass(i, "se-table-layout-fixed") || "fixed" === i.style.tableLayout, t.setTableStyle.call(this, n._maxWidth ? "width|column" : "width"), t.setPositionControllerTop.call(this, i), t.setPositionControllerDiv.call(this, e, t._shift), t._shift || this.controllersOn(n.resizeDiv, n.tableController, t.init.bind(this), e, "table") }, setPositionControllerTop: function (e) { this.setControllerPosition(this.context.table.tableController, e, "top", { left: 0, top: 0 }) }, setPositionControllerDiv: function (e, t) { const n = this.context.table, i = n.resizeDiv; this.plugins.table.setCellInfo.call(this, e, t), n.cellControllerTop ? this.setControllerPosition(i, n._element, "top", { left: n.tableController.offsetWidth, top: 0 }) : this.setControllerPosition(i, e, "bottom", { left: 0, top: 0 }) }, setCellInfo: function (e, t) { const n = this.context.table, i = n._element = this.plugins.table._selectedTable || this.util.getParentElement(e, "TABLE"); if (/THEAD/i.test(i.firstElementChild.nodeName) ? this.util.addClass(n.headerButton, "active") : this.util.removeClass(n.headerButton, "active"), t || 0 === n._physical_cellCnt) { n._tdElement !== e && (n._tdElement = e, n._trElement = e.parentNode); const t = n._trElements = i.rows, l = e.cellIndex; let o = 0; for (let e = 0, n = t[0].cells, i = t[0].cells.length; e < i; e++)o += n[e].colSpan; const s = n._rowIndex = n._trElement.rowIndex; n._rowCnt = t.length, n._physical_cellCnt = n._trElement.cells.length, n._logical_cellCnt = o, n._physical_cellIndex = l, n._current_colSpan = n._tdElement.colSpan - 1, n._current_rowSpan, n._trElement.cells[l].rowSpan; let a = [], r = []; for (let e, i, o = 0; o <= s; o++) { e = t[o].cells, i = 0; for (let t, c, d, u, h = 0, p = e.length; h < p; h++) { if (t = e[h], c = t.colSpan - 1, d = t.rowSpan - 1, u = h + i, r.length > 0) for (let e, t = 0; t < r.length; t++)e = r[t], e.row > o || (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), t--))); 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 += "
") } } 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; n < o; n++)t = l[n], e !== t.parentNode && (i.push(t), e = t.parentNode); for (let e = 0, l = i.length; e < l; e++)n.setCellInfo.call(this, i[e], !0), n.editRow.call(this, t) } else { const i = l[0].parentNode; if (t) { let o = null; for (let e = 0, t = l.length - 1; e < t; e++)if (i !== l[e + 1].parentNode) { o = l[e]; break } n.setCellInfo.call(this, "left" === t ? l[0] : o || l[0], !0), n.editCell.call(this, t, e) } else { const e = [l[0]]; for (let t, n = 1, o = l.length; n < o && (t = l[n], i === t.parentNode); n++)e.push(t); for (let i = 0, l = e.length; i < l; i++)n.setCellInfo.call(this, e[i], !0), n.editCell.call(this, t) } } t || n.init.call(this) } else n[o ? "editRow" : "editCell"].call(this, t); if (!t) { const e = l.children; for (let t = 0; t < e.length; t++)0 === e[t].children.length && (this.util.removeItem(e[t]), t--); 0 === l.children.length && this.util.removeItem(l) } }, editRow: function (e, t) { const n = this.context.table, i = !e, l = "up" === e, o = n._rowIndex, s = i || l ? o : o + n._current_rowSpan + 1, a = i ? -1 : 1, r = n._trElements; let c = n._logical_cellCnt; for (let e, t = 0, n = o + (i ? -1 : 0); t <= n; t++) { if (e = r[t].cells, 0 === e.length) return; for (let n, i, l = 0, o = e.length; l < o; l++)n = e[l].rowSpan, i = e[l].colSpan, n < 2 && i < 2 || n + t > s && 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; o < s; o++)e = n[o], l = o + i, i += e.colSpan - 1, e.rowSpan > 1 && (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 < r && (o = n[a], s = a + i, i += o.colSpan - 1, !(s >= l.index) || (a--, i--, i += l.cell.colSpan - 1, e.insertBefore(l.cell, o), l = t.shift(), l)); a++); if (l) { e.appendChild(l.cell); for (let n = 0, i = t.length; n < i; n++)e.appendChild(t[n].cell) } } } n._element.deleteRow(s) } else { n._element.insertRow(s).innerHTML = this.plugins.table.createCells.call(this, "td", c, !1) } i ? this.controllersOff() : this.plugins.table.setPositionControllerDiv.call(this, t || n._tdElement, !0) }, editCell: function (e, t) { const n = this.context.table, i = this.util, l = !e, o = "left" === e, s = n._current_colSpan, a = l || o ? n._logical_cellIndex : n._logical_cellIndex + s + 1, r = n._trElements; let c = [], d = [], u = 0; const h = [], p = []; for (let e, t, o, g, m, f, _ = 0, b = n._rowCnt; _ < b; _++) { e = r[_], t = a, m = !1, o = e.cells, f = 0; for (let e, n, r, g, b = 0, v = o.length; b < v && (e = o[b], e); b++)if (n = e.rowSpan - 1, r = e.colSpan - 1, l) { if (g = b + f, d.length > 0) { const e = !o[b + 1]; for (let t, n = 0; n < d.length; n++)t = d[n], t.row > _ || (g >= t.index ? (f += t.cs, g = b + f, t.rs -= 1, t.row = _ + 1, t.rs < 1 && (d.splice(n, 1), n--)) : e && (t.rs -= 1, t.row = _ + 1, t.rs < 1 && (d.splice(n, 1), n--))) } n > 0 && c.push({ rs: n, cs: r + 1, index: 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 && (g < t || g + r > t + 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; n < d.length; n++)e = d[n], t -= e.cs, e.rs -= 1, e.rs < 1 && (d.splice(n, 1), n--); m = !0 } } if (d = d.concat(c).sort((function (e, t) { return e.index - t.index })), c = [], !l) { if (u > 0) { 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; l < o; l++)n = h[l].parentNode, i.removeItem(h[l]), 0 === n.cells.length && (e || (e = i.getArrayIndex(r, n)), t = i.getArrayIndex(r, n), i.removeItem(n)); for (let n, l = 0, o = p.length; l < o; l++)n = p[l], n.cell.rowSpan = i.getOverlapRangeAtIndex(e, t, n.i, n.rs); this.controllersOff() } else this.plugins.table.setPositionControllerDiv.call(this, t || n._tdElement, !0) }, _closeSplitMenu: null, openSplitMenu: function () { this.util.addClass(this.context.table.splitButton, "on"), this.context.table.splitMenu.style.display = "inline-table", this.plugins.table._closeSplitMenu = function () { this.util.removeClass(this.context.table.splitButton, "on"), this.context.table.splitMenu.style.display = "none", this.removeDocEvent("click", this.plugins.table._closeSplitMenu), this.plugins.table._closeSplitMenu = null }.bind(this), this.addDocEvent("click", this.plugins.table._closeSplitMenu) }, splitCells: function (e) { const t = this.util, n = "vertical" === e, i = this.context.table, l = i._tdElement, o = i._trElements, s = i._trElement, a = i._logical_cellIndex, r = i._rowIndex, c = this.plugins.table.createCells.call(this, l.nodeName, 0, !0); if (n) { const e = l.colSpan; if (c.rowSpan = l.rowSpan, e > 1) 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; c < d; c++) { s = o[c].cells, r = 0; for (let i, o, d, u, h = 0, p = s.length; h < p; h++) { if (i = s[h], o = i.colSpan - 1, d = i.rowSpan - 1, u = h + r, n.length > 0) for (let e, t = 0; t < n.length; t++)e = n[t], e.row > c || (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), t--))); 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 < r; n++) { e = o[n].cells, t = 0; for (let l, o, s, c = 0, d = e.length; c < d && (s = c + t, !(s >= a)); c++)l = e[c], o = l.rowSpan - 1, o > 0 && o + n >= r && s < a && i.push({ index: s, cs: l.colSpan }), t += l.colSpan - 1 } const d = o[r], u = d.cells; let h = i.shift(); for (let e, t, n, l, o = 0, s = u.length, r = 0; o < s; o++) { if (n = o + r, e = u[o], t = e.colSpan - 1, l = n + t + 1, h && l >= 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; t++) { if (e = o[t].cells, 0 === e.length) return; for (let n = 0, i = e.length; n < i; n++)t + e[n].rowSpan - 1 >= r && (e[n].rowSpan += 1) } const n = i._physical_cellIndex, a = s.cells; for (let e = 0, t = a.length; e < t; e++)e !== n && (a[e].rowSpan += 1); s.parentNode.insertBefore(e, s.nextElementSibling) } } this.focusEdge(l), this.plugins.table.setPositionControllerDiv.call(this, l, !0) }, mergeCells: function () { const e = this.plugins.table, t = this.context.table, n = this.util, i = e._ref, l = e._selectedCells, o = l[0]; let s = null, a = null, r = i.ce - i.cs + 1, c = i.re - i.rs + 1, d = "", u = null; for (let e, t, i = 1, o = l.length; i < o; i++) { e = l[i], u !== e.parentNode && (u = e.parentNode), t = e.children; for (let e = 0, i = t.length; e < i; e++)n.isFormatElement(t[e]) && n.onlyZeroWidthSpace(t[e].textContent) && n.removeItem(t[e]); d += e.innerHTML, n.removeItem(e), 0 === u.cells.length && (s ? a = u : s = u, c -= 1) } if (s) { const e = t._trElements, i = n.getArrayIndex(e, s), l = n.getArrayIndex(e, a || s), o = []; for (let t, s = 0; s <= l; s++)if (t = e[s].cells, 0 !== t.length) for (let e, o, a = 0, r = t.length; a < r; a++)e = t[a], o = e.rowSpan - 1, o > 0 && 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 < t; e++)n.removeItem(o[e]) } o.innerHTML += d, o.colSpan = r, o.rowSpan = c, this.controllersOff(), e.setActiveButton.call(this, !0, !1), e.call_controller_tableEdit.call(this, o), n.addClass(o, "se-table-selected-cell"), this.focusEdge(o) }, toggleHeader: function () { const e = this.util, t = this.context.table.headerButton, n = e.hasClass(t, "active"), i = this.context.table._element; if (n) e.removeItem(i.querySelector("thead")); else { const t = e.createElement("THEAD"); t.innerHTML = "
", i.insertBefore(t, i.firstElementChild) } e.toggleClass(t, "active"), /TH/i.test(this.context.table._tdElement.nodeName) ? this.controllersOff() : this.plugins.table.setPositionControllerDiv.call(this, this.context.table._tdElement, !1) }, setTableStyle: function (e) { const t = this.context.table, n = t._element; let i, l, o, s; e.indexOf("width") > -1 && (i = t.resizeButton.firstElementChild, l = t.resizeText, t._maxWidth ? (o = t.icons.reduction, s = t.minText, t.columnFixedButton.style.display = "block", this.util.removeClass(n, "se-table-size-auto"), this.util.addClass(n, "se-table-size-100")) : (o = t.icons.expansion, s = t.maxText, t.columnFixedButton.style.display = "none", this.util.removeClass(n, "se-table-size-100"), this.util.addClass(n, "se-table-size-auto")), this.util.changeElement(i, o), this.util.changeTxt(l, s)), e.indexOf("column") > -1 && (t._fixedColumn ? (this.util.removeClass(n, "se-table-layout-auto"), this.util.addClass(n, "se-table-layout-fixed"), this.util.addClass(t.columnFixedButton, "active")) : (this.util.removeClass(n, "se-table-layout-fixed"), this.util.addClass(n, "se-table-layout-auto"), this.util.removeClass(t.columnFixedButton, "active"))) }, setActiveButton: function (e, t) { const n = this.context.table; /^TH$/i.test(e.nodeName) ? (n.insertRowAboveButton.setAttribute("disabled", !0), n.insertRowBelowButton.setAttribute("disabled", !0)) : (n.insertRowAboveButton.removeAttribute("disabled"), n.insertRowBelowButton.removeAttribute("disabled")), t && e !== t ? (n.splitButton.setAttribute("disabled", !0), n.mergeButton.removeAttribute("disabled")) : (n.splitButton.removeAttribute("disabled"), n.mergeButton.setAttribute("disabled", !0)) }, _bindOnSelect: null, _bindOffSelect: null, _bindOffShift: null, _selectedCells: null, _shift: !1, _fixedCell: null, _fixedCellName: null, _selectedCell: null, _selectedTable: null, _ref: null, _toggleEditor: function (e) { this.context.element.wysiwyg.setAttribute("contenteditable", e), e ? this.util.removeClass(this.context.element.wysiwyg, "se-disabled") : this.util.addClass(this.context.element.wysiwyg, "se-disabled") }, _offCellMultiSelect: function (e) { e.stopPropagation(); const t = this.plugins.table; t._shift ? t._initBind && (this._wd.removeEventListener("touchmove", t._initBind), t._initBind = null) : (t._removeEvents.call(this), t._toggleEditor.call(this, !0)), t._fixedCell && t._selectedTable && (t.setActiveButton.call(this, t._fixedCell, t._selectedCell), t.call_controller_tableEdit.call(this, t._selectedCell || t._fixedCell), t._selectedCells = t._selectedTable.querySelectorAll(".se-table-selected-cell"), t._selectedCell && t._fixedCell && this.focusEdge(t._selectedCell), t._shift || (t._fixedCell = null, t._selectedCell = null, t._fixedCellName = null)) }, _onCellMultiSelect: function (e) { this._antiBlur = !0; const t = this.plugins.table, n = this.util.getParentElement(e.target, this.util.isCell); if (t._shift) n === t._fixedCell ? t._toggleEditor.call(this, !0) : t._toggleEditor.call(this, !1); else if (!t._ref) { if (n === t._fixedCell) return; t._toggleEditor.call(this, !1) } n && n !== t._selectedCell && t._fixedCellName === n.nodeName && t._selectedTable === this.util.getParentElement(n, "TABLE") && (t._selectedCell = n, t._setMultiCells.call(this, t._fixedCell, n)) }, _setMultiCells: function (e, t) { const n = this.plugins.table, i = n._selectedTable.rows, l = this.util, o = n._selectedTable.querySelectorAll(".se-table-selected-cell"); for (let e = 0, t = o.length; e < t; e++)l.removeClass(o[e], "se-table-selected-cell"); if (e === t && (l.addClass(e, "se-table-selected-cell"), !n._shift)) return; let s = !0, a = [], r = []; const c = n._ref = { _i: 0, cs: null, ce: null, rs: null, re: null }; for (let n, o, d = 0, u = i.length; d < u; d++) { n = i[d].cells, o = 0; for (let i, u, h, p, g = 0, m = n.length; g < m; g++) { if (i = n[g], h = i.colSpan - 1, p = i.rowSpan - 1, u = g + o, a.length > 0) for (let e, t = 0; t < a.length; t++)e = a[t], e.row > d || (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), t--))); if (s) { if (i !== e && i !== t || (c.cs = null !== c.cs && c.cs < u ? c.cs : u, c.ce = null !== c.ce && c.ce > u + h ? c.ce : u + h, c.rs = null !== c.rs && c.rs < d ? c.rs : d, c.re = null !== c.re && c.re > d + 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.cs < u ? c.cs : u, t = c.ce > u + h ? c.ce : u + h, n = c.rs < d ? c.rs : d, o = c.re > d + 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._initBind && (this._wd.removeEventListener("touchmove", e._initBind), e._initBind = null), e._bindOnSelect && (this._wd.removeEventListener("mousedown", e._bindOnSelect), this._wd.removeEventListener("mousemove", e._bindOnSelect), e._bindOnSelect = null), e._bindOffSelect && (this._wd.removeEventListener("mouseup", e._bindOffSelect), e._bindOffSelect = null), e._bindOffShift && (this._wd.removeEventListener("keyup", e._bindOffShift), e._bindOffShift = null) }, _initBind: null, onTableCellMultiSelect: function (e, t) { const n = this.plugins.table; n._removeEvents.call(this), this.controllersOff(), n._shift = t, n._fixedCell = e, n._fixedCellName = e.nodeName, n._selectedTable = this.util.getParentElement(e, "TABLE"); const i = n._selectedTable.querySelectorAll(".se-table-selected-cell"); for (let e = 0, t = i.length; e < t; e++)this.util.removeClass(i[e], "se-table-selected-cell"); this.util.addClass(e, "se-table-selected-cell"), n._bindOnSelect = n._onCellMultiSelect.bind(this), n._bindOffSelect = n._offCellMultiSelect.bind(this), t ? (n._bindOffShift = function () { this.controllersOn(this.context.table.resizeDiv, this.context.table.tableController, this.plugins.table.init.bind(this), e, "table"), n._ref || this.controllersOff() }.bind(this), this._wd.addEventListener("keyup", n._bindOffShift, !1), this._wd.addEventListener("mousedown", n._bindOnSelect, !1)) : this._wd.addEventListener("mousemove", n._bindOnSelect, !1), this._wd.addEventListener("mouseup", n._bindOffSelect, !1), n._initBind = n.init.bind(this), this._wd.addEventListener("touchmove", n._initBind, !1) }, onClick_tableController: function (e) { e.stopPropagation(); const t = e.target.getAttribute("data-command") ? e.target : e.target.parentNode; if (t.getAttribute("disabled")) return; const n = t.getAttribute("data-command"), i = t.getAttribute("data-value"), l = t.getAttribute("data-option"), o = this.plugins.table; if ("function" == typeof o._closeSplitMenu && (o._closeSplitMenu(), "onsplit" === n)) return; if (!n) return; e.preventDefault(); const s = this.context.table; switch (n) { case "insert": case "delete": o.editTable.call(this, i, l); break; case "header": o.toggleHeader.call(this); break; case "onsplit": o.openSplitMenu.call(this); break; case "split": o.splitCells.call(this, i); break; case "merge": o.mergeCells.call(this); break; case "resize": s._maxWidth = !s._maxWidth, o.setTableStyle.call(this, "width"), o.setPositionControllerTop.call(this, s._element), o.setPositionControllerDiv.call(this, s._tdElement, o._shift); break; case "layout": s._fixedColumn = !s._fixedColumn, o.setTableStyle.call(this, "column"), o.setPositionControllerTop.call(this, s._element), o.setPositionControllerDiv.call(this, s._tdElement, o._shift); break; case "remove": const e = s._element.parentNode; this.util.removeItem(s._element), this.controllersOff(), e !== this.context.element.wysiwyg && this.util.removeItemAllParents(e, (function (e) { return 0 === e.childNodes.length }), null), this.focus() }this.history.push(!1) } }, formatBlock: { name: "formatBlock", display: "submenu", add: function (e, t) { const n = e.context; n.formatBlock = { targetText: t.querySelector(".txt"), targetTooltip: t.parentNode.querySelector(".se-tooltip-text"), _formatList: null, currentFormat: "" }; let i = this.setSubmenu(e); i.querySelector("ul").addEventListener("click", this.pickUp.bind(e)), n.formatBlock._formatList = i.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null }, setSubmenu: function (e) { const t = e.options, n = e.lang.toolbar, i = e.util.createElement("DIV"); i.className = "se-submenu se-list-layer se-list-format"; const l = ["p", "div", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6"], o = t.formats && 0 !== t.formats.length ? t.formats : l; let s = '
'; for (let e, t, i, a, r, c, d, u = 0, h = o.length; u < h; u++)e = o[u], "string" == typeof e && l.indexOf(e) > -1 ? (t = e.toLowerCase(), i = "blockquote" === t ? "range" : "pre" === t ? "free" : "replace", r = /^h/.test(t) ? t.match(/\d+/)[0] : "", a = n["tag_" + (r ? "h" : t)] + r, d = "", c = "") : (t = e.tag.toLowerCase(), i = e.command, a = e.name || t, d = e.class, c = d ? ' class="' + d + '"' : ""), s += '"; return s += "
", i.innerHTML = s, i }, active: function (e) { let t = this.lang.toolbar.formats; const n = this.context.formatBlock.targetText; if (e) { if (this.util.isFormatElement(e)) { const i = this.context.formatBlock._formatList, l = e.nodeName.toLowerCase(), o = (e.className.match(/(\s|^)__se__format__[^\s]+/) || [""])[0].trim(); for (let e, n = 0, s = i.length; n < s; n++)if (e = i[n], l === e.getAttribute("data-value") && o === e.getAttribute("data-class")) { t = e.title; break } return this.util.changeTxt(n, t), n.setAttribute("data-value", l), n.setAttribute("data-class", o), !0 } } else this.util.changeTxt(n, t); return !1 }, on: function () { const e = this.context.formatBlock, t = e._formatList, n = e.targetText, i = (n.getAttribute("data-value") || "") + (n.getAttribute("data-class") || ""); if (i !== e.currentFormat) { for (let e, n = 0, l = t.length; n < l; n++)e = t[n], i === e.getAttribute("data-value") + e.getAttribute("data-class") ? this.util.addClass(e, "active") : this.util.removeClass(e, "active"); e.currentFormat = i } }, pickUp: function (e) { e.preventDefault(), e.stopPropagation(); let t = e.target, n = null, i = null, l = null, o = ""; for (; !n && !/UL/i.test(t.tagName);) { if (n = t.getAttribute("data-command"), i = t.getAttribute("data-value"), o = t.getAttribute("data-class"), n) { l = t.firstChild; break } t = t.parentNode } if (n) { if ("range" === n) { const e = l.cloneNode(!1); this.applyRangeFormatElement(e) } else { let e = this.getRange(), t = this.getSelectedElementsAndComponents(!1); if (0 === t.length && (e = this.getRange_addLine(e, null), t = this.getSelectedElementsAndComponents(!1), 0 === t.length)) return; const s = e.startOffset, a = e.endOffset, r = this.util; let c = t[0], d = t[t.length - 1]; const u = r.getNodePath(e.startContainer, c, null, null), h = r.getNodePath(e.endContainer, d, null, null), p = this.detachList(t, !1); p.sc && (c = p.sc), p.ec && (d = p.ec), this.setRange(r.getNodeFromPath(u, c), s, r.getNodeFromPath(h, d), a); const g = this.getSelectedElementsAndComponents(!1); if ("free" === n) { const e = g.length - 1; let t = g[e].parentNode, n = l.cloneNode(!1); const i = n; for (let i, o, s, a, c, d, u = e, h = !0; u >= 0; u--)if (i = g[u], i !== (g[u + 1] ? g[u + 1].parentNode : null)) { if (d = r.isComponent(i), o = d ? "" : i.innerHTML.replace(/(?!>)\s+(?=<)|\n/g, " "), s = r.getParentElement(i, (function (e) { return e.parentNode === t })), (t !== i.parentNode || d) && (r.isFormatElement(t) ? (t.parentNode.insertBefore(n, t.nextSibling), t = t.parentNode) : (t.insertBefore(n, s ? s.nextSibling : null), t = i.parentNode), a = n.nextSibling, a && n.nodeName === a.nodeName && r.isSameAttributes(n, a) && (n.innerHTML += " " + a.innerHTML, r.removeItem(a)), n = l.cloneNode(!1), h = !0), c = n.innerHTML, n.innerHTML = (h || !o || !c || / $/i.test(o) ? o : o + " ") + 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), o && (h = !1) } this.setRange(i, 0, i, 0) } else { for (let e, t, n = 0, s = g.length; n < s; n++)e = g[n], e.nodeName.toLowerCase() === i.toLowerCase() && (e.className.match(/(\s|^)__se__format__[^\s]+/) || [""])[0].trim() === o || r.isComponent(e) || (t = l.cloneNode(!1), r.copyFormatAttributes(t, e), t.innerHTML = e.innerHTML, e.parentNode.replaceChild(t, e)), 0 === n && (c = t || e), n === s - 1 && (d = t || e), t = null; this.setRange(r.getNodeFromPath(u, c), s, r.getNodeFromPath(h, d), a) } this.history.push(!1) } this.submenuOff() } } }, lineHeight: { name: "lineHeight", display: "submenu", add: function (e, t) { const n = e.context; n.lineHeight = { _sizeList: null, currentSize: -1 }; let i = this.setSubmenu(e), l = i.querySelector("ul"); l.addEventListener("click", this.pickup.bind(e)), n.lineHeight._sizeList = l.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null, l = null }, setSubmenu: function (e) { const t = e.options, n = e.lang, i = e.util.createElement("DIV"); i.className = "se-submenu se-list-layer"; const l = t.lineHeights ? t.lineHeights : [{ text: "1", value: 1 }, { text: "1.15", value: 1.15 }, { text: "1.5", value: 1.5 }, { text: "2", value: 2 }]; let o = '
"; for (let e, t = 0, n = l.length; t < n; t++)e = l[t], o += '"; return o += "
", i.innerHTML = o, i }, on: function () { const e = this.context.lineHeight, t = e._sizeList, n = this.util.getFormatElement(this.getSelectionNode()), i = n ? n.style.lineHeight + "" : ""; if (i !== e.currentSize) { for (let e = 0, n = t.length; e < n; e++)i === t[e].getAttribute("data-value") ? this.util.addClass(t[e], "active") : this.util.removeClass(t[e], "active"); e.currentSize = i } }, pickup: function (e) { if (!/^BUTTON$/i.test(e.target.tagName)) return !1; e.preventDefault(), e.stopPropagation(); const t = e.target.getAttribute("data-value") || "", n = this.getSelectedElements(); for (let e = 0, i = n.length; e < i; e++)n[e].style.lineHeight = t; this.submenuOff(), this.history.push(!1) } }, template: s, paragraphStyle: { name: "paragraphStyle", display: "submenu", add: function (e, t) { const n = e.context; n.paragraphStyle = { _classList: null }; let i = this.setSubmenu(e); i.querySelector("ul").addEventListener("click", this.pickUp.bind(e)), n.paragraphStyle._classList = i.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null }, setSubmenu: function (e) { const t = e.options, n = e.util.createElement("DIV"); n.className = "se-submenu se-list-layer se-list-format"; const i = e.lang.menu, l = { spaced: { name: i.spaced, class: "__se__p-spaced", _class: "" }, bordered: { name: i.bordered, class: "__se__p-bordered", _class: "" }, neon: { name: i.neon, class: "__se__p-neon", _class: "" } }, o = t.paragraphStyles && 0 !== t.paragraphStyles.length ? t.paragraphStyles : ["spaced", "bordered", "neon"]; let s = '
'; for (let e, t, n, i, a = 0, r = o.length; a < r; a++) { if (e = o[a], "string" == typeof e) { const t = l[e.toLowerCase()]; if (!t) continue; e = t } t = e.name, n = e.class ? ' class="' + e.class + '"' : "", i = e._class, s += '" } return s += "
", n.innerHTML = s, n }, on: function () { const e = this.context.paragraphStyle._classList, t = this.util.getFormatElement(this.getSelectionNode()); for (let n = 0, i = e.length; n < i; n++)this.util.hasClass(t, e[n].getAttribute("data-value")) ? this.util.addClass(e[n], "active") : this.util.removeClass(e[n], "active") }, pickUp: function (e) { e.preventDefault(), e.stopPropagation(); let t = e.target, n = null; for (; !/^UL$/i.test(t.tagName) && (n = t.getAttribute("data-value"), !n);)t = t.parentNode; if (!n) return; let i = this.getSelectedElements(); if (0 === i.length && (this.getRange_addLine(this.getRange(), null), i = this.getSelectedElements(), 0 === i.length)) return; const l = this.util.hasClass(t, "active") ? this.util.removeClass.bind(this.util) : this.util.addClass.bind(this.util); for (let e = 0, t = i.length; e < t; e++)l(i[e], n); this.submenuOff(), this.history.push(!1) } }, textStyle: { name: "textStyle", display: "submenu", add: function (e, t) { const n = e.context; n.textStyle = { _styleList: null }; let i = this.setSubmenu(e), l = i.querySelector("ul"); l.addEventListener("click", this.pickup.bind(e)), n.textStyle._styleList = i.querySelectorAll("li button"), e.initMenuTarget(this.name, t, i), i = null, l = null }, setSubmenu: function (e) { const t = e.options, n = e.util.createElement("DIV"); n.className = "se-submenu se-list-layer se-list-format"; const i = { code: { name: e.lang.menu.code, class: "__se__t-code", tag: "code" }, translucent: { name: e.lang.menu.translucent, style: "opacity: 0.5;", tag: "span" }, shadow: { name: e.lang.menu.shadow, class: "__se__t-shadow", tag: "span" } }, l = t.textStyles ? t.textStyles : e._w.Object.keys(i); let o = '
'; for (let e, t, n, s, a, r, c, d = 0, u = l.length; d < u; d++) { if (e = l[d], s = "", r = "", a = [], "string" == typeof e) { const t = i[e.toLowerCase()]; if (!t) continue; e = t } n = e.name, t = e.tag || "span", c = e._class, e.style && (s += ' style="' + e.style + '"', r += e.style.replace(/:[^;]+(;|$)\s*/g, ","), a.push("style")), e.class && (s += ' class="' + e.class + '"', r += "." + e.class.trim().replace(/\s+/g, ",."), a.push("class")), r = r.replace(/,$/, ""), o += '" } return o += "
", n.innerHTML = o, n }, on: function () { const e = this.util, t = this.context.textStyle._styleList, n = this.getSelectionNode(); for (let i, l, o, s = 0, a = t.length; s < a; s++) { i = t[s], l = i.getAttribute("data-value").split(","); for (let t, s, a = 0; a < l.length; a++) { for (t = n, o = !1; t && !e.isFormatElement(t) && !e.isComponent(t);) { if (t.nodeName.toLowerCase() === i.getAttribute("data-command").toLowerCase() && (s = l[a], /^\./.test(s) ? e.hasClass(t, s.replace(/^\./, "")) : t.style[s])) { o = !0; break } t = t.parentNode } if (!o) break } o ? e.addClass(i, "active") : e.removeClass(i, "active") } }, pickup: function (e) { e.preventDefault(), e.stopPropagation(); let t = e.target, n = null, i = null; for (; !n && !/UL/i.test(t.tagName);) { if (n = t.getAttribute("data-command"), n) { i = t.firstChild; break } t = t.parentNode } if (!n) return; const l = i.style.cssText.replace(/:.+(;|$)/g, ",").split(","); l.pop(); const o = i.classList; for (let e = 0, t = o.length; e < t; e++)l.push("." + o[e]); const s = this.util.hasClass(t, "active") ? null : i.cloneNode(!1), a = s ? null : [i.nodeName]; this.nodeChange(s, l, a, !0), this.submenuOff() } }, link: u, image: b, video: v, audio: y, math: C, imageGallery: { name: "imageGallery", add: function (e) { e.addModule([x.a]); e.context.imageGallery = { title: e.lang.toolbar.imageGallery, url: e.options.imageGalleryUrl, header: e.options.imageGalleryHeader, listClass: "se-image-list", itemTemplateHandler: this.drawItems, selectorHandler: this.setImage.bind(e), columnSize: 4 } }, open: function (e) { this.plugins.fileBrowser.open.call(this, "imageGallery", e) }, drawItems: function (e) { const t = e.src.split("/").pop(); return '
' + (e.name || t) + "
" }, setImage: function (e) { this.callPlugin("image", function () { const t = { name: e.parentNode.querySelector(".__se__img_name").textContent, size: 0 }; this.context.image._altText = e.alt, this.plugins.image.create_image.call(this, e.src, null, this.context.image._origin_w, this.context.image._origin_h, "none", t) }.bind(this), null) } } }, S = { rtl: { italic: '', indent: '', outdent: '', list_bullets: '', list_number: '', link: '', unlink: '' }, redo: '', undo: '', bold: '', underline: '', italic: '', strike: '', subscript: '', superscript: '', erase: '', indent: '', outdent: '', expansion: '', reduction: '', code_view: '', preview: '', print: '', template: '', line_height: '', paragraph_style: '', text_style: '', save: '', blockquote: '', arrow_down: '', align_justify: '', align_left: '', align_right: '', align_center: '', font_color: '', highlight_color: '', list_bullets: '', list_number: '', table: '', horizontal_rule: '', show_blocks: '', cancel: '', image: '', video: '', link: '', math: '', unlink: '', table_header: '', merge_cell: '', split_cell: '', caption: '', edit: '', delete: '', modify: '', revert: '', auto_size: '', insert_row_below: '', insert_row_above: '', insert_column_left: '', insert_column_right: '', delete_row: '', delete_column: '', fixed_column_width: '', rotate_left: '', rotate_right: '', mirror_horizontal: '', mirror_vertical: '', checked: '', line_break: '', audio: '', image_gallery: '', bookmark: '', download: '', more_text: '', more_paragraph: '', more_plus: '', more_horizontal: '', more_vertical: '', attachment: '', map: '', magic_stick: '', empty_file: '' }, N = n("P6u4"), T = n.n(N); const k = { _d: null, _w: null, isIE: null, isIE_Edge: null, isOSX_IOS: null, _propertiesInit: function () { this._d || (this._d = document, this._w = window, this.isIE = navigator.userAgent.indexOf("Trident") > -1, this.isIE_Edge = navigator.userAgent.indexOf("Trident") > -1 || navigator.appVersion.indexOf("Edge") > -1, this.isOSX_IOS = /(Mac|iPhone|iPod|iPad)/.test(navigator.platform)) }, _allowedEmptyNodeList: ".se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas", _HTMLConvertor: function (e) { const t = { "&": "&", " ": " ", "'": "'", '"': """, "<": "<", ">": ">" }; return e.replace(/&|\u00A0|'|"|<|>/g, (function (e) { return "string" == typeof t[e] ? t[e] : e })) }, zeroWidthSpace: String.fromCharCode(8203), zeroWidthRegExp: new RegExp(String.fromCharCode(8203), "g"), onlyZeroWidthRegExp: new RegExp("^" + String.fromCharCode(8203) + "+$"), onlyZeroWidthSpace: function (e) { return "string" != typeof e && (e = e.textContent), "" === e || this.onlyZeroWidthRegExp.test(e) }, getXMLHttpRequest: function () { if (!this._w.ActiveXObject) return this._w.XMLHttpRequest ? new XMLHttpRequest : null; try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { return null } } }, createElement: function (e) { return this._d.createElement(e) }, createTextNode: function (e) { return this._d.createTextNode(e || "") }, HTMLEncoder: function (e) { const t = { "<": "$lt;", ">": "$gt;" }; return e.replace(/<|>/g, (function (e) { return "string" == typeof t[e] ? t[e] : e })) }, HTMLDecoder: function (e) { const t = { "$lt;": "<", "$gt;": ">" }; return e.replace(/\$lt;|\$gt;/g, (function (e) { return "string" == typeof t[e] ? t[e] : e })) }, hasOwn: function (e, t) { return this._hasOwn.call(e, t) }, _hasOwn: Object.prototype.hasOwnProperty, 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; t < n; t++)s += e[t] + (t < n - 1 ? "|" : ")"); const a = new this._w.RegExp("(^|.*[\\/])" + s + "(\\.[^\\/]+)?." + t + "(?:\\?.*|;.*)?$", "i"), r = new this._w.RegExp(".+\\." + t + "(?:\\?.*|;.*)?$", "i"); for (let e = this._d.getElementsByTagName(l), t = 0; t < e.length; t++)r.test(e[t][o]) && i.push(e[t]); for (let e = 0; e < i.length; e++) { let t = i[e][o].match(a); if (t) { n = t[0]; break } } if ("" === n && (n = i.length > 0 ? 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 }, getPageStyle: function (e) { let t = ""; const n = (e || this._d).styleSheets; for (let e, i = 0, l = n.length; i < l; i++) { try { e = n[i].cssRules } catch (e) { continue } if (e) for (let n = 0, i = e.length; n < i; n++)t += e[n].cssText } return t }, getIframeDocument: function (e) { let t = e.contentWindow || e.contentDocument; return t.document && (t = t.document), t }, getAttributesToString: function (e, t) { if (!e.attributes) return ""; const n = e.attributes; let i = ""; for (let e = 0, l = n.length; e < l; e++)t && t.indexOf(n[e].name) > -1 || (i += n[e].name + '="' + n[e].value + '" '); return i }, getByteLength: function (e) { if (!e || !e.toString) return 0; e = e.toString(); const t = this._w.encodeURIComponent; let n, i; return this.isIE_Edge ? (i = this._w.unescape(t(e)).length, n = 0, null !== t(e).match(/(%0A|%0D)/gi) && (n = t(e).match(/(%0A|%0D)/gi).length), i + n) : (i = new this._w.TextEncoder("utf-8").encode(e).length, n = 0, null !== t(e).match(/(%0A|%0D)/gi) && (n = t(e).match(/(%0A|%0D)/gi).length), i + n) }, isWysiwygDiv: function (e) { return e && 1 === e.nodeType && (this.hasClass(e, "se-wrapper-wysiwyg") || /^BODY$/i.test(e.nodeName)) }, isNonEditable: function (e) { return e && 1 === e.nodeType && "false" === e.getAttribute("contenteditable") }, isTextStyleElement: function (e) { return e && 3 !== e.nodeType && /^(strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code)$/i.test(e.nodeName) }, isFormatElement: function (e) { return e && 1 === e.nodeType && (/^(P|DIV|H[1-6]|PRE|LI|TH|TD)$/i.test(e.nodeName) || this.hasClass(e, "(\\s|^)__se__format__replace_.+(\\s|$)|(\\s|^)__se__format__free_.+(\\s|$)")) && !this.isComponent(e) && !this.isWysiwygDiv(e) }, isRangeFormatElement: function (e) { return e && 1 === e.nodeType && (/^(BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(e.nodeName) || this.hasClass(e, "(\\s|^)__se__format__range_.+(\\s|$)")) }, isClosureRangeFormatElement: function (e) { return e && 1 === e.nodeType && (/^(TH|TD)$/i.test(e.nodeName) || this.hasClass(e, "(\\s|^)__se__format__range__closure_.+(\\s|$)")) }, isFreeFormatElement: function (e) { return e && 1 === e.nodeType && (/^PRE$/i.test(e.nodeName) || this.hasClass(e, "(\\s|^)__se__format__free_.+(\\s|$)")) && !this.isComponent(e) && !this.isWysiwygDiv(e) }, isClosureFreeFormatElement: function (e) { return e && 1 === e.nodeType && this.hasClass(e, "(\\s|^)__se__format__free__closure_.+(\\s|$)") }, isComponent: function (e) { return e && (/se-component/.test(e.className) || /^(TABLE|HR)$/.test(e.nodeName)) }, isUneditableComponent: function (e) { return e && this.hasClass(e, "__se__uneditable") }, isMediaComponent: function (e) { return e && /se-component/.test(e.className) }, isNotCheckingNode: function (e) { return e && /katex|__se__tag/.test(e.className) }, getFormatElement: function (e, t) { if (!e) return null; for (t || (t = function () { return !0 }); e;) { if (this.isWysiwygDiv(e)) return null; if (this.isRangeFormatElement(e) && e.firstElementChild, this.isFormatElement(e) && t(e)) return e; e = e.parentNode } return null }, getRangeFormatElement: function (e, t) { if (!e) return null; for (t || (t = function () { return !0 }); e;) { if (this.isWysiwygDiv(e)) return null; if (this.isRangeFormatElement(e) && !/^(THEAD|TBODY|TR)$/i.test(e.nodeName) && t(e)) return e; e = e.parentNode } return null }, getFreeFormatElement: function (e, t) { if (!e) return null; for (t || (t = function () { return !0 }); e;) { if (this.isWysiwygDiv(e)) return null; if (this.isFreeFormatElement(e) && t(e)) return e; e = e.parentNode } return null }, getClosureFreeFormatElement: function (e, t) { if (!e) return null; for (t || (t = function () { return !0 }); e;) { if (this.isWysiwygDiv(e)) return null; if (this.isClosureFreeFormatElement(e) && t(e)) return e; e = e.parentNode } return null }, copyTagAttributes: function (e, t) { t.style.cssText && (e.style.cssText += t.style.cssText); const n = t.classList; for (let t = 0, i = n.length; t < i; t++)this.addClass(e, n[t]); e.style.cssText || e.removeAttribute("style"), e.className.trim() || e.removeAttribute("class") }, copyFormatAttributes: function (e, t) { (t = t.cloneNode(!1)).className = t.className.replace(/(\s|^)__se__format__[^\s]+/g, ""), this.copyTagAttributes(e, t) }, getArrayItem: function (e, t, n) { if (!e || 0 === e.length) return null; t = t || function () { return !0 }; const i = []; for (let l, o = 0, s = e.length; o < s; o++)if (l = e[o], t(l)) { if (!n) return l; i.push(l) } return n ? i : null }, getArrayIndex: function (e, t) { let n = -1; for (let i = 0, l = e.length; i < l; i++)if (e[i] === t) { n = i; break } return n }, nextIdx: function (e, t) { let n = this.getArrayIndex(e, t); return -1 === n ? -1 : n + 1 }, prevIdx: function (e, t) { let n = this.getArrayIndex(e, t); return -1 === n ? -1 : n - 1 }, getPositionIndex: function (e) { let t = 0; for (; e = e.previousSibling;)t += 1; return t }, getNodePath: function (e, t, n) { const i = []; let l = !0; return this.getParentElement(e, function (e) { if (e === t && (l = !1), l && !this.isWysiwygDiv(e)) { if (n && 3 === e.nodeType) { let t = null, i = null; n.s = n.e = 0; let l = e.previousSibling; for (; l && 3 === l.nodeType;)i = l.textContent.replace(this.zeroWidthRegExp, ""), n.s += i.length, e.textContent = i + e.textContent, t = l, l = l.previousSibling, this.removeItem(t); let o = e.nextSibling; for (; o && 3 === o.nodeType;)i = o.textContent.replace(this.zeroWidthRegExp, ""), n.e += i.length, e.textContent += i, t = o, o = o.nextSibling, this.removeItem(t) } i.push(e) } return !1 }.bind(this)), i.map(this.getPositionIndex).reverse() }, getNodeFromPath: function (e, t) { let n, i = t; for (let t = 0, l = e.length; t < l && (n = i.childNodes, 0 !== n.length); t++)i = n.length <= e[t] ? n[n.length - 1] : n[e[t]]; return i }, isSameAttributes: function (e, t) { if (3 === e.nodeType && 3 === t.nodeType) return !0; if (3 === e.nodeType || 3 === t.nodeType) return !1; const n = e.style, i = t.style; let l = 0; for (let e = 0, t = n.length; e < t; e++)n[n[e]] === i[n[e]] && l++; const o = e.classList, s = t.classList, a = this._w.RegExp; let r = 0; for (let e = 0, t = o.length; e < t; e++)a("(s|^)" + o[e] + "(s|$)").test(s.value) && r++; return l === i.length && l === n.length && r === s.length && r === o.length }, isEmptyLine: function (e) { return !e || !e.parentNode || !e.querySelector("IMG, IFRAME, AUDIO, VIDEO, CANVAS, TABLE") && this.onlyZeroWidthSpace(e.textContent) }, isList: function (e) { return e && /^(OL|UL)$/i.test("string" == typeof e ? e : e.nodeName) }, isListCell: function (e) { return e && /^LI$/i.test("string" == typeof e ? e : e.nodeName) }, isTable: function (e) { return e && /^(TABLE|THEAD|TBODY|TR|TH|TD)$/i.test("string" == typeof e ? e : e.nodeName) }, isCell: function (e) { return e && /^(TD|TH)$/i.test("string" == typeof e ? e : e.nodeName) }, isBreak: function (e) { return e && /^BR$/i.test("string" == typeof e ? e : e.nodeName) }, isAnchor: function (e) { return e && /^A$/i.test("string" == typeof e ? e : e.nodeName) }, isMedia: function (e) { return e && /^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test("string" == typeof e ? e : e.nodeName) }, isNumber: function (e) { return !!e && /^-?\d+(\.\d+)?$/.test(e + "") }, getNumber: function (e, t) { if (!e) return 0; let n = (e + "").match(/-?\d+(\.\d+)?/); return n && n[0] ? (n = n[0], t < 0 ? 1 * n : 0 === t ? this._w.Math.round(1 * n) : 1 * (1 * n).toFixed(t)) : 0 }, getListChildren: function (e, t) { const n = []; return e && e.children && 0 !== e.children.length ? (t = t || function () { return !0 }, function i(l) { if (e !== l && t(l) && n.push(l), l.children) for (let e = 0, t = l.children.length; e < t; e++)i(l.children[e]) }(e), n) : n }, getListChildNodes: function (e, t) { const n = []; return e && 0 !== e.childNodes.length ? (t = t || function () { return !0 }, function i(l) { e !== l && t(l) && n.push(l); for (let e = 0, t = l.childNodes.length; e < t; e++)i(l.childNodes[e]) }(e), n) : n }, getElementDepth: function (e) { if (!e || this.isWysiwygDiv(e)) return -1; let t = 0; for (e = e.parentNode; e && !this.isWysiwygDiv(e);)t += 1, e = e.parentNode; return t }, compareElements: function (e, t) { let n = e, i = t; for (; n && i && n.parentNode !== i.parentNode;)n = n.parentNode, i = i.parentNode; if (!n || !i) return { ancestor: null, a: e, b: t, result: 0 }; const l = n.parentNode.childNodes, o = this.getArrayIndex(l, n), s = this.getArrayIndex(l, i); return { ancestor: n.parentNode, a: n, b: i, result: o > s ? 1 : o < s ? -1 : 0 } }, getParentElement: function (e, t) { let n; if ("function" == typeof t) n = t; else { let e; /^\./.test(t) ? (e = "className", t = t.split(".")[1]) : /^#/.test(t) ? (e = "id", t = "^" + t.split("#")[1] + "$") : /^:/.test(t) ? (e = "name", t = "^" + t.split(":")[1] + "$") : (e = "nodeName", t = "^" + t + "$"); const i = new this._w.RegExp(t, "i"); n = function (t) { return i.test(t[e]) } } for (; e && !n(e);) { if (this.isWysiwygDiv(e)) return null; e = e.parentNode } return e }, getChildElement: function (e, t, n) { let i; if ("function" == typeof t) i = t; else { let e; /^\./.test(t) ? (e = "className", t = t.split(".")[1]) : /^#/.test(t) ? (e = "id", t = "^" + t.split("#")[1] + "$") : /^:/.test(t) ? (e = "name", t = "^" + t.split(":")[1] + "$") : (e = "nodeName", t = "^" + ("text" === t ? "#" + t : t) + "$"); const n = new this._w.RegExp(t, "i"); i = function (t) { return n.test(t[e]) } } const l = this.getListChildNodes(e, (function (e) { return i(e) })); return l[n ? l.length - 1 : 0] }, getEdgeChildNodes: function (e, t) { if (e) { for (t || (t = e); e && 1 === e.nodeType && e.childNodes.length > 0 && !this.isBreak(e);)e = e.firstChild; for (; t && 1 === t.nodeType && t.childNodes.length > 0 && !this.isBreak(t);)t = t.lastChild; return { sc: e, ec: t || e } } }, getOffset: function (e, t) { let n = 0, i = 0, l = 3 === e.nodeType ? e.parentElement : e; const o = this.getParentElement(e, this.isWysiwygDiv.bind(this)); for (; l && !this.hasClass(l, "se-container") && l !== o;)n += l.offsetLeft, i += l.offsetTop, l = l.offsetParent; const s = t && /iframe/i.test(t.nodeName); return { left: n + (s ? t.parentElement.offsetLeft : 0), top: i - (o ? o.scrollTop : 0) + (s ? t.parentElement.offsetTop : 0) } }, getOverlapRangeAtIndex: function (e, t, n, i) { if (e <= i ? t < n : t > n) return 0; const l = (e > n ? e : n) - (t < i ? t : i); return (l < 0 ? -1 * l : l) + 1 }, changeTxt: function (e, t) { e && t && (e.textContent = t) }, changeElement: function (e, t) { if ("string" == typeof t) if (e.outerHTML) e.outerHTML = t; else { const n = this.createElement("DIV"); n.innerHTML = t, t = n.firstChild, e.parentNode.replaceChild(t, e) } else 1 === t.nodeType && e.parentNode.replaceChild(t, e) }, setStyle: function (e, t, n) { e.style[t] = n, n || e.style.cssText || e.removeAttribute("style") }, hasClass: function (e, t) { if (e) return new this._w.RegExp(t).test(e.className) }, addClass: function (e, t) { if (!e) return; new this._w.RegExp("(\\s|^)" + t + "(\\s|$)").test(e.className) || (e.className += (e.className.length > 0 ? " " : "") + t) }, removeClass: function (e, t) { if (!e) return; const n = new this._w.RegExp("(\\s|^)" + t + "(\\s|$)"); e.className = e.className.replace(n, " ").trim(), e.className.trim() || e.removeAttribute("class") }, toggleClass: function (e, t) { if (!e) return; let n = !1; const i = new this._w.RegExp("(\\s|^)" + t + "(\\s|$)"); return i.test(e.className) ? e.className = e.className.replace(i, " ").trim() : (e.className += " " + t, n = !0), e.className.trim() || e.removeAttribute("class"), n }, setDisabledButtons: function (e, t) { for (let n = 0, i = t.length; n < i; n++)t[n].disabled = e }, removeItem: function (e) { e && ("function" == typeof e.remove ? e.remove() : e.parentNode && e.parentNode.removeChild(e)) }, removeItemAllParents: function (e, t, n) { if (!e) return null; let i = null; return t || (t = function (e) { if (e === n || this.isComponent(e)) return !1; const t = e.textContent.trim(); return 0 === t.length || /^(\n|\u200B)+$/.test(t) }.bind(this)), function e(n) { if (!k.isWysiwygDiv(n)) { const l = n.parentNode; l && t(n) && (i = { sc: n.previousElementSibling, ec: n.nextElementSibling }, k.removeItem(n), e(l)) } }(e), i }, detachNestedList: function (e, t) { const n = this._deleteNestedList(e); let i, l, o; if (n) { i = n.cloneNode(!1), l = n.childNodes; const t = this.getPositionIndex(e); for (; l[t];)i.appendChild(l[t]) } else i = e; if (t) o = this.getListChildren(i, function (e) { return this.isListCell(e) && !e.previousElementSibling }.bind(this)); else { const t = this.getElementDepth(e) + 2; o = this.getListChildren(e, function (e) { return this.isListCell(e) && !e.previousElementSibling && this.getElementDepth(e) === t }.bind(this)) } for (let e = 0, t = o.length; e < t; e++)this._deleteNestedList(o[e]); return n && (n.parentNode.insertBefore(i, n.nextSibling), l && 0 === l.length && this.removeItem(n)), i === e ? i.parentNode : i }, _deleteNestedList: function (e) { const t = e.parentNode; let n, i, l, o, s, a = t, r = a.parentNode; for (; this.isListCell(r);) { for (o = this.getPositionIndex(e), n = r.nextElementSibling, i = r.parentNode, l = a; l;) { if (a = a.nextSibling, this.isList(l)) { for (s = l.childNodes; s[o];)i.insertBefore(s[o], n); 0 === s.length && this.removeItem(l) } else i.appendChild(l); l = a } a = i, r = i.parentNode } return 0 === t.children.length && this.removeItem(t), i }, splitElement: function (e, t, n) { const i = e.parentNode; let l, o, s, a = 0, r = !0; if ((!n || n < 0) && (n = 0), 3 === e.nodeType) { if (a = this.getPositionIndex(e), t >= 0) { e.splitText(t); const n = this.getNodeFromPath([a + 1], i); this.onlyZeroWidthSpace(n) && (n.data = this.zeroWidthSpace) } } else 1 === e.nodeType && (e.previousSibling ? e = e.previousSibling : this.getElementDepth(e) === n && (r = !1)); let c = e; for (; this.getElementDepth(c) > n;)for (a = this.getPositionIndex(c) + 1, c = c.parentNode, s = l, l = c.cloneNode(!1), o = c.childNodes, s && (this.isListCell(l) && this.isList(s) && s.firstElementChild ? (l.innerHTML = s.firstElementChild.innerHTML, k.removeItem(s.firstElementChild), s.children.length > 0 && l.appendChild(s)) : l.appendChild(s)); o[a];)l.appendChild(o[a]); c.childNodes.length <= 1 && (!c.firstChild || 0 === c.firstChild.textContent.length) && (c.innerHTML = " "); const d = c.parentNode; return r && (c = c.nextSibling), l ? (this.mergeSameTags(l, null, !1), this.mergeNestedTags(l, function (e) { return this.isList(e) }.bind(this)), l.childNodes.length > 0 ? d.insertBefore(l, c) : l = c, 0 === i.childNodes.length && this.removeItem(i), l) : c }, mergeSameTags: function (e, t, n) { const i = this, l = t ? t.length : 0; let o = null; return l && (o = this._w.Array.apply(null, new this._w.Array(l)).map(this._w.Number.prototype.valueOf, 0)), function e(s, a, r) { const c = s.childNodes; for (let d, u, h = 0, p = c.length; h < p && (d = c[h], u = c[h + 1], d); h++)if (n && i._isIgnoreNodeChange(d) || !n && (i.isTable(d) || i.isListCell(d) || i.isFormatElement(d) && !i.isFreeFormatElement(d))) (i.isTable(d) || i.isListCell(d)) && e(d, a + 1, h); else { if (1 === p && s.nodeName === d.nodeName && s.parentNode) { if (l) { let e, n, o, r, c; for (let u = 0; u < l; u++)if (e = t[u], e && e[a] === h) { for (n = d, o = s, r = a, c = !0; r >= 0;) { if (i.getArrayIndex(o.childNodes, n) !== e[r]) { c = !1; break } n = d.parentNode, o = n.parentNode, r-- } c && (e.splice(a, 1), e[a] = h) } } i.copyTagAttributes(d, s), s.parentNode.insertBefore(d, s), i.removeItem(s) } if (!u) { 1 === d.nodeType && e(d, a + 1, h); break } if (d.nodeName === u.nodeName && i.isSameAttributes(d, u) && d.href === u.href) { const e = d.childNodes; let n = 0; for (let t = 0, i = e.length; t < i; t++)e[t].textContent.length > 0 && n++; const s = d.lastChild, c = u.firstChild; let p = 0; if (s && c) { const e = 3 === s.nodeType && 3 === c.nodeType; p = s.textContent.length; let i = s.previousSibling; for (; i && 3 === i.nodeType;)p += i.textContent.length, i = i.previousSibling; if (n > 0 && 3 === s.nodeType && 3 === c.nodeType && (s.textContent.length > 0 || c.textContent.length > 0) && n--, l) { let i = null; for (let d = 0; d < l; d++)if (i = t[d], i && i[a] > h) { if (a > 0 && i[a - 1] !== r) continue; i[a] -= 1, i[a + 1] >= 0 && i[a] === h && (i[a + 1] += n, e && s && 3 === s.nodeType && c && 3 === c.nodeType && (o[d] += p)) } } } if (3 === d.nodeType) { if (p = d.textContent.length, d.textContent += u.textContent, l) { let e = null; for (let i = 0; i < l; i++)if (e = t[i], e && e[a] > h) { if (a > 0 && e[a - 1] !== r) continue; e[a] -= 1, e[a + 1] >= 0 && e[a] === h && (e[a + 1] += n, o[i] += p) } } } else d.innerHTML += u.innerHTML; i.removeItem(u), h-- } else 1 === d.nodeType && e(d, a + 1, h) } }(e, 0, 0), o }, mergeNestedTags: function (e, t) { "string" == typeof t ? t = function (e) { return this.test(e.tagName) }.bind(new this._w.RegExp("^(" + (t || ".+") + ")$", "i")) : "function" != typeof t && (t = function () { return !0 }), function e(n) { let i = n.children; if (1 === i.length && i[0].nodeName === n.nodeName && t(n)) { const e = i[0]; for (i = e.children; i[0];)n.appendChild(i[0]); n.removeChild(e) } for (let t = 0, i = n.children.length; t < i; t++)e(n.children[t]) }(e) }, removeEmptyNode: function (e, t) { const n = this; t && (t = n.getParentElement(t, (function (t) { return e === t.parentElement }))), function i(l) { if (n._notTextNode(l) || l === t || n.isNonEditable(l)) return 0; if (l === e || !n.onlyZeroWidthSpace(l.textContent) || l.firstChild && n.isBreak(l.firstChild) || l.querySelector(n._allowedEmptyNodeList)) { const e = l.children; for (let t = 0, l = e.length, o = 0; t < l; t++)e[t + o] && !n.isComponent(e[t + o]) && (o += i(e[t + o])) } else if (l.parentNode) return l.parentNode.removeChild(l), -1; return 0 }(e), 0 === e.childNodes.length && (e.innerHTML = " ") }, htmlRemoveWhiteSpace: function (e) { return e ? e.trim().replace(/<\/?(?!strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code)[^>^<]+>\s+(?=<)/gi, (function (e) { return e.trim() })) : "" }, sortByDepth: function (e, t) { const n = t ? 1 : -1, i = -1 * n; e.sort(function (e, t) { return this.isListCell(e) && this.isListCell(t) ? (e = this.getElementDepth(e)) > (t = this.getElementDepth(t)) ? n : e < t ? i : 0 : 0 }.bind(this)) }, _isIgnoreNodeChange: function (e) { return e && 3 !== e.nodeType && (this.isNonEditable(e) || !this.isTextStyleElement(e)) }, _isMaintainedNode: function (e) { return e && 3 !== e.nodeType && /^(a|label|code)$/i.test("string" == typeof e ? e : e.nodeName) }, _isSizeNode: function (e) { return e && 3 !== e.nodeType && this.isTextStyleElement(e) && !!e.style.fontSize }, _notTextNode: function (e) { return e && 3 !== e.nodeType && (this.isComponent(e) || /^(br|input|select|canvas|img|iframe|audio|video)$/i.test("string" == typeof e ? e : e.nodeName)) }, _disallowedTags: function (e) { return /^(meta|script|link|style|[a-z]+\:[a-z]+)$/i.test(e.nodeName) }, createTagsWhitelist: function (e) { return new RegExp("<\\/?\\b(?!\\b" + e.replace(/\|/g, "\\b|\\b") + "\\b)[^>]*>", "gi") }, _consistencyCheckOfHTML: function (e, t) { const n = [], i = [], l = [], o = [], s = this.getListChildNodes(e, function (s) { if (1 !== s.nodeType) return !1; if (!t.test(s.nodeName) && 0 === s.childNodes.length && this.isNotCheckingNode(s)) return n.push(s), !1; const a = !this.getParentElement(s, this.isNotCheckingNode); if (!this.isTable(s) && !this.isListCell(s) && (this.isFormatElement(s) || this.isRangeFormatElement(s) || this.isTextStyleElement(s)) && 0 === s.childNodes.length && a) return i.push(s), !1; if (this.isList(s.parentNode) && !this.isList(s) && !this.isListCell(s)) return l.push(s), !1; if (this.isCell(s)) { const e = s.firstElementChild; if (!this.isFormatElement(e) && !this.isRangeFormatElement(e) && !this.isComponent(e)) return o.push(s), !1 } return s.parentNode !== e && (this.isFormatElement(s) || this.isComponent(s) || this.isList(s)) && !this.isRangeFormatElement(s.parentNode) && !this.isListCell(s.parentNode) && !this.getParentElement(s, this.isComponent) && a }.bind(this)); for (let e = 0, t = n.length; e < t; e++)this.removeItem(n[e]); const a = []; for (let e, t, n = 0, i = s.length; n < i; n++)e = s[n], t = e.parentNode, t && t.parentNode && (t.parentNode.insertBefore(e, t), a.push(t)); for (let e, t = 0, n = a.length; t < n; t++)e = a[t], this.onlyZeroWidthSpace(e.textContent.trim()) && this.removeItem(e); for (let e = 0, t = i.length; e < t; e++)this.removeItem(i[e]); for (let e, t, n, i, o = 0, s = l.length; o < s; o++) { for (e = l[o], t = this.createElement("LI"), n = e.childNodes; n[0];)t.appendChild(n[0]); i = e.parentNode, i && (i.insertBefore(t, e), this.removeItem(e)) } for (let e, t, n = 0, i = o.length; n < i; n++)e = o[n], t = this.createElement("DIV"), t.innerHTML = 0 === e.textContent.trim().length && 0 === e.children.length ? " " : e.innerHTML, e.innerHTML = t.outerHTML }, _setDefaultOptionStyle: function (e, t) { let n = ""; e.height && (n += "height:" + e.height + ";"), e.minHeight && (n += "min-height:" + e.minHeight + ";"), e.maxHeight && (n += "max-height:" + e.maxHeight + ";"), e.position && (n += "position:" + e.position + ";"), e.width && (n += "width:" + e.width + ";"), e.minWidth && (n += "min-width:" + e.minWidth + ";"), e.maxWidth && (n += "max-width:" + e.maxWidth + ";"); let i = "", l = "", o = ""; const s = (t = n + t).split(";"); for (let t, n = 0, a = s.length; n < a; n++)t = s[n].trim(), t && (/^(min-|max-)?width\s*:/.test(t) || /^(z-index|position)\s*:/.test(t) ? i += t + ";" : /^(min-|max-)?height\s*:/.test(t) ? (/^height/.test(t) && "auto" === t.split(":")[1].trim() && (e.height = "auto"), l += t + ";") : o += t + ";"); return { top: i, frame: l, editor: o } }, _setIframeDocument: function (e, t) { e.setAttribute("scrolling", "auto"), e.contentDocument.head.innerHTML = '' + this._setIframeCssTags(t), e.contentDocument.body.className = t._editableClass, e.contentDocument.body.setAttribute("contenteditable", !0) }, _setIframeCssTags: function (e) { const t = e.iframeCSSFileName, n = this._w.RegExp; let i = ""; for (let e, l = 0, o = t.length; l < o; l++) { if (e = [], /(^https?:\/\/)|(^data:text\/css,)/.test(t[l])) e.push(t[l]); else { const i = new n("(^|.*[\\/])" + t[l] + "(\\..+)?\\.css(?:\\?.*|;.*)?$", "i"); for (let t, n = document.getElementsByTagName("link"), l = 0, o = n.length; l < o; l++)t = n[l].href.match(i), t && e.push(t[0]) } if (!e || 0 === e.length) throw '[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframeCSSFileName" before creating editor instances.'; for (let t = 0, n = e.length; t < n; t++)i += '' } 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 o = this._createToolBar(n, t.buttonList, t.plugins, t); o.element.style.visibility = "hidden", o.pluginCallButtons.math && this._checkKatexMath(t.katex); const s = n.createElement("DIV"); s.className = "se-arrow"; const a = n.createElement("DIV"); a.className = "se-toolbar-sticky-dummy"; const r = n.createElement("DIV"); r.className = "se-wrapper"; const c = this._initElements(t, i, o.element, s), d = c.bottomBar, u = c.wysiwygFrame, h = c.placeholder; let p = c.codeView; const g = d.resizingBar, m = d.navigation, f = d.charWrapper, _ = d.charCounter, b = n.createElement("DIV"); b.className = "se-loading-box sun-editor-common", b.innerHTML = ''; const v = n.createElement("DIV"); v.className = "se-line-breaker", v.innerHTML = '"; const y = n.createElement("DIV"); y.className += "se-line-breaker-component"; const C = y.cloneNode(!0); y.innerHTML = C.innerHTML = t.icons.line_break; const w = n.createElement("DIV"); w.className = "se-resizing-back"; const x = t.toolbarContainer; return x && x.appendChild(o.element), r.appendChild(p), h && r.appendChild(h), x || l.appendChild(o.element), l.appendChild(a), l.appendChild(r), l.appendChild(w), l.appendChild(b), l.appendChild(v), l.appendChild(y), l.appendChild(C), g && l.appendChild(g), i.appendChild(l), p = this._checkCodeMirror(t, p), { constructed: { _top: i, _relative: l, _toolBar: o.element, _menuTray: o._menuTray, _editorArea: r, _wysiwygArea: u, _codeArea: p, _placeholder: h, _resizingBar: g, _navigation: m, _charWrapper: f, _charCounter: _, _loading: b, _lineBreaker: v, _lineBreaker_t: y, _lineBreaker_b: C, _resizeBack: w, _stickyDummy: a, _arrow: s }, options: t, plugins: o.plugins, pluginCallButtons: o.pluginCallButtons, _responsiveButtons: o.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, o = i.editorArea, s = e.toolbarContainer && e.toolbarContainer !== n.toolbarContainer, a = e.lang !== n.lang || e.buttonList !== n.buttonList || e.mode !== n.mode || s, 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", s ? (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, p = d.placeholder; let g = d.codeView; return i.resizingBar && l.removeChild(i.resizingBar), u.resizingBar && l.appendChild(u.resizingBar), o.innerHTML = "", o.appendChild(g), p && o.appendChild(p), g = this._checkCodeMirror(e, g), i.resizingBar = u.resizingBar, i.navigation = u.navigation, i.charWrapper = u.charWrapper, i.charCounter = u.charCounter, i.wysiwygFrame = h, i.code = g, i.placeholder = p, 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"); l.className = "se-wrapper-inner se-wrapper-wysiwyg", e.iframe ? (l.allowFullscreen = !0, l.frameBorder = 0, l.style.cssText = e._editorStyles.frame) : (l.setAttribute("contenteditable", !0), l.setAttribute("scrolling", "auto"), l.className += " " + e._editableClass, l.style.cssText = e._editorStyles.frame + e._editorStyles.editor); const o = document.createElement("TEXTAREA"); o.className = "se-wrapper-inner se-wrapper-code", o.style.cssText = e._editorStyles.frame, o.style.display = "none", "auto" === e.height && (o.style.overflow = "hidden"); let s = null, a = null, r = null, c = null; if (e.resizingBar && (s = document.createElement("DIV"), s.className = "se-resizing-bar sun-editor-common", a = document.createElement("DIV"), a.className = "se-navigation sun-editor-common", s.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) } s.appendChild(r) } let d = null; return e.placeholder && (d = document.createElement("SPAN"), d.className = "se-placeholder", d.innerText = e.placeholder), { bottomBar: { resizingBar: s, navigation: a, charWrapper: r, charCounter: c }, wysiwygFrame: l, codeView: o, placeholder: d } }, _initOptions: function (e, t) { t.lang = t.lang || T.a, t.defaultTag = "string" == typeof t.defaultTag ? t.defaultTag : "p"; const n = t.textTags = [{ bold: "STRONG", underline: "U", italic: "EM", strike: "DEL", sub: "SUB", sup: "SUP" }, t.textTags || {}].reduce((function (e, t) { for (let n in t) e[n] = t[n]; return e }), {}); t._textTagsMap = { strong: n.bold, b: n.bold, u: n.underline, ins: n.underline, em: n.italic, i: n.italic, del: n.strike, strike: n.strike, s: n.strike, sub: n.sub, sup: n.sup }, t.value = "string" == typeof t.value ? t.value : null, t.historyStackDelayTime = "number" == typeof t.historyStackDelayTime ? t.historyStackDelayTime : 400; t._defaultTagsWhitelist = "string" == typeof t._defaultTagsWhitelist ? t._defaultTagsWhitelist : "br|p|div|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path", t._editorTagsWhitelist = this._setWhitelist(t._defaultTagsWhitelist + ("string" == typeof t.addTagsWhitelist && t.addTagsWhitelist.length > 0 ? "|" + t.addTagsWhitelist : ""), t.tagsBlacklist), t.pasteTagsWhitelist = this._setWhitelist("string" == typeof t.pasteTagsWhitelist ? t.pasteTagsWhitelist : t._editorTagsWhitelist, t.pasteTagsBlacklist), t.attributesWhitelist = t.attributesWhitelist && "object" == typeof t.attributesWhitelist ? t.attributesWhitelist : null, t.mode = t.mode || "classic", t.rtl = !!t.rtl, t._editableClass = "sun-editor-editable" + (t.rtl ? " se-rtl" : ""), t._printClass = "string" == typeof t._printClass ? t._printClass : null, t.toolbarWidth = t.toolbarWidth ? L.isNumber(t.toolbarWidth) ? t.toolbarWidth + "px" : t.toolbarWidth : "auto", t.toolbarContainer = "string" == typeof t.toolbarContainer ? document.querySelector(t.toolbarContainer) : t.toolbarContainer, t.stickyToolbar = /balloon/i.test(t.mode) || t.toolbarContainer ? -1 : void 0 === t.stickyToolbar ? 0 : /^\d+/.test(t.stickyToolbar) ? L.getNumber(t.stickyToolbar, 0) : -1, t.fullScreenOffset = void 0 === t.fullScreenOffset ? 0 : /^\d+/.test(t.fullScreenOffset) ? L.getNumber(t.fullScreenOffset, 0) : 0, t.iframe = t.fullPage || t.iframe, t.fullPage = !!t.fullPage, t.iframeCSSFileName = t.iframe ? "string" == typeof t.iframeCSSFileName ? [t.iframeCSSFileName] : t.iframeCSSFileName || ["suneditor"] : null, t.previewTemplate = "string" == typeof t.previewTemplate ? t.previewTemplate : null, t.printTemplate = "string" == typeof t.printTemplate ? t.printTemplate : null, t.codeMirror = t.codeMirror ? t.codeMirror.src ? t.codeMirror : { src: t.codeMirror } : null, t.katex = t.katex ? t.katex.src ? t.katex : { src: t.katex } : null, t.mathFontSize = t.mathFontSize ? t.mathFontSize : [{ text: "1", value: "1em" }, { text: "1.5", value: "1.5em" }, { text: "2", value: "2em" }, { text: "2.5", value: "2.5em" }], t.position = "string" == typeof t.position ? t.position : null, t.display = t.display || ("none" !== e.style.display && e.style.display ? e.style.display : "block"), t.popupDisplay = t.popupDisplay || "full", t.resizingBar = void 0 === t.resizingBar ? !/inline|balloon/i.test(t.mode) : t.resizingBar, t.showPathLabel = !!t.resizingBar && ("boolean" != typeof t.showPathLabel || t.showPathLabel), t.charCounter = t.maxCharCount > 0 || "boolean" == typeof t.charCounter && t.charCounter, t.charCounterType = "string" == typeof t.charCounterType ? t.charCounterType : "char", t.charCounterLabel = "string" == typeof t.charCounterLabel ? t.charCounterLabel.trim() : null, t.maxCharCount = L.isNumber(t.maxCharCount) && t.maxCharCount > -1 ? 1 * t.maxCharCount : null, t.width = t.width ? L.isNumber(t.width) ? t.width + "px" : t.width : e.clientWidth ? e.clientWidth + "px" : "100%", t.minWidth = (L.isNumber(t.minWidth) ? t.minWidth + "px" : t.minWidth) || "", t.maxWidth = (L.isNumber(t.maxWidth) ? t.maxWidth + "px" : t.maxWidth) || "", t.height = t.height ? L.isNumber(t.height) ? t.height + "px" : t.height : e.clientHeight ? e.clientHeight + "px" : "auto", t.minHeight = (L.isNumber(t.minHeight) ? t.minHeight + "px" : t.minHeight) || "", t.maxHeight = (L.isNumber(t.maxHeight) ? t.maxHeight + "px" : t.maxHeight) || "", t.defaultStyle = "string" == typeof t.defaultStyle ? t.defaultStyle : "", t.font = t.font ? t.font : null, t.fontSize = t.fontSize ? t.fontSize : null, t.formats = t.formats ? t.formats : null, t.colorList = t.colorList ? t.colorList : null, t.lineHeights = t.lineHeights ? t.lineHeights : null, t.paragraphStyles = t.paragraphStyles ? t.paragraphStyles : null, t.textStyles = t.textStyles ? t.textStyles : null, t.fontSizeUnit = "string" == typeof t.fontSizeUnit && t.fontSizeUnit.trim() || "px", t.imageResizing = void 0 === t.imageResizing || t.imageResizing, t.imageHeightShow = void 0 === t.imageHeightShow || !!t.imageHeightShow, t.imageWidth = t.imageWidth ? L.isNumber(t.imageWidth) ? t.imageWidth + "px" : t.imageWidth : "auto", t.imageHeight = t.imageHeight ? L.isNumber(t.imageHeight) ? t.imageHeight + "px" : t.imageHeight : "auto", t.imageSizeOnlyPercentage = !!t.imageSizeOnlyPercentage, t._imageSizeUnit = t.imageSizeOnlyPercentage ? "%" : "px", t.imageRotation = void 0 !== t.imageRotation ? t.imageRotation : !(t.imageSizeOnlyPercentage || !t.imageHeightShow), t.imageFileInput = void 0 === t.imageFileInput || t.imageFileInput, t.imageUrlInput = void 0 === t.imageUrlInput || !t.imageFileInput || t.imageUrlInput, t.imageUploadHeader = t.imageUploadHeader || null, t.imageUploadUrl = "string" == typeof t.imageUploadUrl ? t.imageUploadUrl : null, t.imageUploadSizeLimit = /\d+/.test(t.imageUploadSizeLimit) ? L.getNumber(t.imageUploadSizeLimit, 0) : null, t.imageMultipleFile = !!t.imageMultipleFile, t.imageAccept = "string" != typeof t.imageAccept || "*" === t.imageAccept.trim() ? "image/*" : t.imageAccept.trim() || "image/*", t.imageGalleryUrl = "string" == typeof t.imageGalleryUrl ? t.imageGalleryUrl : null, t.imageGalleryHeader = t.imageGalleryHeader || null, t.videoResizing = void 0 === t.videoResizing || t.videoResizing, t.videoHeightShow = void 0 === t.videoHeightShow || !!t.videoHeightShow, t.videoRatioShow = void 0 === t.videoRatioShow || !!t.videoRatioShow, t.videoWidth = t.videoWidth && L.getNumber(t.videoWidth, 0) ? L.isNumber(t.videoWidth) ? t.videoWidth + "px" : t.videoWidth : "", t.videoHeight = t.videoHeight && L.getNumber(t.videoHeight, 0) ? L.isNumber(t.videoHeight) ? t.videoHeight + "px" : t.videoHeight : "", t.videoSizeOnlyPercentage = !!t.videoSizeOnlyPercentage, t._videoSizeUnit = t.videoSizeOnlyPercentage ? "%" : "px", t.videoRotation = void 0 !== t.videoRotation ? t.videoRotation : !(t.videoSizeOnlyPercentage || !t.videoHeightShow), t.videoRatio = L.getNumber(t.videoRatio, 4) || .5625, t.videoRatioList = t.videoRatioList ? t.videoRatioList : null, t.youtubeQuery = (t.youtubeQuery || "").replace("?", ""), t.videoFileInput = !!t.videoFileInput, t.videoUrlInput = void 0 === t.videoUrlInput || !t.videoFileInput || t.videoUrlInput, t.videoUploadHeader = t.videoUploadHeader || null, t.videoUploadUrl = "string" == typeof t.videoUploadUrl ? t.videoUploadUrl : null, t.videoUploadSizeLimit = /\d+/.test(t.videoUploadSizeLimit) ? L.getNumber(t.videoUploadSizeLimit, 0) : null, t.videoMultipleFile = !!t.videoMultipleFile, t.videoTagAttrs = t.videoTagAttrs || null, t.videoIframeAttrs = t.videoIframeAttrs || null, t.videoAccept = "string" != typeof t.videoAccept || "*" === t.videoAccept.trim() ? "video/*" : t.videoAccept.trim() || "video/*", t.audioWidth = t.audioWidth ? L.isNumber(t.audioWidth) ? t.audioWidth + "px" : t.audioWidth : "", t.audioHeight = t.audioHeight ? L.isNumber(t.audioHeight) ? t.audioHeight + "px" : t.audioHeight : "", t.audioFileInput = !!t.audioFileInput, t.audioUrlInput = void 0 === t.audioUrlInput || !t.audioFileInput || t.audioUrlInput, t.audioUploadHeader = t.audioUploadHeader || null, t.audioUploadUrl = "string" == typeof t.audioUploadUrl ? t.audioUploadUrl : null, t.audioUploadSizeLimit = /\d+/.test(t.audioUploadSizeLimit) ? L.getNumber(t.audioUploadSizeLimit, 0) : null, t.audioMultipleFile = !!t.audioMultipleFile, t.audioTagAttrs = t.audioTagAttrs || null, t.audioAccept = "string" != typeof t.audioAccept || "*" === t.audioAccept.trim() ? "audio/*" : t.audioAccept.trim() || "audio/*", t.tableCellControllerPosition = "string" == typeof t.tableCellControllerPosition ? t.tableCellControllerPosition.toLowerCase() : "cell", t.linkProtocol = "string" == typeof t.linkProtocol ? t.linkProtocol : null, t.linkRel = Array.isArray(t.linkRel) ? t.linkRel : [], t.linkRelDefault = t.linkRelDefault || {}, t.tabDisable = !!t.tabDisable, t.shortcutsDisable = Array.isArray(t.shortcutsDisable) ? t.shortcutsDisable : [], t.shortcutsHint = void 0 === t.shortcutsHint || !!t.shortcutsHint, t.callBackSave = t.callBackSave ? t.callBackSave : null, t.templates = t.templates ? t.templates : null, t.placeholder = "string" == typeof t.placeholder ? t.placeholder : null, t.mediaAutoSelect = void 0 === t.mediaAutoSelect || !!t.mediaAutoSelect, t.buttonList = t.buttonList ? t.buttonList : [["undo", "redo"], ["bold", "underline", "italic", "strike", "subscript", "superscript"], ["removeFormat"], ["outdent", "indent"], ["fullScreen", "showBlocks", "codeView"], ["preview", "print"]], t.rtl && (t.buttonList = t.buttonList.reverse()), t.icons = t.icons && "object" == typeof t.icons ? [S, t.icons].reduce((function (e, t) { for (let n in t) L.hasOwn(t, n) && (e[n] = t[n]); return e }), {}) : S, t.icons = t.rtl ? [t.icons, t.icons.rtl].reduce((function (e, t) { for (let n in t) L.hasOwn(t, n) && (e[n] = t[n]); return e }), {}) : t.icons, t._editorStyles = L._setDefaultOptionStyle(t, t.defaultStyle) }, _setWhitelist: function (e, t) { if ("string" != typeof t) return e; t = t.split("|"), e = e.split("|"); for (let n, i = 0, l = t.length; i < l; i++)n = e.indexOf(t[i]), n > -1 && e.splice(n, 1); return e.join("|") }, _defaultButtons: function (e) { const t = e.icons, n = e.lang, i = L.isOSX_IOS ? "⌘" : "CTRL", l = L.isOSX_IOS ? "⇧" : "+SHIFT", o = e.shortcutsHint ? e.shortcutsDisable : ["bold", "strike", "underline", "italic", "undo", "indent", "save"], s = e.rtl ? ["[", "]"] : ["]", "["]; return { bold: ["_se_command_bold", n.toolbar.bold + '' + (o.indexOf("bold") > -1 ? "" : i + '+B') + "", "bold", "", t.bold], underline: ["_se_command_underline", n.toolbar.underline + '' + (o.indexOf("underline") > -1 ? "" : i + '+U') + "", "underline", "", t.underline], italic: ["_se_command_italic", n.toolbar.italic + '' + (o.indexOf("italic") > -1 ? "" : i + '+I') + "", "italic", "", t.italic], strike: ["_se_command_strike", n.toolbar.strike + '' + (o.indexOf("strike") > -1 ? "" : i + l + '+S') + "", "strike", "", t.strike], subscript: ["_se_command_subscript", n.toolbar.subscript, "SUB", "", t.subscript], superscript: ["_se_command_superscript", n.toolbar.superscript, "SUP", "", t.superscript], removeFormat: ["", n.toolbar.removeFormat, "removeFormat", "", t.erase], indent: ["_se_command_indent", n.toolbar.indent + '' + (o.indexOf("indent") > -1 ? "" : i + '+' + s[0] + "") + "", "indent", "", t.outdent], outdent: ["_se_command_outdent", n.toolbar.outdent + '' + (o.indexOf("indent") > -1 ? "" : i + '+' + s[1] + "") + "", "outdent", "", t.indent], fullScreen: ["se-code-view-enabled se-resizing-enabled _se_command_fullScreen", n.toolbar.fullScreen, "fullScreen", "", t.expansion], showBlocks: ["_se_command_showBlocks", n.toolbar.showBlocks, "showBlocks", "", t.show_blocks], codeView: ["se-code-view-enabled se-resizing-enabled _se_command_codeView", n.toolbar.codeView, "codeView", "", t.code_view], undo: ["_se_command_undo se-resizing-enabled", n.toolbar.undo + '' + (o.indexOf("undo") > -1 ? "" : i + '+Z') + "", "undo", "", t.undo], redo: ["_se_command_redo se-resizing-enabled", n.toolbar.redo + '' + (o.indexOf("undo") > -1 ? "" : i + '+Y / ' + i + l + '+Z') + "", "redo", "", t.redo], preview: ["se-resizing-enabled", n.toolbar.preview, "preview", "", t.preview], print: ["se-resizing-enabled", n.toolbar.print, "print", "", t.print], save: ["_se_command_save se-resizing-enabled", n.toolbar.save + '' + (o.indexOf("save") > -1 ? "" : i + '+S') + "", "save", "", t.save], blockquote: ["", n.toolbar.tag_blockquote, "blockquote", "command", t.blockquote], font: ["se-btn-select se-btn-tool-font", n.toolbar.font, "font", "submenu", '' + n.toolbar.font + "" + t.arrow_down], formatBlock: ["se-btn-select se-btn-tool-format", n.toolbar.formats, "formatBlock", "submenu", '' + n.toolbar.formats + "" + t.arrow_down], fontSize: ["se-btn-select se-btn-tool-size", n.toolbar.fontSize, "fontSize", "submenu", '' + n.toolbar.fontSize + "" + t.arrow_down], fontColor: ["", n.toolbar.fontColor, "fontColor", "submenu", t.font_color], hiliteColor: ["", n.toolbar.hiliteColor, "hiliteColor", "submenu", t.highlight_color], align: ["se-btn-align", n.toolbar.align, "align", "submenu", e.rtl ? t.align_right : t.align_left], list: ["", n.toolbar.list, "list", "submenu", t.list_number], horizontalRule: ["btn_line", n.toolbar.horizontalRule, "horizontalRule", "submenu", t.horizontal_rule], table: ["", n.toolbar.table, "table", "submenu", t.table], lineHeight: ["", n.toolbar.lineHeight, "lineHeight", "submenu", t.line_height], template: ["", n.toolbar.template, "template", "submenu", t.template], paragraphStyle: ["", n.toolbar.paragraphStyle, "paragraphStyle", "submenu", t.paragraph_style], textStyle: ["", n.toolbar.textStyle, "textStyle", "submenu", t.text_style], link: ["", n.toolbar.link, "link", "dialog", t.link], image: ["", n.toolbar.image, "image", "dialog", t.image], video: ["", n.toolbar.video, "video", "dialog", t.video], audio: ["", n.toolbar.audio, "audio", "dialog", t.audio], math: ["", n.toolbar.math, "math", "dialog", t.math], imageGallery: ["", n.toolbar.imageGallery, "imageGallery", "fileBrowser", t.image_gallery] } }, _createModuleGroup: function () { const e = L.createElement("DIV"); e.className = "se-btn-module se-btn-module-border"; const t = L.createElement("UL"); return t.className = "se-menu-list", e.appendChild(t), { div: e, ul: t } }, _createButton: function (e, t, n, i, l, o, s) { const a = L.createElement("LI"), r = L.createElement("BUTTON"); return r.setAttribute("type", "button"), r.setAttribute("class", "se-btn" + (e ? " " + e : "") + " se-tooltip"), r.setAttribute("data-command", n), r.setAttribute("data-display", i), r.setAttribute("tabindex", "-1"), l || (l = '!'), /^default\./i.test(l) && (l = s[l.replace(/^default\./i, "")]), /^text\./i.test(l) && (l = l.replace(/^text\./i, ""), r.className += " se-btn-more-text"), l += '' + (t || n) + "", o && r.setAttribute("disabled", !0), r.innerHTML = l, a.appendChild(r), { li: a, button: r } }, _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 = e.createElement("DIV"); s.className = "se-btn-tray", o.appendChild(s), t = JSON.parse(JSON.stringify(t)); const a = i.icons, r = this._defaultButtons(i), c = {}, d = [], u = {}; if (n) { const e = n.length ? n : Object.keys(n).map((function (e) { return n[e] })); for (let t, n = 0, i = e.length; n < i; n++)t = e[n].default || e[n], u[t.name] = t } let h = null, p = null, g = null, m = null, f = "", _ = !1; const b = L.createElement("DIV"); b.className = "se-toolbar-more-layer"; e: for (let n, i, o, v, y, C = 0; C < t.length; C++)if (n = !1, y = "", v = t[C], g = this._createModuleGroup(), "object" == typeof v) { for (let e, l = 0; l < v.length; l++) { if (p = v[l], e = !1, /^\%\d+/.test(p) && 0 === l) { v[0] = p.replace(/[^\d]/g, ""), d.push(v), t.splice(C--, 1); continue e } if ("object" == typeof p) "function" == typeof p.add ? (f = p.name, h = r[f], u[f] = p) : (f = p.name, h = [p.buttonClass, p.title, p.name, p.dataDisplay, p.innerHTML, p._disabled]); else { if (/^\-/.test(p)) { y = p.substr(1), g.div.style.float = y; continue } if (/^\:/.test(p)) { e = !0; const t = p.match(/^\:([^\-]+)\-([^\-]+)\-([^\-]+)/); o = "__se__" + t[1].trim(); h = ["se-btn-more", t[2].trim(), o, "MORE", t[3].trim()] } else h = r[p]; if (f = p, !h) { const e = u[f]; if (!e) throw Error("[SUNEDITOR.create.toolbar.fail] The button name of a plugin that does not exist. [" + f + "]"); h = [e.buttonClass, e.title, e.name, e.display, e.innerHTML, e._disabled] } } m = this._createButton(h[0], h[1], h[2], h[3], h[4], h[5], a), (n ? i : g.ul).appendChild(m.li), u[f] && (c[f] = m.button), e && (n = !0, i = L.createElement("DIV"), i.className = "se-more-layer " + o, i.innerHTML = '
", b.appendChild(i), i = i.firstElementChild.firstElementChild) } if (_) { const e = l.cloneNode(!1); s.appendChild(e) } s.appendChild(g.div), _ = !0 } else if (/^\/$/.test(v)) { const t = e.createElement("DIV"); t.className = "se-btn-module-enter", s.appendChild(t), _ = !1 } switch (s.children.length) { case 0: s.style.display = "none"; break; case 1: L.removeClass(s.firstElementChild, "se-btn-module-border"); break; default: if (i.rtl) { const e = l.cloneNode(!1); e.style.float = s.lastElementChild.style.float, s.appendChild(e) } }d.length > 0 && d.unshift(t), b.children.length > 0 && s.appendChild(b); const v = e.createElement("DIV"); v.className = "se-menu-tray", o.appendChild(v); const y = e.createElement("DIV"); return y.className = "se-toolbar-cover", o.appendChild(y), { element: o, plugins: u, pluginCallButtons: c, responsiveButtons: d, _menuTray: v, _buttonTray: s } } }; var A = function (e, t, n) { return { element: { originElement: e, topArea: t._top, relative: t._relative, toolbar: t._toolBar, _buttonTray: t._toolBar.querySelector(".se-btn-tray"), _menuTray: t._menuTray, resizingBar: t._resizingBar, navigation: t._navigation, charWrapper: t._charWrapper, charCounter: t._charCounter, editorArea: t._editorArea, wysiwygFrame: t._wysiwygArea, wysiwyg: t._wysiwygArea, code: t._codeArea, placeholder: t._placeholder, loading: t._loading, lineBreaker: t._lineBreaker, lineBreaker_t: t._lineBreaker_t, lineBreaker_b: t._lineBreaker_b, resizeBackground: t._resizeBack, _stickyDummy: t._stickyDummy, _arrow: t._arrow }, tool: { cover: t._toolBar.querySelector(".se-toolbar-cover"), bold: t._toolBar.querySelector("._se_command_bold"), underline: t._toolBar.querySelector("._se_command_underline"), italic: t._toolBar.querySelector("._se_command_italic"), strike: t._toolBar.querySelector("._se_command_strike"), subscript: t._toolBar.querySelector("._se_command_subscript"), superscript: t._toolBar.querySelector("._se_command_superscript"), undo: t._toolBar.querySelector("._se_command_undo"), redo: t._toolBar.querySelector("._se_command_redo"), save: t._toolBar.querySelector("._se_command_save"), outdent: t._toolBar.querySelector("._se_command_outdent"), indent: t._toolBar.querySelector("._se_command_indent"), fullScreen: t._toolBar.querySelector("._se_command_fullScreen"), showBlocks: t._toolBar.querySelector("._se_command_showBlocks"), codeView: t._toolBar.querySelector("._se_command_codeView") }, options: n, option: n } }, M = { 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 = e.icons.cancel, 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.appendChild(n), 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" } }, z = { init: function (e) { return { create: function (t, n) { return this.create(t, n, e) }.bind(this) } }, create: function (e, t, n) { L._propertiesInit(), "object" != typeof t && (t = {}), n && (t = [n, t].reduce((function (e, t) { for (let n in t) if (L.hasOwn(t, n)) if ("plugins" === n && t[n] && e[n]) { let i = e[n], l = t[n]; i = i.length ? i : Object.keys(i).map((function (e) { return i[e] })), l = l.length ? l : Object.keys(l).map((function (e) { return l[e] })), e[n] = l.filter((function (e) { return -1 === i.indexOf(e) })).concat(i) } else e[n] = t[n]; return e }), {})); const i = "string" == typeof e ? document.getElementById(e) : e; if (!i) { if ("string" == typeof e) throw Error('[SUNEDITOR.create.fail] The element for that id was not found (ID:"' + e + '")'); throw Error("[SUNEDITOR.create.fail] suneditor requires textarea's element or id value") } const l = B.init(i, t); if (l.constructed._top.id && document.getElementById(l.constructed._top.id)) throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:"' + l.constructed._top.id + '")'); return function (e, t, n, i, l, o) { const s = e.element.originElement.ownerDocument || document, a = s.defaultView || window, r = L, c = l.icons, d = { _d: s, _w: a, _parser: new a.DOMParser, _wd: null, _ww: null, _shadowRoot: null, _shadowRootControllerEventTarget: null, util: r, functions: null, options: null, wwComputedStyle: a.getComputedStyle(e.element.wysiwyg), notice: M, icons: c, history: null, context: e, pluginCallButtons: t, plugins: n || {}, initPlugins: {}, _targetPlugins: {}, _menuTray: {}, lang: i, effectNode: null, submenu: null, container: null, _submenuName: "", _bindedSubmenuOff: null, _bindedContainerOff: null, submenuActiveButton: null, containerActiveButton: null, controllerArray: [], currentControllerName: "", currentControllerTarget: null, currentFileComponentInfo: null, codeViewDisabledButtons: null, resizingDisabledButtons: null, _moreLayerActiveButton: null, _htmlCheckWhitelistRegExp: null, _disallowedTextTagsRegExp: null, editorTagsWhitelistRegExp: null, pasteTagsWhitelistRegExp: null, hasFocus: !1, isDisabled: !1, _attributesWhitelistRegExp: null, _attributesTagsWhitelist: null, _bindControllersOff: null, _isInline: null, _isBalloon: null, _isBalloonAlways: null, _inlineToolbarAttr: { top: "", width: "", isShow: !1 }, _notHideToolbar: !1, _sticky: !1, _antiBlur: !1, _lineBreaker: null, _lineBreakerButton: null, _componentsInfoInit: !0, _componentsInfoReset: !1, activePlugins: null, managedTagsInfo: null, _charTypeHTML: !1, _fileInfoPluginsCheck: null, _fileInfoPluginsReset: null, _fileManager: { tags: null, regExp: null, queryString: null, pluginRegExp: null, pluginMap: null }, commandMap: null, _styleCommandMap: null, _defaultCommand: { bold: l.textTags.bold, underline: l.textTags.underline, italic: l.textTags.italic, strike: l.textTags.strike, subscript: l.textTags.sub, superscript: l.textTags.sup }, _variable: { isChanged: !1, isCodeView: !1, isFullScreen: !1, innerHeight_fullScreen: 0, resizeClientY: 0, tabSize: 4, codeIndent: 4, minResizingSize: r.getNumber(e.element.wysiwygFrame.style.minHeight || "65", 0), currentNodes: [], currentNodesMap: [], _range: null, _selectionNode: null, _originCssText: e.element.topArea.style.cssText, _bodyOverflow: "", _editorAreaOriginCssText: "", _wysiwygOriginCssText: "", _codeOriginCssText: "", _fullScreenAttrs: { sticky: !1, balloon: !1, inline: !1 }, _lineBreakComp: null, _lineBreakDir: "" }, callPlugin: function (e, n, i) { if (i = i || t[e], !this.plugins[e]) throw Error('[SUNEDITOR.core.callPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName:"' + e + '")'); this.initPlugins[e] ? "object" == typeof this._targetPlugins[e] && i && this.initMenuTarget(e, i, this._targetPlugins[e]) : (this.plugins[e].add(this, i), this.initPlugins[e] = !0), this.plugins[e].active && !this.commandMap[e] && i && (this.commandMap[e] = i, this.activePlugins.push(e)), "function" == typeof n && n() }, addModule: function (e) { for (let t, n = 0, i = e.length; n < i; n++)t = e[n].name, this.plugins[t] || (this.plugins[t] = e[n]), this.initPlugins[t] || (this.initPlugins[t] = !0, "function" == typeof this.plugins[t].add && this.plugins[t].add(this)) }, getGlobalScrollOffset: function () { let t = 0, n = 0, i = e.element.topArea; for (; i;)t += i.scrollTop, n += i.scrollLeft, i = i.parentElement; for (i = this._shadowRoot ? this._shadowRoot.host : null; i;)t += i.scrollTop, n += i.scrollLeft, i = i.parentElement; return { top: t, left: n } }, initMenuTarget: function (t, n, i) { n ? (e.element._menuTray.appendChild(i), this._targetPlugins[t] = !0, this._menuTray[n.getAttribute("data-command")] = i) : this._targetPlugins[t] = i }, submenuOn: function (e) { this._bindedSubmenuOff && this._bindedSubmenuOff(), this._bindControllersOff && this.controllersOff(); const t = this._submenuName = e.getAttribute("data-command"), n = this.submenu = this._menuTray[t]; this.submenuActiveButton = e, this._setMenuPosition(e, n), this._bindedSubmenuOff = this.submenuOff.bind(this), this.addDocEvent("mousedown", this._bindedSubmenuOff, !1), this.plugins[t].on && this.plugins[t].on.call(this), this._antiBlur = !0 }, submenuOff: function () { this.removeDocEvent("mousedown", this._bindedSubmenuOff), this._bindedSubmenuOff = null, this.submenu && (this._submenuName = "", this.submenu.style.display = "none", this.submenu = null, r.removeClass(this.submenuActiveButton, "on"), this.submenuActiveButton = null, this._notHideToolbar = !1), this._antiBlur = !1 }, containerOn: function (e) { this._bindedContainerOff && this._bindedContainerOff(); const t = this._containerName = e.getAttribute("data-command"), n = this.container = this._menuTray[t]; this.containerActiveButton = e, this._setMenuPosition(e, n), this._bindedContainerOff = this.containerOff.bind(this), this.addDocEvent("mousedown", this._bindedContainerOff, !1), this.plugins[t].on && this.plugins[t].on.call(this), this._antiBlur = !0 }, containerOff: function () { this.removeDocEvent("mousedown", this._bindedContainerOff), this._bindedContainerOff = null, this.container && (this._containerName = "", this.container.style.display = "none", this.container = null, r.removeClass(this.containerActiveButton, "on"), this.containerActiveButton = null, this._notHideToolbar = !1), this._antiBlur = !1 }, _setMenuPosition: function (t, n) { n.style.visibility = "hidden", n.style.display = "block", n.style.height = "", r.addClass(t, "on"); const i = this.context.element.toolbar, o = i.offsetWidth, s = u._getEditorOffsets(e.element.toolbar), c = n.offsetWidth, d = t.parentElement.offsetLeft + 3; if (l.rtl) { const e = t.offsetWidth, i = c > e ? c - e : 0, l = i > 0 ? 0 : e - c; n.style.left = d - i + l + "px", s.left > u._getEditorOffsets(n).left && (n.style.left = "0px") } else { const e = o <= c ? 0 : o - (d + c); n.style.left = e < 0 ? d + e + "px" : d + "px" } let h = 0, p = t; for (; p && p !== i;)h += p.offsetTop, p = p.offsetParent; const g = h; this._isBalloon ? h += i.offsetTop + t.offsetHeight : h -= t.offsetHeight; const m = s.top, f = n.offsetHeight, _ = this.getGlobalScrollOffset().top, b = a.innerHeight - (m - _ + g + t.parentElement.offsetHeight); if (b < f) { let e = -1 * (f - g + 3); const i = m - _ + e, l = f + (i < 0 ? i : 0); l > b ? (n.style.height = l + "px", e = -1 * (l - g + 3)) : (n.style.height = b + "px", e = g + t.parentElement.offsetHeight), n.style.top = e + "px" } else n.style.top = g + t.parentElement.offsetHeight + "px"; n.style.visibility = "" }, controllersOn: function () { this._bindControllersOff && this._bindControllersOff(), this.controllerArray = []; for (let e, t = 0; t < arguments.length; t++)e = arguments[t], e && ("string" != typeof e ? "function" != typeof e ? r.hasClass(e, "se-controller") ? (e.style && (e.style.display = "block", this._shadowRoot && -1 === this._shadowRootControllerEventTarget.indexOf(e) && (e.addEventListener("mousedown", (function (e) { e.preventDefault(), e.stopPropagation() })), this._shadowRootControllerEventTarget.push(e))), this.controllerArray.push(e)) : (this.currentControllerTarget = e, this.currentFileComponentInfo = this.getFileComponent(e)) : this.controllerArray.push(e) : this.currentControllerName = e); this._bindControllersOff = this.controllersOff.bind(this), this.addDocEvent("mousedown", this._bindControllersOff, !1), this.addDocEvent("keydown", this._bindControllersOff, !1), this._antiBlur = !0, "function" == typeof h.showController && h.showController(this.currentControllerName, this.controllerArray, this) }, controllersOff: function (t) { this._lineBreaker.style.display = "none"; const n = this.controllerArray.length; if (t && t.target && n > 0) for (let e = 0; e < n; e++)if ("function" == typeof this.controllerArray[e].contains && this.controllerArray[e].contains(t.target)) return; if ((!this._fileManager.pluginRegExp.test(this.currentControllerName) || !t || "keydown" !== t.type || 27 === t.keyCode) && (e.element.lineBreaker_t.style.display = e.element.lineBreaker_b.style.display = "none", this._variable._lineBreakComp = null, this.currentControllerName = "", this.currentControllerTarget = null, this.currentFileComponentInfo = null, this.effectNode = null, this._bindControllersOff)) { if (this.removeDocEvent("mousedown", this._bindControllersOff), this.removeDocEvent("keydown", this._bindControllersOff), this._bindControllersOff = null, n > 0) { for (let e = 0; e < n; e++)"function" == typeof this.controllerArray[e] ? this.controllerArray[e]() : this.controllerArray[e].style.display = "none"; this.controllerArray = [] } this._antiBlur = !1 } }, setControllerPosition: function (t, n, i, o) { l.rtl && (o.left *= -1); const s = r.getOffset(n, e.element.wysiwygFrame); t.style.visibility = "hidden", t.style.display = "block"; const a = "top" === i ? -(t.offsetHeight + 2) : n.offsetHeight + 12; t.style.top = s.top + a + o.top + "px"; const c = s.left - e.element.wysiwygFrame.scrollLeft + o.left, d = t.offsetWidth, u = n.offsetWidth, h = r.hasClass(t.firstElementChild, "se-arrow") ? t.firstElementChild : null; if (l.rtl) { const n = d > u ? d - u : 0, i = n > 0 ? 0 : u - d; t.style.left = c - n + i + "px", n > 0 && h && (h.style.left = (d - 14 < 10 + n ? d - 14 : 10 + n) + "px"); const l = e.element.wysiwygFrame.offsetLeft - t.offsetLeft; l > 0 && (t.style.left = "0px", h && (h.style.left = l + "px")) } else { t.style.left = c + "px"; const n = e.element.wysiwygFrame.offsetWidth - (t.offsetLeft + d); n < 0 ? (t.style.left = t.offsetLeft + n + "px", h && (h.style.left = 20 - n + "px")) : h && (h.style.left = "20px") } t.style.visibility = "" }, execCommand: function (e, t, n) { this._wd.execCommand(e, t, "formatBlock" === e ? "<" + n + ">" : n), this.history.push(!0) }, nativeFocus: function () { const t = r.getParentElement(this.getSelectionNode(), "figcaption"); t ? t.focus() : e.element.wysiwyg.focus(), this._editorRange() }, focus: function () { if ("none" !== e.element.wysiwygFrame.style.display) { if (l.iframe) this.nativeFocus(); else try { const t = this.getRange(); if (t.startContainer === t.endContainer && r.isWysiwygDiv(t.startContainer)) { const n = t.commonAncestorContainer.children[t.startOffset]; if (!r.isFormatElement(n) && !r.isComponent(n)) { const t = r.createElement(l.defaultTag), i = r.createElement("BR"); return t.appendChild(i), e.element.wysiwyg.insertBefore(t, n), void this.setRange(i, 0, i, 0) } } this.setRange(t.startContainer, t.startOffset, t.endContainer, t.endOffset) } catch (e) { this.nativeFocus() } u._applyTagEffects(), this._isBalloon && u._toggleToolbarBalloon() } }, focusEdge: function (t) { t || (t = e.element.wysiwyg.lastElementChild); const n = this.getFileComponent(t); n ? this.selectComponent(n.target, n.pluginName) : t ? (t = r.getChildElement(t, (function (e) { return 0 === e.childNodes.length || 3 === e.nodeType }), !0)) ? this.setRange(t, t.textContent.length, t, t.textContent.length) : this.nativeFocus() : this.focus() }, blur: function () { l.iframe ? e.element.wysiwygFrame.blur() : e.element.wysiwyg.blur() }, 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), r.isFormatElement(e) && (e = e.childNodes[t] || e, t = 0), r.isFormatElement(n) && (n = n.childNodes[i] || n, i = t > 1 ? t : 0); const o = this._wd.createRange(); try { o.setStart(e, t), o.setEnd(n, i) } catch (e) { return console.warn("[SUNEDITOR.core.focus.error] " + e), void this.nativeFocus() } const s = this.getSelection(); return s.removeAllRanges && s.removeAllRanges(), s.addRange(o), this._editorRange(), l.iframe && this.nativeFocus(), o }, removeRange: function () { this._variable._range = null, this._variable._selectionNode = null, this.hasFocus && this.getSelection().removeAllRanges(); const e = this.commandMap, t = this.activePlugins; for (let i in e) r.hasOwn(e, i) && (t.indexOf(i) > -1 ? n[i].active.call(this, null) : e.OUTDENT && /^OUTDENT$/i.test(i) ? e.OUTDENT.setAttribute("disabled", !0) : e.INDENT && /^INDENT$/i.test(i) ? e.INDENT.removeAttribute("disabled") : r.removeClass(e[i], "active")) }, getRange: function () { const t = this._variable._range || this._createDefaultRange(), n = this.getSelection(); if (t.collapsed === n.isCollapsed || !e.element.wysiwyg.contains(n.focusNode)) return t; if (n.rangeCount > 0) return this._variable._range = n.getRangeAt(0), this._variable._range; { const e = n.anchorNode, t = n.focusNode, i = n.anchorOffset, l = n.focusOffset, o = r.compareElements(e, t), s = o.ancestor && (0 === o.result ? i <= l : o.result > 1); return this.setRange(s ? e : t, s ? i : l, s ? t : e, s ? l : i) } }, getRange_addLine: function (t, n) { if (this._selectionVoid(t)) { const i = e.element.wysiwyg, o = r.createElement(l.defaultTag); o.innerHTML = " ", i.insertBefore(o, n && n !== i ? n.nextElementSibling : i.firstElementChild), this.setRange(o.firstElementChild, 0, o.firstElementChild, 1), t = this._variable._range } return t }, getSelection: function () { return this._shadowRoot && this._shadowRoot.getSelection ? this._shadowRoot.getSelection() : this._ww.getSelection() }, 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, n = null; t = e.rangeCount > 0 ? e.getRangeAt(0) : this._createDefaultRange(), this._variable._range = t, n = t.collapsed ? r.isWysiwygDiv(t.commonAncestorContainer) && t.commonAncestorContainer.children[t.startOffset] || t.commonAncestorContainer : e.extentNode || e.anchorNode, this._variable._selectionNode = n }, _createDefaultRange: function () { const t = e.element.wysiwyg; t.focus(); const n = this._wd.createRange(); let i = t.firstElementChild; return i || (i = r.createElement(l.defaultTag), i.innerHTML = " ", t.appendChild(i)), n.setStart(i, 0), n.setEnd(i, 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, o, s = t.startContainer, a = t.startOffset, c = t.endContainer, d = t.endOffset; if (r.isFormatElement(s) && (s = s.childNodes[a] || s.lastChild, a = s.textContent.length), r.isFormatElement(c) && (c = c.childNodes[d] || c.lastChild, d = c.textContent.length), n = r.isWysiwygDiv(s) ? e.element.wysiwyg.firstChild : s, 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 && s === c && (c = n, d = 1) } } if (s = 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 && (o = n.childNodes, 0 !== o.length);)n = o[i > 0 ? i - 1 : i] || !/FIGURE/i.test(o[0].nodeName) ? o[0] : n.previousElementSibling || n.previousSibling || s, i = i > 0 ? n.textContent.length : i; let e = r.getFormatElement(n, null); e === r.getRangeFormatElement(e, null) && (e = r.createElement(r.isCell(e) ? "DIV" : 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(s, 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, o = n.commonAncestorContainer, s = r.getListChildren(o, (function (e) { return t ? t(e) : r.isFormatElement(e) })); if (r.isWysiwygDiv(o) || r.isRangeFormatElement(o) || s.unshift(r.getFormatElement(o, null)), i === l || 1 === s.length) return s; 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 p = r.getRangeFormatElement(a, h), g = r.getRangeFormatElement(c, h); r.isTable(p) && r.isListCell(p.parentNode) && (p = p.parentNode), r.isTable(g) && r.isListCell(g.parentNode) && (g = g.parentNode); const m = p === g; for (let e, t = 0, n = s.length; t < n; t++)if (e = s[t], a === e || !m && e === p) d = t; else if (c === e || !m && e === g) { u = t; break } return null === d && (d = 0), null === u && (u = s.length - 1), s.slice(d, u + 1) }, getSelectedElementsAndComponents: function (e) { const t = this.getRange().commonAncestorContainer, n = r.getParentElement(t, r.isComponent), i = r.isTable(t) ? this.getSelectedElements(null) : this.getSelectedElements(function (e) { const t = this.getParentElement(e, this.isComponent); return this.isFormatElement(e) && (!t || t === n) || this.isComponent(e) && !this.getFormatElement(e) }.bind(r)); if (e) for (let e = 0, t = i.length; e < t; e++)for (let n = e - 1; n >= 0; n--)if (i[n].contains(i[e])) { i.splice(e, 1), e--, t--; break } return i }, isEdgePoint: function (e, t, n) { return "end" !== n && 0 === t || (!n || "front" !== n) && !e.nodeValue && 1 === t || (!n || "end" === n) && !!e.nodeValue && t === e.nodeValue.length }, _isEdgeFormat: function (e, t, n) { if (!this.isEdgePoint(e, t, n)) return !1; const i = []; for (n = "front" === n ? "previousSibling" : "nextSibling"; e && !r.isFormatElement(e) && !r.isWysiwygDiv(e);) { if (e[n] && (!r.isBreak(e[n]) || e[n][n])) return null; 1 === e.nodeType && i.push(e.cloneNode(!1)), e = e.parentNode } return i }, showLoading: function () { e.element.loading.style.display = "block" }, closeLoading: function () { e.element.loading.style.display = "none" }, appendFormatTag: function (e, t) { const n = r.getFormatElement(this.getSelectionNode(), null), i = t ? "string" == typeof t ? t : t.nodeName : r.isFormatElement(n) && !r.isFreeFormatElement(n) ? n.nodeName : l.defaultTag, o = r.createElement(i); return o.innerHTML = " ", (t && "string" != typeof t || !t && r.isFormatElement(n)) && r.copyTagAttributes(o, t || n), r.isCell(e) ? e.insertBefore(o, e.nextElementSibling) : e.parentNode.insertBefore(o, e.nextElementSibling), o }, insertComponent: function (e, t, n, i) { if (n && !this.checkCharCount(e, null)) return null; const l = this.removeNode(); this.getRange_addLine(this.getRange(), l.container); let o = null, s = this.getSelectionNode(), a = r.getFormatElement(s, null); if (r.isListCell(a)) this.insertNode(e, s === 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)); o = r.splitElement(l.container, l.offset, e ? r.getElementDepth(e) + 1 : 0), o && (a = o.previousSibling) } this.insertNode(e, a, !1), a && r.onlyZeroWidthSpace(a) && r.removeItem(a) } if (this.setRange(e, 0, e, 0), !i) { const t = this.getFileComponent(e); t ? this.selectComponent(t.target, t.pluginName) : o && (o = r.getEdgeChildNodes(o, null).sc || o, this.setRange(o, 0, o, 0)) } return t || this.history.push(1), o || 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, o = "block" === this.context.resizing.resizeContainer.style.display ? this.context.resizing.resizeContainer : t, s = r.isListCell(n.parentNode); let a, c, d; (s ? 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 = o.offsetWidth / 2 / 2, i.top = a - c - 12 + "px", i.left = r.getOffset(o).left + d + "px", i.display = "block"), (s ? 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 = o.offsetWidth / 2 / 2), l.top = a + o.offsetHeight - c - 12 + "px", l.left = r.getOffset(o).left + o.offsetWidth - d - 24 + "px", l.display = "block") }, insertNode: function (t, n, i) { if (i && !this.checkCharCount(t, null)) return null; const o = r.getFreeFormatElement(this.getSelectionNode(), null), s = !o && (r.isFormatElement(t) || r.isRangeFormatElement(t)) || r.isComponent(t); if (!n && (s || r.isComponent(t) || r.isMedia(t))) { const e = this.removeNode(); if (3 === e.container.nodeType || r.isBreak(e.container)) { const t = r.getParentElement(e.container, function (e) { return this.isRangeFormatElement(e) || this.isListCell(e) }.bind(r)); (n = r.splitElement(e.container, e.offset, t ? r.getElementDepth(t) + 1 : 0)) && (n = n.previousSibling) } } const a = n || s ? this.getRange() : this.getRange_addLine(this.getRange(), null), c = a.commonAncestorContainer, d = a.startOffset, u = a.endOffset, h = a.startContainer === c && r.isFormatElement(c), p = h ? c.childNodes[d] || c.childNodes[0] : a.startContainer, g = h ? c.childNodes[u] || c.childNodes[c.childNodes.length - 1] : a.endContainer; let m, f = null; if (n) m = n.parentNode, n = n.nextSibling, f = !0; else if (m = p, 3 === p.nodeType && (m = p.parentNode), a.collapsed) if (3 === c.nodeType) n = c.textContent.length > u ? c.splitText(u) : c.nextSibling; else if (r.isBreak(m)) n = m, m = m.parentNode; else { let e = m.childNodes[d]; const i = e && 3 === e.nodeType && r.onlyZeroWidthSpace(e) && r.isBreak(e.nextSibling) ? e.nextSibling : e; i ? i.nextSibling ? n = r.isBreak(i) && !r.isBreak(t) ? i : i.nextSibling : (m.removeChild(i), n = null) : n = null } else { if (p === g) { n = this.isEdgePoint(g, u) ? g.nextSibling : g.splitText(u); let e = p; this.isEdgePoint(p, d) || (e = p.splitText(d)), m.removeChild(e), 0 === m.childNodes.length && s && (m.innerHTML = " ") } else { const e = this.removeNode(), t = e.container, i = e.prevContainer; if (t && 0 === t.childNodes.length && s && (r.isFormatElement(t) ? t.innerHTML = " " : r.isRangeFormatElement(t) && (t.innerHTML = "<" + l.defaultTag + "> " + l.defaultTag + ">")), !s && i) if (m = 3 === i.nodeType ? i.parentNode : i, m.contains(t)) { let e = !0; for (n = t; n.parentNode !== m;)n = n.parentNode, e = !1; e && t === i && (n = n.nextSibling) } else n = null; else m = (n = s ? g : t === i ? t.nextSibling : t) && n.parentNode ? n.parentNode : c; for (; n && !r.isFormatElement(n) && n.parentNode !== c;)n = n.parentNode } } try { if ((r.isWysiwygDiv(n) || m === e.element.wysiwyg.parentNode) && (m = e.element.wysiwyg, n = null), r.isFormatElement(t) || r.isRangeFormatElement(t) || !r.isListCell(m) && r.isComponent(t)) { const e = m; if (r.isList(n)) m = n, n = null; else if (r.isListCell(n)) m = n.previousElementSibling || n; else if (!f && !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); m = i ? t : t.parentNode, n = i ? null : t.nextSibling } 0 === e.childNodes.length && m !== e && r.removeItem(e) } if (!s || o || r.isRangeFormatElement(m) || r.isListCell(m) || r.isWysiwygDiv(m) || (n = m.nextElementSibling, m = m.parentNode), r.isWysiwygDiv(m) && (3 === t.nodeType || r.isBreak(t))) { const e = r.createElement(l.defaultTag); e.appendChild(t), t = e } m.insertBefore(t, m === n ? m.lastChild : n) } catch (e) { m.appendChild(t) } finally { if ((r.isFormatElement(t) || r.isComponent(t)) && p === g) { const e = r.getFormatElement(c, null); e && 1 === e.nodeType && r.isEmptyLine(e) && r.removeItem(e) } if (o && (r.isFormatElement(t) || r.isRangeFormatElement(t)) && (t = this._setIntoFreeFormat(t)), !r.isComponent(t)) { let e = 1; if (3 === t.nodeType) { const e = t.previousSibling, n = t.nextSibling, i = !e || 1 === e.nodeType || r.onlyZeroWidthSpace(e) ? "" : e.textContent, l = !n || 1 === n.nodeType || r.onlyZeroWidthSpace(n) ? "" : n.textContent; e && i.length > 0 && (t.textContent = i + t.textContent, r.removeItem(e)), n && n.length > 0 && (t.textContent += l, r.removeItem(n)); const o = { container: t, startOffset: i.length, endOffset: t.textContent.length - l.length }; return this.setRange(t, o.startOffset, t, o.endOffset), o } if (!r.isBreak(t) && r.isFormatElement(m)) { 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, o = t.endContainer, s = t.startOffset, a = t.endOffset; const c = 3 === t.commonAncestorContainer.nodeType && t.commonAncestorContainer.parentNode === l.parentNode ? l.parentNode : t.commonAncestorContainer; c === l && c === o && (l = c.children[s], o = c.children[a], s = a = 0); let d = null, u = null; const h = r.getListChildNodes(c, null); let p = r.getArrayIndex(h, l), g = r.getArrayIndex(h, o); if (h.length > 0 && p > -1 && g > -1) { for (let e = p + 1, t = l; e >= 0; e--)h[e] === t.parentNode && h[e].firstChild === t && 0 === s && (p = e, t = t.parentNode); for (let e = g - 1, t = o; e > p; e--)h[e] === t.parentNode && 1 === h[e].nodeType && (h.splice(e, 1), t = t.parentNode, --g) } 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 = o = c } else if (l = o = h[0], r.isBreak(l) || r.onlyZeroWidthSpace(l)) return { container: r.isMedia(c) ? c : l, offset: 0 }; p = g = 0 } function m(e) { const t = r.getFormatElement(e, null); if (r.removeItem(e), r.isListCell(t)) { const e = r.getArrayItem(t.children, r.isList, !1); if (e) { const n = e.firstElementChild, i = n.childNodes; for (; i[0];)t.insertBefore(i[0], e); r.removeItemAllParents(n, null, null) } } } for (let e = p; e <= g; e++) { const t = h[e]; if (0 === t.length || 3 === t.nodeType && void 0 === t.data) m(t); else if (t !== l) if (t !== o) m(t); else { if (1 === o.nodeType) { if (r.isComponent(o)) continue; u = r.createTextNode(o.textContent) } else u = r.createTextNode(o.substringData(a, o.length - a)); u.length > 0 ? o.data = u.data : m(o) } else { if (1 === l.nodeType) { if (r.isComponent(l)) continue; d = r.createTextNode(l.textContent) } else t === o ? (d = r.createTextNode(l.substringData(0, s) + o.substringData(a, o.length - a)), i = s) : d = r.createTextNode(l.substringData(0, s)); if (d.length > 0 ? l.data = d.data : m(l), t === o) break } } if (n = o && o.parentNode ? o : l && l.parentNode ? l : t.endContainer || t.startContainer, !r.isWysiwygDiv(n) && 0 === n.childNodes.length) { const t = r.removeItemAllParents(n, function (e) { if (this.isComponent(e)) return !1; const t = e.textContent; return 0 === t.length || /^(\n|\u200B)+$/.test(t) }.bind(r), null); t && (n = t.sc || t.ec || e.element.wysiwyg) } return this.setRange(n, i, n, i), this.history.push(!0), { container: n, offset: i, prevContainer: l && l.parentNode ? l : null } }, applyRangeFormatElement: function (e) { this.getRange_addLine(this.getRange(), null); const t = this.getSelectedElementsAndComponents(!1); if (!t || 0 === t.length) return; e: for (let e, n, i, l, o, s, a = 0, c = t.length; a < c; a++)if (e = t[a], r.isListCell(e)) if (n = e.lastElementChild, n && r.isListCell(e.nextElementSibling) && t.indexOf(e.nextElementSibling) > -1 && (l = n.lastElementChild, t.indexOf(l) > -1)) { let e = null; for (; e = l.lastElementChild;)if (r.isList(e)) { if (!(t.indexOf(e.lastElementChild) > -1)) continue e; l = e.lastElementChild } i = n.firstElementChild, o = t.indexOf(i), s = t.indexOf(l), t.splice(o, s - o + 1), c = t.length } else; let n, i, l, o = t[t.length - 1]; n = r.isRangeFormatElement(o) || r.isFormatElement(o) ? o : r.getRangeFormatElement(o, null) || r.getFormatElement(o, null), r.isCell(n) ? (i = null, l = n) : (i = n.nextSibling, l = n.parentNode); let s = r.getElementDepth(n), a = null; const c = [], d = function (e, t, n) { let i = null; if (e !== t && !r.isTable(t)) { if (t && r.getElementDepth(e) === r.getElementDepth(t)) return n; i = r.removeItemAllParents(t, null, e) } return i ? i.ec : n }; for (let n, o, u, h, p, g, m, f = 0, _ = t.length; f < _; f++)if (n = t[f], o = n.parentNode, o && !e.contains(o)) if (u = r.getElementDepth(n), r.isList(o)) { if (null === a && (g ? (a = g, m = !0, g = null) : a = o.cloneNode(!1)), c.push(n), p = t[f + 1], f === _ - 1 || p && p.parentNode !== o) { p && n.contains(p.parentNode) && (g = p.parentNode.cloneNode(!1)); let t, f = o.parentNode; for (; r.isList(f);)t = r.createElement(f.nodeName), t.appendChild(a), a = t, f = f.parentNode; const _ = this.detachRangeFormatElement(o, c, null, !0, !0); s >= u ? (s = u, l = _.cc, i = d(l, o, _.ec), i && (l = i.parentNode)) : l === _.cc && (i = _.ec), l !== _.cc && (h = d(l, _.cc, h), i = void 0 !== h ? h : _.cc); for (let e = 0, t = _.removeArray.length; e < t; e++)a.appendChild(_.removeArray[e]); m || e.appendChild(a), g && _.removeArray[_.removeArray.length - 1].appendChild(g), a = null, m = !1 } } else s >= u && (s = u, l = o, i = n.nextSibling), e.appendChild(n), l !== o && (h = d(l, o), void 0 !== h && (i = h)); if (this.effectNode = null, r.mergeSameTags(e, null, !1), r.mergeNestedTags(e, function (e) { return this.isList(e) }.bind(r)), i && r.getElementDepth(i) > 0 && (r.isList(i.parentNode) || r.isList(i.parentNode.parentNode))) { const t = r.getParentElement(i, function (e) { return this.isRangeFormatElement(e) && !this.isList(e) }.bind(r)), n = r.splitElement(i, null, t ? r.getElementDepth(t) + 1 : 0); n.parentNode.insertBefore(e, n) } else l.insertBefore(e, i), d(e, i); const u = r.getEdgeChildNodes(e.firstElementChild, e.lastElementChild); t.length > 1 ? this.setRange(u.sc, 0, u.ec, u.ec.textContent.length) : this.setRange(u.ec, u.ec.textContent.length, u.ec, u.ec.textContent.length), this.history.push(!1) }, detachRangeFormatElement: function (e, t, n, i, o) { const s = this.getRange(), a = s.startOffset, c = s.endOffset; let d = r.getListChildNodes(e, (function (t) { return t.parentNode === e })), u = e.parentNode, h = null, p = null, g = e.cloneNode(!1); const m = [], f = r.isList(n); let _ = !1, b = !1, v = !1; function y(t, n, i, l) { if (r.onlyZeroWidthSpace(n) && (n.innerHTML = r.zeroWidthSpace), 3 === n.nodeType) return t.insertBefore(n, i), n; const o = (v ? n : l).childNodes; let s = n.cloneNode(!1), a = null, c = null; for (; o[0];)c = o[0], !r._notTextNode(c) || r.isBreak(c) || r.isListCell(s) ? s.appendChild(c) : (s.childNodes.length > 0 && (a || (a = s), t.insertBefore(s, i), s = n.cloneNode(!1)), t.insertBefore(c, i), a || (a = c)); if (s.childNodes.length > 0) { if (r.isListCell(t) && r.isListCell(s) && r.isList(i)) if (f) { for (a = i; i;)s.appendChild(i), i = i.nextSibling; t.parentNode.insertBefore(s, t.nextElementSibling) } else { const t = l.nextElementSibling, n = r.detachNestedList(l, !1); if (e !== n || t !== l.nextElementSibling) { const t = s.childNodes; for (; t[0];)l.appendChild(t[0]); e = n, b = !0 } } else t.insertBefore(s, i); a || (a = s) } return a } for (let o, s, a, c = 0, C = d.length; c < C; c++)if (o = d[c], 3 !== o.nodeType || !r.isList(g)) if (v = !1, i && 0 === c && (h = t && t.length !== C && t[0] !== o ? g : e.previousSibling), t && (s = t.indexOf(o)), t && -1 === s) g || (g = e.cloneNode(!1)), g.appendChild(o); else { if (t && (a = t[s + 1]), g && g.children.length > 0 && (u.insertBefore(g, e), g = null), !f && r.isListCell(o)) if (a && r.getElementDepth(o) !== r.getElementDepth(a) && (r.isListCell(u) || r.getArrayItem(o.children, r.isList, !1))) { const t = o.nextElementSibling, n = r.detachNestedList(o, !1); e === n && t === o.nextElementSibling || (e = n, b = !0) } else { const t = o; o = r.createElement(i ? t.nodeName : r.isList(e.parentNode) || r.isListCell(e.parentNode) ? "LI" : r.isCell(e.parentNode) ? "DIV" : l.defaultTag); const n = r.isListCell(o), s = t.childNodes; for (; s[0] && (!r.isList(s[0]) || n);)o.appendChild(s[0]); r.copyFormatAttributes(o, t), v = !0 } else o = o.cloneNode(!1); if (!b && (i ? (m.push(o), r.removeItem(d[c])) : (n ? (_ || (u.insertBefore(n, e), _ = !0), o = y(n, o, null, d[c])) : o = y(u, o, e, d[c]), b || (t ? (p = o, h || (h = o)) : h || (h = p = o))), b)) { b = v = !1, d = r.getListChildNodes(e, (function (t) { return t.parentNode === e })), g = e.cloneNode(!1), u = e.parentNode, c = -1, C = d.length; continue } } const C = e.parentNode; let w = e.nextSibling; g && g.children.length > 0 && C.insertBefore(g, w), n ? h = n.previousSibling : h || (h = e.previousSibling), w = e.nextSibling, 0 === e.children.length || 0 === e.textContent.length ? r.removeItem(e) : r.removeEmptyNode(e, null); let x = null; if (i) x = { cc: C, sc: h, ec: w, removeArray: m }; else { h || (h = p), p || (p = h); const e = r.getEdgeChildNodes(h, p.parentNode ? h : p); x = { cc: (e.sc || e.ec).parentNode, sc: e.sc, ec: e.ec } } if (this.effectNode = null, o) return x; !i && x && (t ? this.setRange(x.sc, a, x.ec, c) : this.setRange(x.sc, 0, x.sc, 0)), this.history.push(!1) }, detachList: function (e, t) { let n = {}, i = !1, l = !1, o = null, s = null; const a = function (e) { return !this.isComponent(e) }.bind(r); for (let c, d, u, h, p = 0, g = e.length; p < g; p++) { if (u = p === g - 1, d = r.getRangeFormatElement(e[p], a), h = r.isList(d), !c && h) c = d, n = { r: c, f: [r.getParentElement(e[p], "LI")] }, 0 === p && (i = !0); else if (c && h) if (c !== d) { const a = this.detachRangeFormatElement(n.f[0].parentNode, n.f, null, t, !0); d = e[p].parentNode, i && (o = a.sc, i = !1), u && (s = a.ec), h ? (c = d, n = { r: c, f: [r.getParentElement(e[p], "LI")] }, u && (l = !0)) : c = null } else n.f.push(r.getParentElement(e[p], "LI")), u && (l = !0); if (u && r.isList(c)) { const e = this.detachRangeFormatElement(n.f[0].parentNode, n.f, null, t, !0); (l || 1 === g) && (s = e.ec), i && (o = e.sc || s) } } return { sc: o, ec: s } }, nodeChange: function (e, t, n, i) { this._resetRangeToTextNode(); let l = this.getRange_addLine(this.getRange(), null); t = !!(t && t.length > 0) && t, n = !!(n && n.length > 0) && n; const o = !e, s = o && !n && !t; let c = l.startContainer, d = l.startOffset, u = l.endContainer, h = l.endOffset; if (s && l.collapsed && r.isFormatElement(c.parentNode) && r.isFormatElement(u.parentNode) || c === u && 1 === c.nodeType && r.isNonEditable(c)) return; if (l.collapsed && !s && 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), o && (e = r.createElement("DIV")); const p = a.RegExp, g = e.nodeName; if (!s && c === u && !n && e) { let t = c, n = 0; const i = [], l = e.style; for (let e = 0, t = l.length; e < t; e++)i.push(l[e]); const s = e.classList; for (let e = 0, t = s.length; e < t; e++)i.push("." + s[e]); if (i.length > 0) { for (; !r.isFormatElement(t) && !r.isWysiwygDiv(t);) { for (let l = 0; l < i.length; l++)if (1 === t.nodeType) { const s = i[l], a = !!/^\./.test(s) && new p("\\s*" + s.replace(/^\./, "") + "(\\s+|$)", "ig"), r = o ? !!t.style[s] : !!t.style[s] && !!e.style[s] && t.style[s] === e.style[s], c = !1 !== a && (o ? !!t.className.match(a) : !!t.className.match(a) && !!e.className.match(a)); (r || c) && n++ } t = t.parentNode } if (n >= i.length) return } } let m, f = {}, _ = {}, b = "", v = "", y = ""; if (t) { for (let e, n = 0, i = t.length; n < i; n++)e = t[n], /^\./.test(e) ? v += (v ? "|" : "\\s*(?:") + e.replace(/^\./, "") : b += (b ? "|" : "(?:;|^|\\s)(?:") + e; b && (b += ")\\s*:[^;]*\\s*(?:;|$)", b = new p(b, "ig")), v && (v += ")(?=\\s+|$)", v = new p(v, "ig")) } if (n) { y = "^(?:" + n[0]; for (let e = 1; e < n.length; e++)y += "|" + n[e]; y += ")$", y = new p(y, "i") } const C = a.Boolean, w = { v: !1 }, x = function (e) { const t = e.cloneNode(!1); if (3 === t.nodeType || r.isBreak(t)) return t; if (s) return null; const n = !y && o || y && y.test(t.nodeName); if (n && !i) return w.v = !0, null; const l = t.style.cssText; let a = ""; b && l.length > 0 && (a = l.replace(b, "").trim(), a !== l && (w.v = !0)); const c = t.className; let d = ""; return v && c.length > 0 && (d = c.replace(v, "").trim(), d !== c && (w.v = !0)), (!o || !v && c || !b && l || a || d || !n) && (a || d || t.nodeName !== g || C(b) !== C(l) || C(v) !== C(c)) ? (b && l.length > 0 && (t.style.cssText = a), t.style.cssText || t.removeAttribute("style"), v && c.length > 0 && (t.className = d.trim()), t.className.trim() || t.removeAttribute("class"), t.style.cssText || t.className || t.nodeName !== g && !n ? t : (w.v = !0, null)) : (w.v = !0, null) }, E = this.getSelectedElements(null); l = this.getRange(), c = l.startContainer, d = l.startOffset, u = l.endContainer, h = l.endOffset, r.getFormatElement(c, null) || (c = r.getChildElement(E[0], (function (e) { return 3 === e.nodeType }), !1), d = 0), r.getFormatElement(u, null) || (u = r.getChildElement(E[E.length - 1], (function (e) { return 3 === e.nodeType }), !1), h = u.textContent.length); const S = r.getFormatElement(c, null) === r.getFormatElement(u, null), N = E.length - (S ? 0 : 1); m = e.cloneNode(!1); const T = s || o && function (e) { for (let t = 0, n = e.length; t < n; t++)if (r._isMaintainedNode(e[t]) || r._isSizeNode(e[t])) return !0; return !1 }(n), k = o || r._isSizeNode(m), L = this._util_getMaintainedNode.bind(r, T, k), B = this._util_isMaintainedNode.bind(r, T, k); if (S) { const e = this._nodeChange_oneLine(E[0], m, x, c, d, u, h, s, o, l.collapsed, w, L, B); f.container = e.startContainer, f.offset = e.startOffset, _.container = e.endContainer, _.offset = e.endOffset, f.container === _.container && r.onlyZeroWidthSpace(f.container) && (f.offset = _.offset = 1), this._setCommonListStyle(e.ancestor, null) } else { N > 0 && (m = e.cloneNode(!1), _ = this._nodeChange_endLine(E[N], m, x, u, h, s, o, w, L, B)); for (let t, n = N - 1; n > 0; n--)m = e.cloneNode(!1), t = this._nodeChange_middleLine(E[n], m, x, s, o, w, _.container), t.endContainer && (_.ancestor = null, _.container = t.endContainer), this._setCommonListStyle(t.ancestor, null); m = e.cloneNode(!1), f = this._nodeChange_startLine(E[0], m, x, c, d, s, o, w, L, B, _.container), f.endContainer && (_.ancestor = null, _.container = f.endContainer), N <= 0 ? _ = f : _.container || (_.ancestor = null, _.container = f.container, _.offset = f.container.textContent.length), this._setCommonListStyle(f.ancestor, null), this._setCommonListStyle(_.ancestor || r.getFormatElement(_.container), null) } this.controllersOff(), this.setRange(f.container, f.offset, _.container, _.offset), this.history.push(!1) }, _setCommonListStyle: function (e, t) { if (!r.isListCell(e)) return; t || e.removeAttribute("style"); const n = r.getArrayItem((t || e).childNodes, (function (e) { return !r.isBreak(e) && !r.onlyZeroWidthSpace(e.textContent.trim()) }), !0); if (n[0] && 1 === n.length) { if (!(t = n[0]) || 1 !== t.nodeType) return; const i = t.style, l = e.style; /STRONG/i.test(t.nodeName) ? l.fontWeight = "bold" : i.fontWeight && (l.fontWeight = i.fontWeight), i.color && (l.color = i.color), i.fontSize && (l.fontSize = i.fontSize), this._setCommonListStyle(e, t) } }, _stripRemoveNode: function (e) { const t = e.parentNode; if (!e || 3 === e.nodeType || !t) return; const n = e.childNodes; for (; n[0];)t.insertBefore(n[0], e); t.removeChild(e) }, _util_getMaintainedNode: function (e, t, n) { return !n || e ? null : this.getParentElement(n, this._isMaintainedNode.bind(this)) || (t ? null : this.getParentElement(n, this._isSizeNode.bind(this))) }, _util_isMaintainedNode: function (e, t, n) { if (!n || e || 1 !== n.nodeType) return !1; const i = this._isMaintainedNode(n); return this.getParentElement(n, this._isMaintainedNode.bind(this)) ? i : i || !t && this._isSizeNode(n) }, _nodeChange_oneLine: function (e, t, n, i, l, o, s, c, d, u, h, p, g) { let m = i.parentNode; for (; !(m.nextSibling || m.previousSibling || r.isFormatElement(m.parentNode) || r.isWysiwygDiv(m.parentNode)) && m.nodeName !== t.nodeName;)m = m.parentNode; if (!d && m === o.parentNode && m.nodeName === t.nodeName && r.onlyZeroWidthSpace(i.textContent.slice(0, l)) && r.onlyZeroWidthSpace(o.textContent.slice(s))) { const e = m.childNodes; let n = !0; for (let t, l, s, a, c = 0, d = e.length; c < d; c++)if (t = e[c], a = !r.onlyZeroWidthSpace(t), t !== i) if (t !== o) { if (!l && a || l && s && a) { n = !1; break } } else s = !0; else l = !0; if (n) return r.copyTagAttributes(m, t), { startContainer: i, startOffset: l, endContainer: o, endOffset: s } } h.v = !1; const f = e, _ = [t], b = e.cloneNode(!1), v = i === o; let y, C, w, x, E, S = i, N = l, T = o, k = s, L = !1, B = !1; const A = a.RegExp; function M(e) { const t = new A("(?:;|^|\\s)(?:" + x + "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, s = 0, a = o.length; s < a; s++) { let a = o[s]; if (!a) continue; let d, h = l; if (!L && a === S) { let e = b; E = p(a); const o = r.createTextNode(1 === S.nodeType ? "" : S.substringData(0, N)), s = r.createTextNode(1 === S.nodeType ? "" : S.substringData(N, v && k >= N ? k - N : S.data.length - N)); if (E) { const t = p(l); if (t && t.parentNode !== e) { let n = t, i = null; for (; n.parentNode !== e;) { for (l = i = n.parentNode.cloneNode(!1); n.childNodes[0];)i.appendChild(n.childNodes[0]); n.appendChild(i), n = n.parentNode } n.parentNode.appendChild(t) } E = E.cloneNode(!1) } r.onlyZeroWidthSpace(o) || l.appendChild(o); const c = p(l); for (c && (E = c), E && (e = E), C = a, y = [], x = ""; C !== e && C !== f && null !== C;)i = g(C) ? null : n(C), i && 1 === C.nodeType && M(C) && (y.push(i), x += C.style.cssText.substr(0, C.style.cssText.indexOf(":")) + "|"), C = C.parentNode; const d = y.pop() || s; for (w = C = d; y.length > 0;)C = y.pop(), w.appendChild(C), w = C; if (t.appendChild(d), e.appendChild(t), E && !p(T) && (t = t.cloneNode(!1), b.appendChild(t), _.push(t)), S = s, N = 0, L = !0, C !== s && C.appendChild(S), !v) continue } if (B || a !== T) { if (L) { if (1 === a.nodeType && !r.isBreak(a)) { r._isIgnoreNodeChange(a) ? (b.appendChild(a.cloneNode(!0)), u || (t = t.cloneNode(!1), b.appendChild(t), _.push(t))) : e(a, a); continue } C = a, y = [], x = ""; const o = []; for (; null !== C.parentNode && C !== f && C !== t;)i = B ? C.cloneNode(!1) : n(C), 1 === C.nodeType && !r.isBreak(a) && i && M(C) && (g(C) ? E || o.push(i) : y.push(i), x += C.style.cssText.substr(0, C.style.cssText.indexOf(":")) + "|"), C = C.parentNode; y = y.concat(o); const s = y.pop() || a; for (w = C = s; y.length > 0;)C = y.pop(), w.appendChild(C), w = C; if (!g(t.parentNode) || g(s) || r.onlyZeroWidthSpace(t) || (t = t.cloneNode(!1), b.appendChild(t), _.push(t)), B || E || !g(s)) s === a ? l = B ? b : t : B ? (b.appendChild(s), l = C) : (t.appendChild(s), l = C); else { t = t.cloneNode(!1); const e = s.childNodes; for (let n = 0, i = e.length; n < i; n++)t.appendChild(e[n]); s.appendChild(t), b.appendChild(s), _.push(t), l = t.children.length > 0 ? C : t } if (E && 3 === a.nodeType) if (p(a)) { const e = r.getParentElement(l, function (e) { return this._isMaintainedNode(e.parentNode) || e.parentNode === b }.bind(r)); E.appendChild(e), t = e.cloneNode(!1), _.push(t), b.appendChild(t) } else E = null } d = a.cloneNode(!1), l.appendChild(d), 1 !== a.nodeType || r.isBreak(a) || (h = d), e(a, h) } else { E = p(a); const e = r.createTextNode(1 === T.nodeType ? "" : T.substringData(k, T.length - k)), l = r.createTextNode(v || 1 === T.nodeType ? "" : T.substringData(0, k)); if (E ? E = E.cloneNode(!1) : g(t.parentNode) && !E && (t = t.cloneNode(!1), b.appendChild(t), _.push(t)), !r.onlyZeroWidthSpace(e)) { C = a, x = "", y = []; const t = []; for (; C !== b && C !== f && null !== C;)1 === C.nodeType && M(C) && (g(C) ? t.push(C.cloneNode(!1)) : y.push(C.cloneNode(!1)), x += C.style.cssText.substr(0, C.style.cssText.indexOf(":")) + "|"), C = C.parentNode; for (y = y.concat(t), d = w = C = y.pop() || e; y.length > 0;)C = y.pop(), w.appendChild(C), w = C; b.appendChild(d), C.textContent = e.data } if (E && d) { const e = p(d); e && (E = e) } for (C = a, y = [], x = ""; C !== b && C !== f && null !== C;)i = g(C) ? null : n(C), i && 1 === C.nodeType && M(C) && (y.push(i), x += C.style.cssText.substr(0, C.style.cssText.indexOf(":")) + "|"), C = C.parentNode; const o = y.pop() || l; for (w = C = o; y.length > 0;)C = y.pop(), w.appendChild(C), w = C; E ? ((t = t.cloneNode(!1)).appendChild(o), E.insertBefore(t, E.firstChild), b.appendChild(E), _.push(t), E = null) : t.appendChild(o), T = l, k = l.data.length, B = !0, !c && u && (t = l, l.textContent = r.zeroWidthSpace), C !== l && C.appendChild(T) } } }(e, b), d && !c && !h.v) return { ancestor: e, startContainer: i, startOffset: l, endContainer: o, endOffset: s }; if (c = c && d) for (let e = 0; e < _.length; e++) { let t, n, i, l = _[e]; if (u) t = r.createTextNode(r.zeroWidthSpace), b.replaceChild(t, l); else { const e = l.childNodes; for (n = e[0]; e[0];)i = e[0], b.insertBefore(i, l); r.removeItem(l) } 0 === e && (u ? S = T = t : (S = n, T = i)) } else { if (d) for (let e = 0; e < _.length; e++)this._stripRemoveNode(_[e]); u && (S = T = t) } r.removeEmptyNode(b, t), u && (N = S.textContent.length, k = T.textContent.length); const z = c || 0 === T.textContent.length; r.isBreak(T) || 0 !== T.textContent.length || (r.removeItem(T), T = S), k = z ? T.textContent.length : k; const H = { s: 0, e: 0 }, I = r.getNodePath(S, b, H), R = !T.parentNode; R && (T = S); const D = { s: 0, e: 0 }, O = r.getNodePath(T, b, R || z ? null : D); N += H.s, k = u ? N : R ? S.textContent.length : z ? k + H.s : k + D.s; const F = r.mergeSameTags(b, [I, O], !0); return e.parentNode.replaceChild(b, e), S = r.getNodeFromPath(I, b), T = r.getNodeFromPath(O, b), { ancestor: b, startContainer: S, startOffset: N + F[0], endContainer: T, endOffset: k + F[1] } }, _nodeChange_startLine: function (e, t, n, i, l, o, s, a, c, d, u) { let h = i.parentNode; for (; !(h.nextSibling || h.previousSibling || r.isFormatElement(h.parentNode) || r.isWysiwygDiv(h.parentNode)) && h.nodeName !== t.nodeName;)h = h.parentNode; if (!s && h.nodeName === t.nodeName && !r.isFormatElement(h) && !h.nextSibling && r.onlyZeroWidthSpace(i.textContent.slice(0, l))) { let n = !0, o = i.previousSibling; for (; o;) { if (!r.onlyZeroWidthSpace(o)) { n = !1; break } o = o.previousSibling } if (n) return r.copyTagAttributes(h, t), { ancestor: e, container: i, offset: l } } a.v = !1; const p = e, g = [t], m = e.cloneNode(!1); let f, _, b, v, y = i, C = l, w = !1; if (function e(i, l) { const o = i.childNodes; for (let i, s, a = 0, h = o.length; a < h; a++) { const h = o[a]; if (!h) continue; let x = l; if (w && !r.isBreak(h)) { if (1 === h.nodeType) { if (r._isIgnoreNodeChange(h)) { if (t = t.cloneNode(!1), s = h.cloneNode(!0), m.appendChild(s), m.appendChild(t), g.push(t), u && h.contains(u)) { const e = r.getNodePath(u, h); u = r.getNodeFromPath(e, s) } } else e(h, h); continue } _ = h, f = []; const o = []; for (; null !== _.parentNode && _ !== p && _ !== t;)i = n(_), 1 === _.nodeType && i && (d(_) ? v || o.push(i) : f.push(i)), _ = _.parentNode; f = f.concat(o); const a = f.length > 0, y = f.pop() || h; for (b = _ = y; f.length > 0;)_ = f.pop(), b.appendChild(_), b = _; if (d(t.parentNode) && !d(y) && (t = t.cloneNode(!1), m.appendChild(t), g.push(t)), !v && d(y)) { t = t.cloneNode(!1); const e = y.childNodes; for (let n = 0, i = e.length; n < i; n++)t.appendChild(e[n]); y.appendChild(t), m.appendChild(y), l = d(_) ? t : _, g.push(t) } else a ? (t.appendChild(y), l = _) : l = t; if (v && 3 === h.nodeType) if (c(h)) { const e = r.getParentElement(l, function (e) { return this._isMaintainedNode(e.parentNode) || e.parentNode === m }.bind(r)); v.appendChild(e), t = e.cloneNode(!1), g.push(t), m.appendChild(t) } else v = null } if (w || h !== y) i = w ? n(h) : h.cloneNode(!1), i && (l.appendChild(i), 1 !== h.nodeType || r.isBreak(h) || (x = i)), e(h, x); else { let e = m; v = c(h); const o = r.createTextNode(1 === y.nodeType ? "" : y.substringData(0, C)), s = r.createTextNode(1 === y.nodeType ? "" : y.substringData(C, y.length - C)); if (v) { const t = c(l); if (t && t.parentNode !== e) { let n = t, i = null; for (; n.parentNode !== e;) { for (l = i = n.parentNode.cloneNode(!1); n.childNodes[0];)i.appendChild(n.childNodes[0]); n.appendChild(i), n = n.parentNode } n.parentNode.appendChild(t) } v = v.cloneNode(!1) } r.onlyZeroWidthSpace(o) || l.appendChild(o); const a = c(l); for (a && (v = a), v && (e = v), _ = l, f = []; _ !== e && null !== _;)i = n(_), 1 === _.nodeType && i && f.push(i), _ = _.parentNode; const d = f.pop() || l; for (b = _ = d; f.length > 0;)_ = f.pop(), b.appendChild(_), b = _; d !== l ? (t.appendChild(d), l = _) : l = t, r.isBreak(h) && t.appendChild(h.cloneNode(!1)), e.appendChild(t), y = s, C = 0, w = !0, l.appendChild(y) } } }(e, m), s && !o && !a.v) return { ancestor: e, container: i, offset: l, endContainer: u }; if (o = o && s) for (let e = 0; e < g.length; e++) { let t = g[e]; const n = t.childNodes, i = n[0]; for (; n[0];)m.insertBefore(n[0], t); r.removeItem(t), 0 === e && (y = i) } else if (s) { t = t.firstChild; for (let e = 0; e < g.length; e++)this._stripRemoveNode(g[e]) } if (o || 0 !== m.childNodes.length) { r.removeEmptyNode(m, t), r.onlyZeroWidthSpace(m.textContent) && (y = m.firstChild, C = 0); const n = { s: 0, e: 0 }, i = r.getNodePath(y, m, n); C += n.s; const l = r.mergeSameTags(m, [i], !0); e.parentNode.replaceChild(m, e), y = r.getNodeFromPath(i, m), C += l[0] } else e.childNodes ? y = e.childNodes[0] : (y = r.createTextNode(r.zeroWidthSpace), e.appendChild(y)); return { ancestor: m, container: y, offset: C, endContainer: u } }, _nodeChange_middleLine: function (e, t, n, i, l, o, s) { if (!l) { let n = null; s && e.contains(s) && (n = r.getNodePath(s, e)); const i = e.cloneNode(!0), l = t.nodeName, o = t.style.cssText, a = t.className; let c, d = i.childNodes, u = 0, h = d.length; for (; u < h && (c = d[u], 3 !== c.nodeType); u++) { if (c.nodeName !== l) { if (!r.isBreak(c) && r._isIgnoreNodeChange(c)) continue; if (1 === h) { d = c.childNodes, h = d.length, u = -1; continue } break } c.style.cssText += o, r.addClass(c, a) } if (h > 0 && u === h) return e.innerHTML = i.innerHTML, { ancestor: e, endContainer: n ? r.getNodeFromPath(n, e) : null } } o.v = !1; const a = e.cloneNode(!1), c = [t]; let d = !0; if (function e(i, l) { const o = i.childNodes; for (let i, u, h = 0, p = o.length; h < p; h++) { let p = o[h]; if (!p) continue; let g = l; if (r.isBreak(p) || !r._isIgnoreNodeChange(p)) i = n(p), i && (d = !1, l.appendChild(i), 1 === p.nodeType && (g = i)), r.isBreak(p) || e(p, g); else if (t.childNodes.length > 0 && (a.appendChild(t), t = t.cloneNode(!1)), u = p.cloneNode(!0), a.appendChild(u), a.appendChild(t), c.push(t), l = t, s && p.contains(s)) { const e = r.getNodePath(s, p); s = r.getNodeFromPath(e, u) } } }(e, t), d || l && !i && !o.v) return { ancestor: e, endContainer: s }; if (a.appendChild(t), i && l) for (let e = 0; e < c.length; e++) { let t = c[e]; const n = t.childNodes; for (; n[0];)a.insertBefore(n[0], t); r.removeItem(t) } else if (l) { t = t.firstChild; for (let e = 0; e < c.length; e++)this._stripRemoveNode(c[e]) } return r.removeEmptyNode(a, t), r.mergeSameTags(a, null, !0), e.parentNode.replaceChild(a, e), { ancestor: a, endContainer: s } }, _nodeChange_endLine: function (e, t, n, i, l, o, s, a, c, d) { let u = i.parentNode; for (; !(u.nextSibling || u.previousSibling || r.isFormatElement(u.parentNode) || r.isWysiwygDiv(u.parentNode)) && u.nodeName !== t.nodeName;)u = u.parentNode; if (!s && u.nodeName === t.nodeName && !r.isFormatElement(u) && !u.previousSibling && r.onlyZeroWidthSpace(i.textContent.slice(l))) { let n = !0, o = i.nextSibling; for (; o;) { if (!r.onlyZeroWidthSpace(o)) { n = !1; break } o = o.nextSibling } if (n) return r.copyTagAttributes(u, t), { ancestor: e, container: i, offset: l } } a.v = !1; const h = e, p = [t], g = e.cloneNode(!1); let m, f, _, b, v = i, y = l, C = !1; if (function e(i, l) { const o = i.childNodes; for (let i, s = o.length - 1; 0 <= s; s--) { const a = o[s]; if (!a) continue; let u = l; if (C && !r.isBreak(a)) { if (1 === a.nodeType) { if (r._isIgnoreNodeChange(a)) { t = t.cloneNode(!1); const e = a.cloneNode(!0); g.insertBefore(e, l), g.insertBefore(t, e), p.push(t) } else e(a, a); continue } f = a, m = []; const o = []; for (; null !== f.parentNode && f !== h && f !== t;)i = n(f), i && 1 === f.nodeType && (d(f) ? b || o.push(i) : m.push(i)), f = f.parentNode; m = m.concat(o); const s = m.length > 0, u = m.pop() || a; for (_ = f = u; m.length > 0;)f = m.pop(), _.appendChild(f), _ = f; if (d(t.parentNode) && !d(u) && (t = t.cloneNode(!1), g.insertBefore(t, g.firstChild), p.push(t)), !b && d(u)) { t = t.cloneNode(!1); const e = u.childNodes; for (let n = 0, i = e.length; n < i; n++)t.appendChild(e[n]); u.appendChild(t), g.insertBefore(u, g.firstChild), p.push(t), l = t.children.length > 0 ? f : t } else s ? (t.insertBefore(u, t.firstChild), l = f) : l = t; if (b && 3 === a.nodeType) if (c(a)) { const e = r.getParentElement(l, function (e) { return this._isMaintainedNode(e.parentNode) || e.parentNode === g }.bind(r)); b.appendChild(e), t = e.cloneNode(!1), p.push(t), g.insertBefore(t, g.firstChild) } else b = null } if (C || a !== v) i = C ? n(a) : a.cloneNode(!1), i && (l.insertBefore(i, l.firstChild), 1 !== a.nodeType || r.isBreak(a) || (u = i)), e(a, u); else { b = c(a); const e = r.createTextNode(1 === v.nodeType ? "" : v.substringData(y, v.length - y)), o = r.createTextNode(1 === v.nodeType ? "" : v.substringData(0, y)); if (b) { b = b.cloneNode(!1); const e = c(l); if (e && e.parentNode !== g) { let t = e, n = null; for (; t.parentNode !== g;) { for (l = n = t.parentNode.cloneNode(!1); t.childNodes[0];)n.appendChild(t.childNodes[0]); t.appendChild(n), t = t.parentNode } t.parentNode.insertBefore(e, t.parentNode.firstChild) } b = b.cloneNode(!1) } else d(t.parentNode) && !b && (t = t.cloneNode(!1), g.appendChild(t), p.push(t)); for (r.onlyZeroWidthSpace(e) || l.insertBefore(e, l.firstChild), f = l, m = []; f !== g && null !== f;)i = d(f) ? null : n(f), i && 1 === f.nodeType && m.push(i), f = f.parentNode; const s = m.pop() || l; for (_ = f = s; m.length > 0;)f = m.pop(), _.appendChild(f), _ = f; s !== l ? (t.insertBefore(s, t.firstChild), l = f) : l = t, r.isBreak(a) && t.appendChild(a.cloneNode(!1)), b ? (b.insertBefore(t, b.firstChild), g.insertBefore(b, g.firstChild), b = null) : g.insertBefore(t, g.firstChild), v = o, y = o.data.length, C = !0, l.insertBefore(v, l.firstChild) } } }(e, g), s && !o && !a.v) return { ancestor: e, container: i, offset: l }; if (o = o && s) for (let e = 0; e < p.length; e++) { let t = p[e]; const n = t.childNodes; let i = null; for (; n[0];)i = n[0], g.insertBefore(i, t); r.removeItem(t), e === p.length - 1 && (v = i, y = i.textContent.length) } else if (s) { t = t.firstChild; for (let e = 0; e < p.length; e++)this._stripRemoveNode(p[e]) } if (o || 0 !== g.childNodes.length) { if (!s && 0 === t.textContent.length) return r.removeEmptyNode(g, null), { ancestor: null, container: null, offset: 0 }; r.removeEmptyNode(g, t), r.onlyZeroWidthSpace(g.textContent) ? (v = g.firstChild, y = v.textContent.length) : r.onlyZeroWidthSpace(v) && (v = t, y = 1); const n = { s: 0, e: 0 }, i = r.getNodePath(v, g, n); y += n.s; const l = r.mergeSameTags(g, [i], !0); e.parentNode.replaceChild(g, e), v = r.getNodeFromPath(i, g), y += l[0] } else e.childNodes ? v = e.childNodes[0] : (v = r.createTextNode(r.zeroWidthSpace), e.appendChild(v)); return { ancestor: g, container: v, offset: y } }, actionCall: function (t, n, i) { if (n) { if (/more/i.test(n) && i !== this._moreLayerActiveButton) { const n = e.element.toolbar.querySelector("." + t); return void (n && (this._moreLayerActiveButton && (e.element.toolbar.querySelector("." + this._moreLayerActiveButton.getAttribute("data-command")).style.display = "none", r.removeClass(this._moreLayerActiveButton, "on")), r.addClass(i, "on"), this._moreLayerActiveButton = i, n.style.display = "block", u._showToolbarBalloon(), u._showToolbarInline())) } if (/submenu/.test(n) && (null === this._menuTray[t] || i !== this.submenuActiveButton)) return void this.callPlugin(t, this.submenuOn.bind(this, i), i); if (/dialog/.test(n)) return void this.callPlugin(t, this.plugins[t].open.bind(this), i); if (/command/.test(n)) this.callPlugin(t, this.plugins[t].action.bind(this), i); else { if (/container/.test(n) && (null === this._menuTray[t] || i !== this.containerActiveButton)) return void this.callPlugin(t, this.containerOn.bind(this, i), i); /fileBrowser/.test(n) && this.callPlugin(t, this.plugins[t].open.bind(this, null), i) } } else t && this.commandHandler(i, t); if (/more/i.test(n)) { const t = e.element.toolbar.querySelector("." + this._moreLayerActiveButton.getAttribute("data-command")); t && (r.removeClass(this._moreLayerActiveButton, "on"), this._moreLayerActiveButton = null, t.style.display = "none", u._showToolbarBalloon(), u._showToolbarInline()) } else /submenu/.test(n) ? this.submenuOff() : /command/.test(n) || (this.submenuOff(), this.containerOff()) }, commandHandler: function (t, n) { switch (n) { case "copy": case "cut": this.execCommand(n); break; case "paste": break; case "selectAll": const i = e.element.wysiwyg; let o = r.getChildElement(i.firstChild, (function (e) { return 0 === e.childNodes.length || 3 === e.nodeType }), !1) || i.firstChild, s = r.getChildElement(i.lastChild, (function (e) { return 0 === e.childNodes.length || 3 === e.nodeType }), !0) || i.lastChild; if (!o || !s) return; if (r.isMedia(o)) { const e = this.getFileComponent(o), t = r.createElement("BR"), n = r.createElement(l.defaultTag); n.appendChild(t), o = e ? e.component : o, o.parentNode.insertBefore(n, o), o = t } if (r.isMedia(s)) { const e = r.createElement("BR"), t = r.createElement(l.defaultTag); t.appendChild(e), i.appendChild(t), s = e } this.setRange(o, 0, s, s.textContent.length); break; case "codeView": this.toggleCodeView(); break; case "fullScreen": this.toggleFullScreen(t); break; case "indent": case "outdent": this.indent(n); break; case "undo": this.history.undo(); break; case "redo": this.history.redo(); break; case "removeFormat": this.removeFormat(), this.focus(); break; case "print": this.print(); break; case "preview": this.preview(); break; case "showBlocks": this.toggleDisplayBlocks(); break; case "save": if ("function" == typeof l.callBackSave) l.callBackSave(this.getContents(!1), this._variable.isChanged); else { if (!this._variable.isChanged || "function" != typeof h.save) throw Error("[SUNEDITOR.core.commandHandler.fail] Please register call back function in creation option. (callBackSave : Function)"); h.save() } this._variable.isChanged = !1, e.tool.save && e.tool.save.setAttribute("disabled", !0); break; default: n = this._defaultCommand[n.toLowerCase()] || n, this.commandMap[n] || (this.commandMap[n] = t); const a = this._variable.currentNodesMap, c = a.indexOf(n) > -1 ? null : r.createElement(n); let d = n; /^SUB$/i.test(n) && a.indexOf("SUP") > -1 ? d = "SUP" : /^SUP$/i.test(n) && a.indexOf("SUB") > -1 && (d = "SUB"), this.nodeChange(c, null, [d], !1), this.focus() } }, removeFormat: function () { this.nodeChange(null, null, null, null) }, indent: function (e) { const t = this.getRange(), n = this.getSelectedElements(null), i = [], o = "indent" !== e, s = l.rtl ? "marginRight" : "marginLeft"; let a = t.startContainer, c = t.endContainer, d = t.startOffset, u = t.endOffset; for (let e, t, l = 0, a = n.length; l < a; l++)e = n[l], r.isListCell(e) && this.plugins.list ? (o || e.previousElementSibling) && i.push(e) : (t = /\d+/.test(e.style[s]) ? r.getNumber(e.style[s], 0) : 0, o ? t -= 25 : t += 25, r.setStyle(e, s, t <= 0 ? "" : t + "px")); i.length > 0 && this.plugins.list.editInsideList.call(this, o, i), this.effectNode = null, this.setRange(a, d, c, u), this.history.push(!1) }, toggleDisplayBlocks: function () { const t = e.element.wysiwyg; r.toggleClass(t, "se-show-block"), r.hasClass(t, "se-show-block") ? r.addClass(this._styleCommandMap.showBlocks, "active") : r.removeClass(this._styleCommandMap.showBlocks, "active"), this._resourcesStateChange() }, toggleCodeView: function () { const t = this._variable.isCodeView; this.controllersOff(), r.setDisabledButtons(!t, this.codeViewDisabledButtons), t ? (this._setCodeDataToEditor(), e.element.wysiwygFrame.scrollTop = 0, e.element.code.style.display = "none", e.element.wysiwygFrame.style.display = "block", this._variable._codeOriginCssText = this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, "display: none"), this._variable._wysiwygOriginCssText = this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, "display: block"), "auto" !== l.height || l.codeMirrorEditor || (e.element.code.style.height = "0px"), this._variable.isCodeView = !1, this._variable.isFullScreen || (this._notHideToolbar = !1, /balloon|balloon-always/i.test(l.mode) && (e.element._arrow.style.display = "", this._isInline = !1, this._isBalloon = !0, u._hideToolbar())), this.nativeFocus(), r.removeClass(this._styleCommandMap.codeView, "active"), this.history.push(!1)) : (this._setEditorDataToCodeView(), this._variable._codeOriginCssText = this._variable._codeOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, "display: block"), this._variable._wysiwygOriginCssText = this._variable._wysiwygOriginCssText.replace(/(\s?display(\s+)?:(\s+)?)[a-zA-Z]+(?=;)/, "display: none"), "auto" !== l.height || l.codeMirrorEditor || (e.element.code.style.height = e.element.code.scrollHeight > 0 ? e.element.code.scrollHeight + "px" : "auto"), l.codeMirrorEditor && l.codeMirrorEditor.refresh(), this._variable.isCodeView = !0, this._variable.isFullScreen || (this._notHideToolbar = !0, this._isBalloon && (e.element._arrow.style.display = "none", e.element.toolbar.style.left = "", this._isInline = !0, this._isBalloon = !1, u._showToolbarInline())), this._variable._range = null, e.element.code.focus(), r.addClass(this._styleCommandMap.codeView, "active")), this._checkPlaceholder(), "function" == typeof h.toggleCodeView && h.toggleCodeView(this._variable.isCodeView, this) }, _setCodeDataToEditor: function () { const t = this._getCodeView(); if (l.fullPage) { const e = this._parser.parseFromString(t, "text/html"), n = e.head.children; for (let t = 0, i = n.length; t < i; t++)/^script$/i.test(n[t].tagName) && (e.head.removeChild(n[t]), t--, i--); this._wd.head.innerHTML = e.head.innerHTML, this._wd.body.innerHTML = this.convertContentsForEditor(e.body.innerHTML); const i = e.body.attributes; for (let e = 0, t = i.length; e < t; e++)"contenteditable" !== i[e].name && this._wd.body.setAttribute(i[e].name, i[e].value); if (!r.hasClass(this._wd.body, "sun-editor-editable")) { const e = l._editableClass.split(" "); for (let t = 0; t < e.length; t++)r.addClass(this._wd.body, l._editableClass[t]) } } else e.element.wysiwyg.innerHTML = t.length > 0 ? this.convertContentsForEditor(t) : "<" + l.defaultTag + "> " + l.defaultTag + ">" }, _setEditorDataToCodeView: function () { const t = this.convertHTMLForCodeView(e.element.wysiwyg); let n = ""; if (l.fullPage) { const e = r.getAttributesToString(this._wd.body, null); n = "\n\n" + this._wd.head.outerHTML.replace(/>(?!\n)/g, ">\n") + "\n" + t + "\n" } else n = t; e.element.code.style.display = "block", e.element.wysiwygFrame.style.display = "none", this._setCodeView(n) }, toggleFullScreen: function (t) { const n = e.element.topArea, i = e.element.toolbar, o = e.element.editorArea, d = e.element.wysiwygFrame, p = e.element.code, g = this._variable; this.controllersOff(), g.isFullScreen ? (g.isFullScreen = !1, d.style.cssText = g._wysiwygOriginCssText, p.style.cssText = g._codeOriginCssText, i.style.cssText = "", o.style.cssText = g._editorAreaOriginCssText, n.style.cssText = g._originCssText, s.body.style.overflow = g._bodyOverflow, l.toolbarContainer && l.toolbarContainer.appendChild(i), l.stickyToolbar > -1 && r.removeClass(i, "se-toolbar-sticky"), g._fullScreenAttrs.sticky && !l.toolbarContainer && (g._fullScreenAttrs.sticky = !1, e.element._stickyDummy.style.display = "block", r.addClass(i, "se-toolbar-sticky")), this._isInline = g._fullScreenAttrs.inline, this._isBalloon = g._fullScreenAttrs.balloon, this._isInline && u._showToolbarInline(), l.toolbarContainer && r.removeClass(i, "se-toolbar-balloon"), u.onScroll_window(), r.changeElement(t.firstElementChild, c.expansion), e.element.topArea.style.marginTop = "", r.removeClass(this._styleCommandMap.fullScreen, "active")) : (g.isFullScreen = !0, g._fullScreenAttrs.inline = this._isInline, g._fullScreenAttrs.balloon = this._isBalloon, (this._isInline || this._isBalloon) && (this._isInline = !1, this._isBalloon = !1), l.toolbarContainer && e.element.relative.insertBefore(i, o), 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 && (g._fullScreenAttrs.sticky = !0, e.element._stickyDummy.style.display = "none", r.removeClass(i, "se-toolbar-sticky")), g._bodyOverflow = s.body.style.overflow, s.body.style.overflow = "hidden", g._editorAreaOriginCssText = o.style.cssText, g._wysiwygOriginCssText = d.style.cssText, g._codeOriginCssText = p.style.cssText, o.style.cssText = i.style.cssText = "", d.style.cssText = (d.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/) || [""])[0], p.style.cssText = (p.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/) || [""])[0], i.style.width = d.style.height = p.style.height = "100%", i.style.position = "relative", i.style.display = "block", g.innerHeight_fullScreen = a.innerHeight - i.offsetHeight, o.style.height = g.innerHeight_fullScreen - l.fullScreenOffset + "px", r.changeElement(t.firstElementChild, c.reduction), l.iframe && "auto" === l.height && (o.style.overflow = "auto", this._iframeAutoHeight()), e.element.topArea.style.marginTop = l.fullScreenOffset + "px", r.addClass(this._styleCommandMap.fullScreen, "active")), "function" == typeof h.toggleFullScreen && h.toggleFullScreen(this._variable.isFullScreen, this) }, print: function () { const e = r.createElement("IFRAME"); e.style.display = "none", s.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 = s.head.getElementsByTagName("link"), i = s.head.getElementsByTagName("style"); let o = ""; for (let t = 0, n = e.length; t < n; t++)o += e[t].outerHTML; for (let e = 0, t = i.length; e < t; e++)o += i[e].outerHTML; n.write("" + o + '' + t + "") } this.showLoading(), a.setTimeout((function () { try { if (e.focus(), r.isIE_Edge || s.documentMode || a.StyleMedia) try { e.contentWindow.document.execCommand("print", !1, null) } catch (t) { e.contentWindow.print() } else e.contentWindow.print() } catch (e) { throw Error("[SUNEDITOR.core.print.fail] error: " + e) } finally { d.closeLoading(), r.removeItem(e) } }), 1e3) }, preview: function () { d.submenuOff(), d.containerOff(), d.controllersOff(); const e = l.previewTemplate ? l.previewTemplate.replace(/\{\{\s*contents\s*\}\}/i, this.getContents(!0)) : this.getContents(!0), t = a.open("", "_blank"); t.mimeType = "text/html"; const n = this._wd; if (l.iframe) { const i = null !== l._printClass ? 'class="' + l._printClass + '"' : l.fullPage ? r.getAttributesToString(n.body, ["contenteditable"]) : 'class="' + l._editableClass + '"'; t.document.write("" + n.head.innerHTML + "" + e + "") } else { const n = s.head.getElementsByTagName("link"), o = s.head.getElementsByTagName("style"); let a = ""; for (let e = 0, t = n.length; e < t; e++)a += n[e].outerHTML; for (let e = 0, t = o.length; e < t; e++)a += o[e].outerHTML; t.document.write('' + i.toolbar.preview + "" + a + '' + e + "") } }, setContents: function (t) { this.removeRange(); const n = null == t ? "" : this.convertContentsForEditor(t); if (this._resetComponents(), this._variable.isCodeView) { const e = this.convertHTMLForCodeView(n); this._setCodeView(e) } else e.element.wysiwyg.innerHTML = n, this.history.push(!1) }, setIframeContents: function (e) { if (!l.iframe) return !1; e.head && (this._wd.head.innerHTML = e.head.replace(/