WordPress/wp-includes/js/dist/reusable-blocks.min.js
youknowriad 1de40f71be Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress. 
This includes features like:

 - DataViews.
 - Customization tools like box shadow, background size and repeat.
 - UI improvements in the site editor. 
 - Preferences sharing between the post and site editors.
 - Unified panels and editors between post and site editors.
 - Improved template mode in the post editor.
 - Iterations to multiple interactive blocks.
 - Preparing the blocks and UI for pattern overrides.
 - and a lot more.

Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.
Built from https://develop.svn.wordpress.org/trunk@57377


git-svn-id: http://core.svn.wordpress.org/trunk@56883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 21:07:12 +00:00

2 lines
6.4 KiB
JavaScript

/*! This file is auto-generated */
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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 T},store:function(){return _}});var n={};e.r(n),e.d(n,{__experimentalConvertBlockToStatic:function(){return s},__experimentalConvertBlocksToReusable:function(){return i},__experimentalDeleteReusableBlock:function(){return u},__experimentalSetEditingReusableBlock:function(){return p}});var r={};e.r(r),e.d(r,{__experimentalIsEditingReusableBlock:function(){return m}});var o=window.wp.data,l=window.wp.blockEditor,c=window.wp.blocks,a=window.wp.i18n;const s=e=>({registry:t})=>{const n=t.select(l.store).getBlock(e),r=t.select("core").getEditedEntityRecord("postType","wp_block",n.attributes.ref),o=(0,c.parse)("function"==typeof r.content?r.content(r):r.content);t.dispatch(l.store).replaceBlocks(n.clientId,o)},i=(e,t,n)=>async({registry:r,dispatch:o})=>{const s="unsynced"===n?{wp_pattern_sync_status:n}:void 0,i={title:t||(0,a.__)("Untitled pattern block"),content:(0,c.serialize)(r.select(l.store).getBlocksByClientId(e)),status:"publish",meta:s},u=await r.dispatch("core").saveEntityRecord("postType","wp_block",i);if("unsynced"===n)return;const p=(0,c.createBlock)("core/block",{ref:u.id});r.dispatch(l.store).replaceBlocks(e,p),o.__experimentalSetEditingReusableBlock(p.clientId,!0)},u=e=>async({registry:t})=>{if(!t.select("core").getEditedEntityRecord("postType","wp_block",e))return;const n=t.select(l.store).getBlocks().filter((t=>(0,c.isReusableBlock)(t)&&t.attributes.ref===e)).map((e=>e.clientId));n.length&&t.dispatch(l.store).removeBlocks(n),await t.dispatch("core").deleteEntityRecord("postType","wp_block",e)};function p(e,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:e,isEditing:t}}var d=(0,o.combineReducers)({isEditingReusableBlock:function(e={},t){return"SET_EDITING_REUSABLE_BLOCK"===t?.type?{...e,[t.clientId]:t.isEditing}:e}});function m(e,t){return e.isEditingReusableBlock[t]}const _=(0,o.createReduxStore)("core/reusable-blocks",{actions:n,reducer:d,selectors:r});(0,o.register)(_);var b=window.React,k=window.wp.element,w=window.wp.components,y=window.wp.primitives;var g=(0,b.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,b.createElement)(y.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,v=window.wp.coreData,E=window.wp.privateApis;const{unlock:f}=(0,E.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/reusable-blocks"),{useReusableBlocksRenameHint:h,ReusableBlocksRenameHint:C}=f(l.privateApis);function R({clientIds:e,rootClientId:t,onClose:n}){const r=h(),[s,i]=(0,k.useState)(void 0),[u,p]=(0,k.useState)(!1),[d,m]=(0,k.useState)(""),y=(0,o.useSelect)((n=>{var r;const{canUser:o}=n(v.store),{getBlocksByClientId:a,canInsertBlockType:s,getBlockRootClientId:i}=n(l.store),u=t||(e.length>0?i(e[0]):void 0),p=null!==(r=a(e))&&void 0!==r?r:[];return!(1===p.length&&p[0]&&(0,c.isReusableBlock)(p[0])&&!!n(v.store).getEntityRecord("postType","wp_block",p[0].attributes.ref))&&s("core/block",u)&&p.every((e=>!!e&&e.isValid&&(0,c.hasBlockSupport)(e.name,"reusable",!0)))&&!!o("create","blocks")}),[e,t]),{__experimentalConvertBlocksToReusable:E}=(0,o.useDispatch)(_),{createSuccessNotice:f,createErrorNotice:R}=(0,o.useDispatch)(B.store),I=(0,k.useCallback)((async function(t){try{await E(e,t,s),f(s?(0,a.sprintf)((0,a.__)("Unsynced pattern created: %s"),t):(0,a.sprintf)((0,a.__)("Synced pattern created: %s"),t),{type:"snackbar",id:"convert-to-reusable-block-success"})}catch(e){R(e.message,{type:"snackbar",id:"convert-to-reusable-block-error"})}}),[E,e,s,f,R]);return y?(0,b.createElement)(b.Fragment,null,(0,b.createElement)(w.MenuItem,{icon:g,onClick:()=>p(!0)},r?(0,a.__)("Create pattern/reusable block"):(0,a.__)("Create pattern")),u&&(0,b.createElement)(w.Modal,{title:(0,a.__)("Create pattern"),onRequestClose:()=>{p(!1),m("")},overlayClassName:"reusable-blocks-menu-items__convert-modal"},(0,b.createElement)("form",{onSubmit:e=>{e.preventDefault(),I(d),p(!1),m(""),n()}},(0,b.createElement)(w.__experimentalVStack,{spacing:"5"},(0,b.createElement)(C,null),(0,b.createElement)(w.TextControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Name"),value:d,onChange:m,placeholder:(0,a.__)("My pattern")}),(0,b.createElement)(w.ToggleControl,{label:(0,a._x)("Synced","Option that makes an individual pattern synchronized"),help:(0,a.__)("Sync this pattern across multiple locations."),checked:!s,onChange:()=>{i(s?void 0:"unsynced")}}),(0,b.createElement)(w.__experimentalHStack,{justify:"right"},(0,b.createElement)(w.Button,{variant:"tertiary",onClick:()=>{p(!1),m("")}},(0,a.__)("Cancel")),(0,b.createElement)(w.Button,{variant:"primary",type:"submit"},(0,a.__)("Create"))))))):null}var I=window.wp.url;var S=function({clientId:e}){const{canRemove:t,isVisible:n,managePatternsUrl:r}=(0,o.useSelect)((t=>{const{getBlock:n,canRemoveBlock:r,getBlockCount:o,getSettings:a}=t(l.store),{canUser:s}=t(v.store),i=n(e),u=a().__unstableIsBlockBasedTheme;return{canRemove:r(e),isVisible:!!i&&(0,c.isReusableBlock)(i)&&!!s("update","blocks",i.attributes.ref),innerBlockCount:o(e),managePatternsUrl:u&&s("read","templates")?(0,I.addQueryArgs)("site-editor.php",{path:"/patterns"}):(0,I.addQueryArgs)("edit.php",{post_type:"wp_block"})}}),[e]),{__experimentalConvertBlockToStatic:s}=(0,o.useDispatch)(_);return n?(0,b.createElement)(b.Fragment,null,(0,b.createElement)(w.MenuItem,{href:r},(0,a.__)("Manage patterns")),t&&(0,b.createElement)(w.MenuItem,{onClick:()=>s(e)},(0,a.__)("Detach"))):null};function T({rootClientId:e}){return(0,b.createElement)(l.BlockSettingsMenuControls,null,(({onClose:t,selectedClientIds:n})=>(0,b.createElement)(b.Fragment,null,(0,b.createElement)(R,{clientIds:n,rootClientId:e,onClose:t}),1===n.length&&(0,b.createElement)(S,{clientId:n[0]}))))}(window.wp=window.wp||{}).reusableBlocks=t}();