Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.143.24.110
/*! This file is auto-generated */
!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},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 C},store:function(){return k}});var n={};e.r(n),e.d(n,{__experimentalConvertBlockToStatic:function(){return s},__experimentalConvertBlocksToReusable:function(){return a},__experimentalDeleteReusableBlock:function(){return u},__experimentalSetEditingReusableBlock:function(){return d}});var o={};e.r(o),e.d(o,{__experimentalIsEditingReusableBlock:function(){return b}});var l=window.wp.data,r=window.wp.blockEditor,c=window.wp.blocks,i=window.wp.i18n;const s=e=>t=>{let{registry:n}=t;const o=n.select(r.store).getBlock(e),l=n.select("core").getEditedEntityRecord("postType","wp_block",o.attributes.ref),i=(0,c.parse)("function"==typeof l.content?l.content(l):l.content);n.dispatch(r.store).replaceBlocks(o.clientId,i)},a=(e,t)=>async n=>{let{registry:o,dispatch:l}=n;const s={title:t||(0,i.__)("Untitled Reusable block"),content:(0,c.serialize)(o.select(r.store).getBlocksByClientId(e)),status:"publish"},a=await o.dispatch("core").saveEntityRecord("postType","wp_block",s),u=(0,c.createBlock)("core/block",{ref:a.id});o.dispatch(r.store).replaceBlocks(e,u),l.__experimentalSetEditingReusableBlock(u.clientId,!0)},u=e=>async t=>{let{registry:n}=t;if(!n.select("core").getEditedEntityRecord("postType","wp_block",e))return;const o=n.select(r.store).getBlocks().filter((t=>(0,c.isReusableBlock)(t)&&t.attributes.ref===e)).map((e=>e.clientId));o.length&&n.dispatch(r.store).removeBlocks(o),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,l.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 k=(0,l.createReduxStore)("core/reusable-blocks",{actions:n,reducer:p,selectors:o});(0,l.register)(k);var m=window.wp.element,_=window.wp.components,w=window.wp.primitives;var g=(0,m.createElement)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,m.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"})),B=window.wp.notices,y=window.wp.coreData;function E(e){let{clientIds:t,rootClientId:n}=e;const[o,s]=(0,m.useState)(!1),[a,u]=(0,m.useState)(""),d=(0,l.useSelect)((e=>{var o;const{canUser:l}=e(y.store),{getBlocksByClientId:i,canInsertBlockType:s}=e(r.store),a=null!==(o=i(t))&&void 0!==o?o:[];return!(1===a.length&&a[0]&&(0,c.isReusableBlock)(a[0])&&!!e(y.store).getEntityRecord("postType","wp_block",a[0].attributes.ref))&&s("core/block",n)&&a.every((e=>!!e&&e.isValid&&(0,c.hasBlockSupport)(e.name,"reusable",!0)))&&!!l("create","blocks")}),[t]),{__experimentalConvertBlocksToReusable:p}=(0,l.useDispatch)(k),{createSuccessNotice:b,createErrorNotice:w}=(0,l.useDispatch)(B.store),E=(0,m.useCallback)((async function(e){try{await p(t,e),b((0,i.__)("Reusable block created."),{type:"snackbar"})}catch(e){w(e.message,{type:"snackbar"})}}),[t]);return d?(0,m.createElement)(r.BlockSettingsMenuControls,null,(e=>{let{onClose:t}=e;return(0,m.createElement)(m.Fragment,null,(0,m.createElement)(_.MenuItem,{icon:g,onClick:()=>{s(!0)}},(0,i.__)("Create Reusable block")),o&&(0,m.createElement)(_.Modal,{title:(0,i.__)("Create Reusable block"),onRequestClose:()=>{s(!1),u("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},(0,m.createElement)("form",{onSubmit:e=>{e.preventDefault(),E(a),s(!1),u(""),t()}},(0,m.createElement)(_.__experimentalVStack,{spacing:"5"},(0,m.createElement)(_.TextControl,{__nextHasNoMarginBottom:!0,label:(0,i.__)("Name"),value:a,onChange:u}),(0,m.createElement)(_.__experimentalHStack,{justify:"right"},(0,m.createElement)(_.Button,{variant:"tertiary",onClick:()=>{s(!1),u("")}},(0,i.__)("Cancel")),(0,m.createElement)(_.Button,{variant:"primary",type:"submit"},(0,i.__)("Save")))))))})):null}var v=window.wp.url;var f=function(e){let{clientId:t}=e;const{canRemove:n,isVisible:o,innerBlockCount:s}=(0,l.useSelect)((e=>{const{getBlock:n,canRemoveBlock:o,getBlockCount:l}=e(r.store),{canUser:i}=e(y.store),s=n(t);return{canRemove:o(t),isVisible:!!s&&(0,c.isReusableBlock)(s)&&!!i("update","blocks",s.attributes.ref),innerBlockCount:l(t)}}),[t]),{__experimentalConvertBlockToStatic:a}=(0,l.useDispatch)(k);return o?(0,m.createElement)(r.BlockSettingsMenuControls,null,(0,m.createElement)(_.MenuItem,{href:(0,v.addQueryArgs)("edit.php",{post_type:"wp_block"})},(0,i.__)("Manage Reusable blocks")),n&&(0,m.createElement)(_.MenuItem,{onClick:()=>a(t)},s>1?(0,i.__)("Convert to regular blocks"):(0,i.__)("Convert to regular block"))):null};var C=(0,l.withSelect)((e=>{const{getSelectedBlockClientIds:t}=e(r.store);return{clientIds:t()}}))((function(e){let{clientIds:t,rootClientId:n}=e;return(0,m.createElement)(m.Fragment,null,(0,m.createElement)(E,{clientIds:t,rootClientId:n}),1===t.length&&(0,m.createElement)(f,{clientId:t[0]}))}));(window.wp=window.wp||{}).reusableBlocks=t}();
|