[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> list-reusable-blocks.min.js (source)

   1  /*! This file is auto-generated */
   2  this.wp=this.wp||{},this.wp.listReusableBlocks=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=472)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.wp.compose},16:function(e,t){e.exports=window.regeneratorRuntime},18:function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,"a",(function(){return r}))},2:function(e,t){e.exports=window.lodash},22:function(e,t,n){"use strict";function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}n.d(t,"a",(function(){return r}))},25:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},26:function(e,t,n){"use strict";function r(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)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}n.d(t,"a",(function(){return o}))},3:function(e,t){e.exports=window.wp.components},33:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(55);function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Object(r.a)(e,t)}},34:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(59),o=n.n(r),i=n(18);function c(e,t){return!t||"object"!==o()(t)&&"function"!=typeof t?Object(i.a)(e):t}},472:function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1),i=n(48),c=n(16),a=n.n(c),u=n(2),s=n(50),l=n.n(s);function f(e,t,n){var r=new window.Blob([t],{type:n});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,e);else{var o=document.createElement("a");o.href=URL.createObjectURL(r),o.download=e,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)}}function p(e){var t=new window.FileReader;return new Promise((function(n){t.onload=function(){n(t.result)},t.readAsText(e)}))}function b(){return(b=Object(i.a)(a.a.mark((function e(t){var n,r,o,i,c;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l()({path:"/wp/v2/types/wp_block"});case 2:return n=e.sent,e.next=5,l()({path:"/wp/v2/".concat(n.rest_base,"/").concat(t,"?context=edit")});case 5:r=e.sent,o=r.title.raw,i=r.content.raw,c=JSON.stringify({__file:"wp_block",title:o,content:i},null,2),f(Object(u.kebabCase)(o)+".json",c,"application/json");case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var d=function(e){return b.apply(this,arguments)},m=n(3),v=n(25),y=n(26),w=n(18),O=n(33),h=n(34),_=n(22),j=n(11);function S(){return(S=Object(i.a)(a.a.mark((function e(t){var n,r,o,i;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p(t);case 2:n=e.sent,e.prev=3,r=JSON.parse(n),e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(3),new Error("Invalid JSON file");case 10:if("wp_block"===r.__file&&r.title&&r.content&&Object(u.isString)(r.title)&&Object(u.isString)(r.content)){e.next=12;break}throw new Error("Invalid Reusable block JSON file");case 12:return e.next=14,l()({path:"/wp/v2/types/wp_block"});case 14:return o=e.sent,e.next=17,l()({path:"/wp/v2/".concat(o.rest_base),data:{title:r.title,content:r.content,status:"publish"},method:"POST"});case 17:return i=e.sent,e.abrupt("return",i);case 19:case"end":return e.stop()}}),e,null,[[3,7]])})))).apply(this,arguments)}var x=function(e){return S.apply(this,arguments)};function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Object(_.a)(e);if(t){var o=Object(_.a)(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Object(h.a)(this,n)}}var k=function(e){Object(O.a)(n,e);var t=g(n);function n(){var e;return Object(v.a)(this,n),(e=t.apply(this,arguments)).state={isLoading:!1,error:null,file:null},e.isStillMounted=!0,e.onChangeFile=e.onChangeFile.bind(Object(w.a)(e)),e.onSubmit=e.onSubmit.bind(Object(w.a)(e)),e}return Object(y.a)(n,[{key:"componentWillUnmount",value:function(){this.isStillMounted=!1}},{key:"onChangeFile",value:function(e){this.setState({file:e.target.files[0],error:null})}},{key:"onSubmit",value:function(e){var t=this;e.preventDefault();var n=this.state.file,r=this.props.onUpload;n&&(this.setState({isLoading:!0}),x(n).then((function(e){t.isStillMounted&&(t.setState({isLoading:!1}),r(e))})).catch((function(e){if(t.isStillMounted){var n;switch(e.message){case"Invalid JSON file":n=Object(o.__)("Invalid JSON file");break;case"Invalid Reusable block JSON file":n=Object(o.__)("Invalid Reusable block JSON file");break;default:n=Object(o.__)("Unknown error")}t.setState({isLoading:!1,error:n})}})))}},{key:"onDismissError",value:function(){this.setState({error:null})}},{key:"render",value:function(){var e=this,t=this.props.instanceId,n=this.state,i=n.file,c=n.isLoading,a=n.error,u="list-reusable-blocks-import-form-"+t;return Object(r.createElement)("form",{className:"list-reusable-blocks-import-form",onSubmit:this.onSubmit},a&&Object(r.createElement)(m.Notice,{status:"error",onRemove:function(){return e.onDismissError()}},a),Object(r.createElement)("label",{htmlFor:u,className:"list-reusable-blocks-import-form__label"},Object(o.__)("File")),Object(r.createElement)("input",{id:u,type:"file",onChange:this.onChangeFile}),Object(r.createElement)(m.Button,{type:"submit",isBusy:c,disabled:!i||c,isSecondary:!0,className:"list-reusable-blocks-import-form__button"},Object(o._x)("Import","button label")))}}]),n}(r.Component),E=Object(j.withInstanceId)(k);var N=function(e){var t=e.onUpload;return Object(r.createElement)(m.Dropdown,{position:"bottom right",contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:function(e){var t=e.isOpen,n=e.onToggle;return Object(r.createElement)(m.Button,{"aria-expanded":t,onClick:n,isPrimary:!0},Object(o.__)("Import from JSON"))},renderContent:function(e){var n=e.onClose;return Object(r.createElement)(E,{onUpload:Object(u.flow)(n,t)})}})};document.body.addEventListener("click",(function(e){e.target.classList.contains("wp-list-reusable-blocks__export")&&(e.preventDefault(),d(e.target.dataset.id))})),document.addEventListener("DOMContentLoaded",(function(){var e=document.querySelector(".page-title-action");if(e){var t=document.createElement("div");t.className="list-reusable-blocks__container",e.parentNode.insertBefore(t,e),Object(r.render)(Object(r.createElement)(N,{onUpload:function(){var e=document.createElement("div");e.className="notice notice-success is-dismissible",e.innerHTML="<p>".concat(Object(o.__)("Reusable block imported successfully!"),"</p>");var t=document.querySelector(".wp-header-end");t&&t.parentNode.insertBefore(e,t)}}),t)}}))},48:function(e,t,n){"use strict";function r(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var c=e.apply(t,n);function a(e){r(c,o,i,a,u,"next",e)}function u(e){r(c,o,i,a,u,"throw",e)}a(void 0)}))}}n.d(t,"a",(function(){return o}))},50:function(e,t){e.exports=window.wp.apiFetch},55:function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}n.d(t,"a",(function(){return r}))},59:function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=n=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),n(t)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0}});


Generated: Sat May 15 01:00:05 2021 Cross-referenced by PHPXref 0.7.1