WordPress/wp-includes/js/dist/reusable-blocks.min.js

2 lines
5.6 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
Editor: Sync changes from the Gutenberg plugin 14.1 release Updated WordPress packages necessary for releasing WordPress 6.1 Beta 1: - @wordpress/a11y@3.17.1 - @wordpress/annotations@2.17.2 - @wordpress/api-fetch@6.14.1 - @wordpress/autop@3.17.1 - @wordpress/babel-plugin-import-jsx-pragma@4.0.1 - @wordpress/babel-plugin-makepot@5.1.1 - @wordpress/babel-preset-default@7.1.1 - @wordpress/base-styles@4.8.1 - @wordpress/blob@3.17.1 - @wordpress/block-directory@3.15.2 - @wordpress/block-editor@10.0.2 - @wordpress/block-library@7.14.2 - @wordpress/block-serialization-default-parser@4.17.1 - @wordpress/block-serialization-spec-parser@4.17.1 - @wordpress/blocks@11.16.2 - @wordpress/browserslist-config@5.0.1 - @wordpress/components@21.0.2 - @wordpress/compose@5.15.2 - @wordpress/core-data@5.0.2 - @wordpress/create-block-tutorial-template@2.5.1 - @wordpress/create-block@4.1.1 - @wordpress/custom-templated-path-webpack-plugin@2.1.3 - @wordpress/customize-widgets@3.14.2 - @wordpress/data-controls@2.17.2 - @wordpress/data@7.1.2 - @wordpress/date@4.17.1 - @wordpress/dependency-extraction-webpack-plugin@4.0.2 - @wordpress/deprecated@3.17.1 - @wordpress/docgen@1.26.1 - @wordpress/dom-ready@3.17.1 - @wordpress/dom@3.17.2 - @wordpress/e2e-test-utils@8.1.1 - @wordpress/e2e-tests@5.1.2 - @wordpress/edit-post@6.14.2 - @wordpress/edit-site@4.14.2 - @wordpress/edit-widgets@4.14.2 - @wordpress/editor@12.16.2 - @wordpress/element@4.15.1 - @wordpress/env@5.2.1 - @wordpress/escape-html@2.17.1 - @wordpress/eslint-plugin@13.1.1 - @wordpress/format-library@3.15.2 - @wordpress/hooks@3.17.1 - @wordpress/html-entities@3.17.1 - @wordpress/i18n@4.17.1 - @wordpress/icons@9.8.1 - @wordpress/interface@4.16.2 - @wordpress/is-shallow-equal@4.17.1 - @wordpress/jest-console@6.0.1 - @wordpress/jest-preset-default@9.0.1 - @wordpress/jest-puppeteer-axe@5.0.1 - @wordpress/keyboard-shortcuts@3.15.2 - @wordpress/keycodes@3.17.1 - @wordpress/lazy-import@1.4.3 - @wordpress/library-export-default-webpack-plugin@2.3.3 - @wordpress/list-reusable-blocks@3.15.2 - @wordpress/media-utils@4.8.1 - @wordpress/notices@3.17.2 - @wordpress/npm-package-json-lint-config@4.2.1 - @wordpress/nux@5.15.2 - @wordpress/plugins@4.15.2 - @wordpress/postcss-plugins-preset@4.1.1 - @wordpress/postcss-themes@5.0.1 - @wordpress/preferences-persistence@1.9.1 - @wordpress/preferences@2.9.2 - @wordpress/prettier-config@2.0.1 - @wordpress/primitives@3.15.1 - @wordpress/priority-queue@2.17.2 - @wordpress/project-management-automation@1.16.1 - @wordpress/react-i18n@3.15.1 - @wordpress/readable-js-assets-webpack-plugin@2.0.1 - @wordpress/redux-routine@4.17.1 - @wordpress/reusable-blocks@3.15.2 - @wordpress/rich-text@5.15.2 - @wordpress/scripts@24.1.2 - @wordpress/server-side-render@3.15.2 - @wordpress/shortcode@3.17.1 - @wordpress/style-engine@1.0.1 - @wordpress/stylelint-config@21.0.1 - @wordpress/token-list@2.17.1 - @wordpress/url@3.18.1 - @wordpress/viewport@4.15.2 - @wordpress/warning@2.17.1 - @wordpress/widgets@2.15.2 - @wordpress/wordcount@3.17.1 Props bernhard-reiter, cbravobernal, czapla, oandregal, isabel_brison, andrewserong, mciampini. See #56467. Built from https://develop.svn.wordpress.org/trunk@54257 git-svn-id: http://core.svn.wordpress.org/trunk@53816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 11:43:29 -04:00
!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"),onReque