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

2 lines
9.4 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.reusableBlocks=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./node_modules/@wordpress/reusable-blocks/build-module/index.js")}({"./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js":function(e,t,r){"use strict";function n(e,t,r,n,o,c,i){try{var s=e[c](i),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(o,c){var i=e.apply(t,r);function s(e){n(i,o,c,s,u,"next",e)}function u(e){n(i,o,c,s,u,"throw",e)}s(void 0)}))}}r.d(t,"a",(function(){return o}))},"./node_modules/@babel/runtime/helpers/esm/defineProperty.js":function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},"./node_modules/@wordpress/reusable-blocks/build-module/index.js":function(e,t,r){"use strict";r.r(t),r.d(t,"store",(function(){return I})),r.d(t,"ReusableBlocksMenuItems",(function(){return U}));var n={};r.r(n),r.d(n,"__experimentalConvertBlockToStatic",(function(){return j})),r.d(n,"__experimentalConvertBlocksToReusable",(function(){return _})),r.d(n,"__experimentalDeleteReusableBlock",(function(){return y})),r.d(n,"__experimentalSetEditingReusableBlock",(function(){return E}));var o={};r.r(o),r.d(o,"__experimentalIsEditingReusableBlock",(function(){return R}));var c=r("@wordpress/block-editor"),i=(r("@wordpress/core-data"),r("@wordpress/data")),s=r("@babel/runtime/regenerator"),u=r.n(s),l=r("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),a=r("lodash"),d=r("@wordpress/blocks"),p=r("@wordpress/i18n");function b(e){return{type:"CONVERT_BLOCK_TO_STATIC",clientId:e}}function f(e){return{type:"CONVERT_BLOCKS_TO_REUSABLE",clientIds:e}}function w(e){return{type:"DELETE_REUSABLE_BLOCK",id:e}}var O={CONVERT_BLOCK_TO_STATIC:Object(i.createRegistryControl)((function(e){return function(t){var r=t.clientId,n=e.select("core/block-editor").getBlock(r),o=e.select("core").getEditedEntityRecord("postType","wp_block",n.attributes.ref),c=Object(d.parse)(Object(a.isFunction)(o.content)?o.content(o):o.content);e.dispatch("core/block-editor").replaceBlocks(n.clientId,c)}})),CONVERT_BLOCKS_TO_REUSABLE:Object(i.createRegistryControl)((function(e){return function(){var t=Object(l.a)(u.a.mark((function t(r){var n,o,c,i;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.clientIds,o={title:Object(p.__)("Untitled Reusable Block"),content:Object(d.serialize)(e.select("core/block-editor").getBlocksByClientId(n)),status:"publish"},t.next=4,e.dispatch("core").saveEntityRecord("postType","wp_block",o);case 4:c=t.sent,i=Object(d.createBlock)("core/block",{ref:c.id}),e.dispatch("core/block-editor").replaceBlocks(n,i),e.dispatch(I).__experimentalSetEditingReusableBlock(i.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)(u.a.mark((function t(r){var n,o,c,i;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.id,e.select("core").getEditedEntityRecord("postType","wp_block",n)){t.next=4;break}return t.abrupt("return");case 4:return o=e.select("core/block-editor").getBlocks(),c=o.filter((function(e){return Object(d.isReusableBlock)(e)&&e.attributes.ref===n})),(i=c.map((function(e){return e.clientId}))).length&&e.dispatch("core/block-editor").removeBlocks(i),t.next=10,e.dispatch("core").deleteEntityRecord("postType","wp_block",n);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}))},k=u.a.mark(j),m=u.a.mark(_),v=u.a.mark(y);function j(e){return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b(e);case 2:case"end":return t.stop()}}),k)}function _(e){return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f(e);case 2:case"end":return t.stop()}}),m)}function y(e){return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,w(e);case 2:case"end":return t.stop()}}),v)}function E(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}var h=r("./node_modules/@babel/runtime/helpers/esm/defineProperty.js");function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach((function(t){Object(h.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=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)?B(B({},e),{},Object(h.a)({},t.clientId,t.isEditing)):e}});function R(e,t){return e.isEditingReusableBlock[t]}var I=Object(i.createReduxStore)("core/reusable-blocks",{actions:n,controls:O,reducer:x,selectors:o});Object(i.register)(I);var S=r("@wordpress/element"),C=r("@wordpress/components"),T=r("@wordpress/primitives"),P=Object(S.createElement)(T.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(S.createElement)(T.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"})),L=r("@wordpress/notices");function D(e){var t=e.clientIds,r=e.rootClientId,n=Object(i.useSelect)((function(e){var n,o=e("core").canUser,c=e("core/block-editor"),i=c.getBlocksByClientId,s=c.canInsertBlockType,u=null!==(n=i(t))&&void 0!==n?n:[];return!(1===u.length&&u[0]&&Object(d.isReusableBlock)(u[0])&&!!e("core").getEntityRecord("postType","wp_block",u[0].attributes.ref))&&s("core/block",r)&&u.every((function(e){return!!e&&e.isValid&&Object(d.hasBlockSupport)(e.name,"reusable",!0)}))&&!!o("create","blocks")}),[t]),o=Object(i.useDispatch)(I).__experimentalConvertBlocksToReusable,s=Object(i.useDispatch)(L.store),a=s.createSuccessNotice,b=s.createErrorNotice,f=Object(S.useCallback)(Object(l.a)(u.a.mark((function e(){return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o(t);case 3:a(Object(p.__)("Block created."),{type:"snackbar"}),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),b(e.t0.message,{type:"snackbar"});case 9:case"end":return e.stop()}}),e,null,[[0,6]])}))),[t]);return n?Object(S.createElement)(c.BlockSettingsMenuControls,null,(function(e){var t=e.onClose;return Object(S.createElement)(C.MenuItem,{icon:P,onClick:function(){f(),t()}},Object(p.__)("Add to Reusable blocks"))})):null}var M=r("@wordpress/url");var A=function(e){var t=e.clientId;return Object(i.useSelect)((function(e){var r=e("core/block-editor").getBlock,n=e("core").canUser,o=r(t);return{isVisible:!!o&&Object(d.isReusableBlock)(o)&&!!n("update","blocks",o.attributes.ref)}}),[t]).isVisible?Object(S.createElement)(c.BlockSettingsMenuControls,null,Object(S.createElement)(C.MenuItem,{href:Object(M.addQueryArgs)("edit.php",{post_type:"wp_block"})},Object(p.__)("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,r=e.rootClientId;return Object(S.createElement)(S.Fragment,null,Object(S.createElement)(D,{clientIds:t,rootClientId:r}),1===t.length&&Object(S.createElement)(A,{clientId:t[0]}))}))},"@babel/runtime/regenerator":function(e,t){e.exports=window.regeneratorRuntime},"@wordpress/block-editor":function(e,t){e.exports=window.wp.blockEditor},"@wordpress/blocks":function(e,t){e.exports=window.wp.blocks},"@wordpress/components":function(e,t){e.exports=window.wp.components},"@wordpress/core-data":function(e,t){e.exports=window.wp.coreData},"@wordpress/data":function(e,t){e.exports=window.wp.data},"@wordpress/element":function(e,t){e.exports=window.wp.element},"@wordpress/i18n":function(e,t){e.exports=window.wp.i18n},"@wordpress/notices":function(e,t){e.exports=window.wp.notices},"@wordpress/primitives":function(e,t){e.exports=window.wp.primitives},"@wordpress/url":function(e,t){e.exports=window.wp.url},lodash:function(e,t){e.exports=window.lodash}});