owncast/static/admin/_next/static/chunks/1912.40e8274b3898c5b0.js

1 line
No EOL
48 KiB
JavaScript
Vendored

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1912],{26729:function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,a){if("function"!==typeof r)throw new TypeError("The listener must be a function");var l=new i(r,o||e,a),s=n?n+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],l]:e._events[s].push(l):(e._events[s]=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,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},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 i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].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,i,o,a){var l=n?n+e:e;if(!this._events[l])return!1;var s,c,u=this._events[l],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,o),!0;case 6:return u.fn.call(u.context,t,r,i,o,a),!0}for(c=1,s=new Array(h-1);c<h;c++)s[c-1]=arguments[c];u.fn.apply(u.context,s)}else{var d,f=u.length;for(c=0;c<f;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,r);break;case 4:u[c].fn.call(u[c].context,t,r,i);break;default:if(!s)for(d=1,s=new Array(h-1);d<h;d++)s[d-1]=arguments[d];u[c].fn.apply(u[c].context,s)}}return!0},l.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},l.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},l.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var l=this._events[o];if(l.fn)l.fn!==t||i&&!l.once||r&&l.context!==r||a(this,o);else{for(var s=0,c=[],u=l.length;s<u;s++)(l[s].fn!==t||i&&!l[s].once||r&&l[s].context!==r)&&c.push(l[s]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}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},1912:function(e,t,n){n.r(t),n.d(t,{DropList:function(){return le},PluginComponent:function(){return y},Plugins:function(){return Le},default:function(){return Ke},getDecorated:function(){return V}});var r=n(87462),i=n(97326),o=n(89611);function a(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(0,o.Z)(e,t)}var l=n(67294);function s(e){return l.createElement("i",{className:"rmel-iconfont rmel-icon-"+e.type})}function c(e){return l.createElement("div",{className:"rc-md-navigation "+(e.visible?"visible":"in-visible")},l.createElement("div",{className:"navigation-nav left"},l.createElement("div",{className:"button-wrap"},e.left)),l.createElement("div",{className:"navigation-nav right"},l.createElement("div",{className:"button-wrap"},e.right)))}function u(e){return l.createElement("div",{className:"tool-bar",style:e.style},e.children)}var h=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).EVENT_CHANGE="a1",t.EVENT_FULL_SCREEN="a2",t.EVENT_VIEW_CHANGE="a3",t.EVENT_KEY_DOWN="a4",t.EVENT_FOCUS="a5",t.EVENT_BLUR="a6",t.EVENT_SCROLL="a7",t.EVENT_LANG_CHANGE="b1",t}return a(t,e),t}(n(26729).EventEmitter),d=new h,f=h,p={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:"Actually input when typing a Tab key",tab:"Tab",spaces:"Spaces"},m={clearTip:"\u60a8\u786e\u5b9a\u8981\u6e05\u7a7a\u6240\u6709\u5185\u5bb9\u5417\uff1f",btnHeader:"\u6807\u9898",btnClear:"\u6e05\u7a7a",btnBold:"\u52a0\u7c97",btnItalic:"\u659c\u4f53",btnUnderline:"\u4e0b\u5212\u7ebf",btnStrikethrough:"\u5220\u9664\u7ebf",btnUnordered:"\u65e0\u5e8f\u5217\u8868",btnOrdered:"\u6709\u5e8f\u5217\u8868",btnQuote:"\u5f15\u7528",btnLineBreak:"\u6362\u884c",btnInlineCode:"\u884c\u5185\u4ee3\u7801",btnCode:"\u4ee3\u7801\u5757",btnTable:"\u8868\u683c",btnImage:"\u56fe\u7247",btnLink:"\u94fe\u63a5",btnUndo:"\u64a4\u9500",btnRedo:"\u91cd\u505a",btnFullScreen:"\u5168\u5c4f",btnExitFullScreen:"\u9000\u51fa\u5168\u5c4f",btnModeEditor:"\u4ec5\u663e\u793a\u7f16\u8f91\u5668",btnModePreview:"\u4ec5\u663e\u793a\u9884\u89c8",btnModeAll:"\u663e\u793a\u7f16\u8f91\u5668\u4e0e\u9884\u89c8",selectTabMap:"\u6309\u4e0b Tab \u952e\u65f6\u5b9e\u9645\u7684\u8f93\u5165",tab:"\u5236\u8868\u7b26",spaces:"\u7a7a\u683c"},g=new(function(){function e(){this.langs={enUS:p,zhCN:m},this.current="enUS",this.setUp()}var t=e.prototype;return t.setUp=function(){if("undefined"!==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,d.emit(d.EVENT_LANG_CHANGE,this,e,this.langs[e]))}},t.isAvailable=function(e){return"undefined"!==typeof this.langs[e]},t.add=function(e,t){this.langs[e]=t},t.setCurrent=function(e){if(!this.isAvailable(e))throw new Error("Language "+e+" is not exists");this.current!==e&&(this.current=e,d.emit(d.EVENT_LANG_CHANGE,this,e,this.langs[e]))},t.get=function(e,t){var n=this.langs[this.current][e]||"";return t&&Object.keys(t).forEach((function(e){n=n.replace(new RegExp("\\{"+e+"\\}","g"),t[e])})),n},t.getCurrent=function(){return this.current},e}()),v=n(43144),y=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.getConfig=function(e,t){return"undefined"!==typeof this.props.config[e]&&null!==this.props.config[e]?this.props.config[e]:t},(0,v.Z)(t,[{key:"editor",get:function(){return this.props.editor}},{key:"editorConfig",get:function(){return this.props.editorConfig}}]),t}(l.Component);y.pluginName="",y.align="left",y.defaultConfig={};var b=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.render=function(){return l.createElement("span",{className:"rc-md-divider"})},t}(y);b.pluginName="divider";var w={start:0,end:0,text:""};function C(e,t){var n="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"===typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(e,t)}(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function k(e){return e&&(e instanceof Promise||("object"===typeof e||"function"===typeof e)&&"function"===typeof e.then)}function S(e,t){for(var n="",r=t;r--;)n+=e;return n}function M(e,t){var n=t.withKey,r=t.keyCode,i=t.key,o=t.aliasCommand,a={ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey,keyCode:e.keyCode,key:e.key};if(o&&(a.ctrlKey=a.ctrlKey||a.metaKey),n&&n.length>0)for(var l,s=C(n);!(l=s()).done;){var c=l.value;if("undefined"!==typeof a[c]&&!a[c])return!1}else if(a.metaKey||a.ctrlKey||a.shiftKey||a.altKey)return!1;return a.key?a.key===i:a.keyCode===r}function T(e,t){var n=e.split("\n"),r=e.substr(0,t).split("\n"),i=r.length,o=r[r.length-1].length,a=n[r.length-1],l=r.length>1?r[r.length-2]:null,s=n.length>r.length?n[r.length]:null;return{line:i,col:o,beforeText:e.substr(0,t),afterText:e.substr(t),curLine:a,prevLine:l,nextLine:s}}for(var N={bold:["**","**"],italic:["*","*"],underline:["++","++"],strikethrough:["~~","~~"],quote:["\n> ","\n"],inlinecode:["`","`"],code:["\n```\n","\n```\n"]},x=1;x<=6;x++)N["h"+x]=["\n"+S("#",x)+" ","\n"];function L(e){for(var t=e.row,n=void 0===t?2:t,r=e.col,i=void 0===r?2:r,o=["|"],a=["|"],l=["|"],s="",c=1;c<=i;c++)o.push(" Head |"),l.push(" --- |"),a.push(" Data |");for(var u=1;u<=n;u++)s+="\n"+a.join("");return o.join("")+"\n"+l.join("")+s}function K(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"+r+++". "})).trim():"1. "}function U(e,t){return{text:e,newBlock:t,selection:{start:e.length,end:e.length}}}var _,V=function(e,t,n){if("undefined"!==typeof N[t])return{text:""+N[t][0]+e+N[t][1],selection:{start:N[t][0].length,end:N[t][0].length+e.length}};switch(t){case"tab":var r=1===n.tabMapValue?"\t":" ".repeat(n.tabMapValue),i=r+e.replace(/\n/g,"\n"+r),o=e.includes("\n")?e.match(/\n/g).length:0;return{text:i,selection:{start:n.tabMapValue,end:n.tabMapValue*(o+1)+e.length}};case"unordered":return U(K("unordered",e),!0);case"order":return U(K("order",e),!0);case"hr":return U("---",!0);case"table":return{text:L(n),newBlock:!0};case"image":return{text:"!["+(e||n.target)+"]("+(n.imageUrl||"")+")",selection:{start:2,end:e.length+2}};case"link":return{text:"["+e+"]("+(n.linkUrl||"")+")",selection:{start:1,end:e.length+1}}}return{text:e,selection:{start:0,end:e.length}}};function H(e,t){var n={};return Object.keys(e).forEach((function(r){"undefined"!==typeof t[r]?"object"!==typeof t[r]?n[r]=t[r]:Array.isArray(t[r])?n[r]=[].concat(t[r]):n[r]=H(e[r],t[r]):n[r]=e[r]})),n}var I=new Uint8Array(16);function A(){if(!_&&!(_="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!==typeof msCrypto&&"function"===typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _(I)}var O=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var D=function(e){return"string"===typeof e&&O.test(e)},R=[],W=0;W<256;++W)R.push((W+256).toString(16).substr(1));var P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase();if(!D(n))throw TypeError("Stringified UUID is invalid");return n};var Z=function(e,t,n){var r=(e=e||{}).random||(e.rng||A)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return P(r)};var F=function(e,t){return{placeholder:V("","image",{target:"Uploading_"+Z(),imageUrl:""}).text,uploaded:new Promise((function(n){var r=!0,i=function(t){r&&console.warn("Deprecated: onImageUpload should return a Promise, callback will be removed in future"),n(V("","image",{target:e.name,imageUrl:t}).text)},o=t(e,i);k(o)&&(r=!1,o.then(i))}))}},B={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:"",table:{maxRow:4,maxCol:6},allowPasteImage:!0,onImageUpload:void 0,onCustomImageUpload:void 0,shortcuts:!0},j=function(e){function t(){return e.apply(this,arguments)||this}a(t,e);var n=t.prototype;return n.getHtml=function(){return"string"===typeof this.props.html?this.props.html:this.el.current?this.el.current.innerHTML:""},n.render=function(){return"string"===typeof this.props.html?l.createElement("div",{ref:this.el,dangerouslySetInnerHTML:{__html:this.props.html},className:this.props.className||"custom-html-style"}):l.createElement("div",{ref:this.el,className:this.props.className||"custom-html-style"},this.props.html)},t}(function(e){function t(t){var n;return(n=e.call(this,t)||this).el=l.createRef(),n}a(t,e);var n=t.prototype;return n.getElement=function(){return this.el.current},n.getHeight=function(){return this.el.current?this.el.current.offsetHeight:0},t}(l.Component));function G(e,t){var n="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"===typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,t)}(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var q=function(e){function t(t){var n;return(n=e.call(this,t)||this).nodeMdText=l.createRef(),n.nodeMdPreview=l.createRef(),n.nodeMdPreviewWrapper=l.createRef(),n.hasContentChanged=!0,n.composing=!1,n.scrollScale=1,n.isSyncingScroll=!1,n.shouldSyncScroll="md",n.keyboardListeners=[],n.emitter=new f,n.config=function(e){for(var t=(0,r.Z)({},e),n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i.forEach((function(e){"object"===typeof e&&(t=H(t,e))})),t}(B,n.props.config,n.props),n.state={text:(n.props.value||n.props.defaultValue||"").replace(/\u21b5/g,"\n"),html:"",view:n.config.view||B.view,fullScreen:!1,plugins:n.getPlugins()},n.config.canView&&!n.config.canView.menu&&(n.state.view.menu=!1),n.nodeMdText=l.createRef(),n.nodeMdPreviewWrapper=l.createRef(),n.handleChange=n.handleChange.bind((0,i.Z)(n)),n.handlePaste=n.handlePaste.bind((0,i.Z)(n)),n.handleDrop=n.handleDrop.bind((0,i.Z)(n)),n.handleToggleMenu=n.handleToggleMenu.bind((0,i.Z)(n)),n.handleKeyDown=n.handleKeyDown.bind((0,i.Z)(n)),n.handleEditorKeyDown=n.handleEditorKeyDown.bind((0,i.Z)(n)),n.handleLocaleUpdate=n.handleLocaleUpdate.bind((0,i.Z)(n)),n.handleFocus=n.handleFocus.bind((0,i.Z)(n)),n.handleBlur=n.handleBlur.bind((0,i.Z)(n)),n.handleInputScroll=n.handleSyncScroll.bind((0,i.Z)(n),"md"),n.handlePreviewScroll=n.handleSyncScroll.bind((0,i.Z)(n),"html"),n}a(t,e),t.use=function(e,n){void 0===n&&(n={});for(var r=0;r<t.plugins.length;r++)if(t.plugins[r].comp===e)return void t.plugins.splice(r,1,{comp:e,config:n});t.plugins.push({comp:e,config:n})},t.unuse=function(e){for(var n=0;n<t.plugins.length;n++)if(t.plugins[n].comp===e)return void t.plugins.splice(n,1)},t.unuseAll=function(){t.plugins=[]};var n=t.prototype;return n.componentDidMount=function(){var e=this.state.text;this.renderHTML(e),d.on(d.EVENT_LANG_CHANGE,this.handleLocaleUpdate),g.setUp()},n.componentWillUnmount=function(){d.off(d.EVENT_LANG_CHANGE,this.handleLocaleUpdate)},n.componentDidUpdate=function(e){if("undefined"!==typeof this.props.value&&this.props.value!==this.state.text){var t=this.props.value;"string"!==typeof t&&(t=String(t).toString()),t=t.replace(/\u21b5/g,"\n"),this.state.text!==t&&(this.setState({text:t}),this.renderHTML(t))}e.plugins!==this.props.plugins&&this.setState({plugins:this.getPlugins()})},n.getPlugins=function(){var e=this,n=[];if(this.props.plugins)for(var i,o=function(e){if(e!==b.pluginName)for(var r,i=G(t.plugins);!(r=i()).done;){var o=r.value;if(o.comp.pluginName===e)return void n.push(o)}else n.push({comp:b,config:{}})},a=G(this.props.plugins);!(i=a()).done;){var s=i.value;"fonts"===s?(o("font-bold"),o("font-italic"),o("font-underline"),o("font-strikethrough"),o("list-unordered"),o("list-ordered"),o("block-quote"),o("block-wrap"),o("block-code-inline"),o("block-code-block")):o(s)}else n=[].concat(t.plugins);var c={};return n.forEach((function(t){"undefined"===typeof c[t.comp.align]&&(c[t.comp.align]=[]),c[t.comp.align].push(l.createElement(t.comp,{editor:e,editorConfig:e.config,config:(0,r.Z)({},t.comp.defaultConfig||{},t.config||{}),key:t.comp.pluginName}))})),c},n.handleSyncScroll=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}))))}},n.renderHTML=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 k(n)?n.then((function(e){return t.setHtml(e)})):"function"===typeof n?this.setHtml(n()):this.setHtml(n)},n.setHtml=function(e){var t=this;return new Promise((function(n){t.setState({html:e},n)}))},n.handleToggleMenu=function(){this.setView({menu:!this.state.view.menu})},n.handleFocus=function(e){var t=this.props.onFocus;t&&t(e),this.emitter.emit(this.emitter.EVENT_FOCUS,e)},n.handleBlur=function(e){var t=this.props.onBlur;t&&t(e),this.emitter.emit(this.emitter.EVENT_BLUR,e)},n.handleChange=function(e){e.persist();var t=e.target.value;this.setText(t,e)},n.handlePaste=function(e){if(this.config.allowPasteImage&&this.config.onImageUpload){var t=(e.nativeEvent.clipboardData||window.clipboardData).items;t&&(e.preventDefault(),this.uploadWithDataTransfer(t))}},n.handleDrop=function(e){if(this.config.onImageUpload){var t=e.nativeEvent;if(t.dataTransfer){var n=t.dataTransfer.items;n&&(e.preventDefault(),this.uploadWithDataTransfer(n))}}},n.handleEditorKeyDown=function(e){var t=this,n=e.keyCode,r=e.key,i=e.currentTarget;if((13===n||"Enter"===r)&&!1===this.composing){var o=e.currentTarget.value,a=i.selectionStart,l=T(o,a),s=function(){var n=i.value.substr(0,a-l.curLine.length)+i.value.substr(a);t.setText(n,void 0,{start:a-l.curLine.length,end:a-l.curLine.length}),e.preventDefault()},c=function(n){t.insertText("\n"+n,!1,{start:n.length+1,end:n.length+1}),e.preventDefault()},u=l.curLine.match(/^(\s?)([-*]) /);if(u)return/^(\s?)([-*]) $/.test(l.curLine)?void s():void c(u[0]);var h=l.curLine.match(/^(\s?)(\d+)\. /);if(h){if(/^(\s?)(\d+)\. $/.test(l.curLine))return void s();c(""+h[1]+(parseInt(h[2],10)+1)+". ")}}},n.handleLocaleUpdate=function(){this.forceUpdate()},n.getMdElement=function(){return this.nodeMdText.current},n.getHtmlElement=function(){return this.nodeMdPreviewWrapper.current},n.clearSelection=function(){this.nodeMdText.current&&this.nodeMdText.current.setSelectionRange(0,0,"none")},n.getSelection=function(){var e=this.nodeMdText.current;if(!e)return(0,r.Z)({},w);var t=e.selectionStart,n=e.selectionEnd;return{start:t,end:n,text:(e.value||"").slice(t,n)}},n.setSelection=function(e){this.nodeMdText.current&&(this.nodeMdText.current.setSelectionRange(e.start,e.end,"forward"),this.nodeMdText.current.focus())},n.insertMarkdown=function(e,t){void 0===t&&(t={});var n=this.getSelection(),i=t?(0,r.Z)({},t):{};if("image"===e&&(i=(0,r.Z)({},i,{target:t.target||n.text||"",imageUrl:t.imageUrl||this.config.imageUrl})),"link"===e&&(i=(0,r.Z)({},i,{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 a=V(n.text,e,i),l=a.text,s=a.selection;if(a.newBlock){var c=T(this.getMdValue(),n.start),u=c.col,h=c.curLine;u>0&&h.length>0&&(l="\n"+l,s&&(s.start++,s.end++));var d=c.afterText;n.start!==n.end&&(d=T(this.getMdValue(),n.end).afterText),""!==d.trim()&&"\n\n"!==d.substr(0,2)&&("\n"!==d.substr(0,1)&&(l+="\n"),l+="\n")}this.insertText(l,!0,s)},n.insertPlaceholder=function(e,t){var n=this;this.insertText(e,!0),t.then((function(t){var r=n.getMdValue().replace(e,t);n.setText(r)}))},n.insertText=function(e,t,n){void 0===e&&(e=""),void 0===t&&(t=!1);var r=this.state.text,i=this.getSelection(),o=r.slice(0,i.start),a=r.slice(t?i.end:i.start,r.length);this.setText(o+e+a,void 0,n?{start:n.start+o.length,end:n.end+o.length}:{start:i.start,end:i.start})},n.setText=function(e,t,n){var r=this;void 0===e&&(e="");var i=this.config.onChangeTrigger,o=void 0===i?"both":i,a=e.replace(/\u21b5/g,"\n");if(this.state.text!==e){this.setState({text:a}),!this.props.onChange||"both"!==o&&"beforeRender"!==o||this.props.onChange({text:a,html:this.getHtmlValue()},t),this.emitter.emit(this.emitter.EVENT_CHANGE,e,t,"undefined"===typeof t),n&&setTimeout((function(){return r.setSelection(n)})),this.hasContentChanged||(this.hasContentChanged=!0);var l=this.renderHTML(a);"both"!==o&&"afterRender"!==o||l.then((function(){r.props.onChange&&r.props.onChange({text:r.state.text,html:r.getHtmlValue()},t)}))}},n.getMdValue=function(){return this.state.text},n.getHtmlValue=function(){return"string"===typeof this.state.html?this.state.html:this.nodeMdPreview.current?this.nodeMdPreview.current.getHtml():""},n.onKeyboard=function(e){var t=this;Array.isArray(e)?e.forEach((function(e){return t.onKeyboard(e)})):this.keyboardListeners.includes(e)||this.keyboardListeners.push(e)},n.offKeyboard=function(e){var t=this;if(Array.isArray(e))e.forEach((function(e){return t.offKeyboard(e)}));else{var n=this.keyboardListeners.indexOf(e);n>=0&&this.keyboardListeners.splice(n,1)}},n.handleKeyDown=function(e){for(var t,n=G(this.keyboardListeners);!(t=n()).done;){var r=t.value;if(M(e,r))return e.preventDefault(),void r.callback(e)}this.emitter.emit(this.emitter.EVENT_KEY_DOWN,e)},n.getEventType=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"blur":return this.emitter.EVENT_BLUR;case"focus":return this.emitter.EVENT_FOCUS;case"scroll":return this.emitter.EVENT_SCROLL}},n.on=function(e,t){var n=this.getEventType(e);n&&this.emitter.on(n,t)},n.off=function(e,t){var n=this.getEventType(e);n&&this.emitter.off(n,t)},n.setView=function(e){var t=this,n=(0,r.Z)({},this.state.view,e);this.setState({view:n},(function(){t.emitter.emit(t.emitter.EVENT_VIEW_CHANGE,n)}))},n.getView=function(){return(0,r.Z)({},this.state.view)},n.fullScreen=function(e){var t=this;this.state.fullScreen!==e&&this.setState({fullScreen:e},(function(){t.emitter.emit(t.emitter.EVENT_FULL_SCREEN,e)}))},n.isFullScreen=function(){return this.state.fullScreen},n.uploadWithDataTransfer=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 i=e.getAsFile();if(i){var o=F(i,n);r.push(Promise.resolve(o.placeholder)),o.uploaded.then((function(e){var n=t.getMdValue().replace(o.placeholder,e),r=e.length-o.placeholder.length,i=t.getSelection();t.setText(n,void 0,{start:i.start+r,end:i.start+r})}))}}else"string"===e.kind&&"text/plain"===e.type&&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})}))}},n.render=function(){var e=this,t=this.state,n=t.view,r=t.fullScreen,i=t.text,o=t.html,a=this.props,h=a.id,d=a.className,f=void 0===d?"":d,p=a.style,m=a.name,g=void 0===m?"textarea":m,v=a.autoFocus,y=a.placeholder,b=a.readOnly,w=this.config.canView&&this.config.canView.hideMenu&&!this.config.canView.menu,C=function(t){return e.state.plugins[t]||[]},E=!!n.menu,k=h?h+"_md":void 0,S=h?h+"_html":void 0;return l.createElement("div",{id:h,className:"rc-md-editor "+(r?"full":"")+" "+f,style:p,onKeyDown:this.handleKeyDown,onDrop:this.handleDrop},l.createElement(c,{visible:E,left:C("left"),right:C("right")}),l.createElement("div",{className:"editor-container"},w&&l.createElement(u,null,l.createElement("span",{className:"button button-type-menu",title:E?"hidden menu":"show menu",onClick:this.handleToggleMenu},l.createElement(s,{type:"expand-"+(E?"less":"more")}))),l.createElement("section",{className:"section sec-md "+(n.md?"visible":"in-visible")},l.createElement("textarea",{id:k,ref:this.nodeMdText,name:g,autoFocus:v,placeholder:y,readOnly:b,value:i,className:"section-container input "+(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})),l.createElement("section",{className:"section sec-html "+(n.html?"visible":"in-visible")},l.createElement("div",{id:S,className:"section-container html-wrap",ref:this.nodeMdPreviewWrapper,onMouseOver:function(){return e.shouldSyncScroll="html"},onScroll:this.handlePreviewScroll},l.createElement(j,{html:o,className:this.config.htmlClass,ref:this.nodeMdPreview})))))},t}(l.Component);q.plugins=[],q.addLocale=g.add.bind(g),q.useLocale=g.setCurrent.bind(g),q.getLocale=g.getCurrent.bind(g);var Q=q,$=function(e){function t(t){var n;return(n=e.call(this,t)||this).timer=null,n.useTimer=n.getConfig("useTimer")||"undefined"===typeof requestAnimationFrame,n.handleChange=n.handleChange.bind((0,i.Z)(n)),n.doResize=n.doResize.bind((0,i.Z)(n)),n}a(t,e);var n=t.prototype;return n.doResize=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=n+"px",n};this.timer=null;var n=this.editor.getView(),r=this.editor.getMdElement(),i=this.editor.getHtmlElement();if(r&&n.md){var o=t(r);i&&(i.style.height=o+"px")}else i&&n.html&&t(i)},n.handleChange=function(){null===this.timer&&(this.useTimer?this.timer=window.setTimeout(this.doResize):this.timer=requestAnimationFrame(this.doResize))},n.componentDidMount=function(){this.editor.on("change",this.handleChange),this.editor.on("viewchange",this.handleChange),this.handleChange()},n.componentWillUnmount=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)},n.render=function(){return l.createElement("span",null)},t}(y);$.pluginName="auto-resize",$.align="left",$.defaultConfig={min:200,max:1/0,useTimer:!1};var Y=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.render=function(){var e=this;return l.createElement("span",{className:"button button-type-code-block",title:g.get("btnCode"),onClick:function(){return e.editor.insertMarkdown("code")}},l.createElement(s,{type:"code-block"}))},t}(y);Y.pluginName="block-code-block";var J=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.render=function(){var e=this;return l.createElement("span",{className:"button button-type-code-inline",title:g.get("btnInlineCode"),onClick:function(){return e.editor.insertMarkdown("inlinecode")}},l.createElement(s,{type:"code"}))},t}(y);J.pluginName="block-code-inline";var X=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.render=function(){var e=this;return l.createElement("span",{className:"button button-type-quote",title:g.get("btnQuote"),onClick:function(){return e.editor.insertMarkdown("quote")}},l.createElement(s,{type:"quote"}))},t}(y);X.pluginName="block-quote";var ee=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t.prototype.render=function(){var e=this;return l.createElement("span",{className:"button button-type-wrap",title:g.get("btnLineBreak"),onClick:function(){return e.editor.insertMarkdown("hr")}},l.createElement(s,{type:"wrap"}))},t}(y);ee.pluginName="block-wrap";var te=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleClick=n.handleClick.bind((0,i.Z)(n)),n}a(t,e);var n=t.prototype;return n.handleClick=function(){""!==this.editor.getMdValue()&&(window.confirm&&"function"===typeof window.confirm&&window.confirm(g.get("clearTip"))&&this.editor.setText(""))},n.render=function(){return l.createElement("span",{className:"button button-type-clear",title:g.get("btnClear"),onClick:this.handleClick},l.createElement(s,{type:"delete"}))},t}(y);te.pluginName="clear";var ne=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"b",keyCode:66,aliasCommand:!0,withKey:["ctrlKey"],callback:function(){return n.editor.insertMarkdown("bold")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-bold",title:g.get("btnBold"),onClick:function(){return e.editor.insertMarkdown("bold")}},l.createElement(s,{type:"bold"}))},t}(y);ne.pluginName="font-bold";var re=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"i",keyCode:73,aliasCommand:!0,withKey:["ctrlKey"],callback:function(){return n.editor.insertMarkdown("italic")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-italic",title:g.get("btnItalic"),onClick:function(){return e.editor.insertMarkdown("italic")}},l.createElement(s,{type:"italic"}))},t}(y);re.pluginName="font-italic";var ie=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"d",keyCode:68,aliasCommand:!0,withKey:["ctrlKey"],callback:function(){return n.editor.insertMarkdown("strikethrough")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-strikethrough",title:g.get("btnStrikethrough"),onClick:function(){return e.editor.insertMarkdown("strikethrough")}},l.createElement(s,{type:"strikethrough"}))},t}(y);ie.pluginName="font-strikethrough";var oe=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"u",keyCode:85,withKey:["ctrlKey"],callback:function(){return n.editor.insertMarkdown("underline")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-underline",title:g.get("btnUnderline"),onClick:function(){return e.editor.insertMarkdown("underline")}},l.createElement(s,{type:"underline"}))},t}(y);oe.pluginName="font-underline";var ae=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleClick=n.handleClick.bind((0,i.Z)(n)),n.handleChange=n.handleChange.bind((0,i.Z)(n)),n.state={enable:n.editor.isFullScreen()},n}a(t,e);var n=t.prototype;return n.handleClick=function(){this.editor.fullScreen(!this.state.enable)},n.handleChange=function(e){this.setState({enable:e})},n.componentDidMount=function(){this.editor.on("fullscreen",this.handleChange)},n.componentWillUnmount=function(){this.editor.off("fullscreen",this.handleChange)},n.render=function(){if(this.editorConfig.canView&&this.editorConfig.canView.fullScreen){var e=this.state.enable;return l.createElement("span",{className:"button button-type-fullscreen",title:g.get(e?"btnExitFullScreen":"btnFullScreen"),onClick:this.handleClick},l.createElement(s,{type:e?"fullscreen-exit":"fullscreen"}))}return null},t}(y);ae.pluginName="full-screen",ae.align="right";var le=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleClose=n.handleClose.bind((0,i.Z)(n)),n}a(t,e);var n=t.prototype;return n.handleClose=function(e){e.stopPropagation();var t=this.props.onClose;"function"===typeof t&&t()},n.render=function(){return l.createElement("div",{className:"drop-wrap "+(this.props.show?"show":"hidden"),onClick:this.handleClose},this.props.children)},t}(l.Component),se=function(e){function t(){return e.apply(this,arguments)||this}a(t,e);var n=t.prototype;return n.handleHeader=function(e){var t=this.props.onSelectHeader;"function"===typeof t&&t(e)},n.render=function(){return l.createElement("ul",{className:"header-list"},l.createElement("li",{className:"list-item"},l.createElement("h1",{onClick:this.handleHeader.bind(this,"h1")},"H1")),l.createElement("li",{className:"list-item"},l.createElement("h2",{onClick:this.handleHeader.bind(this,"h2")},"H2")),l.createElement("li",{className:"list-item"},l.createElement("h3",{onClick:this.handleHeader.bind(this,"h3")},"H3")),l.createElement("li",{className:"list-item"},l.createElement("h4",{onClick:this.handleHeader.bind(this,"h4")},"H4")),l.createElement("li",{className:"list-item"},l.createElement("h5",{onClick:this.handleHeader.bind(this,"h5")},"H5")),l.createElement("li",{className:"list-item"},l.createElement("h6",{onClick:this.handleHeader.bind(this,"h6")},"H6")))},t}(l.Component),ce=se,ue=function(e){function t(t){var n;return(n=e.call(this,t)||this).show=n.show.bind((0,i.Z)(n)),n.hide=n.hide.bind((0,i.Z)(n)),n.state={show:!1},n}a(t,e);var n=t.prototype;return n.show=function(){this.setState({show:!0})},n.hide=function(){this.setState({show:!1})},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-header",title:g.get("btnHeader"),onMouseEnter:this.show,onMouseLeave:this.hide},l.createElement(s,{type:"font-size"}),l.createElement(le,{show:this.state.show,onClose:this.hide},l.createElement(ce,{onSelectHeader:function(t){return e.editor.insertMarkdown(t)}})))},t}(y);ue.pluginName="header";var he=function(e){function t(t){var n;return(n=e.call(this,t)||this).timerId=void 0,n.locked=!1,n.input=l.createRef(),n}a(t,e);var n=t.prototype;return n.click=function(){var e=this;!this.locked&&this.input.current&&(this.locked=!0,this.input.current.value="",this.input.current.click(),this.timerId&&window.clearTimeout(this.timerId),this.timerId=window.setTimeout((function(){e.locked=!1,window.clearTimeout(e.timerId),e.timerId=void 0}),200))},n.componentWillUnmount=function(){this.timerId&&window.clearTimeout(this.timerId)},n.render=function(){return l.createElement("input",{type:"file",ref:this.input,accept:this.props.accept,style:{position:"absolute",zIndex:-1,left:0,top:0,width:0,height:0,opacity:0},onChange:this.props.onChange})},t}(l.Component),de=function(e){function t(t){var n;return(n=e.call(this,t)||this).inputFile=l.createRef(),n.onImageChanged=n.onImageChanged.bind((0,i.Z)(n)),n.handleCustomImageUpload=n.handleCustomImageUpload.bind((0,i.Z)(n)),n.handleImageUpload=n.handleImageUpload.bind((0,i.Z)(n)),n.state={show:!1},n}a(t,e);var n=t.prototype;return n.handleImageUpload=function(){"function"===typeof this.editorConfig.onImageUpload?this.inputFile.current&&this.inputFile.current.click():this.editor.insertMarkdown("image")},n.onImageChanged=function(e){var t=this.editorConfig.onImageUpload;if(t){var n=F(e,t);this.editor.insertPlaceholder(n.placeholder,n.uploaded)}},n.handleCustomImageUpload=function(e){var t=this,n=this.editorConfig.onCustomImageUpload;if(n){var r=n.call(this,e);k(r)&&r.then((function(e){e&&e.url&&t.editor.insertMarkdown("image",{target:e.text,imageUrl:e.url})}))}},n.render=function(){var e=this;return!!this.editorConfig.onCustomImageUpload?l.createElement("span",{className:"button button-type-image",title:g.get("btnImage"),onClick:this.handleCustomImageUpload},l.createElement(s,{type:"image"})):l.createElement("span",{className:"button button-type-image",title:g.get("btnImage"),onClick:this.handleImageUpload,style:{position:"relative"}},l.createElement(s,{type:"image"}),l.createElement(he,{accept:this.editorConfig.imageAccept||"",ref:this.inputFile,onChange:function(t){t.persist(),t.target.files&&t.target.files.length>0&&e.onImageChanged(t.target.files[0])}}))},t}(y);de.pluginName="image";var fe=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"k",keyCode:75,aliasCommand:!0,withKey:["ctrlKey"],callback:function(){return n.editor.insertMarkdown("link")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-link",title:g.get("btnLink"),onClick:function(){return e.editor.insertMarkdown("link")}},l.createElement(s,{type:"link"}))},t}(y);fe.pluginName="link";var pe=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"7",keyCode:55,withKey:["ctrlKey","shiftKey"],aliasCommand:!0,callback:function(){return n.editor.insertMarkdown("order")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-ordered",title:g.get("btnOrdered"),onClick:function(){return e.editor.insertMarkdown("order")}},l.createElement(s,{type:"list-ordered"}))},t}(y);pe.pluginName="list-ordered";var me=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboard={key:"8",keyCode:56,withKey:["ctrlKey","shiftKey"],aliasCommand:!0,callback:function(){return n.editor.insertMarkdown("unordered")}},n}a(t,e);var n=t.prototype;return n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){var e=this;return l.createElement("span",{className:"button button-type-unordered",title:g.get("btnUnordered"),onClick:function(){return e.editor.insertMarkdown("unordered")}},l.createElement(s,{type:"list-unordered"}))},t}(y);me.pluginName="list-unordered";var ge,ve=function(){function e(){this.record=[],this.recycle=[],this.initValue=""}var t=e.prototype;return t.push=function(e){for(var t=this.record.push(e);this.record.length>100;)this.record.shift();return t},t.get=function(){return this.record},t.getLast=function(){var e=this.record.length;return this.record[e-1]},t.undo=function(e){var t=this.record.pop();if("undefined"===typeof t)return this.initValue;if(t!==e)return this.recycle.push(t),t;var n=this.record.pop();return"undefined"===typeof n?(this.recycle.push(t),this.initValue):(this.recycle.push(t),n)},t.redo=function(){var e=this.recycle.pop();if("undefined"!==typeof e)return this.push(e),e},t.cleanRedo=function(){this.recycle=[]},t.getUndoCount=function(){return this.undo.length},t.getRedoCount=function(){return this.recycle.length},e}(),ye=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleKeyboards=[],n.lastPop=null,n.handleChange=n.handleChange.bind((0,i.Z)(n)),n.handleRedo=n.handleRedo.bind((0,i.Z)(n)),n.handleUndo=n.handleUndo.bind((0,i.Z)(n)),n.handleKeyboards=[{key:"y",keyCode:89,withKey:["ctrlKey"],callback:n.handleRedo},{key:"z",keyCode:90,withKey:["metaKey","shiftKey"],callback:n.handleRedo},{key:"z",keyCode:90,aliasCommand:!0,withKey:["ctrlKey"],callback:n.handleUndo}],n.logger=new ve,n}a(t,e);var n=t.prototype;return n.handleUndo=function(){var e=this.logger.undo(this.editor.getMdValue());"undefined"!==typeof e&&(this.pause(),this.lastPop=e,this.editor.setText(e),this.forceUpdate())},n.handleRedo=function(){var e=this.logger.redo();"undefined"!==typeof e&&(this.lastPop=e,this.editor.setText(e),this.forceUpdate())},n.handleChange=function(e,t,n){var r=this;if(this.logger.getLast()!==e&&(null===this.lastPop||this.lastPop!==e)){if(this.logger.cleanRedo(),n)return this.logger.push(e),this.lastPop=null,void this.forceUpdate();this.timerId&&(window.clearTimeout(this.timerId),this.timerId=0),this.timerId=window.setTimeout((function(){r.logger.getLast()!==e&&(r.logger.push(e),r.lastPop=null,r.forceUpdate()),window.clearTimeout(r.timerId),r.timerId=0}),600)}},n.componentDidMount=function(){var e=this;this.editor.on("change",this.handleChange),this.handleKeyboards.forEach((function(t){return e.editor.onKeyboard(t)})),this.logger.initValue=this.editor.getMdValue(),this.forceUpdate()},n.componentWillUnmount=function(){var e=this;this.timerId&&window.clearTimeout(this.timerId),this.editor.off("change",this.handleChange),this.handleKeyboards.forEach((function(t){return e.editor.offKeyboard(t)}))},n.pause=function(){this.timerId&&(window.clearTimeout(this.timerId),this.timerId=void 0)},n.render=function(){var e=this.logger.getUndoCount()>1||this.logger.initValue!==this.editor.getMdValue(),t=this.logger.getRedoCount()>0;return l.createElement(l.Fragment,null,l.createElement("span",{className:"button button-type-undo "+(e?"":"disabled"),title:g.get("btnUndo"),onClick:this.handleUndo},l.createElement(s,{type:"undo"})),l.createElement("span",{className:"button button-type-redo "+(t?"":"disabled"),title:g.get("btnRedo"),onClick:this.handleRedo},l.createElement(s,{type:"redo"})))},t}(y);ye.pluginName="logger",function(e){e[e.SHOW_ALL=0]="SHOW_ALL",e[e.SHOW_MD=1]="SHOW_MD",e[e.SHOW_HTML=2]="SHOW_HTML"}(ge||(ge={}));var be=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleClick=n.handleClick.bind((0,i.Z)(n)),n.handleChange=n.handleChange.bind((0,i.Z)(n)),n.state={view:n.editor.getView()},n}a(t,e);var n=t.prototype;return n.handleClick=function(){switch(this.next){case ge.SHOW_ALL:this.editor.setView({html:!0,md:!0});break;case ge.SHOW_HTML:this.editor.setView({html:!0,md:!1});break;case ge.SHOW_MD:this.editor.setView({html:!1,md:!0})}},n.handleChange=function(e){this.setState({view:e})},n.componentDidMount=function(){this.editor.on("viewchange",this.handleChange)},n.componentWillUnmount=function(){this.editor.off("viewchange",this.handleChange)},n.getDisplayInfo=function(){switch(this.next){case ge.SHOW_ALL:return{icon:"view-split",title:"All"};case ge.SHOW_HTML:return{icon:"visibility",title:"Preview"};default:return{icon:"keyboard",title:"Editor"}}},n.render=function(){if(this.isDisplay){var e=this.getDisplayInfo();return l.createElement("span",{className:"button button-type-mode",title:g.get("btnMode"+e.title),onClick:this.handleClick},l.createElement(s,{type:e.icon}))}return null},(0,v.Z)(t,[{key:"isDisplay",get:function(){var e=this.editorConfig.canView;return!!e&&[e.html,e.md,e.both].filter((function(e){return e})).length>=2}},{key:"next",get:function(){var e=this.editorConfig.canView,t=this.state.view,n=[ge.SHOW_ALL,ge.SHOW_MD,ge.SHOW_HTML];e&&(e.both||n.splice(n.indexOf(ge.SHOW_ALL),1),e.md||n.splice(n.indexOf(ge.SHOW_MD),1),e.html||n.splice(n.indexOf(ge.SHOW_HTML),1));var r=ge.SHOW_MD;if(t.html&&(r=ge.SHOW_HTML),t.html&&t.md&&(r=ge.SHOW_ALL),0===n.length)return r;if(1===n.length)return n[0];var i=n.indexOf(r);return i<n.length-1?n[i+1]:n[0]}}]),t}(y);be.pluginName="mode-toggle",be.align="right";var we=be,Ce=function(e){function t(t){var n;(n=e.call(this,t)||this).config={padding:3,width:20,height:20};var r=t.maxRow,i=void 0===r?5:r,o=t.maxCol,a=void 0===o?6:o;return n.state={maxRow:i,maxCol:a,list:n.formatTableModel(i,a)},n}a(t,e);var n=t.prototype;return n.formatTableModel=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),new Array(e).fill(void 0).map((function(e){return new Array(t).fill(0)}))},n.calcWrapStyle=function(){var e=this.state,t=e.maxRow,n=e.maxCol,r=this.config,i=r.width,o=r.height,a=r.padding;return{width:(i+a)*n-a+"px",height:(o+a)*t-a+"px"}},n.calcItemStyle=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var n=this.config,r=n.width,i=n.height,o=n.padding;return{top:(i+o)*e+"px",left:(r+o)*t+"px"}},n.getList=function(e,t){return this.state.list.map((function(n,r){return n.map((function(n,i){return r<=e&&i<=t?1:0}))}))},n.handleHover=function(e,t){this.setState({list:this.getList(e,t)})},n.handleSetTable=function(e,t){var n=this.props.onSetTable;"function"===typeof n&&n({row:e+1,col:t+1})},n.componentDidUpdate=function(e){!1===this.props.visibility&&e.visibility!==this.props.visibility&&this.setState({list:this.getList(-1,-1)})},n.render=function(){var e=this;return l.createElement("ul",{className:"table-list wrap",style:this.calcWrapStyle()},this.state.list.map((function(t,n){return t.map((function(t,r){return l.createElement("li",{className:"list-item "+(1===t?"active":""),key:n+"-"+r,style:e.calcItemStyle(n,r),onMouseOver:e.handleHover.bind(e,n,r),onClick:e.handleSetTable.bind(e,n,r)})}))})))},t}(l.Component),Ee=Ce,ke=function(e){function t(t){var n;return(n=e.call(this,t)||this).show=n.show.bind((0,i.Z)(n)),n.hide=n.hide.bind((0,i.Z)(n)),n.state={show:!1},n}a(t,e);var n=t.prototype;return n.show=function(){this.setState({show:!0})},n.hide=function(){this.setState({show:!1})},n.render=function(){var e=this,t=this.editorConfig.table||this.props.config;return l.createElement("span",{className:"button button-type-table",title:g.get("btnTable"),onMouseEnter:this.show,onMouseLeave:this.hide},l.createElement(s,{type:"grid"}),l.createElement(le,{show:this.state.show,onClose:this.hide},l.createElement(Ee,{visibility:this.state.show,maxRow:t.maxRow,maxCol:t.maxCol,onSetTable:function(t){return e.editor.insertMarkdown("table",t)}})))},t}(y);ke.pluginName="table",ke.defaultConfig={maxRow:6,maxCol:6};var Se=n(94184),Me=n.n(Se),Te=function(e){function t(){return e.apply(this,arguments)||this}a(t,e);var n=t.prototype;return n.handleSelectMapValue=function(e){var t=this.props.onSelectMapValue;"function"===typeof t&&t(e)},n.render=function(){var e=this,t=this.props.value;return l.createElement("ul",{className:"tab-map-list"},[1,2,4,8].map((function(n){return l.createElement("li",{key:n,className:Me()("list-item",{active:t===n})},l.createElement("div",{onClick:e.handleSelectMapValue.bind(e,n)},1===n?g.get("tab"):n+" "+g.get("spaces")))})))},t}(l.Component),Ne=Te,xe=function(e){function t(t){var n;return(n=e.call(this,t)||this).show=n.show.bind((0,i.Z)(n)),n.hide=n.hide.bind((0,i.Z)(n)),n.handleChangeMapValue=n.handleChangeMapValue.bind((0,i.Z)(n)),n.state={tabMapValue:n.getConfig("tabMapValue"),show:!1},n.handleKeyboard={key:"Tab",keyCode:9,aliasCommand:!0,withKey:[],callback:function(){return n.editor.insertMarkdown("tab",{tabMapValue:n.state.tabMapValue})}},n}a(t,e);var n=t.prototype;return n.show=function(){this.setState({show:!0})},n.hide=function(){this.setState({show:!1})},n.handleChangeMapValue=function(e){this.setState({tabMapValue:e})},n.componentDidMount=function(){this.editorConfig.shortcuts&&this.editor.onKeyboard(this.handleKeyboard)},n.componentWillUnmount=function(){this.editor.offKeyboard(this.handleKeyboard)},n.render=function(){return l.createElement("span",{className:"button button-type-header",title:g.get("selectTabMap"),onClick:this.show,onMouseLeave:this.hide},l.createElement(s,{type:"tab"}),l.createElement(le,{show:this.state.show,onClose:this.hide},l.createElement(Ne,{value:this.state.tabMapValue,onSelectMapValue:this.handleChangeMapValue})))},t}(y);xe.pluginName="tab-insert",xe.defaultConfig={tabMapValue:1},Q.use(ue),Q.use(ne),Q.use(re),Q.use(oe),Q.use(ie),Q.use(me),Q.use(pe),Q.use(X),Q.use(ee),Q.use(J),Q.use(Y),Q.use(ke),Q.use(de),Q.use(fe),Q.use(te),Q.use(ye),Q.use(we),Q.use(ae);var Le={Header:ue,FontBold:ne,FontItalic:re,FontUnderline:oe,FontStrikethrough:ie,ListUnordered:me,ListOrdered:pe,BlockQuote:X,BlockWrap:ee,BlockCodeInline:J,BlockCodeBlock:Y,Table:ke,Image:de,Link:fe,Clear:te,Logger:ye,ModeToggle:we,FullScreen:ae,AutoResize:$,TabInsert:xe},Ke=Q}}]);