react-simplemde-v1
Version:
React.js(v16.x+) component wrap for SimpleMDE Markdown Editor(v1.x+)
3 lines (2 loc) • 13.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("simplemde")):"function"==typeof define&&define.amd?define(["react","simplemde"],e):t.ISimpleMDE=e(t.React,t.SimpleMDE)}(this,function(t,e){"use strict";function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;var a="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,f=a||c||Function("return this")(),l=f.Symbol,s=Object.prototype,p=s.hasOwnProperty,v=s.toString,y=l?l.toStringTag:void 0;var h=Object.prototype.toString;var b="[object Null]",d="[object Undefined]",_=l?l.toStringTag:void 0;function j(t){return null==t?void 0===t?d:b:_&&_ in Object(t)?function(t){var e=p.call(t,y),r=t[y];try{t[y]=void 0}catch(t){}var n=v.call(t);return e?t[y]=r:delete t[y],n}(t):function(t){return h.call(t)}(t)}function g(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var m="[object AsyncFunction]",O="[object Function]",w="[object GeneratorFunction]",A="[object Proxy]";function P(t){if(!g(t))return!1;var e=j(t);return e==O||e==w||e==m||e==A}var x,S=f["__core-js_shared__"],E=(x=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"";var T=Function.prototype.toString;var z=/^\[object .+?Constructor\]$/,F=Function.prototype,$=Object.prototype,k=F.toString,C=$.hasOwnProperty,M=RegExp("^"+k.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R(t){return!(!g(t)||(e=t,E&&E in e))&&(P(t)?M:z).test(function(t){if(null!=t){try{return T.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function D(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return R(r)?r:void 0}var I=function(){try{var t=D(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function U(t,e,r){"__proto__"==e&&I?I(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function N(t,e){return t===e||t!=t&&e!=e}var q=Object.prototype.hasOwnProperty;function B(t,e,r){var n=t[e];q.call(t,e)&&N(n,r)&&(void 0!==r||e in t)||U(t,e,r)}function L(t){return t}var W=Math.max;var G=I?function(t,e){return I(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:L,V=800,H=16,J=Date.now;var K,Q,X,Y=(K=G,Q=0,X=0,function(){var t=J(),e=H-(t-X);if(X=t,e>0){if(++Q>=V)return arguments[0]}else Q=0;return K.apply(void 0,arguments)});function Z(t,e){return Y(function(t,e,r){return e=W(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=W(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}(t,e,L),t+"")}var tt=9007199254740991;function et(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=tt}function rt(t){return null!=t&&et(t.length)&&!P(t)}var nt=9007199254740991,ot=/^(?:0|[1-9]\d*)$/;function it(t,e){var r=typeof t;return!!(e=null==e?nt:e)&&("number"==r||"symbol"!=r&&ot.test(t))&&t>-1&&t%1==0&&t<e}var ut=Object.prototype;function at(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ut)}function ct(t){return null!=t&&"object"==typeof t}var ft="[object Arguments]";function lt(t){return ct(t)&&j(t)==ft}var st=Object.prototype,pt=st.hasOwnProperty,vt=st.propertyIsEnumerable,yt=lt(function(){return arguments}())?lt:function(t){return ct(t)&&pt.call(t,"callee")&&!vt.call(t,"callee")},ht=Array.isArray;var bt="object"==typeof exports&&exports&&!exports.nodeType&&exports,dt=bt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=dt&&dt.exports===bt?f.Buffer:void 0,jt=(_t?_t.isBuffer:void 0)||function(){return!1},gt={};gt["[object Float32Array]"]=gt["[object Float64Array]"]=gt["[object Int8Array]"]=gt["[object Int16Array]"]=gt["[object Int32Array]"]=gt["[object Uint8Array]"]=gt["[object Uint8ClampedArray]"]=gt["[object Uint16Array]"]=gt["[object Uint32Array]"]=!0,gt["[object Arguments]"]=gt["[object Array]"]=gt["[object ArrayBuffer]"]=gt["[object Boolean]"]=gt["[object DataView]"]=gt["[object Date]"]=gt["[object Error]"]=gt["[object Function]"]=gt["[object Map]"]=gt["[object Number]"]=gt["[object Object]"]=gt["[object RegExp]"]=gt["[object Set]"]=gt["[object String]"]=gt["[object WeakMap]"]=!1;var mt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=mt&&"object"==typeof module&&module&&!module.nodeType&&module,wt=Ot&&Ot.exports===mt&&a.process,At=function(){try{var t=Ot&&Ot.require&&Ot.require("util").types;return t||wt&&wt.binding&&wt.binding("util")}catch(t){}}(),Pt=At&&At.isTypedArray,xt=Pt?function(t){return function(e){return t(e)}}(Pt):function(t){return ct(t)&&et(t.length)&&!!gt[j(t)]},St=Object.prototype.hasOwnProperty;function Et(t,e){var r=ht(t),n=!r&&yt(t),o=!r&&!n&&jt(t),i=!r&&!n&&!o&&xt(t),u=r||n||o||i,a=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var f in t)!e&&!St.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||it(f,c))||a.push(f);return a}function Tt(t,e){return function(r){return t(e(r))}}var zt=Tt(Object.keys,Object),Ft=Object.prototype.hasOwnProperty;function $t(t){return rt(t)?Et(t):function(t){if(!at(t))return zt(t);var e=[];for(var r in Object(t))Ft.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var kt,Ct=Object.prototype.hasOwnProperty,Mt=(kt=function(t,e){if(at(e)||rt(e))!function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?U(r,a,c):B(r,a,c)}}(e,$t(e),t);else for(var r in e)Ct.call(e,r)&&B(t,r,e[r])},Z(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=kt.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!g(r))return!1;var n=typeof e;return!!("number"==n?rt(r)&&it(e,r.length):"string"==n&&e in r)&&N(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var u=e[r];u&&kt(t,u,r,o)}return t})),Rt="[object Symbol]";function Dt(t){return"symbol"==typeof t||ct(t)&&j(t)==Rt}var It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ut=/^\w*$/;var Nt=D(Object,"create");var qt="__lodash_hash_undefined__",Bt=Object.prototype.hasOwnProperty;var Lt=Object.prototype.hasOwnProperty;var Wt="__lodash_hash_undefined__";function Gt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Vt(t,e){for(var r=t.length;r--;)if(N(t[r][0],e))return r;return-1}Gt.prototype.clear=function(){this.__data__=Nt?Nt(null):{},this.size=0},Gt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Gt.prototype.get=function(t){var e=this.__data__;if(Nt){var r=e[t];return r===qt?void 0:r}return Bt.call(e,t)?e[t]:void 0},Gt.prototype.has=function(t){var e=this.__data__;return Nt?void 0!==e[t]:Lt.call(e,t)},Gt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Nt&&void 0===e?Wt:e,this};var Ht=Array.prototype.splice;function Jt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Jt.prototype.clear=function(){this.__data__=[],this.size=0},Jt.prototype.delete=function(t){var e=this.__data__,r=Vt(e,t);return!(r<0||(r==e.length-1?e.pop():Ht.call(e,r,1),--this.size,0))},Jt.prototype.get=function(t){var e=this.__data__,r=Vt(e,t);return r<0?void 0:e[r][1]},Jt.prototype.has=function(t){return Vt(this.__data__,t)>-1},Jt.prototype.set=function(t,e){var r=this.__data__,n=Vt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Kt=D(f,"Map");function Qt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Xt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Xt.prototype.clear=function(){this.size=0,this.__data__={hash:new Gt,map:new(Kt||Jt),string:new Gt}},Xt.prototype.delete=function(t){var e=Qt(this,t).delete(t);return this.size-=e?1:0,e},Xt.prototype.get=function(t){return Qt(this,t).get(t)},Xt.prototype.has=function(t){return Qt(this,t).has(t)},Xt.prototype.set=function(t,e){var r=Qt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var Yt="Expected a function";function Zt(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(Yt);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(Zt.Cache||Xt),r}Zt.Cache=Xt;var te=500;var ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,re=/\\(\\)?/g,ne=function(t){var e=Zt(t,function(t){return r.size===te&&r.clear(),t}),r=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ee,function(t,r,n,o){e.push(n?o.replace(re,"$1"):r||t)}),e});var oe=1/0,ie=l?l.prototype:void 0,ue=ie?ie.toString:void 0;function ae(t){if("string"==typeof t)return t;if(ht(t))return function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(t,ae)+"";if(Dt(t))return ue?ue.call(t):"";var e=t+"";return"0"==e&&1/t==-oe?"-0":e}function ce(t){return null==t?"":ae(t)}function fe(t,e){return ht(t)?t:function(t,e){if(ht(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!Dt(t))||Ut.test(t)||!It.test(t)||null!=e&&t in Object(e)}(t,e)?[t]:ne(ce(t))}var le=1/0;function se(t){if("string"==typeof t||Dt(t))return t;var e=t+"";return"0"==e&&1/t==-le?"-0":e}function pe(t,e,r){var n=null==t?void 0:function(t,e){for(var r=0,n=(e=fe(e,t)).length;null!=t&&r<n;)t=t[se(e[r++])];return r&&r==n?t:void 0}(t,e);return void 0===n?r:n}var ve=Tt(Object.getPrototypeOf,Object),ye="[object Object]",he=Function.prototype,be=Object.prototype,de=he.toString,_e=be.hasOwnProperty,je=de.call(Object);var ge,me=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),u=i.length;u--;){var a=i[ge?u:++n];if(!1===e(o[a],a,o))break}return t};var Oe=Object.prototype.hasOwnProperty;function we(t){if(!g(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=at(t),r=[];for(var n in t)("constructor"!=n||!e&&Oe.call(t,n))&&r.push(n);return r}function Ae(t){return rt(t)?Et(t,!0):we(t)}function Pe(t,e){return null==t?t:me(t,"function"==typeof(r=e)?r:L,Ae);var r}var xe=function(a){function c(t){var r,i,a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),i=this,a=o(c).call(this,t),r=!a||"object"!=typeof a&&"function"!=typeof a?u(i):a,n(u(u(r)),"init",function(){var t=u(u(r)),n=t.props,o=n.option,i=n.text,a=n.onReady,c=t.state.instance;if(t.dom&&!c){var f=new e(Mt({},o,{element:t.dom}));f&&(t.events(f),P(f.value)&&f.value(i),P(a)&&setTimeout(function(){return a(f,e)}),t.setState({instance:f}))}}),n(u(u(r)),"uninit",function(){var t=u(u(r)),e=t.state.instance;e&&P(e.toTextArea)&&e.toTextArea(),t.setState({instance:null})}),n(u(u(r)),"events",function(t){var e=u(u(r)).props.onEvents;t&&P(pe(t,"codemirror.on"))&&P(pe(t,"codemirror.off"))&&function(t){if(!ct(t)||j(t)!=ye)return!1;var e=ve(t);if(null===e)return!0;var r=_e.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&de.call(r)==je}(e)&&Pe(e,function(e,r){if(P(e)){var n=function(t){return ce(t).toLowerCase()}(r),o=e.bind(t);t.codemirror.off(n,o),t.codemirror.on(n,o)}})}),r.dom=null,r.state={instance:null},r}var f,l,s;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(c,t.Component),f=c,(l=[{key:"componentDidMount",value:function(){this.init()}},{key:"componentWillUnmount",value:function(){this.uninit()}},{key:"render",value:function(){var e=this,r=e.props,n=r.className,o=r.style;return t.createElement("textarea",{className:n,style:o,ref:function(t){e.dom=t}})}}])&&r(f.prototype,l),s&&r(f,s),c}();return n(xe,"defaultProps",{className:"react-simplemde",style:{width:"100%",height:"100%"},text:"",onReady:function(t,e){},onEvents:{}}),xe.__simplemde__=e,xe});
//# sourceMappingURL=simplemde.min.js.map