react-live
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -737,3 +737,3 @@ 'use strict'; | ||
return React__default.createElement(WrappedComponent, { live: live }); | ||
return React__default.createElement(WrappedComponent, _extends({ live: live }, this.props)); | ||
}; | ||
@@ -740,0 +740,0 @@ |
@@ -730,3 +730,3 @@ import { highlight, languages } from 'prismjs/components/prism-core'; | ||
return React.createElement(WrappedComponent, { live: live }); | ||
return React.createElement(WrappedComponent, _extends({ live: live }, this.props)); | ||
}; | ||
@@ -733,0 +733,0 @@ |
@@ -730,3 +730,3 @@ (function (global, factory) { | ||
return React__default.createElement(WrappedComponent, { live: live }); | ||
return React__default.createElement(WrappedComponent, _extends({ live: live }, this.props)); | ||
}; | ||
@@ -733,0 +733,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("prismjs/components/prism-core"),require("prismjs/components/prism-clike"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-jsx"),require("unescape"),require("dom-iterator"),require("react"),require("buble"),require("core-js/fn/object/assign"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","prismjs/components/prism-core","prismjs/components/prism-clike","prismjs/components/prism-javascript","prismjs/components/prism-markup","prismjs/components/prism-jsx","unescape","dom-iterator","react","buble","core-js/fn/object/assign","prop-types"],n):n(e.ReactLive={},e.prismCore,null,null,null,null,e.unescape,e.iterator,e.React,e.Buble,e.assign,e.PropTypes)}(this,function(e,n,t,o,r,i,a,s,c,l,p,u){"use strict";function d(e,n){var t=window.getSelection();if(1==arguments.length){if(!t.rangeCount)return;var o={},r=(p=t.getRangeAt(0)).cloneRange();return r.selectNodeContents(e),r.setEnd(p.endContainer,p.endOffset),o.end=r.toString().length,r.setStart(p.startContainer,p.startOffset),o.start=o.end-r.toString().length,o.atStart=0===r.startOffset,o.commonAncestorContainer=r.commonAncestorContainer,o.endContainer=r.endContainer,o.startContainer=r.startContainer,o}for(var i,a,c=n.end&&n.end!==n.start,l=0,p=document.createRange(),u=s(e).select(Node.TEXT_NODE).revisit(!1),d=n.start>e.textContent.length?e.textContent.length:n.start,m=n.end>e.textContent.length?e.textContent.length:n.end,h=n.atStart;i=u.next();){var g=l;l+=i.textContent.length;var y=h?l>d:l>=d;if(!a&&y&&(a=!0,p.setStart(i,d-g),!c)){p.collapse(!0),f(e,p);break}if(c&&l>=m){p.setEnd(i,m-g),f(e,p);break}}}function f(e,n){var t=window.getSelection();e.focus(),t.removeAllRanges(),t.addRange(n)}a=a&&a.hasOwnProperty("default")?a.default:a,s=s&&s.hasOwnProperty("default")?s.default:s;var m="default"in c?c.default:c;p=p&&p.hasOwnProperty("default")?p.default:p,u=u&&u.hasOwnProperty("default")?u.default:u;var h=function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.filter(Boolean).join(" ")},g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"jsx";return n.highlight(e,n.languages[t])},y=function(e){return e.replace(/^((\t| )+)/gm,function(e,n){return n.replace(/\t/g," ")})},v=function(e){return e.replace("\n","<br>")},C=function(e){return a(e.replace(/<br>/gm,"\n").replace(/<\/?[^>]*>/gm,""))},k=function(e,n){var t=e.slice(0,n),o=t.lastIndexOf("\n")+1;return t.slice(o)},b=function(e,n){var t=k(e,n).match(/^\s+/);return null===t?"":t[0]||""},S=/^(\t| )* $/,E=function(e,n){var t=k(e,n);return S.test(t)?2:0},w=function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")},j=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},x=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)},T=function(e,n){var t={};for(var o in e)n.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},O=function(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?e:n},P=function(e){function n(){var t,o,r;w(this,n);for(var i=arguments.length,a=Array(i),s=0;s<i;s++)a[s]=arguments[s];return t=o=O(this,e.call.apply(e,[this].concat(a))),o.undoStack=[],o.undoOffset=0,o.undoTimestamp=0,o.compositing=!1,o.state={html:""},o.onRef=function(e){o.ref=e},o.getPlain=function(){if(o._innerHTML===o.ref.innerHTML)return o._plain;var e=C(v(o.ref.innerHTML));return o._plain=e,o._innerHTML=o.ref.innerHTML,o._plain},o.recordChange=function(e,n){if(e!==o.undoStack[o.undoStack.length-1]){o.undoOffset>0&&(o.undoStack=o.undoStack.slice(0,-o.undoOffset),o.undoOffset=0);var t=Date.now(),r={plain:e,selection:n};t-o.undoTimestamp<3e3?o.undoStack[o.undoStack.length-1]=r:(o.undoStack.push(r),o.undoStack.length>50&&o.undoStack.shift()),o.undoTimestamp=t}},o.updateContent=function(e){o.compositing||(o.setState({html:g(e,o.props.language)}),o.props.onChange&&o.props.onChange(e))},o.restoreStackState=function(e){var n=o.undoStack[o.undoStack.length-1-e],t=n.plain,r=n.selection;o.selection=r,o.undoOffset=e,o.updateContent(t)},o.undo=function(){var e=o.undoOffset+1;e>=o.undoStack.length||o.restoreStackState(e)},o.redo=function(){var e=o.undoOffset-1;e<0||o.restoreStackState(e)},o.onKeyDown=function(e){if(o.props.onKeyDown&&o.props.onKeyDown(e),9!==e.keyCode||o.props.ignoreTabKey)if(8===e.keyCode){var n=d(o.ref),t=n.start;if(t!==n.end)return;var r=E(o.getPlain(),t);if(r<=0)return;for(var i=0;i<r;i++)document.execCommand("delete",!1);e.preventDefault()}else if(13===e.keyCode){var a=d(o.ref).start,s=b(o.getPlain(),a);document.execCommand("insertHTML",!1,"\n"+s),e.preventDefault()}else 90!==e.keyCode||e.metaKey===e.ctrlKey||e.altKey||(e.shiftKey?o.redo():o.undo(),e.preventDefault());else document.execCommand("insertHTML",!1," "),e.preventDefault()},o.onKeyUp=function(e){if(o.props.onKeyUp&&o.props.onKeyUp(e),91!==e.keyCode&&93!==e.keyCode&&!e.ctrlKey&&!e.metaKey)if(13===e.keyCode&&(o.undoTimestamp=0),o.selection=d(o.ref),37!==e.keyCode&&38!==e.keyCode&&39!==e.keyCode&&40!==e.keyCode){var n=o.getPlain();o.recordChange(n,o.selection),o.updateContent(n)}else o.undoTimestamp=0},o.onCompositionStart=function(e){o.props.onCompositionStart&&o.props.onCompositionStart(e),o.compositing=!0},o.onCompositionEnd=function(e){o.props.onCompositionEnd&&o.props.onCompositionEnd(e),o.compositing=!1},o.onClick=function(e){o.props.onClick&&o.props.onClick(e),o.undoTimestamp=0,o.selection=d(o.ref)},r=t,O(o,r)}return x(n,e),n.prototype.componentWillMount=function(){var e=g(y(this.props.code),this.props.language);this.setState({html:e})},n.prototype.componentDidMount=function(){this.recordChange(this.getPlain()),this.undoTimestamp=0},n.prototype.componentWillReceiveProps=function(e){var n=e.code,t=e.language;if(n!==this.props.code||t!==this.props.language){var o=g(y(n),t);this.setState({html:o})}},n.prototype.componentDidUpdate=function(){var e=this.selection;e&&d(this.ref,e)},n.prototype.render=function(){var e=this.props,n=e.contentEditable,t=(e.className,e.style),o=(e.code,e.ignoreTabKey,e.language,T(e,["contentEditable","className","style","code","ignoreTabKey","language"])),r=this.state.html;return m.createElement("pre",j({},o,{ref:this.onRef,className:h(),style:t,spellCheck:"false",contentEditable:n,onCompositionEnd:n?this.onCompositionEnd:void 0,onCompositionStart:n?this.onCompositionStart:void 0,onKeyDown:n?this.onKeyDown:void 0,onKeyUp:n?this.onKeyUp:void 0,onClick:n?this.onClick:void 0,dangerouslySetInnerHTML:{__html:r}}))},n}(c.Component);P.defaultProps={contentEditable:!0,language:"jsx"};var K={assign:p},_={objectAssign:"_poly.assign",transforms:{dangerousForOf:!0,dangerousTaggedTemplateString:!0}},N=function(e){return l.transform(e,_).code},D=function(e,n){return function(t){function o(){return w(this,o),O(this,t.apply(this,arguments))}return x(o,t),o.prototype.componentDidCatch=function(e){n(e)},o.prototype.render=function(){return"function"==typeof e?m.createElement(e,null):e},o}(m.Component)},I=function(e,n){var t=Object.keys(n),o=t.map(function(e){return n[e]});return(new(Function.prototype.bind.apply(Function,[null].concat(["_poly","React"],t,[e])))).apply(void 0,[K,m].concat(o))},L=function(e,n){var t=e.code,o=void 0===t?"":t,r=e.scope,i=void 0===r?{}:r,a=o.trim().replace(/;$/,""),s=N("("+a+")").trim();return D(I("return "+s,i),n)},M=function(e,n,t){var o=e.code,r=void 0===o?"":o,i=e.scope,a=void 0===i?{}:i,s=function(e){n(D(e,t))};if(!/render\s*\(/.test(r))return t(new SyntaxError("No-Inline evaluations must call `render`."));I(N(r),j({},a,{render:s}))},R=m.createElement("style",{dangerouslySetInnerHTML:{__html:"\n.prism-code {\n display: block;\n white-space: pre;\n\n background-color: #1D1F21;\n color: #C5C8C6;\n\n padding: 0.5rem;\n margin: 0;\n\n box-sizing: border-box;\n vertical-align: baseline;\n outline: none;\n text-shadow: none;\n -webkit-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n word-wrap: normal;\n word-break: normal;\n text-align: left;\n word-spacing: normal;\n -moz-tab-size: 2;\n -o-tab-size: 2;\n tab-size: 2;\n}\n\n.token.comment,\n.token.prolog,\n.token.doctype,\n.token.cdata {\n color: hsl(30, 20%, 50%);\n}\n\n.token.punctuation {\n opacity: .7;\n}\n\n.namespace {\n opacity: .7;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol {\n color: hsl(350, 40%, 70%);\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.inserted {\n color: hsl(75, 70%, 60%);\n}\n\n.token.operator,\n.token.entity,\n.token.url,\n.language-css .token.string,\n.style .token.string,\n.token.variable {\n color: hsl(40, 90%, 60%);\n}\n\n.token.atrule,\n.token.attr-value,\n.token.keyword {\n color: hsl(350, 40%, 70%);\n}\n\n.token.regex,\n.token.important {\n color: #e90;\n}\n\n.token.important,\n.token.bold {\n font-weight: bold;\n}\n.token.italic {\n font-style: italic;\n}\n\n.token.entity {\n cursor: help;\n}\n\n.token.deleted {\n color: red;\n}\n"}}),q=function(){return R},A={live:u.shape({code:u.string,error:u.string,onError:u.func,onChange:u.func,element:u.oneOfType([u.string,u.number,u.element,u.func])})},H=function(e){function n(){var t,o,r;w(this,n);for(var i=arguments.length,a=Array(i),s=0;s<i;s++)a[s]=arguments[s];return t=o=O(this,e.call.apply(e,[this].concat(a))),o.onChange=function(e){var n=o.props,t=n.scope,r=n.transformCode,i=n.noInline;o.transpile({code:e,scope:t,transformCode:r,noInline:i})},o.onError=function(e){o.setState({error:e.toString()})},o.transpile=function(e){var n=e.code,t=e.scope,r=e.transformCode,i=e.noInline,a=void 0!==i&&i,s={code:r?r(n):n,scope:t},c=function(e){return o.setState({element:void 0,error:e.toString()})},l=function(e){return o.setState(j({},p,{element:e}))},p={unsafeWrapperError:void 0,error:void 0};try{a?(o.setState(j({},p,{element:null})),M(s,l,c)):l(L(s,c))}catch(e){o.setState(j({},p,{error:e.toString()}))}},o.getChildContext=function(){return{live:j({},o.state,{code:o.props.code,onError:o.onError,onChange:o.onChange})}},r=t,O(o,r)}return x(n,e),n.prototype.componentWillMount=function(){var e=this.props,n=e.code,t=e.scope,o=e.transformCode,r=e.noInline;this.transpile({code:n,scope:t,transformCode:o,noInline:r})},n.prototype.componentWillReceiveProps=function(e){var n=e.code,t=e.scope,o=e.noInline,r=e.transformCode;n===this.props.code&&t===this.props.scope&&o===this.props.noInline&&r===this.props.transformCode||this.transpile({code:n,scope:t,transformCode:r,noInline:o})},n.prototype.render=function(){var e=this.props,n=e.children,t=(e.className,e.code,e.mountStylesheet),o=(e.noInline,e.transformCode,e.scope,T(e,["children","className","code","mountStylesheet","noInline","transformCode","scope"]));return m.createElement("div",j({className:h()},o),t&&m.createElement(q,null),n)},n}(c.Component);H.childContextTypes=A,H.defaultProps={code:"",mountStylesheet:!0,noInline:!1};var U=function(e,n){var t=n.live;return m.createElement(P,j({},e,{code:t.code,onChange:function(n){t.onChange(n),"function"==typeof e.onChange&&e.onChange(n)}}))};U.contextTypes=A;var z=function(e,n){var t=n.live,o=(e.className,T(e,["className"]));return t.error?m.createElement("div",j({},o,{className:h()}),t.error):null};z.contextTypes=A;var W=function(e,n){var t=n.live.element,o=(e.className,T(e,["className"])),r=t;return m.createElement("div",j({},o,{className:h()}),r&&m.createElement(r,null))};W.contextTypes=A;var F=function(e){var n=function(n){function t(){return w(this,t),O(this,n.apply(this,arguments))}return x(t,n),t.prototype.render=function(){var n=this.context.live;return m.createElement(e,{live:n})},t}(c.Component);return n.contextTypes=A,n};e.Editor=P,e.LiveProvider=H,e.LiveEditor=U,e.LiveError=z,e.LivePreview=W,e.withLive=F,e.generateElement=L,e.renderElementAsync=M,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("prismjs/components/prism-core"),require("prismjs/components/prism-clike"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-jsx"),require("unescape"),require("dom-iterator"),require("react"),require("buble"),require("core-js/fn/object/assign"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","prismjs/components/prism-core","prismjs/components/prism-clike","prismjs/components/prism-javascript","prismjs/components/prism-markup","prismjs/components/prism-jsx","unescape","dom-iterator","react","buble","core-js/fn/object/assign","prop-types"],n):n(e.ReactLive={},e.prismCore,null,null,null,null,e.unescape,e.iterator,e.React,e.Buble,e.assign,e.PropTypes)}(this,function(e,n,t,o,r,i,a,s,c,l,p,u){"use strict";function d(e,n){var t=window.getSelection();if(1==arguments.length){if(!t.rangeCount)return;var o={},r=(p=t.getRangeAt(0)).cloneRange();return r.selectNodeContents(e),r.setEnd(p.endContainer,p.endOffset),o.end=r.toString().length,r.setStart(p.startContainer,p.startOffset),o.start=o.end-r.toString().length,o.atStart=0===r.startOffset,o.commonAncestorContainer=r.commonAncestorContainer,o.endContainer=r.endContainer,o.startContainer=r.startContainer,o}for(var i,a,c=n.end&&n.end!==n.start,l=0,p=document.createRange(),u=s(e).select(Node.TEXT_NODE).revisit(!1),d=n.start>e.textContent.length?e.textContent.length:n.start,m=n.end>e.textContent.length?e.textContent.length:n.end,h=n.atStart;i=u.next();){var g=l;l+=i.textContent.length;var y=h?l>d:l>=d;if(!a&&y&&(a=!0,p.setStart(i,d-g),!c)){p.collapse(!0),f(e,p);break}if(c&&l>=m){p.setEnd(i,m-g),f(e,p);break}}}function f(e,n){var t=window.getSelection();e.focus(),t.removeAllRanges(),t.addRange(n)}a=a&&a.hasOwnProperty("default")?a.default:a,s=s&&s.hasOwnProperty("default")?s.default:s;var m="default"in c?c.default:c;p=p&&p.hasOwnProperty("default")?p.default:p,u=u&&u.hasOwnProperty("default")?u.default:u;var h=function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.filter(Boolean).join(" ")},g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"jsx";return n.highlight(e,n.languages[t])},y=function(e){return e.replace(/^((\t| )+)/gm,function(e,n){return n.replace(/\t/g," ")})},v=function(e){return e.replace("\n","<br>")},C=function(e){return a(e.replace(/<br>/gm,"\n").replace(/<\/?[^>]*>/gm,""))},k=function(e,n){var t=e.slice(0,n),o=t.lastIndexOf("\n")+1;return t.slice(o)},b=function(e,n){var t=k(e,n).match(/^\s+/);return null===t?"":t[0]||""},S=/^(\t| )* $/,E=function(e,n){var t=k(e,n);return S.test(t)?2:0},w=function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")},j=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},x=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)},T=function(e,n){var t={};for(var o in e)n.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},O=function(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?e:n},P=function(e){function n(){var t,o,r;w(this,n);for(var i=arguments.length,a=Array(i),s=0;s<i;s++)a[s]=arguments[s];return t=o=O(this,e.call.apply(e,[this].concat(a))),o.undoStack=[],o.undoOffset=0,o.undoTimestamp=0,o.compositing=!1,o.state={html:""},o.onRef=function(e){o.ref=e},o.getPlain=function(){if(o._innerHTML===o.ref.innerHTML)return o._plain;var e=C(v(o.ref.innerHTML));return o._plain=e,o._innerHTML=o.ref.innerHTML,o._plain},o.recordChange=function(e,n){if(e!==o.undoStack[o.undoStack.length-1]){o.undoOffset>0&&(o.undoStack=o.undoStack.slice(0,-o.undoOffset),o.undoOffset=0);var t=Date.now(),r={plain:e,selection:n};t-o.undoTimestamp<3e3?o.undoStack[o.undoStack.length-1]=r:(o.undoStack.push(r),o.undoStack.length>50&&o.undoStack.shift()),o.undoTimestamp=t}},o.updateContent=function(e){o.compositing||(o.setState({html:g(e,o.props.language)}),o.props.onChange&&o.props.onChange(e))},o.restoreStackState=function(e){var n=o.undoStack[o.undoStack.length-1-e],t=n.plain,r=n.selection;o.selection=r,o.undoOffset=e,o.updateContent(t)},o.undo=function(){var e=o.undoOffset+1;e>=o.undoStack.length||o.restoreStackState(e)},o.redo=function(){var e=o.undoOffset-1;e<0||o.restoreStackState(e)},o.onKeyDown=function(e){if(o.props.onKeyDown&&o.props.onKeyDown(e),9!==e.keyCode||o.props.ignoreTabKey)if(8===e.keyCode){var n=d(o.ref),t=n.start;if(t!==n.end)return;var r=E(o.getPlain(),t);if(r<=0)return;for(var i=0;i<r;i++)document.execCommand("delete",!1);e.preventDefault()}else if(13===e.keyCode){var a=d(o.ref).start,s=b(o.getPlain(),a);document.execCommand("insertHTML",!1,"\n"+s),e.preventDefault()}else 90!==e.keyCode||e.metaKey===e.ctrlKey||e.altKey||(e.shiftKey?o.redo():o.undo(),e.preventDefault());else document.execCommand("insertHTML",!1," "),e.preventDefault()},o.onKeyUp=function(e){if(o.props.onKeyUp&&o.props.onKeyUp(e),91!==e.keyCode&&93!==e.keyCode&&!e.ctrlKey&&!e.metaKey)if(13===e.keyCode&&(o.undoTimestamp=0),o.selection=d(o.ref),37!==e.keyCode&&38!==e.keyCode&&39!==e.keyCode&&40!==e.keyCode){var n=o.getPlain();o.recordChange(n,o.selection),o.updateContent(n)}else o.undoTimestamp=0},o.onCompositionStart=function(e){o.props.onCompositionStart&&o.props.onCompositionStart(e),o.compositing=!0},o.onCompositionEnd=function(e){o.props.onCompositionEnd&&o.props.onCompositionEnd(e),o.compositing=!1},o.onClick=function(e){o.props.onClick&&o.props.onClick(e),o.undoTimestamp=0,o.selection=d(o.ref)},r=t,O(o,r)}return x(n,e),n.prototype.componentWillMount=function(){var e=g(y(this.props.code),this.props.language);this.setState({html:e})},n.prototype.componentDidMount=function(){this.recordChange(this.getPlain()),this.undoTimestamp=0},n.prototype.componentWillReceiveProps=function(e){var n=e.code,t=e.language;if(n!==this.props.code||t!==this.props.language){var o=g(y(n),t);this.setState({html:o})}},n.prototype.componentDidUpdate=function(){var e=this.selection;e&&d(this.ref,e)},n.prototype.render=function(){var e=this.props,n=e.contentEditable,t=(e.className,e.style),o=(e.code,e.ignoreTabKey,e.language,T(e,["contentEditable","className","style","code","ignoreTabKey","language"])),r=this.state.html;return m.createElement("pre",j({},o,{ref:this.onRef,className:h(),style:t,spellCheck:"false",contentEditable:n,onCompositionEnd:n?this.onCompositionEnd:void 0,onCompositionStart:n?this.onCompositionStart:void 0,onKeyDown:n?this.onKeyDown:void 0,onKeyUp:n?this.onKeyUp:void 0,onClick:n?this.onClick:void 0,dangerouslySetInnerHTML:{__html:r}}))},n}(c.Component);P.defaultProps={contentEditable:!0,language:"jsx"};var K={assign:p},_={objectAssign:"_poly.assign",transforms:{dangerousForOf:!0,dangerousTaggedTemplateString:!0}},N=function(e){return l.transform(e,_).code},D=function(e,n){return function(t){function o(){return w(this,o),O(this,t.apply(this,arguments))}return x(o,t),o.prototype.componentDidCatch=function(e){n(e)},o.prototype.render=function(){return"function"==typeof e?m.createElement(e,null):e},o}(m.Component)},I=function(e,n){var t=Object.keys(n),o=t.map(function(e){return n[e]});return(new(Function.prototype.bind.apply(Function,[null].concat(["_poly","React"],t,[e])))).apply(void 0,[K,m].concat(o))},L=function(e,n){var t=e.code,o=void 0===t?"":t,r=e.scope,i=void 0===r?{}:r,a=o.trim().replace(/;$/,""),s=N("("+a+")").trim();return D(I("return "+s,i),n)},M=function(e,n,t){var o=e.code,r=void 0===o?"":o,i=e.scope,a=void 0===i?{}:i,s=function(e){n(D(e,t))};if(!/render\s*\(/.test(r))return t(new SyntaxError("No-Inline evaluations must call `render`."));I(N(r),j({},a,{render:s}))},R=m.createElement("style",{dangerouslySetInnerHTML:{__html:"\n.prism-code {\n display: block;\n white-space: pre;\n\n background-color: #1D1F21;\n color: #C5C8C6;\n\n padding: 0.5rem;\n margin: 0;\n\n box-sizing: border-box;\n vertical-align: baseline;\n outline: none;\n text-shadow: none;\n -webkit-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n word-wrap: normal;\n word-break: normal;\n text-align: left;\n word-spacing: normal;\n -moz-tab-size: 2;\n -o-tab-size: 2;\n tab-size: 2;\n}\n\n.token.comment,\n.token.prolog,\n.token.doctype,\n.token.cdata {\n color: hsl(30, 20%, 50%);\n}\n\n.token.punctuation {\n opacity: .7;\n}\n\n.namespace {\n opacity: .7;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol {\n color: hsl(350, 40%, 70%);\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.inserted {\n color: hsl(75, 70%, 60%);\n}\n\n.token.operator,\n.token.entity,\n.token.url,\n.language-css .token.string,\n.style .token.string,\n.token.variable {\n color: hsl(40, 90%, 60%);\n}\n\n.token.atrule,\n.token.attr-value,\n.token.keyword {\n color: hsl(350, 40%, 70%);\n}\n\n.token.regex,\n.token.important {\n color: #e90;\n}\n\n.token.important,\n.token.bold {\n font-weight: bold;\n}\n.token.italic {\n font-style: italic;\n}\n\n.token.entity {\n cursor: help;\n}\n\n.token.deleted {\n color: red;\n}\n"}}),q=function(){return R},A={live:u.shape({code:u.string,error:u.string,onError:u.func,onChange:u.func,element:u.oneOfType([u.string,u.number,u.element,u.func])})},H=function(e){function n(){var t,o,r;w(this,n);for(var i=arguments.length,a=Array(i),s=0;s<i;s++)a[s]=arguments[s];return t=o=O(this,e.call.apply(e,[this].concat(a))),o.onChange=function(e){var n=o.props,t=n.scope,r=n.transformCode,i=n.noInline;o.transpile({code:e,scope:t,transformCode:r,noInline:i})},o.onError=function(e){o.setState({error:e.toString()})},o.transpile=function(e){var n=e.code,t=e.scope,r=e.transformCode,i=e.noInline,a=void 0!==i&&i,s={code:r?r(n):n,scope:t},c=function(e){return o.setState({element:void 0,error:e.toString()})},l=function(e){return o.setState(j({},p,{element:e}))},p={unsafeWrapperError:void 0,error:void 0};try{a?(o.setState(j({},p,{element:null})),M(s,l,c)):l(L(s,c))}catch(e){o.setState(j({},p,{error:e.toString()}))}},o.getChildContext=function(){return{live:j({},o.state,{code:o.props.code,onError:o.onError,onChange:o.onChange})}},r=t,O(o,r)}return x(n,e),n.prototype.componentWillMount=function(){var e=this.props,n=e.code,t=e.scope,o=e.transformCode,r=e.noInline;this.transpile({code:n,scope:t,transformCode:o,noInline:r})},n.prototype.componentWillReceiveProps=function(e){var n=e.code,t=e.scope,o=e.noInline,r=e.transformCode;n===this.props.code&&t===this.props.scope&&o===this.props.noInline&&r===this.props.transformCode||this.transpile({code:n,scope:t,transformCode:r,noInline:o})},n.prototype.render=function(){var e=this.props,n=e.children,t=(e.className,e.code,e.mountStylesheet),o=(e.noInline,e.transformCode,e.scope,T(e,["children","className","code","mountStylesheet","noInline","transformCode","scope"]));return m.createElement("div",j({className:h()},o),t&&m.createElement(q,null),n)},n}(c.Component);H.childContextTypes=A,H.defaultProps={code:"",mountStylesheet:!0,noInline:!1};var U=function(e,n){var t=n.live;return m.createElement(P,j({},e,{code:t.code,onChange:function(n){t.onChange(n),"function"==typeof e.onChange&&e.onChange(n)}}))};U.contextTypes=A;var z=function(e,n){var t=n.live,o=(e.className,T(e,["className"]));return t.error?m.createElement("div",j({},o,{className:h()}),t.error):null};z.contextTypes=A;var W=function(e,n){var t=n.live.element,o=(e.className,T(e,["className"])),r=t;return m.createElement("div",j({},o,{className:h()}),r&&m.createElement(r,null))};W.contextTypes=A;var F=function(e){var n=function(n){function t(){return w(this,t),O(this,n.apply(this,arguments))}return x(t,n),t.prototype.render=function(){var n=this.context.live;return m.createElement(e,j({live:n},this.props))},t}(c.Component);return n.contextTypes=A,n};e.Editor=P,e.LiveProvider=H,e.LiveEditor=U,e.LiveError=z,e.LivePreview=W,e.withLive=F,e.generateElement=L,e.renderElementAsync=M,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "react-live", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "A production-focused playground for live editing React code", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-live.cjs.js", |
@@ -10,3 +10,3 @@ import React, { Component } from 'react' | ||
const { live } = this.context | ||
return <WrappedComponent live={live} /> | ||
return <WrappedComponent live={live} {...this.props} /> | ||
} | ||
@@ -13,0 +13,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
164299
1