diff --git a/dist/tui-editor.js b/dist/tui-editor.js index 318ddf2349..5f2cc1c401 100644 --- a/dist/tui-editor.js +++ b/dist/tui-editor.js @@ -1499,6 +1499,12 @@ var getOffsetLength = function(node) { return len; }; +/** + * getNodeOffsetOfParent + * get node offset between parent's childnodes + * @param {Node} node node + * @return {number} offset(index) + */ var getNodeOffsetOfParent = function(node) { var i, t, childNodesOfParent = node.parentNode.childNodes; @@ -1510,8 +1516,35 @@ var getNodeOffsetOfParent = function(node) { } }; +/** + * getChildNodeByOffset + * get child node by offset + * @param {Node} node node + * @param {number} index offset index + * @return {Node} foudned node + */ +var getChildNodeByOffset = function(node, index) { + var currentNode; + + if (isTextNode(node)) { + currentNode = node; + } else { + currentNode = node.childNodes[index]; + } + + return currentNode; +}; -var _getNodeWithDirectionUntil = function(direction, node, untilNodeName) { +/** + * getNodeWithDirectionUntil + * find next node from passed node + * 노드의 다음 노드를 찾는다 sibling노드가 없으면 부모레벨까지 올라가서 찾는다. + * @param {strong} direction previous or next + * @param {Node} node node + * @param {string} untilNodeName parent node name to limit + * @return {Node} founded node + */ +var getNodeWithDirectionUntil = function(direction, node, untilNodeName) { var directionKey = direction + 'Sibling', nodeName, foundedNode; @@ -1535,34 +1568,27 @@ var _getNodeWithDirectionUntil = function(direction, node, untilNodeName) { return foundedNode; }; +/** + * getPrevOffsetNodeUntil + * get prev node of childnode pointed with index + * 인덱스에 해당하는 차일드 노드의 이전 노드를 찾는다. + * @param {Node} node node + * @param {number} index offset index + * @param {string} untilNodeName parent node name to limit + * @return {Node} founded node + */ var getPrevOffsetNodeUntil = function(node, index, untilNodeName) { var prevNode; if (index > 0) { - if (isTextNode(node)) { - prevNode = node; - } else { - prevNode = node.childNodes[index - 1]; - } + prevNode = getChildNodeByOffset(node, index - 1); } else { - prevNode = _getNodeWithDirectionUntil('previous', node, untilNodeName); + prevNode = getNodeWithDirectionUntil('previous', node, untilNodeName); } return prevNode; }; -var getNodeByOffset = function(node, index) { - var currentNode; - - if (isTextNode(node)) { - currentNode = node; - } else { - currentNode = node.childNodes[index]; - } - - return currentNode; -}; - module.exports = { getChildNodeAt: getChildNodeAt, getNodeName: getNodeName, @@ -1572,7 +1598,7 @@ module.exports = { getOffsetLength: getOffsetLength, getPrevOffsetNodeUntil: getPrevOffsetNodeUntil, getNodeOffsetOfParent: getNodeOffsetOfParent, - getNodeByOffset: getNodeByOffset + getChildNodeByOffset: getChildNodeByOffset }; },{}],9:[function(require,module,exports){ @@ -7910,7 +7936,7 @@ WysiwygEditor.prototype._initSquireEvent = function() { var sel = self.editor.getSelection(), eventObj; - if (!this._silentChange) { + if (!self._silentChange) { eventObj = { source: 'wysiwyg', selection: sel, @@ -7922,7 +7948,7 @@ WysiwygEditor.prototype._initSquireEvent = function() { self.eventManager.emit('change', eventObj); self.eventManager.emit('contentChangedFromWysiwyg', self); } else { - this._silentChange = false; + self._silentChange = false; } self._autoResizeHeightIfNeed(); diff --git a/dist/tui-editor.min.js b/dist/tui-editor.min.js index 3eff59bb9a..a9bc13be44 100644 --- a/dist/tui-editor.min.js +++ b/dist/tui-editor.min.js @@ -1,5 +1,5 @@ !function t(e,n,o){function i(a,s){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(r)return r(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[a]={exports:{}};e[a][0].call(d.exports,function(t){var n=e[a][1][t];return i(n?n:t)},d,d.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;ae)return t+"";for(;e-1>o;o+=1)n+="0";return(n+t).slice(-1*e)},isValidRGB:function(t){return o.test(t)},hexToRGB:function(t){var e,n,o;return i.isValidRGB(t)?(t=t.substring(1),e=parseInt(t.substr(0,2),16),n=parseInt(t.substr(2,2),16),o=parseInt(t.substr(4,2),16),[e,n,o]):!1},rgbToHEX:function(t,e,n){var o="#"+i.leadingZero(t.toString(16),2)+i.leadingZero(e.toString(16),2)+i.leadingZero(n.toString(16),2);return i.isValidRGB(o)?o:!1},rgbToHSV:function(t,e,n){var o,i,r,a,s,l;if(t/=255,e/=255,n/=255,o=Math.max(t,e,n),i=Math.min(t,e,n),s=o,l=o-i,a=0===o?0:l/o,o===i)r=0;else{switch(o){case t:r=(e-n)/l+(n>e?6:0);break;case e:r=(n-t)/l+2;break;case n:r=(t-e)/l+4}r/=6}return[Math.round(360*r),Math.round(100*a),Math.round(100*s)]},hsvToRGB:function(t,e,n){var o,i,r,a,s,l,c,d;if(t=Math.max(0,Math.min(360,t)),e=Math.max(0,Math.min(100,e)),n=Math.max(0,Math.min(100,n)),e/=100,n/=100,0===e)return o=i=r=n,[Math.round(255*o),Math.round(255*i),Math.round(255*r)];switch(t/=60,a=Math.floor(t),s=t-a,l=n*(1-e),c=n*(1-e*s),d=n*(1-e*(1-s)),a){case 0:o=n,i=d,r=l;break;case 1:o=c,i=n,r=l;break;case 2:o=l,i=n,r=d;break;case 3:o=l,i=c,r=n;break;case 4:o=d,i=l,r=n;break;default:o=n,i=l,r=c}return[Math.round(255*o),Math.round(255*i),Math.round(255*r)]}};e.exports=i},{}],3:[function(t,e,n){(function(t){"use strict";function n(t){this.items={},this.length=0,a(t)&&(this.getItemID=t)}var o=t.tui.util,i=o.forEachOwnProperties,r=o.forEachArray,a=o.isFunction,s=o.isObject,l=Array.prototype.slice;n.and=function(t){var e;return t=l.call(arguments),e=t.length,function(n){for(var o=0;e>o;o+=1)if(!t[o].call(null,n))return!1;return!0}},n.or=function(t){var e;return t=l.call(arguments),e=t.length,function(n){for(var o=1,i=t[0].call(null,n);e>o;o+=1)i=i||t[o].call(null,n);return i}},n.merge=function(t){var e=l.call(arguments),i={},a=new n(e[0].getItemID),s=o.extend;return r(e,function(t){s(i,t.items)}),a.items=i,a.length=o.keys(a.items).length,a},n.prototype.getItemID=function(t){return t._id+""},n.prototype.add=function(t){var e,n;return arguments.length>1?void r(l.call(arguments),function(t){this.add(t)},this):(e=this.getItemID(t),n=this.items,n[e]||(this.length+=1),void(n[e]=t))},n.prototype.remove=function(t){var e,n,i=[];return this.length?arguments.length>1?i=o.map(l.call(arguments),function(t){return this.remove(t)},this):(e=this.items,s(t)&&(t=this.getItemID(t)),e[t]?(this.length-=1,n=e[t],delete e[t],n):i):i},n.prototype.clear=function(){this.items={},this.length=0},n.prototype.has=function(t){var e,n;return this.length?(e=a(t),n=!1,e?this.each(function(e){return t(e)===!0?(n=!0,!1):void 0}):(t=s(t)?this.getItemID(t):t,n=o.isExisty(this.items[t])),n):!1},n.prototype.doWhenHas=function(t,e,n){var i=this.items[t];o.isExisty(i)&&e.call(n||this,i)},n.prototype.find=function(t){var e=new n;return this.hasOwnProperty("getItemID")&&(e.getItemID=this.getItemID),this.each(function(n){t(n)===!0&&e.add(n)}),e},n.prototype.groupBy=function(t,e){var i,r,a={},s=o.isFunction,l=s(t),c=this.getItemID;if(o.isArray(t)){if(o.forEachArray(t,function(t){a[t+""]=new n(c)}),!e)return a;t=e,l=!0}return this.each(function(e){l?r=t(e):(r=e[t],s(r)&&(r=r.apply(e))),i=a[r],i||(i=a[r]=new n(c)),i.add(e)}),a},n.prototype.single=function(){var t;return this.each(function(e){return t=e,!1},this),t},n.prototype.sort=function(t){var e=[];return this.each(function(t){e.push(t)}),a(t)&&(e=e.sort(t)),e},n.prototype.each=function(t,e){i(this.items,t,e||this)},n.prototype.toArray=function(){return this.length?o.map(this.items,function(t){return t}):[]},e.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,n){(function(t){"use strict";var n=t.tui.util,o=n.browser,i="_evt",r={START:["touchstart","mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},a={on:function(t,e,o,i){return n.isString(e)?void n.forEach(e.split(" "),function(e){a._on(t,e,o,i)}):void n.forEachOwnProperties(e,function(e,n){a._on(t,n,e,o)})},_on:function(t,e,o,r){var s,l,c;s=e+n.stamp(o)+(r?"_"+n.stamp(r):""),t[i]&&t[i][s]||(l=function(e){o.call(r||t,e||window.event)},c=l,"addEventListener"in t?"mouseenter"===e||"mouseleave"===e?(l=function(e){e=e||window.event,a._checkMouse(t,e)&&c(e)},t.addEventListener("mouseenter"===e?"mouseover":"mouseout",l,!1)):("mousewheel"===e&&t.addEventListener("DOMMouseScroll",l,!1),t.addEventListener(e,l,!1)):"attachEvent"in t&&t.attachEvent("on"+e,l),t[i]=t[i]||{},t[i][s]=l)},off:function(t,e,o,i){return n.isString(e)?void n.forEach(e.split(" "),function(e){a._off(t,e,o,i)}):void n.forEachOwnProperties(e,function(e,n){a._off(t,n,e,o)})},_off:function(t,e,o,r){var a=e+n.stamp(o)+(r?"_"+n.stamp(r):""),s=t[i]&&t[i][a];if(s){if("removeEventListener"in t)"mouseenter"===e||"mouseleave"===e?t.removeEventListener("mouseenter"===e?"mouseover":"mouseout",s,!1):("mousewheel"===e&&t.removeEventListener("DOMMouseScroll",s,!1),t.removeEventListener(e,s,!1));else if("detachEvent"in t)try{t.detachEvent("on"+e,s)}catch(l){}if(delete t[i][a],!n.keys(t[i]).length)return n.browser.msie&&n.browser.version<9?void(t[i]=null):void delete t[i]}},once:function(t,e,o,i){function r(){o.apply(i||t,arguments),s._off(t,e,r,i)}var s=this;return n.isObject(e)?void n.forEachOwnProperties(e,function(e,n){a.once(t,n,e,o)}):void a.on(t,e,r,i)},stopPropagation:function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0},preventDefault:function(t){t.preventDefault?t.preventDefault():t.returnValue=!1},stop:function(t){a.preventDefault(t),a.stopPropagation(t)},disableScrollPropagation:function(t){a.on(t,"mousewheel MozMousePixelScroll",a.stopPropagation)},disableClickPropagation:function(t){a.on(t,r.START.join(" ")+" click dblclick",a.stopPropagation)},getMousePosition:function(t,e){var n;return e?(n=e.getBoundingClientRect(),[t.clientX-n.left-e.clientLeft,t.clientY-n.top-e.clientTop]):[t.clientX,t.clientY]},getWheelDelta:function(t){var e=0;return t.wheelDelta&&(e=t.wheelDelta/120),t.detail&&(e=-t.detail/3),e},_checkMouse:function(t,e){var n=e.relatedTarget;if(!n)return!0;try{for(;n&&n!==t;)n=n.parentNode}catch(o){return!1}return n!==t},trigger:function(t,e,o){var i=/(mouse|click)/;n.isUndefined(o)&&i.exec(e)&&(o=a.mouseEvent(e)),t.dispatchEvent?t.dispatchEvent(o):t.fireEvent&&t.fireEvent("on"+e,o)},mouseEvent:function(t,e){var i,r;return r=n.extend({bubbles:!0,cancelable:"mousemove"!==t,view:window,wheelDelta:0,detail:0,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:void 0},e),o.msie&&o.version<9&&delete r.wheelDelta,"function"==typeof document.createEvent?(i=document.createEvent("MouseEvents"),i.initMouseEvent(t,r.bubbles,r.cancelable,r.view,r.detail,r.screenX,r.screenY,r.clientX,r.clientY,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.button,document.body.parentNode)):document.createEventObject&&(i=document.createEventObject(),n.forEach(r,function(t,e){i[e]=t},this),i.button={0:1,1:4,2:2}[i.button]||i.button),i},getMouseButton:function(t){var e,n="0,1,3,5,7",o="2,6",i="4";return document.implementation.hasFeature("MouseEvents","2.0")?t.button:(e=t.button+"",~n.indexOf(e)?0:~o.indexOf(e)?2:~i.indexOf(e)?1:void 0)}};e.exports=a}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(t,e,n){(function(n){"use strict";function o(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}var i,r=t("./domevent"),a=t("./collection"),s=n.tui.util,l="_pos",c=/^auto$|^$|%/;i={appendHTMLElement:function(t,e,n){var o;return n=n||"",o=document.createElement(t),o.className=n,e?e.appendChild(o):document.body.appendChild(o),o},remove:function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},get:function(t){return document.getElementById(t)},_matcher:function(t,e){var n=/^\./,o=/^#/;return n.test(e)?i.hasClass(t,e.replace(".","")):o.test(e)?t.id===e.replace("#",""):t.nodeName.toLowerCase()===e.toLowerCase()},find:function(t,e,n){function o(t,e){for(var s,d=t.childNodes,u=0,h=d.length;h>u;u+=1)if(s=d[u],"#text"!==s.nodeName)if(i._matcher(s,e)){if((c&&n(s)||!c)&&r.push(s),l){a=!0;break}}else if(s.childNodes.length>0&&(o(s,e),a))break}var r=[],a=!1,l=s.isUndefined(n)||n===!1,c=s.isFunction(n);return s.isString(e)&&(e=i.get(e)),e=e||window.document.body,o(e,t),l?r[0]||null:r},closest:function(t,e){var n=t.parentNode;if(i._matcher(t,e))return t;for(;n&&n!==window.document.body;){if(i._matcher(n,e))return n;n=n.parentNode}},text:function(t){var e="",n=0,o=t.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)e+=i.text(t)}else if(3===o||4===o)return t.nodeValue}else for(;t[n];n+=1)e+=i.text(t[n]);return e},setData:function(t,e,n){return"dataset"in t?void(t.dataset[e]=n):void t.setAttribute("data-"+e,n)},getData:function(t,e){return"dataset"in t?t.dataset[e]:t.getAttribute("data-"+e)},hasClass:function(t,e){var n;return s.isUndefined(t.classList)?(n=i.getClass(t),n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)):t.classList.contains(e)},addClass:function(t,e){var n;s.isUndefined(t.classList)?i.hasClass(t,e)||(n=i.getClass(t),i.setClass(t,(n?n+" ":"")+e)):s.forEachArray(e.split(" "),function(e){t.classList.add(e)})},setClass:function(t,e){s.isUndefined(t.className.baseVal)?t.className=e:t.className.baseVal=e},removeClass:function(t,e){var n="";s.isUndefined(t.classList)?(n=(" "+i.getClass(t)+" ").replace(" "+e+" "," "),i.setClass(t,o(n))):t.classList.remove(e)},getClass:function(t){return t&&t.className?s.isUndefined(t.className.baseVal)?t.className:t.className.baseVal:""},getStyle:function(t,e){var n,o=t.style[e]||t.currentStyle&&t.currentStyle[e];return o&&"auto"!==o||!document.defaultView||(n=document.defaultView.getComputedStyle(t,null),o=n?n[e]:null),"auto"===o?null:o},getComputedStyle:function(t){var e=document.defaultView;return e&&e.getComputedStyle?document.defaultView.getComputedStyle(t):{getPropertyValue:function(e){var n=/(\-([a-z]){1})/g;return"float"===e&&(e="styleFloat"),n.test(e)&&(e=e.replace(n,function(){return arguments[2].toUpperCase()})),t.currentStyle[e]?t.currentStyle[e]:null}}},setPosition:function(t,e,n){e=s.isUndefined(e)?0:e,n=s.isUndefined(n)?0:n,t[l]=[e,n],t.style.left=e+"px",t.style.top=n+"px"},getPosition:function(t,e){var n,o,i;return e&&(t[l]=null),t[l]?t[l]:(n=0,o=0,(c.test(t.style.left)||c.test(t.style.top))&&"getBoundingClientRect"in t?(i=t.getBoundingClientRect(),n=i.left,o=i.top):(n=parseFloat(t.style.left||0),o=parseFloat(t.style.top||0)),[n,o])},getSize:function(t){var e,n=i.getStyle(t,"width"),o=i.getStyle(t,"height");return(c.test(n)||c.test(o))&&"getBoundingClientRect"in t?(e=t.getBoundingClientRect(),n=e.width,o=e.height):(n=parseFloat(n||0),o=parseFloat(o||0)),[n,o]},testProp:function(t){for(var e=document.documentElement.style,n=0,o=t.length;o>n;n+=1)if(t[n]in e)return t[n];return!1},getFormData:function(t){var e=new a(function(){return this.length}),n=function(t){return!t.disabled},o={};return e.add.apply(e,i.find("input",t,n).concat(i.find("select",t,n)).concat(i.find("textarea",t,n))),e=e.groupBy(function(t){return t&&t.getAttribute("name")||"_other"}),s.forEach(e,function(t,e){"_other"!==e&&t.each(function(n){var r=n.nodeName.toLowerCase(),a=n.type,l=[];"radio"===a?l=[t.find(function(t){return t.checked}).toArray().pop()]:"checkbox"===a?l=t.find(function(t){return t.checked}).toArray():"select"===r?t.find(function(t){return!!t.childNodes.length}).each(function(t){l=l.concat(i.find("option",t,function(t){return t.selected}))}):l=t.find(function(t){return""!==t.value}).toArray(),l=s.map(l,function(t){return t.value}),l.length?1===l.length&&(l=l[0]):l="",o[e]=l})}),o}};var d=i.testProp(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]),u="onselectstart"in document,h="";i.disableTextSelection=function(){return u?function(){r.on(window,"selectstart",r.preventDefault)}:function(){var t=document.documentElement.style;h=t[d],t[d]="none"}}(),i.enableTextSelection=function(){return u?function(){r.off(window,"selectstart",r.preventDefault)}:function(){document.documentElement.style[d]=h}}(),i.disableImageDrag=function(){r.on(window,"dragstart",r.preventDefault)},i.enableImageDrag=function(){r.off(window,"dragstart",r.preventDefault)},e.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./collection":3,"./domevent":4}],6:[function(t,e,n){(function(n){"use strict";function o(t,e){a.on(e,"mousedown",this._onMouseDown,this),this.options=i.extend({distance:10},t),this.container=e,this._isMoved=!1,this._distance=0,this._dragStartFired=!1,this._dragStartEventData=null}var i=n.tui.util,r=t("./domutil"),a=t("./domevent");o.prototype.destroy=function(){a.off(this.container,"mousedown",this._onMouseDown,this),this.options=this.container=this._isMoved=this._distance=this._dragStartFired=this._dragStartEventData=null},o.prototype._toggleDragEvent=function(t){var e,o,i=this.container;t?(e="on",o="disable"):(e="off",o="enable"),r[o+"TextSelection"](i),r[o+"ImageDrag"](i),a[e](n.document,{mousemove:this._onMouseMove,mouseup:this._onMouseUp},this)},o.prototype._getEventData=function(t){return{target:t.target||t.srcElement,originEvent:t}},o.prototype._onMouseDown=function(t){0===a.getMouseButton(t)&&(this._distance=0,this._dragStartFired=!1,this._dragStartEventData=this._getEventData(t),this._toggleDragEvent(!0))},o.prototype._onMouseMove=function(t){var e=this.options.distance;return a.preventDefault(t),this._isMoved=!0,this._distance50?"white":"black",s.setStrokeColor(i,o),n||this.fire("_selectColor",{color:l.rgbToHEX.apply(null,this.getRGB())})},o.prototype.moveSaturationAndValue=function(t,e,n){var o,i,r,a;t=t||0,e=e||0,o=Math.abs(h[0]),i=h[1],r=t*i/100-o,a=i-e*i/100-o,this._moveColorSliderHandle(r,a,n)},o.prototype._moveColorSliderByPosition=function(t,e){var n=h[0];this._moveColorSliderHandle(t+n,e+n)},o.prototype.getSaturationAndValue=function(){var t,e,n=Math.abs(h[0]),o=n+h[1],i=s.getTranslateXY(this.sliderHandleElement);return t=(i[1]+n)/o*100,e=100-(i[0]+n)/o*100,[t,e]},o.prototype._moveHueHandle=function(t,e){var n,o,i=this.huebarHandleElement,r=this.baseColorElement;t=Math.max(p[0],t),t=Math.min(p[1],t),s.setTranslateY(i,t),n=l.hsvToRGB(this.getHue(),100,100),o=l.rgbToHEX.apply(null,n),s.setGradientColorStop(r,o),e||this.fire("_selectColor",{color:l.rgbToHEX.apply(null,this.getRGB())})},o.prototype.moveHue=function(t,e){var n,o,i=0;n=Math.abs(p[0]),o=n+p[1],t=t||0,i=o*t/f-n,this._moveHueHandle(i,e)},o.prototype._moveHueByPosition=function(t){var e=p[0];this._moveHueHandle(t+e)},o.prototype.getHue=function(){var t,e,n=this.huebarHandleElement,o=s.getTranslateXY(n);return t=Math.abs(p[0]),e=t+p[1],(o[0]+t)*f/e},o.prototype.getHSV=function(){var t=this.getSaturationAndValue(),e=this.getHue();return[e].concat(t)},o.prototype.getRGB=function(){return l.hsvToRGB.apply(null,this.getHSV())},o.prototype._prepareColorSliderForMouseEvent=function(t){var e,n=this.options,o=r.closest(t.target,"."+n.cssPrefix+"slider-part");return e=this._dragDataCache={isColorSlider:r.hasClass(o,n.cssPrefix+"slider-left"),parentElement:o}},o.prototype._onClick=function(t){var e=this._prepareColorSliderForMouseEvent(t),n=a.getMousePosition(t.originEvent,e.parentElement);e.isColorSlider?this._moveColorSliderByPosition(n[0],n[1]):this._moveHueByPosition(n[1]),this._dragDataCache=null},o.prototype._onDragStart=function(t){this._prepareColorSliderForMouseEvent(t)},o.prototype._onDrag=function(t){var e=this._dragDataCache,n=a.getMousePosition(t.originEvent,e.parentElement);e.isColorSlider?this._moveColorSliderByPosition(n[0],n[1]):this._moveHueByPosition(n[1])},o.prototype._onDragEnd=function(){this._dragDataCache=null},i.CustomEvents.mixin(o),e.exports=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../template/slider":14,"./colorutil":2,"./core/domevent":4,"./core/domutil":5,"./core/drag":6,"./core/view":7,"./svgvml":12}],12:[function(t,e,n){(function(t){"use strict";var n=t.tui.util,o=/[\.\-0-9]+/g,i=-6,r={isOldBrowser:function(){var t=r._isOldBrowser;return n.isExisty(t)||(r._isOldBrowser=t=n.browser.msie&&n.browser.version<9),t},getTranslateXY:function(t){var e;return r.isOldBrowser()?(e=t.style,[parseFloat(e.top),parseFloat(e.left)]):(e=t.getAttribute("transform"))?(e=e.match(o),[parseFloat(e[1]),parseFloat(e[0])]):[0,0]},setTranslateXY:function(t,e,n){r.isOldBrowser()?(t.style.left=e+"px",t.style.top=n+"px"):t.setAttribute("transform","translate("+e+","+n+")")},setTranslateY:function(t,e){r.isOldBrowser()?t.style.top=e+"px":t.setAttribute("transform","translate("+i+","+e+")")},setStrokeColor:function(t,e){r.isOldBrowser()?t.strokecolor=e:t.setAttribute("stroke",e)},setGradientColorStop:function(t,e){r.isOldBrowser()?t.color=e:t.setAttribute("stop-color",e)}};e.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(t,e,n){"use strict";var o=['','
','','','{{color}}',"
"].join("\n"),i='
  • ';e.exports={layout:o,item:i}},{}],14:[function(t,e,n){(function(t){"use strict";var n=t.tui.util,o=['
    {{slider}}
    ','
    {{huebar}}
    '].join("\n"),i=['',"",'','','',"",'','','',"","",'','','',""].join("\n"),r=['
    ','','',"",'','',"",'',"
    "].join("\n"),a=['',"",'','','','','','','','',"","",'','',""].join("\n"),s=['
    ','','',"",'',"
    "].join("\n"),l=n.browser.msie&&n.browser.version<9;l&&t.document.namespaces.add("v","urn:schemas-microsoft-com:vml"),e.exports={layout:o,slider:l?r:i,huebar:l?s:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]),function e(t,n,o){function i(a,s){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(r)return r(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return i(n?n:e)},d,d.exports,e,t,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a[> ]*|[*+-]\s(?:\[(?:x|\s)\]\s)?|(\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(\s*)/,i=/^(\s*)(>[> ]*|[*+-]\s(?:\[(?:x|\s)\]\s)?|(\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(\s*)$/,r=/[*+-]\s/;CodeMirror.commands.subListIndentTab=function(t){if(t.getOption("disableInput"))return CodeMirror.Pass;for(var e=t.listSelections(),n=0;n")>=0?h[2]:parseInt(h[3],10)+1+h[4],n[a]="\n"+f+p+m}}t.replaceSelections(n)}},{}],2:[function(t,e,n){"use strict";CodeMirror.defineMode("gfm",function(t,e){function n(t){return t.code=!1,null}var o=0,i={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(t){return{code:t.code,codeBlock:t.codeBlock,ateSpace:t.ateSpace}},token:function(t,e){if(e.combineTokens=null,e.codeBlock)return t.match(/^```+/)?(e.codeBlock=!1,null):(t.skipToEnd(),null);if(t.sol()&&(e.code=!1),t.sol()&&t.match(/^```+/))return t.skipToEnd(),e.codeBlock=!0,null;if("`"===t.peek()){t.next();var n=t.pos;t.eatWhile("`");var i=1+t.pos-n;return e.code?i===o&&(e.code=!1):(o=i,e.code=!0),null}return e.code?(t.next(),null):t.eatSpace()?(e.ateSpace=!0,null):((t.sol()||e.ateSpace)&&(e.ateSpace=!1),t.next(),null)},blankLine:n},r={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var a in e)r[a]=e[a];return r.name="markdown",CodeMirror.overlayMode(CodeMirror.getMode(t,r),i)},"markdown"),CodeMirror.defineMIME("text/x-gfm","gfm")},{}],3:[function(t,e,n){"use strict";CodeMirror.defineMode("markdown",function(t,e){function n(e){if(CodeMirror.findModeByName){var n=CodeMirror.findModeByName(e);n&&(e=n.mime||n.mimes[0])}var o=CodeMirror.getMode(t,e);return"null"==o.name?null:o}function o(t,e,n){return e.f=e.inline=n,n(t,e)}function i(t){return!t||!/\S/.test(t.string)}function r(t){return t.linkTitle=!1,t.em=!1,t.strong=!1,t.strikethrough=!1,t.quote=0,t.indentedCode=!1,C||t.f!=s||(t.f=h,t.block=a),t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine=null,null}function a(t,r){var a=t.sol(),s=r.list!==!1,c=r.indentedCode;r.indentedCode=!1,s&&(r.indentationDiff>=0&&(r.indentationDiff<4&&(r.indentation-=r.indentationDiff),r.list=null),r.indentation>0?(r.list=null,r.listDepth=Math.floor(r.indentation/4)+1):(r.list=!1,r.listDepth=0));var u=null;if(r.indentationDiff>=4)return t.skipToEnd(),c||i(r.prevLine)?(r.indentation-=4,r.indentedCode=!0,b):null;if(t.eatSpace())return null;if((u=t.match(V))&&u[1].length<=6)return r.header=u[1].length,e.highlightFormatting&&(r.formatting="header"),r.f=r.inline,d(r);if(!(i(r.prevLine)||r.quote||s||c)&&(u=t.match(q)))return r.header="="==u[0].charAt(0)?1:2,e.highlightFormatting&&(r.formatting="header"),r.f=r.inline,d(r);if(t.eat(">"))return r.quote=a?1:r.quote+1,e.highlightFormatting&&(r.formatting="quote"),t.eatSpace(),d(r);if("["===t.peek())return o(t,r,g);if(t.match(H,!0))return r.hr=!0,N;if((i(r.prevLine)||s)&&(t.match(F,!1)||t.match(W,!1))){var h=null;return t.match(F,!0)?h="ul":(t.match(W,!0),h="ol"),r.indentation=t.column()+t.current().length,r.list=!0,r.listDepth++,e.taskLists&&t.match(U,!1)&&(r.taskList=!0),r.f=r.inline,e.highlightFormatting&&(r.formatting=["list","list-"+h]),d(r)}return e.fencedCodeBlocks&&(u=t.match(z,!0))?(r.fencedChars=u[1],r.localMode=n(u[2]),r.localMode&&(r.localState=r.localMode.startState()),r.f=r.block=l,e.highlightFormatting&&(r.formatting="code-block"),r.code=!0,d(r)):o(t,r,r.inline)}function s(t,e){var n=_.token(t,e.htmlState);return(C&&null===e.htmlState.tagStart&&!e.htmlState.context&&e.htmlState.tokenize.isInText||e.md_inside&&t.current().indexOf(">")>-1)&&(e.f=h,e.block=a,e.htmlState=null),n}function l(t,e){return t.sol()&&e.fencedChars&&t.match(e.fencedChars,!1)?(e.localMode=e.localState=null,e.f=e.block=c,null):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),b)}function c(t,n){t.match(n.fencedChars),n.block=a,n.f=h,n.fencedChars=null,e.highlightFormatting&&(n.formatting="code-block"),n.code=!0;var o=d(n);return n.code=!1,o}function d(t){var n=[];if(t.formatting){n.push(B),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var o=0;o=t.quote?n.push(B+"-"+t.formatting[o]+"-"+t.quote):n.push("error"))}if(t.taskOpen)return n.push("meta"),n.length?n.join(" "):null;if(t.taskClosed)return n.push("property"),n.length?n.join(" "):null;if(t.linkHref?n.push(D,"url"):(t.strong&&n.push(O),t.em&&n.push(A),t.strikethrough&&n.push(R),t.linkText&&n.push(P),t.code&&n.push(b)),t.header&&(n.push(k),n.push(k+"-"+t.header)),t.quote&&(n.push(x),!e.maxBlockquoteDepth||e.maxBlockquoteDepth>=t.quote?n.push(x+"-"+t.quote):n.push(x+"-"+e.maxBlockquoteDepth)),t.list!==!1){var i=(t.listDepth-1)%3;i?1===i?n.push(S):n.push(T):n.push(M)}return t.trailingSpaceNewLine?n.push("trailing-space-new-line"):t.trailingSpace&&n.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),n.length?n.join(" "):null}function u(t,e){return t.match(j,!0)?d(e):void 0}function h(t,n){var o=n.text(t,n);if("undefined"!=typeof o)return o;if(n.list)return n.list=null,d(n);if(n.taskList){var i="x"!==t.match(U,!0)[1];return i?n.taskOpen=!0:n.taskClosed=!0,e.highlightFormatting&&(n.formatting="task"),n.taskList=!1,d(n)}if(n.taskOpen=!1,n.taskClosed=!1,n.header&&t.match(/^#+$/,!0))return e.highlightFormatting&&(n.formatting="header"),d(n);var r=t.sol(),a=t.next();if("\\"===a&&(t.next(),e.highlightFormatting)){var s=d(n);return s?s+" formatting-escape":"formatting-escape"}if(n.linkTitle){n.linkTitle=!1;var l=a;"("===a&&(l=")"),l=(l+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var c="^\\s*(?:[^"+l+"\\\\]+|\\\\\\\\|\\\\.)"+l;if(t.match(new RegExp(c),!0))return D}if("`"===a){var u=n.formatting;e.highlightFormatting&&(n.formatting="code");var h=d(n),m=t.pos;t.eatWhile("`");var g=1+t.pos-m;return n.code?g===E?(n.code=!1,h):(n.formatting=u,d(n)):(E=g,n.code=!0,d(n))}if(n.code)return d(n);if("!"===a&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),$;if("["===a&&t.match(/.*\](\(.*\)| ?\[.*\])/,!1))return n.linkText=!0,e.highlightFormatting&&(n.formatting="link"),d(n);if("]"===a&&n.linkText&&t.match(/\(.*\)| ?\[.*\]/,!1)){e.highlightFormatting&&(n.formatting="link");var s=d(n);return n.linkText=!1,n.inline=n.f=f,s}if("<"===a&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=p,e.highlightFormatting&&(n.formatting="link");var s=d(n);return s?s+=" ":s="",s+I}if("<"===a&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=p,e.highlightFormatting&&(n.formatting="link");var s=d(n);return s?s+=" ":s="",s+L}if("<"===a&&t.match(/^\/\w*?>/))return n.md_inside=!1,"tag";var v=!1;if(!e.underscoresBreakWords&&"_"===a&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var y=t.pos-2;if(y>=0){var w=t.string.charAt(y);"_"!==w&&w.match(/(\w)/,!1)&&(v=!0)}}if("*"===a||"_"===a&&!v)if(r&&" "===t.peek());else{if(n.strong===a&&t.eat(a)){e.highlightFormatting&&(n.formatting="strong");var h=d(n);return n.strong=!1,h}if(!n.strong&&t.eat(a))return n.strong=a,e.highlightFormatting&&(n.formatting="strong"),d(n);if(n.em===a){e.highlightFormatting&&(n.formatting="em");var h=d(n);return n.em=!1,h}if(!n.em)return n.em=a,e.highlightFormatting&&(n.formatting="em"),d(n)}else if(" "===a&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return d(n);t.backUp(1)}if(e.strikethrough)if("~"===a&&t.eatWhile(a)){if(n.strikethrough){e.highlightFormatting&&(n.formatting="strikethrough");var h=d(n);return n.strikethrough=!1,h}if(t.match(/^[^\s]/,!1))return n.strikethrough=!0,e.highlightFormatting&&(n.formatting="strikethrough"),d(n)}else if(" "===a&&t.match(/^~~/,!0)){if(" "===t.peek())return d(n);t.backUp(2)}return" "===a&&(t.match(/ +$/,!1)?n.trailingSpace++:n.trailingSpace&&(n.trailingSpaceNewLine=!0)),d(n)}function p(t,n){var o=t.next();if(">"===o){n.f=n.inline=h,e.highlightFormatting&&(n.formatting="link");var i=d(n);return i?i+=" ":i="",i+I}return t.match(/^[^>]+/,!0),I}function f(t,n){if(t.eatSpace())return null;var o=t.next();return"("===o||"["===o?(n.f=n.inline=m("("===o?")":"]"),e.highlightFormatting&&(n.formatting="link-string"),n.linkHref=!0,d(n)):"error"}function m(t){return function(n,o){var i=n.next();if(i===t){o.f=o.inline=h,e.highlightFormatting&&(o.formatting="link-string");var r=d(o);return o.linkHref=!1,r}return n.match(w(t),!0)&&n.backUp(1),o.linkHref=!0,d(o)}}function g(t,n){return t.match(/^[^\]]*\]:/,!1)?(n.f=v,t.next(),e.highlightFormatting&&(n.formatting="link"),n.linkText=!0,d(n)):o(t,n,h)}function v(t,n){if(t.match(/^\]:/,!0)){n.f=n.inline=y,e.highlightFormatting&&(n.formatting="link");var o=d(n);return n.linkText=!1,o}return t.match(/^[^\]]+/,!0),P}function y(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=h,D+" url")}function w(t){return G[t]||(t=(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),G[t]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+t+")")),G[t]}var C=CodeMirror.modes.hasOwnProperty("xml"),_=CodeMirror.getMode(t,C?{name:"xml",htmlMode:!0}:"text/plain");void 0===e.highlightFormatting&&(e.highlightFormatting=!1),void 0===e.maxBlockquoteDepth&&(e.maxBlockquoteDepth=0),void 0===e.underscoresBreakWords&&(e.underscoresBreakWords=!0),void 0===e.taskLists&&(e.taskLists=!1),void 0===e.strikethrough&&(e.strikethrough=!1);var E=0,k="header",b="comment",x="quote",M="variable-2",S="variable-3",T="keyword",N="hr",$="tag",B="formatting",I="link",L="link",P="link",D="string",A="em",O="strong",R="strikethrough",H=/^([*\-_])(?:\s*\1){2,}\s*$/,F=/^[*\-+]\s+/,W=/^[0-9]+([.)])\s+/,U=/^\[(x| )\](?=\s)/,V=e.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,q=/^ *(?:\={1,}|-{1,})\s*$/,j=/^[^#!\[\]*_\\<>` "'(~]+/,z=new RegExp("^("+(e.fencedCodeBlocks===!0?"~~~+|```+":e.fencedCodeBlocks)+")[ \\t]*([\\w+#]*)"),G=[],Y={startState:function(){return{f:a,prevLine:null,thisLine:null,block:a,htmlState:null,indentation:0,inline:h,text:u,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t["this"],block:t.block,htmlState:t.htmlState&&CodeMirror.copyState(_,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?CodeMirror.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listDepth:t.listDepth,quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine){var n=e.header||e.hr;if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0)||n){if(r(e),!n)return null;e.prevLine=null}e.prevLine=e.thisLine,e.thisLine=t,e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.f=e.block;var o=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length,i=4*Math.floor((o-e.indentation)/4);i>4&&(i=4);var a=e.indentation+i;if(e.indentationDiff=a-e.indentation,e.indentation=a,o>0)return null}return e.f(t,e)},innerMode:function(t){return t.block==s?{state:t.htmlState,mode:_}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:Y}},blankLine:r,getType:d,fold:"markdown"};return Y},"xml"),CodeMirror.defineMIME("text/x-markdown","markdown")},{}],4:[function(t,e,n){"use strict";CodeMirror.overlayMode=function(t,e,n){return{startState:function(){return{base:CodeMirror.startState(t),overlay:CodeMirror.startState(e),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(n){return{base:CodeMirror.copyState(t,n.base),overlay:CodeMirror.copyState(e,n.overlay),basePos:n.basePos,baseCur:null,overlayPos:n.overlayPos,overlayCur:null}},token:function(o,i){return(o!=i.streamSeen||Math.min(i.basePos,i.overlayPos)/g,"<script>"),t=t.replace(/\<\/script\>/g,"</script>")},o.factory=function(t){return new o(t)},e.exports=o},{"./markedCustomRenderer":34}],8:[function(t,e,n){"use strict";var o=function(t){return t&&t.nodeType===Node.TEXT_NODE},i=function(t){return t&&t.nodeType===Node.ELEMENT_NODE},r=function(t,e){return t.childNodes.length&&e>=0?t.childNodes[e]:void 0},a=function(t){return i(t)?t.tagName:o(t)?"TEXT":void 0},s=function(t){var e;return i(t)?e=t.textContent.length:o(t)&&(e=t.nodeValue.length),e},l=function(t){var e;return i(t)?e=t.childNodes.length:o(t)&&(e=t.nodeValue.length),e},c=function(t){var e,n,o=t.parentNode.childNodes;for(e=0,n=o.length;n>e;e+=1)if(o[e]===t)return e},d=function(t,e,n){for(var o,i,r=t+"Sibling";e&&!e[r]&&(o=a(e.parentNode),o!==n&&"BODY"!==o);)e=e.parentNode;return e[r]&&(i=e[r]),i},u=function(t,e,n){var i;return i=e>0?o(t)?t:t.childNodes[e-1]:d("previous",t,n)},h=function(t,e){var n;return n=o(t)?t:t.childNodes[e]};e.exports={getChildNodeAt:r,getNodeName:a,isTextNode:o,isElemNode:i,getTextLength:s,getOffsetLength:l,getPrevOffsetNodeUntil:u,getNodeOffsetOfParent:c,getNodeByOffset:h}},{}],9:[function(t,e,n){"use strict";function o(t){var e=this;this.options=$.extend({previewStyle:"tab",initialEditType:"markdown",height:300},t),this.eventManager=new l,this.importManager=new u(this.eventManager),this.commandManager=new c(this),this.convertor=new h(this.eventManager),this.layout=new s(t,this.eventManager),this.setUI(this.options.UI||new p(this)),this.mdEditor=new i(this.layout.getMdEditorContainerEl(),this.eventManager),this.preview=new r(this.layout.getPreviewEl(),this.eventManager,this.convertor),this.wwEditor=new a(this.layout.getWwEditorContainerEl(),this.options.contentCSSStyles,this.eventManager),this.options.hooks&&R.forEach(this.options.hooks,function(t,n){e.addHook(n,t)}),this.options.events&&R.forEach(this.options.events,function(t,n){e.on(n,t)}),this.changePreviewStyle(this.options.previewStyle),this.mdEditor.init(),this.wwEditor.init(function(){d.applyExtension(e,e.options.exts),e._initDefaultCommands(),e.changeMode(e.options.initialEditType),e.contentHeight(e.options.height),e.setValue(e.options.initialValue),e.eventManager.emit("load",e)}),H.push(this)}var i=t("./markdownEditor"),r=t("./preview"),a=t("./wysiwygEditor"),s=t("./layout"),l=t("./eventManager"),c=t("./commandManager"),d=t("./extManager"),u=t("./importManager"),h=t("./convertor"),p=t("./ui/defaultUI.js"),f=t("./markdownCommands/bold"),m=t("./markdownCommands/italic"),g=t("./markdownCommands/blockquote"),v=t("./markdownCommands/heading"),y=t("./markdownCommands/hr"),w=t("./markdownCommands/addLink"),C=t("./markdownCommands/addImage"),_=t("./markdownCommands/ul"),E=t("./markdownCommands/ol"),k=t("./markdownCommands/table"),b=t("./markdownCommands/task"),x=t("./wysiwygCommands/bold"),M=t("./wysiwygCommands/italic"),S=t("./wysiwygCommands/blockquote"),T=t("./wysiwygCommands/addImage"),N=t("./wysiwygCommands/addLink"),B=t("./wysiwygCommands/hr"),I=t("./wysiwygCommands/heading"),L=t("./wysiwygCommands/ul"),P=t("./wysiwygCommands/ol"),D=t("./wysiwygCommands/table"),A=t("./wysiwygCommands/increaseTask"),O=t("./wysiwygCommands/task"),R=tui.util,H=[];t("./extensions/taskCounter"),t("./extensions/textPalette"),t("./extensions/scrollFollow"),t("./extensions/colorSyntax"),o.prototype._initDefaultCommands=function(){this.commandManager.addCommand(f),this.commandManager.addCommand(m),this.commandManager.addCommand(g),this.commandManager.addCommand(v),this.commandManager.addCommand(y),this.commandManager.addCommand(w),this.commandManager.addCommand(C),this.commandManager.addCommand(_),this.commandManager.addCommand(E),this.commandManager.addCommand(k),this.commandManager.addCommand(b),this.commandManager.addCommand(x),this.commandManager.addCommand(M),this.commandManager.addCommand(S),this.commandManager.addCommand(L),this.commandManager.addCommand(P),this.commandManager.addCommand(T),this.commandManager.addCommand(N),this.commandManager.addCommand(B),this.commandManager.addCommand(I),this.commandManager.addCommand(A),this.commandManager.addCommand(O),this.commandManager.addCommand(D)},o.prototype.changePreviewStyle=function(t){this.layout.changePreviewStyle(t),this.mdPreviewStyle=t,this.eventManager.emit("changePreviewStyle",t)},o.prototype.exec=function(){this.commandManager.exec.apply(this.commandManager,arguments)},o.prototype.addCommand=function(t,e){e?this.commandManager.addCommand(c.command(t,e)):this.commandManager.addCommand(t)},o.prototype.on=function(t,e){this.eventManager.listen(t,e)},o.prototype.off=function(t){this.eventManager.removeEventHandler(t)},o.prototype.addHook=function(t,e){this.eventManager.removeEventHandler(t),this.eventManager.listen(t,e)},o.prototype.removeHook=function(t){this.eventManager.removeEventHandler(t)},o.prototype.getCodeMirror=function(){return this.mdEditor.getEditor()},o.prototype.getSquire=function(){return this.wwEditor.getEditor()},o.prototype.focus=function(){this.getCurrentModeEditor().focus()},o.prototype.setValue=function(t){t=t||"",this.isMarkdownMode()?this.mdEditor.setValue(t):this.wwEditor.setValue(this.convertor.toHTML(t))},o.prototype.getValue=function(){var t;return t=this.isMarkdownMode()?this.mdEditor.getValue():this.convertor.toMarkdown(this.wwEditor.getValue())},o.prototype.addWidget=function(t,e,n,o){this.getCurrentModeEditor().addWidget(t,e,n,o)},o.prototype.contentHeight=function(t){return t&&(this._contentHeight=t,this.mdEditor.setHeight(t),this.preview.setHeight(t),this.wwEditor.setHeight(t)),this._contentHeight},o.prototype.getCurrentModeEditor=function(){var t;return t=this.isMarkdownMode()?this.mdEditor:this.wwEditor},o.prototype.isMarkdownMode=function(){return"markdown"===this.currentMode},o.prototype.isWysiwygMode=function(){return"wysiwyg"===this.currentMode},o.prototype.getCurrentPreviewStyle=function(){return this.mdPreviewStyle},o.prototype.changeMode=function(t){this.currentMode!==t&&(this.currentMode=t,this.isWysiwygMode()?(this.wwEditor.setValue(this.convertor.toHTML(this.mdEditor.getValue())),this.layout.switchToWYSIWYG(),this.eventManager.emit("changeModeToWysiwyg")):(this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue())),this.layout.switchToMarkdown(),this.getCodeMirror().refresh(),this.eventManager.emit("changeModeToMarkdown")),this.eventManager.emit("changeMode",t))},o.prototype.remove=function(){this.wwEditor.remove(),this.mdEditor.remove(),this.layout.remove(),this.getUI()&&this.getUI().remove()},o.prototype.hide=function(){this.eventManager.emit("hide",this)},o.prototype.show=function(){this.eventManager.emit("show",this),this.getCodeMirror().refresh()},o.prototype.setUI=function(t){this._ui=t},o.prototype.getUI=function(){return this._ui},o.prototype.reset=function(){this.wwEditor.reset(),this.mdEditor.reset()},o.getInstances=function(){return H},o.defineExtension=function(t,e){d.defineExtension(t,e)},e.exports=o},{"./commandManager":6,"./convertor":7,"./eventManager":10,"./extManager":11,"./extensions/colorSyntax":12,"./extensions/scrollFollow":13,"./extensions/taskCounter":16,"./extensions/textPalette":17,"./importManager":18,"./layout":20,"./markdownCommands/addImage":22,"./markdownCommands/addLink":23,"./markdownCommands/blockquote":24,"./markdownCommands/bold":25,"./markdownCommands/heading":26,"./markdownCommands/hr":27,"./markdownCommands/italic":28,"./markdownCommands/ol":29,"./markdownCommands/table":30,"./markdownCommands/task":31,"./markdownCommands/ul":32,"./markdownEditor":33,"./preview":35,"./ui/defaultUI.js":38,"./wysiwygCommands/addImage":51,"./wysiwygCommands/addLink":52,"./wysiwygCommands/blockquote":53,"./wysiwygCommands/bold":54,"./wysiwygCommands/heading":55,"./wysiwygCommands/hr":56,"./wysiwygCommands/increaseTask":57,"./wysiwygCommands/italic":58,"./wysiwygCommands/ol":59,"./wysiwygCommands/table":60,"./wysiwygCommands/task":61,"./wysiwygCommands/ul":62,"./wysiwygEditor":63}],10:[function(t,e,n){"use strict";function o(){this.events=new i.Map,this.TYPE=new i.Enum(r)}var i=tui.util,r=["previewBeforeHook","previewRenderAfter","addImageBlobHook","contentChangedFromWysiwyg","changeFromWysiwyg","contentChangedFromMarkdown","changeFromMarkdown","change","changeModeToWysiwyg","changeModeToMarkdown","changeMode","changePreviewStyle","openPopupAddLink","openPopupAddImage","openPopupAddTable","closeAllPopup","command","htmlUpdate","markdownUpdate","renderedHtmlUpdated","convertorAfterMarkdownToHtmlConverted","convertorAfterHtmlToMarkdownConverted","stateChange","load","focus","blur","paste","copy","drop","show","hide"];o.prototype.listen=function(t,e){var n,o=this._getTypeInfo(t);if(!this._hasEventType(o.type))throw new Error("There is no event type "+o.type);n=this.events.get(o.type)||[],o.namespace&&(e.namespace=o.namespace),n.push(e),this.events.set(o.type,n)},o.prototype.emit=function(){var t,e,n=i.toArray(arguments),o=n.shift(),r=this._getTypeInfo(o),a=this.events.get(r.type);return a&&(e=[],i.forEach(a,function(o){t=o.apply(null,n),i.isUndefined(t)||e.push(t)})),e&&e.length?e:void 0},o.prototype.emitReduce=function(){var t=i.toArray(arguments),e=t.shift(),n=this.events.get(e);return n&&i.forEach(n,function(e){var n=e.apply(null,t);i.isFalsy(n)||(t[0]=n)}),t[0]},o.prototype._getTypeInfo=function(t){var e=t.split(".");return{type:e[0],namespace:e[1]}},o.prototype._hasEventType=function(t){return!i.isUndefined(this.TYPE[t.split(".")[0]])},o.prototype.addEventType=function(t){if(this._hasEventType(t))throw new Error("There is already have event type "+t);this.TYPE.set(t)},o.prototype.removeEventHandler=function(t){var e=this,n=this._getTypeInfo(t),t=n.type,o=n.namespace;t&&!o?this.events["delete"](t):!t&&o?this.events.forEach(function(t,n){e._removeEventHandlerWithTypeInfo(n,o)}):t&&o&&e._removeEventHandlerWithTypeInfo(t,o)},o.prototype._removeEventHandlerWithTypeInfo=function(t,e){var n,o=[];n=this.events.get(t),i.forEach(n,function(t){t.namespace!==e&&o.push(t)}),this.events.set(t,o)},e.exports=o},{}],11:[function(t,e,n){"use strict";function o(){this.exts=new i.Map}var i=tui.util;o.prototype.defineExtension=function(t,e){this.exts.set(t,e)},o.prototype.applyExtension=function(t,e){var n=this;e&&e.forEach(function(e){n.exts.has(e)&&n.exts.get(e)(t)})},e.exports=new o},{}],12:[function(t,e,n){"use strict";function o(t){var e,n,o,i,r;t.eventManager.addEventType("colorButtonClicked"),t.getUI().toolbar.addButton({className:"color",event:"colorButtonClicked",text:"Ͼ"}),e=$("
    "),i=$('
    '),i.css("margin-top",10),n=tui.component.colorpicker.create({container:e[0]}),e.append(i),o=t.getUI().createPopup({title:!1,content:e,$target:t.getUI().$el,css:{width:178,position:"absolute",top:$("button.color").offset().top+$("button.color").height()+5,left:$("button.color").offset().left}}),t.eventManager.listen("focus",function(){o.hide()}),t.eventManager.listen("colorButtonClicked",function(){o.isShow()?o.hide():o.show()}),t.eventManager.listen("closeAllPopup",function(){o.hide()}),n.on("selectColor",function(e){r=e.color,"palette"===e.origin&&(t.exec("color",r),o.hide())}),o.$el.find(".applyButton").on("click",function(){t.exec("color",r)})}function i(t,e){return"{color:"+e+"}"+t+"{color}"}function r(t,e){return''+t+""}function a(t){return t.replace(h,function(t,e,n,o){return e=parseInt(e,10),n=parseInt(n,10),o=parseInt(o,10),"#"+s(e.toString(16))+s(n.toString(16))+s(o.toString(16))})}function s(t){return"0"===t?"00":t}var l=t("../extManager"),c=/{color:(.+?)}(.*?){color}/g,d=/(.*?)/g,u=/(.*?)<\/span>/g,h=/rgb\((\d+)[, ]+(\d+)[, ]+(\d+)\)/g,p="#181818";l.defineExtension("colorSyntax",function(t){var e=!1;t.options.colorSyntax&&(e=!!t.options.colorSyntax.useCustomSyntax),t.eventManager.listen("convertorAfterMarkdownToHtmlConverted",function(t){var n;return n=e?t.replace(c,function(t,e,n){return r(n,e)}):t}),t.eventManager.listen("convertorAfterHtmlToMarkdownConverted",function(t){var n=e?u:d;return t.replace(n,function(t,n,o){var r;return n.match(h)&&(n=a(n)),r=e?i(o,n):t.replace(/ ?class="colour" ?/g," ").replace(h,n)})}),t.addCommand("markdown",{name:"color",exec:function(t,n){var o=t.getEditor();e?o.replaceSelection(i(o.getSelection(),n)):o.replaceSelection(r(o.getSelection(),n)),t.focus()}}),t.addCommand("wysiwyg",{name:"color",exec:function(t,e){e===p?t.getEditor().changeFormat(null,{"class":"colour",tag:"span"}):t.getEditor().setTextColour(e),t.focus()}}),"default"===t.getUI().name&&o(t)})},{"../extManager":11}],13:[function(t,e,n){"use strict";var o=t("../extManager"),i=t("./scrollFollow.scrollSync"),r=t("./scrollFollow.sectionManager");o.defineExtension("scrollFollow",function(t){var e,n,o=t.getCodeMirror(),a=!1,s=!0;e=new r(o,t.preview),n=new i(e,o,t.preview.$el),t.addCommand("markdown",{name:"scrollFollowDisable",exec:function(){s=!1}}),t.addCommand("markdown",{name:"scrollFollowEnable",exec:function(){s=!0}}),o.on("change",function(){a=!1,e.makeSectionList()}),t.on("previewRenderAfter",function(){e.sectionMatch(),n.syncToPreview(),a=!0}),o.on("scroll",function(){s&&a&&n.syncToPreview()}),"default"===t.getUI().name&&t.getUI().toolbar.addButton([{classname:"te-scrollfollow-enable",command:"scrollFollowDisable",text:"Ƒ",style:"background-color: #f5f5f7"},{className:"te-scrollfollow-disable",command:"scrollFollowEnable",text:"Ƒ",style:"background-color: #ddd"}])})},{"../extManager":11,"./scrollFollow.scrollSync":14,"./scrollFollow.sectionManager":15}],14:[function(t,e,n){"use strict";function o(t,e,n){this.sectionManager=t,this.cm=e,this.$previewContainerEl=n,this.$contents=this.$previewContainerEl.find(".tui-editor-contents"),this._currentTimeoutId=null}var i=20;o.prototype._getEditorSectionHeight=function(t){return this.cm.heightAtLine(t.end,"local")-this.cm.heightAtLine(t.start>0?t.start-1:0,"local")},o.prototype._getEditorLineHeightGapInSection=function(t,e){var n=this.cm.heightAtLine(e,"local")-this.cm.heightAtLine(t.start>0?t.start-1:0,"local");return Math.max(n,0)},o.prototype._getEditorSectionScrollRatio=function(t,e){var n,o=t.end===t.start;return n=o?0:this._getEditorLineHeightGapInSection(t,e)/this._getEditorSectionHeight(t)},o.prototype._getScrollFactorsOfEditor=function(){var t,e,n,o,i,r=this.cm,a=r.getScrollInfo();return o=a.height-a.top<=a.clientHeight,o?i={isEditorBottom:o}:(t=r.coordsChar({left:a.left,top:a.top},"local").line,e=this.sectionManager.sectionByLine(t),n=this._getEditorSectionScrollRatio(e,t),i={section:e,sectionRatio:n}),i},o.prototype._getScrollTopForPreview=function(){var t,e,n,o;return e=this._getScrollFactorsOfEditor(),n=e.section,o=e.sectionRatio,e.isEditorBottom?t=this.$contents.height():n.$previewSectionEl&&(t=n.$previewSectionEl[0].offsetTop+n.$previewSectionEl.height()*o-i),t=t&&Math.max(t,0)},o.prototype.syncToPreview=function(){var t=this,e=this._getScrollTopForPreview();this._animateRun(this.$previewContainerEl.scrollTop(),e,function(e){t.$previewContainerEl.scrollTop(e)})},o.prototype._animateRun=function(t,e,n){function o(){var s,l=Date.now(),c=(l-r)/200;1>c?(s=t+i*Math.cos((1-c)*Math.PI/2),n(Math.ceil(s)),a._currentTimeoutId=setTimeout(o,1)):(n(e),a._currentTimeoutId=null)}var i=e-t,r=Date.now(),a=this;this._currentTimeoutId&&clearTimeout(this._currentTimeoutId),o()},e.exports=o},{}],15:[function(t,e,n){"use strict";function o(t,e){this.cm=t,this.preview=e,this.$previewContent=e.$el.find(".tui-editor-contents"),this._sectionList=null,this._currentSection=null}var i=/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/,r=/^ *(?:\={1,}|-{1,})\s*$/,a=/^ *(`{3,}|~{3,})[ ]*$/,s=/^ *(`{3,}|~{3,})[ \.]*(\S+)? */,l=/\s/g;o.prototype._addNewSection=function(t,e){var n=this._makeSectionData(t,e);this._sectionList.push(n),this._currentSection=n},o.prototype.getSectionList=function(){return this._sectionList},o.prototype._makeSectionData=function(t,e){return{start:t,end:e,$previewSectionEl:null}},o.prototype._updateCurrentSectionEnd=function(t){this._currentSection.end=t},o.prototype._eachLineState=function(t){var e,n,o,i,r,a,s=!0,l=!1,c=!1,d="";for(o=this.cm.getDoc().lineCount(),n=0;o>n;n+=1){if(e=!1,i=this.cm.getLine(n),r=this.cm.getLine(n+1)||"",a=this.cm.getLine(n-1)||"",!l||i&&(this._isTableCode(i)||this._isTableAligner(i))?!l&&this._isTable(i,r)&&(l=!0):l=!1,c&&this._isCodeBlockEnd(a)?c=!1:!c&&this._isCodeBlockStart(i)&&(c=this._doFollowedLinesHaveCodeBlockEnd(n,o)), +if(t.getOption("disableInput"))return CodeMirror.Pass;for(var e=t.listSelections(),n=[],a=0;a")>=0?h[2]:parseInt(h[3],10)+1+h[4],n[a]="\n"+f+p+m}}t.replaceSelections(n)}},{}],2:[function(t,e,n){"use strict";CodeMirror.defineMode("gfm",function(t,e){function n(t){return t.code=!1,null}var o=0,i={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(t){return{code:t.code,codeBlock:t.codeBlock,ateSpace:t.ateSpace}},token:function(t,e){if(e.combineTokens=null,e.codeBlock)return t.match(/^```+/)?(e.codeBlock=!1,null):(t.skipToEnd(),null);if(t.sol()&&(e.code=!1),t.sol()&&t.match(/^```+/))return t.skipToEnd(),e.codeBlock=!0,null;if("`"===t.peek()){t.next();var n=t.pos;t.eatWhile("`");var i=1+t.pos-n;return e.code?i===o&&(e.code=!1):(o=i,e.code=!0),null}return e.code?(t.next(),null):t.eatSpace()?(e.ateSpace=!0,null):((t.sol()||e.ateSpace)&&(e.ateSpace=!1),t.next(),null)},blankLine:n},r={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var a in e)r[a]=e[a];return r.name="markdown",CodeMirror.overlayMode(CodeMirror.getMode(t,r),i)},"markdown"),CodeMirror.defineMIME("text/x-gfm","gfm")},{}],3:[function(t,e,n){"use strict";CodeMirror.defineMode("markdown",function(t,e){function n(e){if(CodeMirror.findModeByName){var n=CodeMirror.findModeByName(e);n&&(e=n.mime||n.mimes[0])}var o=CodeMirror.getMode(t,e);return"null"==o.name?null:o}function o(t,e,n){return e.f=e.inline=n,n(t,e)}function i(t){return!t||!/\S/.test(t.string)}function r(t){return t.linkTitle=!1,t.em=!1,t.strong=!1,t.strikethrough=!1,t.quote=0,t.indentedCode=!1,C||t.f!=s||(t.f=h,t.block=a),t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine=null,null}function a(t,r){var a=t.sol(),s=r.list!==!1,c=r.indentedCode;r.indentedCode=!1,s&&(r.indentationDiff>=0&&(r.indentationDiff<4&&(r.indentation-=r.indentationDiff),r.list=null),r.indentation>0?(r.list=null,r.listDepth=Math.floor(r.indentation/4)+1):(r.list=!1,r.listDepth=0));var u=null;if(r.indentationDiff>=4)return t.skipToEnd(),c||i(r.prevLine)?(r.indentation-=4,r.indentedCode=!0,b):null;if(t.eatSpace())return null;if((u=t.match(V))&&u[1].length<=6)return r.header=u[1].length,e.highlightFormatting&&(r.formatting="header"),r.f=r.inline,d(r);if(!(i(r.prevLine)||r.quote||s||c)&&(u=t.match(q)))return r.header="="==u[0].charAt(0)?1:2,e.highlightFormatting&&(r.formatting="header"),r.f=r.inline,d(r);if(t.eat(">"))return r.quote=a?1:r.quote+1,e.highlightFormatting&&(r.formatting="quote"),t.eatSpace(),d(r);if("["===t.peek())return o(t,r,g);if(t.match(H,!0))return r.hr=!0,N;if((i(r.prevLine)||s)&&(t.match(F,!1)||t.match(W,!1))){var h=null;return t.match(F,!0)?h="ul":(t.match(W,!0),h="ol"),r.indentation=t.column()+t.current().length,r.list=!0,r.listDepth++,e.taskLists&&t.match(U,!1)&&(r.taskList=!0),r.f=r.inline,e.highlightFormatting&&(r.formatting=["list","list-"+h]),d(r)}return e.fencedCodeBlocks&&(u=t.match(z,!0))?(r.fencedChars=u[1],r.localMode=n(u[2]),r.localMode&&(r.localState=r.localMode.startState()),r.f=r.block=l,e.highlightFormatting&&(r.formatting="code-block"),r.code=!0,d(r)):o(t,r,r.inline)}function s(t,e){var n=_.token(t,e.htmlState);return(C&&null===e.htmlState.tagStart&&!e.htmlState.context&&e.htmlState.tokenize.isInText||e.md_inside&&t.current().indexOf(">")>-1)&&(e.f=h,e.block=a,e.htmlState=null),n}function l(t,e){return t.sol()&&e.fencedChars&&t.match(e.fencedChars,!1)?(e.localMode=e.localState=null,e.f=e.block=c,null):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),b)}function c(t,n){t.match(n.fencedChars),n.block=a,n.f=h,n.fencedChars=null,e.highlightFormatting&&(n.formatting="code-block"),n.code=!0;var o=d(n);return n.code=!1,o}function d(t){var n=[];if(t.formatting){n.push(B),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var o=0;o=t.quote?n.push(B+"-"+t.formatting[o]+"-"+t.quote):n.push("error"))}if(t.taskOpen)return n.push("meta"),n.length?n.join(" "):null;if(t.taskClosed)return n.push("property"),n.length?n.join(" "):null;if(t.linkHref?n.push(D,"url"):(t.strong&&n.push(O),t.em&&n.push(A),t.strikethrough&&n.push(R),t.linkText&&n.push(P),t.code&&n.push(b)),t.header&&(n.push(k),n.push(k+"-"+t.header)),t.quote&&(n.push(x),!e.maxBlockquoteDepth||e.maxBlockquoteDepth>=t.quote?n.push(x+"-"+t.quote):n.push(x+"-"+e.maxBlockquoteDepth)),t.list!==!1){var i=(t.listDepth-1)%3;i?1===i?n.push(S):n.push(T):n.push(M)}return t.trailingSpaceNewLine?n.push("trailing-space-new-line"):t.trailingSpace&&n.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),n.length?n.join(" "):null}function u(t,e){return t.match(j,!0)?d(e):void 0}function h(t,n){var o=n.text(t,n);if("undefined"!=typeof o)return o;if(n.list)return n.list=null,d(n);if(n.taskList){var i="x"!==t.match(U,!0)[1];return i?n.taskOpen=!0:n.taskClosed=!0,e.highlightFormatting&&(n.formatting="task"),n.taskList=!1,d(n)}if(n.taskOpen=!1,n.taskClosed=!1,n.header&&t.match(/^#+$/,!0))return e.highlightFormatting&&(n.formatting="header"),d(n);var r=t.sol(),a=t.next();if("\\"===a&&(t.next(),e.highlightFormatting)){var s=d(n);return s?s+" formatting-escape":"formatting-escape"}if(n.linkTitle){n.linkTitle=!1;var l=a;"("===a&&(l=")"),l=(l+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var c="^\\s*(?:[^"+l+"\\\\]+|\\\\\\\\|\\\\.)"+l;if(t.match(new RegExp(c),!0))return D}if("`"===a){var u=n.formatting;e.highlightFormatting&&(n.formatting="code");var h=d(n),m=t.pos;t.eatWhile("`");var g=1+t.pos-m;return n.code?g===E?(n.code=!1,h):(n.formatting=u,d(n)):(E=g,n.code=!0,d(n))}if(n.code)return d(n);if("!"===a&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),$;if("["===a&&t.match(/.*\](\(.*\)| ?\[.*\])/,!1))return n.linkText=!0,e.highlightFormatting&&(n.formatting="link"),d(n);if("]"===a&&n.linkText&&t.match(/\(.*\)| ?\[.*\]/,!1)){e.highlightFormatting&&(n.formatting="link");var s=d(n);return n.linkText=!1,n.inline=n.f=f,s}if("<"===a&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=p,e.highlightFormatting&&(n.formatting="link");var s=d(n);return s?s+=" ":s="",s+I}if("<"===a&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){n.f=n.inline=p,e.highlightFormatting&&(n.formatting="link");var s=d(n);return s?s+=" ":s="",s+L}if("<"===a&&t.match(/^\/\w*?>/))return n.md_inside=!1,"tag";var v=!1;if(!e.underscoresBreakWords&&"_"===a&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var y=t.pos-2;if(y>=0){var w=t.string.charAt(y);"_"!==w&&w.match(/(\w)/,!1)&&(v=!0)}}if("*"===a||"_"===a&&!v)if(r&&" "===t.peek());else{if(n.strong===a&&t.eat(a)){e.highlightFormatting&&(n.formatting="strong");var h=d(n);return n.strong=!1,h}if(!n.strong&&t.eat(a))return n.strong=a,e.highlightFormatting&&(n.formatting="strong"),d(n);if(n.em===a){e.highlightFormatting&&(n.formatting="em");var h=d(n);return n.em=!1,h}if(!n.em)return n.em=a,e.highlightFormatting&&(n.formatting="em"),d(n)}else if(" "===a&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return d(n);t.backUp(1)}if(e.strikethrough)if("~"===a&&t.eatWhile(a)){if(n.strikethrough){e.highlightFormatting&&(n.formatting="strikethrough");var h=d(n);return n.strikethrough=!1,h}if(t.match(/^[^\s]/,!1))return n.strikethrough=!0,e.highlightFormatting&&(n.formatting="strikethrough"),d(n)}else if(" "===a&&t.match(/^~~/,!0)){if(" "===t.peek())return d(n);t.backUp(2)}return" "===a&&(t.match(/ +$/,!1)?n.trailingSpace++:n.trailingSpace&&(n.trailingSpaceNewLine=!0)),d(n)}function p(t,n){var o=t.next();if(">"===o){n.f=n.inline=h,e.highlightFormatting&&(n.formatting="link");var i=d(n);return i?i+=" ":i="",i+I}return t.match(/^[^>]+/,!0),I}function f(t,n){if(t.eatSpace())return null;var o=t.next();return"("===o||"["===o?(n.f=n.inline=m("("===o?")":"]"),e.highlightFormatting&&(n.formatting="link-string"),n.linkHref=!0,d(n)):"error"}function m(t){return function(n,o){var i=n.next();if(i===t){o.f=o.inline=h,e.highlightFormatting&&(o.formatting="link-string");var r=d(o);return o.linkHref=!1,r}return n.match(w(t),!0)&&n.backUp(1),o.linkHref=!0,d(o)}}function g(t,n){return t.match(/^[^\]]*\]:/,!1)?(n.f=v,t.next(),e.highlightFormatting&&(n.formatting="link"),n.linkText=!0,d(n)):o(t,n,h)}function v(t,n){if(t.match(/^\]:/,!0)){n.f=n.inline=y,e.highlightFormatting&&(n.formatting="link");var o=d(n);return n.linkText=!1,o}return t.match(/^[^\]]+/,!0),P}function y(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=h,D+" url")}function w(t){return G[t]||(t=(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),G[t]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+t+")")),G[t]}var C=CodeMirror.modes.hasOwnProperty("xml"),_=CodeMirror.getMode(t,C?{name:"xml",htmlMode:!0}:"text/plain");void 0===e.highlightFormatting&&(e.highlightFormatting=!1),void 0===e.maxBlockquoteDepth&&(e.maxBlockquoteDepth=0),void 0===e.underscoresBreakWords&&(e.underscoresBreakWords=!0),void 0===e.taskLists&&(e.taskLists=!1),void 0===e.strikethrough&&(e.strikethrough=!1);var E=0,k="header",b="comment",x="quote",M="variable-2",S="variable-3",T="keyword",N="hr",$="tag",B="formatting",I="link",L="link",P="link",D="string",A="em",O="strong",R="strikethrough",H=/^([*\-_])(?:\s*\1){2,}\s*$/,F=/^[*\-+]\s+/,W=/^[0-9]+([.)])\s+/,U=/^\[(x| )\](?=\s)/,V=e.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,q=/^ *(?:\={1,}|-{1,})\s*$/,j=/^[^#!\[\]*_\\<>` "'(~]+/,z=new RegExp("^("+(e.fencedCodeBlocks===!0?"~~~+|```+":e.fencedCodeBlocks)+")[ \\t]*([\\w+#]*)"),G=[],Y={startState:function(){return{f:a,prevLine:null,thisLine:null,block:a,htmlState:null,indentation:0,inline:h,text:u,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t["this"],block:t.block,htmlState:t.htmlState&&CodeMirror.copyState(_,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?CodeMirror.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listDepth:t.listDepth,quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine){var n=e.header||e.hr;if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0)||n){if(r(e),!n)return null;e.prevLine=null}e.prevLine=e.thisLine,e.thisLine=t,e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.f=e.block;var o=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length,i=4*Math.floor((o-e.indentation)/4);i>4&&(i=4);var a=e.indentation+i;if(e.indentationDiff=a-e.indentation,e.indentation=a,o>0)return null}return e.f(t,e)},innerMode:function(t){return t.block==s?{state:t.htmlState,mode:_}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:Y}},blankLine:r,getType:d,fold:"markdown"};return Y},"xml"),CodeMirror.defineMIME("text/x-markdown","markdown")},{}],4:[function(t,e,n){"use strict";CodeMirror.overlayMode=function(t,e,n){return{startState:function(){return{base:CodeMirror.startState(t),overlay:CodeMirror.startState(e),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(n){return{base:CodeMirror.copyState(t,n.base),overlay:CodeMirror.copyState(e,n.overlay),basePos:n.basePos,baseCur:null,overlayPos:n.overlayPos,overlayCur:null}},token:function(o,i){return(o!=i.streamSeen||Math.min(i.basePos,i.overlayPos)/g,"<script>"),t=t.replace(/\<\/script\>/g,"</script>")},o.factory=function(t){return new o(t)},e.exports=o},{"./markedCustomRenderer":34}],8:[function(t,e,n){"use strict";var o=function(t){return t&&t.nodeType===Node.TEXT_NODE},i=function(t){return t&&t.nodeType===Node.ELEMENT_NODE},r=function(t,e){return t.childNodes.length&&e>=0?t.childNodes[e]:void 0},a=function(t){return i(t)?t.tagName:o(t)?"TEXT":void 0},s=function(t){var e;return i(t)?e=t.textContent.length:o(t)&&(e=t.nodeValue.length),e},l=function(t){var e;return i(t)?e=t.childNodes.length:o(t)&&(e=t.nodeValue.length),e},c=function(t){var e,n,o=t.parentNode.childNodes;for(e=0,n=o.length;n>e;e+=1)if(o[e]===t)return e},d=function(t,e){var n;return n=o(t)?t:t.childNodes[e]},u=function(t,e,n){for(var o,i,r=t+"Sibling";e&&!e[r]&&(o=a(e.parentNode),o!==n&&"BODY"!==o);)e=e.parentNode;return e[r]&&(i=e[r]),i},h=function(t,e,n){var o;return o=e>0?d(t,e-1):u("previous",t,n)};e.exports={getChildNodeAt:r,getNodeName:a,isTextNode:o,isElemNode:i,getTextLength:s,getOffsetLength:l,getPrevOffsetNodeUntil:h,getNodeOffsetOfParent:c,getChildNodeByOffset:d}},{}],9:[function(t,e,n){"use strict";function o(t){var e=this;this.options=$.extend({previewStyle:"tab",initialEditType:"markdown",height:300},t),this.eventManager=new l,this.importManager=new u(this.eventManager),this.commandManager=new c(this),this.convertor=new h(this.eventManager),this.layout=new s(t,this.eventManager),this.setUI(this.options.UI||new p(this)),this.mdEditor=new i(this.layout.getMdEditorContainerEl(),this.eventManager),this.preview=new r(this.layout.getPreviewEl(),this.eventManager,this.convertor),this.wwEditor=new a(this.layout.getWwEditorContainerEl(),this.options.contentCSSStyles,this.eventManager),this.options.hooks&&R.forEach(this.options.hooks,function(t,n){e.addHook(n,t)}),this.options.events&&R.forEach(this.options.events,function(t,n){e.on(n,t)}),this.changePreviewStyle(this.options.previewStyle),this.mdEditor.init(),this.wwEditor.init(function(){d.applyExtension(e,e.options.exts),e._initDefaultCommands(),e.changeMode(e.options.initialEditType),e.contentHeight(e.options.height),e.setValue(e.options.initialValue),e.eventManager.emit("load",e)}),H.push(this)}var i=t("./markdownEditor"),r=t("./preview"),a=t("./wysiwygEditor"),s=t("./layout"),l=t("./eventManager"),c=t("./commandManager"),d=t("./extManager"),u=t("./importManager"),h=t("./convertor"),p=t("./ui/defaultUI.js"),f=t("./markdownCommands/bold"),m=t("./markdownCommands/italic"),g=t("./markdownCommands/blockquote"),v=t("./markdownCommands/heading"),y=t("./markdownCommands/hr"),w=t("./markdownCommands/addLink"),C=t("./markdownCommands/addImage"),_=t("./markdownCommands/ul"),E=t("./markdownCommands/ol"),k=t("./markdownCommands/table"),b=t("./markdownCommands/task"),x=t("./wysiwygCommands/bold"),M=t("./wysiwygCommands/italic"),S=t("./wysiwygCommands/blockquote"),T=t("./wysiwygCommands/addImage"),N=t("./wysiwygCommands/addLink"),B=t("./wysiwygCommands/hr"),I=t("./wysiwygCommands/heading"),L=t("./wysiwygCommands/ul"),P=t("./wysiwygCommands/ol"),D=t("./wysiwygCommands/table"),A=t("./wysiwygCommands/increaseTask"),O=t("./wysiwygCommands/task"),R=tui.util,H=[];t("./extensions/taskCounter"),t("./extensions/textPalette"),t("./extensions/scrollFollow"),t("./extensions/colorSyntax"),o.prototype._initDefaultCommands=function(){this.commandManager.addCommand(f),this.commandManager.addCommand(m),this.commandManager.addCommand(g),this.commandManager.addCommand(v),this.commandManager.addCommand(y),this.commandManager.addCommand(w),this.commandManager.addCommand(C),this.commandManager.addCommand(_),this.commandManager.addCommand(E),this.commandManager.addCommand(k),this.commandManager.addCommand(b),this.commandManager.addCommand(x),this.commandManager.addCommand(M),this.commandManager.addCommand(S),this.commandManager.addCommand(L),this.commandManager.addCommand(P),this.commandManager.addCommand(T),this.commandManager.addCommand(N),this.commandManager.addCommand(B),this.commandManager.addCommand(I),this.commandManager.addCommand(A),this.commandManager.addCommand(O),this.commandManager.addCommand(D)},o.prototype.changePreviewStyle=function(t){this.layout.changePreviewStyle(t),this.mdPreviewStyle=t,this.eventManager.emit("changePreviewStyle",t)},o.prototype.exec=function(){this.commandManager.exec.apply(this.commandManager,arguments)},o.prototype.addCommand=function(t,e){e?this.commandManager.addCommand(c.command(t,e)):this.commandManager.addCommand(t)},o.prototype.on=function(t,e){this.eventManager.listen(t,e)},o.prototype.off=function(t){this.eventManager.removeEventHandler(t)},o.prototype.addHook=function(t,e){this.eventManager.removeEventHandler(t),this.eventManager.listen(t,e)},o.prototype.removeHook=function(t){this.eventManager.removeEventHandler(t)},o.prototype.getCodeMirror=function(){return this.mdEditor.getEditor()},o.prototype.getSquire=function(){return this.wwEditor.getEditor()},o.prototype.focus=function(){this.getCurrentModeEditor().focus()},o.prototype.setValue=function(t){t=t||"",this.isMarkdownMode()?this.mdEditor.setValue(t):this.wwEditor.setValue(this.convertor.toHTML(t))},o.prototype.getValue=function(){var t;return t=this.isMarkdownMode()?this.mdEditor.getValue():this.convertor.toMarkdown(this.wwEditor.getValue())},o.prototype.addWidget=function(t,e,n,o){this.getCurrentModeEditor().addWidget(t,e,n,o)},o.prototype.contentHeight=function(t){return t&&(this._contentHeight=t,this.mdEditor.setHeight(t),this.preview.setHeight(t),this.wwEditor.setHeight(t)),this._contentHeight},o.prototype.getCurrentModeEditor=function(){var t;return t=this.isMarkdownMode()?this.mdEditor:this.wwEditor},o.prototype.isMarkdownMode=function(){return"markdown"===this.currentMode},o.prototype.isWysiwygMode=function(){return"wysiwyg"===this.currentMode},o.prototype.getCurrentPreviewStyle=function(){return this.mdPreviewStyle},o.prototype.changeMode=function(t){this.currentMode!==t&&(this.currentMode=t,this.isWysiwygMode()?(this.wwEditor.setValue(this.convertor.toHTML(this.mdEditor.getValue())),this.layout.switchToWYSIWYG(),this.eventManager.emit("changeModeToWysiwyg")):(this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue())),this.layout.switchToMarkdown(),this.getCodeMirror().refresh(),this.eventManager.emit("changeModeToMarkdown")),this.eventManager.emit("changeMode",t))},o.prototype.remove=function(){this.wwEditor.remove(),this.mdEditor.remove(),this.layout.remove(),this.getUI()&&this.getUI().remove()},o.prototype.hide=function(){this.eventManager.emit("hide",this)},o.prototype.show=function(){this.eventManager.emit("show",this),this.getCodeMirror().refresh()},o.prototype.setUI=function(t){this._ui=t},o.prototype.getUI=function(){return this._ui},o.prototype.reset=function(){this.wwEditor.reset(),this.mdEditor.reset()},o.getInstances=function(){return H},o.defineExtension=function(t,e){d.defineExtension(t,e)},e.exports=o},{"./commandManager":6,"./convertor":7,"./eventManager":10,"./extManager":11,"./extensions/colorSyntax":12,"./extensions/scrollFollow":13,"./extensions/taskCounter":16,"./extensions/textPalette":17,"./importManager":18,"./layout":20,"./markdownCommands/addImage":22,"./markdownCommands/addLink":23,"./markdownCommands/blockquote":24,"./markdownCommands/bold":25,"./markdownCommands/heading":26,"./markdownCommands/hr":27,"./markdownCommands/italic":28,"./markdownCommands/ol":29,"./markdownCommands/table":30,"./markdownCommands/task":31,"./markdownCommands/ul":32,"./markdownEditor":33,"./preview":35,"./ui/defaultUI.js":38,"./wysiwygCommands/addImage":51,"./wysiwygCommands/addLink":52,"./wysiwygCommands/blockquote":53,"./wysiwygCommands/bold":54,"./wysiwygCommands/heading":55,"./wysiwygCommands/hr":56,"./wysiwygCommands/increaseTask":57,"./wysiwygCommands/italic":58,"./wysiwygCommands/ol":59,"./wysiwygCommands/table":60,"./wysiwygCommands/task":61,"./wysiwygCommands/ul":62,"./wysiwygEditor":63}],10:[function(t,e,n){"use strict";function o(){this.events=new i.Map,this.TYPE=new i.Enum(r)}var i=tui.util,r=["previewBeforeHook","previewRenderAfter","addImageBlobHook","contentChangedFromWysiwyg","changeFromWysiwyg","contentChangedFromMarkdown","changeFromMarkdown","change","changeModeToWysiwyg","changeModeToMarkdown","changeMode","changePreviewStyle","openPopupAddLink","openPopupAddImage","openPopupAddTable","closeAllPopup","command","htmlUpdate","markdownUpdate","renderedHtmlUpdated","convertorAfterMarkdownToHtmlConverted","convertorAfterHtmlToMarkdownConverted","stateChange","load","focus","blur","paste","copy","drop","show","hide"];o.prototype.listen=function(t,e){var n,o=this._getTypeInfo(t);if(!this._hasEventType(o.type))throw new Error("There is no event type "+o.type);n=this.events.get(o.type)||[],o.namespace&&(e.namespace=o.namespace),n.push(e),this.events.set(o.type,n)},o.prototype.emit=function(){var t,e,n=i.toArray(arguments),o=n.shift(),r=this._getTypeInfo(o),a=this.events.get(r.type);return a&&(e=[],i.forEach(a,function(o){t=o.apply(null,n),i.isUndefined(t)||e.push(t)})),e&&e.length?e:void 0},o.prototype.emitReduce=function(){var t=i.toArray(arguments),e=t.shift(),n=this.events.get(e);return n&&i.forEach(n,function(e){var n=e.apply(null,t);i.isFalsy(n)||(t[0]=n)}),t[0]},o.prototype._getTypeInfo=function(t){var e=t.split(".");return{type:e[0],namespace:e[1]}},o.prototype._hasEventType=function(t){return!i.isUndefined(this.TYPE[t.split(".")[0]])},o.prototype.addEventType=function(t){if(this._hasEventType(t))throw new Error("There is already have event type "+t);this.TYPE.set(t)},o.prototype.removeEventHandler=function(t){var e=this,n=this._getTypeInfo(t),t=n.type,o=n.namespace;t&&!o?this.events["delete"](t):!t&&o?this.events.forEach(function(t,n){e._removeEventHandlerWithTypeInfo(n,o)}):t&&o&&e._removeEventHandlerWithTypeInfo(t,o)},o.prototype._removeEventHandlerWithTypeInfo=function(t,e){var n,o=[];n=this.events.get(t),i.forEach(n,function(t){t.namespace!==e&&o.push(t)}),this.events.set(t,o)},e.exports=o},{}],11:[function(t,e,n){"use strict";function o(){this.exts=new i.Map}var i=tui.util;o.prototype.defineExtension=function(t,e){this.exts.set(t,e)},o.prototype.applyExtension=function(t,e){var n=this;e&&e.forEach(function(e){n.exts.has(e)&&n.exts.get(e)(t)})},e.exports=new o},{}],12:[function(t,e,n){"use strict";function o(t){var e,n,o,i,r;t.eventManager.addEventType("colorButtonClicked"),t.getUI().toolbar.addButton({className:"color",event:"colorButtonClicked",text:"Ͼ"}),e=$("
    "),i=$('
    '),i.css("margin-top",10),n=tui.component.colorpicker.create({container:e[0]}),e.append(i),o=t.getUI().createPopup({title:!1,content:e,$target:t.getUI().$el,css:{width:178,position:"absolute",top:$("button.color").offset().top+$("button.color").height()+5,left:$("button.color").offset().left}}),t.eventManager.listen("focus",function(){o.hide()}),t.eventManager.listen("colorButtonClicked",function(){o.isShow()?o.hide():o.show()}),t.eventManager.listen("closeAllPopup",function(){o.hide()}),n.on("selectColor",function(e){r=e.color,"palette"===e.origin&&(t.exec("color",r),o.hide())}),o.$el.find(".applyButton").on("click",function(){t.exec("color",r)})}function i(t,e){return"{color:"+e+"}"+t+"{color}"}function r(t,e){return''+t+""}function a(t){return t.replace(h,function(t,e,n,o){return e=parseInt(e,10),n=parseInt(n,10),o=parseInt(o,10),"#"+s(e.toString(16))+s(n.toString(16))+s(o.toString(16))})}function s(t){return"0"===t?"00":t}var l=t("../extManager"),c=/{color:(.+?)}(.*?){color}/g,d=/(.*?)/g,u=/(.*?)<\/span>/g,h=/rgb\((\d+)[, ]+(\d+)[, ]+(\d+)\)/g,p="#181818";l.defineExtension("colorSyntax",function(t){var e=!1;t.options.colorSyntax&&(e=!!t.options.colorSyntax.useCustomSyntax),t.eventManager.listen("convertorAfterMarkdownToHtmlConverted",function(t){var n;return n=e?t.replace(c,function(t,e,n){return r(n,e)}):t}),t.eventManager.listen("convertorAfterHtmlToMarkdownConverted",function(t){var n=e?u:d;return t.replace(n,function(t,n,o){var r;return n.match(h)&&(n=a(n)),r=e?i(o,n):t.replace(/ ?class="colour" ?/g," ").replace(h,n)})}),t.addCommand("markdown",{name:"color",exec:function(t,n){var o=t.getEditor();e?o.replaceSelection(i(o.getSelection(),n)):o.replaceSelection(r(o.getSelection(),n)),t.focus()}}),t.addCommand("wysiwyg",{name:"color",exec:function(t,e){e===p?t.getEditor().changeFormat(null,{"class":"colour",tag:"span"}):t.getEditor().setTextColour(e),t.focus()}}),"default"===t.getUI().name&&o(t)})},{"../extManager":11}],13:[function(t,e,n){"use strict";var o=t("../extManager"),i=t("./scrollFollow.scrollSync"),r=t("./scrollFollow.sectionManager");o.defineExtension("scrollFollow",function(t){var e,n,o=t.getCodeMirror(),a=!1,s=!0;e=new r(o,t.preview),n=new i(e,o,t.preview.$el),t.addCommand("markdown",{name:"scrollFollowDisable",exec:function(){s=!1}}),t.addCommand("markdown",{name:"scrollFollowEnable",exec:function(){s=!0}}),o.on("change",function(){a=!1,e.makeSectionList()}),t.on("previewRenderAfter",function(){e.sectionMatch(),n.syncToPreview(),a=!0}),o.on("scroll",function(){s&&a&&n.syncToPreview()}),"default"===t.getUI().name&&t.getUI().toolbar.addButton([{classname:"te-scrollfollow-enable",command:"scrollFollowDisable",text:"Ƒ",style:"background-color: #f5f5f7"},{className:"te-scrollfollow-disable",command:"scrollFollowEnable",text:"Ƒ",style:"background-color: #ddd"}])})},{"../extManager":11,"./scrollFollow.scrollSync":14,"./scrollFollow.sectionManager":15}],14:[function(t,e,n){"use strict";function o(t,e,n){this.sectionManager=t,this.cm=e,this.$previewContainerEl=n,this.$contents=this.$previewContainerEl.find(".tui-editor-contents"),this._currentTimeoutId=null}var i=20;o.prototype._getEditorSectionHeight=function(t){return this.cm.heightAtLine(t.end,"local")-this.cm.heightAtLine(t.start>0?t.start-1:0,"local")},o.prototype._getEditorLineHeightGapInSection=function(t,e){var n=this.cm.heightAtLine(e,"local")-this.cm.heightAtLine(t.start>0?t.start-1:0,"local");return Math.max(n,0)},o.prototype._getEditorSectionScrollRatio=function(t,e){var n,o=t.end===t.start;return n=o?0:this._getEditorLineHeightGapInSection(t,e)/this._getEditorSectionHeight(t)},o.prototype._getScrollFactorsOfEditor=function(){var t,e,n,o,i,r=this.cm,a=r.getScrollInfo();return o=a.height-a.top<=a.clientHeight,o?i={isEditorBottom:o}:(t=r.coordsChar({left:a.left,top:a.top},"local").line,e=this.sectionManager.sectionByLine(t),n=this._getEditorSectionScrollRatio(e,t),i={section:e,sectionRatio:n}),i},o.prototype._getScrollTopForPreview=function(){var t,e,n,o;return e=this._getScrollFactorsOfEditor(),n=e.section,o=e.sectionRatio,e.isEditorBottom?t=this.$contents.height():n.$previewSectionEl&&(t=n.$previewSectionEl[0].offsetTop+n.$previewSectionEl.height()*o-i),t=t&&Math.max(t,0)},o.prototype.syncToPreview=function(){var t=this,e=this._getScrollTopForPreview();this._animateRun(this.$previewContainerEl.scrollTop(),e,function(e){t.$previewContainerEl.scrollTop(e)})},o.prototype._animateRun=function(t,e,n){function o(){var s,l=Date.now(),c=(l-r)/200;1>c?(s=t+i*Math.cos((1-c)*Math.PI/2),n(Math.ceil(s)),a._currentTimeoutId=setTimeout(o,1)):(n(e),a._currentTimeoutId=null)}var i=e-t,r=Date.now(),a=this;this._currentTimeoutId&&clearTimeout(this._currentTimeoutId),o()},e.exports=o},{}],15:[function(t,e,n){"use strict";function o(t,e){this.cm=t,this.preview=e,this.$previewContent=e.$el.find(".tui-editor-contents"),this._sectionList=null,this._currentSection=null}var i=/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/,r=/^ *(?:\={1,}|-{1,})\s*$/,a=/^ *(`{3,}|~{3,})[ ]*$/,s=/^ *(`{3,}|~{3,})[ \.]*(\S+)? */,l=/\s/g;o.prototype._addNewSection=function(t,e){var n=this._makeSectionData(t,e);this._sectionList.push(n),this._currentSection=n},o.prototype.getSectionList=function(){return this._sectionList},o.prototype._makeSectionData=function(t,e){return{start:t,end:e,$previewSectionEl:null}},o.prototype._updateCurrentSectionEnd=function(t){this._currentSection.end=t},o.prototype._eachLineState=function(t){var e,n,o,i,r,a,s=!0,l=!1,c=!1,d="";for(o=this.cm.getDoc().lineCount(),n=0;o>n;n+=1){if(e=!1,i=this.cm.getLine(n),r=this.cm.getLine(n+1)||"",a=this.cm.getLine(n-1)||"",!l||i&&(this._isTableCode(i)||this._isTableAligner(i))?!l&&this._isTable(i,r)&&(l=!0):l=!1,c&&this._isCodeBlockEnd(a)?c=!1:!c&&this._isCodeBlockStart(i)&&(c=this._doFollowedLinesHaveCodeBlockEnd(n,o)), this._isAtxHeader(i)?e=!0:c||l||!this._isSeTextHeader(i,r)||(e=!0),s){if(d+=i.trim(),!d)continue;s=!1}t(e,n)}},o.prototype._doFollowedLinesHaveCodeBlockEnd=function(t,e){var n,o=!1;for(n=t+1;e>n;n+=1)if(this._isCodeBlockEnd(this.cm.getLine(n))){o=!0;break}return o},o.prototype._isCodeBlockStart=function(t){return s.test(t)},o.prototype._isCodeBlockEnd=function(t){return a.test(t)},o.prototype._isTable=function(t,e){return this._isTableCode(t)&&this._isTableAligner(e)},o.prototype._isTableCode=function(t){return!(!t.match(/ *(\S.*\|.*)/)||!t.match(/ *\|(.+)/))},o.prototype._isTableAligner=function(t){return!(!t.match(/ *([-:]+ *\|[-| :]*)/)||!t.match(/ *\|( *[-:]+[-| :]*)/))},o.prototype._isAtxHeader=function(t){return i.test(t)},o.prototype._isSeTextHeader=function(t,e){return""!==t.replace(l,"")&&e&&r.test(e)},o.prototype.makeSectionList=function(){var t=this;this._sectionList=[],this._eachLineState(function(e,n){e||!t._sectionList.length?t._addNewSection(n,n):t._updateCurrentSectionEnd(n)})},o.prototype.sectionMatch=function(){var t;this._sectionList&&(t=this._getPreviewSections(),this._matchPreviewSectionsWithSectionlist(t))},o.prototype._matchPreviewSectionsWithSectionlist=function(t){var e=this;t.forEach(function(t,n){var o;e._sectionList[n]&&(o=$('
    '),e._sectionList[n].$previewSectionEl=$(t).wrapAll(o).parent())})},o.prototype._getPreviewSections=function(){var t=0,e=[];return e[0]=[],this.$previewContent.contents().filter(function(){return this.nodeType===Node.ELEMENT_NODE}).each(function(n,o){o.tagName.match(/H1|H2|H3|H4|H5|H6/)&&e[t].length&&(e.push([]),t+=1),e[t].push(o)}),e},o.prototype.sectionByLine=function(t){var e,n=this._sectionList,o=n.length;for(e=0;o>e&&!(t<=n[e].end);e+=1);return e===o&&(e=o-1),n[e]},e.exports=o},{}],16:[function(t,e,n){"use strict";var o=t("../extManager"),i=/^\s*\* \[[xX ]\] [^\n]*/gm,r=/^\s*\* \[[xX]\] [^\n]*/gm;o.defineExtension("taskCounter",function(t){t.getTaskCount=function(){var e,n;return t.isMarkdownMode()?(e=t.mdEditor.getValue().match(i),n=e?e.length:0):n=t.wwEditor.get$Body().find("input").length,n},t.getCheckedTaskCount=function(){var e,n;return t.isMarkdownMode()?(e=t.mdEditor.getValue().match(r),n=e?e.length:0):n=t.wwEditor.get$Body().find("input:checked").length,n}})},{"../extManager":11}],17:[function(t,e,n){"use strict";function o(t){t.show(),t.find("input").focus()}function i(t){t.hide(),t.find("input").val("")}function r(t,e){}var a=t("../extManager");a.defineExtension("textPalette",function(t){var e=$('
    '),n=t.options.textPalette.triggers,a=t.options.textPalette.querySender;$(t.options.el).append(e),e.find("input").on("keyup",function(n){var o=e.find("input").val();13===n.which?(n.stopPropagation(),t.getCurrentModeEditor().replaceRelativeOffset(o,-1,1),t.focus(),i(e)):a(o,function(t){r(e,t)})}),t.eventManager.listen("change",function(i){-1!==n.indexOf(i.textContent[i.caretOffset-1])&&(t.addWidget(i.selection,e[0],"over"),o(e))})})},{"../extManager":11}],18:[function(t,e,n){"use strict";function o(t){this.eventManager=t,this._initDropEvent(),this._initPasteEvent(),this._initDefaultImageImporter()}var i=tui.util;o.prototype._initDropEvent=function(){var t=this;this.eventManager.listen("drop",function(e){var n=e.data.dataTransfer&&e.data.dataTransfer.files;t._processEachItems(n)})},o.prototype._initPasteEvent=function(){var t=this;this.eventManager.listen("paste",function(e){var n=e.data.clipboardData&&e.data.clipboardData.items;t._processEachItems(n)})},o.prototype._initDefaultImageImporter=function(){this.eventManager.listen("addImageBlobHook",function(t,e){var n=new FileReader;n.onload=function(t){e(t.target.result)},n.readAsDataURL(t)})},o.prototype._emitAddImageBlobHook=function(t){var e=this,n=t.name?t:t.getAsFile();this.eventManager.emit("addImageBlobHook",n,function(t){e.eventManager.emit("command","AddImage",{imageUrl:t,altText:n.name||"image"})})},o.prototype._processEachItems=function(t){var e=this;t&&i.forEachArray(t,function(t){return-1!==t.type.indexOf("image")?(e._emitAddImageBlobHook(t),!1):void 0})},e.exports=o},{}],19:[function(t,e,n){"use strict";var o;t("./codemirror/overlay"),t("./codemirror/markdown"),t("./codemirror/gfm"),t("./codemirror/continuelist"),o=t("./editor"),$.fn.tuiEditor=function(){var t,e,n,i=$.makeArray(arguments);if(n=this[0])if(t=i[0]||{},e=$.data(n,"tuiEditor")){if("string"==typeof t)return e[t].apply(e,i.slice(1))}else t.el=n,e=new o(t),$.data(n,"tuiEditor",e);return this},window.tui=window.tui||{},window.tui.Editor=o},{"./codemirror/continuelist":1,"./codemirror/gfm":2,"./codemirror/markdown":3,"./codemirror/overlay":4,"./editor":9}],20:[function(t,e,n){"use strict";function o(t,e){this.$el=$(t.el),this.height=t.height,this.type=t.initialEditType,this.eventManager=e,this.init(),this._initEvent()}var i=['
    ','
    ','
    ','
    ','
    ',"
    ",'
    ','
    ',"
    ","
    "].join("");o.prototype.init=function(){this._renderLayout(),this._initMarkdownAndPreviewSection(),this._initWysiwygSection()},o.prototype._initEvent=function(){this.eventManager.listen("hide",this.hide.bind(this)),this.eventManager.listen("show",this.show.bind(this))},o.prototype._renderLayout=function(){this.$containerEl=$(i).appendTo(this.$el)},o.prototype.switchToWYSIWYG=function(){this.$containerEl.removeClass("te-md-mode"),this.$containerEl.addClass("te-ww-mode")},o.prototype.switchToMarkdown=function(){this.$containerEl.removeClass("te-ww-mode"),this.$containerEl.addClass("te-md-mode")},o.prototype._initMarkdownAndPreviewSection=function(){this.$mdEditorContainerEl=this.$containerEl.find(".te-md-container .te-editor"),this.$previewEl=this.$containerEl.find(".te-md-container .te-preview")},o.prototype._initWysiwygSection=function(){this.$wwEditorContainerEl=this.$containerEl.find(".te-ww-container .te-editor")},o.prototype._verticalSplitStyle=function(){this.$containerEl.find(".te-md-container").removeClass("te-preview-style-tab"),this.$containerEl.find(".te-md-container").addClass("te-preview-style-vertical")},o.prototype._tabStyle=function(){this.$containerEl.find(".te-md-container").removeClass("te-preview-style-vertical"),this.$containerEl.find(".te-md-container").addClass("te-preview-style-tab")},o.prototype.changePreviewStyle=function(t){"tab"===t?this._tabStyle():"vertical"===t&&this._verticalSplitStyle()},o.prototype.hide=function(){this.$el.find(".tui-editor").addClass("te-hide")},o.prototype.show=function(){this.$el.find(".tui-editor").removeClass("te-hide")},o.prototype.remove=function(){this.$el.find(".tui-editor").remove()},o.prototype.getEditorEl=function(){return this.$containerEl},o.prototype.getPreviewEl=function(){return this.$previewEl},o.prototype.getMdEditorContainerEl=function(){return this.$mdEditorContainerEl},o.prototype.getWwEditorContainerEl=function(){return this.$wwEditorContainerEl},e.exports=o},{}],21:[function(t,e,n){"use strict";function o(){this.globalTOID=null,this.lazyRunFunctions={}}var i=tui.util;o.prototype.run=function(t,e,n,o){var r;return i.isString(t)?r=this._runRegisteredRun(t,e,n,o):(r=this._runSingleRun(t,e,n,o,this.globalTOID),this.globalTOID=r),r},o.prototype.registerLazyRunFunction=function(t,e,n,o){o=o||this,this.lazyRunFunctions[t]={fn:e,delay:n,context:o,TOID:null}},o.prototype._runSingleRun=function(t,e,n,o,i){return this._clearTOIDIfNeed(i),i=setTimeout(function(){t.call(n,e)},o)},o.prototype._runRegisteredRun=function(t,e,n,o){var i,r;return r=this.lazyRunFunctions[t].fn,i=this.lazyRunFunctions[t].TOID,o=o||this.lazyRunFunctions[t].delay,n=n||this.lazyRunFunctions[t].context,i=this._runSingleRun(r,e,n,o,i),this.lazyRunFunctions[t].TOID=i,i},o.prototype._clearTOIDIfNeed=function(t){t&&clearTimeout(t)},e.exports=o},{}],22:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"AddImage",exec:function(t,e){var n,o,i,r,a=t.getEditor(),s=a.getDoc();o=t.getCurrentRange(),i={line:o.from.line,ch:o.from.ch},r={line:o.to.line,ch:o.to.ch},n="!["+e.altText+"]("+e.imageUrl+")",s.replaceRange(n,i,r,"+addImage"),a.focus()}});e.exports=i},{"../commandManager":6}],23:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"AddLink",exec:function(t,e){var n,o,i,r,a=t.getEditor(),s=a.getDoc();o=t.getCurrentRange(),i={line:o.from.line,ch:o.from.ch},r={line:o.to.line,ch:o.to.ch},n="["+e.linkText+"]("+e.url+")",s.replaceRange(n,i,r),a.focus()}});e.exports=i},{"../commandManager":6}],24:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"Blockquote",keyMap:["Ctrl-Q","Ctrl-Q"],exec:function(t){var e,n,o,i,r,a,s,l=t.getEditor(),c=l.getDoc();for(n=t.getCurrentRange(),o={line:n.from.line,ch:0},i={line:n.to.line,ch:c.getLineHandle(n.to.line).text.length},e=c.getRange(o,i),r=e.split("\n"),a=r.length,s=0;a>s;s+=1)r[s]=">"+r[s];c.replaceRange(r.join("\n"),o,i),n.to.ch+=1,c.setCursor(n.to),l.focus()}});e.exports=i},{"../commandManager":6}],25:[function(t,e,n){"use strict";var o=t("../commandManager"),i=/^[\*_]{2,}[^\*_]*[\*_]{2,}$/,r=o.command("markdown",{name:"Bold",keyMap:["Ctrl-B","Ctrl-B"],exec:function(t){var e,n,o,i,r,a,s=t.getEditor(),l=s.getDoc();e=l.getCursor(),n=l.getSelection(),a=!n,a&&e.ch>1&&(o=this.expendSelection(l,e),n=o||n),i=this.isNeedRemove(n),r=i?this.remove(n):this.append(n),l.replaceSelection(r,"around"),a&&!i&&this.setCursorToCenter(l,e),s.focus()},isNeedRemove:function(t){return i.test(t)},append:function(t){return"**"+t+"**"},remove:function(t){return t.substr(2,t.length-4)},expendSelection:function(t,e){var n=t.getSelection();return t.setSelection({line:e.line,ch:e.ch-2},{line:e.line,ch:e.ch+2}),"****"===n||"____"===n?n:void t.setSelection(e)},setCursorToCenter:function(t,e){t.setCursor(e.line,e.ch+2)}});e.exports=r},{"../commandManager":6}],26:[function(t,e,n){"use strict";function o(t){var e,n=t.match(a);return n?(e="#"+n[0],7===e.match(/#/g).length&&(e="# "),t=t.split(n[0])[1]):e="# ",e+t}var i=t("../commandManager"),r=i.command("markdown",{name:"Heading",keyMap:["Ctrl-H","Ctrl-H"],exec:function(t){var e,n,i,r,a,s,l,c,d=t.getEditor(),u=d.getDoc();for(n=t.getCurrentRange(),i={line:n.from.line,ch:0},r={line:n.to.line,ch:u.getLineHandle(n.to.line).text.length},c=u.getLine(r.line).length,e=u.getRange(i,r),a=e.split("\n"),s=a.length,l=0;s>l;l+=1)a[l]=o(a[l]);u.replaceRange(a.join("\n"),i,r),n.to.ch+=u.getLine(r.line).length-c,u.setCursor(n.to),d.focus()}}),a=/^#+\s/g;e.exports=r},{"../commandManager":6}],27:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"HR",exec:function(t){var e,n,o,i=t.getEditor(),r="",a=i.getDoc();e=t.getCurrentRange(),n={line:e.from.line,ch:e.from.ch},o={line:e.to.line,ch:e.to.ch},e.collapsed&&(r=a.getLine(n.line),n.ch=0,o.ch=a.getLineHandle(e.to.line).text.length),r+=a.getLine(n.line).length?"\n\n* * *\n\n":"\n* * *\n",a.replaceRange(r,n,o),i.focus()}});e.exports=i},{"../commandManager":6}],28:[function(t,e,n){"use strict";var o=t("../commandManager"),i=/^[\*_]{3,}[^\*_]*[\*_]{3,}$/,r=/^[\*_][^\*_]*[\*_]$/,a=o.command("markdown",{name:"Italic",keyMap:["Ctrl-I","Ctrl-I"],exec:function(t){var e,n,o,i,r,a,s,l=t.getEditor(),c=l.getDoc();e=c.getCursor(),n=c.getSelection(),a=!n,s=!1,a&&(e.ch>2&&(o=this.expendWithBoldSelection(c,e),o&&(s="with")),"with"!==s&&e.ch>1&&(s=this.expendOnlyBoldSelection(c,e)),!s&&e.ch>0&&(this.expendSelection(c,e),n=o||n)),i=this.isNeedRemove(n),r=i?this.remove(n):this.append(n),c.replaceSelection(r,"around"),a&&this.setCursorToCenter(c,e,i),l.focus()},isNeedRemove:function(t){return r.test(t)||i.test(t)},append:function(t){return"_"+t+"_"},remove:function(t){return t.substr(1,t.length-2)},expendWithBoldSelection:function(t,e){var n=t.getSelection();return t.setSelection({line:e.line,ch:e.ch-3},{line:e.line,ch:e.ch+3}),"******"===n||"______"===n?n:void t.setSelection(e)},expendOnlyBoldSelection:function(t,e){var n=t.getSelection();return t.setSelection({line:e.line,ch:e.ch-2},{line:e.line,ch:e.ch+2}),"****"===n||"____"===n?(t.setSelection(e),"only"):!1},expendSelection:function(t,e){var n=t.getSelection();return t.setSelection({line:e.line,ch:e.ch-1},{line:e.line,ch:e.ch+1}),"**"===n||"__"===n?n:void t.setSelection(e)},setCursorToCenter:function(t,e,n){var o=n?-1:1;t.setCursor(e.line,e.ch+o)}});e.exports=a},{"../commandManager":6}],29:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"OL",exec:function(t){var e,n,o,i,r=t.getEditor(),a=r.getDoc();n=t.getCurrentRange(),o={line:n.from.line,ch:n.from.ch},i={line:n.to.line,ch:n.to.ch},e="1. ",a.replaceRange(e,o,i),r.focus()}});e.exports=i},{"../commandManager":6}],30:[function(t,e,n){"use strict";function o(t){for(var e="|",n="|";t;)e+=" |",n+=" --- |",t-=1;return e+"\n"+n+"\n"}function i(t,e){var n,o,i="";for(n=0;e>n;n+=1){for(i+="|",o=0;t>o;o+=1)i+=" |";i+="\n"}return i=i.replace(/\n$/g,"")}var r=t("../commandManager"),a=r.command("markdown",{name:"Table",exec:function(t,e,n){var r=t.getEditor(),a=r.getDoc(),s="\n";r.getCursor().ch>0&&(s+="\n"),s+=o(e),s+=i(e,n-1),a.replaceSelection(s),r.setCursor(r.getCursor().line-n,2),t.focus()}});e.exports=a},{"../commandManager":6}],31:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"Task",exec:function(t){var e,n,o,i,r=t.getEditor(),a=r.getDoc();n=t.getCurrentRange(),o={line:n.from.line,ch:n.from.ch},i={line:n.to.line,ch:n.to.ch},e="* [ ] ",a.replaceRange(e,o,i),r.focus()}});e.exports=i},{"../commandManager":6}],32:[function(t,e,n){"use strict";var o=t("../commandManager"),i=o.command("markdown",{name:"UL",exec:function(t){var e,n,o,i,r=t.getEditor(),a=r.getDoc();n=t.getCurrentRange(),o={line:n.from.line,ch:n.from.ch},i={line:n.to.line,ch:n.to.ch},e="* ",a.replaceRange(e,o,i),r.focus()}});e.exports=i},{"../commandManager":6}],33:[function(t,e,n){"use strict";function o(t,e){this.eventManager=e,this.$editorContainerEl=t,this._latestState={bold:!1,italic:!1}}var i=window.CodeMirror;o.prototype.init=function(t){var e=$("