File "reusable-blocks.min.js"

Full Path: /home/arielcor/public_html/wp-includes/js/reusable-blocks.min.js
File size: 5.61 KB
MIME-type: text/plain
Charset: utf-8

/*! This file is auto-generated */
!function(){"use strict";var e={d:function(t,n){for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ReusableBlocksMenuItems:function(){return R},store:function(){return m}});var n={};e.r(n),e.d(n,{__experimentalConvertBlockToStatic:function(){return i},__experimentalConvertBlocksToReusable:function(){return a},__experimentalDeleteReusableBlock:function(){return u},__experimentalSetEditingReusableBlock:function(){return d}});var l={};e.r(l),e.d(l,{__experimentalIsEditingReusableBlock:function(){return b}});var o=window.wp.data,r=window.wp.blockEditor,c=window.wp.blocks,s=window.wp.i18n;const i=e=>t=>{let{registry:n}=t;const l=n.select(r.store).getBlock(e),o=n.select("core").getEditedEntityRecord("postType","wp_block",l.attributes.ref),s=(0,c.parse)("function"==typeof o.content?o.content(o):o.content);n.dispatch(r.store).replaceBlocks(l.clientId,s)},a=(e,t)=>async n=>{let{registry:l,dispatch:o}=n;const i={title:t||(0,s.__)("Untitled Reusable block"),content:(0,c.serialize)(l.select(r.store).getBlocksByClientId(e)),status:"publish"},a=await l.dispatch("core").saveEntityRecord("postType","wp_block",i),u=(0,c.createBlock)("core/block",{ref:a.id});l.dispatch(r.store).replaceBlocks(e,u),o.__experimentalSetEditingReusableBlock(u.clientId,!0)},u=e=>async t=>{let{registry:n}=t;if(!n.select("core").getEditedEntityRecord("postType","wp_block",e))return;const l=n.select(r.store).getBlocks().filter((t=>(0,c.isReusableBlock)(t)&&t.attributes.ref===e)).map((e=>e.clientId));l.length&&n.dispatch(r.store).removeBlocks(l),await n.dispatch("core").deleteEntityRecord("postType","wp_block",e)};function d(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}var p=(0,o.combineReducers)({isEditingReusableBlock:function(){let 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)?{...e,[t.clientId]:t.isEditing}:e}});function b(e,t){return e.isEditingReusableBlock[t]}const m=(0,o.createReduxStore)("core/reusable-blocks",{actions:n,reducer:p,selectors:l});(0,o.register)(m);var k=window.wp.element,_=window.wp.components,w=window.wp.primitives;var E=(0,k.createElement)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,k.createElement)(w.Path,{d:"M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"})),y=window.wp.notices,g=window.wp.coreData;function v(e){let{clientIds:t,rootClientId:n}=e;const[l,i]=(0,k.useState)(!1),[a,u]=(0,k.useState)(""),d=(0,o.useSelect)((e=>{var l;const{canUser:o}=e(g.store),{getBlocksByClientId:s,canInsertBlockType:i}=e(r.store),a=null!==(l=s(t))&&void 0!==l?l:[];return!(1===a.length&&a[0]&&(0,c.isReusableBlock)(a[0])&&!!e(g.store).getEntityRecord("postType","wp_block",a[0].attributes.ref))&&i("core/block",n)&&a.every((e=>!!e&&e.isValid&&(0,c.hasBlockSupport)(e.name,"reusable",!0)))&&!!o("create","blocks")}),[t]),{__experimentalConvertBlocksToReusable:p}=(0,o.useDispatch)(m),{createSuccessNotice:b,createErrorNotice:w}=(0,o.useDispatch)(y.store),v=(0,k.useCallback)((async function(e){try{await p(t,e),b((0,s.__)("Reusable block created."),{type:"snackbar"})}catch(e){w(e.message,{type:"snackbar"})}}),[t]);return d?(0,k.createElement)(r.BlockSettingsMenuControls,null,(e=>{let{onClose:t}=e;return(0,k.createElement)(k.Fragment,null,(0,k.createElement)(_.MenuItem,{icon:E,onClick:()=>{i(!0)}},(0,s.__)("Create Reusable block")),l&&(0,k.createElement)(_.Modal,{title:(0,s.__)("Create Reusable block"),closeLabel:(0,s.__)("Close"),onRequestClose:()=>{i(!1),u("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},(0,k.createElement)("form",{onSubmit:e=>{e.preventDefault(),v(a),i(!1),u(""),t()}},(0,k.createElement)(_.TextControl,{label:(0,s.__)("Name"),value:a,onChange:u}),(0,k.createElement)(_.Flex,{className:"reusable-blocks-menu-items__convert-modal-actions",justify:"flex-end"},(0,k.createElement)(_.FlexItem,null,(0,k.createElement)(_.Button,{variant:"tertiary",onClick:()=>{i(!1),u("")}},(0,s.__)("Cancel"))),(0,k.createElement)(_.FlexItem,null,(0,k.createElement)(_.Button,{variant:"primary",type:"submit"},(0,s.__)("Save")))))))})):null}var B=window.wp.url;var f=function(e){let{clientId:t}=e;const{canRemove:n,isVisible:l}=(0,o.useSelect)((e=>{const{getBlock:n,canRemoveBlock:l}=e(r.store),{canUser:o}=e(g.store),s=n(t);return{canRemove:l(t),isVisible:!!s&&(0,c.isReusableBlock)(s)&&!!o("update","blocks",s.attributes.ref)}}),[t]),{__experimentalConvertBlockToStatic:i}=(0,o.useDispatch)(m);return l?(0,k.createElement)(r.BlockSettingsMenuControls,null,(0,k.createElement)(_.MenuItem,{href:(0,B.addQueryArgs)("edit.php",{post_type:"wp_block"})},(0,s.__)("Manage Reusable blocks")),n&&(0,k.createElement)(_.MenuItem,{onClick:()=>i(t)},(0,s.__)("Convert to regular blocks"))):null};var R=(0,o.withSelect)((e=>{const{getSelectedBlockClientIds:t}=e(r.store);return{clientIds:t()}}))((function(e){let{clientIds:t,rootClientId:n}=e;return(0,k.createElement)(k.Fragment,null,(0,k.createElement)(v,{clientIds:t,rootClientId:n}),1===t.length&&(0,k.createElement)(f,{clientId:t[0]}))}));(window.wp=window.wp||{}).reusableBlocks=t}();