react-page-markdown-plugin
Version:
react-page plugin to render markdown as HTML in realtime
2 lines • 13.6 kB
JavaScript
(self.webpackChunkdemo=self.webpackChunkdemo||[]).push([[5821],{15821:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return tt}});var r=n(72791),i=n(43144),o=n(15671),a=n(60136),u=n(29388),l=n(61120);function s(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=(0,l.Z)(t)););return t}function d(){return d="undefined"!==typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=s(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},d.apply(this,arguments)}var c=n(68787),v=n.n(c),h=n(18111),p=n.n(h),f=n(24242),m=n.n(f),g=n(63078),y=n.n(g),b=n(97326),Z=n(26181),C=n.n(Z),k=n(75929);function S(t){return!!t&&t===Object(t)&&!(t instanceof Date)}var O=n(59758);function M(t){var e=0;return function(){return"".concat(t,"-").concat(("000"+(e++).toString(36)).slice(-4))}}var x=M("uniforms");var j=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(t){var r;(0,o.Z)(this,n),(r=e.call(this,t)).state={changed:!1,changedMap:Object.create(null),resetCount:0,submitted:!1,submitting:!1},r.mounted=!1,r.randomId=function(){return M(arguments.length>0&&void 0!==arguments[0]?arguments[0]:x())}(r.props.id),r.onReset=r.reset=r.onReset.bind((0,b.Z)(r)),r.onChange=r.change=r.onChange.bind((0,b.Z)(r)),r.onSubmit=r.submit=r.onSubmit.bind((0,b.Z)(r));var i=r.getModel.bind((0,b.Z)(r));return r.getModel=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i(t);return void 0!==t&&r.props.modelTransform?r.props.modelTransform(t,e):e},r}return(0,i.Z)(n,[{key:"componentDidMount",value:function(){this.mounted=!0}},{key:"componentDidUpdate",value:function(t,e,n){}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.delayId&&clearTimeout(this.delayId)}},{key:"getContext",value:function(){return{changed:this.state.changed,changedMap:this.state.changedMap,error:this.getContextError(),formRef:this,model:this.getContextModel(),name:this.getContextName(),onChange:this.getContextOnChange(),onSubmit:this.getContextOnSubmit(),randomId:this.randomId,schema:this.getContextSchema(),state:this.getContextState(),submitted:this.state.submitted,submitting:this.state.submitting,validating:!1}}},{key:"getContextName",value:function(){return[]}},{key:"getContextError",value:function(){return this.props.error}},{key:"getContextModel",value:function(){return this.getModel("form")}},{key:"getContextState",value:function(){return{disabled:!!this.props.disabled,label:!!this.props.label,placeholder:!!this.props.placeholder,readOnly:!!this.props.readOnly,showInlineError:!!this.props.showInlineError}}},{key:"getContextSchema",value:function(){return this.props.schema}},{key:"getContextOnChange",value:function(){return this.onChange}},{key:"getContextOnSubmit",value:function(){return this.onSubmit}},{key:"getModel",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.model;return e}},{key:"getNativeFormProps",value:function(){var t=m()(this.props,["autosave","autosaveDelay","disabled","error","label","model","modelTransform","onChange","onSubmit","placeholder","readOnly","schema","showInlineError"]);return Object.assign(Object.assign({},t),{onSubmit:this.onSubmit,key:"reset-".concat(this.state.resetCount)})}},{key:"onChange",value:function(t,e){var n=this;if(this.mounted){var r=function(t,e,n){if(!S(e)||n&&typeof e!==typeof n)return p()(e,n)?[]:[t];var r=[t];if(S(n)){for(var i in e)i in n&&p()(e[i],n[i])||r.push((0,k.m)(t,i));for(var o in n)o in e||r.push((0,k.m)(t,o));1===r.length&&r.pop()}else for(var a in e)r.push((0,k.m)(t,a));return r}(t,e,C()(this.getModel(),t));0!==r.length&&this.setState((function(t){return t.changed&&r.every((function(e){return!!C()(t.changedMap,e)}))?null:{changed:!0,changedMap:r.reduce((function(t,e){return y()(t,e,{},v())}),v()(t.changedMap))}}))}this.props.onChange&&this.props.onChange(t,e),this.mounted&&this.props.autosave&&(this.delayId&&(this.delayId=clearTimeout(this.delayId)),this.delayId=setTimeout((function(){n.setState((function(){return null}),(function(){n.onSubmit()}))}),this.props.autosaveDelay))}},{key:"__reset",value:function(t){return{changed:!1,changedMap:Object.create(null),resetCount:t.resetCount+1,submitted:!1,submitting:!1}}},{key:"onReset",value:function(){this.setState(this.__reset)}},{key:"onSubmit",value:function(t){var e=this;t&&(t.preventDefault(),t.stopPropagation()),this.setState((function(t){return t.submitted?null:{submitted:!0}}));var n=this.props.onSubmit(this.getModel("submit"));return n instanceof Promise?(this.setState({submitting:!0}),n.finally((function(){e.setState({submitting:!1})}))):Promise.resolve()}},{key:"render",value:function(){return r.createElement(O.D.Provider,{value:this.getContext()},r.createElement("form",Object.assign({},this.getNativeFormProps())))}}]),n}(r.Component);j.displayName="Form",j.defaultProps={autosave:!1,autosaveDelay:0,error:null,label:!0,model:Object.create(null),noValidate:!0,onSubmit:function(){}};var F=n(3431);function E(t){var e=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(){return(0,o.Z)(this,n),e.apply(this,arguments)}return(0,i.Z)(n,[{key:"getNativeFormProps",value:function(){var t=d((0,l.Z)(n.prototype),"getNativeFormProps",this).call(this),e=t.autoField,i=void 0===e?this.getAutoField():e,o=t.errorsField,a=void 0===o?this.getErrorsField():o,u=t.submitField,s=void 0===u?this.getSubmitField():u,c=(0,F._T)(t,["autoField","errorsField","submitField"]);return c.children||(c.children=this.getContextSchema().getSubfields().map((function(t){return r.createElement(i,{key:t,name:t})})).concat([r.createElement(a,{key:"$ErrorsField"}),r.createElement(s,{key:"$SubmitField"})])),c}},{key:"getAutoField",value:function(){return function(){return null}}},{key:"getErrorsField",value:function(){return function(){return null}}},{key:"getSubmitField",value:function(){return function(){return null}}}]),n}(t);return e.Quick=E,e.displayName="Quick".concat(t.displayName),e}var P=E(j),V=n(58121),_=n.n(V),N=n(19694),D=n.n(N);function I(t){var e=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(t){var r;return(0,o.Z)(this,n),(r=e.call(this,t)).state=Object.assign(Object.assign({},r.state),{error:null,validate:!1,validating:!1,validator:r.getContextSchema().getValidator(t.validator)}),r.onValidate=r.validate=r.onValidate.bind((0,b.Z)(r)),r.onValidateModel=r.validateModel=r.onValidateModel.bind((0,b.Z)(r)),r}return(0,i.Z)(n,[{key:"getContextError",value:function(){var t;return null!==(t=d((0,l.Z)(n.prototype),"getContextError",this).call(this))&&void 0!==t?t:this.state.error}},{key:"getContext",value:function(){return Object.assign(Object.assign({},d((0,l.Z)(n.prototype),"getContext",this).call(this)),{validating:this.state.validating})}},{key:"getNativeFormProps",value:function(){var t=d((0,l.Z)(n.prototype),"getNativeFormProps",this).call(this);return m()(t,["onValidate","validate","validator"])}},{key:"componentDidUpdate",value:function(t,e,r){var i=this;d((0,l.Z)(n.prototype),"componentDidUpdate",this).call(this,t,e,r);var o=this.props,a=o.model,u=o.schema,s=o.validate,c=o.validator;u!==t.schema||c!==t.validator?this.setState({validator:u.getValidator(c)},(function(){w(s,i.state.validate)&&i.onValidate()})):!p()(a,t.model)&&w(s,this.state.validate)&&this.onValidateModel(a)}},{key:"onChange",value:function(t,e){w(this.props.validate,this.state.validate)&&this.onValidate(t,e),d((0,l.Z)(n.prototype),"onChange",this).call(this,t,e)}},{key:"__reset",value:function(t){return Object.assign(Object.assign({},d((0,l.Z)(n.prototype),"__reset",this).call(this,t)),{error:null,validate:!1,validating:!1})}},{key:"onSubmit",value:function(t){var e=this;t&&(t.preventDefault(),t.stopPropagation()),this.setState({submitted:!0,validate:!0});var r=this.onValidate().then((function(t){return null!==t?Promise.reject(t):d((0,l.Z)(n.prototype),"onSubmit",e).call(e).catch((function(t){throw e.setState({error:t}),t}))}));return r.catch(D()),r}},{key:"onValidate",value:function(t,e){var n=this.getContextModel();return n&&t&&(n=y()(v()(n),t,_()(e),v())),this.onValidateModel(n)}},{key:"onValidateModel",value:function(t){var e=this,n=this.getModel("validate",t),r=function(t){function e(e,n){return e instanceof Promise?(t(),e.then(n)):n(e)}return e}((function(){e.setState({validating:!0})}));return r(this.state.validator(n),(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return r(e.props.onValidate(n,t),(function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return n=e.props.error===n?null:n,e.setState((function(t){return t.error!==n||t.validating?{error:n,validating:!1}:null})),Promise.resolve(null!==(t=e.props.error)&&void 0!==t?t:n)}))}))}}]),n}(t);return e.Validated=I,e.displayName="Validated".concat(t.displayName),e.defaultProps=Object.assign(Object.assign({},t.defaultProps),{onValidate:function(t,e){return e},validate:"onChangeAfterSubmit"}),e}function w(t,e){return"onChange"===t||"onChangeAfterSubmit"===t&&e}var R=I(j);var A=function t(e){var n=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(t){var r;return(0,o.Z)(this,n),(r=e.call(this,t)).state=Object.assign(Object.assign({},r.state),{model:t.model}),r}return(0,i.Z)(n,[{key:"componentDidUpdate",value:function(t,e,r){var i=this.props.model;p()(i,t.model)||this.setState({model:i}),d((0,l.Z)(n.prototype),"componentDidUpdate",this).call(this,t,e,r)}},{key:"getNativeFormProps",value:function(){var t=d((0,l.Z)(n.prototype),"getNativeFormProps",this).call(this);return m()(t,["onChangeModel"])}},{key:"getModel",value:function(t){return this.state.model}},{key:"onChange",value:function(t,e){var r=this;d((0,l.Z)(n.prototype),"onChange",this).call(this,t,e),this.setState((function(n){return{model:y()(v()(n.model),t,e,v())}}),(function(){r.props.onChangeModel&&r.props.onChangeModel(r.state.model)}))}},{key:"__reset",value:function(t){return Object.assign(Object.assign({},d((0,l.Z)(n.prototype),"__reset",this).call(this,t)),{model:this.props.model})}}]),n}(e);return n.Auto=t,n.displayName="Auto".concat(e.displayName),n}(I(E(j)));var T=function t(e){var n=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(){return(0,o.Z)(this,n),e.apply(this,arguments)}return(0,i.Z)(n)}(e);return n.Material=t,n.displayName="Material".concat(e.displayName),n}(j),U=n(9815),Q=n(23364),W=n(66828),z=n(76782),$=n(56414),B=n(75834);var q=function(t){var e,n,i,o=t.children,a=t.fullWidth,u=t.margin,l=t.variant,s=(0,F._T)(t,["children","fullWidth","margin","variant"]),d=null===(e=(0,Q.Z)().props)||void 0===e?void 0:e.MuiFormControl,c=(0,$.c)(),v=c.error,h=c.schema;return v||o?r.createElement(W.Z,{error:!!v,fullWidth:null===(n=null!==a&&void 0!==a?a:null===d||void 0===d?void 0:d.fullWidth)||void 0===n||n,margin:null!==(i=null!==u&&void 0!==u?u:null===d||void 0===d?void 0:d.margin)&&void 0!==i?i:"dense",variant:null!==l&&void 0!==l?l:null===d||void 0===d?void 0:d.variant},!!o&&r.createElement(z.Z,Object.assign({},(0,B.z)(s)),o),h.getErrorMessages(v).map((function(t,e){return r.createElement(z.Z,Object.assign({key:e},(0,B.z)(s)),t)}))):null},G=n(26513);var H=function(t){var e,n,i=t.children,o=t.disabled,a=t.inputRef,u=t.label,l=void 0===u?"Submit":u,s=t.value,d=(0,F._T)(t,["children","disabled","inputRef","label","value"]),c=(0,$.c)(),v=c.error,h=c.state,p=null===(e=(0,Q.Z)().props)||void 0===e?void 0:e.MuiButton;return r.createElement(G.Z,Object.assign({disabled:void 0===o?!(!v&&!h.disabled):o,ref:a,type:"submit",value:s,variant:null!==(n=null===p||void 0===p?void 0:p.variant)&&void 0!==n?n:"contained"},(0,B.z)(d)),i||l)};var J=function t(e){var n=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(){return(0,o.Z)(this,n),e.apply(this,arguments)}return(0,i.Z)(n,[{key:"getAutoField",value:function(){return U.Z}},{key:"getErrorsField",value:function(){return q}},{key:"getSubmitField",value:function(){return H}}]),n}(P.Quick(e));return n.Quick=t,n}(T);var K=function t(e){var n=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(){return(0,o.Z)(this,n),e.apply(this,arguments)}return(0,i.Z)(n)}(R.Validated(e));return n.Validated=t,n}(T);var L=function t(e){var n=function(t){(0,a.Z)(n,t);var e=(0,u.Z)(n);function n(){return(0,o.Z)(this,n),e.apply(this,arguments)}return(0,i.Z)(n)}(A.Auto(e));return n.Auto=t,n}(K.Validated(J.Quick(T))),X=function(t){var e=t.children;return r.createElement(U.Z.componentDetectorContext.Provider,{value:function(t,e){var n,r;return null===(r=null===(n=t.showIf)||void 0===n?void 0:n.call(t,e.model))||void 0===r||r?t._customComponent?t._customComponent:U.Z.defaultComponentDetector(t,e):function(){return null}}},e)},Y=function(){return Y=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Y.apply(this,arguments)},tt=(0,r.forwardRef)((function(t,e){return r.createElement(X,null,r.createElement(L,Y({},t,{ref:e})))}))},40379:function(t,e,n){var r=n(18463),i=n(43082),o=n(26800),a=n(8092),u=n(69793);t.exports=function(t,e,n,l){if(!a(t))return t;for(var s=-1,d=(e=i(e,t)).length,c=d-1,v=t;null!=v&&++s<d;){var h=u(e[s]),p=n;if("__proto__"===h||"constructor"===h||"prototype"===h)return t;if(s!=c){var f=v[h];void 0===(p=l?l(f,h,v):void 0)&&(p=a(f)?f:o(e[s+1])?[]:{})}r(v,h,p),v=v[h]}return t}},68787:function(t,e,n){var r=n(31905);t.exports=function(t){return r(t,4)}},18111:function(t,e,n){var r=n(71848);t.exports=function(t,e){return r(t,e)}},63078:function(t,e,n){var r=n(40379);t.exports=function(t,e,n,i){return i="function"==typeof i?i:void 0,null==t?t:r(t,e,n,i)}}}]);
//# sourceMappingURL=5821.85908cba.chunk.js.map