WordPress/wp-includes/js/dist/reusable-blocks.min.js

2 lines
11 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.reusableBlocks=function(e){var t={};function n(r){if(t[r])return t[r].exports;var c=t[r]={i:r,l:!1,exports:{}};return e[r].call(c.exports,c,c.exports,n),c.l=!0,c.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 c in e)n.d(r,c,function(t){return e[t]}.bind(null,c));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=461)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},12:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(37);var c=n(28),o=n(38);function i(e,t){return Object(r.a)(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,c=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){c=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(c)throw o}}return n}}(e,t)||Object(c.a)(e,t)||Object(o.a)()}},16:function(e,t){e.exports=window.regeneratorRuntime},2:function(e,t){e.exports=window.lodash},24:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return r}))},28:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(24);function c(e,t){if(e){if("string"==typeof e)return Object(r.a)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Object(r.a)(e,t):void 0}}},29:function(e,t){e.exports=window.wp.url},3:function(e,t){e.exports=window.wp.components},37:function(e,t,n){"use strict";function r(e){if(Array.isArray(e))return e}n.d(t,"a",(function(){return r}))},38:function(e,t,n){"use strict";function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(t,"a",(function(){return r}))},4:function(e,t){e.exports=window.wp.data},42:function(e,t){e.exports=window.wp.coreData},461:function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return C})),n.d(t,"ReusableBlocksMenuItems",(function(){return U}));var r={};n.r(r),n.d(r,"__experimentalConvertBlockToStatic",(function(){return w})),n.d(r,"__experimentalConvertBlocksToReusable",(function(){return k})),n.d(r,"__experimentalDeleteReusableBlock",(function(){return _})),n.d(r,"__experimentalSetEditingReusableBlock",(function(){return E}));var c={};n.r(c),n.d(c,"__experimentalIsEditingReusableBlock",(function(){return S}));var o=n(6),i=(n(42),n(4)),u=n(16),a=n.n(u),l=n(48),s=n(2),b=n(9),f=n(1);function p(e){return{type:"CONVERT_BLOCK_TO_STATIC",clientId:e}}function d(e,t){return{type:"CONVERT_BLOCKS_TO_REUSABLE",clientIds:e,title:t}}function O(e){return{type:"DELETE_REUSABLE_BLOCK",id:e}}var j={CONVERT_BLOCK_TO_STATIC:Object(i.createRegistryControl)((function(e){return function(t){var n=t.clientId,r=e.select("core/block-editor").getBlock(n),c=e.select("core").getEditedEntityRecord("postType","wp_block",r.attributes.ref),o=Object(b.parse)(Object(s.isFunction)(c.content)?c.content(c):c.content);e.dispatch("core/block-editor").replaceBlocks(r.clientId,o)}})),CONVERT_BLOCKS_TO_REUSABLE:Object(i.createRegistryControl)((function(e){return function(){var t=Object(l.a)(a.a.mark((function t(n){var r,c,o,i,u;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.clientIds,c=n.title,o={title:c||Object(f.__)("Untitled Reusable block"),content:Object(b.serialize)(e.select("core/block-editor").getBlocksByClientId(r)),status:"publish"},t.next=4,e.dispatch("core").saveEntityRecord("postType","wp_block",o);case 4:i=t.sent,u=Object(b.createBlock)("core/block",{ref:i.id}),e.dispatch("core/block-editor").replaceBlocks(r,u),e.dispatch(C).__experimentalSetEditingReusableBlock(u.clientId,!0);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()})),DELETE_REUSABLE_BLOCK:Object(i.createRegistryControl)((function(e){return function(){var t=Object(l.a)(a.a.mark((function t(n){var r,c,o,i;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.id,e.select("core").getEditedEntityRecord("postType","wp_block",r)){t.next=4;break}return t.abrupt("return");case 4:return c=e.select("core/block-editor").getBlocks(),o=c.filter((function(e){return Object(b.isReusableBlock)(e)&&e.attributes.ref===r})),(i=o.map((function(e){return e.clientId}))).length&&e.dispatch("core/block-editor").removeBlocks(i),t.next=10,e.dispatch("core").deleteEntityRecord("postType","wp_block",r);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}))},v=a.a.mark(w),m=a.a.mark(k),y=a.a.mark(_);function w(e){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p(e);case 2:case"end":return t.stop()}}),v)}function k(e,t){return a.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,d(e,t);case 2:case"end":return n.stop()}}),m)}function _(e){return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,O(e);case 2:case"end":return t.stop()}}),y)}function E(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}var g=n(5);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){Object(g.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var B=Object(i.combineReducers)({isEditingReusableBlock:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return"SET_EDITING_REUSABLE_BLOCK"===(null==t?void 0:t.type)?x(x({},e),{},Object(g.a)({},t.clientId,t.isEditing)):e}});function S(e,t){return e.isEditingReusableBlock[t]}var C=Object(i.createReduxStore)("core/reusable-blocks",{actions:r,controls:j,reducer:B,selectors:c});Object(i.register)(C);var R=n(0),I=n(12),T=n(3),L=n(7),P=Object(R.createElement)(L.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(R.createElement)(L.Path,{d:"M7 7.2h8.2L13.5 9l1.1 1.1 3.6-3.6-3.5-4-1.1 1 1.9 2.3H7c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.2-.5zm13.8 4V11h-1.5v.3c0 1.1 0 3.5-1 4.5-.3.3-.7.5-1.3.5H8.8l1.7-1.7-1.1-1.1L5.9 17l3.5 4 1.1-1-1.9-2.3H17c.9 0 1.7-.3 2.3-.9 1.5-1.4 1.5-4.2 1.5-5.6z"})),A=n(51);function D(e){var t=e.clientIds,n=e.rootClientId,r=Object(R.useState)(!1),c=Object(I.a)(r,2),u=c[0],s=c[1],p=Object(R.useState)(""),d=Object(I.a)(p,2),O=d[0],j=d[1],v=Object(i.useSelect)((function(e){var r,c=e("core").canUser,o=e("core/block-editor"),i=o.getBlocksByClientId,u=o.canInsertBlockType,a=null!==(r=i(t))&&void 0!==r?r:[];return!(1===a.length&&a[0]&&Object(b.isReusableBlock)(a[0])&&!!e("core").getEntityRecord("postType","wp_block",a[0].attributes.ref))&&u("core/block",n)&&a.every((function(e){return!!e&&e.isValid&&Object(b.hasBlockSupport)(e.name,"reusable",!0)}))&&!!c("create","blocks")}),[t]),m=Object(i.useDispatch)(C).__experimentalConvertBlocksToReusable,y=Object(i.useDispatch)(A.store),w=y.createSuccessNotice,k=y.createErrorNotice,_=Object(R.useCallback)(function(){var e=Object(l.a)(a.a.mark((function e(n){return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,m(t,n);case 3:w(Object(f.__)("Reusable block created."),{type:"snackbar"}),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),k(e.t0.message,{type:"snackbar"});case 9:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t){return e.apply(this,arguments)}}(),[t]);return v?Object(R.createElement)(o.BlockSettingsMenuControls,null,(function(e){var t=e.onClose;return Object(R.createElement)(R.Fragment,null,Object(R.createElement)(T.MenuItem,{icon:P,onClick:function(){s(!0)}},Object(f.__)("Add to Reusable blocks")),u&&Object(R.createElement)(T.Modal,{title:Object(f.__)("Create Reusable block"),closeLabel:Object(f.__)("Close"),onRequestClose:function(){s(!1),j("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},Object(R.createElement)("form",{onSubmit:function(e){e.preventDefault(),_(O),s(!1),j(""),t()}},Object(R.createElement)(T.TextControl,{label:Object(f.__)("Name"),value:O,onChange:j}),Object(R.createElement)(T.Flex,{className:"reusable-blocks-menu-items__convert-modal-actions",justify:"flex-end"},Object(R.createElement)(T.FlexItem,null,Object(R.createElement)(T.Button,{isSecondary:!0,onClick:function(){s(!1),j("")}},Object(f.__)("Cancel"))),Object(R.createElement)(T.FlexItem,null,Object(R.createElement)(T.Button,{isPrimary:!0,type:"submit"},Object(f.__)("Save")))))))})):null}var M=n(29);var N=function(e){var t=e.clientId;return Object(i.useSelect)((function(e){var n=e("core/block-editor").getBlock,r=e("core").canUser,c=n(t);return{isVisible:!!c&&Object(b.isReusableBlock)(c)&&!!r("update","blocks",c.attributes.ref)}}),[t]).isVisible?Object(R.createElement)(o.BlockSettingsMenuControls,null,Object(R.createElement)(T.MenuItem,{href:Object(M.addQueryArgs)("edit.php",{post_type:"wp_block"})},Object(f.__)("Manage Reusable blocks"))):null};var U=Object(i.withSelect)((function(e){return{clientIds:(0,e("core/block-editor").getSelectedBlockClientIds)()}}))((function(e){var t=e.clientIds,n=e.rootClientId;return Object(R.createElement)(R.Fragment,null,Object(R.createElement)(D,{clientIds:t,rootClientId:n}),1===t.length&&Object(R.createElement)(N,{clientId:t[0]}))}))},48:function(e,t,n){"use strict";function r(e,t,n,r,c,o,i){try{var u=e[o](i),a=u.value}catch(e){return void n(e)}u.done?t(a):Promise.resolve(a).then(r,c)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(c,o){var i=e.apply(t,n);function u(e){r(i,c,o,u,a,"next",e)}function a(e){r(i,c,o,u,a,"throw",e)}u(void 0)}))}}n.d(t,"a",(function(){return c}))},5:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},51:function(e,t){e.exports=window.wp.notices},6:function(e,t){e.exports=window.wp.blockEditor},7:function(e,t){e.exports=window.wp.primitives},9:function(e,t){e.exports=window.wp.blocks}});