]*>/g,""),e=e.replace(/<\/div>/g,"
"),e=this.eventManager.emitReduce("wysiwygProcessHTMLText",e),e}},{key:"_prepareGetHTML",value:function(){var e=this;this.getEditor().modifyDocument((function(){e._joinSplitedTextNodes(),e.eventManager.emit("wysiwygGetValueBefore",e)}))}},{key:"postProcessForChange",value:function(){var e=this;this.isEditorValid()&&this.getEditor().modifyDocument((function(){e.eventManager.emit("wysiwygRangeChangeAfter",e)}))}},{key:"readySilentChange",value:function(){K&&!this.getEditor().isIgnoreChange()&&(this._silentChange=!0)}},{key:"getEditor",value:function(){return this.editor}},{key:"replaceSelection",value:function(e,t){this.getEditor().replaceSelection(e,t)}},{key:"replaceRelativeOffset",value:function(e,t,n){this.getEditor().replaceRelativeOffset(e,t,n)}},{key:"addWidget",value:function(e,t,n,r){var i=this.getEditor().getSelectionPosition(e,n,r),o=this.$editorContainerEl.offset();this.$editorContainerEl.append(t),(0,a.default)(t).css({position:"absolute",top:i.top-o.top+this.scrollTop(),left:i.left-o.left})}},{key:"get$Body",value:function(){return this.getEditor().get$Body()}},{key:"hasFormatWithRx",value:function(e){return this.getEditor().getPath().match(e)}},{key:"breakToNewDefaultBlock",value:function(e,t){var n=this.editor.createDefaultBlock(),r=c.default.getChildNodeByOffset(e.startContainer,e.startOffset)||c.default.getChildNodeByOffset(e.startContainer,e.startOffset-1),i=c.default.getParentUntil(r,this.get$Body()[0]);"before"===t?(0,a.default)(i).before(n):(0,a.default)(i).after(n),e.setStart(n,0),e.collapse(!0),this.setRange(e)}},{key:"replaceContentText",value:function(e,t,n){var r=(0,a.default)(e).html();(0,a.default)(e).html(r.replace(t,n))}},{key:"unwrapBlockTag",value:function(e){e||(e=function(e){return q.test(e)}),this.getEditor().changeBlockFormat(e),this.eventManager.emit("wysiwygRangeChangeAfter",this)}},{key:"scrollIntoCursor",value:function(){var e=this.scrollTop(),t=this.getEditor().getCursorPosition(),n=t.top,r=t.height,i=this.$editorContainerEl.get(0).getBoundingClientRect(),a=i.top,o=i.height,s=n-a,l=n+r-(a+o);s<0?this.scrollTop(e+s):l>0&&this.scrollTop(Math.ceil(e+l))}},{key:"moveCursorToEnd",value:function(){this.getEditor().moveCursorToEnd(),this.scrollIntoCursor(),this._correctRangeAfterMoveCursor("end")}},{key:"moveCursorToStart",value:function(){this.getEditor().moveCursorToStart(),this.scrollTop(0)}},{key:"scrollTop",value:function(e){return s.default.isUndefined(e)?this.$editorContainerEl.scrollTop():this.$editorContainerEl.scrollTop(e)}},{key:"_correctRangeAfterMoveCursor",value:function(e){var t=this.getRange(),n=this.get$Body().get(0);if("start"===e)while(n.firstChild)n=n.firstChild;else while(n.lastChild)n=n.lastChild;"BR"===n.tagName?t.setStartBefore(n):t.setStartAfter(n),t.collapse(!0),this.setRange(t)}},{key:"getRange",value:function(){return this.getEditor().getSelection().cloneRange()}},{key:"getIMERange",value:function(){var e=void 0,t=getSelection();return t&&t.rangeCount&&(e=t.getRangeAt(0).cloneRange()),e}},{key:"fixIMERange",value:function(){var e=this.getIMERange();e&&(0,a.default)(e.commonAncestorContainer).closest(this.$editorContainerEl).length&&this.setRange(e)}},{key:"setRange",value:function(e){this.getEditor().setSelection(e)}},{key:"isInTable",value:function(e){var t=e.collapsed?e.startContainer:e.commonAncestorContainer;return!!(0,a.default)(t).closest("[contenteditable=true] table").length}},{key:"getTextObject",value:function(e){return new M.default(this,e)}},{key:"defer",value:function(e,t){var n=this,r=t||0;setTimeout((function(){n.isEditorValid()&&e(n)}),r)}},{key:"isEditorValid",value:function(){return this.getEditor()&&a.default.contains(this.$editorContainerEl[0].ownerDocument,this.$editorContainerEl[0])}},{key:"_isCursorNotInRestrictedAreaOfTabAction",value:function(e){return!e.hasFormat("li")&&!e.hasFormat("blockquote")&&!e.hasFormat("table")}}],[{key:"factory",value:function(t,n,r){var i=new e(t,n,r);return i.init(r.useDefaultHTMLSanitizer),i.componentManager.addManager(p.default),i.componentManager.addManager(f.default),i.componentManager.addManager(S.default),i.componentManager.addManager(h.default),i.componentManager.addManager(b.default),i.componentManager.addManager(y.default),i.componentManager.addManager(N.default),i.componentManager.addManager(R.default),i}}]),e}();t.default=Q},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n
");this._extendRange(o),s.append(o.cloneContents()),this._updateCopyDataForListTypeIfNeed(o,s),this.wwe.eventManager.emit("copyBefore",{source:"wysiwyg",$clipboardContainer:s}),this._setClipboardData(i,s.html(),s.text())}else t.createRangeBySelectedCells()}},{key:"_clearClipboardArea",value:function(){this._$clipboardArea&&(this._$clipboardArea.remove(),this._$clipboardArea=null)}},{key:"_onCopyAfter",value:function(){this.wwe.getEditor().get$Body().focus(),this._clearClipboardArea()}},{key:"_onCutAfter",value:function(){var e=this.wwe.getEditor().getSelection();e.deleteContents(),this.wwe.getEditor().focus(),this._clearClipboardArea()}},{key:"_onPasteIntoTable",value:function(e){var t=e.data,n=this.wwe.getEditor().getSelection();this.wwe.isInTable(n)&&this._isSingleCellSelected(n)&&this._tablePasteHelper.pasteClipboard(t)}},{key:"_isSingleCellSelected",value:function(e){var t=e.startContainer,n=e.endContainer;return this._getCell(t)===this._getCell(n)}},{key:"_getCell",value:function(e){return"TD"===e.nodeName?e:c.default.getParentUntil(e,"TR")}},{key:"_replaceNewLineToBr",value:function(e){var t=c.default.getAllTextNode(e);t.forEach((function(e){/\n/.test(e.nodeValue)&&(e.parentNode.innerHTML=e.nodeValue.replace(/\n/g,"
"))}))}},{key:"_onWillPaste",value:function(e){var t=this,n=e.data,r=(0,a.default)("
").append(n.fragment.cloneNode(!0));this._preparePaste(r),this._setTableBookmark(r),n.fragment=document.createDocumentFragment(),r.contents().each((function(e,t){n.fragment.appendChild(t)}));var i=function e(){t.wwe.getEditor().removeEventListener("input",e),t.wwe.eventManager.emit("wysiwygRangeChangeAfter",t),t._focusTableBookmark()};this.wwe.getEditor().addEventListener("input",i)}},{key:"_setClipboardData",value:function(e,t,n){s.default.browser.msie?(e.squirePrevented=!0,this._$clipboardArea=this._createClipboardArea(),this._$clipboardArea.html(t),this._$clipboardArea.focus(),window.getSelection().selectAllChildren(this._$clipboardArea[0])):(e.preventDefault(),e.stopPropagation(),e.clipboardData.setData("text/html",t),e.clipboardData.setData("text/plain",n))}},{key:"_createClipboardArea",value:function(){return(0,a.default)("
").attr({contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"}).appendTo(document.body)}},{key:"_updateCopyDataForListTypeIfNeed",value:function(e,t){var n=e.commonAncestorContainer.nodeName;if("UL"===n||"OL"===n){var r=(0,a.default)("<"+n+" />");r.append(t.html()),t.html(""),t.append(r)}}},{key:"_removeEmptyFontElement",value:function(e){e.children("font").each((function(e,t){var n=(0,a.default)(t);n.text().trim()||n.remove()}))}},{key:"_isFromMs",value:function(e){return/
"),o=void 0,l=void 0,u=void 0;this._pasteFirstAid(e);var d=s.default.toArray(e[0].childNodes);while(d.length)l=d[0],o=c.default.getNodeName(l),u="LI"===o||"UL"===o||"OL"===o,n.isInCodeBlock(t)?i.append(n.prepareToPasteOnCodeblock(d)):u?(i.append(this._prepareToPasteList(d,t,r)),r=!0):i.append(d.shift());e.html(i.html())}},{key:"_wrapOrphanNodeWithDiv",value:function(e){var t=(0,a.default)("
"),n=s.default.toArray(e[0].childNodes),r=void 0;return s.default.forEachArray(n,(function(e){var n=3===e.nodeType,i=/^(SPAN|A|CODE|EM|I|STRONG|B|S|U|ABBR|ACRONYM|CITE|DFN|KBD|SAMP|VAR|BDO|Q|SUB|SUP)$/gi.test(e.tagName),o="BR"===e.nodeName;n||i||o?(r||(r=document.createElement("div"),t.append(r)),r.appendChild(e),o&&(r=null)):(r&&"BR"!==r.lastChild.tagName&&r.appendChild((0,a.default)("
")[0]),r=null,t.append(e))})),t.html()}},{key:"_pasteFirstAid",value:function(e){var t=this,n="div, section, article, aside, nav, menus, p";e.html((0,d.default)(e.html(),!0)),e.find("*").each((function(e,n){t._removeStyles(n)})),this._unwrapIfNonBlockElementHasBr(e),this._unwrapNestedBlocks(e,n),this._removeUnnecessaryBlocks(e,n),e.html(this._wrapOrphanNodeWithDiv(e)),this._preElementAid(e),this._tableElementAid(e),e.children("br").remove()}},{key:"_preElementAid",value:function(e){var t=this.wwe.componentManager.getManager("codeblock");t.modifyCodeBlockForWysiwyg(e)}},{key:"_unwrapIfNonBlockElementHasBr",value:function(e){var t=e.find("span, a, b, em, i, s");t.each((function(e,t){var n=(0,a.default)(t).children("br");n.length&&"LI"!==t.nodeName&&"UL"!==t.nodeName&&n.eq(0).unwrap()}))}},{key:"_unwrapNestedBlocks",value:function(e,t){var n=e.find(":not(:has(*))").not("b,s,i,em,code,span,hr");n.each((function(n,r){var i="BR"===r.nodeName?(0,a.default)(r.parentNode):(0,a.default)(r);while(i.parents(t).length){var o=i.parent(t);o.length&&o[0]!==e[0]?i.unwrap():i=i.parent()}}))}},{key:"_removeUnnecessaryBlocks",value:function(e,t){e.find(t).each((function(e,n){var r=(0,a.default)(n),i=n.tagName,o="DIV"===i,s=0!==r.parent("li").length,l=0!==r.parent("blockquote").length,c=r.children(t).length;o&&(s||l||!c)||(n.lastChild&&"BR"!==n.lastChild.nodeName&&r.append(document.createElement("br")),r.replaceWith(r.html()))}))}},{key:"_removeStyles",value:function(e){var t=(0,a.default)(e),n=void 0;"SPAN"!==c.default.getNodeName(t[0])?t.removeAttr("style"):(t.attr("style")&&(n=t.css("color")),t.removeAttr("style"),n?t.css("color",n):t.contents().unwrap())}},{key:"_prepareToPasteList",value:function(e,t,n){var r=c.default.getNodeName(e[0]),i=e.shift(),o=this.wwe.getEditor().getDocument().createDocumentFragment();if("LI"!==r&&e.length&&"LI"===e[0].tagName&&(r="LI",i=this._makeNodeAndAppend({tagName:r},i)),"OL"===r||"UL"===r)!n&&this.wwe.getEditor().hasFormat("LI")?(0,a.default)(o).append(this._wrapCurrentFormat(i)):(0,a.default)(o).append(i);else if("LI"===r){var s=this.wwe.getEditor().getDocument().createDocumentFragment();s.appendChild(i);while(e.length&&"LI"===e[0].tagName)s.appendChild(e.shift());!n&&this.wwe.getEditor().hasFormat("LI")?(0,a.default)(o).append(this._wrapCurrentFormat(s)):!t||"UL"!==t.commonAncestorName&&"OL"!==t.commonAncestorName?(0,a.default)(o).append(this._makeNodeAndAppend({tagName:"UL"},s)):(0,a.default)(o).append(this._makeNodeAndAppend({tagName:t.commonAncestorName},s))}return o}},{key:"_unwrapFragmentFirstChildForPasteAsInline",value:function(e){return(0,a.default)(e).find("br").remove(),e.childNodes}},{key:"_wrapCurrentFormat",value:function(e){var t=this,n=void 0;return this._eachCurrentPath((function(r){"DIV"!==r.tagName&&(n=c.default.isElemNode(e)?e.tagName:e.firstChild.tagName,r.tagName!==n&&(e=t._makeNodeAndAppend(r,e)))})),e}},{key:"_eachCurrentPath",value:function(e){for(var t=c.default.getPath(this.wwe.getEditor().getSelection().startContainer,this.wwe.get$Body()[0]),n=t.length-1;n>-1;n-=1)e(t[n])}},{key:"_makeNodeAndAppend",value:function(e,t){var n=(0,a.default)("<"+e.tagName+"/>");return n.append(t),e.id&&n.attr("id",e.id),e.className&&n.addClass(e.className),n[0]}},{key:"_tableElementAid",value:function(e){this._removeColgroup(e),this._completeTableIfNeed(e),this._updateTableIDClassName(e)}},{key:"_removeColgroup",value:function(e){e.find("colgroup").remove()}},{key:"_completeTableIfNeed",value:function(e){var t=this.wwe.componentManager.getManager("table"),n=t.wrapDanglingTableCellsIntoTrIfNeed(e);n&&e.append(n);var r=t.wrapTrsIntoTbodyIfNeed(e);r&&e.append(r);var i=t.wrapTheadAndTbodyIntoTableIfNeed(e);i&&e.append(i)}},{key:"_updateTableIDClassName",value:function(e){var t=this.wwe.componentManager.getManager("table");e.find("table").each((function(e,t){(0,a.default)(t).removeClass((function(e,t){return t.replace(/.*\s*(te-content-table-\d+)\s*.*/,"$1")}))})),e.find("table").each((function(e,n){(0,a.default)(n).addClass(t.getTableIDClassName())}))}}]),e}();t.default=m},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n
-1&&a>-1&&(e=e.slice(i+n.length,a)),/<\/td>((?!<\/tr>)[\s\S])*$/i.test(e)&&(e=""+e+"
"),/<\/tr>((?!<\/table>)[\s\S])*$/i.test(e)&&(e=""),t.appendChild((0,c.default)(e)),this._pasteClipboardContainer(t)}},{key:"_pasteClipboardContainer",value:function(e){var t=this.wwe.getEditor(),n=e.childNodes,r=1===n.length&&"TABLE"===n[0].nodeName;if(r){var i=this.wwe.componentManager.getManager("table");i.pasteTableData(e)}else{var a=t.getSelection().cloneRange(),o=this._preparePasteDocumentFragment(e);t.saveUndoState(a),a.collapsed||this._deleteContentsRange(a),s.default.isTextNode(a.startContainer)?this._pasteIntoTextNode(a,o):this._pasteIntoElements(a,o),t.setSelection(a)}}},{key:"_preparePasteDocumentFragment",value:function(e){var t=e.childNodes,n=document.createDocumentFragment();return t.length?n.appendChild(this._unwrapBlock(e)):this._isPossibleInsertToTable(e)&&n.appendChild(e),n}},{key:"_unwrapBlock",value:function(e){var t=document.createDocumentFragment(),n=a.default.toArray(e.childNodes);while(n.length){var r=n.shift();if(this._isPossibleInsertToTable(r))t.appendChild(r);else{t.appendChild(this._unwrapBlock(r));var i=t.lastChild;n.length&&i&&"BR"!==i.nodeName&&t.appendChild(document.createElement("br"))}}return t}},{key:"_isPossibleInsertToTable",value:function(e){var t=e.nodeName,n="CODE"===t&&e.childNodes.length>1,r="UL"===t||"OL"===t;return!n&&(r||s.default.isMDSupportInlineNode(e)||s.default.isTextNode(e))}},{key:"_pasteIntoElements",value:function(e,t){var n=e.startContainer,r=e.startOffset,i=s.default.getChildNodeByOffset(n,r);if(i)n.insertBefore(t,i),e.setStart(i,0);else if("TD"===n.nodeName)n.appendChild(t),e.setStart(n,n.childNodes.length);else{var a=n.parentNode,o=n.nextSibling;a.insertBefore(t,o),o?e.setStart(o,0):e.setStartAfter(a.lastChild)}e.collapse(!0)}},{key:"_pasteIntoTextNode",value:function(e,t){var n=e.startContainer,r=e.startOffset,i=n.parentNode,o=n.textContent,l=o.slice(0,r),c=o.slice(r,o.length),u=t.childNodes,d=u[0],_=1===u.length&&s.default.isTextNode(d);if(l)if(c)if(_){var p=d.textContent;n.textContent=""+l+p+c,e.setStart(n,l.length+p.length)}else{var m=document.createDocumentFragment();m.appendChild(document.createTextNode(l)),m.appendChild(t),m.appendChild(document.createTextNode(c)),i.replaceChild(m,n);var f=a.default.toArray(i.childNodes),g=0;f.forEach((function(e,t){e.textContent===c&&(g=t)})),e.setStart(i.childNodes[g],0)}else{var h=n.nextSibling;i.insertBefore(t,h),e.setStartAfter(h)}else i.insertBefore(t,n),e.setStart(n,0);e.collapse(!0)}},{key:"_deleteContentsRange",value:function(e){var t=e.startContainer,n=e.startOffset,r=e.endContainer,i=e.endOffset;t===r?(this._deleteContentsByOffset(t,n,i),e.setStart(t,n),e.collapse(!0)):this._deleteNotCollapsedRangeContents(e)}},{key:"_deleteNotCollapsedRangeContents",value:function(e){var t=e.startContainer,n=e.startOffset,r=e.endContainer,i=e.endOffset,a=e.commonAncestorContainer,o=this._getBlock(t,a,n),l=this._getBlock(r,a,i-1);if(o===l)this._removeInSameBlock(o,t,r,n,i),l=r!==l?null:l;else{var c=o.nextSibling;"TD"===t.nodeName?c=this._removeOneLine(o):(this._deleteContentsByOffset(t,n,s.default.getOffsetLength(t)),s.default.removeNodesByDirection(o,t,!1)),"TD"===r.nodeName?l=this._removeOneLine(l):(this._deleteContentsByOffset(r,0,i),s.default.removeNodesByDirection(l,r,!0)),s.default.removeChildFromStartToEndNode(a,c,l)}l?e.setStart(l,0):e.setStartAfter(o),e.collapse(!0)}},{key:"_removeInSameBlock",value:function(e,t,n,r,i){var a=t===e?r:0,o=n===e?i:s.default.getOffsetLength(e);this._deleteContentsByOffset(e,a,o)}},{key:"_removeOneLine",value:function(e){var t=e.nextSibling,n=e.parentNode,r=t;return n.removeChild(e),t&&"BR"===t.nodeName&&(r=t.nextSibling,n.removeChild(t)),r}},{key:"_getBlock",value:function(e,t,n){return s.default.getParentUntil(e,t)||s.default.getChildNodeByOffset(e,n)}},{key:"_deleteContentsByOffset",value:function(e,t,n){if(s.default.isTextNode(e)){var r=e.textContent,i=r.slice(0,t),a=r.slice(n,r.length);e.textContent=""+i+a}else{var o=s.default.getChildNodeByOffset(e,t),l=s.default.getChildNodeByOffset(e,n);o&&s.default.removeChildFromStartToEndNode(e,o,l||null)}}}]),e}();t.default=_},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n]*>)(.*?)(<\/(?:th|td)>)/g,g=/<(ul|ol|li)([^>]*)>/g,h=function(){function e(t){d(this,e),this.wwe=t,this.eventManager=t.eventManager,this.name="list",this._init()}return r(e,[{key:"_init",value:function(){this._initEvent(),this._initKeyHandler()}},{key:"_initEvent",value:function(){var e=this;this.eventManager.listen("wysiwygSetValueBefore",(function(t){return e._convertToArbitraryNestingList(t)})),this.eventManager.listen("wysiwygRangeChangeAfter",(function(){e._findAndRemoveEmptyList(),e._removeBranchListAll()})),this.eventManager.listen("wysiwygSetValueAfter",(function(){e._removeBranchListAll()})),this.eventManager.listen("wysiwygProcessHTMLText",(function(t){return t=e._convertFromArbitraryNestingList(t),t})),this.eventManager.listen("convertorBeforeHtmlToMarkdownConverted",(function(t){return e._insertDataToMarkPassForListInTable(t)}))}},{key:"_initKeyHandler",value:function(){var e=this;this.wwe.addKeyEventHandler(["TAB","CTRL+]","META+]"],(function(t){var n=void 0;return e.wwe.getEditor().hasFormat("LI")&&(t.preventDefault(),e.eventManager.emit("command","Indent"),n=!1),n})),this.wwe.addKeyEventHandler(["SHIFT+TAB","CTRL+[","META+["],(function(t,n){var r=void 0;if(e.wwe.getEditor().hasFormat("LI")){t.preventDefault();var i=(0,a.default)(n.startContainer).closest("li").children(m);e.eventManager.emit("command","Outdent"),i.length&&!i.prev().length&&e._removeBranchList(i),r=!1}return r})),this.wwe.addKeyEventHandler("ENTER",(function(t,n){n.collapsed&&e.wwe.getEditor().hasFormat("LI")&&e.wwe.defer((function(){var t=e.wwe.getRange(),n=(0,a.default)(t.startContainer).parents("li").eq(0);e._removeBranchListAll(n)}))})),this.wwe.addKeyEventHandler("BACK_SPACE",(function(t,n){n.collapsed&&e.wwe.getEditor().hasFormat("LI")&&e.wwe.defer((function(){e._removeBranchListAll()}))}))}},{key:"_findAndRemoveEmptyList",value:function(){this.wwe.get$Body().find(m).each((function(e,t){_.test(t.innerHTML)||(0,a.default)(t).remove()}))}},{key:"_removeBranchListAll",value:function(e){var t=this;e=e?(0,a.default)(e):this.wwe.get$Body(),e.find("li ul, li ol").each((function(e,n){n&&!n.previousSibling&&t._removeBranchList(n)}))}},{key:"_removeBranchList",value:function(e){var t=(0,a.default)(e),n=t;while(!n[0].previousSibling&&n[0].parentElement.tagName.match(/UL|OL|LI/g))n=n.parent();var r=n.children("li").eq(0);n.prepend(t.children().unwrap()),r.remove()}},{key:"_convertToArbitraryNestingList",value:function(e){var t="li > ul, li > ol",n=document.createElement("div");n.innerHTML=e;var r=n.querySelector(t);while(null!==r){var i=r.parentNode,a=i.parentNode;a.insertBefore(r,i.nextElementSibling),r=n.querySelector(t)}return n.innerHTML}},{key:"_convertFromArbitraryNestingList",value:function(e){var t="ol > ol, ol > ul, ul > ol, ul > ul",n=document.createElement("div");n.innerHTML=e;var r=n.querySelector(t);while(null!==r){var i=r.previousElementSibling;while(i&&"LI"!==i.tagName)i=i.previousElementSibling;i?i.appendChild(r):this._unwrap(r),r=n.querySelector(t)}return n.innerHTML}},{key:"_unwrap",value:function(e){var t=document.createDocumentFragment();while(e.firstChild)t.appendChild(e.firstChild);e.parentNode.replaceChild(t,e)}},{key:"_insertDataToMarkPassForListInTable",value:function(e){var t=e.replace(f,(function(e,t,n,r){var i=n.replace(g,'<$1 data-tomark-pass="" $2>');return""+t+i+r}));return t}},{key:"getLinesOfSelection",value:function(e,t){var n=[],r=!1,i=!0,o=void 0;c.default.isTextNode(e)&&(e=(0,a.default)(e).parents(p).first().get(0)),c.default.isTextNode(t)&&(t=(0,a.default)(t).parents(p).first().get(0));for(var s=e;i;s=o){if(!(0,a.default)(s).is(p))break;n.push(s),s===t?r=!0:o=this._getNextLine(s,t),i=o&&!r}return n}},{key:"_getNextLine",value:function(e,t){var n=e.nextElementSibling;return n?(0,a.default)(n).is(m)&&(n=n.querySelector("li")):n=e.parentNode.nextElementSibling,(0,a.default)(n).is(p)||n===t?n:this._getNextLine(n)}},{key:"mergeList",value:function(e){var t=e.parentNode,n=t.previousElementSibling,r=t.nextElementSibling;t.firstElementChild===e&&n&&(0,a.default)(n).is(m)&&(this._mergeList(t,n),t=n),t.lastElementChild===e&&r&&(0,a.default)(r).is(m)&&this._mergeList(r,t)}},{key:"_mergeList",value:function(e,t){var n=e.firstElementChild;if(t&&(0,a.default)(t).is(m)){while(n){var r=n.nextElementSibling;t.appendChild(n),n=r}e.parentNode.removeChild(e)}}},{key:"isAvailableMakeListInTable",value:function(){var e=this.wwe.componentManager.getManager("tableSelection"),t=e.getSelectedCells(),n=this.wwe.getEditor();return 0===t.length&&n.hasFormat("table")&&!n.hasFormat("OL")&&!n.hasFormat("UL")}},{key:"_getParentNodeBeforeTD",value:function(e,t){var n=c.default.getParentUntil(e,"TD");if(!n){var r=e.childNodes,i=r?r.length:0,a=t>0&&t===i?t-1:t;n=c.default.getChildNodeByOffset(e,a)}return n}},{key:"_findLINodeInsideTD",value:function(e,t){var n=null,r=c.default.getParentUntilBy(e,(function(e){return e&&c.default.isListNode(e)}),(function(e){return e&&"TD"===e.nodeName}));if(r)n=r;else if("LI"===e.nodeName)n=e;else if(c.default.isListNode(e)){var i=e.childNodes.length;n=e.childNodes[t>=i?i-1:t]}return n}},{key:"_getFirstNodeInLineOfTable",value:function(e,t){var n=this._findLINodeInsideTD(e,t);if(!n){n=this._getParentNodeBeforeTD(e,t);var r=n,i=r.previousSibling;while(i&&"BR"!==i.nodeName&&!c.default.isListNode(i))n=i,i=n.previousSibling}return n}},{key:"_getLastNodeInLineOfTable",value:function(e,t){var n=this._findLINodeInsideTD(e,t);if(!n){n=this._getParentNodeBeforeTD(e,t);while(n.nextSibling){if("BR"===n.nodeName||c.default.isListNode(n))break;n=n.nextSibling}}return n}},{key:"_isLastNodeInLineOfTable",value:function(e){var t=e.nodeName;return"LI"===t||"BR"===t}},{key:"_getNextNodeInLineOfTable",value:function(e){var t=e.nextSibling;if("LI"!==e.nodeName||t)c.default.isListNode(t)&&(t=t.firstChild);else{var n=e.parentNode;while("TD"!==n.nodeName){if(n.nextSibling){t=n.nextSibling;break}n=n.parentNode}}return t}},{key:"_getLinesOfSelectionInTable",value:function(e){var t=e.startContainer,n=e.endContainer,r=e.startOffset,i=e.endOffset,a=this._getFirstNodeInLineOfTable(t,r),o=this._getLastNodeInLineOfTable(n,i),s=[],l=[];while(a){if(l.push(a),this._isLastNodeInLineOfTable(a)&&(s.push(l),l=[]),a===o){l.length&&s.push(l);break}a=this._getNextNodeInLineOfTable(a)}return s}},{key:"_createListElement",value:function(e){return document.createElement("TASK"===e?"UL":e)}},{key:"_createListItemElement",value:function(e,t){var n=document.createElement("li");if(e.forEach((function(e){n.appendChild(e)})),"TASK"===t){var r=this.wwe.componentManager.getManager("task");r.formatTask(n)}return n}},{key:"_mergeListWithPreviousSibiling",value:function(e){var t=e.previousSibling,n=e;return t&&e.nodeName===t.nodeName&&(this._mergeList(e,t),n=t),n}},{key:"_mergeListWithNextSibiling",value:function(e){var t=e.nextSibling;return t&&e.nodeName===t.nodeName&&this._mergeList(t,e),e}},{key:"createListInTable",value:function(e,t){var n=this,r=this._getLinesOfSelectionInTable(e),i=r[r.length-1],a=i[i.length-1],o=a.nextSibling,l=a.parentNode,c=this._createListElement(t),u=c,d=u.nodeName,_=[];return r.forEach((function(e){var r=e[0],i=void 0;if("LI"===r.nodeName){var a=r.parentNode;if(i=r,a.nodeName!==d){var o=a.childNodes;s.default.forEachArray(o,(function(){c.appendChild(a.firstChild)})),a.parentNode.replaceChild(c,a)}c=i.parentNode}else i=n._createListItemElement(e,t),c.appendChild(i);_.push(i)})),c.parentNode||l.insertBefore(c,o),c=this._mergeListWithPreviousSibiling(c),this._mergeListWithNextSibiling(c),_}},{key:"adjustRange",value:function(e,t,n,r,i){var a=c.default.containsNode(i[0],e)?e:i[0],o=c.default.containsNode(i[i.length-1],t)?t:i[i.length-1],s="TD"===e.nodeName?0:n,l="TD"===t.nodeName?0:r;this.wwe.setSelectionByContainerAndOffset(a,s,o,l)}}]),e}();t.default=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n");t.html(e),t.find("p").each((function(e,t){var n=t.innerHTML,r=n.split(/
/gi),i=r.length-1,o=t.nextElementSibling||t.nextSibling,s="";s=r.map((function(e,t){var n="";return t>0&&t"),e&&(n=""+e+"
"),n})),o&&"P"===o.nodeName&&s.push("
"),(0,a.default)(t).replaceWith((0,a.default)(s.join("")))})),e=t.html()}return e}},{key:"_ensurePtagContentWrappedWithDiv",value:function(){this.wwe.get$Body().find("p").each((function(e,t){(0,a.default)(t).find("div").length<=0&&(0,a.default)(t).wrapInner(""),(0,a.default)(t).next().is("p")&&(0,a.default)(t).append("
")}))}},{key:"_unwrapPtags",value:function(){this.wwe.get$Body().find("div").each((function(e,t){(0,a.default)(t).parent().is("p")&&(0,a.default)(t).unwrap()}))}}]),e}();t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n")}))}},{key:"_unwrapHeading",value:function(){this.wwe.unwrapBlockTag((function(e){return u.test(e)}))}},{key:"_onEnter",value:function(e,t){var n=this;t.startOffset>0?this.wwe.defer((function(e){n._unwrapHeading(),e.getEditor().removeLastUndoStack()})):(e.preventDefault(),this._insertEmptyBlockToPrevious(t))}},{key:"_insertEmptyBlockToPrevious",value:function(e){this.wwe.getEditor().saveUndoState(e),(0,a.default)("
").insertBefore(s.default.getParentUntil(e.startContainer,this.wwe.get$Body()[0]))}},{key:"_removePrevTopNodeIfNeed",value:function(e,t){var n=!1;if(t.collapsed&&0===t.startOffset){var r=t.startContainer,i=s.default.getTopPrevNodeUnder(r,this.wwe.get$Body()[0]),o=i&&0===i.textContent.length,l=this.wwe.getEditor();0===r.textContent.length?n=this._removeHedingAndChangeSelection(e,t,i):o&&(e.preventDefault(),l.saveUndoState(t),(0,a.default)(i).remove(),n=!0)}return n}},{key:"_removeHedingAndChangeSelection",value:function(e,t,n){var r=t.startContainer,i=this.wwe.getEditor(),o=this.wwe.get$Body(),l=u.test(s.default.getNodeName(r)),c=l?r:(0,a.default)(r).parents("h1,h2,h3,h4,h5,h6")[0],d=n,_=1;return e.defaultPrevented||(e.preventDefault(),i.saveUndoState(t)),(0,a.default)(c).remove(),n||(d=o.children("div").first().get(0),_=0),t.setStart(d,_),t.collapse(!0),i.setSelection(t),!0}}]),e}();t.default=d},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1)throw new Error("too many"+e+"handlers in squire");var n=t[0].bind(this);t[0]=function(e){e.defaultPrevented||e.squirePrevented||n(e)}}},{key:"changeBlockFormat",value:function(e,t){var n=this;this.modifyBlocks((function(r){var i=void 0,a=void 0,o=void 0,l=void 0,c=void 0,u=void 0,_=void 0;if(r.childNodes.length?i=r.childNodes.item(0):(i=n.createDefaultBlock(),r.appendChild(i)),e){while(i.firstChild)i=i.firstChild;_=function(e){l.appendChild(e)};while(i!==r){var p=i;if(c=p.tagName,s.default.isFunction(e)?e(c):c===e){l=i.childNodes.item(0),(!d.default.isElemNode(l)||i.childNodes.length>1)&&(l=n.createDefaultBlock(),s.default.forEachArray(s.default.toArray(i.childNodes),_),u=l.lastChild,u&&"BR"===d.default.getNodeName(u)&&l.removeChild(u)),o=t?n.createElement(t,[l]):l,a=n.getDocument().createDocumentFragment(),a.appendChild(o),r=a;break}i=i.parentNode}}return a&&e||!t||"DIV"!==d.default.getNodeName(r.childNodes[0])||(r=n.createElement(t,[r.childNodes[0]])),r}))}},{key:"changeBlockFormatTo",value:function(e){this.changeBlockFormat((function(e){return h.test(e)}),e)}},{key:"getCaretPosition",value:function(){return this.getCursorPosition()}},{key:"replaceSelection",value:function(e,t){t&&this.setSelection(t),this._ignoreChange=!0,this.insertHTML(e)}},{key:"replaceRelativeOffset",value:function(e,t,n){var r=this.getSelection().cloneRange();this._replaceRelativeOffsetOfSelection(e,t,n,r)}},{key:"_replaceRelativeOffsetOfSelection",value:function(e,t,n,r){var i=void 0,a=void 0,o=void 0,s=r.endContainer,l=r.endOffset;"TEXT"!==d.default.getNodeName(s)&&(s=this._getClosestTextNode(s,l),s&&(l=d.default.isTextNode(s)?s.nodeValue.length:s.textContent.length)),s?(i=this.getSelectionInfoByOffset(s,l+t),r.setStart(i.element,i.offset),o=l+(t+n),a=this.getSelectionInfoByOffset(s,o),r.setEnd(a.element,a.offset),this.replaceSelection(e,r)):this.replaceSelection(e)}},{key:"_getClosestTextNode",value:function(e,t){var n=d.default.getChildNodeByOffset(e,t-1);return"TEXT"!==d.default.getNodeName(n)&&(n=n.previousSibling),n}},{key:"getSelectionInfoByOffset",value:function(e,t){var n=void 0,r=void 0,i=void 0,a=void 0,o=t>=0?"next":"previous",s=Math.abs(t),l=n;n="next"===o?e:e.previousSibling,i=s,a=0;while(n){if(r=d.default.isTextNode(n)?n.nodeValue.length:n.textContent.length,a+=r,s<=a)break;i-=r,d.default.getTextLength(n)>0&&(l=n),n=n[o+"Sibling"]}return n||(n=l,i=d.default.getTextLength(n)),"previous"===o&&(i=d.default.getTextLength(n)-i),{element:n,offset:i}}},{key:"getSelectionPosition",value:function(e,t,n){var r=this.createElement("INPUT"),i=e.cloneRange(),o=this.getSelectionInfoByOffset(e.endContainer,e.endOffset+(n||0));i.setStart(i.startContainer,i.startOffset),i.setEnd(o.element,o.offset),this._ignoreChange=!0,this.insertElement(r,i);var s=(0,a.default)(r).offset();return"over"!==t&&(s.top+=(0,a.default)(r).outerHeight()),r.parentNode.removeChild(r),e.setStart(e.endContainer,e.endOffset),e.collapse(!0),this.setSelection(e),s}},{key:"removeLastUndoStack",value:function(){this._undoStack.length&&(this._undoStackLength-=1,this._undoIndex-=1,this._undoStack.pop(),this._isInUndoState=!1)}},{key:"replaceParent",value:function(e,t,n){var r=(0,a.default)(e).closest(t);r.length&&(r.wrapInner("<"+n+"/>"),r.children().unwrap())}},{key:"preserveLastLine",value:function(){var e=this.get$Body().children().last();"DIV"!==d.default.getNodeName(e[0])&&(this._ignoreChange=!0,(0,a.default)(this.createDefaultBlock()).insertAfter(e))}},{key:"scrollTop",value:function(e){return s.default.isUndefined(e)?this.get$Body().scrollTop():this.get$Body().scrollTop(e)}},{key:"isIgnoreChange",value:function(){return this._ignoreChange}},{key:"focus",value:function(){c.default.prototype.focus.call(this)}},{key:"blockCommandShortcuts",value:function(){var e=this,t=_.isMac?"meta":"ctrl",n=["b","i","u","shift-7","shift-5","shift-6","shift-8","shift-9","[","]","d"];n.forEach((function(n){e.setKeyHandler(t+"-"+n,(function(e,t){t.preventDefault()}))}))}}]),t}(c.default);t.default=S},function(e,t){e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&e.setStart(e.startContainer,e.startOffset-1)}},{key:"expandEndOffset",value:function(){var e=this._range;s.default.isTextNode(e.endContainer)&&e.endOffsettext"),this.$el.append(this._$languageLabel),this._$buttonOpenModalEditor=(0,o.default)(''),this.$el.append(this._$buttonOpenModalEditor),this._eventManager.emit("removeEditor",(function(){e._$buttonOpenModalEditor.off("click"),e._$buttonOpenModalEditor=null}))}},{key:"_initDOMEvent",value:function(){var e=this;this._$buttonOpenModalEditor.on("click",(function(){return e._openPopupCodeBlockEditor()}))}},{key:"_openPopupCodeBlockEditor",value:function(){this._eventManager.emit("openPopupCodeBlockEditor",this.getAttachedElement())}},{key:"_updateLanguage",value:function(){var e=this.getAttachedElement(),t=e?e.getAttribute("data-language"):null;this._$languageLabel.text(t||"text")}},{key:"syncLayout",value:function(){var e=(0,o.default)(this.getAttachedElement()),t=e.offset();t.left=t.left+(e.outerWidth()-m),this.$el.offset(t),this.$el.height(f),this.$el.width(m)}},{key:"onShow",value:function(){var e=this;i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onShow",this).call(this),this._onAttachedElementChange=function(){return e._updateLanguage()},(0,o.default)(this.getAttachedElement()).on(p,this._onAttachedElementChange),this._updateLanguage()}},{key:"onHide",value:function(){(0,o.default)(this.getAttachedElement()).off(p,this._onAttachedElementChange),i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onHide",this).call(this)}}]),t}(l.default);t.default=g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n'),this.$el.css({position:"absolute",display:"none","z-index":1}),this._$container.append(this.$el)}},{key:"_initEvent",value:function(){var e=this;this._eventManager.listen("change",this._onChange.bind(this)),this._eventManager.listen("mouseover",this._onMouseOver.bind(this)),this._eventManager.listen("focus",(function(){e.setVisibility(!1)})),this._eventManager.listen("mousedown",(function(){e.setVisibility(!1)}))}},{key:"_onChange",value:function(){this._$attachedElement&&a.default.contains(document,this._$attachedElement[0])?this.syncLayout():this.setVisibility(!1)}},{key:"_onMouseOver",value:function(e){var t=e.data,n=(0,a.default)(t.target),r=n.closest(this._attachedSelector);r.length?(this._$attachedElement=r,this.setVisibility(!0)):n.closest(this.$el).length?this.setVisibility(!0):this.active||this.setVisibility(!1)}},{key:"syncLayout",value:function(){this.$el.offset(this._$attachedElement.offset()),this.$el.width(this._$attachedElement.outerWidth()),this.$el.height(this._$attachedElement.outerHeight())}},{key:"getAttachedElement",value:function(){return this._$attachedElement?this._$attachedElement.get(0):null}},{key:"getVisibility",value:function(){return"block"===this.$el.css("display")}},{key:"setVisibility",value:function(e){e&&this._$attachedElement?this.getVisibility()||(this.$el.css("display","block"),this.syncLayout(),this.onShow()):e||this.getVisibility()&&(this.$el.css("display","none"),this.onHide())}},{key:"onShow",value:function(){}},{key:"onHide",value:function(){this.active=!1,this._$attachedElement=null}}]),e}();t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n','",'",""].join(""),c=function(){function e(t,n){s(this,e),this.$el=(0,a.default)(t.el),this.height=t.height,this.type=t.initialEditType,this.eventManager=n,this.init(),this._initEvent()}return r(e,[{key:"init",value:function(){this._renderLayout(),this._initMarkdownAndPreviewSection(),this._initWysiwygSection()}},{key:"_initEvent",value:function(){this.eventManager.listen("hide",this.hide.bind(this)),this.eventManager.listen("show",this.show.bind(this))}},{key:"_renderLayout",value:function(){this.$el.css("box-sizing","border-box"),this.$containerEl=(0,a.default)(l).appendTo(this.$el)}},{key:"switchToWYSIWYG",value:function(){this.$containerEl.removeClass("te-md-mode"),this.$containerEl.addClass("te-ww-mode")}},{key:"switchToMarkdown",value:function(){this.$containerEl.removeClass("te-ww-mode"),this.$containerEl.addClass("te-md-mode")}},{key:"_initMarkdownAndPreviewSection",value:function(){this.$mdEditorContainerEl=this.$containerEl.find(".te-md-container .te-editor"),this.$previewEl=this.$containerEl.find(".te-md-container .te-preview")}},{key:"_initWysiwygSection",value:function(){this.$wwEditorContainerEl=this.$containerEl.find(".te-ww-container .te-editor")}},{key:"_verticalSplitStyle",value:function(){this.$containerEl.find(".te-md-container").removeClass("te-preview-style-tab"),this.$containerEl.find(".te-md-container").addClass("te-preview-style-vertical")}},{key:"_tabStyle",value:function(){this.$containerEl.find(".te-md-container").removeClass("te-preview-style-vertical"),this.$containerEl.find(".te-md-container").addClass("te-preview-style-tab")}},{key:"changePreviewStyle",value:function(e){"tab"===e?this._tabStyle():"vertical"===e&&this._verticalSplitStyle()}},{key:"hide",value:function(){this.$el.find(".tui-editor").addClass("te-hide")}},{key:"show",value:function(){this.$el.find(".tui-editor").removeClass("te-hide")}},{key:"remove",value:function(){this.$el.find(".tui-editor").remove()}},{key:"getEditorEl",value:function(){return this.$containerEl}},{key:"getPreviewEl",value:function(){return this.$previewEl}},{key:"getMdEditorContainerEl",value:function(){return this.$mdEditorContainerEl}},{key:"getWwEditorContainerEl",value:function(){return this.$wwEditorContainerEl}}]),e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n
\n \n \n \n \n',U=function(){function e(t){M(this,e),Object.defineProperty(this,"name",{enumerable:!0,writable:!0,value:"default"}),Object.defineProperty(this,"_popups",{enumerable:!0,writable:!0,value:[]}),this._editor=t,this._initialEditType=t.options.initialEditType,this._init(t.options),this._initEvent()}return r(e,[{key:"_init",value:function(e){var t=e.el,n=e.toolbarItems,r=e.hideModeSwitch;this.$el=(0,a.default)(F).appendTo(t),this._container=t,this._editorSection=this.$el.find("."+P).get(0),this._editorSection.appendChild(this._editor.layout.getEditorEl().get(0)),this._initToolbar(this._editor.eventManager,n),this._initModeSwitch(r),this._initPopupAddLink(),this._initPopupAddImage(),this._initPopupAddTable(),this._initPopupAddHeading(),this._initPopupTableUtils(),this._initPopupCodeBlockLanguages(),this._initPopupCodeBlockEditor(),this._initMarkdownTab()}},{key:"_initEvent",value:function(){this._editor.eventManager.listen("hide",this.hide.bind(this)),this._editor.eventManager.listen("show",this.show.bind(this)),this._editor.eventManager.listen("changeMode",this._markdownTabControl.bind(this)),this._editor.eventManager.listen("changePreviewStyle",this._markdownTabControl.bind(this))}},{key:"_initToolbar",value:function(e,t){var n=new s.default(e,t);this._toolbar=n,this.$el.find("."+k).append(n.$el)}},{key:"_initModeSwitch",value:function(e){var t=this,n=this.$el.find("."+B),r="markdown"===this._initialEditType?p.default.TYPE.MARKDOWN:p.default.TYPE.WYSIWYG,i=new p.default(n,r);this._modeSwitch=i,e&&i.hide(),i.on("modeSwitched",(function(e,n){return t._editor.changeMode(n)}))}},{key:"_initMarkdownTab",value:function(){var e=this._editor;this._markdownTab=new c.default({initName:I.default.get("Write"),items:[I.default.get("Write"),I.default.get("Preview")],sections:[e.layout.getMdEditorContainerEl(),e.layout.getPreviewEl()]}),this._$markdownTabSection=this.$el.find("."+L),this._$markdownTabSection.append(this._markdownTab.$el),this._markdownTab.on("itemClick",(function(t,n){n===I.default.get("Preview")?(e.eventManager.emit("previewNeedsRefresh"),e.eventManager.emit("changePreviewTabPreview"),e.eventManager.emit("closeAllPopup")):(e.getCodeMirror().focus(),e.eventManager.emit("changePreviewTabWrite"))}))}},{key:"_markdownTabControl",value:function(){this._editor.isMarkdownMode()&&"tab"===this._editor.getCurrentPreviewStyle()?(this._$markdownTabSection.show(),this._markdownTab.activate(I.default.get("Write"))):this._$markdownTabSection.hide()}},{key:"_initPopupAddLink",value:function(){this._popups.push(new f.default({$target:this.$el,editor:this._editor}))}},{key:"_initPopupAddImage",value:function(){this._popups.push(new h.default({$target:this.$el,eventManager:this._editor.eventManager}))}},{key:"_initPopupAddTable",value:function(){this._popups.push(new b.default({$target:this._toolbar.$el,eventManager:this._editor.eventManager,$button:this.$el.find("button.tui-table"),css:{position:"absolute"}}))}},{key:"_initPopupAddHeading",value:function(){this._popups.push(new y.default({$target:this._toolbar.$el,eventManager:this._editor.eventManager,$button:this.$el.find("button.tui-heading"),css:{position:"absolute"}}))}},{key:"_initPopupTableUtils",value:function(){var e=this;this._editor.eventManager.listen("contextmenu",(function(t){(0,a.default)(t.data.target).parents("[contenteditable=true] table").length>0&&(t.data.preventDefault(),e._editor.eventManager.emit("openPopupTableUtils",t.data))})),this._popups.push(new S.default({$target:this.$el,eventManager:this._editor.eventManager}))}},{key:"_initPopupCodeBlockLanguages",value:function(){var e=this._editor;this._popups.push(new N.default({$target:this.$el,eventManager:e.eventManager,languages:e.options.codeBlockLanguages}))}},{key:"_initPopupCodeBlockEditor",value:function(){this._popups.push(new R.default({$target:this.$el,eventManager:this._editor.eventManager,convertor:this._editor.convertor}))}},{key:"getToolbar",value:function(){return this._toolbar}},{key:"setToolbar",value:function(e){this._toolbar.destroy(),this._toolbar=e}},{key:"getModeSwitch",value:function(){return this._modeSwitch}},{key:"getEditorSectionHeight",value:function(){var e=this._editorSection.getBoundingClientRect();return e.bottom-e.top}},{key:"getEditorHeight",value:function(){var e=this._container.getBoundingClientRect();return e.bottom-e.top}},{key:"getPopupTableUtils",value:function(){var e=void 0;return this._popups.forEach((function(t){t instanceof S.default&&(e=t)})),e}},{key:"hide",value:function(){this.$el.addClass("te-hide")}},{key:"show",value:function(){this.$el.removeClass("te-hide")}},{key:"remove",value:function(){this.$el.remove(),this._markdownTab.remove(),this._modeSwitch.remove(),this._toolbar.destroy(),this._popups.forEach((function(e){return e.remove()})),this._popups=[],D.default.hide()}},{key:"createPopup",value:function(e){return new d.default(e)}}]),e}();t.default=U},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n
r}));o.forEach((function(t){e.removeItem(t,!1),e._popupDropdownToolbar.addItem(t)})),this._arrangeMoreButton()}},{key:"_arrangeMoreButton",value:function(){if(this._popupDropdownToolbar){this.removeItem(this._moreButton,!1);var e=this._popupDropdownToolbar.getItems().length>0,n=this.getItems().length;e&&i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"insertItem",this).call(this,n,this._moreButton)}}},{key:"destroy",value:function(){this._observer&&(this._observer.disconnect(),this._observer=null)}}]),t}(u.default);t.default=v},function(e,t,n){"use strict";n.r(t),function(e){var n=function(){if("undefined"!==typeof Map)return Map;function e(e,t){var n=-1;return e.some((function(e,r){return e[0]===t&&(n=r,!0)})),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n0},e.prototype.connect_=function(){r&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),u?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){r&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t,r=c.some((function(e){return!!~n.indexOf(e)}));r&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),_=function(e,t){for(var n=0,r=Object.keys(t);n0},e}(),A="undefined"!==typeof WeakMap?new WeakMap:new n,I=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=d.getInstance(),r=new R(t,n,this);A.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach((function(e){I.prototype[e]=function(){var t;return(t=A.get(this))[e].apply(t,arguments)}}));var w=function(){return"undefined"!==typeof i.ResizeObserver?i.ResizeObserver:I}();t["default"]=w}.call(this,n(75))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"===typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(19),i=a(r);function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function l(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(e){function t(){return o(this,t),s(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),t}(i.default);t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n'+d.default.get("Markdown")+""),this._buttons.$wysiwyg=(0,a.default)('"),this.$el.append(this._buttons.$markdown),this.$el.append(this._buttons.$wysiwyg),e&&(e.append(this.$el),this._$rootElement=e),this.on("click .markdown",this._changeMarkdown.bind(this)),this.on("click .wysiwyg",this._changeWysiwyg.bind(this)),this.show()}},{key:"_changeMarkdown",value:function(){this._switchType(g)}},{key:"_changeWysiwyg",value:function(){this._switchType(h)}},{key:"_setActiveButton",value:function(e){this._buttons.$markdown.removeClass("active"),this._buttons.$wysiwyg.removeClass("active"),this._buttons["$"+e].addClass("active")}},{key:"_switchType",value:function(e){this._type!==e&&(this._type=e,this._setActiveButton(e),this.trigger("modeSwitched",this._type))}}]),t}(c.default);Object.defineProperty(E,"TYPE",{enumerable:!0,writable:!0,value:{MARKDOWN:g,WYSIWYG:h}}),t.default=E},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n\n \n \n \n \n \n \n
\n ";return e=l.default.extend({header:!0,title:_.default.get("Insert link"),className:"te-popup-add-link tui-editor-popup",content:n},e),f(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return g(t,e),r(t,[{key:"_initInstance",value:function(e){i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this._editor=e.editor,this._eventManager=e.editor.eventManager}},{key:"_initDOM",value:function(){i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOM",this).call(this);var e=this.$el.get(0);this._inputText=e.querySelector(".te-link-text-input"),this._inputURL=e.querySelector(".te-url-input")}},{key:"_initDOMEvent",value:function(){var e=this;i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this),this.on("click .te-close-button",(function(){return e.hide()})),this.on("click .te-ok-button",(function(){return e._addLink()})),this.on("shown",(function(){var t=e._inputText,n=e._inputURL,r=e._editor.getSelectedText().trim();t.value=r,h.exec(r)&&(n.value=r),n.focus()})),this.on("hidden",(function(){e._resetInputs()}))}},{key:"_initEditorEvent",value:function(){var e=this;i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this);var n=this._eventManager;n.listen("focus",(function(){return e.hide()})),n.listen("closeAllPopup",(function(){return e.hide()})),n.listen("openPopupAddLink",(function(){n.emit("closeAllPopup"),e.show()}))}},{key:"_addLink",value:function(){var e=this._getValue(),t=e.url,n=e.linkText;this._clearValidationStyle(),n.length<1?(0,o.default)(this._inputText).addClass("wrong"):t.length<1?(0,o.default)(this._inputURL).addClass("wrong"):(this._eventManager.emit("command","AddLink",{linkText:n,url:t}),this.hide())}},{key:"_getValue",value:function(){var e=this._inputURL.value,t=this._inputText.value;return{url:e,linkText:t}}},{key:"_clearValidationStyle",value:function(){(0,o.default)(this._inputURL).removeClass("wrong"),(0,o.default)(this._inputText).removeClass("wrong")}},{key:"_resetInputs",value:function(){this._inputText.value="",this._inputURL.value="",this._clearValidationStyle()}}]),t}(u.default);t.default=E},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n \n