PluginProbe
Gutenberg / 13.9.0
Gutenberg v13.9.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / reusable-blocks / index.min.js

index.min.js in Gutenberg 13.9.0, at build/reusable-blocks/index.min.js

2 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e={d:(t,l)=>{for(var o in l)e.o(l,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:l[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>I,store:()=>m});var l={};e.r(l),e.d(l,{__experimentalConvertBlockToStatic:()=>a,__experimentalConvertBlocksToReusable:()=>i,__experimentalDeleteReusableBlock:()=>u,__experimentalSetEditingReusableBlock:()=>d});var o={};e.r(o),e.d(o,{__experimentalIsEditingReusableBlock:()=>b});const n=window.wp.data,c=window.wp.blockEditor,r=window.wp.blocks,s=window.wp.i18n,a=e=>t=>{let{registry:l}=t;const o=l.select(c.store).getBlock(e),n=l.select("core").getEditedEntityRecord("postType","wp_block",o.attributes.ref),s=(0,r.parse)("function"==typeof n.content?n.content(n):n.content);l.dispatch(c.store).replaceBlocks(o.clientId,s)},i=(e,t)=>async l=>{let{registry:o,dispatch:n}=l;const a={title:t||(0,s.__)("Untitled Reusable block"),content:(0,r.serialize)(o.select(c.store).getBlocksByClientId(e)),status:"publish"},i=await o.dispatch("core").saveEntityRecord("postType","wp_block",a),u=(0,r.createBlock)("core/block",{ref:i.id});o.dispatch(c.store).replaceBlocks(e,u),n.__experimentalSetEditingReusableBlock(u.clientId,!0)},u=e=>async t=>{let{registry:l}=t;if(!l.select("core").getEditedEntityRecord("postType","wp_block",e))return;const o=l.select(c.store).getBlocks().filter((t=>(0,r.isReusableBlock)(t)&&t.attributes.ref===e)).map((e=>e.clientId));o.length&&l.dispatch(c.store).removeBlocks(o),await l.dispatch("core").deleteEntityRecord("postType","wp_block",e)};function d(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}const p=(0,n.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,n.createReduxStore)("core/reusable-blocks",{actions:l,reducer:p,selectors:o});(0,n.register)(m);const k=window.wp.element,_=window.wp.components,w=window.wp.primitives,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 B(e){let{clientIds:t,rootClientId:l}=e;const[o,a]=(0,k.useState)(!1),[i,u]=(0,k.useState)(""),d=(0,n.useSelect)((e=>{var o;const{canUser:n}=e(g.store),{getBlocksByClientId:s,canInsertBlockType:a}=e(c.store),i=null!==(o=s(t))&&void 0!==o?o:[];return!(1===i.length&&i[0]&&(0,r.isReusableBlock)(i[0])&&e(g.store).getEntityRecord("postType","wp_block",i[0].attributes.ref))&&a("core/block",l)&&i.every((e=>!!e&&e.isValid&&(0,r.hasBlockSupport)(e.name,"reusable",!0)))&&!!n("create","blocks")}),[t]),{__experimentalConvertBlocksToReusable:p}=(0,n.useDispatch)(m),{createSuccessNotice:b,createErrorNotice:w}=(0,n.useDispatch)(y.store),B=(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)(c.BlockSettingsMenuControls,null,(e=>{let{onClose:t}=e;return(0,k.createElement)(k.Fragment,null,(0,k.createElement)(_.MenuItem,{icon:E,onClick:()=>{a(!0)}},(0,s.__)("Create Reusable block")),o&&(0,k.createElement)(_.Modal,{title:(0,s.__)("Create Reusable block"),closeLabel:(0,s.__)("Close"),onRequestClose:()=>{a(!1),u("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},(0,k.createElement)("form",{onSubmit:e=>{e.preventDefault(),B(i),a(!1),u(""),t()}},(0,k.createElement)(_.TextControl,{label:(0,s.__)("Name"),value:i,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:()=>{a(!1),u("")}},(0,s.__)("Cancel"))),(0,k.createElement)(_.FlexItem,null,(0,k.createElement)(_.Button,{variant:"primary",type:"submit"},(0,s.__)("Save")))))))})):null}const v=window.wp.url,R=function(e){let{clientId:t}=e;const{canRemove:l,isVisible:o}=(0,n.useSelect)((e=>{const{getBlock:l,canRemoveBlock:o}=e(c.store),{canUser:n}=e(g.store),s=l(t);return{canRemove:o(t),isVisible:!!s&&(0,r.isReusableBlock)(s)&&!!n("update","blocks",s.attributes.ref)}}),[t]),{__experimentalConvertBlockToStatic:a}=(0,n.useDispatch)(m);return o?(0,k.createElement)(c.BlockSettingsMenuControls,null,(0,k.createElement)(_.MenuItem,{href:(0,v.addQueryArgs)("edit.php",{post_type:"wp_block"})},(0,s.__)("Manage Reusable blocks")),l&&(0,k.createElement)(_.MenuItem,{onClick:()=>a(t)},(0,s.__)("Convert to regular blocks"))):null},I=(0,n.withSelect)((e=>{const{getSelectedBlockClientIds:t}=e(c.store);return{clientIds:t()}}))((function(e){let{clientIds:t,rootClientId:l}=e;return(0,k.createElement)(k.Fragment,null,(0,k.createElement)(B,{clientIds:t,rootClientId:l}),1===t.length&&(0,k.createElement)(R,{clientId:t[0]}))}));(window.wp=window.wp||{}).reusableBlocks=t})();
2 //# sourceMappingURL=index.min.js.map