/*! * tui-editor * @version 1.0.2 * @author NHN Ent. FE Development Lab (https://nhnent.github.io/tui.editor/) * @license MIT */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery"),require("tui-code-snippet"),require("codemirror"),require("markdown-it"),require("to-mark"),require("highlight.js"),require("squire-rte")):"function"==typeof define&&define.amd?define(["jquery","tui-code-snippet","codemirror","markdown-it","to-mark","highlight.js","squire-rte"],t):"object"==typeof exports?exports.Editor=t(require("jquery"),require("tui-code-snippet"),require("codemirror"),require("markdown-it"),require("to-mark"),require("highlight.js"),require("squire-rte")):(e.tui=e.tui||{},e.tui.Editor=t(e.$,e.tui&&e.tui.util,e.CodeMirror,e.markdownit,e.toMark,e.hljs,e.Squire))}("undefined"!=typeof self?self:this,function(e,t,n,i,a,o,r){return function(e){function t(i){if(n[i])return n[i].exports;var a=n[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist/",t(t.s=38)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};a(this,e),this._command=new u.default.Map,this._mdCommand=new u.default.Map,this._wwCommand=new u.default.Map,this._options=l.default.extend({useCommandShortcut:!0},n),this.base=t,this.keyMapCommand={},this._initEvent()}return o(e,[{key:"_addCommandBefore",value:function(e){var t={command:e};return this.base.eventManager.emit("addCommandBefore",t),t.command||e}},{key:"addCommand",value:function(t){for(var n=arguments.length,i=Array(n>1?n-1:0),a=1;a1?o-1:0),l=1;l=0&&(n=e.childNodes[t]),n},p=function(e,t,n){for(var i=e+"Sibling",a=void 0,o=void 0;t&&!t[i]&&(a=d(t.parentNode))!==n&&"BODY"!==a;)t=t.parentNode;return t[i]&&(o=t[i]),o},m=function(e,t,n){return t>0?v(e,t-1):p("previous",e,n)},y=function(e,t){for(var n=void 0;e.parentNode&&!t(e.parentNode);)e=e.parentNode;return t(e.parentNode)&&(n=e),n},_=function(e,t){return l.default.isString(t)?y(e,function(e){return t===d(e)}):y(e,function(e){return t===e})},b=function(e,t,n){var i=e+"Sibling",a=void 0;return t=_(t,n),t&&t[i]&&(a=t[i]),a},k=function(e,t){return b("previous",e,t)},w=function(e,t){return b("next",e,t)},C=function(e){return _(e,"BODY")},E=function(e){for(e=e.previousSibling||e.parentNode;!u(e)&&"BODY"!==d(e);)if(e.previousSibling)for(e=e.previousSibling;e.lastChild;)e=e.lastChild;else e=e.parentNode;return"BODY"===d(e)&&(e=null),e},M=function(e,t,n){var i=[],a="",o=0,r=void 0;if(!t.length)return i;for(var s=t.shift(),u=document.createTreeWalker(e,4,null,!1);u.nextNode();){for(a=u.currentNode.nodeValue||"",n&&(a=n(a)),r=o+a.length;r>=s;){if(i.push({container:u.currentNode,offsetInContainer:s-o,offset:s}),!t.length)return i;s=t.shift()}o=r}do{i.push({container:u.currentNode,offsetInContainer:a.length,offset:s}),s=t.shift()}while(!l.default.isUndefined(s));return i},T=function(e){var t={};t.tagName=e.nodeName,e.id&&(t.id=e.id);var n=e.className.trim();return n&&(t.className=n),t},S=function(e,t){for(var n=[];e&&e!==t;)c(e)&&n.unshift(T(e)),e=e.parentNode;return n},O=function(e,t){var n=!0;return l.default.isUndefined(t)||"next"!==t&&"previous"!==t?null:("previous"===t&&(n=!1),n?e.nextElementSibling:e.previousElementSibling)},L=function(e,t,n){var i=!0,a=null,r=void 0,s=void 0,u=void 0,c=void 0,f=void 0,h=void 0;return l.default.isUndefined(t)||"next"!==t&&"previous"!==t?null:("previous"===t&&(i=!1),e?(r=(0,o.default)(e),i?(u=r.parent().next(),c=r.parents("thead"),f=c[0]&&c.next(),h=f&&"TBODY"===d(f[0]),s=0):(u=r.parent().prev(),c=r.parents("tbody"),f=c[0]&&c.prev(),h=f&&"THEAD"===d(f[0]),s=e.parentNode.childNodes.length-1),!l.default.isUndefined(n)&&n||(s=g(e)),u[0]?a=u.children("td,th")[s]:c[0]&&h&&(a=f.find("td,th")[s]),a):null)};t.default={getNodeName:d,isTextNode:u,isElemNode:c,getTextLength:f,getOffsetLength:h,getPrevOffsetNodeUntil:m,getNodeOffsetOfParent:g,getChildNodeByOffset:v,getTopPrevNodeUnder:k,getTopNextNodeUnder:w,getParentUntil:_,getTopBlockNode:C,getPrevTextNode:E,findOffsetNode:M,getPath:S,getNodeInfo:T,getTableCellByDirection:O,getSiblingRowCellByDirection:L}},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.I18n=void 0;var a=function(){function e(e,t){for(var n=0;n\n \n
\n \n
\n \n
',p='
\n
\n \n
\n \n
\n
\n
\n
',m=function(e){function t(e){a(this,t),e=d.default.extend({header:!0,$target:(0,u.default)("body"),textContent:""},e);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{tagName:"div",className:e.modal?g+"modal-background":g+"wrapper",rootElement:e.$el}));return n._initInstance(e),n._initDOM(e),n._initDOMEvent(e),n._initEditorEvent(e),n}return r(t,e),l(t,[{key:"_initInstance",value:function(e){this._$target=e.$target,e.$el&&(this.$el=e.$el,this._isExternalHtmlUse=!0),e.content?this.$content=(0,u.default)(e.content):this.$content=e.textContent,this.options=e}},{key:"_initDOM",value:function(){this._initLayout(),this._isExternalHtmlUse||(d.default.isExisty(this.options.title)&&this.setTitle(this.options.title),this.setContent(this.$content));var e=this.options.headerButtons;if(e){this.$el.find("."+g+"close-button").remove();var t=this.$el.find("."+g+"header-buttons");t.empty(),t.append((0,u.default)(e))}this.options.css&&this.$el.css(this.options.css)}},{key:"_initDOMEvent",value:function(){var e=this,t=this.options,n=t.openerCssQuery,i=t.closerCssQuery;n&&(0,u.default)(n).on("click."+this._id,function(){return e.show()}),i&&(0,u.default)(i).on("click."+this._id,function(){return e.hide()}),this.on("click ."+g+"close-button",function(){return e.hide()})}},{key:"_initEditorEvent",value:function(){}},{key:"_initLayout",value:function(){var e=this.options;if(this._isExternalHtmlUse)this.hide(),this._$target.append(this.$el);else{var t=e.modal?p:v;this.$el.html(t),this.$el.addClass(e.className),this.hide(),this._$target.append(this.$el),this.$body=this.$el.find("."+g+"body"),e.header||this.$el.find("."+g+"header").remove()}}},{key:"setContent",value:function(e){this.$body.empty(),this.$body.append(e)}},{key:"setTitle",value:function(e){var t=this.$el.find("."+g+"title");t.empty(),t.append(e)}},{key:"getTitleElement",value:function(){return this.$el.find("."+g+"title").get(0)}},{key:"hide",value:function(){this.$el.css("display","none"),this._isShow=!1,this.trigger("hidden",this)}},{key:"show",value:function(){this.$el.css("display","block"),this._isShow=!0,this.trigger("shown",this)}},{key:"isShow",value:function(){return this._isShow}},{key:"remove",value:function(){var e=this.options,t=e.openerCssQuery,n=e.closerCssQuery;this.trigger("remove",this),this.off(),t&&(0,u.default)(t).off("."+this._id),n&&(0,u.default)(n).off("."+this._id),this.$el.remove()}},{key:"setFitToWindow",value:function(e){this.$el.toggleClass("fit-window",e)}},{key:"isFitToWindow",value:function(){return this.$el.hasClass("fit-window")}},{key:"toggleFitToWindow",value:function(){var e=!this.isFitToWindow();return this.setFitToWindow(e),e}}]),t}(h.default);t.default=m},function(e,t){e.exports=n},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockManager=void 0;var o=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),t=c.default.extend({tagName:"div"},t),this.tagName=t.tagName,this.className=t.className,this._id=o(),this.$el=null,this._setRootElement(t.rootElement)}return r(e,[{key:"on",value:function(e,t){var n=this;c.default.isObject(e)?c.default.forEach(e,function(e,t){n._addEvent(t,e)}):this._addEvent(e,t)}},{key:"_addEvent",value:function(e,t){var n=this._parseEventType(e),i=n.event,a=n.selector;a?this.$el.on(i,a,t):this.$el.on(i,t)}},{key:"off",value:function(e,t){if(e){var n=this._parseEventType(e),i=n.event,a=n.selector;a?this.$el.off(i,a,t):this.$el.off(i,t)}else this.$el.off()}},{key:"_parseEventType",value:function(e){var t=e.split(" ");return{event:t.shift(),selector:t.join(" ")}}},{key:"_setRootElement",value:function(e){var t=this.tagName,n=this.className;e||(n=n||"uic"+this._id,e=(0,s.default)("<"+t+' class="'+n+'"/>')),this.$el=e}},{key:"trigger",value:function(){var e;(e=this.$el).trigger.apply(e,arguments)}},{key:"_getEventNameWithNamespace",value:function(e){var t=e.split(" ");return t[0]+=".uicEvent"+this._id,t.join(" ")}},{key:"remove",value:function(){this.$el.remove()}},{key:"destroy",value:function(){var e=this;this.remove(),c.default.forEachOwnProperties(this,function(t,n){e[n]=null})}}]),e}();t.default=f},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 o(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)}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n\n/g,"
"))}),this.eventManager.listen("previewNeedsRefresh",function(n){e.refresh(n||t)}),this.$el.on("scroll",function(t){e.eventManager.emit("scroll",{source:"preview",data:t})})}},{key:"render",value:function(e){l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"render",this).call(this,e),this.eventManager.emit("previewRenderAfter",this)}}]),t}(u.default);t.default=c},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n'),this.$el.append(this._$previewContent)}},{key:"refresh",value:function(e){this.render(this.convertor.toHTMLWithCodeHightlight(e))}},{key:"getHTML",value:function(){return this._$previewContent.html()}},{key:"setHTML",value:function(e){this._$previewContent.html(e)}},{key:"render",value:function(e){var t=this._$previewContent;e=this.eventManager.emit("previewBeforeHook",e)||e,t.empty(),t.html(e)}},{key:"setHeight",value:function(e){this.$el.get(0).style.height=e+"px"}},{key:"setMinHeight",value:function(e){this.$el.get(0).style.minHeight=e+"px"}},{key:"isVisible",value:function(){return"none"!==this.$el.css("display")}}]),e}();t.default=c},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=(0,u.default)("
");return e=e.replace(//g,""),n.append(e),o(n),r(n),l(n,t)}function o(e){e.find("script, iframe, textarea, form, button, select, meta, style, link, title").remove()}function r(e){e.find("*").each(function(e,t){var n=t.attributes,i=d.default.toArray(n).filter(function(e){var t=e.name.match(f),n=e.name.match(h);return!t&&!n});d.default.forEachArray(i,function(e){n.getNamedItem(e.name)&&n.removeNamedItem(e.name)})})}function l(e,t){var n=void 0;if(t)n=e[0].innerHTML;else{for(var i=document.createDocumentFragment(),a=d.default.toArray(e[0].childNodes),o=a.length,r=0;r=0&&n.splice(i,1)}},{key:"_removeEventHandlerWithTypeInfo",value:function(e,t){var n=[],i=this.events.get(e);i&&(i.map(function(e){e.namespace!==t&&n.push(e)}),this.events.set(e,n))}}]),e}();t.default=s},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n/gi,"
");for(var t=/(]*)(onerror\s*=\s*[\"']?[^\"']*[\"']?)(.*)/i;t.exec(e);)e=e.replace(t,"$1$3");var n=A.render(e);return n=this._removeBrToMarkPassAttributeInCode(n)}},{key:"_markdownToHtml",value:function(e){e=e.replace(/
/gi,"
");for(var t=/(]*)(onerror\s*=\s*[\"']?[^\"']*[\"']?)(.*)/i;t.exec(e);)e=e.replace(t,"$1$3");var n=x.render(e);return n=this._removeBrToMarkPassAttributeInCode(n)}},{key:"_removeBrToMarkPassAttributeInCode",value:function(e){var t=(0,l.default)("
");return t.html(e),t.find("code, pre").each(function(e,t){var n=(0,l.default)(t);n.html(n.html().replace(/<br data-tomark-pass>/,"<br>"))}),e=t.html()}},{key:"toHTMLWithCodeHightlight",value:function(e){var t=this._markdownToHtmlWithCodeHighlight(e);return t=this.eventManager.emitReduce("convertorAfterMarkdownToHtmlConverted",t)}},{key:"toHTML",value:function(e){var t=this._markdownToHtml(e);return t=this.eventManager.emitReduce("convertorAfterMarkdownToHtmlConverted",t)}},{key:"initHtmlSanitizer",value:function(){this.eventManager.listen("convertorAfterMarkdownToHtmlConverted",function(e){return(0,v.default)(e,!0)})}},{key:"toMarkdown",value:function(e,t){var n=[];e=this.eventManager.emitReduce("convertorBeforeHtmlToMarkdownConverted",e);var i=(0,h.default)(this._appendAttributeForBrIfNeed(e),t);return i=this.eventManager.emitReduce("convertorAfterHtmlToMarkdownConverted",i),u.default.forEach(i.split("\n"),function(e,t){var i=/^\|[^|]*\|/gi;/`[^`]*
[^`]*`/gi.test(e)||i.test(e)||(e=e.replace(/
/gi,"
\n")),n[t]=e}),n.join("\n")}},{key:"_appendAttributeForBrIfNeed",value:function(e){var t=/
/gi,n=/

/gi,i=/

(.)/gi,a=/([^>]|<\/b>|<\/i>|<\/s>|]*>)/,o=/

/,r=new RegExp(a.source+o.source,"g");e=e.replace(t,"
"),e=e.replace(n,"

");var s=document.createElement("div"),u=(0,l.default)(s);return u.html(e),u.find("pre br,code br").each(function(e,t){t.hasAttribute("data-tomark-pass")&&t.removeAttribute("data-tomark-pass")}),e=u.html().replace(/
/gi,"
"),e=e.replace(t,"
"),e=e.replace(i,"

$1"),e=e.replace(r,"$1

")}}],[{key:"getMarkdownitHighlightRenderer",value:function(){return A}}]),e}();t.default=P},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n","?","AT","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","","","CONTEXT_MENU","","SLEEP","NUMPAD0","NUMPAD1","NUMPAD2","NUMPAD3","NUMPAD4","NUMPAD5","NUMPAD6","NUMPAD7","NUMPAD8","NUMPAD9","MULTIPLY","ADD","SEPARATOR","SUBTRACT","DECIMAL","DIVIDE","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24","","","","","","","","","NUM_LOCK","SCROLL_LOCK","WIN_OEM_FJ_JISHO","WIN_OEM_FJ_MASSHOU","WIN_OEM_FJ_TOUROKU","WIN_OEM_FJ_LOYA","WIN_OEM_FJ_ROYA","","","","","","","","","","@","!",'"',"#","$","%","&","_","(",")","*","+","|","-","{","}","~","","","","","VOLUME_MUTE","VOLUME_DOWN","VOLUME_UP","","",";","=",",","-",".","/","`","","","","","","","","","","","","","","","","","","","","","","","","","","","[","\\","]","'","","META","ALTGR","","WIN_ICO_HELP","WIN_ICO_00","","WIN_ICO_CLEAR","","","WIN_OEM_RESET","WIN_OEM_JUMP","WIN_OEM_PA1","WIN_OEM_PA2","WIN_OEM_PA3","WIN_OEM_WSCTRL","WIN_OEM_CUSEL","WIN_OEM_ATTN","WIN_OEM_FINISH","WIN_OEM_COPY","WIN_OEM_AUTO","WIN_OEM_ENLW","WIN_OEM_BACKTAB","ATTN","CRSEL","EXSEL","EREOF","PLAY","ZOOM","","PA1","WIN_OEM_CLEAR",""],r=void 0,l=function(){function e(t){i(this,e),this._setSplitter(t)}return a(e,[{key:"_setSplitter",value:function(e){var t=e?e.splitter:"+";this._splitter=t}},{key:"convert",value:function(e){var t=[];e.shiftKey&&t.push("SHIFT"),e.ctrlKey&&t.push("CTRL"),e.metaKey&&t.push("META"),e.altKey&&t.push("ALT");var n=this._getKeyCodeChar(e.keyCode);return n&&t.push(n),t.join(this._splitter)}},{key:"_getKeyCodeChar",value:function(e){return o[e]}}],[{key:"getSharedInstance",value:function(){return r||(r=new e),r}},{key:"keyCode",value:function(e){return o.indexOf(e)}}]),e}();t.default=l},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n/g,"%3E")}},{key:"escapeMarkdownCharacters",value:function(e){return e.replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(//g,"\\>")}}]),e}();t.default=u},function(e,t){e.exports=i},function(e,t){e.exports=a},function(e,t,n){"use strict";function i(e){e.content=e.content.slice(4),e.children[0].content=e.children[0].content.slice(4)}function a(e){var t=!1;return 0!==e.content.indexOf("[x]")&&0!==e.content.indexOf("[X]")||(t=!0),t}function o(e,t,n){var i=e.attrIndex(t),a=[t,n];i<0?e.attrPush(a):e.attrs[i]=a}function r(e,t){return"inline"===e[t].type&&"paragraph_open"===e[t-1].type&&"list_item_open"===e[t-2].type&&(0===e[t].content.indexOf("[ ]")||0===e[t].content.indexOf("[x]")||0===e[t].content.indexOf("[X]"))}var l=function(e){e.core.ruler.after("inline","tui-task-list",function(e){var t,n,l=e.tokens;for(n=2;n/g,">").replace(/"/g,""").replace(/'/g,"'")}var r=function(e){e.core.ruler.after("block","tui-code-block",function(e){var t,n,r=e.tokens;for(n=0;n=2&&"list"===e.parentType)break;i++}else{if(u=0,!(e.sCount[i]-e.blkIndent>=4))break;i++,a=i}return e.line=a,o=e.push("code_block","code",0),o.content=e.getLines(t,a,4+e.blkIndent,!0),o.map=[t,e.line],!0}},function(e,t,n){"use strict";function i(e){switch(e){case 9:case 32:return!0}return!1}e.exports=function(e,t,n,a){var o,r,l,s,u,c,d,f,h,g,v,p,m,y,_,b,k,w,C,E,M=e.lineMax,T=e.bMarks[t]+e.tShift[t],S=e.eMarks[t],O=/(?:-|\*|\d+\.) {1,4}(?:> {0,3})[^>]*$/,L=e.src.split("\n"),B=L[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(62!==e.src.charCodeAt(T++))return!1;if(B.match(O))return!1;if(a)return!0;for(s=h=e.sCount[t]+T-(e.bMarks[t]+e.tShift[t]),32===e.src.charCodeAt(T)?(T++,s++,h++,o=!1,b=!0):9===e.src.charCodeAt(T)?(b=!0,(e.bsCount[t]+h)%4==3?(T++,s++,h++,o=!1):o=!0):b=!1,g=[e.bMarks[t]],e.bMarks[t]=T;T=S,y=[e.sCount[t]],e.sCount[t]=h-s,_=[e.tShift[t]],e.tShift[t]=T-e.bMarks[t],w=e.md.block.ruler.getRules("blockquote"),m=e.parentType,e.parentType="blockquote",E=!1,f=t+1;f=S));f++)if(62!==e.src.charCodeAt(T++)||E){if(c)break;for(k=!1,l=0,u=w.length;l=S,v.push(e.bsCount[f]),e.bsCount[f]=e.sCount[f]+1+(b?1:0),y.push(e.sCount[f]),e.sCount[f]=h-s,_.push(e.tShift[f]),e.tShift[f]=T-e.bMarks[f]}for(p=e.blkIndent,e.blkIndent=0,C=e.push("blockquote_open","blockquote",1),C.markup=">",C.map=d=[t,0],e.md.block.tokenize(e,t,f),C=e.push("blockquote_close","blockquote",-1),C.markup=">",e.lineMax=M,e.parentType=m,d[1]=e.line,l=0;l<_.length;l++)e.bMarks[l+t]=g[l],e.tShift[l+t]=_[l],e.sCount[l+t]=y[l],e.bsCount[l+t]=v[l];return e.blkIndent=p,!0}},function(e,t,n){"use strict";function i(e,t){var n=e.bMarks[t]+e.blkIndent,i=e.eMarks[t];return e.src.substr(n,i-n)}function a(e){var t,n=[],i=0,a=e.length,o=0,r=0,l=!1,s=0;for(t=e.charCodeAt(i);in)return!1;if(c=t+1,e.sCount[c]=e.eMarks[c])return!1;if(124!==(r=e.src.charCodeAt(s))&&45!==r&&58!==r)return!1;if(l=i(e,t+1),!/^[-:| ]+$/.test(l))return!1;for(d=l.split("|"),g=[],u=0;uv)return!1;if(f|$))/i,/<\/(script|pre|style)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^<("+i.join("|")+")","i"),/^\/?>$/,!0],[new RegExp("^|$))","i"),/^$/,!0],[/^(?:<[A-Za-z][A-Za-z0-9\-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\s*=\s*(?:[^"'=<>`\x00-\x20]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][A-Za-z0-9\-]*\s*>)\s*$/,/^$/,!1]];e.exports=function(e,t,n,i){var o,r,l,s,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(!e.md.options.html)return!1;if(60!==e.src.charCodeAt(u))return!1;for(s=e.src.slice(u,c),o=0;o18;e.target.hasAttribute("data-te-task")&&!t&&((0,l.default)(e.target).toggleClass("checked"),this.eventManager.emit("change",{source:"viewer",data:e}))}},{key:"setMarkdown",value:function(e){this.markdownValue=e=e||"",this.preview.refresh(this.markdownValue),this.eventManager.emit("setMarkdownAfter",this.markdownValue)}},{key:"setValue",value:function(e){this.setMarkdown(e)}},{key:"on",value:function(e,t){this.eventManager.listen(e,t)}},{key:"off",value:function(e){this.eventManager.removeEventHandler(e)}},{key:"remove",value:function(){this.eventManager.emit("removeEditor"),this.preview.$el.off("mousedown",l.default.proxy(this._toggleTask,this)),this.options=null,this.eventManager=null,this.commandManager=null,this.convertor=null,this.preview=null}},{key:"addHook",value:function(e,t){this.eventManager.removeEventHandler(e),this.eventManager.listen(e,t)}},{key:"isViewer",value:function(){return!0}},{key:"isMarkdownMode",value:function(){return!1}},{key:"isWysiwygMode",value:function(){return!1}}],[{key:"defineExtension",value:function(e,t){m.default.defineExtension(e,t)}}]),e}();E.isViewer=!0,E.domUtils=k.default,E.codeBlockManager=C.default,E.markdownitHighlight=_.default.getMarkdownitHighlightRenderer(),E.i18n=null,E.Button=null,E.WwCodeBlockManager=null,E.WwTableManager=null,E.WwTableSelectionManager=null,e.exports=E},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};a(this,e),this.editorContainerEl=t,this.cm=null,this._init(n)}return o(e,[{key:"_init",value:function(e){var t=document.createElement("textarea");this.editorContainerEl.appendChild(t),e=l.default.extend(!0,{lineWrapping:!0,theme:"default",extraKeys:{"Shift-Tab":"indentLess","Alt-Up":"replaceLineTextToUpper","Alt-Down":"replaceLineTextToLower"},indentUnit:4},e),this.cm=u.default.fromTextArea(t,e)}},{key:"getCurrentRange",value:function(){var e=this.cm.getCursor("from"),t=this.cm.getCursor("to");return{from:e,to:t,collapsed:e.line===t.line&&e.ch===t.ch}}},{key:"focus",value:function(){this.cm.focus()}},{key:"blur",value:function(){this.cm.getInputField().blur()}},{key:"remove",value:function(){this.cm.toTextArea()}},{key:"setValue",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.cm.setValue(e),t&&this.moveCursorToEnd(),this.cm.refresh()}},{key:"getValue",value:function(){return this.cm.getValue("\n")}},{key:"getEditor",value:function(){return this.cm}},{key:"reset",value:function(){this.setValue("")}},{key:"getCaretPosition",value:function(){return this.cm.cursorCoords()}},{key:"addWidget",value:function(e,t,n,i){i&&(e.ch+=i),this.cm.addWidget(e.end,t,!0,n)}},{key:"replaceSelection",value:function(e,t){t&&this.cm.setSelection(t.from,t.to),this.cm.replaceSelection(e),this.focus()}},{key:"replaceRelativeOffset",value:function(e,t,n){var i=this.cm.getCursor(),a={from:{line:i.line,ch:i.ch+t},to:{line:i.line,ch:i.ch+t+n}};this.replaceSelection(e,a)}},{key:"setHeight",value:function(e){this.getWrapperElement().style.height=e+"px"}},{key:"setMinHeight",value:function(e){this.getWrapperElement().style.minHeight=e+"px"}},{key:"getWrapperElement",value:function(){return this.cm.getWrapperElement()}},{key:"getCursor",value:function(e){return this.cm.getCursor(e)}},{key:"moveCursorToEnd",value:function(){var e=this.getEditor().getDoc(),t=e.lastLine();e.setCursor(t,e.getLine(t).length)}},{key:"moveCursorToStart",value:function(){var e=this.getEditor().getDoc(),t=e.firstLine();e.setCursor(t,0)}},{key:"scrollTop",value:function(e){return e&&this.cm.scrollTo(0,e),this.cm.getScrollInfo().top}},{key:"getRange",value:function(){var e=this.cm.getCursor("from"),t=this.cm.getCursor("to");return{start:{line:e.line,ch:e.ch},end:{line:t.line,ch:t.ch}}}},{key:"on",value:function(e,t){this.cm.on(e,t)}},{key:"off",value:function(e,t){this.cm.off(e,t)}}]),e}();t.default=c},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n
",i="",a=0;a",p=function(){function e(t){a(this,e),this.wwe=t,this.eventManager=t.eventManager,this.name="table",this._lastCellNode=null,this._init()}return r(e,[{key:"_init",value:function(){this._initKeyHandler(),this._initEvent(),this.tableID=0}},{key:"_initEvent",value:function(){var e=this;this.eventManager.listen("wysiwygRangeChangeAfter.table",function(){var t=e.wwe.getEditor().getSelection(),n=e.isInTable(t);if(e._unwrapBlockInTable(),e._completeTableIfNeed(),!n){e.wwe.componentManager.getManager("tableSelection").removeClassAttrbuteFromAllCellsIfNeed()}e._insertDefaultBlockBetweenTable()}),this.eventManager.listen("wysiwygSetValueAfter.table",function(){e._unwrapBlockInTable(),e._insertDefaultBlockBetweenTable()}),this.eventManager.listen("wysiwygProcessHTMLText.table",function(e){return e.replace(/
(<\/td>|<\/th>)/g,"$1")}),this.eventManager.listen("cut.table",function(){var t=e.wwe.componentManager.getManager("tableSelection"),n=t.getSelectedCells();n.length&&n.get().forEach(function(e){return(0,s.default)(e).html(v)}),t.removeClassAttrbuteFromAllCellsIfNeed()}),this.eventManager.listen("copyBefore.table",function(t){var n=t.$clipboardContainer;return e.updateTableHtmlOfClipboardIfNeed(n)}),this.onBindedPaste=this._onPaste.bind(this),this.wwe.getEditor().addEventListener("paste",this.onBindedPaste)}},{key:"updateTableHtmlOfClipboardIfNeed",value:function(e){var t=this,n=this.wwe.componentManager.getManager("tableSelection");if(n.getSelectedCells().length){n.createRangeBySelectedCells();var i=this.wwe.getEditor().getSelection().cloneContents();(0,s.default)(i).children().each(function(e,n){var i=(0,s.default)(n);t.isTableOrSubTableElement(n.nodeName)&&("TABLE"===n.nodeName&&0===i.find("thead").length&&0===i.find("tbody").length?i.remove():n.previousSibling&&"TABLE"===n.previousSibling.nodeName?n.previousSibling.appendChild(n):(t._completeIncompleteTable(n),"TABLE"!==n.nodeName&&"THEAD"!==n.nodeName&&(0,s.default)(n).closest("table").find("thead").remove()))}),e.append(i),e.find(".te-cell-selected").removeClass("te-cell-selected")}}},{key:"pasteClipboardData",value:function(e){this.wwe.componentManager.getManager("tableSelection").getSelectedCells().length||(this._expandTableIfNeed(e),this._pasteDataIntoTable(e))}},{key:"_onPaste",value:function(e){var t=this.wwe.getEditor().getSelection(),n=!f.default.isTextNode(t.commonAncestorContainer);this.isInTable(t)&&!t.collapsed&&n&&e.preventDefault()}},{key:"_initKeyHandler",value:function(){var e=this;this.keyEventHandlers={DEFAULT:function(t,n,i){var a=e.isInTable(n);a&&!e._isSingleModifierKey(i)?(e._recordUndoStateIfNeed(n),e._removeBRIfNeed(n),e._removeContentsAndChangeSelectionIfNeed(n,i,t)):!a&&e._lastCellNode&&e._recordUndoStateAndResetCellNode(n),a&&!e._isModifierKeyPushed(t)&&e.wwe.getEditor().modifyDocument(function(){e.wwe.componentManager.getManager("tableSelection").removeClassAttrbuteFromAllCellsIfNeed()})},ENTER:function(t,n){var i=void 0;return e._isAfterTable(n)?(t.preventDefault(),n.setStart(n.startContainer,n.startOffset-1),e.wwe.breakToNewDefaultBlock(n),i=!1):e._isBeforeTable(n)?(t.preventDefault(),e.wwe.breakToNewDefaultBlock(n,"before"),i=!1):e.isInTable(n)&&(e._appendBrIfTdOrThNotHaveAsLastChild(n),i=!1),i},BACK_SPACE:function(t,n,i){return e._handleBackspaceAndDeleteKeyEvent(t,n,i)},DELETE:function(t,n,i){return e._handleBackspaceAndDeleteKeyEvent(t,n,i)},TAB:function(){return e._moveCursorTo("next","cell")},"SHIFT+TAB":function(t){return e._moveCursorTo("previous","cell",t)},UP:function(t){return e._moveCursorTo("previous","row",t)},DOWN:function(t){return e._moveCursorTo("next","row",t)}},c.default.forEach(this.keyEventHandlers,function(t,n){return e.wwe.addKeyEventHandler(n,t)})}},{key:"isInTable",value:function(e){var t=void 0,n=void 0;return e.collapsed?(t=e.startContainer,n=!!(0,s.default)(t).closest("[contenteditable=true] table").length):(t=e.commonAncestorContainer,n=!!(0,s.default)(t).closest("[contenteditable=true] table").length||!!(0,s.default)(e.cloneContents()).find("table").length),n}},{key:"_isBeforeTable",value:function(e){return"TABLE"===f.default.getNodeName(f.default.getChildNodeByOffset(e.startContainer,e.startOffset))}},{key:"_isAfterTable",value:function(e){var t=f.default.getPrevOffsetNodeUntil(e.startContainer,e.startOffset);return"TABLE"===f.default.getNodeName(t)&&e.commonAncestorContainer===this.wwe.get$Body()[0]}},{key:"_handleBackspaceAndDeleteKeyEvent",value:function(e,t,n){var i="BACK_SPACE"===n,a=this.wwe.componentManager.getManager("tableSelection"),o=a.getSelectedCells(),r=!0;if(t.collapsed){if(this.isInTable(t))i?this._tableHandlerOnBackspace(t,e):this._tableHandlerOnDelete(t,e),this._insertBRIfNeed(t),this._removeContentsAndChangeSelectionIfNeed(t,n,e),r=!1;else if(!i&&this._isBeforeTable(t)||i&&this._isAfterTable(t)){e.preventDefault();var l=i?t.startOffset-1:t.startOffset;this._removeTable(t,f.default.getChildNodeByOffset(t.startContainer,l)),r=!1}}else if(this.isInTable(t)&&o.length>0){var s=this._removeContentsAndChangeSelectionIfNeed(t,n,e);s&&(e.preventDefault(),r=!1)}return r}},{key:"_tableHandlerOnBackspace",value:function(e,t){var n=f.default.getPrevOffsetNodeUntil(e.startContainer,e.startOffset,"TR"),i=f.default.getNodeName(n);n&&"TD"!==i&&"TH"!==i?"BR"===i&&1!==n.parentNode.childNodes.length&&(t.preventDefault(),(0,s.default)(n).remove()):t.preventDefault()}},{key:"isNonTextDeleting",value:function(e){var t=e.startContainer,n=t.nextSibling,i=f.default.getNodeName(n),a=f.default.getNodeName(t),o=a===i&&"TEXT"!==a,r=(!n||"BR"===i&&n.parentNode.lastChild===n)&&f.default.isTextNode(t)&&e.startOffset===t.nodeValue.length,l=!r&&(0,s.default)(t).parents("tr").children().last()[0]===t&&("TD"===a||"TH"===a);return o||r||l}},{key:"_tableHandlerOnDelete",value:function(e,t){this.isNonTextDeleting(e)&&(t.preventDefault(),e.startContainer.normalize())}},{key:"_appendBrIfTdOrThNotHaveAsLastChild",value:function(e){var t=f.default.getNodeName(e.startContainer),n=void 0;if("TD"===t||"TH"===t)n=e.startContainer;else{var i=(0,s.default)(e.startContainer).parentsUntil("tr");n=i[i.length-1]}"BR"===f.default.getNodeName(n.lastChild)||"DIV"===f.default.getNodeName(n.lastChild)||g||(0,s.default)(n).append((0,s.default)("
")[0])}},{key:"_unwrapBlockInTable",value:function(){this.wwe.get$Body().find("td div,th div,tr>br,td>br,th>br").each(function(e,t){if("BR"===f.default.getNodeName(t)){var n=f.default.getNodeName(t.parentNode),i=/TD|TH/.test(n),a=0===t.parentNode.textContent.length,o=t.parentNode.lastChild===t;("TR"===n||i&&!a&&o)&&(0,s.default)(t).remove()}else(0,s.default)(t).children().unwrap()})}},{key:"_insertDefaultBlockBetweenTable",value:function(){this.wwe.get$Body().find("table").each(function(e,t){t.nextElementSibling&&"TABLE"===t.nextElementSibling.nodeName&&(0,s.default)("

").insertAfter(t)})}},{key:"_removeTable",value:function(e,t){"TABLE"===t.tagName&&(this.wwe.getEditor().saveUndoState(e),this.wwe.saveSelection(e),(0,s.default)(t).remove(),this.wwe.restoreSavedSelection())}},{key:"_recordUndoStateIfNeed",value:function(e){var t=f.default.getParentUntil(e.startContainer,"TR");e.collapsed&&t&&this._lastCellNode!==t&&(this.wwe.getEditor().saveUndoState(e),this._lastCellNode=t)}},{key:"_recordUndoStateAndResetCellNode",value:function(e){this.wwe.getEditor().saveUndoState(e),this.resetLastCellNode()}},{key:"_pasteDataIntoTable",value:function(e){var t=this.wwe.getEditor().getSelection(),n=t.startContainer,i=n.parentNode,a=this._getTableDataFromTable(e),o="TD"===i.tagName||"TH"===i.tagName,r="TD"===n.tagName||"TH"===n.tagName,l=3===n.nodeType,u=h?"":"
",c=void 0,d=void 0,g=void 0,v=void 0;for(c=l&&o?i:r?n:(0,s.default)(n).find("th,td").get(0),d=c;a.length;){for(g=a.shift();d&&g.length;)v=g.shift(),v.length?d.textContent=v:d.innerHTML=u,d=f.default.getTableCellByDirection(d,"next");d=f.default.getSiblingRowCellByDirection(c,"next",!1),c=d}}},{key:"_getTableDataFromTable",value:function(e){var t=(0,s.default)(e),n=[];return t.find("tr").each(function(e,t){var i=[];(0,s.default)(t).children().each(function(e,t){i.push(t.textContent)}),i.length&&n.push(i)}),n}},{key:"_removeTableContents",value:function(e){this.wwe.getEditor().saveUndoState(),e.each(function(e,t){var n=h?"":"
";(0,s.default)(t).html(n)})}},{key:"wrapDanglingTableCellsIntoTrIfNeed",value:function(e){var t=e.children("td,th"),n=void 0;if(t.length){var i=(0,s.default)("");t.each(function(e,t){i.append(t)}),n=i.get(0)}return n}},{key:"wrapTrsIntoTbodyIfNeed",value:function(e){var t=e.children("tr"),n=t.find("th"),i=void 0;if(n.length&&n.each(function(e,t){var n=(0,s.default)(t),i=(0,s.default)("");i.html(n.html()),i.insertBefore(t),n.detach()}),t.length){var a=(0,s.default)("");t.each(function(e,t){a.append(t)}),i=a.get(0)}return i}},{key:"wrapTheadAndTbodyIntoTableIfNeed",value:function(e){var t=e.children("thead"),n=e.children("tbody"),i=(0,s.default)("
"),a=void 0;return!n.length&&t.length?(i.append(t[0]),i.append(""),a=i.get(0)):n.length&&!t.length?(i.append(""),i.append(n[0]),a=i.get(0)):n.length&&t.length&&(i.append(t[0]),i.append(n[0]),a=i.get(0)),a}},{key:"isTableOrSubTableElement",value:function(e){return"TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e||"TD"===e}},{key:"_stuffTableCellsIntoIncompleteRow",value:function(e,t){e.each(function(e,n){for(var i=(0,s.default)(n),a=i.find("th,td"),r=f.default.getNodeName(i.parent()[0]),l="THEAD"===r?"th":"td",u=a.length;u").get(0),e.prepend(i)):n&&(i=(0,s.default)("").get(0),e.append(i))}},{key:"tableCellAppendAidForTableElement",value:function(e){var t=(0,s.default)(e);this._addTbodyOrTheadIfNeed(t),this._addTrIntoContainerIfNeed(t);var n=t.find("tr"),i=this.prepareToTableCellStuffing(n),a=i.maximumCellLength;i.needTableCellStuffingAid&&this._stuffTableCellsIntoIncompleteRow(n,a)}},{key:"_generateTheadAndTbodyFromTbody",value:function(e){var t=(0,s.default)(""),n=(0,s.default)("");return t.append(o((0,s.default)(e).find("tr").eq(0).find("td").length,"th")),n.append(t),{thead:n[0],tbody:e}}},{key:"_generateTheadAndTbodyFromThead",value:function(e){var t=(0,s.default)(""),n=(0,s.default)("");return t.append(o((0,s.default)(e).find("th").length,"td")),n.append(t),{thead:e,tbody:n[0]}}},{key:"_generateTheadAndTbodyFromTr",value:function(e){var t=(0,s.default)(e),n=(0,s.default)(""),i=(0,s.default)(""),a=void 0,r=void 0;return"TH"===t.children()[0].tagName?(a=e,r=(0,s.default)(""+o(t.find("th").length,"td")+"").get(0)):(a=(0,s.default)(""+o(t.find("td").length,"th")+"").get(0),r=e),n.append(a),i.append(r),{thead:n[0],tbody:i[0]}}},{key:"_completeIncompleteTable",value:function(e,t){var n=e.tagName,i=void 0,a=void 0;t=!!c.default.isUndefined(t)||t,"TABLE"===n?i=e:(i=(0,s.default)("
"),i.insertAfter(e),"TBODY"===n?a=this._generateTheadAndTbodyFromTbody(e):"THEAD"===n?a=this._generateTheadAndTbodyFromThead(e):"TR"===n&&(a=this._generateTheadAndTbodyFromTr(e)),t&&i.append(a.thead),i.append(a.tbody)),this.tableCellAppendAidForTableElement(i)}},{key:"_completeTableIfNeed",value:function(){var e=this;this.wwe.getEditor().get$Body().children().each(function(t,n){var i=(0,s.default)(n);e.isTableOrSubTableElement(n.nodeName)&&("TABLE"===n.nodeName&&0===i.find("thead").length&&0===i.find("tbody").length&&i.remove(),e._completeIncompleteTable(n))})}},{key:"resetLastCellNode",value:function(){this._lastCellNode=null}},{key:"setLastCellNode",value:function(e){this._lastCellNode=e}},{key:"_isSingleModifierKey",value:function(e){return"META"===e||"SHIFT"===e||"ALT"===e||"CONTROL"===e}},{key:"_isModifierKeyPushed",value:function(e){return e.metaKey||e.ctrlKey||e.altKey||e.shiftKey}},{key:"_addTrIntoContainerIfNeed",value:function(e){e.children().each(function(e,t){0===(0,s.default)(t).find("tr").length&&(0,s.default)(t).append((0,s.default)("")[0])})}},{key:"_expandTableIfNeed",value:function(e){var t=this.wwe.getEditor().getSelection().cloneRange(),n=(0,s.default)(t.startContainer).parents("table"),i=this._getColumnAndRowDifference(e,t);i.column<0&&this._appendCellForAllRow(n,i.column),i.row<0&&this._appendRow(n,i.row)}},{key:"_getColumnAndRowDifference",value:function(e,t){var n=this._getTableDataFromTable(e),i=n.length,a=n[0].length,o=(0,s.default)(t.startContainer).closest("th,td"),r=o.parent(),l=f.default.getNodeOffsetOfParent(o[0]),u=f.default.getNodeOffsetOfParent(o[0].parentNode),c=r.parents("table"),d=c.find("tr").eq(0).children().length,h=c.find("tr").length;return r.parents("tbody").length&&(u+=1),{row:h-(u+i),column:d-(l+a)}}},{key:"_appendCellForAllRow",value:function(e,t){var n=h?"":"
";e.find("tr").each(function(e,i){for(var a=void 0,o=t;o<0;o+=1)a=0===e?"th":"td",(0,s.default)(i).append((0,s.default)("<"+a+">"+n+"")[0])})}},{key:"_appendRow",value:function(e,t){var n=e.find("tr").last().clone(),i=h?"":"
";for(n.find("td").html(i);t<0;t+=1)e.find("tbody").append(n.clone()[0])}},{key:"_getSiblingTextNodeByDirection",value:function(e,t){var n=e.previousSibling&&"BR"===e.previousSibling.nodeName&&e.previousSibling.previousSibling&&3===e.previousSibling.previousSibling.nodeType,i=e.nextSibling&&"BR"===e.nextSibling.nodeName&&e.nextSibling.nextSibling&&3===e.nextSibling.nextSibling.nodeType,a=void 0;return t&&i?a=e.nextSibling.nextSibling:!t&&n&&(a=e.previousSibling.previousSibling),a}},{key:"_changeSelectionToTargetCell",value:function(e,t,n,i){var a=t.startContainer,o="next"===n,r="row"===i,l=void 0,u=void 0;if(r){if(f.default.isTextNode(a)&&(l=this._getSiblingTextNodeByDirection(a,o)))return u=l.length"))}},{key:"destroy",value:function(){var e=this;this.eventManager.removeEventHandler("wysiwygRangeChangeAfter.table"),this.eventManager.removeEventHandler("wysiwygSetValueAfter.table"),this.eventManager.removeEventHandler("wysiwygProcessHTMLText.table"),this.eventManager.removeEventHandler("cut.table"),this.eventManager.removeEventHandler("copyBefore.table"),this.wwe.getEditor().removeEventListener("paste",this.onBindedPaste),c.default.forEach(this.keyEventHandlers,function(t,n){return e.wwe.removeKeyEventHandler(n,t)})}}]),e}();t.default=p},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n0;return s?c?(t.setStart(a,0),t.setEnd(i,1)):(t.setStart(i,0),t.setEnd(a,1)):u?(t.setStart(i,0),t.setEnd(a,1)):(t.setStart(a,0),t.setEnd(i,1)),t}},{key:"getSelectionRangeFromTable",value:function(e,t){var n=d.default.getNodeOffsetOfParent,i=n(e.parentNode),a=n(t.parentNode),o=n(e),r=n(t),s=d.default.getParentUntil(e,"TABLE"),u=d.default.getParentUntil(t,"TABLE"),c="TBODY"===d.default.getNodeName(s)&&"THEAD"===d.default.getNodeName(u),f=s!==u,h=!!(0,l.default)(e).parents("tbody").length&&!!(0,l.default)(t).parents("tbody").length,g={row:i,cell:o},v={row:a,cell:r},p=void 0,m=void 0;return c?g.row+=1:f?v.row+=1:h&&(g.row+=1,v.row+=1),i>a||i===a&&o>r?(p=v,m=g):(p=g,m=v),{from:p,to:m}}},{key:"highlightTableCellsBy",value:function(e,t){var n=(0,l.default)(e).parents("[contenteditable=true] table").find("tr"),i=this.getSelectionRangeFromTable(e,t),a=i.from.row,o=i.from.cell,r=i.to.row,s=i.to.cell;n.each(function(e,t){(0,l.default)(t).find("td,th").each(function(t,n){var i=(0,l.default)(n),u=e===a,c=e===r;u&&ts||er?i.removeClass("te-cell-selected"):i.addClass("te-cell-selected")})})}},{key:"removeClassAttrbuteFromAllCellsIfNeed",value:function(){this.wwe.get$Body().find("td.te-cell-selected,th.te-cell-selected").each(function(e,t){var n=(0,l.default)(t);n.removeClass("te-cell-selected"),n.attr("class").length||n.removeAttr("class")})}},{key:"getSelectedCells",value:function(){return this.wwe.get$Body().find(".te-cell-selected")}},{key:"createRangeBySelectedCells",value:function(){var e=this.wwe.getEditor(),t=e.getSelection().cloneRange(),n=this.getSelectedCells(),i=this.wwe.componentManager.getManager("table"),a=n.first().get(0),o=n.last().get(0);n.length&&i.isInTable(t)&&(t.setStart(a,0),t.setEnd(o,o.childNodes.length),e.setSelection(t))}},{key:"styleToSelectedCells",value:function(e){this.createRangeBySelectedCells(),e(this.wwe.getEditor())}},{key:"destroy",value:function(){this.eventManager.removeEventHandler("mousedown.tableSelection"),this.eventManager.removeEventHandler("mouseover.tableSelection"),this.eventManager.removeEventHandler("mouseup.tableSelection"),this.eventManager.removeEventHandler("copyBefore.tableSelection"),this.eventManager.removeEventHandler("pasteBefore.tableSelection")}}]),e}();t.default=f},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return e.replace(/[<>&]/g,function(e){return h[e]||e})}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n":">"},g=/\u200B/g,v=function(){function e(t){a(this,e),this.wwe=t,this.eventManager=t.eventManager,this.name="codeblock",this._init()}return r(e,[{key:"_init",value:function(){this._initKeyHandler(),this._initEvent()}},{key:"_initKeyHandler",value:function(){this.wwe.addKeyEventHandler("BACK_SPACE",this._removeCodeblockIfNeed.bind(this))}},{key:"_initEvent",value:function(){var e=this;this.eventManager.listen("wysiwygSetValueAfter",function(){e.splitCodeblockToEachLine()}),this.eventManager.listen("wysiwygProcessHTMLText",function(t){return e._mergeCodeblockEachlinesFromHTMLText(t)})}},{key:"prepareToPasteOnCodeblock",value:function(e){var t=this.wwe.getEditor().getSelection().cloneRange(),n=this.wwe.getEditor().getDocument().createDocumentFragment();return 1===e.length&&this._isCodeBlock(e[0])?n.appendChild(this._copyCodeblockTypeFromRangeCodeblock(e.shift(),t)):n.appendChild(this._copyCodeblockTypeFromRangeCodeblock(this.convertToCodeblock(e),t)),n}},{key:"convertToCodeblock",value:function(e){for(var t=(0,s.default)("
"),n=this,i=e.shift();c.default.isTruthy(i);)t.append(n._makeCodeBlockLineHtml(c.default.isString(i)?i:i.textContent)),i=e.shift();return t.attr("data-te-codeblock",""),t[0]}},{key:"_copyCodeblockTypeFromRangeCodeblock",value:function(e,t){var n=f.default.getParentUntil(t.commonAncestorContainer,this.wwe.get$Body()[0]);if("PRE"===f.default.getNodeName(n)){var i=(0,s.default)(n).prop("attributes");c.default.forEach(i,function(t){(0,s.default)(e).attr(t.name,t.value)})}return e}},{key:"_mergeCodeblockEachlinesFromHTMLText",value:function(e){return e=e.replace(/(.*?)<\/pre>/g,function(e,t,n){return n=n.replace(/
/g,"\n"),n=n.replace(/
/g,""),n=n.replace(/\n$/,""),"
"+n+"
"})}},{key:"splitCodeblockToEachLine",value:function(e){var t=this;e||(e=this.wwe.get$Body()),(0,s.default)(e).find("pre").each(function(e,n){var i=(0,s.default)(n),a=i.find("code").attr("data-language"),o=void 0;i.children().length>1&&(o=[],i.children().each(function(e,t){"DIV"!==t.nodeName&&"P"!==t.nodeName||(0,s.default)(t).find("br").length||(0,s.default)(t).append("
")})),i.find("br").replaceWith("\n"),o=i.text().replace(/\s+$/,"").split(/\n/g),a&&(i.attr("data-language",a),i.addClass("lang-"+a)),i.empty(),c.default.forEach(o,function(e){i.append(t._makeCodeBlockLineHtml(e))}),i.attr("data-te-codeblock","")})}},{key:"_makeCodeBlockLineHtml",value:function(e){return"
"+(e=e?o(e):"
")+"
"}},{key:"_removeCodeblockIfNeed",value:function(e,t){var n=this;if(!this.isInCodeBlock(t))return!0;var i=(0,s.default)(t.startContainer).closest("pre"),a=(0,s.default)(i).find("div").eq(0),o=a.text().replace(g,"");return 0!==t.startOffset&&0!==o.length||!((0,s.default)(i).find("div").length<=1)||(this.wwe.getEditor().modifyBlocks(function(){var e=n.wwe.getEditor().getDocument().createDocumentFragment(),t=void 0;return t=0===o.length?"
":a.html().replace(g,""),(0,s.default)(e).append((0,s.default)("
"+t+"
")),e}),!1)}},{key:"isInCodeBlock",value:function(e){var t=void 0;return t=e.collapsed?e.startContainer:e.commonAncestorContainer,this._isCodeBlock(t)}},{key:"_isCodeBlock",value:function(e){return!!(0,s.default)(e).closest("pre").length}}]),e}();t.default=v},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};a(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{tagName:"div",className:"te-tab"}));return n.sections=e.sections,n._$activeButton=null,n._render(e),n._initEvent(e),n}return r(t,e),l(t,[{key:"_initEvent",value:function(e){var t=e.onItemClick;t&&this.on("itemClick",t),this.on("click button",this._onTabButton.bind(this))}},{key:"_render",value:function(e){for(var t=e.items,n=e.initName,i=[],a=0,o=t.length;a'+t[a]+"");this.$el.html(i.join("")),this.activate(n)}},{key:"activate",value:function(e){var t=this.$el.find('button:contains("'+e+'")');this._activateTabByButton(t)}},{key:"_onTabButton",value:function(e){var t=(0,u.default)(e.target);this._activateTabByButton(t),this.trigger("itemClick",t.text())}},{key:"_activateTabByButton",value:function(e){this._isActivatedButton(e)||this._updateClassByButton(e)}},{key:"_updateClassByButton",value:function(e){if(this._$activeButton){var t=this._$activeButton.attr("data-index");this._$activeButton.removeClass("te-tab-active"),this.sections&&this.sections[t].removeClass("te-tab-active")}e.addClass("te-tab-active"),this._$activeButton=e;var n=e.attr("data-index");this.sections&&this.sections[n].addClass("te-tab-active")}},{key:"_isActivatedButton",value:function(e){return this._$activeButton&&this._$activeButton.text()===e.text()}}]),t}(d.default);t.default=f},function(e,t,n){"use strict";var i=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=n(39);a.default.fn.tuiEditor=function(){var e=void 0,t=void 0,n=this.get(0);if(n){for(var i=arguments.length,r=Array(i),l=0;l1&&void 0!==arguments[1])||arguments[1];e=e||"",this.isMarkdownMode()?this.mdEditor.setValue(e,t):this.wwEditor.setValue(this.convertor.toHTML(e),t),this.eventManager.emit("setMarkdownAfter",e)}},{key:"setHtml",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e=e||"",this.wwEditor.setValue(e),this.isMarkdownMode()){var n=this.convertor.toMarkdown(this.wwEditor.getValue(),this.toMarkOptions);this.mdEditor.setValue(n,t),this.eventManager.emit("setMarkdownAfter",n)}}},{key:"setValue",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setMarkdown(e,t)}},{key:"getMarkdown",value:function(){return this.isMarkdownMode()?this.mdEditor.getValue():this.convertor.toMarkdown(this.wwEditor.getValue(),this.toMarkOptions)}},{key:"getHtml",value:function(){return this.isWysiwygMode()&&this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(),this.toMarkOptions)),this.convertor.toHTML(this.mdEditor.getValue())}},{key:"getValue",value:function(){return this.getMarkdown()}},{key:"insertText",value:function(e){this.isMarkdownMode()?this.mdEditor.replaceSelection(e):this.wwEditor.insertText(e)}},{key:"addWidget",value:function(e,t,n,i){this.getCurrentModeEditor().addWidget(e,t,n,i)}},{key:"height",value:function(e){return u.default.isExisty(e)&&("auto"===e?(this.options.el.classList.add("auto-height"),this.minHeight(this.minHeight())):(this.options.el.classList.remove("auto-height"),this.minHeight(e)),u.default.isNumber(e)&&(e+="px"),this.options.el.style.height=e,this._height=e),this._height}},{key:"minHeight",value:function(e){if(u.default.isExisty(e)){var t=this._ui.getEditorHeight(),n=this._ui.getEditorSectionHeight(),i=t-n;this._minHeight=e,e=parseInt(e,10),e=Math.max(e-i,0),this.wwEditor.setMinHeight(e),this.mdEditor.setMinHeight(e),this.preview.setMinHeight(e)}return this._minHeight}},{key:"getCurrentModeEditor",value:function(){return this.isMarkdownMode()?this.mdEditor:this.wwEditor}},{key:"isMarkdownMode",value:function(){return"markdown"===this.currentMode}},{key:"isWysiwygMode",value:function(){return"wysiwyg"===this.currentMode}},{key:"isViewer",value:function(){return!1}},{key:"getCurrentPreviewStyle",value:function(){return this.mdPreviewStyle}},{key:"changeMode",value:function(e,t){this.currentMode!==e&&(this.eventManager.emit("changeModeBefore",this.currentMode),this.currentMode=e,this.isWysiwygMode()?(this.layout.switchToWYSIWYG(),this.wwEditor.setValue(this.convertor.toHTML(this.mdEditor.getValue()),!t),this.eventManager.emit("changeModeToWysiwyg")):(this.layout.switchToMarkdown(),this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(),this.toMarkOptions),!t),this.getCodeMirror().refresh(),this.eventManager.emit("changeModeToMarkdown")),this.eventManager.emit("changeMode",e),t||this.focus())}},{key:"remove",value:function(){var e=this,t=gt.length-1;for(this.wwEditor.remove(),this.mdEditor.remove(),this.layout.remove(),this.getUI()&&this.getUI().remove(),this.eventManager.emit("removeEditor"),this.eventManager.events.forEach(function(t,n){e.off(n)}),this.eventManager=null;t>=0;t-=1)gt[t]===this&>.splice(t,1)}},{key:"hide",value:function(){this.eventManager.emit("hide",this)}},{key:"show",value:function(){this.eventManager.emit("show",this),this.getCodeMirror().refresh()}},{key:"scrollTop",value:function(e){return this.getCurrentModeEditor().scrollTop(e)}},{key:"setUI",value:function(e){this._ui=e}},{key:"getUI",value:function(){return this._ui}},{key:"reset",value:function(){this.wwEditor.reset(),this.mdEditor.reset()}},{key:"getRange",value:function(){return this.getCurrentModeEditor().getRange()}},{key:"getTextObject",value:function(e){return this.getCurrentModeEditor().getTextObject(e)}},{key:"getSelectedText",value:function(){var e=this.getRange();return this.getTextObject(e).getTextContent()||""}}],[{key:"getInstances",value:function(){return gt}},{key:"defineExtension",value:function(e,t){M.default.defineExtension(e,t)}},{key:"factory",value:function(t){return t.viewer?new x.default(t):new e(t)}}]),e}();vt.isViewer=!1,vt.i18n=I.default,vt.domUtils=j.default,vt.codeBlockManager=q.default,vt.Button=d.default,vt.WwCodeBlockManager=L.default,vt.WwTableManager=F.default,vt.WwTableSelectionManager=W.default,vt.CommandManager=C.default,vt.markdownitHighlight=N.default.getMarkdownitHighlightRenderer(),e.exports=vt},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;nt))return e;e=i(e,u,1,a)}d=a.getLine(e)}while(l.test(d));return e}function a(e,t){for(var n=e,i=t.getLine(e);l.test(i);)n-=1,i=t.getLine(n);return e===n?n=-1:n+=1,n}var o=n(6),r=function(e){return e&&e.__esModule?e:{default:e}}(o),l=/^(\s*)((\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(.*)/;r.default.commands.indentLessOrderedList=function(e){return e.getOption("disableInput")?r.default.Pass:(e.execCommand("indentLess"),e.execCommand("fixOrderedListNumber"),null)},r.default.commands.fixOrderedListNumber=function(e){if(e.getOption("disableInput"))return r.default.Pass;for(var t=e.listSelections(),n=0;n=0){var u=e.getLine(s),c=l.exec(u),d=c[1],f=c[3];i(s,d.length,parseInt(f,10),e)}}return null}},function(e,t,n){"use strict";var i=n(6),a=function(e){return e&&e.__esModule?e:{default:e}}(i);a.default.overlayMode=function(e,t,n){return{startState:function(){return{base:a.default.startState(e),overlay:a.default.startState(t),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(n){return{base:a.default.copyState(e,n.base),overlay:a.default.copyState(t,n.overlay),basePos:n.basePos,baseCur:null,overlayPos:n.overlayPos,overlayCur:null}},token:function(i,a){return(i!=a.streamSeen||Math.min(a.basePos,a.overlayPos)=0&&(a.indentationDiff<4&&(a.indentation-=a.indentationDiff),a.list=null),a.indentation>0?(a.list=null,a.listDepth=Math.floor(a.indentation/4)):(a.list=!1,a.listDepth=0));var c=null;if(a.indentationDiff>=4)return e.skipToEnd(),s||o(a.prevLine)?(a.indentation-=4,a.indentedCode=!0,M):null;if(e.eatSpace())return null;if((c=e.match(V))&&c[1].length<=6)return a.header=c[1].length,t.highlightFormatting&&(a.formatting="header"),a.f=a.inline,d(a);if(!(o(a.prevLine)||a.quote||l||s)&&(c=e.match(q)))return a.header="="==c[0].charAt(0)?1:2,t.highlightFormatting&&(a.formatting="header"),a.f=a.inline,d(a);if(e.eat(">"))return a.quote=r?1:a.quote+1,t.highlightFormatting&&(a.formatting="quote"),e.eatSpace(),d(a);if("["===e.peek())return i(e,a,m);if(e.match(H,!0))return a.hr=!0,B;if((o(a.prevLine)||l)&&(e.match(F,!1)||e.match(U,!1))){var f=null;return e.match(F,!0)?f="ul":(e.match(U,!0),f="ol"),a.indentation+=4,a.list=!0,a.listDepth++,t.taskLists&&e.match(W,!1)&&(a.taskList=!0,a.task=!0),a.f=a.inline,t.highlightFormatting&&(a.formatting=["list","list-"+f]),d(a)}return t.fencedCodeBlocks&&(c=e.match(Y,!0))?(a.fencedChars=c[1],a.localMode=n(c[2]),a.localMode&&(a.localState=a.localMode.startState()),a.f=a.block=u,t.highlightFormatting&&(a.formatting="code-block"),a.code=!0,d(a)):i(e,a,a.inline)}function s(e,t){var n=w.token(e,t.htmlState);return(k&&null===t.htmlState.tagStart&&!t.htmlState.context&&t.htmlState.tokenize.isInText||t.md_inside&&e.current().indexOf(">")>-1)&&(t.f=h,t.block=l,t.htmlState=null),n}function u(e,t){return e.sol()&&t.fencedChars&&e.match(t.fencedChars,!1)?(t.localMode=t.localState=null,t.f=t.block=c,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),M)}function c(e,n){e.match(n.fencedChars),n.block=l,n.f=h,n.fencedChars=null,t.highlightFormatting&&(n.formatting="code-block"),n.code=!0;var i=d(n);return n.code=!1,i}function d(e){var n=[];if(e.formatting){n.push(A),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var i=0;i=e.quote?n.push(A+"-"+e.formatting[i]+"-"+e.quote):n.push("error"))}if(e.taskOpen)return n.push("meta"),n.length?n.join(" "):null;if(e.taskClosed)return n.push("property"),n.length?n.join(" "):null;if(e.linkHref?n.push(R,"url"):(e.strong&&n.push($),e.em&&n.push(D),e.strikethrough&&n.push(j),e.linkText&&n.push(I),e.code&&n.push(M)),e.header&&(n.push(E),n.push(E+"-"+e.header)),e.quote&&(n.push(T),!t.maxBlockquoteDepth||t.maxBlockquoteDepth>=e.quote?n.push(T+"-"+e.quote):n.push(T+"-"+t.maxBlockquoteDepth)),!1!==e.list){var a=(e.listDepth-1)%3;a?1===a?n.push(O):n.push(L):n.push(S)}return e.trailingSpaceNewLine?n.push("trailing-space-new-line"):e.trailingSpace&&n.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),n.length?n.join(" "):null}function f(e,t){if(e.match(K,!0))return d(t)}function h(e,n){var i=n.text(e,n);if(void 0!==i)return i;if(n.list)return n.list=null,d(n);if(n.taskList){return"x"!==e.match(W,!0)[1]?n.taskOpen=!0:n.taskClosed=!0,t.highlightFormatting&&(n.formatting="task"),n.taskList=!1,d(n)}if(n.taskOpen=!1,n.taskClosed=!1,n.header&&e.match(/^#+$/,!0))return t.highlightFormatting&&(n.formatting="header"),d(n);var a=e.sol(),o=e.next();if("\\"===o&&(e.next(),t.highlightFormatting)){var r=d(n);return r?r+" formatting-escape":"formatting-escape"}if(n.linkTitle){n.linkTitle=!1;var l=o;"("===o&&(l=")"),l=(l+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var s="^\\s*(?:[^"+l+"\\\\]+|\\\\\\\\|\\\\.)"+l;if(e.match(new RegExp(s),!0))return R}if("`"===o){var u=n.formatting;t.highlightFormatting&&(n.formatting="code");var c=d(n),f=e.pos;e.eatWhile("`");var h=1+e.pos-f;return n.code?h===C?(n.code=!1,c):(n.formatting=u,d(n)):(C=h,n.code=!0,d(n))}if(n.code)return d(n);if("!"===o&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return e.match(/\[[^\]]*\]/),N;if("["===o&&e.match(/.*\](\(.*\)| ?\[.*\])/,!1))return n.linkText=!0,t.highlightFormatting&&(n.formatting="link"),d(n);if("]"===o&&n.linkText&&e.match(/\(.*\)| ?\[.*\]/,!1)){t.highlightFormatting&&(n.formatting="link");var r=d(n);return n.linkText=!1,n.inline=n.f=v,r}if("<"===o&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=g,t.highlightFormatting&&(n.formatting="link");var r=d(n);return r?r+=" ":r="",r+x}if("<"===o&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=g,t.highlightFormatting&&(n.formatting="link");var r=d(n);return r?r+=" ":r="",r+P}var p=!1;if(!t.underscoresBreakWords&&"_"===o&&"_"!==e.peek()&&e.match(/(\w)/,!1)){var m=e.pos-2;if(m>=0){var y=e.string.charAt(m);"_"!==y&&y.match(/(\w)/,!1)&&(p=!0)}}if("*"===o||"_"===o&&!p)if(a&&" "===e.peek());else{if(n.strong===o&&e.eat(o)){t.highlightFormatting&&(n.formatting="strong");var c=d(n);return n.strong=!1,c}if(!n.strong&&e.eat(o))return n.strong=o,t.highlightFormatting&&(n.formatting="strong"),d(n);if(n.em===o){t.highlightFormatting&&(n.formatting="em");var c=d(n);return n.em=!1,c}if(!n.em)return n.em=o,t.highlightFormatting&&(n.formatting="em"),d(n)}else if(" "===o&&(e.eat("*")||e.eat("_"))){if(" "===e.peek())return d(n);e.backUp(1)}if(t.strikethrough)if("~"===o&&e.eatWhile(o)){if(n.strikethrough){t.highlightFormatting&&(n.formatting="strikethrough");var c=d(n);return n.strikethrough=!1,c}if(e.match(/^[^\s]/,!1))return n.strikethrough=!0,t.highlightFormatting&&(n.formatting="strikethrough"),d(n)}else if(" "===o&&e.match(/^~~/,!0)){if(" "===e.peek())return d(n);e.backUp(2)}return" "===o&&(e.match(/ +$/,!1)?n.trailingSpace++:n.trailingSpace&&(n.trailingSpaceNewLine=!0)),d(n)}function g(e,n){if(">"===e.next()){n.f=n.inline=h,t.highlightFormatting&&(n.formatting="link");var i=d(n);return i?i+=" ":i="",i+x}return e.match(/^[^>]+/,!0),x}function v(e,n){if(e.eatSpace())return null;var i=e.next();return"("===i||"["===i?(n.f=n.inline=p("("===i?")":"]"),t.highlightFormatting&&(n.formatting="link-string"),n.linkHref=!0,d(n)):"error"}function p(e){return function(n,i){if(n.next()===e){i.f=i.inline=h,t.highlightFormatting&&(i.formatting="link-string");var a=d(i);return i.linkHref=!1,a}return n.match(b(e),!0)&&n.backUp(1),i.linkHref=!0,d(i)}}function m(e,n){return e.match(/^[^\]]*\]:/,!1)?(n.f=y,e.next(),t.highlightFormatting&&(n.formatting="link"),n.linkText=!0,d(n)):i(e,n,h)}function y(e,n){if(e.match(/^\]:/,!0)){n.f=n.inline=_,t.highlightFormatting&&(n.formatting="link");var i=d(n);return n.linkText=!1,i}return e.match(/^[^\]]+/,!0),I}function _(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=h,R+" url")}function b(e){return z[e]||(e=(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),z[e]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+e+")")),z[e]}var k=a.default.modes.hasOwnProperty("xml"),w=a.default.getMode(e,k?{name:"xml",htmlMode:!0}:"text/plain");void 0===t.highlightFormatting&&(t.highlightFormatting=!1),void 0===t.maxBlockquoteDepth&&(t.maxBlockquoteDepth=0),void 0===t.underscoresBreakWords&&(t.underscoresBreakWords=!0),void 0===t.taskLists&&(t.taskLists=!1),void 0===t.strikethrough&&(t.strikethrough=!1);var C=0,E="header",M="comment",T="quote",S="variable-2",O="variable-3",L="keyword",B="hr",N="tag",A="formatting",x="link",P="link",I="link",R="string",D="em",$="strong",j="strikethrough",H=/^([*\-_])(?:\s*\1){2,}\s*$/,F=/^[*\-+]\s+/,U=/^[0-9]+([.)])\s+/,W=/^\[(x| )\](?=\s)/,V=t.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,q=/^ *(?:\={1,}|-{1,})\s*$/,K=/^[^#!\[\]*_\\<>` "'(~]+/,Y=new RegExp("^("+(!0===t.fencedCodeBlocks?"~~~+|```+":t.fencedCodeBlocks)+")[ \\t]*([\\w+#]*)"),z=[],G={startState:function(){return{f:l,prevLine:null,thisLine:null,block:l,htmlState:null,indentation:0,inline:h,text:f,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,hr:!1,task:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(e){return{f:e.f,prevLine:e.prevLine,thisLine:e.this,block:e.block,htmlState:e.htmlState&&a.default.copyState(w,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?a.default.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkTitle:e.linkTitle,code:e.code,em:e.em,strong:e.strong,strikethrough:e.strikethrough,header:e.header,hr:e.hr,taskList:e.taskList,task:e.task,list:e.list,listDepth:e.listDepth,quote:e.quote,indentedCode:e.indentedCode,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside,fencedChars:e.fencedChars}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine){var n=t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n){if(r(t),!n)return null;t.prevLine=null}t.prevLine=t.thisLine,t.thisLine=e,t.taskList=!1,t.task=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.f=t.block;var i=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length,a=4*Math.floor((i-t.indentation)/4);a>4&&(a=4);var o=t.indentation+a;if(t.indentationDiff=o-t.indentation,t.indentation=o,i>0)return null}return t.f(e,t)},innerMode:function(e){return e.block==s?{state:e.htmlState,mode:w}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:G}},blankLine:r,getType:d,closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return G},"xml"),a.default.defineMIME("text/x-markdown","markdown")},function(e,t,n){"use strict";var i=n(6),a=function(e){return e&&e.__esModule?e:{default:e}}(i);a.default.defineMode("gfm",function(e,t){function n(e){return e.code=!1,null}var i=0,o={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,t){if(t.combineTokens=null,t.codeBlock)return e.match(/^```+/)?(t.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(t.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),t.codeBlock=!0,null;if("`"===e.peek()){e.next();var n=e.pos;e.eatWhile("`");var a=1+e.pos-n;return t.code?a===i&&(t.code=!1):(i=a,t.code=!0),null}return t.code?(e.next(),null):e.eatSpace()?(t.ateSpace=!0,null):((e.sol()||t.ateSpace)&&(t.ateSpace=!1),e.next(),null)},blankLine:n},r={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var l in t)r[l]=t[l];return r.name="markdown",a.default.overlayMode(a.default.getMode(e,r),o)},"markdown"),a.default.defineMIME("text/x-gfm","gfm")},function(e,t,n){"use strict";var i=n(6),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=/^(\s*)(>[> ]*|[*+-]\s(?:\[(?:x|\s)\]\s)?|(\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(\s*)/,r=/^(\s*)(>[> ]*|[*+-]\s(?:\[(?:x|\s)\]\s)?|(\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(\s*)$/,l=/^ *(`{3,}|~{3,})[ \.]*\S+ */,s=/[*+-]\s/;a.default.commands.subListIndentTab=function(e){if(e.getOption("disableInput"))return a.default.Pass;for(var t=e.listSelections(),n=0;n0)e.replaceRange("",{line:u.line,ch:0},{line:u.line,ch:h.length}),n[i]="\n";else if(g)n[i]="\n\n```";else{var m,y=v[1],_=v[5];m=y.length===u.ch?"":s.test(v[2])||v[2].indexOf(">")>=0?v[2]:parseInt(v[3],10)+1+v[4],n[i]="\n"+y+m+_}}e.replaceSelections(n),g&&e.setCursor(u.line+1,0)}},function(e,t,n){"use strict";function i(e){return a(e)&&e.anchor.ch===e.head.ch}function a(e){return e.anchor.line===e.head.line}function o(e,t,n,a){var o=e.getLine(n.line),r=e.getLine(n.line+a),l={anchor:t,head:n};e.replaceRange(r,{line:n.line,ch:0},{line:n.line,ch:o.length},"+input"),e.replaceRange(o,{line:n.line+a,ch:0},{line:n.line+a,ch:r.length},"+input"),i(l)?e.setCursor({line:n.line+a,ch:n.ch}):e.setSelection({line:t.line+a,ch:t.ch},{line:n.line+a,ch:n.ch})}function r(e,t,n,i){var a=e.getRange({line:t.line,ch:0},{line:n.line,ch:e.getLine(n.line).length}),o=i>0?n:t,r=e.getLine(o.line+i),l=void 0;l=i>0?t:n,e.replaceRange(r,{line:l.line,ch:0},{line:l.line,ch:e.getLine(l.line).length},"+input"),e.replaceRange(a,{line:t.line+i,ch:0},{line:n.line+i,ch:e.getLine(n.line+i).length},"+input"),e.setSelection({line:t.line+i,ch:t.ch},{line:n.line+i,ch:n.ch})}var l=n(6),s=function(e){return e&&e.__esModule?e:{default:e}}(l);s.default.commands.replaceLineTextToUpper=function(e){if(e.getOption("disableInput"))return s.default.Pass;for(var t=e.listSelections(),n=0;n0)o(e,u,c,-1);else if(!i(l)){var d=u.line0){var f=u.line===d?u:c,h=u.line===d?c:u;r(e,f,h,-1)}}}},s.default.commands.replaceLineTextToLower=function(e){if(e.getOption("disableInput"))return s.default.Pass;for(var t=e.listSelections(),n=0;n?!@#$%^&*()_=+\\\/'";: \r[\]]*\|+)+/i,u=/^#+\s/,c=/^ {0,3}(```|\||>)/,d=function(){function e(t){i(this,e),this.mde=t,this.eventManager=t.eventManager,this.name="list"}return a(e,[{key:"isListOrParagraph",value:function(e){return!c.test(e)&&!s.test(e)&&!u.test(e)}},{key:"appendBlankLineIfNeed",value:function(e,t,n,i){var a=e.getDoc(),o=0,r=i!==n,l=a.getLine(this._getEndLineNumberOfList(a,n)+1),s=a.getLine(this._getStartLineNumberOfList(a,i)-1),u=a.getLine(t+1);(r&&this._isNeedAppendBlankLine(l)||!r&&this._isNeedAppendBlankLine(u))&&a.replaceRange("\n",{line:t,ch:a.getLine(t).length});var c=a.getLine(t-1);if((r&&this._isNeedAppendBlankLine(s)||!r&&this._isNeedAppendBlankLine(c))&&(a.replaceRange("\n",{line:i,ch:0}),o+=1),!r){var d=t+o;e.setCursor(d,a.getLine(d).length)}}},{key:"_isNeedAppendBlankLine",value:function(e){return e&&0!==e.length&&!this._isAList(e)}},{key:"createSortedLineRange",value:function(e){var t=e.from.line>e.to.line;return{start:{line:t?e.to.line:e.from.line,ch:0}.line,end:{line:t?e.from.line:e.to.line,ch:0}.line}}},{key:"expandLineRangeIfNeed",value:function(e,t,n){var i=this.createSortedLineRange(t),a=i.start,o=i.end,r=this._isDifferentListType(n,e.getLine(a)),l=this._isDifferentListType(n,e.getLine(o));return r&&(a=this._getStartLineNumberOfList(e,a)),l&&(o=this._getEndLineNumberOfList(e,o)),{start:a,end:o}}},{key:"replaceLineText",value:function(e,t,n,i){var a=e.getLine(t),o={line:t,ch:0},r={line:t,ch:a.length};a=a.replace(n,i),e.replaceRange(a,o,r)}},{key:"_isDifferentListType",value:function(e,t){return t&&0!==t.length&&e.call(this,t)}},{key:"_isAList",value:function(e){return e&&0!==e.length&&this._isListLine(e)}},{key:"_isListLine",value:function(e){return!!(e.match(l)||e.match(r)||e.match(o))}},{key:"_getStartLineNumberOfList",value:function(e,t){var n=void 0;for(n=t;n>0;n-=1){var i=e.getLine(n-1);if(!i||!this._isListLine(i))break}return n}},{key:"_getEndLineNumberOfList",value:function(e,t){var n=e.lineCount(),i=void 0;for(i=t;i(
|
|
|
)<\/\1>/g,U=/(?:
|
|
|
)<\/(.+?)>/g,W=/\b(H[\d]|LI|P|BLOCKQUOTE|TD|PRE)\b/,V="undefined"!=typeof MutationObserver,q=function(){function e(t,n){var i=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a(this,e),this.componentManager=new D.default(this),this.eventManager=n,this.$editorContainerEl=t,this._height=0,this._silentChange=!1,this._keyEventHandlers={},this._managers={},this._options=l.default.extend({useCommandShortcut:!0},o),this._initEvent(),this._initDefaultKeyEventHandler(),this.debouncedPostProcessForChange=u.default.debounce(function(){return i.postProcessForChange()},0)}return o(e,[{key:"init",value:function(){var e=(0,l.default)("
");this.$editorContainerEl.append(e),this.editor=new N.default(e[0],{blockTag:"DIV",leafNodeNames:{HR:!1}}),this._options.useCommandShortcut||this.editor.blockCommandShortcuts(),this._clipboardManager=new h.default(this),this._initSquireEvent(),this._clipboardManager.init(),this.get$Body().addClass("tui-editor-contents"),this.$editorContainerEl.css("position","relative"),this.codeBlockGadget=new j.default({eventManager:this.eventManager,container:this.$editorContainerEl,wysiwygEditor:this})}},{key:"_preprocessForInlineElement",value:function(e){return e.replace(/
( *)
$1B|>STRONG|^B$|^STRONG$)/.test(t.path),italic:/(>I|>EM|^I$|^EM$)/.test(t.path),strike:/(^S>|>S$|>S>|^S$)/.test(t.path),code:/CODE/.test(t.path),codeBlock:/PRE/.test(t.path),quote:/BLOCKQUOTE/.test(t.path),list:/LI(?!.task-list-item)/.test(e._getLastLiString(t.path)),task:/LI.task-list-item/.test(e._getLastLiString(t.path)),source:"wysiwyg"};e.eventManager.emit("stateChange",n)}),t.addEventListener("willPaste",function(t){e.eventManager.emit("willPaste",{source:"wysiwyg",data:t})})}},{key:"_getLastLiString",value:function(e){var t=/LI[^UO]*$/.exec(e);return t?t[0]:""}},{key:"_onKeyDown",value:function(e){var t=H.convert(e);e.keyCode&&(this.eventManager.emit("keyMap",{source:"wysiwyg",keyMap:t,data:e}),e.defaultPrevented||this.eventManager.emit("wysiwygKeyEvent",{keyMap:t,data:e}))}},{key:"_initDefaultKeyEventHandler",value:function(){var e=this;this.addKeyEventHandler("ENTER",function(t,n){e._isInOrphanText(n)&&e.defer(function(){e._wrapDefaultBlockToOrphanTexts(),e.breakToNewDefaultBlock(n,"before")}),e.defer(function(){e._scrollToRangeIfNeed()})}),this.addKeyEventHandler("TAB",function(t){var n=e.getEditor(),i=n.getSelection(),a=i.collapsed&&e._isCursorNotInRestrictedAreaOfTabAction(n),o=!i.collapsed&&d.default.isTextNode(i.commonAncestorContainer);return t.preventDefault(),!a&&!o||(n.insertPlainText("    "),!1)})}},{key:"_wrapDefaultBlockToOrphanTexts",value:function(){this.get$Body().contents().filter(this.findTextNodeFilter).each(function(e,t){t.nextSibling&&"BR"===t.nextSibling.tagName&&(0,l.default)(t.nextSibling).remove(),(0,l.default)(t).wrap("
")})}},{key:"_scrollToRangeIfNeed",value:function(){var e=this.$editorContainerEl,t=this.getRange();if(this.getEditor().getCursorPosition(t).top-e.offset().top>=e.height()){var n=t.endContainer;n instanceof Element||(n=n.parentNode),n.scrollIntoView(!1)}}},{key:"_isInOrphanText",value:function(e){return e.startContainer.nodeType===Node.TEXT_NODE&&e.startContainer.parentNode===this.get$Body()[0]}},{key:"_wrapDefaultBlockTo",value:function(e){this.saveSelection(e),this._joinSplitedTextNodes(),this.restoreSavedSelection(),e=this.getRange();var t=e.startContainer,n=e.startOffset,i=this.getEditor().createDefaultBlock([e.startContainer]),a=d.default.getChildNodeByOffset(e.startContainer,e.startOffset);a?e.setStartBefore(a):e.selectNodeContents(e.startContainer),e.collapse(!0),e.insertNode(i),e.setStart(t,n),e.collapse(!0),this.setRange(e)}},{key:"findTextNodeFilter",value:function(){return this.nodeType===Node.TEXT_NODE}},{key:"_joinSplitedTextNodes",value:function(){var e=void 0,t=void 0,n=[];this.get$Body().contents().filter(this.findTextNodeFilter).each(function(i,a){e===a.previousSibling?(t.nodeValue+=a.nodeValue,n.push(a)):t=a,e=a}),(0,l.default)(n).remove()}},{key:"saveSelection",value:function(e){e||(e=this.getRange()),this.getEditor()._saveRangeToBookmark(e)}},{key:"restoreSavedSelection",value:function(){this.setRange(this.getEditor()._getRangeAndRemoveBookmark())}},{key:"reset",value:function(){this.setValue("")}},{key:"changeBlockFormatTo",value:function(e){this.getEditor().changeBlockFormatTo(e),this.eventManager.emit("wysiwygRangeChangeAfter",this)}},{key:"makeEmptyBlockCurrentSelection",value:function(){var e=this;this.getEditor().modifyBlocks(function(t){return t.textContent||(t=e.getEditor().createDefaultBlock()),t})}},{key:"focus",value:function(){var e=this.scrollTop();this.editor.focus(),e!==this.scrollTop()&&this.scrollTop(e)}},{key:"blur",value:function(){this.editor.blur()}},{key:"remove",value:function(){this.getEditor().destroy(),this.editor=null,this.$body=null,this.eventManager=null}},{key:"setHeight",value:function(e){this._height=e,this.$editorContainerEl.css("overflow","auto"),this.$editorContainerEl.css("height","100%"),this.$editorContainerEl.parent().height(e);var t=parseInt(this.$editorContainerEl.css("padding-top"),10)-parseInt(this.$editorContainerEl.css("padding-bottom"),10),n=parseInt(this.get$Body().css("margin-top"),10)-parseInt(this.get$Body().css("margin-bottom"),10);this.get$Body().css("min-height",e-n-t+"px")}},{key:"setMinHeight",value:function(e){this.get$Body().get(0).style.minHeight=e+"px"}},{key:"setValue",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e=this.eventManager.emitReduce("wysiwygSetValueBefore",e),this.editor.setHTML(e),this.eventManager.emit("wysiwygSetValueAfter",this),this.eventManager.emit("contentChangedFromWysiwyg",this),t&&this.moveCursorToEnd(),this.getEditor().preserveLastLine(),this.getEditor().removeLastUndoStack(),this.getEditor().saveUndoState()}},{key:"insertText",value:function(e){this.editor.insertPlainText(e)}},{key:"getValue",value:function(){this._prepareGetHTML();var e=this.editor.getHTML();return e=e.replace(F,function(e,t){return"li"===t?e:"td"===t||"th"===t?"<"+t+">":"
"}),e=e.replace(U,""),e=e.replace(/]*>/g,""),e=e.replace(/<\/div>/g,"
"),e=this.eventManager.emitReduce("wysiwygProcessHTMLText",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(){V&&!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,i){var a=this.getEditor().getSelectionPosition(e,n,i),o=this.$editorContainerEl.offset();this.$editorContainerEl.append(t),(0,l.default)(t).css({position:"absolute",top:a.top-o.top,left:a.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(),i=d.default.getChildNodeByOffset(e.startContainer,e.startOffset)||d.default.getChildNodeByOffset(e.startContainer,e.startOffset-1),a=d.default.getParentUntil(i,this.get$Body()[0]);"before"===t?(0,l.default)(a).before(n):(0,l.default)(a).after(n),e.setStart(n,0),e.collapse(!0),this.setRange(e)}},{key:"replaceContentText",value:function(e,t,n){var i=(0,l.default)(e).html();(0,l.default)(e).html(i.replace(t,n))}},{key:"unwrapBlockTag",value:function(e){e||(e=function(e){return W.test(e)}),this.getEditor().changeBlockFormat(e),this.eventManager.emit("wysiwygRangeChangeAfter",this)}},{key:"moveCursorToEnd",value:function(){this.getEditor().moveCursorToEnd();var e=this.get$Body().get(0).childNodes;e.length>0&&e[e.length-1].scrollIntoView(!1),this._correctRangeAfterMoveCursor("end")}},{key:"moveCursorToStart",value:function(){this.getEditor().moveCursorToStart(),this.scrollTop(0)}},{key:"scrollTop",value:function(e){return u.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)for(;n.firstChild;)n=n.firstChild;else for(;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:"setRange",value:function(e){this.getEditor().setSelection(e)}},{key:"getTextObject",value:function(e){return new I.default(this,e)}},{key:"defer",value:function(e,t){var n=this,i=t||0;setTimeout(function(){n.isEditorValid()&&e(n)},i)}},{key:"isEditorValid",value:function(){return this.getEditor()&&l.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,i){var a=new e(t,n,i);return a.init(),a.componentManager.addManager(v.default),a.componentManager.addManager(m.default),a.componentManager.addManager(k.default),a.componentManager.addManager(_.default),a.componentManager.addManager(C.default),a.componentManager.addManager(M.default),a.componentManager.addManager(S.default),a.componentManager.addManager(L.default),a}}]),e}();t.default=q},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n");this._extendRange(a),o.append(a.cloneContents()),this._updateCopyDataForListTypeIfNeed(a,o),this.wwe.eventManager.emit("copyBefore",{source:"wysiwyg",$clipboardContainer:o}),this._setClipboardData(i,o.html(),o.text())}}},{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(){this.wwe.getEditor().getSelection().deleteContents(),this.wwe.getEditor().focus(),this._clearClipboardArea()}},{key:"_onWillPaste",value:function(e){var t=this,n=(0,l.default)("
").append(e.fragment.cloneNode(!0));this._setTableBookmark(n),this._pasteToTable(n)?e.preventDefault():(this._preparePaste(n),this._setTableBookmark(n),e.fragment=document.createDocumentFragment(),(0,l.default)(n[0].childNodes).each(function(t,n){e.fragment.appendChild(n)}));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){u.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,l.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 i=(0,l.default)("<"+n+" />");i.append(t.html()),t.html(""),t.append(i)}}},{key:"_removeEmptyFontElement",value:function(e){e.children("font").each(function(e,t){var n=(0,l.default)(t);n.text().trim()||n.remove()})}},{key:"_pasteToTable",value:function(e){var t=this.wwe.componentManager.getManager("table"),n=this.wwe.componentManager.getManager("tableSelection"),i=this.wwe.getEditor().getSelection(),a=t.isInTable(i),o=e.get(0),r=o.childNodes,l=1===r.length&&"TABLE"===r[0].nodeName,s=!1;return a&&(l?(t.pasteClipboardData(e.first()),e.html(""),s=!0):n.getSelectedCells().length&&(alert(v.default.get("Cannot paste values ​​other than a table in the cell selection state")),e.html(""),s=!0)),s}},{key:"_preparePaste",value:function(e){this._removeEmptyFontElement(e),this._pch.preparePaste(e),this.wwe.eventManager.emit("pasteBefore",{source:"wysiwyg",$clipboardContainer:e})}},{key:"_setTableBookmark",value:function(e){var t=(0,l.default)(e[0].childNodes).last();t[0]&&"TABLE"===t[0].nodeName&&t.addClass("tui-paste-table-bookmark")}},{key:"_focusTableBookmark",value:function(){var e=this.wwe.getEditor(),t=e.getSelection().cloneRange(),n=e.get$Body().find(".tui-paste-table-bookmark"),i=e.get$Body().find(".tui-paste-table-cell-bookmark");n.length&&(n.removeClass("tui-paste-table-bookmark"),t.setEndAfter(n[0]),t.collapse(!1),e.setSelection(t)),i.length&&(i.removeClass("tui-paste-table-cell-bookmark"),t.selectNodeContents(i[0]),t.collapse(!1),e.setSelection(t))}},{key:"_extendRange",value:function(e){(!d.default.isTextNode(e.commonAncestorContainer)||0===e.startOffset&&e.commonAncestorContainer.textContent.length===e.endOffset||"TD"===e.commonAncestorContainer.nodeName)&&(0===e.startOffset&&(e=this._extendStartRange(e)),e.endOffset===d.default.getOffsetLength(e.endContainer)&&(e=this._extendEndRange(e)),this._isWholeCommonAncestorContainerSelected(e)&&e.selectNode(e.commonAncestorContainer),this.wwe.getEditor().setSelection(e))}},{key:"_extendStartRange",value:function(e){for(var t=e.startContainer;t.parentNode!==e.commonAncestorContainer&&t.parentNode!==this.wwe.get$Body()[0]&&!t.previousSibling;)t=t.parentNode;return e.setStart(t.parentNode,d.default.getNodeOffsetOfParent(t)),e}},{key:"_extendEndRange",value:function(e){for(var t=e.endContainer,n=t.nextSibling;t.parentNode!==e.commonAncestorContainer&&t.parentNode!==this.wwe.get$Body()[0]&&(!n||"BR"===d.default.getNodeName(n)&&t.parentNode.lastChild===n);)t=t.parentNode,n=t.nextSibling;return e.setEnd(t.parentNode,d.default.getNodeOffsetOfParent(t)+1),e}},{key:"_isWholeCommonAncestorContainerSelected",value:function(e){return e.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&e.commonAncestorContainer!==this.wwe.get$Body()[0]&&0===e.startOffset&&e.endOffset===e.commonAncestorContainer.childNodes.length&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer}}]),e}();t.default=p},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n"),o=void 0,r=void 0,s=void 0;this._pasteFirstAid(e);var c=u.default.toArray(e[0].childNodes);for(c.length&&"DIV"===c[0].tagName&&(a.append(this._unwrapFragmentFirstChildForPasteAsInline(c[0])),c.shift());c.length;)r=c[0],o=d.default.getNodeName(r),s="LI"===o||"UL"===o||"OL"===o,n.isInCodeBlock(t)?a.append(n.prepareToPasteOnCodeblock(c)):s?(a.append(this._prepareToPasteList(c,t,i)),i=!0):a.append(c.shift());e.html(a.html())}},{key:"_wrapOrphanNodeWithDiv",value:function(e){var t=(0,l.default)("
"),n=u.default.toArray(e[0].childNodes),i=void 0;return u.default.forEachArray(n,function(e){var n=3===e.nodeType,a=/^(SPAN|A|CODE|EM|I|STRONG|B|S|ABBR|ACRONYM|CITE|DFN|KBD|SAMP|VAR|BDO|Q|SUB|SUP)$/gi.test(e.tagName);n||a?(i||(i=document.createElement("div"),t.append(i)),i.appendChild(e)):(i&&"BR"!==i.lastChild.tagName&&i.appendChild((0,l.default)("
")[0]),i=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,h.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){this.wwe.componentManager.getManager("codeblock").splitCodeblockToEachLine(e)}},{key:"_unwrapIfNonBlockElementHasBr",value:function(e){e.find("span, a, b, em, i, s").each(function(e,t){var n=(0,l.default)(t).children("br");n.length&&"LI"!==t.nodeName&&"UL"!==t.nodeName&&n.eq(0).unwrap()})}},{key:"_unwrapNestedBlocks",value:function(e,t){e.find(":not(:has(*))").not("b,s,i,em,code,span").each(function(n,i){for(var a="BR"===i.nodeName?(0,l.default)(i.parentNode):(0,l.default)(i);a.parents(t).length;){var o=a.parent(t);o.length&&o[0]!==e[0]?a.unwrap():a=a.parent()}})}},{key:"_removeUnnecessaryBlocks",value:function(e,t){e.find(t).each(function(e,n){var i=(0,l.default)(n),a=n.tagName,o="DIV"===a,r=0!==i.parent("li").length,s=0!==i.parent("blockquote").length,u=i.children(t).length;o&&(r||s||!u)||i.replaceWith(i.html())})}},{key:"_removeStyles",value:function(e){var t=(0,l.default)(e),n=void 0;"SPAN"!==d.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 i=d.default.getNodeName(e[0]),a=e.shift(),o=this.wwe.getEditor().getDocument().createDocumentFragment();if("LI"!==i&&e.length&&"LI"===e[0].tagName&&(i="LI",a=this._makeNodeAndAppend({tagName:i},a)),"OL"===i||"UL"===i)!n&&this.wwe.getEditor().hasFormat("LI")?(0,l.default)(o).append(this._wrapCurrentFormat(a)):(0,l.default)(o).append(a);else if("LI"===i){var r=this.wwe.getEditor().getDocument().createDocumentFragment();for(r.appendChild(a);e.length&&"LI"===e[0].tagName;)r.appendChild(e.shift());!n&&this.wwe.getEditor().hasFormat("LI")?(0,l.default)(o).append(this._wrapCurrentFormat(r)):!t||"UL"!==t.commonAncestorName&&"OL"!==t.commonAncestorName?(0,l.default)(o).append(this._makeNodeAndAppend({tagName:"UL"},r)):(0,l.default)(o).append(this._makeNodeAndAppend({tagName:t.commonAncestorName},r))}return o}},{key:"_unwrapFragmentFirstChildForPasteAsInline",value:function(e){return(0,l.default)(e).find("br").remove(),e.childNodes}},{key:"_wrapCurrentFormat",value:function(e){var t=this,n=void 0;return this._eachCurrentPath(function(i){"DIV"!==i.tagName&&(n=d.default.isElemNode(e)?e.tagName:e.firstChild.tagName,i.tagName!==n&&(e=t._makeNodeAndAppend(i,e)))}),e}},{key:"_eachCurrentPath",value:function(e){for(var t=d.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,l.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._completeTableIfNeed(e),this._updateTableIDClassName(e)}},{key:"_completeTableIfNeed",value:function(e){var t=this.wwe.componentManager.getManager("table"),n=t.wrapDanglingTableCellsIntoTrIfNeed(e);n&&e.append(n);var i=t.wrapTrsIntoTbodyIfNeed(e);i&&e.append(i);var a=t.wrapTheadAndTbodyIntoTableIfNeed(e);a&&e.append(a)}},{key:"_updateTableIDClassName",value:function(e){var t=this.wwe.componentManager.getManager("table");e.find("table").each(function(e,t){(0,l.default)(t).removeClass(function(e,t){return t.replace(/.*\s*(te-content-table-\d+)\s*.*/,"$1")})}),e.find("table").each(function(e,n){(0,l.default)(n).addClass(t.getTableIDClassName())})}}]),e}();t.default=g},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n(
|
){0,}<\1>/g,":BLANK_LINE:<$1>")}},{key:"_convertToArbitraryNestingList",value:function(e){var t=document.createElement("div");t.innerHTML=e;for(var n=t.querySelector("li > ul, li > ol");null!==n;){var i=n.parentNode;i.parentNode.insertBefore(n,i.nextElementSibling),n=t.querySelector("li > ul, li > ol")}return t.innerHTML}},{key:"_convertFromArbitraryNestingList",value:function(e){var t=document.createElement("div");t.innerHTML=e;for(var n=t.querySelector("ol > ol, ol > ul, ul > ol, ul > ul");null!==n;){for(var i=n.previousElementSibling;"LI"!==i.tagName;)i=i.previousElementSibling;i.appendChild(n),n=t.querySelector("ol > ol, ol > ul, ul > ol, ul > ul")}return t.innerHTML}},{key:"getLinesOfSelection",value:function(e,t){var n=[],i=!1,a=!0,o=void 0;u.default.isTextNode(e)&&(e=(0,l.default)(e).parents("DIV,LI").first().get(0)),u.default.isTextNode(t)&&(t=(0,l.default)(t).parents("DIV,LI").first().get(0));for(var r=e;a&&(0,l.default)(r).is("DIV,LI");r=o)n.push(r),r===t?i=!0:o=this._getNextLine(r,t),a=o&&!i;return n}},{key:"_getNextLine",value:function(e,t){var n=e.nextElementSibling;return n?(0,l.default)(n).is("OL,UL")&&(n=n.querySelector("li")):n=e.parentNode.nextElementSibling,(0,l.default)(n).is("DIV,LI")||n===t?n:this._getNextLine(n)}},{key:"mergeList",value:function(e){var t=e.parentNode,n=t.previousElementSibling,i=t.nextElementSibling;t.firstElementChild===e&&n&&(0,l.default)(n).is("OL,UL")&&(this._mergeList(t,n),t=n),t.lastElementChild===e&&i&&(0,l.default)(i).is("OL,UL")&&this._mergeList(i,t)}},{key:"_mergeList",value:function(e,t){var n=e.firstElementChild;if(t&&(0,l.default)(t).is("OL,UL")){for(;n;){var i=n.nextElementSibling;t.appendChild(n),n=i}e.parentNode.removeChild(e)}}}]),e}();t.default=d},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n")})}}]),e}();t.default=d},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n");t.html(e),t.find("p").each(function(e,t){var n=t.innerHTML,i=n.split(/
/gi),a=i.length-1,o=t.nextElementSibling||t.nextSibling,l="";l=i.map(function(e,t){var n="";return t>0&&t"),e&&(n="
"+e+"
"),n}),o&&"P"===o.nodeName&&l.push("

"),(0,r.default)(t).replaceWith((0,r.default)(l.join("")))}),e=t.html()}return e}},{key:"_ensurePtagContentWrappedWithDiv",value:function(){this.wwe.get$Body().find("p").each(function(e,t){(0,r.default)(t).find("div").length<=0&&(0,r.default)(t).wrapInner("
"),(0,r.default)(t).next().is("p")&&(0,r.default)(t).append("

")})}},{key:"_unwrapPtags",value:function(){this.wwe.get$Body().find("div").each(function(e,t){(0,r.default)(t).parent().is("p")&&(0,r.default)(t).unwrap()})}}]),e}();t.default=l},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n")})}},{key:"_unwrapHeading",value:function(){this.wwe.unwrapBlockTag(function(e){return c.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,l.default)("

").insertBefore(u.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 i=t.startContainer,a=u.default.getTopPrevNodeUnder(i,this.wwe.get$Body()[0]),o=a&&0===a.textContent.length,r=this.wwe.getEditor();0===i.textContent.length?n=this._removeHedingAndChangeSelection(e,t,a):o&&(e.preventDefault(),r.saveUndoState(t),(0,l.default)(a).remove(),n=!0)}return n}},{key:"_removeHedingAndChangeSelection",value:function(e,t,n){var i=t.startContainer,a=this.wwe.getEditor(),o=this.wwe.get$Body(),r=c.test(u.default.getNodeName(i)),s=r?i:(0,l.default)(i).parents("h1,h2,h3,h4,h5,h6")[0],d=n,f=1;return e.defaultPrevented||(e.preventDefault(),a.saveUndoState(t)),(0,l.default)(s).remove(),n||(d=o.children("div").first().get(0),f=0),t.setStart(d,f),t.collapse(!0),a.setSelection(t),!0}}]),e}();t.default=d},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=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(i){var a=void 0,o=void 0,r=void 0,l=void 0,s=void 0,u=void 0,c=void 0;if(i.childNodes.length?a=i.childNodes.item(0):(a=n.createDefaultBlock(),i.appendChild(a)),e){for(;a.firstChild;)a=a.firstChild;for(c=function(e){l.appendChild(e)};a!==i;){if(s=a.tagName,d.default.isFunction(e)?e(s):s===e){l=a.childNodes.item(0),(!v.default.isElemNode(l)||a.childNodes.length>1)&&(l=n.createDefaultBlock(),d.default.forEachArray(d.default.toArray(a.childNodes),c),(u=l.lastChild)&&"BR"===v.default.getNodeName(u)&&l.removeChild(u)),r=t?n.createElement(t,[l]):l,o=n.getDocument().createDocumentFragment(),o.appendChild(r),i=o;break}a=a.parentNode}}return o&&e||!t||"DIV"!==v.default.getNodeName(i.childNodes[0])||(i=n.createElement(t,[i.childNodes[0]])),i})}},{key:"changeBlockFormatTo",value:function(e){this.changeBlockFormat(function(e){return p.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 i=this.getSelection().cloneRange();this._replaceRelativeOffsetOfSelection(e,t,n,i)}},{key:"_replaceRelativeOffsetOfSelection",value:function(e,t,n,i){var a=void 0,o=void 0,r=void 0,l=i.endContainer,s=i.endOffset;"TEXT"!==v.default.getNodeName(l)&&(l=this._getClosestTextNode(l,s))&&(s=v.default.isTextNode(l)?l.nodeValue.length:l.textContent.length),l?(a=this.getSelectionInfoByOffset(l,s+t),i.setStart(a.element,a.offset),r=s+(t+n),o=this.getSelectionInfoByOffset(l,r),i.setEnd(o.element,o.offset),this.replaceSelection(e,i)):this.replaceSelection(e)}},{key:"_getClosestTextNode",value:function(e,t){var n=v.default.getChildNodeByOffset(e,t-1);return"TEXT"!==v.default.getNodeName(n)&&(n=n.previousSibling),n}},{key:"getSelectionInfoByOffset",value:function(e,t){var n=void 0,i=void 0,a=void 0,o=void 0,r=t>=0?"next":"previous",l=Math.abs(t),s=n;for(n="next"===r?e:e.previousSibling,a=l,o=0;n&&(i=v.default.isTextNode(n)?n.nodeValue.length:n.textContent.length,o+=i,!(l<=o));)a-=i,v.default.getTextLength(n)>0&&(s=n),n=n[r+"Sibling"];return n||(n=s,a=v.default.getTextLength(n)),"previous"===r&&(a=v.default.getTextLength(n)-a),{element:n,offset:a}}},{key:"getSelectionPosition",value:function(e,t,n){var i=this.createElement("INPUT"),a=e.cloneRange(),o=this.getSelectionInfoByOffset(e.endContainer,e.endOffset+(n||0));a.setStart(a.startContainer,a.startOffset),a.setEnd(o.element,o.offset),this._ignoreChange=!0,this.insertElement(i,a);var r=(0,u.default)(i).offset();return"over"!==t&&(r.top+=(0,u.default)(i).outerHeight()),i.parentNode.removeChild(i),e.setStart(e.endContainer,e.endOffset),e.collapse(!0),this.setSelection(e),r}},{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 i=(0,u.default)(e).closest(t);i.length&&(i.wrapInner("<"+n+"/>"),i.children().unwrap())}},{key:"preserveLastLine",value:function(){var e=this.get$Body().children().last();"DIV"!==v.default.getNodeName(e[0])&&(this._ignoreChange=!0,(0,u.default)(this.createDefaultBlock()).insertAfter(e))}},{key:"scrollTop",value:function(e){return d.default.isUndefined(e)?this.get$Body().scrollTop():this.get$Body().scrollTop(e)}},{key:"isIgnoreChange",value:function(){return this._ignoreChange}},{key:"focus",value:function(){h.default.prototype.focus.call(this)}},{key:"blockCommandShortcuts",value:function(){var e=this,t=/Mac/.test(navigator.platform),n=t?"meta":"ctrl";["b","i","u","shift-7","shift-5","shift-6","shift-8","shift-9","[","]"].forEach(function(t){e.setKeyHandler(n+"-"+t,function(e,t){t.preventDefault()})})}}]),t}(h.default);t.default=y},function(e,t){e.exports=r},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=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;u.default.isTextNode(e.endContainer)&&e.endOffsettext"),this.$el.append(this._$languageLabel),this._$buttonOpenModalEditor=(0,c.default)(''),this.$el.append(this._$buttonOpenModalEditor)}},{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,c.default)(this.getAttachedElement()),t=e.offset();t.left=t.left+(e.outerWidth()-250),this.$el.offset(t),this.$el.height(30),this.$el.width(250)}},{key:"onShow",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onShow",this).call(this),this._onAttachedElementChange=function(){return e._updateLanguage()},(0,c.default)(this.getAttachedElement()).on("language-changed",this._onAttachedElementChange),this._updateLanguage()}},{key:"onHide",value:function(){(0,c.default)(this.getAttachedElement()).off("language-changed",this._onAttachedElementChange),s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onHide",this).call(this)}}]),t}(f.default);t.default=h},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=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&&r.default.contains(document,this._$attachedElement[0])?this.syncLayout():this.setVisibility(!1)}},{key:"_onMouseOver",value:function(e){var t=e.data,n=(0,r.default)(t.target),i=n.closest(this._attachedSelector);i.length?(this._$attachedElement=i,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";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n','
','
','
','
',"
",'
','
',"
","
"].join(""),s=function(){function e(t,n){i(this,e),this.$el=(0,r.default)(t.el),this.height=t.height,this.type=t.initialEditType,this.eventManager=n,this.init(),this._initEvent()}return a(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,r.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=s},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n\n
\n
\n
\n
\n').appendTo(e),this._editorSection=this.$el.find(".te-editor-section").get(0),this._editorSection.appendChild(this._editor.layout.getEditorEl().get(0)),this._initToolbar(),this._initModeSwitch(),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(){this.toolbar=new u.default(this._editor.eventManager),this.$el.find(".te-toolbar-section").append(this.toolbar.$el)}},{key:"_initModeSwitch",value:function(){var e=this;this._modeSwitch=new v.default("markdown"===this._initialEditType?v.default.TYPE.MARKDOWN:v.default.TYPE.WYSIWYG),this.$el.find(".te-mode-switch-section").append(this._modeSwitch.$el),this._modeSwitch.on("modeSwitched",function(t,n){return e._editor.changeMode(n)})}},{key:"_initMarkdownTab",value:function(){var e=this._editor;this.markdownTab=new d.default({initName:N.default.get("Write"),items:[N.default.get("Write"),N.default.get("Preview")],sections:[e.layout.getMdEditorContainerEl(),e.layout.getPreviewEl()]}),this._$markdownTabSection=this.$el.find(".te-markdown-tab-section"),this._$markdownTabSection.append(this.markdownTab.$el),this.markdownTab.on("itemClick",function(t,n){n===N.default.get("Preview")?e.eventManager.emit("previewNeedsRefresh"):e.getCodeMirror().focus()})}},{key:"_markdownTabControl",value:function(){this._editor.isMarkdownMode()&&"tab"===this._editor.getCurrentPreviewStyle()?(this._$markdownTabSection.show(),this.markdownTab.activate(N.default.get("Write"))):this._$markdownTabSection.hide()}},{key:"_initPopupAddLink",value:function(){this.popupAddLink=new m.default({$target:this.$el,editor:this._editor})}},{key:"_initPopupAddImage",value:function(){this.popupAddImage=new _.default({$target:this.$el,eventManager:this._editor.eventManager})}},{key:"_initPopupAddTable",value:function(){this.popupAddTable=new C.default({$target:this.$el,eventManager:this._editor.eventManager,$button:this.$el.find("button.tui-table"),css:{position:"absolute"}})}},{key:"_initPopupAddHeading",value:function(){this.popupAddHeading=new M.default({$target:this.$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,l.default)(t.data.target).parents("[contenteditable=true] table").length>0&&(t.data.preventDefault(),e._editor.eventManager.emit("openPopupTableUtils",t.data))}),this.popupTableUtils=new k.default({$target:this.$el,eventManager:this._editor.eventManager})}},{key:"_initPopupCodeBlockLanguages",value:function(){var e=this._editor;this.popupCodeBlockLanguages=new S.default({$target:this.$el,eventManager:e.eventManager,languages:e.options.codeBlockLanguages})}},{key:"_initPopupCodeBlockEditor",value:function(){this.popupCodeBlockEditor=new L.default({$target:this.$el,eventManager:this._editor.eventManager,convertor:this._editor.convertor})}},{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:"hide",value:function(){this.$el.addClass("te-hide")}},{key:"show",value:function(){this.$el.removeClass("te-hide")}},{key:"remove",value:function(){this.$el.remove(),x.default.hide()}},{key:"createPopup",value:function(e){return new h.default(e)}}]),e}();t.default=P},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n=0;n-=1)d.default.isNumber(t)?this._addButton(e[n],t):this._addButton(e);else this._addButton(e,t)}},{key:"_addButton",value:function(e,t){var n=this._setButton(e,t).$el;d.default.isNumber(t)?this.$buttonContainer.find(".tui-toolbar-icons").eq(t-1).before(n):this.$buttonContainer.append(n)}},{key:"addDivider",value:function(){var e=(0,u.default)('
');return this.$buttonContainer.append(e),e}},{key:"_setButton",value:function(e,t){var n=this.eventManager;return e instanceof v.default||(e=new v.default(e)),e.on("command",function(e,t){return n.emit("command",t)}),e.on("event",function(e,t){return n.emit(t)}),d.default.isNumber(t)?this.buttons.splice(t,0,e):this.buttons.push(e),e}},{key:"_initButton",value:function(e){var t=this;this.buttonOptions={heading:{className:"tui-heading",event:"openHeadingSelect",tooltip:m.default.get("Headings")},bold:{className:"tui-bold",command:"Bold",tooltip:m.default.get("Bold"),state:"bold"},italic:{className:"tui-italic",command:"Italic",tooltip:m.default.get("Italic"),state:"italic"},strike:{className:"tui-strike",command:"Strike",tooltip:m.default.get("Strike"),state:"strike"},ul:{className:"tui-ul",command:"UL",tooltip:m.default.get("Unordered list")},ol:{className:"tui-ol",command:"OL",tooltip:m.default.get("Ordered list")},task:{className:"tui-task",command:"Task",tooltip:m.default.get("Task")},hr:{className:"tui-hrline",command:"HR",tooltip:m.default.get("Line")},table:{className:"tui-table",event:"openPopupAddTable",tooltip:m.default.get("Insert table")},image:{className:"tui-image",event:"openPopupAddImage",tooltip:m.default.get("Insert image")},link:{className:"tui-link",event:"openPopupAddLink",tooltip:m.default.get("Insert link")},quote:{className:"tui-quote",command:"Blockquote",tooltip:m.default.get("Blockquote"),state:"quote"},codeBlock:{className:"tui-codeblock",command:"CodeBlock",tooltip:m.default.get("Insert CodeBlock"),state:"codeBlock"},code:{className:"tui-code",command:"Code",tooltip:m.default.get("Code"),state:"code"}},d.default.forEach(e,function(e){"|"===e?t.addDivider():t.buttonOptions[e]&&t.addButton(new v.default(t.buttonOptions[e]))})}}]),t}(h.default);t.default=y},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n'+v.default.get("Markdown")+""),this.buttons.$wysiwyg=(0,u.default)('"),this.$el.append(this.buttons.$markdown),this.$el.append(this.buttons.$wysiwyg),this.on("click .markdown",this._changeMarkdown.bind(this)),this.on("click .wysiwyg",this._changeWysiwyg.bind(this))}},{key:"_changeMarkdown",value:function(){this._switchType(p)}},{key:"_changeWysiwyg",value:function(){this._switchType("wysiwyg")}},{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}(h.default);m.TYPE={MARKDOWN:p,WYSIWYG:"wysiwyg"},t.default=m},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n\n \n \n \n
\n \n \n
\n ";return e=c.default.extend({header:!0,title:g.default.get("Insert link"),className:"te-popup-add-link tui-editor-popup",content:n},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(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(){s(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;s(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,i=e._editor.getSelectedText().trim();t.value=i,v.exec(i)&&(n.value=i),i.length>0&&n.value.length<1?n.focus():(t.focus(),t.setSelectionRange(0,i.length))}),this.on("hidden",function(){e._resetInputs()})}},{key:"_initEditorEvent",value:function(){var e=this;s(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;return this._clearValidationStyle(),n.length<1?void this._inputText.classList.add("wrong"):t.length<1?void this._inputURL.classList.add("wrong"):(this._eventManager.emit("command","AddLink",{linkText:n,url:t}),void this.hide())}},{key:"_getValue",value:function(){return{url:this._inputURL.value,linkText:this._inputText.value}}},{key:"_clearValidationStyle",value:function(){this._inputURL.classList.remove("wrong"),this._inputText.classList.remove("wrong")}},{key:"_resetInputs",value:function(){this._inputText.value="",this._inputURL.value="",this._clearValidationStyle()}}]),t}(f.default);t.default=p},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n
\n
\n \n \n
\n
\n \n \n
\n \n \n
\n \n \n
\n ";return e=c.default.extend({header:!0,title:p.default.get("Insert image"),className:"te-popup-add-image tui-editor-popup",content:n},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this.eventManager=e.eventManager}},{key:"_initDOM",value:function(){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOM",this).call(this);var e=this.$el;this._$imageUrlInput=e.find("."+m),this._$imageFileInput=e.find("."+y),this._$altTextInput=e.find("."+_);var n=e.find("."+w),i=e.find("."+C),a=this.$body.find("."+E);this.tab=new g.default({initName:p.default.get("File"),items:[p.default.get("File"),p.default.get("URL")],sections:[n,i]}),a.append(this.tab.$el)}},{key:"_initDOMEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this),this.on("shown",function(){return e._$imageUrlInput.focus()}),this.on("hidden",function(){return e._resetInputs()}),this.on("change ."+y,function(){var t=e._$imageFileInput.val().split("\\").pop();e._$altTextInput.val(t)}),this.on("click ."+k,function(){return e.hide()}),this.on("click ."+b,function(){var t=e._$imageUrlInput.val(),n=e._$altTextInput.val();if(t)e._applyImage(t,n);else{var i=e._$imageFileInput.get(0).files.item(0),a=function(t,i){return e._applyImage(t,n||i)};e.eventManager.emit("addImageBlobHook",i,a,"ui")}e.hide()}),this.tab.on("itemClick",function(){return e._resetInputs()})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this.eventManager.listen("focus",function(){return e.hide()}),this.eventManager.listen("closeAllPopup",function(){return e.hide()}),this.eventManager.listen("openPopupAddImage",function(){e.eventManager.emit("closeAllPopup"),e.show()})}},{key:"_applyImage",value:function(e,t){this.eventManager.emit("command","AddImage",{imageUrl:e,altText:t||"image"}),this.hide()}},{key:"_resetInputs",value:function(){this.$el.find("input").val("")}}]),t}(f.default);t.default=M},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n\n \n \n \n
\n \n \n \n
\n \n ";return e=f.default.extend({header:!1,className:"te-popup-table-utils",content:n},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this.eventManager=e.eventManager}},{key:"_initDOMEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this),this.on("click .te-table-add-row",function(){return e.eventManager.emit("command","AddRow")}),this.on("click .te-table-add-col",function(){return e.eventManager.emit("command","AddCol")}),this.on("click .te-table-remove-row",function(){return e.eventManager.emit("command","RemoveRow")}),this.on("click .te-table-col-align-left",function(){return e.eventManager.emit("command","AlignCol","left")}),this.on("click .te-table-col-align-center",function(){return e.eventManager.emit("command","AlignCol","center")}),this.on("click .te-table-col-align-right",function(){return e.eventManager.emit("command","AlignCol","right")}),this.on("click .te-table-remove-col",function(){return e.eventManager.emit("command","RemoveCol")}),this.on("click .te-table-remove",function(){return e.eventManager.emit("command","RemoveTable")})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this.eventManager.listen("focus",function(){return e.hide()}),this.eventManager.listen("mousedown",function(){return e.hide()}),this.eventManager.listen("closeAllPopup",function(){return e.hide()}),this.eventManager.listen("openPopupTableUtils",function(t){var n=e.$el.parent().offset(),i=t.clientX-n.left,a=t.clientY-n.top+(0,c.default)(window).scrollTop();e.eventManager.emit("closeAllPopup"),e.$el.css({position:"absolute",top:a+5,left:i+10}),e.show()})}}]),t}(g.default);t.default=m},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n\n
\n
\n
\n
\n

\n',g=function(e){function t(e){return a(this,t),e=c.default.extend({header:!1,className:"te-popup-add-table",content:h},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this._selectedBound={},this._tableBound={},this._eventManager=e.eventManager,this.$button=e.$button}},{key:"_initDOM",value:function(){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOM",this).call(this),this._cacheElements(),this._setTableSizeByBound(5,7)}},{key:"_initDOMEvent",value:function(e){var n=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this,e),this.on("mousemove .te-table-selection",function(e){var t=e.pageX-n._selectionOffset.left,i=e.pageY-n._selectionOffset.top,a=n._getSelectionBoundByOffset(t,i);n._resizeTableBySelectionIfNeed(a.col,a.row),n._setSelectionAreaByBound(a.col,a.row),n._setDisplayText(a.col,a.row),n._setSelectedBound(a.col,a.row)}),this.on("click .te-table-selection",function(){var e=n._getSelectedTableSize();n._eventManager.emit("command","Table",e.col,e.row)})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this._eventManager.listen("focus",function(){return e.hide()}),this._eventManager.listen("closeAllPopup",function(){return e.hide()}),this._eventManager.listen("openPopupAddTable",function(){e._eventManager.emit("closeAllPopup");var t=e.$button,n=t.position();e.$el.css({top:n.top+t.outerHeight(!0),left:n.left}),e.show(),e._selectionOffset=e.$el.find(".te-table-selection").offset()})}},{key:"_cacheElements",value:function(){this.$header=this.$el.find(".te-table-header"),this.$body=this.$el.find(".te-table-body"),this.$selection=this.$el.find(".te-selection-area"),this.$desc=this.$el.find(".te-description")}},{key:"_resizeTableBySelectionIfNeed",value:function(e,t){var n=this._getResizedTableBound(e,t);n&&this._setTableSizeByBound(n.col,n.row)}},{key:"_getResizedTableBound",value:function(e,t){var n=void 0,i=void 0,a=void 0;return e>=5&&e<9?n=e+1:e<5&&(n=5),t>=7&&t<14?i=t+1:t<7&&(i=7),this._isNeedResizeTable(n,i)&&(a={row:i||this._tableBound.row,col:n||this._tableBound.col}),a}},{key:"_isNeedResizeTable",value:function(e,t){return e&&e!==this._tableBound.col||t&&t!==this._tableBound.row}},{key:"_getBoundByOffset",value:function(e,t){return{row:parseInt(t/17,10),col:parseInt(e/25,10)}}},{key:"_getOffsetByBound",value:function(e,t){return{x:25*e+25,y:17*t+17}}},{key:"_setTableSizeByBound",value:function(e,t){var n=this._getOffsetByBound(e,t-1);this._setTableSize(n.x,n.y),this._tableBound.row=t,this._tableBound.col=e}},{key:"_getSelectionBoundByOffset",value:function(e,t){var n=this._getBoundByOffset(e,t);return n.row<1?n.row=1:n.row>this._tableBound.row&&(n.row=this._tableBound.row),n.col<1?n.col=1:n.col>this._tableBound.col&&(n.col=this._tableBound.col),n}},{key:"_setSelectionAreaByBound",value:function(e,t){var n=this._getOffsetByBound(e,t);this._setSelectionArea(n.x,n.y)}},{key:"_setSelectedBound",value:function(e,t){this._selectedBound.col=e,this._selectedBound.row=t}},{key:"_getSelectedTableSize",value:function(){return{row:this._selectedBound.row+1,col:this._selectedBound.col+1}}},{key:"_setDisplayText",value:function(e,t){this.$desc.html(e+1+" x "+(t+1))}},{key:"_setTableSize",value:function(e,t){e+=1,t+=1,this.$header.css({height:17,width:e}),this.$body.css({height:t,width:e}),this.$el.css({width:e+30})}},{key:"_setSelectionArea",value:function(e,t){e+=1,t+=1,this.$selection.css({height:t,width:e})}}]),t}(f.default);g.CELL_WIDTH=25,g.CELL_HEIGHT=17,g.MIN_ROW_SELECTION_INDEX=1,g.MIN_COL_SELECTION_INDEX=1,t.default=g},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n\n
  • '+p.default.get("Heading")+' 2

  • \n
  • '+p.default.get("Heading")+' 3

  • \n
  • '+p.default.get("Heading")+' 4

  • \n
  • '+p.default.get("Heading")+' 5
  • \n
  • '+p.default.get("Heading")+' 6
  • \n
  • '+p.default.get("Paragraph")+"
  • \n \n ";return e=f.default.extend({header:!1,className:"te-heading-add",content:n},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this._eventManager=e.eventManager,this._$button=e.$button}},{key:"_initDOMEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this),this.on("click li",function(t){var n=(0,c.default)(t.target).closest("li");e._eventManager.emit("command",n.data("type"),n.data("value"))})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this._eventManager.listen("focus",this.hide.bind(this)),this._eventManager.listen("closeAllPopup",this.hide.bind(this)),this._eventManager.listen("openHeadingSelect",function(){e._eventManager.emit("closeAllPopup");var t=e._$button,n=t.position();e.$el.css({top:n.top+t.outerHeight(!0),left:n.left}),e.show()})}}]),t}(g.default);t.default=m},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n'+e+"")}),e=f.default.extend({header:!1,className:"te-popup-code-block-languages",content:n.join("")},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this._onSelectedLanguage=null,this._onDismissed=null,this._currentButton=null,this._$buttons=null,this._languages=e.languages,this.eventManager=e.eventManager}},{key:"_initDOM",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOM",this).call(this,e),this.$el.css("z-index",1e4),this._$buttons=this.$el.find("button"),this._activateButtonByIndex(0)}},{key:"_initDOMEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this);var n=function(t){var n=(0,c.default)(t.target).data("lang");e._onSelectedLanguage&&e._onSelectedLanguage(n),e.hide()};this._languages.forEach(function(t){return e.on("mousedown ."+v+t,n)})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this.eventManager.listen("openPopupCodeBlockLanguages",function(t){e.show(t.callback);var n=e.$el.get(0).style;return n.top=t.offset.top+"px",n.left=t.offset.left+"px",e.setCurrentLanguage(t.language),e}),this.eventManager.listen("focus",function(){return e.hide()}),this.eventManager.listen("mousedown",function(){return e.hide()}),this.eventManager.listen("closeAllPopup",function(){return e.hide()}),this.eventManager.listen("closePopupCodeBlockLanguages",function(){return e.hide()}),this.eventManager.listen("scroll",function(){return e.hide()})}},{key:"_activateButtonByIndex",value:function(e){this._currentButton&&(0,c.default)(this._currentButton).removeClass("active"),this._currentButton=this._$buttons.get(e),(0,c.default)(this._currentButton).addClass("active"),this._currentButton.scrollIntoView()}},{key:"prev",value:function(){var e=this._$buttons.index(this._currentButton)-1;e<0&&(e=this._$buttons.length-1),this._activateButtonByIndex(e)}},{key:"next",value:function(){var e=this._$buttons.index(this._currentButton)+1;e>=this._$buttons.length&&(e=0),this._activateButtonByIndex(e)}},{key:"getCurrentLanguage",value:function(){return(0,c.default)(this._currentButton).data("lang")}},{key:"setCurrentLanguage",value:function(e){var t=this._$buttons.filter("."+v+e);if(t.length>0){var n=this._$buttons.index(t);this._activateButtonByIndex(n)}}},{key:"show",value:function(e){this._onSelectedLanguage=e.selected,this._onDismissed=e.dismissed,s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"show",this).call(this)}},{key:"hide",value:function(){this._onDismissed&&this._onDismissed(),this._onSelectedLanguage=null,this._onDismissed=null,s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"hide",this).call(this)}}]),t}(g.default);t.default=p},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n\n \n \n \n',L=function(e){function t(e){a(this,t);var n='\n
    \n
    \n \n \n
    \n ";return e=f.default.extend({header:!0,title:"CodeBlock Editor",content:n,className:"tui-popup-code-block-editor",headerButtons:O,modal:!0},e),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),l(t,[{key:"_initInstance",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initInstance",this).call(this,e),this.eventManager=e.eventManager,this.convertor=e.convertor}},{key:"_initDOM",value:function(e){s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOM",this).call(this,e);var n=this.$el.get(0);this._body=n.querySelector("."+M+"body"),this._toggleFitButton=n.querySelector("."+M+"toggle-fit"),this._togglePreviewButton=n.querySelector("."+M+"toggle-preview"),this._toggleScrollButton=n.querySelector("."+M+"toggle-scroll"),this._okButton=n.querySelector("."+T),this._closeButton=n.querySelector("."+S),this._codeMirrorWrapper=this._createCodeBlockEditor(),this._previewWrapper=this._createPreview(),this._scrollSyncSplit=new p.default(this._body,this._codeMirrorWrapper,this._previewWrapper),this._updateFitWindowButton(),this._updatePreviewButton(),this._updateScrollButton(),this._codeBlockLanguagesCombo=this._createCodeBlockLanguagesCombo()}},{key:"_initDOMEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initDOMEvent",this).call(this),this.on("scroll",function(e){return e.preventDefault()}),this.on("click ."+M+"toggle-fit",function(){return e._toggleFitToWindow()}),this.on("click ."+M+"toggle-preview",function(){return e._togglePreview()}),this.on("click ."+M+"toggle-scroll",function(){return e._toggleScroll()}),this.on("click ."+T,function(){return e._save()}),this.on("click ."+S,function(){return e.hide()}),this.on("click ."+M+"close",function(){return e.hide()}),this.on("click ."+M+"editor-wrapper",function(t){t.target===e._codeMirrorWrapper&&e._focusEditor(!0)})}},{key:"_initEditorEvent",value:function(){var e=this;s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_initEditorEvent",this).call(this),this.eventManager.listen("openPopupCodeBlockEditor",function(t){return e.eventManager.emit("closeAllPopup"),e.show(t),e}),this.eventManager.listen("closeAllPopup",this.hide.bind(this)),this.eventManager.listen("closePopupCodeBlockEditor",this.hide.bind(this))}},{key:"_createCodeBlockEditor",value:function(){var e=document.createElement("div");return e.classList.add(M+"editor-wrapper"),this._codeBlockEditor=new y.default(e,this.eventManager),e}},{key:"_createPreview",value:function(){var e=document.createElement("div");return this._codeBlockPreview=new b.default((0,c.default)(e),this.eventManager,this.convertor,this._codeBlockEditor),e}},{key:"_createCodeBlockLanguagesCombo",value:function(){var e=this,t=this.getTitleElement(),n=new w.default(this.eventManager);return n.setOnLanguageSelected(function(t){e._codeBlockEditor.setLanguage(t),e._codeBlockEditor.refresh(),e._focusEditor()}),t.innerHTML="CodeBlock Editor",t.appendChild(n.getElement()),n}},{key:"_updateFitWindowButton",value:function(){(0,c.default)(this._toggleFitButton).toggleClass("active",this.isFitToWindow())}},{key:"_updatePreviewButton",value:function(){(0,c.default)(this._togglePreviewButton).toggleClass("active",this._scrollSyncSplit.isSplitView())}},{key:"_updateScrollButton",value:function(){this._scrollSyncSplit.isSplitView()?this._toggleScrollButton.style.display="inline-block":this._toggleScrollButton.style.display="none",(0,c.default)(this._toggleScrollButton).toggleClass("active",this._scrollSyncSplit.isScrollSynced())}},{key:"_focusEditor",value:function(e){this._codeBlockEditor.focus(),e?this._codeBlockEditor.moveCursorToEnd():this._codeBlockEditor.moveCursorToStart()}},{key:"_togglePreview",value:function(){this._scrollSyncSplit.toggleSplitView(),this._updatePreviewButton(),this._updateScrollButton(),this._codeBlockEditor.refresh()}},{key:"_toggleFitToWindow",value:function(){this.toggleFitToWindow(),this._updateFitWindowButton(),this._codeBlockEditor.refresh()}},{key:"_toggleScroll",value:function(){this._scrollSyncSplit.toggleScrollSync(),this._updateScrollButton()}},{key:"_save",value:function(){this._codeBlockEditor.save(this._codeBlockElement),this.hide()}},{key:"_load",value:function(e){this._codeBlockElement=e,this._codeBlockEditor.load(e),this._codeBlockLanguagesCombo.setLanguage(this._codeBlockEditor.getLanguage()),this._focusEditor(),this._codeBlockPreview.refresh()}},{key:"show",value:function(e){if(s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"show",this).call(this),!e)throw new Error("should be called with codeBlockElement");this._load(e)}},{key:"hide",value:function(){this.setFitToWindow(!1),this._codeBlockEditor&&this._codeBlockEditor.clear(),this._codeBlockPreview&&this._codeBlockPreview.clear(),this._codeBlockElement=null,s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"hide",this).call(this)}}]),t}(g.default);t.default=L},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:{};a(this,e),o=u.default.extend({showScrollSyncButton:!1,scrollSync:!0,splitView:!0},o),this._baseElement=t,this._contentElements=[],this._initDom(n,i,o),this._initDomEvent()}return o(e,[{key:"_initDom",value:function(e,t,n){var i=document.createElement("div");i.className="tui-split-scroll",this._el=i;var a=document.createElement("div");a.className="tui-split-scroll-wrapper",this._scrollWrapper=a,this._setScrollSync(n.scrollSync),this.setSplitView(n.splitView);var o=document.createElement("div");o.className="tui-split-scroll-content",this._contentWrapper=o;var r=document.createElement("div");r.className="tui-splitter",this._baseElement.appendChild(i),i.appendChild(a),a.appendChild(o),a.appendChild(r),this._setLeft(e),this._setRight(t)}},{key:"_initDomEvent",value:function(){this._contentWrapper.addEventListener("scroll",this.sync.bind(this))}},{key:"_requireScrollIntoView",value:function(e){var t=e.target,n=t.getBoundingClientRect(),i=n.top,a=n.bottom,o=void 0,r=void 0,s=void 0;if(this.isScrollSynced())s=this._contentWrapper;else if((0,l.default)(t).parents(this._contentElements.left).length)s=this._contentElements.left;else{if(!(0,l.default)(t).parents(this._contentElements.right).length)return;s=this._contentElements.right}var u=s.getBoundingClientRect();o=u.top,r=u.bottom,ir&&(s.scrollTop=s.scrollTop+a-r),this.sync()}},{key:"_setContentElement",value:function(e,t){var n=this,i=this._contentElements[t];i&&((0,l.default)(i).off("requireScrollIntoView"),this._contentWrapper.removeChild(i)),e.classList.add(c[t]),this._contentWrapper.appendChild(e),(0,l.default)(e).on("requireScrollIntoView",function(e){return n._requireScrollIntoView(e)}),(0,l.default)(e).on("requireScrollSync",function(){return n.sync()}),this._contentElements[t]=e,this.sync()}},{key:"_setLeft",value:function(e){this._setContentElement(e,"left")}},{key:"_setRight",value:function(e){this._setContentElement(e,"right")}},{key:"_setScrollSync",value:function(e){(0,l.default)(this._el).toggleClass("scroll-sync",e)}},{key:"toggleScrollSync",value:function(){this._el.classList.toggle("scroll-sync")}},{key:"setSplitView",value:function(e){(0,l.default)(this._el).toggleClass("single-content",!e)}},{key:"toggleSplitView",value:function(){this._el.classList.toggle("single-content")}},{key:"isScrollSynced",value:function(){return this._el.classList.contains("scroll-sync")}},{key:"isSplitView",value:function(){return!this._el.classList.contains("single-content")}},{key:"sync",value:function(){if(this._contentElements.left&&this._contentElements.right){var e=this._contentWrapper.clientHeight,t=this._contentWrapper.scrollTop,n=this._contentElements.left,i=this._contentElements.right,a=n.offsetHeight-e>0?n:i,o=a===n?i:n,r=a.offsetHeight,l=Math.max(r-e,0),s=Math.max(o.offsetHeight,e),u=r-s;a.style.top="0px",o.style.top=t/l*u+"px"}}},{key:"scrollTop",value:function(e){this._contentWrapper.scrollTop=e}}]),e}();t.default=d},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 r(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n0?document.createTextNode(t):document.createElement("br"),n.appendChild(i)}),e.setAttribute("data-language",this._language),(0,u.default)(e).trigger("language-changed")}},{key:"clear",value:function(){this.setLanguage(""),this.setEditorCodeText("")}},{key:"getLanguage",value:function(){return this._language}},{key:"setLanguage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._language=e}},{key:"getEditorCodeText",value:function(){return this.getValue()}},{key:"setEditorCodeText",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.setValue(e)}},{key:"refresh",value:function(){this.cm.refresh()}}]),t}(d.default);t.default=f},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 o(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)}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n').get(0),this._wrapper=(0,l.default)('').get(0),this._wrapper.appendChild(this._inputLanguage)}},{key:"_initDOMEvent",value:function(){var e=this;this._inputLanguage.addEventListener("keydown",function(t){return e._onKeyEvent(t)}),this._inputLanguage.addEventListener("focus",function(){return e._showPopupCodeBlockLanguages()}),this._inputLanguage.addEventListener("focusout",function(){return e._onFocusOut()}),this._wrapper.addEventListener("mousedown",function(t){t.target===e._wrapper&&(t.preventDefault(),e._toggleFocus())})}},{key:"_showPopupCodeBlockLanguages",value:function(){var e=this,t=this._inputLanguage.getBoundingClientRect();this._wrapper.classList.toggle("active",!0),this.active=!0,this._popupCodeBlockLanguages=this._eventManager.emitReduce("openPopupCodeBlockLanguages",{language:this._prevStoredLanguage,offset:{left:t.left,top:t.bottom},callback:{selected:function(t){return e._onLanguageSelectedFromList(t)},dismissed:function(){e._popupCodeBlockLanguages=null}}})}},{key:"_toggleFocus",value:function(){var e=this._inputLanguage;this._wrapper.classList.contains("active")?e.blur():e.focus()}},{key:"_onFocusOut",value:function(){this._wrapper.classList.toggle("active",!1),this._inputLanguage.value=this._prevStoredLanguage,this._hidePopupCodeBlockLanguages()}},{key:"_onKeyEvent",value:function(e){if(this._popupCodeBlockLanguages)switch(e.which){case d.default.keyCode("UP"):this._popupCodeBlockLanguages.prev(),e.preventDefault();break;case d.default.keyCode("DOWN"):this._popupCodeBlockLanguages.next(),e.preventDefault();break;case d.default.keyCode("ENTER"):case d.default.keyCode("TAB"):var t=this._popupCodeBlockLanguages.getCurrentLanguage();this._inputLanguage.value=t,this._storeInputLanguage(),e.preventDefault();break;default:this._popupCodeBlockLanguages.hide()}else e.which!==d.default.keyCode("ENTER")&&e.which!==d.default.keyCode("TAB")||(this._storeInputLanguage(),e.preventDefault())}},{key:"_onLanguageSelectedFromList",value:function(e){this._inputLanguage.value=e,this._storeInputLanguage()}},{key:"setOnLanguageSelected",value:function(e){this._onLanguageSelected=e}},{key:"_hidePopupCodeBlockLanguages",value:function(){this._eventManager.emit("closePopupCodeBlockLanguages")}},{key:"setLanguage",value:function(e){this._prevStoredLanguage=e,this._inputLanguage.value=e}},{key:"_storeInputLanguage",value:function(){var e=this._inputLanguage.value;this.setLanguage(e),this._onLanguageSelected&&this._onLanguageSelected(e),this._hidePopupCodeBlockLanguages()}},{key:"getElement",value:function(){return this._wrapper}}]),e}();t.default=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=/^[*_]{2,}[^*_]*[*_]{2,}$/,r=a.default.command("markdown",{name:"Bold",keyMap:["CTRL+B","META+B"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=n.getCursor(),a=n.getSelection(),o=!a;if(o&&i.ch>1){a=this.expendSelection(n,i)||a}var r=this.isNeedRemove(a),l=r?this.remove(a):this.append(a);n.replaceSelection(l,"around"),o&&!r&&this.setCursorToCenter(n,i),t.focus()},isNeedRemove:function(e){return o.test(e)},append:function(e){return"**"+e+"**"},remove:function(e){return e.substr(2,e.length-4)},expendSelection:function(e,t){var n=e.getSelection(),i=void 0,a={line:t.line,ch:t.ch-2},o={line:t.line,ch:t.ch+2};return e.setSelection(a,o),"****"===n||"____"===n?i=n:e.setSelection(t),i},setCursorToCenter:function(e,t){e.setCursor(t.line,t.ch+2)}});t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=/^[*_]{3,}[^*_]*[*_]{3,}$/,r=/^[*_][^*_]*[*_]$/,l=a.default.command("markdown",{name:"Italic",keyMap:["CTRL+I","META+I"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=n.getCursor(),a=n.getSelection(),o=!a,r=!1,l=void 0;o&&(i.ch>2&&(l=this.expendWithBoldSelection(n,i))&&(r="with"),"with"!==r&&i.ch>1&&(r=this.expendOnlyBoldSelection(n,i)),!r&&i.ch>0&&(this.expendSelection(n,i),a=l||a));var s=this.isNeedRemove(a),u=s?this.remove(a):this.append(a);n.replaceSelection(u,"around"),o&&this.setCursorToCenter(n,i,s),t.focus()},isNeedRemove:function(e){return r.test(e)||o.test(e)},append:function(e){return"_"+e+"_"},remove:function(e){return e.substr(1,e.length-2)},expendWithBoldSelection:function(e,t){var n=e.getSelection(),i=void 0,a={line:t.line,ch:t.ch-3},o={line:t.line,ch:t.ch+3};return e.setSelection(a,o),"******"===n||"______"===n?i=n:e.setSelection(t),i},expendOnlyBoldSelection:function(e,t){var n=e.getSelection(),i=!1,a={line:t.line,ch:t.ch-2},o={line:t.line,ch:t.ch+2};return e.setSelection(a,o),"****"!==n&&"____"!==n||(e.setSelection(t),i="only"),i},expendSelection:function(e,t){var n=e.getSelection(),i=void 0,a={line:t.line,ch:t.ch-2},o={line:t.line,ch:t.ch+2};return e.setSelection(a,o),"****"===n||"____"===n?i=n:e.setSelection(t),i},setCursorToCenter:function(e,t,n){var i=n?-1:1;e.setCursor(t.line,t.ch+i)}});t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=/^[~~](.*[\s\n]*.*)*[~~]$/,r=a.default.command("markdown",{name:"Strike",keyMap:["CTRL+S","META+S"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=n.getCursor(),a=n.getSelection(),o=this.hasStrikeSyntax(a),r=void 0;r=o?this.remove(a):this.append(a),n.replaceSelection(r,"around"),!a&&!o&&this.setCursorToCenter(n,i,o),t.focus()},hasStrikeSyntax:function(e){return o.test(e)},append:function(e){return"~~"+e+"~~"},remove:function(e){return e.substr(2,e.length-4)},setCursorToCenter:function(e,t,n){var i=n?-2:2;e.setCursor(t.line,t.ch+i)}});t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("markdown",{name:"Blockquote",keyMap:["CTRL+Q","META+Q"],exec:function(e){for(var t=e.getEditor(),n=t.getDoc(),i=e.getCurrentRange(),a={line:i.from.line,ch:0},o={line:i.to.line,ch:n.getLineHandle(i.to.line).text.length},r=n.getRange(a,o),l=r.split("\n"),s=l.length,u=0;u"+l[u];n.replaceRange(l.join("\n"),a,o),i.to.ch+=1,n.setCursor(i.to),t.focus()}});t.default=o},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=e.match(u),i="";do{i+="#",t-=1}while(t>0);if(n){e=e.split(n[0])[1]}return i+" "+e}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=i(o),l=n(2),s=i(l),u=/^#+\s/g,c=s.default.command("markdown",{name:"Heading",exec:function(e,t){var n=e.getEditor(),i=n.getDoc(),o=e.getCurrentRange(),l={line:o.from.line,ch:0},s={line:o.to.line,ch:i.getLineHandle(o.to.line).text.length},u=i.getLine(s.line).length,c=i.getRange(l,s),d=c.split("\n");r.default.forEachArray(d,function(e,n){d[n]=a(e,t)}),i.replaceRange(d.join("\n"),l,s),o.to.ch+=i.getLine(s.line).length-u,i.setSelection(l,o.to),n.focus()}});t.default=c},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=/^(#{1,6}| *((?:\*|-|\d\.)(?: \[[ xX]])?)) /;return e.replace(t,"")}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=i(o),l=n(2),s=i(l),u=s.default.command("markdown",{name:"Paragraph",exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=e.getCurrentRange(),o={line:i.from.line,ch:0},l={line:i.to.line,ch:n.getLineHandle(i.to.line).text.length},s=n.getLine(l.line).length,u=n.getRange(o,l),c=u.split("\n");r.default.forEachArray(c,function(e,t){c[t]=a(e)}),n.replaceRange(c.join("\n"),o,l),i.to.ch+=n.getLine(l.line).length-s,n.setSelection(o,l),t.focus()}});t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("markdown",{name:"HR",keyMap:["CTRL+L","META+L"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i="",a=e.getCurrentRange(),o={line:a.from.line,ch:a.from.ch},r={line:a.to.line,ch:a.to.ch};a.collapsed&&(i=n.getLine(o.line),o.ch=0,r.ch=n.getLineHandle(a.to.line).text.length),n.getLine(o.line).length?i+="\n\n* * *\n\n":i+="\n* * *\n",n.replaceRange(i,o,r),t.focus()}});t.default=o},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=i(a),r=n(18),l=i(r),s=l.default.decodeURIGraceful,u=l.default.encodeMarkdownCharacters,c=l.default.escapeMarkdownCharacters,d=o.default.command("markdown",{name:"AddLink",exec:function(e,t){var n=e.getEditor(),i=n.getDoc(),a=e.getCurrentRange(),o={line:a.from.line,ch:a.from.ch},r={line:a.to.line,ch:a.to.ch},l=t.linkText,d=t.url;l=s(l),l=c(l),d=u(d);var f="["+l+"]("+d+")";i.replaceRange(f,o,r),n.focus()}});t.default=d},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("markdown",{name:"AddImage",exec:function(e,t){var n=e.getEditor(),i=n.getDoc(),a=e.getCurrentRange(),o={line:a.from.line,ch:a.from.ch},r={line:a.to.line,ch:a.to.ch},l="!["+t.altText+"]("+t.imageUrl+")";i.replaceRange(l,o,r,"+addImage"),n.focus()}});t.default=o},function(e,t,n){"use strict";function i(e){return!(!e||!e.match(s)&&!e.match(r))}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=function(e){return e&&e.__esModule?e:{default:e}}(a),r=/^[ \t]*[\d]+\. .*/,l=/^[ \t]*[-*] .*/,s=/^[ \t]*[-*]( \[[ xX]])? .*/,u=o.default.command("markdown",{name:"UL",keyMap:["CTRL+U","META+U"],exec:function(e){for(var t=e.getEditor(),n=t.getDoc(),a=e.getCurrentRange(),o=e.componentManager.getManager("list"),r=o.expandLineRangeIfNeed(n,a,i),s=r.start,u=r.end,c=void 0,d=void 0,f=s;f<=u&&(d={line:f,ch:0},c=n.getLine(f),o.isListOrParagraph(c));f+=1)i(c)?o.replaceLineText(n,f,/[\d]+\. /,"* "):c.match(l)||n.replaceRange("* ",d),f===u&&o.appendBlankLineIfNeed(t,f,u,s);t.focus()}});t.default=u},function(e,t,n){"use strict";function i(e){return!(!e||!e.match(s)&&!e.match(l))}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=function(e){return e&&e.__esModule?e:{default:e}}(a),r=/^[ \t]*[\d]+\. .*/,l=/^[ \t]*[-*] .*/,s=/^[ \t]*[-*]( \[[ xX]])? .*/,u=o.default.command("markdown",{name:"OL",keyMap:["CTRL+O","META+O"],exec:function(e){for(var t=e.getEditor(),n=t.getDoc(),a=e.getCurrentRange(),o=e.componentManager.getManager("list"),l=o.expandLineRangeIfNeed(n,a,i),s=l.start,u=l.end,c=1,d=void 0,f=void 0,h=s;h<=u&&(f={line:h,ch:0},d=n.getLine(h),o.isListOrParagraph(d));h+=1)i(d)?o.replaceLineText(n,h,/[*-] /,c+". "):d.match(r)||n.replaceRange(c+". ",f),c+=1,h===u&&o.appendBlankLineIfNeed(t,h,u,s);t.focus()}});t.default=u},function(e,t,n){"use strict";function i(e,t){for(var n="|",i="|",a=0;e;)t?(n+=" "+t[a]+" |",a+=1):n+=" |",i+=" --- |",e-=1;return n+"\n"+i+"\n"}function a(e,t,n){for(var i="",a=e,o=0;o0&&(s+="\n"),s+=i(t,o),s+=a(t,n-1,o),l.replaceSelection(s),o||r.setCursor(r.getCursor().line-n,2),e.focus()}});t.default=l},function(e,t,n){"use strict";function i(e){return!(!e||!e.match(l)&&!e.match(r))}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=function(e){return e&&e.__esModule?e:{default:e}}(a),r=/^[ \t]*[\d]+\. .*/,l=/^[ \t]*[-*] .*/,s=/^[ \t]*[-*]( \[[ xX]])? .*/,u=/([*-] |[\d]+\. )(\[[ xX]] )/,c=o.default.command("markdown",{name:"Task",keyMap:["CTRL+T","META+T"],exec:function(e){for(var t=e.getEditor(),n=t.getDoc(),a=e.getCurrentRange(),o=e.componentManager.getManager("list"),r=o.createSortedLineRange(a),l=r.start,c=r.end,d=void 0,f=void 0,h=l;h<=c;h+=1){f={line:h,ch:0},d=n.getLine(h);var g=!!d.match(u);if(!o.isListOrParagraph(d))break;i(d)&&g?o.replaceLineText(n,h,u,"$1"):i(d)&&!g?o.replaceLineText(n,h,/([*-] |[\d]+\. )/,"$1[ ] "):d.match(s)||n.replaceRange("* [ ] ",f),h===c&&o.appendBlankLineIfNeed(t,h,c,l)}t.focus()}});t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("markdown",{name:"Code",keyMap:["SHIFT+CTRL+C","SHIFT+META+C"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=n.getSelection(),a=t.getCursor();n.replaceSelection(this.append(i),"around"),i||n.setCursor(a.line,a.ch+1),t.focus()},append:function(e){return"`"+e+"`"}});t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("markdown",{name:"CodeBlock",keyMap:["SHIFT+CTRL+P","SHIFT+META+P"],exec:function(e){var t=e.getEditor(),n=t.getDoc(),i=e.getCurrentRange(),a=["```",n.getSelection(),"```"],o=1;0!==i.from.ch&&(a.unshift(""),o+=1),i.to.ch!==n.getLine(i.to.line).length&&a.push(""),n.replaceSelection(a.join("\n")),t.setCursor(i.from.line+o,0),t.focus()}});t.default=o},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){e.hasFormat("b")||e.hasFormat("strong")?e.changeFormat(null,{tag:"b"}):e.hasFormat("a")||e.hasFormat("PRE")||(e.hasFormat("code")&&e.changeFormat(null,{tag:"code"}),e.bold())}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=i(o),l=n(3),s=i(l),u=r.default.command("wysiwyg",{name:"Bold",keyMap:["CTRL+B","META+B"],exec:function(e){var t=e.getEditor(),n=e.componentManager.getManager("tableSelection");e.focus(),t.hasFormat("table")&&n.getSelectedCells().length?n.styleToSelectedCells(a):a(t);var i=t.getSelection();t.hasFormat("table")&&!s.default.isTextNode(i.commonAncestorContainer)&&(i.collapse(!0),t.setSelection(i))}});t.default=u},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){e.hasFormat("i")||e.hasFormat("em")?e.changeFormat(null,{tag:"i"}):e.hasFormat("a")||e.hasFormat("PRE")||(e.hasFormat("code")&&e.changeFormat(null,{tag:"code"}),e.italic())}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=i(o),l=n(3),s=i(l),u=r.default.command("wysiwyg",{name:"Italic",keyMap:["CTRL+I","META+I"],exec:function(e){var t=e.getEditor(),n=t.getSelection(),i=e.componentManager.getManager("tableSelection");e.focus(),t.hasFormat("table")&&i.getSelectedCells().length?i.styleToSelectedCells(a):a(t),t.hasFormat("table")&&!s.default.isTextNode(n.commonAncestorContainer)&&(n.collapse(!0),t.setSelection(n))}});t.default=u},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){e.hasFormat("S")?e.changeFormat(null,{tag:"S"}):e.hasFormat("a")||e.hasFormat("PRE")||(e.hasFormat("code")&&e.changeFormat(null,{tag:"code"}),e.strikethrough())}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),r=i(o),l=n(3),s=i(l),u=r.default.command("wysiwyg",{name:"Strike",keyMap:["CTRL+S","META+S"],exec:function(e){var t=e.getEditor(),n=t.getSelection(),i=e.componentManager.getManager("tableSelection");e.focus(),t.hasFormat("table")&&i.getSelectedCells().length?i.styleToSelectedCells(a):a(t),t.hasFormat("table")&&!s.default.isTextNode(n.commonAncestorContainer)&&(n.collapse(!0),t.setSelection(n))}});t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("wysiwyg",{name:"Blockquote",keyMap:["CTRL+Q","META+Q"],exec:function(e){var t=e.getEditor();e.focus(),t.hasFormat("TABLE")||t.hasFormat("PRE")||(e.unwrapBlockTag(),t.increaseQuoteLevel())}});t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("wysiwyg",{name:"AddImage",exec:function(e,t){var n=e.getEditor();e.focus(),n.hasFormat("PRE")||n.insertImage(t.imageUrl,{alt:t.altText})}});t.default=o},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),o=i(a),r=n(2),l=i(r),s=n(18),u=i(s),c=u.default.decodeURIGraceful,d=u.default.encodeMarkdownCharacters,f=l.default.command("wysiwyg",{name:"AddLink",exec:function(e,t){var n=e.getEditor(),i=t.url,a=t.linkText;if(a=c(a),i=d(i),e.focus(),!n.hasFormat("PRE"))if(n.removeAllFormatting(),n.getSelectedText())n.makeLink(i);else{var r=n.createElement("A",{href:i});(0,o.default)(r).text(a),n.insertElement(r)}}});t.default=f},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=i(a),r=n(3),l=i(r),s=o.default.command("wysiwyg",{name:"HR",keyMap:["CTRL+L","META+L"],exec:function(e){var t=e.getEditor(),n=t.getSelection(),i=void 0,a=void 0,o=void 0;if(n.collapsed&&!t.hasFormat("TABLE")&&!t.hasFormat("PRE")){i=l.default.getChildNodeByOffset(n.startContainer,n.startOffset),a=l.default.getTopNextNodeUnder(i,e.get$Body()[0]),a||(a=t.createDefaultBlock(),e.get$Body().append(a));var r=t.createElement("HR");t.modifyBlocks(function(e){return e.appendChild(r),e}),o=r.previousSibling,o&&l.default.isTextNode(o)&&0===l.default.getTextLength(o)&&r.parentNode.removeChild(o),n.selectNodeContents(a),n.collapse(!0),t.setSelection(n)}e.focus()}});t.default=s},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),o=i(a),r=n(2),l=i(r),s=l.default.command("wysiwyg",{name:"Heading",exec:function(e,t){var n=e.getEditor();e.focus(),n.hasFormat("TABLE")||n.hasFormat("PRE")||n.modifyBlocks(function(e){return(0,o.default)(e).children("h1, h2, h3, h4, h5, h6, div").each(function(e,n){var i="",a=(0,o.default)(n);if(a.is("DIV"))a.wrap(i);else{var r=(0,o.default)(i);r.insertBefore(n),r.html(a.html()),a.remove()}}),e})}});t.default=s},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),o=i(a),r=n(2),l=i(r),s=l.default.command("wysiwyg",{name:"Paragraph",exec:function(e){var t=e.getEditor();e.focus(),t.hasFormat("TABLE")||t.hasFormat("PRE")||t.modifyBlocks(function(e){var t=(0,o.default)(document.createDocumentFragment());return(0,o.default)(e).children().each(function(e,n){n.nodeName.match(/h\d/i)?t.append((0,o.default)(n).children()):n.nodeName.match(/ul|ol/i)?(0,o.default)(n).find("li").each(function(e,n){t.append((0,o.default)(n).children())}):t.append(n)}),t[0]})}});t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),a=function(e){return e&&e.__esModule?e:{default:e}}(i),o=a.default.command("wysiwyg",{name:"UL",keyMap:["CTRL+U","META+U"],exec:function(e){var t=e.getEditor(),n=t.getSelection(),i=e.componentManager.getManager("list"),a=n,o=a.startContainer,r=a.endContainer,l=a.startOffset,s=a.endOffset;e.focus(),t.saveUndoState(n);for(var u=i.getLinesOfSelection(o,r),c=[],d=0;d",t&&(n+=t[i],i+=1),n+="",e-=1;return n+=""}function o(e,t,n){for(var i="",a=e,o=0;o";for(var r=0;r",n&&(i+=n[a],a+=1),i+="";i+=""}return i+=""}Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),l=function(e){return e&&e.__esModule?e:{default:e}}(r),s=l.default.command("wysiwyg",{name:"Table",exec:function(e,t,n,r){var l=e.getEditor(),s=e.componentManager.getManager("table").getTableIDClassName(),u=void 0;if(!l.getSelection().collapsed||l.hasFormat("TABLE")||l.hasFormat("PRE"))return void e.focus();u='',u+=a(t,r),u+=o(t,n-1,r),u+="
    ",l.insertHTML(u),e.focus(),r||i(l,e.get$Body().find("."+s))}});t.default=s},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.componentManager.getManager("tableSelection"),n=t.getSelectedCells(),i=1;if(n.length>1){var a=n.first().get(0),o=n.last().get(0),r=t.getSelectionRangeFromTable(a,o);i=r.to.row-r.from.row+1}return i}function o(e){var t=e.clone(),n=c.default.browser.msie?"":"
    ";return t.find("td").html(n),t}function r(e,t){var n=e.getSelection();n.selectNodeContents(t.find("td")[0]),n.collapse(!0),e.setSelection(n)}Object.defineProperty(t,"__esModule",{value:!0});var l=n(0),s=i(l),u=n(1),c=i(u),d=n(2),f=i(d),h=f.default.command("wysiwyg",{name:"AddRow",exec:function(e){var t=e.getEditor(),n=t.getSelection().cloneRange(),i=a(e),l=void 0,u=void 0;if(e.focus(),t.hasFormat("TD")){t.saveUndoState(n),l=(0,s.default)(n.startContainer).closest("tr");for(var c=0;c0){var a=n.get(0).parentNode.querySelectorAll("td, th").length;i=Math.min(a,n.length)}return i}function o(e){var t=e.startContainer;return t="TD"===v.default.getNodeName(t)||"TH"===v.default.getNodeName(t)?(0,u.default)(t):(0,u.default)(t).parentsUntil("tr")}function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e.index(),i=void 0;e.parents("table").find("tr").each(function(e,a){for(var o="TBODY"===v.default.getNodeName(a.parentNode),r=d.default.browser.msie,l=a.children[n],s=0;s1){t.saveUndoState(n);var d=u.last().next()[0]?u.last().next():u.first().prev();d.length&&a(t,n,d,l),u.remove()}o.removeClassAttrbuteFromAllCellsIfNeed()}});t.default=d},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=e.startContainer;return t="TD"===h.default.getNodeName(t)||"TH"===h.default.getNodeName(t)?(0,u.default)(t):(0,u.default)(t).parentsUntil("tr")}function o(e){for(var t=e.length,n=0;n0&&r(e.eq(n))}}function r(e){var t=e.index();e.parents("table").find("tr").each(function(e,n){(0,u.default)(n).children().eq(t).remove()})}function l(e,t,n){var i=t.get(0);if(t.length&&u.default.contains(document,t)){var a=e.getSelection();a.selectNodeContents(t[0]),a.collapse(!0),e.setSelection(a),n.setLastCellNode(i)}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),u=i(s),c=n(2),d=i(c),f=n(3),h=i(f),g=d.default.command("wysiwyg",{name:"RemoveCol",exec:function(e){var t=e.getEditor(),n=t.getSelection().cloneRange(),i=e.componentManager.getManager("table"),s=e.componentManager.getManager("tableSelection"),c=(0,u.default)(n.startContainer).closest("table").find("thead tr th").length>1;if(e.focus(),n.collapse(!0),t.setSelection(n),t.hasFormat("TR",null,n)&&c){t.saveUndoState(n);var d=void 0,f=void 0,h=s.getSelectedCells();if(h.length>1){var g=h.last(),v=h.first();d=g.next().length>0?g.next():v.prev(),o(h)}else f=a(n),d=f.next().length?f.next():f.prev(),r(f);l(t,d,i)}}});t.default=g},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n){var i=n.isDivided||!1,a=n.startColumnIndex,o=n.endColumnIndex,r=e.find("tr").eq(0).find("td,th").length;e.find("tr").each(function(e,n){(0,s.default)(n).children("td,th").each(function(e,n){i&&(a<=e&&e<=r||e<=o)?(0,s.default)(n).attr("align",t):a<=e&&e<=o&&(0,s.default)(n).attr("align",t)})})}function o(e,t){var n=e.find("tr").eq(0).find("td,th").length,i=t.from,a=t.to,o=void 0,r=void 0,l=void 0;return i.row===a.row?(o=i.cell,r=a.cell):i.row
    ")[0]]:(i=e.extractContents(),a=u.default.toArray(i.childNodes)),n.convertToCodeblock(a).innerHTML}Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),l=i(r),s=n(1),u=i(s),c=n(2),d=i(c),f=0,h=d.default.command("wysiwyg",{name:"CodeBlock",keyMap:["SHIFT+CTRL+P","SHIFT+META+P"],exec:function(e,t){var n=e.getEditor(),i=n.getSelection().cloneRange();if(!n.hasFormat("PRE")&&!n.hasFormat("TABLE")){var r='data-te-codeblock class = "te-content-codeblock-'+f+'"';t&&(r+=' data-language="'+t+'"');var l=o(i,e);n.insertHTML("
    "+l+"
    "),a(e.get$Body().find(".te-content-codeblock-"+f),e),f+=1}e.focus()}});t.default=h},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["en","en_US"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Write",Preview:"Preview",Headings:"Headings",Paragraph:"Paragraph",Bold:"Bold",Italic:"Italic",Strike:"Strike",Code:"Inline code",Line:"Line",Blockquote:"Blockquote","Unordered list":"Unordered list","Ordered list":"Ordered list",Task:"Task","Insert link":"Insert link","Insert CodeBlock":"Insert codeBlock","Insert table":"Insert table","Insert image":"Insert image",Heading:"Heading","Image URL":"Image URL","Select image file":"Select image file",Description:"Description",OK:"OK",Cancel:"Cancel",File:"File",URL:"URL","Link text":"Link text","Add row":"Add row","Add col":"Add col","Remove row":"Remove row","Remove col":"Remove col","Align left":"Align left","Align center":"Align center","Align right":"Align right","Remove table":"Remove table","Would you like to paste as table?":"Would you like to paste as table?","Text color":"Text color","Auto scroll enabled":"Auto scroll enabled","Auto scroll disabled":"Auto scroll disabled","Cannot paste values ​​other than a table in the cell selection state":"Cannot paste values ​​other than a table in the cell selection state.","Choose language":"Choose language"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["ko","ko_KR"],{Markdown:"마크다운",WYSIWYG:"위지윅",Write:"편집하기",Preview:"미리보기",Headings:"제목크기",Paragraph:"본문",Bold:"굵게",Italic:"기울임꼴",Strike:"취소선",Code:"인라인 코드",Line:"문단나눔",Blockquote:"인용구","Unordered list":"글머리 기호","Ordered list":"번호 매기기",Task:"체크박스","Insert link":"링크 삽입","Insert CodeBlock":"코드블럭 삽입","Insert table":"표 삽입","Insert image":"이미지 삽입",Heading:"제목","Image URL":"이미지 주소","Select image file":"이미지 파일을 선택하세요.",Description:"설명",OK:"확인",Cancel:"취소",File:"파일",URL:"주소","Link text":"링크 텍스트","Add row":"행 추가","Add col":"열 추가","Remove row":"행 삭제","Remove col":"열 삭제","Align left":"왼쪽 정렬","Align center":"가운데 정렬","Align right":"오른쪽 정렬","Remove table":"표 삭제","Would you like to paste as table?":"표형태로 붙여 넣겠습니까?","Text color":"글자 색상","Auto scroll enabled":"자동 스크롤 켜짐","Auto scroll disabled":"자동 스크롤 꺼짐","Cannot paste values ​​other than a table in the cell selection state.":"셀 선택 상태에서는 테이블 이외의 값은 붙여넣을 수 없습니다.","Choose language":"언어 선택"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["zh","zh_CN"],{Markdown:"Markdown",WYSIWYG:"所见即所得",Write:"编辑",Preview:"预览",Headings:"标题",Paragraph:"文本",Bold:"加粗",Italic:"斜体字",Strike:"删除线",Code:"内嵌代码",Line:"画水平线",Blockquote:"引用块","Unordered list":"无序列表","Ordered list":"有序列表",Task:"任务","Insert link":"插入链接","Insert CodeBlock":"插入代码块","Insert table":"插入表格","Insert image":"插入图片",Heading:"标题","Image URL":"图片网址","Select image file":"选择映像文件",Description:"说明",OK:"确认",Cancel:"取消",File:"文件",URL:"URL","Link text":"链接文本","Add row":"添加一行","Add col":"添加列","Remove row":"删除行","Remove col":"删除列","Align left":"左对齐","Align center":"居中对齐","Align right":"右对齐","Remove table":"删除表","Would you like to paste as table?":"你想粘贴表吗?","Text color":"文字色相","Auto scroll enabled":"自动滚动启用","Auto scroll disabled":"自动的滚动作非使用","Cannot paste values ​​other than a table in the cell selection state":"在单元格选择状态下无法粘贴表格以外的值。","Choose language":"选择语言"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["ja","ja_JP"],{Markdown:"マークダウン",WYSIWYG:"WYSIWYG",Write:"編集する",Preview:"プレビュー",Headings:"見出し",Paragraph:"本文",Bold:"太字",Italic:"イタリック",Strike:"ストライク",Code:"インラインコード",Line:"ライン",Blockquote:"引用","Unordered list":"番号なしリスト","Ordered list":"順序付きリスト",Task:"タスク","Insert link":"リンク挿入","Insert CodeBlock":"コードブロック挿入","Insert table":"テーブル挿入","Insert image":"画像挿入",Heading:"見出し","Image URL":"イメージURL","Select image file":"画像ファイル選択",Description:"ディスクリプション ",OK:"はい",Cancel:"キャンセル",File:"ファイル",URL:"URL","Link text":"リンクテキスト","Add row":"行追加","Add col":"列追加","Remove row":"行削除","Remove col":"列削除","Align left":"左揃え","Align center":"中央揃え","Align right":"右揃え","Remove table":"テーブル削除","Would you like to paste as table?":"テーブルを貼り付けますか?","Text color":"文字色相","Auto scroll enabled":"自動スクロールが有効","Auto scroll disabled":"自動スクロールを無効に","Cannot paste values ​​other than a table in the cell selection state":"表以外の値をセル選択状態に貼り付けることはできません。","Choose language":"言語選択"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["nl","nl_NL"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Write",Preview:"Preview",Headings:"Koppen",Paragraph:"tekst",Bold:"Vet",Italic:"Cursief",Strike:"Doorhalen",Code:"Inline Code",Line:"Regel",Blockquote:"Citaatblok","Unordered list":"Opsomming","Ordered list":"Genummerde opsomming",Task:"Taak","Insert link":"Link invoegen","Insert CodeBlock":"Codeblok toevoegen","Insert table":"Tabel invoegen","Insert image":"Afbeelding invoegen",Heading:"Kop","Image URL":"Afbeelding URL","Select image file":"Selecteer een afbeelding",Description:"Omschrijving",OK:"OK",Cancel:"Annuleren",File:"Bestand",URL:"URL","Link text":"Link tekst","Add row":"Rij toevoegen","Add col":"Kolom toevoegen","Remove row":"Rij verwijderen","Remove col":"Kolom verwijderen","Align left":"Links uitlijnen","Align center":"Centreren","Align right":"Rechts uitlijnen","Remove table":"Verwijder tabel","Would you like to paste as table?":"Wil je dit als tabel plakken?","Text color":"Tekstkleur","Auto scroll enabled":"Autoscroll ingeschakeld","Auto scroll disabled":"Autoscroll uitgeschakeld","Cannot paste values ​​other than a table in the cell selection state":"Kan geen waardes anders dan de tabel in de cell plakken","Choose language":"Kies een taal"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["es","es_ES"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Escribir",Preview:"Vista previa",Headings:"Encabezados",Paragraph:"Párrafo",Bold:"Negrita",Italic:"Itálica",Strike:"Tachado",Code:"Código",Line:"Línea",Blockquote:"Cita","Unordered list":"Lista desordenada","Ordered list":"Lista ordenada",Task:"Tarea","Insert link":"Insertar enlace","Insert CodeBlock":"Insertar bloque de código","Insert table":"Insertar tabla","Insert image":"Insertar imagen",Heading:"Encabezado","Image URL":"URL de la imagen","Select image file":"Seleccionar archivo de imagen",Description:"Descripción",OK:"Aceptar",Cancel:"Cancelar",File:"Archivo",URL:"URL","Link text":"Texto del enlace","Add row":"Agregar fila","Add col":"Agregar columna","Remove row":"Eliminar fila","Remove col":"Eliminar columna","Align left":"Alinear a la izquierda","Align center":"Centrar","Align right":"Alinear a la derecha","Remove table":"Eliminar tabla","Would you like to paste as table?":"¿Desea pegar como tabla?","Text color":"Color del texto","Auto scroll enabled":"Desplazamiento automático habilitado","Auto scroll disabled":"Desplazamiento automático deshabilitado","Cannot paste values ​​other than a table in the cell selection state":"Sólo se pueden pegar tablas en el modo de selección de celdas","Choose language":"Elegir idioma"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["de","de_DE"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Verfassen",Preview:"Vorschau",Headings:"Überschriften",Paragraph:"Text",Bold:"Fett",Italic:"Kursiv",Strike:"Durchgestrichen",Code:"Code",Line:"Trennlinie",Blockquote:"Blocktext","Unordered list":"Aufzählung","Ordered list":"Nummerierte Aufzählung",Task:"Aufgabe","Insert link":"Link einfügen","Insert CodeBlock":"Codeblock einfügen","Insert table":"Tabelle einfügen","Insert image":"Grafik einfügen",Heading:"Titel","Image URL":"Bild URL","Select image file":"Grafik auswählen",Description:"Beschreibung",OK:"OK",Cancel:"Abbrechen",File:"Datei",URL:"URL","Link text":"Anzuzeigender Text","Add row":"Zeile hinzufügen","Add col":"Spalte hinzufügen","Remove row":"Zeile entfernen","Remove col":"Spalte entfernen","Align left":"Links ausrichten","Align center":"Zentrieren","Align right":"Rechts ausrichten","Remove table":"Tabelle entfernen","Would you like to paste as table?":"Möchten Sie eine Tabelle einfügen?","Text color":"Textfarbe","Auto scroll enabled":"Autoscrollen aktiviert","Auto scroll disabled":"Autoscrollen deaktiviert","Cannot paste values ​​other than a table in the cell selection state":"Im Zellenauswahlstatus können keine anderen Werte als eine Tabelle eingefügt werden","Choose language":"Sprache auswählen"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["ru","ru_RU"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Написать",Preview:"Предварительный просмотр",Headings:"Заголовки",Paragraph:"Абзац",Bold:"Жирный",Italic:"Курсив",Strike:"Зачеркнутый",Code:"Встроенный код",Line:"Строка",Blockquote:"Блок цитирования","Unordered list":"Неупорядоченный список","Ordered list":"Упорядоченный список",Task:"Задача","Insert link":"Вставить ссылку","Insert CodeBlock":"Вставить код","Insert table":"Вставить таблицу","Insert image":"Вставить изображение",Heading:"Заголовок","Image URL":"URL изображения","Select image file":"Выбрать файл изображения",Description:"Описание",OK:"Хорошо",Cancel:"Отмена",File:"Файл",URL:"URL","Link text":"Текст ссылки","Add row":"Добавить ряд","Add col":"Добавить столбец","Remove row":"Удалить ряд","Remove col":"Удалить столбец","Align left":"Выровнять по левому краю","Align center":"Выровнять по центру","Align right":"Выровнять по правому краю","Remove table":"Удалить таблицу","Would you like to paste as table?":"Вы хотите вставить в виде таблицы?","Text color":"Цвет текста","Auto scroll enabled":"Автоматическая прокрутка включена","Auto scroll disabled":"Автоматическая прокрутка отключена","Cannot paste values ​​other than a table in the cell selection state":"Вы не можете вставлять значения, отличные от таблицы, в состоянии выбора ячейки.","Choose language":"Выбрать язык"})},function(e,t,n){"use strict";var i=n(4);(function(e){return e&&e.__esModule?e:{default:e}})(i).default.setLanguage(["fr","fr_FR"],{Markdown:"Markdown",WYSIWYG:"WYSIWYG",Write:"Écrire",Preview:"Aperçu",Headings:"En-têtes",Paragraph:"Paragraphe",Bold:"Gras",Italic:"Italique",Strike:"Barré",Code:"Code en ligne",Line:"Ligne",Blockquote:"Citation","Unordered list":"Liste non-ordonnée","Ordered list":"Liste ordonnée",Task:"Tâche","Insert link":"Insérer un lien","Insert CodeBlock":"Insérer un bloc de code","Insert table":"Insérer un tableau","Insert image":"Insérer une image",Heading:"En-tête","Image URL":"URL de l'image","Select image file":"Sélectionnez un fichier image",Description:"Description",OK:"OK",Cancel:"Annuler",File:"Fichier",URL:"URL","Link text":"Texte du lien","Add row":"Ajouter une ligne","Add col":"Ajouter une colonne","Remove row":"Supprimer une ligne","Remove col":"Supprimer une colonne","Align left":"Aligner à gauche","Align center":"Aligner au centre","Align right":"Aligner à droite","Remove table":"Supprimer le tableau","Would you like to paste as table?":"Voulez-vous coller ce contenu en tant que tableau ?","Text color":"Couleur du texte","Auto scroll enabled":"Défilement automatique activé","Auto scroll disabled":"Défilement automatique désactivé","Cannot paste values ​​other than a table in the cell selection state":"Impossible de coller autre chose qu'un tableau dans la sélection de la cellule.","Choose language":"Choix de la langue"})}])});