Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

megadraft-embed

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

megadraft-embed - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

7

dist/megadraft-embed.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Megadraft"),require("React")):"function"==typeof define&&define.amd?define(["Megadraft","React"],t):"object"==typeof exports?exports["megadraft-embed"]=t(require("Megadraft"),require("React")):e["megadraft-embed"]=t(e.Megadraft,e.React)}(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),a=n(3),i=r(a),u=n(7),l=r(u),s=n(6),c=r(s);t["default"]={type:c["default"].PLUGIN_TYPE,buttonComponent:i["default"],blockComponent:l["default"],options:{defaultDisplay:"medium",displayOptions:[{key:"small",icon:o.MegadraftIcons.MediaSmallIcon,label:"SMALL"},{key:"medium",icon:o.MegadraftIcons.MediaMediumIcon,label:"MEDIUM"},{key:"big",icon:o.MegadraftIcons.MediaBigIcon,label:"BIG"}]}}},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var 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}}(),s=n(4),c=r(s),f=n(5),d=r(f),p=n(6),m=r(p),y=n(2),h=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onClick=n.onClick.bind(n),n}return i(t,e),l(t,[{key:"onClick",value:function(e){var t={type:m["default"].PLUGIN_TYPE,caption:"Initial plugin text"};this.props.onChange((0,y.insertDataBlock)(this.props.editorState,t))}},{key:"render",value:function(){return c["default"].createElement("button",{className:this.props.className,type:"button",onClick:this.onClick},c["default"].createElement(d["default"],{className:"sidemenu__button__icon"}))}}]),t}(s.Component);t["default"]=h},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var l=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},s=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(4),f=r(c),d=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),s(t,[{key:"render",value:function(){return f["default"].createElement("svg",l({},this.props,{width:"24",height:"24",viewBox:"0 0 24 24"}),f["default"].createElement("g",{fill:"none",fillRule:"evenodd"},f["default"].createElement("path",{d:"M0 0h24v24H0z"}),f["default"].createElement("path",{d:"M19.095 11.619h-1.143V8.571c0-.838-.685-1.523-1.523-1.523H13.38V5.905a1.905 1.905 0 0 0-3.81 0v1.143H6.524c-.838 0-1.516.685-1.516 1.523v2.896h1.135a2.058 2.058 0 0 1 0 4.114H5v2.895C5 19.314 5.686 20 6.524 20h2.895v-1.143a2.058 2.058 0 0 1 4.114 0V20h2.896c.838 0 1.523-.686 1.523-1.524V15.43h1.143a1.905 1.905 0 0 0 0-3.81z",fill:"currentColor"})))}}]),t}(f["default"].Component);t["default"]=d},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={PLUGIN_TYPE:"megadraft-embed"}},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var l=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},s=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(4),f=r(c),d=n(2),p=n(8),m=r(p),y=n(!function(){var e=new Error('Cannot find module "components/Button"');throw e.code="MODULE_NOT_FOUND",e}()),h=r(y),b=n(!function(){var e=new Error('Cannot find module "components/Icon"');throw e.code="MODULE_NOT_FOUND",e}()),_=r(b),v=d.MegadraftPlugin.BlockContent,g=d.MegadraftPlugin.BlockData,w=d.MegadraftPlugin.BlockInput,E=d.MegadraftPlugin.CommonBlock,k=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._handleEdit=n._handleEdit.bind(n),n.actions=[{key:"edit",icon:d.MegadraftIcons.EditIcon,action:n._handleEdit},{key:"delete",icon:d.MegadraftIcons.DeleteIcon,action:n.props.container.remove}],n.sources=["facebook","instagram","twitter","youtube","playbuzz","map"],n.state={url:"",sourceType:"facebook",errors:[],twitId:null,form:{url:""}},n}return i(t,e),s(t,[{key:"componentDidUpdate",value:function(e,t){"facebook"===this.state.sourceType&&(window.fbAsyncInit=function(){FB.init({xfbml:!0,version:"v2.8"}),window.FB=FB,window.FB.XFBML.parse()},function(e,t,n){var r,o=e.getElementsByTagName(t)[0];e.getElementById(n)||(r=e.createElement(t),r.id=n,r.src="//connect.facebook.net/en_US/sdk.js",o.parentNode.insertBefore(r,o))}(document,"script","facebook-jssdk"),window.FB&&window.FB.XFBML.parse()),"twitter"===this.state.sourceType&&(this.state.twitId&&t.twitId!=this.state.twitId?window.twttr.widgets.createTweet(this.state.twitId,document.getElementById("twit-"+this.state.twitId),{align:"center"}):document.getElementById("twit-"+this.state.twitId)&&(document.getElementById("twit-"+this.state.twitId).innerHTML=""))}},{key:"_handleEdit",value:function(){var e=this._getPluginData();alert(JSON.stringify(e,null,4))}},{key:"_getPluginData",value:function(){var e={sourceType:null,url:null};return this.state.url&&(e.url=this.state.url,e.sourceType=this.state.sourceType),e}},{key:"_onChangeForm",value:function(e,t){var n=this.state.form;n[e]=t.target.value,this.setState({form:n})}},{key:"_setSourceType",value:function(e,t){this.setState({sourceType:e,url:""})}},{key:"_embed",value:function(e){var t=this._getValidatedData();this.setState({url:t.url,twitId:t.twitId})}},{key:"_getValidatedData",value:function(){var e=this.state.form.url,t=[];e=e.trim(),m["default"].isUri(e)||t.push("Invalid URL");var n=null;if("twitter"===this.state.sourceType){var r=/\/(\d+)/,o=e.match(r);o&&o.length>=2?n=o[1]:t.push("Invalid Twitter URL")}return this.setState({errors:t}),{url:e,twitId:n}}},{key:"_renderSources",value:function(){var e=this;return this.sources.map(function(t,n){return f["default"].createElement(_["default"],{key:n,type:t,onClick:e._setSourceType.bind(e,t),active:t===e.state.sourceType})})}},{key:"_renderEmbed",value:function(){if(!this.state.url)return null;switch(this.state.sourceType){case"youtube":return this._renderYoutube();case"facebook":return this._renderFacebook();case"playbuzz":return this._renderPlayBuzz();case"instagram":return this._renderInstagram();case"twitter":return this._renderTwitter();case"map":return this._renderMap()}}},{key:"_renderYoutube",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url}))}},{key:"_renderFacebook",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{className:"fb-post","data-href":this.state.url,"data-width":"500"}))}},{key:"_renderPlayBuzz",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{className:"pb_feed","data-game":this.state.url,"data-recommend":"false","data-game-info":"false","data-comments":"false","data-shares":"false"}))}},{key:"_renderInstagram",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url+"/embed/"}))}},{key:"_renderTwitter",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{id:"twit-"+this.state.twitId}))}},{key:"_renderMap",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url}))}},{key:"_renderErrors",value:function(){if(this.state.errors.length)return f["default"].createElement("ul",{className:"md-embed-errors"},this.state.errors.map(function(e,t){return f["default"].createElement("li",{key:t},e)}))}},{key:"render",value:function(){return f["default"].createElement(E,l({},this.props,{actions:this.actions}),f["default"].createElement(g,null,this._renderSources()),f["default"].createElement(g,null,f["default"].createElement(w,{placeholder:"URL",value:this.state.url?this.state.url:null,onChange:this._onChangeForm.bind(this,"url")}),this._renderErrors()),f["default"].createElement(g,null,f["default"].createElement(h["default"],{onClick:this._embed.bind(this),label:"Embed"})),f["default"].createElement(v,{className:"embed"},this._renderEmbed()))}}]),t}(c.Component);t["default"]=k},function(e,t,n){(function(e){!function(e){"use strict";function t(e){if(e&&!/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)&&!/%[^0-9a-f]/i.test(e)&&!/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e)){var t=[],n="",r="",o="",i="",u="",l="";if(t=a(e),n=t[1],r=t[2],o=t[3],i=t[4],u=t[5],n&&n.length&&o.length>=0){if(r&&r.length){if(0!==o.length&&!/^\//.test(o))return}else if(/^\/\//.test(o))return;if(/^[a-z][a-z0-9\+\-\.]*$/.test(n.toLowerCase()))return l+=n+":",r&&r.length&&(l+="//"+r),l+=o,i&&i.length&&(l+="?"+i),u&&u.length&&(l+="#"+u),l}}}function n(e,n){if(t(e)){var r=[],o="",i="",u="",l="",s="",c="",f="";if(r=a(e),o=r[1],i=r[2],u=r[3],s=r[4],c=r[5],o){if(n){if("https"!=o.toLowerCase())return}else if("http"!=o.toLowerCase())return;if(i)return/:(\d+)$/.test(i)&&(l=i.match(/:(\d+)$/)[0],i=i.replace(/:\d+$/,"")),f+=o+":",f+="//"+i,l&&(f+=l),f+=u,s&&s.length&&(f+="?"+s),c&&c.length&&(f+="#"+c),f}}}function r(e){return n(e,!0)}function o(e){return n(e)||r(e)}e.exports.is_uri=t,e.exports.is_http_uri=n,e.exports.is_https_uri=r,e.exports.is_web_uri=o,e.exports.isUri=t,e.exports.isHttpUri=n,e.exports.isHttpsUri=r,e.exports.isWebUri=o;var a=function(e){var t=e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);return t}}(e)}).call(t,n(9)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Megadraft"),require("React")):"function"==typeof define&&define.amd?define(["Megadraft","React"],t):"object"==typeof exports?exports["megadraft-embed"]=t(require("Megadraft"),require("React")):e["megadraft-embed"]=t(e.Megadraft,e.React)}(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),a=n(3),i=r(a),u=n(7),l=r(u),c=n(6),s=r(c);t["default"]={type:s["default"].PLUGIN_TYPE,buttonComponent:i["default"],blockComponent:l["default"],options:{defaultDisplay:"medium",displayOptions:[{key:"small",icon:o.MegadraftIcons.MediaSmallIcon,label:"SMALL"},{key:"medium",icon:o.MegadraftIcons.MediaMediumIcon,label:"MEDIUM"},{key:"big",icon:o.MegadraftIcons.MediaBigIcon,label:"BIG"}]}}},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var 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(4),s=r(c),f=n(5),d=r(f),p=n(6),m=r(p),y=n(2),b=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onClick=n.onClick.bind(n),n}return i(t,e),l(t,[{key:"onClick",value:function(e){var t={type:m["default"].PLUGIN_TYPE,caption:"Initial plugin text"};this.props.onChange((0,y.insertDataBlock)(this.props.editorState,t))}},{key:"render",value:function(){return s["default"].createElement("button",{className:this.props.className,type:"button",onClick:this.onClick},s["default"].createElement(d["default"],{className:"sidemenu__button__icon"}))}}]),t}(c.Component);t["default"]=b},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var l=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},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}}(),s=n(4),f=r(s),d=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),c(t,[{key:"render",value:function(){return f["default"].createElement("svg",l({},this.props,{width:"24",height:"24",viewBox:"0 0 24 24"}),f["default"].createElement("g",{fill:"none",fillRule:"evenodd"},f["default"].createElement("path",{d:"M0 0h24v24H0z"}),f["default"].createElement("path",{d:"M19.095 11.619h-1.143V8.571c0-.838-.685-1.523-1.523-1.523H13.38V5.905a1.905 1.905 0 0 0-3.81 0v1.143H6.524c-.838 0-1.516.685-1.516 1.523v2.896h1.135a2.058 2.058 0 0 1 0 4.114H5v2.895C5 19.314 5.686 20 6.524 20h2.895v-1.143a2.058 2.058 0 0 1 4.114 0V20h2.896c.838 0 1.523-.686 1.523-1.524V15.43h1.143a1.905 1.905 0 0 0 0-3.81z",fill:"currentColor"})))}}]),t}(f["default"].Component);t["default"]=d},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={PLUGIN_TYPE:"megadraft-embed"}},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 a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":u(t))&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":u(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)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=void 0;var l=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},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}}(),s=n(4),f=r(s),d=n(2),p=n(8),m=r(p),y=n(10),b=r(y),h=n(11),_=r(h),v=d.MegadraftPlugin.BlockContent,w=d.MegadraftPlugin.BlockData,g=d.MegadraftPlugin.BlockInput,E=d.MegadraftPlugin.CommonBlock,k=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._handleEdit=n._handleEdit.bind(n),n.actions=[{key:"edit",icon:d.MegadraftIcons.EditIcon,action:n._handleEdit},{key:"delete",icon:d.MegadraftIcons.DeleteIcon,action:n.props.container.remove}],n.sources=["facebook","instagram","twitter","youtube","playbuzz","map"],n.state={url:"",sourceType:"facebook",errors:[],twitId:null,form:{url:""}},n}return i(t,e),c(t,[{key:"componentDidUpdate",value:function(e,t){"facebook"===this.state.sourceType&&(window.fbAsyncInit=function(){FB.init({xfbml:!0,version:"v2.8"}),window.FB=FB,window.FB.XFBML.parse()},function(e,t,n){var r,o=e.getElementsByTagName(t)[0];e.getElementById(n)||(r=e.createElement(t),r.id=n,r.src="//connect.facebook.net/en_US/sdk.js",o.parentNode.insertBefore(r,o))}(document,"script","facebook-jssdk"),window.FB&&window.FB.XFBML.parse()),"twitter"===this.state.sourceType&&(this.state.twitId&&t.twitId!=this.state.twitId?window.twttr.widgets.createTweet(this.state.twitId,document.getElementById("twit-"+this.state.twitId),{align:"center"}):document.getElementById("twit-"+this.state.twitId)&&(document.getElementById("twit-"+this.state.twitId).innerHTML=""))}},{key:"_handleEdit",value:function(){var e=this._getPluginData();alert(JSON.stringify(e,null,4))}},{key:"_getPluginData",value:function(){var e={sourceType:null,url:null};return this.state.url&&(e.url=this.state.url,e.sourceType=this.state.sourceType),e}},{key:"_onChangeForm",value:function(e,t){var n=this.state.form;n[e]=t.target.value,this.setState({form:n})}},{key:"_setSourceType",value:function(e,t){this.setState({sourceType:e,url:""})}},{key:"_embed",value:function(e){var t=this._getValidatedData();this.setState({url:t.url,twitId:t.twitId})}},{key:"_getValidatedData",value:function(){var e=this.state.form.url,t=[];e=e.trim(),m["default"].isUri(e)||t.push("Invalid URL");var n=null;if("twitter"===this.state.sourceType){var r=/\/(\d+)/,o=e.match(r);o&&o.length>=2?n=o[1]:t.push("Invalid Twitter URL")}return this.setState({errors:t}),{url:e,twitId:n}}},{key:"_renderSources",value:function(){var e=this;return this.sources.map(function(t,n){return f["default"].createElement(_["default"],{key:n,type:t,onClick:e._setSourceType.bind(e,t),active:t===e.state.sourceType})})}},{key:"_renderEmbed",value:function(){if(!this.state.url)return null;switch(this.state.sourceType){case"youtube":return this._renderYoutube();case"facebook":return this._renderFacebook();case"playbuzz":return this._renderPlayBuzz();case"instagram":return this._renderInstagram();case"twitter":return this._renderTwitter();case"map":return this._renderMap()}}},{key:"_renderYoutube",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url}))}},{key:"_renderFacebook",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{className:"fb-post","data-href":this.state.url,"data-width":"500"}))}},{key:"_renderPlayBuzz",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{className:"pb_feed","data-game":this.state.url,"data-recommend":"false","data-game-info":"false","data-comments":"false","data-shares":"false"}))}},{key:"_renderInstagram",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url+"/embed/"}))}},{key:"_renderTwitter",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("div",{id:"twit-"+this.state.twitId}))}},{key:"_renderMap",value:function(){return f["default"].createElement("div",{className:"md-embed__media"},f["default"].createElement("iframe",{className:"md-embed__media__iframe",src:this.state.url}))}},{key:"_renderErrors",value:function(){if(this.state.errors.length)return f["default"].createElement("ul",{className:"md-embed-errors"},this.state.errors.map(function(e,t){return f["default"].createElement("li",{key:t},e)}))}},{key:"render",value:function(){return f["default"].createElement(E,l({},this.props,{actions:this.actions}),f["default"].createElement(w,null,this._renderSources()),f["default"].createElement(w,null,f["default"].createElement(g,{placeholder:"URL",value:this.state.url?this.state.url:null,onChange:this._onChangeForm.bind(this,"url")}),this._renderErrors()),f["default"].createElement(w,null,f["default"].createElement(b["default"],{onClick:this._embed.bind(this),label:"Embed"})),f["default"].createElement(v,{className:"embed"},this._renderEmbed()))}}]),t}(s.Component);t["default"]=k},function(e,t,n){(function(e){!function(e){"use strict";function t(e){if(e&&!/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)&&!/%[^0-9a-f]/i.test(e)&&!/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e)){var t=[],n="",r="",o="",i="",u="",l="";if(t=a(e),n=t[1],r=t[2],o=t[3],i=t[4],u=t[5],n&&n.length&&o.length>=0){if(r&&r.length){if(0!==o.length&&!/^\//.test(o))return}else if(/^\/\//.test(o))return;if(/^[a-z][a-z0-9\+\-\.]*$/.test(n.toLowerCase()))return l+=n+":",r&&r.length&&(l+="//"+r),l+=o,i&&i.length&&(l+="?"+i),u&&u.length&&(l+="#"+u),l}}}function n(e,n){if(t(e)){var r=[],o="",i="",u="",l="",c="",s="",f="";if(r=a(e),o=r[1],i=r[2],u=r[3],c=r[4],s=r[5],o){if(n){if("https"!=o.toLowerCase())return}else if("http"!=o.toLowerCase())return;if(i)return/:(\d+)$/.test(i)&&(l=i.match(/:(\d+)$/)[0],i=i.replace(/:\d+$/,"")),f+=o+":",f+="//"+i,l&&(f+=l),f+=u,c&&c.length&&(f+="?"+c),s&&s.length&&(f+="#"+s),f}}}function r(e){return n(e,!0)}function o(e){return n(e)||r(e)}e.exports.is_uri=t,e.exports.is_http_uri=n,e.exports.is_https_uri=r,e.exports.is_web_uri=o,e.exports.isUri=t,e.exports.isHttpUri=n,e.exports.isHttpsUri=r,e.exports.isWebUri=o;var a=function(e){var t=e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);return t}}(e)}).call(t,n(9)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),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 a(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 i(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 u=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(4),c=r(l),s=function(e){function t(e){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),u(t,[{key:"render",value:function(){return c["default"].createElement("button",{className:"md-embed-button md-embed-button--blue md-embed-button--small",type:"button",onClick:this.props.onClick},this.props.label)}}]),t}(l.Component);t["default"]=s},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 a(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 i(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 u=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(4),c=r(l),s=n(12),f=r(s),d=function(e){function t(e){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),u(t,[{key:"render",value:function(){var e=(0,f["default"])("md-embed-icon","md-embed-icon--"+this.props.type,{"md-embed-icon--selected":this.props.active});return c["default"].createElement("i",{className:e,onClick:this.props.onClick})}}]),t}(l.Component);t["default"]=d},function(e,t,n){var r,o;/*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r))e.push(n.apply(null,r));else if("object"===o)for(var i in r)a.call(r,i)&&r[i]&&e.push(i)}}return e.join(" ")}var a={}.hasOwnProperty;"undefined"!=typeof e&&e.exports?e.exports=n:(r=[],o=function(){return n}.apply(t,r),!(void 0!==o&&(e.exports=o)))}()}])});
//# sourceMappingURL=megadraft-embed.js.map

2

package.json
{
"name": "megadraft-embed",
"version": "0.0.1",
"version": "0.0.2",
"description": "Megadraft embed plugin",

@@ -5,0 +5,0 @@ "main": "lib/plugin.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc