WordPress/wp-includes/js/dist/reusable-blocks.min.js
Peter Wilson abde9678b4 Build tools: Use hashed module IDs for minified files.
Further improves webpack configuration for editor files to use hashed module IDs in the compressed (`*.min.js`) production files.

Follow up to [50940].

Props gziolo, peterwilsoncc.
Fixes #53192.


Built from https://develop.svn.wordpress.org/trunk@51035


git-svn-id: http://core.svn.wordpress.org/trunk@50644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-27 00:17:06 +00:00

2 lines
6.9 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.reusableBlocks=function(e){var t={};function n(c){if(t[c])return t[c].exports;var o=t[c]={i:c,l:!1,exports:{}};return e[c].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,c){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},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 c=Object.create(null);if(n.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(c,o,function(t){return e[t]}.bind(null,o));return c},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="iqm2")}({"1ZqX":function(e,t){e.exports=window.wp.data},GRId:function(e,t){e.exports=window.wp.element},HSyU:function(e,t){e.exports=window.wp.blocks},Mmq9:function(e,t){e.exports=window.wp.url},Tqx9:function(e,t){e.exports=window.wp.primitives},YLtl:function(e,t){e.exports=window.lodash},axFQ:function(e,t){e.exports=window.wp.blockEditor},iqm2:function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return m})),n.d(t,"ReusableBlocksMenuItems",(function(){return v}));var c={};n.r(c),n.d(c,"__experimentalConvertBlockToStatic",(function(){return b})),n.d(c,"__experimentalConvertBlocksToReusable",(function(){return d})),n.d(c,"__experimentalDeleteReusableBlock",(function(){return p})),n.d(c,"__experimentalSetEditingReusableBlock",(function(){return O}));var o={};n.r(o),n.d(o,"__experimentalIsEditingReusableBlock",(function(){return _}));var r=n("axFQ"),l=(n("jZUy"),n("1ZqX")),i=n("YLtl"),s=n("HSyU"),a=n("l3Sj");var u={CONVERT_BLOCK_TO_STATIC:Object(l.createRegistryControl)(e=>({clientId:t})=>{const n=e.select(r.store).getBlock(t),c=e.select("core").getEditedEntityRecord("postType","wp_block",n.attributes.ref),o=Object(s.parse)(Object(i.isFunction)(c.content)?c.content(c):c.content);e.dispatch(r.store).replaceBlocks(n.clientId,o)}),CONVERT_BLOCKS_TO_REUSABLE:Object(l.createRegistryControl)(e=>async function({clientIds:t,title:n}){const c={title:n||Object(a.__)("Untitled Reusable block"),content:Object(s.serialize)(e.select(r.store).getBlocksByClientId(t)),status:"publish"},o=await e.dispatch("core").saveEntityRecord("postType","wp_block",c),l=Object(s.createBlock)("core/block",{ref:o.id});e.dispatch(r.store).replaceBlocks(t,l),e.dispatch(m).__experimentalSetEditingReusableBlock(l.clientId,!0)}),DELETE_REUSABLE_BLOCK:Object(l.createRegistryControl)(e=>async function({id:t}){if(!e.select("core").getEditedEntityRecord("postType","wp_block",t))return;const n=e.select(r.store).getBlocks().filter(e=>Object(s.isReusableBlock)(e)&&e.attributes.ref===t).map(e=>e.clientId);n.length&&e.dispatch(r.store).removeBlocks(n),await e.dispatch("core").deleteEntityRecord("postType","wp_block",t)})};function*b(e){yield function(e){return{type:"CONVERT_BLOCK_TO_STATIC",clientId:e}}(e)}function*d(e,t){yield function(e,t){return{type:"CONVERT_BLOCKS_TO_REUSABLE",clientIds:e,title:t}}(e,t)}function*p(e){yield function(e){return{type:"DELETE_REUSABLE_BLOCK",id:e}}(e)}function O(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}var f=Object(l.combineReducers)({isEditingReusableBlock:function(e={},t){return"SET_EDITING_REUSABLE_BLOCK"===(null==t?void 0:t.type)?{...e,[t.clientId]:t.isEditing}:e}});function _(e,t){return e.isEditingReusableBlock[t]}const m=Object(l.createReduxStore)("core/reusable-blocks",{actions:c,controls:u,reducer:f,selectors:o});Object(l.register)(m);var j=n("GRId"),E=n("tI+e"),k=n("Tqx9");var y=Object(j.createElement)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(k.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"})),w=n("onLe");function B({clientIds:e,rootClientId:t}){const[n,c]=Object(j.useState)(!1),[o,i]=Object(j.useState)(""),u=Object(l.useSelect)(n=>{var c;const{canUser:o}=n("core"),{getBlocksByClientId:r,canInsertBlockType:l}=n("core/block-editor"),i=null!==(c=r(e))&&void 0!==c?c:[];return!(1===i.length&&i[0]&&Object(s.isReusableBlock)(i[0])&&!!n("core").getEntityRecord("postType","wp_block",i[0].attributes.ref))&&l("core/block",t)&&i.every(e=>!!e&&e.isValid&&Object(s.hasBlockSupport)(e.name,"reusable",!0))&&!!o("create","blocks")},[e]),{__experimentalConvertBlocksToReusable:b}=Object(l.useDispatch)(m),{createSuccessNotice:d,createErrorNotice:p}=Object(l.useDispatch)(w.store),O=Object(j.useCallback)((async function(t){try{await b(e,t),d(Object(a.__)("Reusable block created."),{type:"snackbar"})}catch(e){p(e.message,{type:"snackbar"})}}),[e]);return u?Object(j.createElement)(r.BlockSettingsMenuControls,null,({onClose:e})=>Object(j.createElement)(j.Fragment,null,Object(j.createElement)(E.MenuItem,{icon:y,onClick:()=>{c(!0)}},Object(a.__)("Add to Reusable blocks")),n&&Object(j.createElement)(E.Modal,{title:Object(a.__)("Create Reusable block"),closeLabel:Object(a.__)("Close"),onRequestClose:()=>{c(!1),i("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},Object(j.createElement)("form",{onSubmit:t=>{t.preventDefault(),O(o),c(!1),i(""),e()}},Object(j.createElement)(E.TextControl,{label:Object(a.__)("Name"),value:o,onChange:i}),Object(j.createElement)(E.Flex,{className:"reusable-blocks-menu-items__convert-modal-actions",justify:"flex-end"},Object(j.createElement)(E.FlexItem,null,Object(j.createElement)(E.Button,{isSecondary:!0,onClick:()=>{c(!1),i("")}},Object(a.__)("Cancel"))),Object(j.createElement)(E.FlexItem,null,Object(j.createElement)(E.Button,{isPrimary:!0,type:"submit"},Object(a.__)("Save")))))))):null}var R=n("Mmq9");var g=function({clientId:e}){const{isVisible:t}=Object(l.useSelect)(t=>{const{getBlock:n}=t(r.store),{canUser:c}=t("core"),o=n(e);return{isVisible:!!o&&Object(s.isReusableBlock)(o)&&!!c("update","blocks",o.attributes.ref)}},[e]);return t?Object(j.createElement)(r.BlockSettingsMenuControls,null,Object(j.createElement)(E.MenuItem,{href:Object(R.addQueryArgs)("edit.php",{post_type:"wp_block"})},Object(a.__)("Manage Reusable blocks"))):null};var v=Object(l.withSelect)(e=>{const{getSelectedBlockClientIds:t}=e(r.store);return{clientIds:t()}})((function({clientIds:e,rootClientId:t}){return Object(j.createElement)(j.Fragment,null,Object(j.createElement)(B,{clientIds:e,rootClientId:t}),1===e.length&&Object(j.createElement)(g,{clientId:e[0]}))}))},jZUy:function(e,t){e.exports=window.wp.coreData},l3Sj:function(e,t){e.exports=window.wp.i18n},onLe:function(e,t){e.exports=window.wp.notices},"tI+e":function(e,t){e.exports=window.wp.components}});