UNPKG

react-markdown-editor-lite

Version:
2 lines 93.1 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactMarkdownEditorLite=t(require("react")):e.ReactMarkdownEditorLite=t(e.React)}(globalThis,e=>(()=>{var t={"./node_modules/eventemitter3/index.js"(e){"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,a){if("function"!=typeof r)throw TypeError("The listener must be a function");var l=new o(r,i||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],l]:e._events[c].push(l):(e._events[c]=l,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function l(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1)),l.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},l.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=Array(i);o<i;o++)a[o]=r[o].fn;return a},l.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,o,i,a){var l=n?n+e:e;if(!this._events[l])return!1;var c,u,s=this._events[l],f=arguments.length;if(s.fn){switch(s.once&&this.removeListener(e,s.fn,void 0,!0),f){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,t),!0;case 3:return s.fn.call(s.context,t,r),!0;case 4:return s.fn.call(s.context,t,r,o),!0;case 5:return s.fn.call(s.context,t,r,o,i),!0;case 6:return s.fn.call(s.context,t,r,o,i,a),!0}for(u=1,c=Array(f-1);u<f;u++)c[u-1]=arguments[u];s.fn.apply(s.context,c)}else{var p,h=s.length;for(u=0;u<h;u++)switch(s[u].once&&this.removeListener(e,s[u].fn,void 0,!0),f){case 1:s[u].fn.call(s[u].context);break;case 2:s[u].fn.call(s[u].context,t);break;case 3:s[u].fn.call(s[u].context,t,r);break;case 4:s[u].fn.call(s[u].context,t,r,o);break;default:if(!c)for(p=1,c=Array(f-1);p<f;p++)c[p-1]=arguments[p];s[u].fn.apply(s[u].context,c)}}return!0},l.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},l.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},l.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var l=this._events[i];if(l.fn)l.fn!==t||o&&!l.once||r&&l.context!==r||a(this,i);else{for(var c=0,u=[],s=l.length;c<s;c++)(l[c].fn!==t||o&&!l[c].once||r&&l[c].context!==r)&&u.push(l[c]);u.length?this._events[i]=1===u.length?u[0]:u:a(this,i)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,e.exports=l},react(t){"use strict";t.exports=e},"./node_modules/classnames/index.js"(e){!function(){"use strict";var t={}.hasOwnProperty;function n(){for(var e="",o=0;o<arguments.length;o++){var i=arguments[o];i&&(e=r(e,function(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var o="";for(var i in e)t.call(e,i)&&e[i]&&(o=r(o,i));return o}(i)))}return e}function r(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):"function"==typeof define&&"object"==typeof define.amd&&define.amd?define("classnames",[],function(){return n}):window.classNames=n}()}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";var e,t,n,o,i,a,l,c=r("react"),u=r.n(c);function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}var h=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(e){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=[e],r=s(r),(t=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(r,o||[],s(this).constructor):r.apply(this,o))).handleClose=t.handleClose.bind(t),t}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&f(n,e),t=[{key:"handleClose",value:function(e){e.stopPropagation();var t=this.props.onClose;"function"==typeof t&&t()}},{key:"render",value:function(){return u().createElement("div",{className:"drop-wrap ".concat(this.props.show?"show":"hidden"),onClick:this.handleClose},this.props.children)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(u().Component);let d=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>((t&=63)<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");function y(e){return u().createElement("i",{className:"rmel-iconfont rmel-icon-".concat(e.type)})}function b(e){return u().createElement("div",{className:"rc-md-navigation ".concat(e.visible?"visible":"in-visible")},u().createElement("div",{className:"navigation-nav left"},u().createElement("div",{className:"button-wrap"},e.left)),u().createElement("div",{className:"navigation-nav right"},u().createElement("div",{className:"button-wrap"},e.right)))}function v(e){return u().createElement("div",{className:"tool-bar",style:e.style},e.children)}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}var k=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,r=arguments,n=g(n),m(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(n,r||[],g(this).constructor):n.apply(this,r)),"EVENT_CHANGE","a1"),m(e,"EVENT_FULL_SCREEN","a2"),m(e,"EVENT_VIEW_CHANGE","a3"),m(e,"EVENT_KEY_DOWN","a4"),m(e,"EVENT_EDITOR_KEY_DOWN","a5"),m(e,"EVENT_FOCUS","a5"),m(e,"EVENT_BLUR","a6"),m(e,"EVENT_SCROLL","a7"),m(e,"EVENT_LANG_CHANGE","b1"),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&w(t,e),t}(r("./node_modules/eventemitter3/index.js").EventEmitter),_=new k;let E={clearTip:"Are you sure you want to clear all contents?",btnHeader:"Header",btnClear:"Clear",btnBold:"Bold",btnItalic:"Italic",btnUnderline:"Underline",btnStrikethrough:"Strikethrough",btnUnordered:"Unordered list",btnOrdered:"Ordered list",btnQuote:"Quote",btnLineBreak:"Line break",btnInlineCode:"Inline code",btnCode:"Code",btnTable:"Table",btnImage:"Image",btnLink:"Link",btnUndo:"Undo",btnRedo:"Redo",btnFullScreen:"Full screen",btnExitFullScreen:"Exit full screen",btnModeEditor:"Only display editor",btnModePreview:"Only display preview",btnModeAll:"Display both editor and preview",selectTabMap:"Actual input when typing a Tab key",tab:"Tab",spaces:"Spaces"},j={clearTip:"您确定要清空所有内容吗?",btnHeader:"标题",btnClear:"清空",btnBold:"加粗",btnItalic:"斜体",btnUnderline:"下划线",btnStrikethrough:"删除线",btnUnordered:"无序列表",btnOrdered:"有序列表",btnQuote:"引用",btnLineBreak:"换行",btnInlineCode:"行内代码",btnCode:"代码块",btnTable:"表格",btnImage:"图片",btnLink:"链接",btnUndo:"撤销",btnRedo:"重做",btnFullScreen:"全屏",btnExitFullScreen:"退出全屏",btnModeEditor:"仅显示编辑器",btnModePreview:"仅显示预览",btnModeAll:"显示编辑器与预览",selectTabMap:"按下 Tab 键时实际的输入",tab:"制表符",spaces:"空格"};function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var S=new(function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");C(this,"langs",{enUS:E,zhCN:j}),C(this,"current","enUS"),this.setUp()}return e=[{key:"setUp",value:function(){if("u">typeof window){var e="enUS";if(navigator.language){var t=navigator.language.split("-");e=t[0],1!==t.length&&(e+=t[t.length-1].toUpperCase())}if(navigator.browserLanguage){var n=navigator.browserLanguage.split("-");e=n[0],n[1]&&(e+=n[1].toUpperCase())}this.current!==e&&this.isAvailable(e)&&(this.current=e,_.emit(_.EVENT_LANG_CHANGE,this,e,this.langs[e]))}}},{key:"isAvailable",value:function(e){return void 0!==this.langs[e]}},{key:"add",value:function(e,t){this.langs[e]=t}},{key:"setCurrent",value:function(e){if(!this.isAvailable(e))throw Error("Language ".concat(e," is not exists"));this.current!==e&&(this.current=e,_.emit(_.EVENT_LANG_CHANGE,this,e,this.langs[e]))}},{key:"get",value:function(e,t){var n=this.langs[this.current][e]||"";return t&&Object.keys(t).forEach(function(e){n=n.replace(RegExp("\\{".concat(e,"\\}"),"g"),t[e])}),n}},{key:"getCurrent",value:function(){return this.current}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}());function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(R=function(){return!!e})()}var M=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=T(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,R()?Reflect.construct(e,t||[],T(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&x(n,e),t=[{key:"editor",get:function(){return this.props.editor}},{key:"editorConfig",get:function(){return this.props.editorConfig}},{key:"config",get:function(){return this.props.config}},{key:"getConfig",value:function(e,t){return void 0!==this.props.config[e]&&null!==this.props.config[e]?this.props.config[e]:t}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(u().Component);P(M,"pluginName",""),P(M,"align","left"),P(M,"defaultConfig",{});function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function K(e,t){return(K=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}var V=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=N(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,U()?Reflect.construct(e,t||[],N(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&K(n,e),t=[{key:"render",value:function(){return u().createElement("span",{className:"rc-md-divider"})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(e="pluginName")in V?Object.defineProperty(V,e,{value:"divider",enumerable:!0,configurable:!0,writable:!0}):V[e]="divider";var I={start:0,end:0,text:""};function L(e){var t;return e&&((null!=(t=Promise)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)||((void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"||"function"==typeof e)&&"function"==typeof e.then)}function B(e,t){var n=e.split("\n"),r=e.substr(0,t).split("\n"),o=r.length,i=r[r.length-1].length,a=n[r.length-1],l=r.length>1?r[r.length-2]:null,c=n.length>r.length?n[r.length]:null;return{line:o,col:i,beforeText:e.substr(0,t),afterText:e.substr(t),curLine:a,prevLine:l,nextLine:c}}for(var A={bold:["**","**"],italic:["*","*"],underline:["++","++"],strikethrough:["~~","~~"],quote:["\n> ","\n"],inlinecode:["`","`"],code:["\n```\n","\n```\n"]},D=1;D<=6;D++)A["h".concat(D)]=["\n".concat(function(e,t){for(var n="",r=t;r--;)n+="#";return n}(0,D)," "),"\n"];function H(e,t){var n=t;if("\n"!==n.substr(0,1)&&(n="\n"+n),"unordered"===e)return n.length>1?n.replace(/\n/g,"\n* ").trim():"* ";var r=1;return n.length>1?n.replace(/\n/g,function(){return"\n".concat(r++,". ")}).trim():"1. "}function F(e,t){return{text:e,newBlock:t,selection:{start:e.length,end:e.length}}}let W=function(e,t,n){if(void 0!==A[t])return{text:"".concat(A[t][0]).concat(e).concat(A[t][1]),selection:{start:A[t][0].length,end:A[t][0].length+e.length}};switch(t){case"tab":var r=1===n.tabMapValue?" ":" ".repeat(n.tabMapValue),o=r+e.replace(/\n/g,"\n".concat(r)),i=e.includes("\n")?e.match(/\n/g).length:0;return{text:o,selection:{start:n.tabMapValue,end:n.tabMapValue*(i+1)+e.length}};case"unordered":return F(H("unordered",e),!0);case"order":return F(H("order",e),!0);case"hr":return F("---",!0);case"table":return{text:function(e){for(var t=e.row,n=void 0===t?2:t,r=e.col,o=void 0===r?2:r,i=["|"],a=["|"],l=["|"],c="",u=1;u<=o;u++)i.push(" Head |"),l.push(" --- |"),a.push(" Data |");for(var s=1;s<=n;s++)c+="\n"+a.join("");return"".concat(i.join(""),"\n").concat(l.join("")).concat(c)}(n),newBlock:!0};case"image":return{text:"![".concat(e||n.target,"](").concat(n.imageUrl||"",")"),selection:{start:2,end:e.length+2}};case"link":return{text:"[".concat(e,"](").concat(n.linkUrl||"",")"),selection:{start:1,end:e.length+1}}}return{text:e,selection:{start:0,end:e.length}}};function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function G(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}let q=function(e,t){return{placeholder:W("","image",{target:"Uploading_".concat(d()),imageUrl:""}).text,uploaded:new Promise(function(n){var r=!0,o=function(t){r&&console.warn("Deprecated: onImageUpload should return a Promise, callback will be removed in future"),n(W("","image",{target:e.name,imageUrl:t}).text)},i=t(e,o);L(i)&&(r=!1,i.then(o))})}},Y={theme:"default",view:{menu:!0,md:!0,html:!0},canView:{menu:!0,md:!0,html:!0,both:!0,fullScreen:!0,hideMenu:!0},htmlClass:"",markdownClass:"",syncScrollMode:["rightFollowLeft","leftFollowRight"],imageUrl:"",imageAccept:"",linkUrl:"",loggerMaxSize:100,loggerInterval:600,table:{maxRow:4,maxCol:6},allowPasteImage:!0,onImageUpload:void 0,onCustomImageUpload:void 0,shortcuts:!0,onChangeTrigger:"both"};function Q(e,t,n){return t=Z(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,en()?Reflect.construct(t,n||[],Z(e).constructor):t.apply(e,n))}function $(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function J(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function X(e,t,n){return t&&J(e.prototype,t),n&&J(e,n),e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&et(e,t)}function et(e,t){return(et=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function en(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(en=function(){return!!e})()}var er=function(e){function t(){return $(this,t),Q(this,t,arguments)}return ee(t,e),X(t,[{key:"getHtml",value:function(){return"string"==typeof this.props.html?this.props.html:this.el.current?this.el.current.innerHTML:""}},{key:"render",value:function(){return"string"==typeof this.props.html?u().createElement("div",{ref:this.el,dangerouslySetInnerHTML:{__html:this.props.html},className:this.props.className||"custom-html-style"}):u().createElement("div",{ref:this.el,className:this.props.className||"custom-html-style"},this.props.html)}}]),t}(function(e){function t(e){var n,r;return $(this,t),n=Q(this,t,[e]),r=void 0,"el"in n?Object.defineProperty(n,"el",{value:r,enumerable:!0,configurable:!0,writable:!0}):n.el=r,n.el=u().createRef(),n}return ee(t,e),X(t,[{key:"getElement",value:function(){return this.el.current}},{key:"getHeight",value:function(){return this.el.current?this.el.current.offsetHeight:0}}]),t}(u().Component));function eo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ei(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ea(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function el(e){return(el=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ec(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ea(e,t,n[t])})}return e}function eu(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function es(e,t){return(es=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ef(e){return function(e){if(Array.isArray(e))return eo(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return eo(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eo(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ep(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ep=function(){return!!e})()}var eh=function(e){var t,n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){var t,n,o;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return n=r,o=[e],n=el(n),ea(t=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ep()?Reflect.construct(n,o||[],el(this).constructor):n.apply(this,o)),"config",void 0),ea(t,"emitter",void 0),ea(t,"nodeMdText",u().createRef()),ea(t,"nodeMdPreview",u().createRef()),ea(t,"nodeMdPreviewWrapper",u().createRef()),ea(t,"hasContentChanged",!0),ea(t,"composing",!1),ea(t,"pluginApis",new Map),ea(t,"handleInputScroll",void 0),ea(t,"handlePreviewScroll",void 0),ea(t,"scrollScale",1),ea(t,"isSyncingScroll",!1),ea(t,"shouldSyncScroll","md"),ea(t,"keyboardListeners",[]),t.emitter=new k,t.config=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e);return n.forEach(function(e){(void 0===e?"undefined":G(e))==="object"&&(o=function e(t,n){var r={};return Object.keys(t).forEach(function(o){if(void 0===n[o]){r[o]=t[o];return}if("object"===G(n[o])){if(Array.isArray(n[o])){var i;r[o]=function(e){if(Array.isArray(e))return z(e)}(i=n[o])||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e,t){if(e){if("string"==typeof e)return z(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,void 0)}}(i)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}else r[o]=e(t[o],n[o]);return}r[o]=n[o]}),r}(o,e))}),o}(Y,t.props.config,t.props),t.state={text:(t.props.value||t.props.defaultValue||"").replace(/↵/g,"\n"),html:"",view:t.config.view||Y.view,fullScreen:!1,plugins:t.getPlugins()},t.config.canView&&!t.config.canView.menu&&(t.state.view.menu=!1),t.nodeMdText=u().createRef(),t.nodeMdPreviewWrapper=u().createRef(),t.handleChange=t.handleChange.bind(t),t.handlePaste=t.handlePaste.bind(t),t.handleDrop=t.handleDrop.bind(t),t.handleToggleMenu=t.handleToggleMenu.bind(t),t.handleKeyDown=t.handleKeyDown.bind(t),t.handleEditorKeyDown=t.handleEditorKeyDown.bind(t),t.handleLocaleUpdate=t.handleLocaleUpdate.bind(t),t.handleFocus=t.handleFocus.bind(t),t.handleBlur=t.handleBlur.bind(t),t.handleInputScroll=t.handleSyncScroll.bind(t,"md"),t.handlePreviewScroll=t.handleSyncScroll.bind(t,"html"),t}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&es(r,e),t=[{key:"componentDidMount",value:function(){var e=this.state.text;this.renderHTML(e),_.on(_.EVENT_LANG_CHANGE,this.handleLocaleUpdate),S.setUp()}},{key:"componentWillUnmount",value:function(){_.off(_.EVENT_LANG_CHANGE,this.handleLocaleUpdate)}},{key:"componentDidUpdate",value:function(e){if(void 0!==this.props.value&&this.props.value!==this.state.text){var t=this.props.value;"string"!=typeof t&&(t=String(t).toString()),t=t.replace(/↵/g,"\n"),this.state.text!==t&&(this.setState({text:t}),this.renderHTML(t))}e.plugins!==this.props.plugins&&this.setState({plugins:this.getPlugins()})}},{key:"isComposing",value:function(){return this.composing}},{key:"getPlugins",value:function(){var e=this,t=[];if(this.props.plugins){var n=function(e){if(e===V.pluginName)return void t.push([V,{}]);var n=!0,o=!1,i=void 0;try{for(var a,l=r.plugins[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){var c=a.value;if(c[0].pluginName===e)return void t.push(c)}}catch(e){o=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw i}}},o=!0,i=!1,a=void 0;try{for(var l,c=this.props.plugins[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var s=l.value;"fonts"===s?(n("font-bold"),n("font-italic"),n("font-underline"),n("font-strikethrough"),n("list-unordered"),n("list-ordered"),n("block-quote"),n("block-wrap"),n("block-code-inline"),n("block-code-block")):n(s)}}catch(e){i=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(i)throw a}}}else t=ef(r.plugins);var f={};return t.forEach(function(t){var n,r=t[0],o=r.align,i=void 0===o?"left":o,a=r.pluginName,l=void 0===a?"":a;void 0===f[i]&&(f[i]=[]);var c="divider"===l?d():l;f[i].push(u().createElement(t[0],{editor:e,editorConfig:e.config,config:ec({},t[0].defaultConfig||{},t[1]||{},(null==(n=e.props.pluginConfig)?void 0:n[l])||{}),key:c}))}),f}},{key:"handleSyncScroll",value:function(e,t){var n=this;if(e===this.shouldSyncScroll){this.props.onScroll&&this.props.onScroll(t,e),this.emitter.emit(this.emitter.EVENT_SCROLL,t,e);var r=this.config.syncScrollMode;(void 0===r?[]:r).includes("md"===e?"rightFollowLeft":"leftFollowRight")&&(this.hasContentChanged&&this.nodeMdText.current&&this.nodeMdPreviewWrapper.current&&(this.scrollScale=this.nodeMdText.current.scrollHeight/this.nodeMdPreviewWrapper.current.scrollHeight,this.hasContentChanged=!1),this.isSyncingScroll||(this.isSyncingScroll=!0,requestAnimationFrame(function(){n.nodeMdText.current&&n.nodeMdPreviewWrapper.current&&("md"===e?n.nodeMdPreviewWrapper.current.scrollTop=n.nodeMdText.current.scrollTop/n.scrollScale:n.nodeMdText.current.scrollTop=n.nodeMdPreviewWrapper.current.scrollTop*n.scrollScale),n.isSyncingScroll=!1})))}}},{key:"renderHTML",value:function(e){var t=this;if(!this.props.renderHTML)return console.error("renderHTML props is required!"),Promise.resolve();var n=this.props.renderHTML(e);return L(n)?n.then(function(e){return t.setHtml(e)}):"function"==typeof n?this.setHtml(n()):this.setHtml(n)}},{key:"setHtml",value:function(e){var t=this;return new Promise(function(n){t.setState({html:e},n)})}},{key:"handleToggleMenu",value:function(){this.setView({menu:!this.state.view.menu})}},{key:"handleFocus",value:function(e){var t=this.props.onFocus;t&&t(e),this.emitter.emit(this.emitter.EVENT_FOCUS,e)}},{key:"handleBlur",value:function(e){var t=this.props.onBlur;t&&t(e),this.emitter.emit(this.emitter.EVENT_BLUR,e)}},{key:"handleChange",value:function(e){e.persist();var t=e.target.value;this.setText(t,e)}},{key:"handlePaste",value:function(e){if(this.config.allowPasteImage&&this.config.onImageUpload){var t=(e.nativeEvent.clipboardData||window.clipboardData).items;t&&(e.preventDefault(),this.uploadWithDataTransfer(t))}}},{key:"handleDrop",value:function(e){if(this.config.onImageUpload){var t=e.nativeEvent;if(t.dataTransfer){var n=t.dataTransfer.items;n&&(e.preventDefault(),this.uploadWithDataTransfer(n))}}}},{key:"handleEditorKeyDown",value:function(e){var t=this,n=e.keyCode,r=e.key,o=e.currentTarget;if((13===n||"Enter"===r)&&!1===this.composing){var i=o.value,a=o.selectionStart,l=B(i,a),c=function(){var n=o.value.substr(0,a-l.curLine.length)+o.value.substr(a);t.setText(n,void 0,{start:a-l.curLine.length,end:a-l.curLine.length}),e.preventDefault()},u=function(n){t.insertText("\n".concat(n),!1,{start:n.length+1,end:n.length+1}),e.preventDefault()},s=l.curLine.match(/^(\s*?)\* /);if(s)return/^(\s*?)\* $/.test(l.curLine)?void c():void u(s[0]);var f=l.curLine.match(/^(\s*?)(\d+)\. /);if(f)return/^(\s*?)(\d+)\. $/.test(l.curLine)?void c():void u("".concat(f[1]).concat(parseInt(f[2],10)+1,". "))}this.emitter.emit(this.emitter.EVENT_EDITOR_KEY_DOWN,e)}},{key:"handleLocaleUpdate",value:function(){this.forceUpdate()}},{key:"getMdElement",value:function(){return this.nodeMdText.current}},{key:"getHtmlElement",value:function(){return this.nodeMdPreviewWrapper.current}},{key:"clearSelection",value:function(){this.nodeMdText.current&&this.nodeMdText.current.setSelectionRange(0,0,"none")}},{key:"getSelection",value:function(){var e=this.nodeMdText.current;if(!e)return ec({},I);var t=e.selectionStart,n=e.selectionEnd,r=(e.value||"").slice(t,n);return{start:t,end:n,text:r}}},{key:"setSelection",value:function(e){this.nodeMdText.current&&(this.nodeMdText.current.setSelectionRange(e.start,e.end,"forward"),this.nodeMdText.current.focus())}},{key:"insertMarkdown",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getSelection(),r=t?ec({},t):{};if("image"===e&&(r=eu(ec({},r),{target:t.target||n.text||"",imageUrl:t.imageUrl||this.config.imageUrl})),"link"===e&&(r=eu(ec({},r),{linkUrl:this.config.linkUrl})),"tab"===e&&n.start!==n.end){var o=this.getMdValue().slice(0,n.start).lastIndexOf("\n")+1;this.setSelection({start:o,end:n.end})}var i=W(n.text,e,r),a=i.text,l=i.selection;if(i.newBlock){var c=B(this.getMdValue(),n.start),u=c.col,s=c.curLine;u>0&&s.length>0&&(a="\n".concat(a),l&&(l.start++,l.end++));var f=c.afterText;n.start!==n.end&&(f=B(this.getMdValue(),n.end).afterText),""!==f.trim()&&"\n\n"!==f.substr(0,2)&&("\n"!==f.substr(0,1)&&(a+="\n"),a+="\n")}this.insertText(a,!0,l)}},{key:"insertPlaceholder",value:function(e,t){var n=this;this.insertText(e,!0),t.then(function(t){var r=n.getMdValue().replace(e,t);n.setText(r)})}},{key:"insertText",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=this.state.text,o=this.getSelection(),i=r.slice(0,o.start),a=r.slice(t?o.end:o.start,r.length);this.setText(i+e+a,void 0,n?{start:n.start+i.length,end:n.end+i.length}:{start:o.start,end:o.start})}},{key:"setText",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,o=this.config.onChangeTrigger,i=void 0===o?"both":o,a=t.replace(/↵/g,"\n");if(this.state.text!==t){this.setState({text:a}),this.props.onChange&&("both"===i||"beforeRender"===i)&&this.props.onChange({text:a,html:this.getHtmlValue()},n),this.emitter.emit(this.emitter.EVENT_CHANGE,t,n,void 0===n),r&&setTimeout(function(){return e.setSelection(r)}),this.hasContentChanged||(this.hasContentChanged=!0);var l=this.renderHTML(a);("both"===i||"afterRender"===i)&&l.then(function(){e.props.onChange&&e.props.onChange({text:e.state.text,html:e.getHtmlValue()},n)})}}},{key:"getMdValue",value:function(){return this.state.text}},{key:"getHtmlValue",value:function(){return"string"==typeof this.state.html?this.state.html:this.nodeMdPreview.current?this.nodeMdPreview.current.getHtml():""}},{key:"onKeyboard",value:function(e){var t=this;Array.isArray(e)?e.forEach(function(e){return t.onKeyboard(e)}):this.keyboardListeners.includes(e)||this.keyboardListeners.push(e)}},{key:"offKeyboard",value:function(e){var t=this;if(Array.isArray(e))return void e.forEach(function(e){return t.offKeyboard(e)});var n=this.keyboardListeners.indexOf(e);n>=0&&this.keyboardListeners.splice(n,1)}},{key:"handleKeyDown",value:function(e){var t=!0,n=!1,r=void 0;try{for(var o,i=this.keyboardListeners[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;if(function(e,t){var n=t.withKey,r=t.keyCode,o=t.key,i=t.aliasCommand,a={ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey,keyCode:e.keyCode,key:e.key};if(i&&(a.ctrlKey=a.ctrlKey||a.metaKey),n&&n.length>0){var l=!0,c=!1,u=void 0;try{for(var s,f=n[Symbol.iterator]();!(l=(s=f.next()).done);l=!0){var p=s.value;if(void 0!==a[p]&&!a[p])return!1}}catch(e){c=!0,u=e}finally{try{l||null==f.return||f.return()}finally{if(c)throw u}}}else if(a.metaKey||a.ctrlKey||a.shiftKey||a.altKey)return!1;return a.key?a.key===o:a.keyCode===r}(e,a)){e.preventDefault(),a.callback(e);return}}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}this.emitter.emit(this.emitter.EVENT_KEY_DOWN,e)}},{key:"getEventType",value:function(e){switch(e){case"change":return this.emitter.EVENT_CHANGE;case"fullscreen":return this.emitter.EVENT_FULL_SCREEN;case"viewchange":return this.emitter.EVENT_VIEW_CHANGE;case"keydown":return this.emitter.EVENT_KEY_DOWN;case"editor_keydown":return this.emitter.EVENT_EDITOR_KEY_DOWN;case"blur":return this.emitter.EVENT_BLUR;case"focus":return this.emitter.EVENT_FOCUS;case"scroll":return this.emitter.EVENT_SCROLL}}},{key:"on",value:function(e,t){var n=this.getEventType(e);n&&this.emitter.on(n,t)}},{key:"off",value:function(e,t){var n=this.getEventType(e);n&&this.emitter.off(n,t)}},{key:"setView",value:function(e){var t=this,n=ec({},this.state.view,e);this.setState({view:n},function(){t.emitter.emit(t.emitter.EVENT_VIEW_CHANGE,n)})}},{key:"getView",value:function(){return ec({},this.state.view)}},{key:"fullScreen",value:function(e){var t=this;this.state.fullScreen!==e&&this.setState({fullScreen:e},function(){t.emitter.emit(t.emitter.EVENT_FULL_SCREEN,e)})}},{key:"registerPluginApi",value:function(e,t){this.pluginApis.set(e,t)}},{key:"unregisterPluginApi",value:function(e){this.pluginApis.delete(e)}},{key:"callPluginApi",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=this.pluginApis.get(e);if(!o)throw Error("API ".concat(e," not found"));return o.apply(void 0,ef(n))}},{key:"isFullScreen",value:function(){return this.state.fullScreen}},{key:"uploadWithDataTransfer",value:function(e){var t=this,n=this.config.onImageUpload;if(n){var r=[];Array.prototype.forEach.call(e,function(e){if("file"===e.kind&&e.type.includes("image")){var o=e.getAsFile();if(o){var i=q(o,n);r.push(Promise.resolve(i.placeholder)),i.uploaded.then(function(e){var n=t.getMdValue().replace(i.placeholder,e),r=e.length-i.placeholder.length,o=t.getSelection();t.setText(n,void 0,{start:o.start+r,end:o.start+r})})}}else"string"===e.kind&&0===e.type.indexOf("text/")&&r.push(new Promise(function(t){return e.getAsString(t)}))}),Promise.all(r).then(function(e){var n=e.join(""),r=t.getSelection();t.insertText(n,!0,{start:r.start===r.end?n.length:0,end:n.length})})}}},{key:"render",value:function(){var e=this,t=this.state,n=t.view,r=t.fullScreen,o=t.text,i=t.html,a=this.props,l=a.id,c=a.className,s=a.style,f=a.name,p=a.autoFocus,h=a.placeholder,d=a.readOnly,m=this.config.canView,g=(null==m?void 0:m.hideMenu)&&(null==m?void 0:m.menu),w=function(t){return e.state.plugins[t]||[]},O=!!n.menu,k=l?"".concat(l,"_md"):void 0,_=l?"".concat(l,"_html"):void 0;return u().createElement("div",{id:l,className:"rc-md-editor ".concat(r?"full":""," ").concat(void 0===c?"":c),style:s,onKeyDown:this.handleKeyDown,onDrop:this.handleDrop},u().createElement(b,{visible:O,left:w("left"),right:w("right")}),u().createElement("div",{className:"editor-container"},g&&u().createElement(v,null,u().createElement("span",{className:"button button-type-menu",title:O?"hidden menu":"show menu",onClick:this.handleToggleMenu},u().createElement(y,{type:"expand-".concat(O?"less":"more")}))),u().createElement("section",{className:"section sec-md ".concat(n.md?"visible":"in-visible")},u().createElement("textarea",{id:k,ref:this.nodeMdText,name:void 0===f?"textarea":f,autoFocus:p,placeholder:h,readOnly:d,value:o,className:"section-container input ".concat(this.config.markdownClass||""),wrap:"hard",onChange:this.handleChange,onScroll:this.handleInputScroll,onMouseOver:function(){return e.shouldSyncScroll="md"},onKeyDown:this.handleEditorKeyDown,onCompositionStart:function(){return e.composing=!0},onCompositionEnd:function(){return e.composing=!1},onPaste:this.handlePaste,onFocus:this.handleFocus,onBlur:this.handleBlur})),u().createElement("section",{className:"section sec-html ".concat(n.html?"visible":"in-visible")},u().createElement("div",{id:_,className:"section-container html-wrap",ref:this.nodeMdPreviewWrapper,onMouseOver:function(){return e.shouldSyncScroll="html"},onScroll:this.handlePreviewScroll},u().createElement(er,{html:i,className:this.config.htmlClass,ref:this.nodeMdPreview})))))}}],n=[{key:"use",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0;n<r.plugins.length;n++)if(r.plugins[n][0]===e)return void r.plugins.splice(n,1,[e,t]);r.plugins.push([e,t])}},{key:"unuse",value:function(e){for(var t=0;t<r.plugins.length;t++)if(r.plugins[t][0]===e)return void r.plugins.splice(t,1)}},{key:"unuseAll",value:function(){r.plugins=[]}}],t&&ei(r.prototype,t),n&&ei(r,n),r}(u().Component);ea(eh,"plugins",[]),ea(eh,"register",eh.use.bind(eh)),ea(eh,"unregister",eh.unuse.bind(eh)),ea(eh,"addLocale",S.add.bind(S)),ea(eh,"useLocale",S.setCurrent.bind(S)),ea(eh,"getLocale",S.getCurrent.bind(S));function ed(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ey(e){return(ey=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eb(e,t){return(eb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ev(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ev=function(){return!!e})()}var em=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(e){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=[e],r=ey(r),ed(t=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ev()?Reflect.construct(r,o||[],ey(this).constructor):r.apply(this,o)),"timer",null),ed(t,"useTimer",void 0),t.useTimer=t.getConfig("useTimer")||"u"<typeof requestAnimationFrame,t.handleChange=t.handleChange.bind(t),t.doResize=t.doResize.bind(t),t}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eb(n,e),t=[{key:"doResize",value:function(){var e=this,t=function(t){t.style.height="auto";var n=Math.min(Math.max(e.getConfig("min"),t.scrollHeight),e.getConfig("max"));return t.style.height="".concat(n,"px"),n};this.timer=null;var n=this.editor.getView(),r=this.editor.getMdElement(),o=this.editor.getHtmlElement();if(r&&n.md){var i=t(r);o&&(o.style.height="".concat(i,"px"));return}o&&n.html&&t(o)}},{key:"handleChange",value:function(){if(null===this.timer){if(this.useTimer){this.timer=window.setTimeout(this.doResize);return}this.timer=requestAnimationFrame(this.doResize)}}},{key:"componentDidMount",value:function(){this.editor.on("change",this.handleChange),this.editor.on("viewchange",this.handleChange),this.handleChange()}},{key:"componentWillUnmount",value:function(){this.editor.off("change",this.handleChange),this.editor.off("viewchange",this.handleChange),null!==this.timer&&this.useTimer&&(window.clearTimeout(this.timer),this.timer=null)}},{key:"render",value:function(){return u().createElement("span",null)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);ed(em,"pluginName","auto-resize"),ed(em,"align","left"),ed(em,"defaultConfig",{min:200,max:1/0,useTimer:!1});function eg(e){return(eg=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ew(e,t){return(ew=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eO(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eO=function(){return!!e})()}var ek=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=eg(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eO()?Reflect.construct(e,t||[],eg(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ew(n,e),t=[{key:"render",value:function(){var e=this;return u().createElement("span",{className:"button button-type-code-block",title:S.get("btnCode"),onClick:function(){return e.editor.insertMarkdown("code")}},u().createElement(y,{type:"code-block"}))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(t="pluginName")in ek?Object.defineProperty(ek,t,{value:"block-code-block",enumerable:!0,configurable:!0,writable:!0}):ek[t]="block-code-block";function e_(e){return(e_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eE(e,t){return(eE=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ej(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ej=function(){return!!e})()}var eC=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=e_(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ej()?Reflect.construct(e,t||[],e_(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eE(n,e),t=[{key:"render",value:function(){var e=this;return u().createElement("span",{className:"button button-type-code-inline",title:S.get("btnInlineCode"),onClick:function(){return e.editor.insertMarkdown("inlinecode")}},u().createElement(y,{type:"code"}))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(n="pluginName")in eC?Object.defineProperty(eC,n,{value:"block-code-inline",enumerable:!0,configurable:!0,writable:!0}):eC[n]="block-code-inline";function eS(e){return(eS=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eP(e,t){return(eP=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eT(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eT=function(){return!!e})()}var ex=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=eS(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eT()?Reflect.construct(e,t||[],eS(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eP(n,e),t=[{key:"render",value:function(){var e=this;return u().createElement("span",{className:"button button-type-quote",title:S.get("btnQuote"),onClick:function(){return e.editor.insertMarkdown("quote")}},u().createElement(y,{type:"quote"}))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(o="pluginName")in ex?Object.defineProperty(ex,o,{value:"block-quote",enumerable:!0,configurable:!0,writable:!0}):ex[o]="block-quote";function eR(e){return(eR=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eM(e,t){return(eM=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eN=function(){return!!e})()}var eK=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=eR(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eN()?Reflect.construct(e,t||[],eR(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eM(n,e),t=[{key:"render",value:function(){var e=this;return u().createElement("span",{className:"button button-type-wrap",title:S.get("btnLineBreak"),onClick:function(){return e.editor.insertMarkdown("hr")}},u().createElement(y,{type:"wrap"}))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(i="pluginName")in eK?Object.defineProperty(eK,i,{value:"block-wrap",enumerable:!0,configurable:!0,writable:!0}):eK[i]="block-wrap";function eU(e){return(eU=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eV(e,t){return(eV=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eI(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eI=function(){return!!e})()}var eL=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(e){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=[e],r=eU(r),(t=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eI()?Reflect.construct(r,o||[],eU(this).constructor):r.apply(this,o))).handleClick=t.handleClick.bind(t),t}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eV(n,e),t=[{key:"handleClick",value:function(){""!==this.editor.getMdValue()&&window.confirm&&"function"==typeof window.confirm&&window.confirm(S.get("clearTip"))&&this.editor.setText("")}},{key:"render",value:function(){return u().createElement("span",{className:"button button-type-clear",title:S.get("btnClear"),onClick:this.handleClick},u().createElement(y,{type:"delete"}))}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(M);(a="pluginName")in eL?Object.defineProperty(eL,a,{value:"clear",enumerable:!0,configurable:!0,writable:!0}):eL[a]="clear";function eB(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eA(e){return(eA=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eD(e,t){return(eD=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eH(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eH=function(){return!!e})()}var eF=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression