WordPress/wp-includes/js/dist/list-reusable-blocks.min.js
desrosj 5a4b00a618 Grouped merges for 5.2.12.
- Update `lodash` to the latest version `4.17.21`.
- Disable some attributes for rich text.
- Use hashed/deterministic moduleIDs in webpack config.

Props ellatrix, peterwilsoncc, get_dave, mcsf, talldanwp, youknowriad, desrosj, nerrad, gziolo.
Merges [50940-50941,50984-50985,51426] to the 5.2 branch.
Built from https://develop.svn.wordpress.org/branches/5.2@51756


git-svn-id: http://core.svn.wordpress.org/branches/5.2@51363 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 21:22:54 +00:00

1 line
15 KiB
JavaScript

this.wp=this.wp||{},this.wp.listReusableBlocks=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="SdGz")}({"1OyB":function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",(function(){return r}))},GRId:function(t,e){!function(){t.exports=this.wp.element}()},"HaE+":function(t,e,n){"use strict";function r(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}n.d(e,"a",(function(){return o}))},JX7q:function(t,e,n){"use strict";function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}n.d(e,"a",(function(){return r}))},Ji7U:function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}n.d(e,"a",(function(){return o}))},K9lf:function(t,e){!function(){t.exports=this.wp.compose}()},SdGz:function(t,e,n){"use strict";n.r(e);var r=n("GRId"),o=n("l3Sj"),i=n("o0o1"),a=n.n(i),c=n("HaE+"),u=n("YLtl"),s=n("ywyh"),l=n.n(s);function f(t,e,n){var r=new window.Blob([e],{type:n});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,t);else{var o=document.createElement("a");o.href=URL.createObjectURL(r),o.download=t,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)}}function p(t){var e=new window.FileReader;return new Promise((function(n){e.onload=function(){n(e.result)},e.readAsText(t)}))}function h(){return(h=Object(c.a)(a.a.mark((function t(e){var n,r,o,i,c;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l()({path:"/wp/v2/types/wp_block"});case 2:return n=t.sent,t.next=5,l()({path:"/wp/v2/".concat(n.rest_base,"/").concat(e,"?context=edit")});case 5:r=t.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 t.stop()}}),t,this)})))).apply(this,arguments)}var d=function(t){return h.apply(this,arguments)},y=n("tI+e"),b=n("1OyB"),v=n("vuIU"),m=n("md7G"),g=n("foSv"),w=n("Ji7U"),O=n("JX7q"),j=n("K9lf");function _(){return(_=Object(c.a)(a.a.mark((function t(e){var n,r,o,i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p(e);case 2:n=t.sent,t.prev=3,r=JSON.parse(n),t.next=10;break;case 7:throw t.prev=7,t.t0=t.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)){t.next=12;break}throw new Error("Invalid Reusable Block JSON file");case 12:return t.next=14,l()({path:"/wp/v2/types/wp_block"});case 14:return o=t.sent,t.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=t.sent,t.abrupt("return",i);case 19:case"end":return t.stop()}}),t,this,[[3,7]])})))).apply(this,arguments)}var x=function(t){return _.apply(this,arguments)},S=function(t){function e(){var t;return Object(b.a)(this,e),(t=Object(m.a)(this,Object(g.a)(e).apply(this,arguments))).state={isLoading:!1,error:null,file:null},t.isStillMounted=!0,t.onChangeFile=t.onChangeFile.bind(Object(O.a)(Object(O.a)(t))),t.onSubmit=t.onSubmit.bind(Object(O.a)(Object(O.a)(t))),t}return Object(w.a)(e,t),Object(v.a)(e,[{key:"componentWillUnmount",value:function(){this.isStillMounted=!1}},{key:"onChangeFile",value:function(t){this.setState({file:t.target.files[0]})}},{key:"onSubmit",value:function(t){var e=this;t.preventDefault();var n=this.state.file,r=this.props.onUpload;n&&(this.setState({isLoading:!0}),x(n).then((function(t){e.isStillMounted&&(e.setState({isLoading:!1}),r(t))})).catch((function(t){if(e.isStillMounted){var n;switch(t.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")}e.setState({isLoading:!1,error:n})}})))}},{key:"render",value:function(){var t=this.props.instanceId,e=this.state,n=e.file,i=e.isLoading,a=e.error,c="list-reusable-blocks-import-form-"+t;return Object(r.createElement)("form",{className:"list-reusable-blocks-import-form",onSubmit:this.onSubmit},a&&Object(r.createElement)(y.Notice,{status:"error"},a),Object(r.createElement)("label",{htmlFor:c,className:"list-reusable-blocks-import-form__label"},Object(o.__)("File")),Object(r.createElement)("input",{id:c,type:"file",onChange:this.onChangeFile}),Object(r.createElement)(y.Button,{type:"submit",isBusy:i,disabled:!n||i,isDefault:!0,className:"list-reusable-blocks-import-form__button"},Object(o._x)("Import","button label")))}}]),e}(r.Component),E=Object(j.withInstanceId)(S);var L=function(t){var e=t.onUpload;return Object(r.createElement)(y.Dropdown,{position:"bottom right",contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:function(t){var e=t.isOpen,n=t.onToggle;return Object(r.createElement)(y.Button,{type:"button","aria-expanded":e,onClick:n,isPrimary:!0},Object(o.__)("Import from JSON"))},renderContent:function(t){var n=t.onClose;return Object(r.createElement)(E,{onUpload:Object(u.flow)(n,e)})}})};document.body.addEventListener("click",(function(t){t.target.classList.contains("wp-list-reusable-blocks__export")&&(t.preventDefault(),d(t.target.dataset.id))})),document.addEventListener("DOMContentLoaded",(function(){var t=document.querySelector(".page-title-action");if(t){var e=document.createElement("div");e.className="list-reusable-blocks__container",t.parentNode.insertBefore(e,t),Object(r.render)(Object(r.createElement)(L,{onUpload:function(){var t=document.createElement("div");t.className="notice notice-success is-dismissible",t.innerHTML="<p>".concat(Object(o.__)("Reusable block imported successfully!"),"</p>");var e=document.querySelector(".wp-header-end");e&&e.parentNode.insertBefore(t,e)}}),e)}}))},U8pU:function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}n.d(e,"a",(function(){return o}))},YLtl:function(t,e){!function(){t.exports=this.lodash}()},foSv:function(t,e,n){"use strict";function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.d(e,"a",(function(){return r}))},l3Sj:function(t,e){!function(){t.exports=this.wp.i18n}()},ls82:function(t,e){!function(e){"use strict";var n=Object.prototype,r=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag",u="object"==typeof t,s=e.regeneratorRuntime;if(s)u&&(t.exports=s);else{(s=e.regeneratorRuntime=u?t.exports:{}).wrap=y;var l={},f={};f[i]=function(){return this};var p=Object.getPrototypeOf,h=p&&p(p(E([])));h&&h!==n&&r.call(h,i)&&(f=h);var d=g.prototype=v.prototype=Object.create(f);m.prototype=d.constructor=g,g.constructor=m,g[c]=m.displayName="GeneratorFunction",s.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},s.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(d),t},s.awrap=function(t){return{__await:t}},w(O.prototype),O.prototype[a]=function(){return this},s.AsyncIterator=O,s.async=function(t,e,n,r){var o=new O(y(t,e,n,r));return s.isGeneratorFunction(e)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},w(d),d[c]="Generator",d[i]=function(){return this},d.toString=function(){return"[object Generator]"},s.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},s.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:E(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}}}function y(t,e,n,r){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),a=new S(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return L()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=j(a,n);if(c){if(c===l)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=b(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),i}function b(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function v(){}function m(){}function g(){}function w(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function O(t){var e;this._invoke=function(n,o){function i(){return new Promise((function(e,i){!function e(n,o,i,a){var c=b(t[n],t,o);if("throw"!==c.type){var u=c.arg,s=u.value;return s&&"object"==typeof s&&r.call(s,"__await")?Promise.resolve(s.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(s).then((function(t){u.value=t,i(u)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(n,o,e,i)}))}return e=e?e.then(i,i):i()}}function j(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=b(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function E(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())},md7G:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n("U8pU"),o=n("JX7q");function i(t,e){return!e||"object"!==Object(r.a)(e)&&"function"!=typeof e?Object(o.a)(t):e}},o0o1:function(t,e,n){t.exports=n("u938")},"tI+e":function(t,e){!function(){t.exports=this.wp.components}()},u938:function(t,e,n){var r=function(){return this||"object"==typeof self&&self}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n("ls82"),o)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},vuIU:function(t,e,n){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}n.d(e,"a",(function(){return o}))},ywyh:function(t,e){!function(){t.exports=this.wp.apiFetch}()}});