New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

megadraft-youtube-plugin

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

megadraft-youtube-plugin - npm Package Compare versions

Comparing version

to
1.3.1

2

dist/youtube.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("Megadraft")):"function"==typeof define&&define.amd?define(["React","Megadraft"],t):"object"==typeof exports?exports.youtube=t(require("React"),require("Megadraft")):e.youtube=t(e.React,e.Megadraft)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/dist/",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),u=r(o),a=n(7),i=r(a),l=n(5),c=r(l);t.default={title:c.default.PLUGIN_NAME,type:c.default.PLUGIN_TYPE,buttonComponent:u.default,blockComponent:i.default,options:{defaultDisplay:"",displayOptions:[]}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=n(4),s=r(f),p=n(5),d=r(p),h=n(6),y=function(e){function t(e){o(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onClick=n.onClick.bind(n),n}return a(t,e),i(t,[{key:"onClick",value:function(e){var t={type:d.default.PLUGIN_TYPE};this.props.onChange((0,h.insertDataBlock)(this.props.editorState,t))}},{key:"render",value:function(){return c.default.createElement("button",{className:this.props.className,type:"button",onClick:this.onClick,title:d.default.PLUGIN_NAME},c.default.createElement(s.default,{className:"sidemenu__button__icon"}))}}]),t}(l.Component);t.default=y},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(3),f=r(c),s=function(e){function t(){return o(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),l(t,[{key:"render",value:function(){return f.default.createElement("svg",i({},this.props,{width:"24",height:"24",viewBox:"0 0 24 24"}),f.default.createElement("path",{fill:"currentColor",d:"M10 9v6l5-3-5-3zm8.222-3H5.778C4.8 6 4 6.6 4 7.333v9.334C4 17.4 4.8 18 5.778 18h12.444C19.2 18 20 17.4 20 16.667V7.333C20 6.6 19.2 6 18.222 6z",fillRule:"evenodd"}))}}]),t}(f.default.Component);t.default=s},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={PLUGIN_NAME:"YouTube",PLUGIN_TYPE:"youtube"}},function(e,n){e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){var n=[],r=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,u=e}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=n(3),s=r(f),p=n(6),d=n(8),h=r(d),y=n(9),b=r(y),v=n(10),_=r(v),m=p.MegadraftPlugin.BlockContent,w=p.MegadraftPlugin.BlockData,g=p.MegadraftPlugin.BlockInput,O=p.MegadraftPlugin.CommonBlock,E=function(e){function t(e){o(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onChangeInput=n.onChangeInput.bind(n),n.loadMedia=(0,h.default)(n.loadMedia.bind(n),800),n.actions=[{key:"delete",icon:p.MegadraftIcons.DeleteIcon,action:n.props.container.remove}],n.state=n.buildInitialState(e.data.videoID),n}return a(t,e),c(t,[{key:"buildInitialState",value:function(e){return{videoID:e,url:e?"https://www.youtube.com/embed/"+e:"",errors:[],unexpectedErrors:[]}}},{key:"componentDidUpdate",value:function(e,t){this.state.url&&t.url!==this.state.url&&this.loadMedia()}},{key:"onChangeInput",value:function(e){this.setState({url:e.target.value,errors:[],unexpectedErrors:[]})}},{key:"validate",value:function(e){var t=void 0,n=[],r=[];try{var o=new _.default(e);t=o.getVideoID()}catch(e){console.error(e),e instanceof v.YouTubeURLException?n.push(e.message):r.push(e.message)}return[t,n,r]}},{key:"loadMedia",value:function(){var e=this.state.url,t=this.validate(e),n=l(t,3),r=n[0],o=n[1],u=n[2];this.setState({videoID:r,errors:o,unexpectedErrors:u}),this.props.container.updateData({videoID:r})}},{key:"renderContent",value:function(){var e=s.default.createElement("pre",null,__("PREVIEW"));return this.state.errors.length>0?e=s.default.createElement("pre",null,this.state.errors[0].toUpperCase()):this.state.unexpectedErrors.length>0?e=[s.default.createElement(p.MegadraftMediaMessage,{type:"error",text:this.state.unexpectedErrors[0]}),e]:this.state.videoID&&(e=s.default.createElement(b.default,{videoID:this.state.videoID})),e}},{key:"render",value:function(){return s.default.createElement(O,i({},this.props,{actions:this.actions}),s.default.createElement(m,null,this.renderContent()),s.default.createElement(w,null,s.default.createElement(g,{placeholder:__("Enter a YouTube URL"),value:this.state.url?this.state.url:"",onChange:this.onChangeInput})))}}]),t}(s.default.Component);t.default=E},function(e,t){e.exports=function(e,t,n){function r(){var c=Date.now()-i;c<t&&c>=0?o=setTimeout(r,t-c):(o=null,n||(l=e.apply(a,u),a=u=null))}var o,u,a,i,l;null==t&&(t=100);var c=function(){a=this,u=arguments,i=Date.now();var c=n&&!o;return o||(o=setTimeout(r,t)),c&&(l=e.apply(a,u),a=u=null),l};return c.clear=function(){o&&(clearTimeout(o),o=null)},c}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=function(e){function t(){return o(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),i(t,[{key:"render",value:function(){if(!this.props.videoID)return null;var e="https://www.youtube.com/embed/"+this.props.videoID;return c.default.createElement("div",{className:"megadraft-youtube"},c.default.createElement("iframe",{src:e,width:"640px",height:"360px",frameBorder:"0",allowFullScreen:!0}))}}]),t}(l.Component);t.default=f},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){this.message=e,this.name="YouTubeURLException"}function o(e){return e.searchParams.get("v")}function u(e){return e.pathname.split("/").pop()}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.YouTubeURLException=r;var i={web:o,embed:u,shortener:u},l=function(){function e(t){n(this,e),this.url=this.validate(t)}return a(e,[{key:"getVideoID",value:function(){var e=i[this.getUrlType()];return e(this.url)}},{key:"validate",value:function(e){var t=void 0;try{t=new URL(e)}catch(e){throw new r(__("Invalid URL"))}var n=this.getUrlType(t);if(!n)throw new r(__("Invalid YouTube URL"));return t}},{key:"getUrlType",value:function(e){return this._urlType||(e.href.includes("youtube.com/watch")?this._urlType="web":e.href.includes("youtube.com/embed")?this._urlType="embed":e.href.includes("youtu.be")&&(this._urlType="shortener")),this._urlType}}]),e}();t.default=l}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("Megadraft")):"function"==typeof define&&define.amd?define(["React","Megadraft"],t):"object"==typeof exports?exports.youtube=t(require("React"),require("Megadraft")):e.youtube=t(e.React,e.Megadraft)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/dist/",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),u=r(o),a=n(7),i=r(a),l=n(5),c=r(l);t.default={title:c.default.PLUGIN_NAME,type:c.default.PLUGIN_TYPE,buttonComponent:u.default,blockComponent:i.default,options:{defaultDisplay:"",displayOptions:[]}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=n(4),s=r(f),p=n(5),d=r(p),h=n(6),v=function(e){function t(e){o(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onClick=n.onClick.bind(n),n}return a(t,e),i(t,[{key:"onClick",value:function(e){var t={type:d.default.PLUGIN_TYPE};this.props.onChange((0,h.insertDataBlock)(this.props.editorState,t))}},{key:"render",value:function(){return c.default.createElement("button",{className:this.props.className,type:"button",onClick:this.onClick,title:d.default.PLUGIN_NAME},c.default.createElement(s.default,{className:"sidemenu__button__icon"}))}}]),t}(l.Component);t.default=v},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(3),f=r(c),s=function(e){function t(){return o(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),l(t,[{key:"render",value:function(){return f.default.createElement("svg",i({},this.props,{width:"24",height:"24",viewBox:"0 0 24 24"}),f.default.createElement("path",{fill:"currentColor",d:"M14.643 16.66v2.827c0 .598-.174.897-.522.897-.205 0-.406-.098-.602-.295v-4.032c.196-.196.397-.295.603-.295.35 0 .523.3.523.898zm4.527.014v.616h-1.206v-.616c0-.607.2-.91.603-.91.402 0 .603.303.603.91zm-12.938-2.92h1.433v-1.258H3.487v1.258h1.406v7.62h1.34v-7.62zm3.857 7.62h1.19V14.76h-1.19v5.06c-.27.376-.523.564-.764.564-.16 0-.255-.094-.28-.28-.01-.028-.015-.184-.015-.47V14.76H7.84v5.236c0 .437.035.763.106.977.108.33.367.496.777.496.43 0 .884-.274 1.366-.818v.723zm5.745-1.98v-2.64c0-.65-.04-1.093-.12-1.325-.152-.5-.47-.75-.952-.75-.446 0-.86.24-1.245.722v-2.906h-1.192v8.88h1.192v-.644c.402.49.817.737 1.245.737.483 0 .8-.247.95-.738.082-.24.122-.687.122-1.34zm4.527-.135v-.175h-1.22c0 .455-.008.727-.026.817-.062.32-.24.482-.536.482-.41 0-.616-.308-.616-.924v-1.165h2.398v-1.38c0-.705-.12-1.223-.362-1.553-.348-.456-.82-.683-1.42-.683-.607 0-1.084.226-1.433.682-.25.33-.375.848-.375 1.553v2.317c0 .706.13 1.223.39 1.554.347.455.83.683 1.445.683.643 0 1.125-.238 1.447-.71.16-.242.254-.483.28-.724.02-.08.028-.34.028-.777zM12.22 7.03V4.22c0-.617-.193-.925-.577-.925-.384 0-.576.308-.576.924v2.81c0 .626.192.94.576.94.384 0 .576-.314.576-.94zm9.628 10.06c0 2.09-.116 3.65-.348 4.687-.125.527-.384.97-.777 1.326-.393.357-.848.562-1.366.616-1.643.186-4.12.28-7.433.28-3.312 0-5.79-.094-7.433-.28-.517-.055-.974-.26-1.372-.617-.397-.357-.654-.8-.77-1.326-.232-1-.348-2.563-.348-4.688 0-2.09.116-3.652.348-4.688.125-.527.384-.97.777-1.326.393-.357.853-.567 1.38-.63 1.633-.178 4.107-.267 7.42-.267 3.312 0 5.79.088 7.432.266.518.063.976.273 1.373.63s.654.8.77 1.326c.232 1 .348 2.562.348 4.687zM8.482 0h1.366l-1.62 5.344v3.63h-1.34v-3.63c-.125-.66-.397-1.607-.817-2.84C5.74 1.584 5.45.75 5.2 0h1.42l.95 3.522L8.483 0zm4.956 4.46v2.344c0 .723-.126 1.25-.376 1.58-.33.455-.803.683-1.42.683-.597 0-1.066-.228-1.405-.683-.25-.34-.375-.866-.375-1.58V4.46c0-.714.125-1.237.375-1.567.34-.455.808-.683 1.406-.683.616 0 1.09.228 1.42.683.25.33.374.853.374 1.567zm4.486-2.17v6.683h-1.22v-.736c-.472.553-.932.83-1.378.83-.41 0-.674-.165-.79-.496-.072-.213-.107-.548-.107-1.003V2.29h1.217v4.915c0 .295.005.45.014.47.027.196.12.294.282.294.24 0 .495-.193.763-.577V2.29h1.22z"}))}}]),t}(f.default.Component);t.default=s},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={PLUGIN_NAME:"YouTube",PLUGIN_TYPE:"youtube"}},function(e,n){e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){var n=[],r=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,u=e}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=n(3),s=r(f),p=n(6),d=n(8),h=r(d),v=n(9),y=r(v),b=n(10),m=r(b),_=p.MegadraftPlugin.BlockContent,w=p.MegadraftPlugin.BlockData,g=p.MegadraftPlugin.BlockInput,O=p.MegadraftPlugin.CommonBlock,E=function(e){function t(e){o(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onChangeInput=n.onChangeInput.bind(n),n.loadMedia=(0,h.default)(n.loadMedia.bind(n),800),n.actions=[{key:"delete",icon:p.MegadraftIcons.DeleteIcon,action:n.props.container.remove}],n.state=n.buildInitialState(e.data.videoID),n}return a(t,e),c(t,[{key:"buildInitialState",value:function(e){return{videoID:e,url:e?"https://www.youtube.com/embed/"+e:"",errors:[],unexpectedErrors:[]}}},{key:"componentDidUpdate",value:function(e,t){this.state.url&&t.url!==this.state.url&&this.loadMedia()}},{key:"onChangeInput",value:function(e){this.setState({url:e.target.value,errors:[],unexpectedErrors:[]})}},{key:"validate",value:function(e){var t=void 0,n=[],r=[];try{var o=new m.default(e);t=o.getVideoID()}catch(e){console.error(e),e instanceof b.YouTubeURLException?n.push(e.message):r.push(e.message)}return[t,n,r]}},{key:"loadMedia",value:function(){var e=this.state.url,t=this.validate(e),n=l(t,3),r=n[0],o=n[1],u=n[2];this.setState({videoID:r,errors:o,unexpectedErrors:u}),this.props.container.updateData({videoID:r})}},{key:"renderContent",value:function(){var e=s.default.createElement("pre",null,__("PREVIEW"));return this.state.errors.length>0?e=s.default.createElement("pre",null,this.state.errors[0].toUpperCase()):this.state.unexpectedErrors.length>0?e=[s.default.createElement(p.MegadraftMediaMessage,{type:"error",text:this.state.unexpectedErrors[0]}),e]:this.state.videoID&&(e=s.default.createElement(y.default,{videoID:this.state.videoID})),e}},{key:"render",value:function(){return s.default.createElement(O,i({},this.props,{actions:this.actions}),s.default.createElement(_,null,this.renderContent()),s.default.createElement(w,null,s.default.createElement(g,{placeholder:__("Enter a YouTube URL"),value:this.state.url?this.state.url:"",onChange:this.onChangeInput})))}}]),t}(s.default.Component);t.default=E},function(e,t){e.exports=function(e,t,n){function r(){var c=Date.now()-i;c<t&&c>=0?o=setTimeout(r,t-c):(o=null,n||(l=e.apply(a,u),a=u=null))}var o,u,a,i,l;null==t&&(t=100);var c=function(){a=this,u=arguments,i=Date.now();var c=n&&!o;return o||(o=setTimeout(r,t)),c&&(l=e.apply(a,u),a=u=null),l};return c.clear=function(){o&&(clearTimeout(o),o=null)},c}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=function(e){function t(){return o(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),i(t,[{key:"render",value:function(){if(!this.props.videoID)return null;var e="https://www.youtube.com/embed/"+this.props.videoID;return c.default.createElement("div",{className:"megadraft-youtube"},c.default.createElement("iframe",{src:e,width:"640px",height:"360px",frameBorder:"0",allowFullScreen:!0}))}}]),t}(l.Component);t.default=f},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){this.message=e,this.name="YouTubeURLException"}function o(e){return e.searchParams.get("v")}function u(e){return e.pathname.split("/").pop()}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.YouTubeURLException=r;var i={web:o,embed:u,shortener:u},l=function(){function e(t){n(this,e),this.url=this.validate(t)}return a(e,[{key:"getVideoID",value:function(){var e=i[this.getUrlType()];return e(this.url)}},{key:"validate",value:function(e){var t=void 0;try{t=new URL(e)}catch(e){throw new r(__("Invalid URL"))}var n=this.getUrlType(t);if(!n)throw new r(__("Invalid YouTube URL"));return t}},{key:"getUrlType",value:function(e){return this._urlType||(e.href.includes("youtube.com/watch")?this._urlType="web":e.href.includes("youtube.com/embed")?this._urlType="embed":e.href.includes("youtu.be")&&(this._urlType="shortener")),this._urlType}}]),e}();t.default=l}])});
//# sourceMappingURL=youtube.js.map

@@ -43,3 +43,3 @@ "use strict";

_extends({}, this.props, { width: "24", height: "24", viewBox: "0 0 24 24" }),
_react2.default.createElement("path", { fill: "currentColor", d: "M10 9v6l5-3-5-3zm8.222-3H5.778C4.8 6 4 6.6 4 7.333v9.334C4 17.4 4.8 18 5.778 18h12.444C19.2 18 20 17.4 20 16.667V7.333C20 6.6 19.2 6 18.222 6z", fillRule: "evenodd" })
_react2.default.createElement("path", { fill: "currentColor", d: "M14.643 16.66v2.827c0 .598-.174.897-.522.897-.205 0-.406-.098-.602-.295v-4.032c.196-.196.397-.295.603-.295.35 0 .523.3.523.898zm4.527.014v.616h-1.206v-.616c0-.607.2-.91.603-.91.402 0 .603.303.603.91zm-12.938-2.92h1.433v-1.258H3.487v1.258h1.406v7.62h1.34v-7.62zm3.857 7.62h1.19V14.76h-1.19v5.06c-.27.376-.523.564-.764.564-.16 0-.255-.094-.28-.28-.01-.028-.015-.184-.015-.47V14.76H7.84v5.236c0 .437.035.763.106.977.108.33.367.496.777.496.43 0 .884-.274 1.366-.818v.723zm5.745-1.98v-2.64c0-.65-.04-1.093-.12-1.325-.152-.5-.47-.75-.952-.75-.446 0-.86.24-1.245.722v-2.906h-1.192v8.88h1.192v-.644c.402.49.817.737 1.245.737.483 0 .8-.247.95-.738.082-.24.122-.687.122-1.34zm4.527-.135v-.175h-1.22c0 .455-.008.727-.026.817-.062.32-.24.482-.536.482-.41 0-.616-.308-.616-.924v-1.165h2.398v-1.38c0-.705-.12-1.223-.362-1.553-.348-.456-.82-.683-1.42-.683-.607 0-1.084.226-1.433.682-.25.33-.375.848-.375 1.553v2.317c0 .706.13 1.223.39 1.554.347.455.83.683 1.445.683.643 0 1.125-.238 1.447-.71.16-.242.254-.483.28-.724.02-.08.028-.34.028-.777zM12.22 7.03V4.22c0-.617-.193-.925-.577-.925-.384 0-.576.308-.576.924v2.81c0 .626.192.94.576.94.384 0 .576-.314.576-.94zm9.628 10.06c0 2.09-.116 3.65-.348 4.687-.125.527-.384.97-.777 1.326-.393.357-.848.562-1.366.616-1.643.186-4.12.28-7.433.28-3.312 0-5.79-.094-7.433-.28-.517-.055-.974-.26-1.372-.617-.397-.357-.654-.8-.77-1.326-.232-1-.348-2.563-.348-4.688 0-2.09.116-3.652.348-4.688.125-.527.384-.97.777-1.326.393-.357.853-.567 1.38-.63 1.633-.178 4.107-.267 7.42-.267 3.312 0 5.79.088 7.432.266.518.063.976.273 1.373.63s.654.8.77 1.326c.232 1 .348 2.562.348 4.687zM8.482 0h1.366l-1.62 5.344v3.63h-1.34v-3.63c-.125-.66-.397-1.607-.817-2.84C5.74 1.584 5.45.75 5.2 0h1.42l.95 3.522L8.483 0zm4.956 4.46v2.344c0 .723-.126 1.25-.376 1.58-.33.455-.803.683-1.42.683-.597 0-1.066-.228-1.405-.683-.25-.34-.375-.866-.375-1.58V4.46c0-.714.125-1.237.375-1.567.34-.455.808-.683 1.406-.683.616 0 1.09.228 1.42.683.25.33.374.853.374 1.567zm4.486-2.17v6.683h-1.22v-.736c-.472.553-.932.83-1.378.83-.41 0-.674-.165-.79-.496-.072-.213-.107-.548-.107-1.003V2.29h1.217v4.915c0 .295.005.45.014.47.027.196.12.294.282.294.24 0 .495-.193.763-.577V2.29h1.22z" })
);

@@ -46,0 +46,0 @@ }

{
"name": "megadraft-youtube-plugin",
"version": "1.3.0",
"version": "1.3.1",
"description": "megadraft-youtube-plugin",

@@ -5,0 +5,0 @@ "main": "dist/youtube.js",

Sorry, the diff of this file is not supported yet