wp/wp-includes/js/dist/reusable-blocks.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    58 __webpack_require__.r(selectors_namespaceObject);
    58 __webpack_require__.r(selectors_namespaceObject);
    59 __webpack_require__.d(selectors_namespaceObject, {
    59 __webpack_require__.d(selectors_namespaceObject, {
    60   __experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock)
    60   __experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock)
    61 });
    61 });
    62 
    62 
    63 ;// CONCATENATED MODULE: external ["wp","data"]
    63 ;// external ["wp","data"]
    64 const external_wp_data_namespaceObject = window["wp"]["data"];
    64 const external_wp_data_namespaceObject = window["wp"]["data"];
    65 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
    65 ;// external ["wp","blockEditor"]
    66 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
    66 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
    67 ;// CONCATENATED MODULE: external ["wp","blocks"]
    67 ;// external ["wp","blocks"]
    68 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
    68 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
    69 ;// CONCATENATED MODULE: external ["wp","i18n"]
    69 ;// external ["wp","i18n"]
    70 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
    70 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
    71 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
    71 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
    72 /**
    72 /**
    73  * WordPress dependencies
    73  * WordPress dependencies
    74  */
    74  */
    75 
    75 
    76 
    76 
   161     clientId,
   161     clientId,
   162     isEditing
   162     isEditing
   163   };
   163   };
   164 }
   164 }
   165 
   165 
   166 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
   166 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
   167 /**
   167 /**
   168  * WordPress dependencies
   168  * WordPress dependencies
   169  */
   169  */
   170 
   170 
   171 function isEditingReusableBlock(state = {}, action) {
   171 function isEditingReusableBlock(state = {}, action) {
   179 }
   179 }
   180 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
   180 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
   181   isEditingReusableBlock
   181   isEditingReusableBlock
   182 }));
   182 }));
   183 
   183 
   184 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
   184 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
   185 /**
   185 /**
   186  * Returns true if reusable block is in the editing state.
   186  * Returns true if reusable block is in the editing state.
   187  *
   187  *
   188  * @param {Object} state    Global application state.
   188  * @param {Object} state    Global application state.
   189  * @param {number} clientId the clientID of the block.
   189  * @param {number} clientId the clientID of the block.
   191  */
   191  */
   192 function __experimentalIsEditingReusableBlock(state, clientId) {
   192 function __experimentalIsEditingReusableBlock(state, clientId) {
   193   return state.isEditingReusableBlock[clientId];
   193   return state.isEditingReusableBlock[clientId];
   194 }
   194 }
   195 
   195 
   196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
   196 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
   197 /**
   197 /**
   198  * WordPress dependencies
   198  * WordPress dependencies
   199  */
   199  */
   200 
   200 
   201 
   201 
   219   reducer: reducer,
   219   reducer: reducer,
   220   selectors: selectors_namespaceObject
   220   selectors: selectors_namespaceObject
   221 });
   221 });
   222 (0,external_wp_data_namespaceObject.register)(store);
   222 (0,external_wp_data_namespaceObject.register)(store);
   223 
   223 
   224 ;// CONCATENATED MODULE: external ["wp","element"]
   224 ;// external ["wp","element"]
   225 const external_wp_element_namespaceObject = window["wp"]["element"];
   225 const external_wp_element_namespaceObject = window["wp"]["element"];
   226 ;// CONCATENATED MODULE: external ["wp","components"]
   226 ;// external ["wp","components"]
   227 const external_wp_components_namespaceObject = window["wp"]["components"];
   227 const external_wp_components_namespaceObject = window["wp"]["components"];
   228 ;// CONCATENATED MODULE: external ["wp","primitives"]
   228 ;// external ["wp","primitives"]
   229 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
   229 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
   230 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
   230 ;// external "ReactJSXRuntime"
   231 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
   231 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
   232 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
   232 ;// ./node_modules/@wordpress/icons/build-module/library/symbol.js
   233 /**
   233 /**
   234  * WordPress dependencies
   234  * WordPress dependencies
   235  */
   235  */
   236 
   236 
   237 
   237 
   242     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"
   242     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"
   243   })
   243   })
   244 });
   244 });
   245 /* harmony default export */ const library_symbol = (symbol);
   245 /* harmony default export */ const library_symbol = (symbol);
   246 
   246 
   247 ;// CONCATENATED MODULE: external ["wp","notices"]
   247 ;// external ["wp","notices"]
   248 const external_wp_notices_namespaceObject = window["wp"]["notices"];
   248 const external_wp_notices_namespaceObject = window["wp"]["notices"];
   249 ;// CONCATENATED MODULE: external ["wp","coreData"]
   249 ;// external ["wp","coreData"]
   250 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
   250 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
   251 ;// CONCATENATED MODULE: external ["wp","privateApis"]
   251 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
   252 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
       
   253 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/lock-unlock.js
       
   254 /**
       
   255  * WordPress dependencies
       
   256  */
       
   257 
       
   258 const {
       
   259   unlock
       
   260 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/reusable-blocks');
       
   261 
       
   262 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
       
   263 /**
   252 /**
   264  * WordPress dependencies
   253  * WordPress dependencies
   265  */
   254  */
   266 
   255 
   267 
   256 
   275 
   264 
   276 /**
   265 /**
   277  * Internal dependencies
   266  * Internal dependencies
   278  */
   267  */
   279 
   268 
   280 
       
   281 
       
   282 
       
   283 
       
   284 const {
       
   285   useReusableBlocksRenameHint,
       
   286   ReusableBlocksRenameHint
       
   287 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
       
   288 
   269 
   289 /**
   270 /**
   290  * Menu control to convert block(s) to reusable block.
   271  * Menu control to convert block(s) to reusable block.
   291  *
   272  *
   292  * @param {Object}   props              Component props.
   273  * @param {Object}   props              Component props.
   293  * @param {string[]} props.clientIds    Client ids of selected blocks.
   274  * @param {string[]} props.clientIds    Client ids of selected blocks.
   294  * @param {string}   props.rootClientId ID of the currently selected top-level block.
   275  * @param {string}   props.rootClientId ID of the currently selected top-level block.
   295  * @param {()=>void} props.onClose      Callback to close the menu.
   276  * @param {()=>void} props.onClose      Callback to close the menu.
   296  * @return {import('react').ComponentType} The menu control or null.
   277  * @return {import('react').ComponentType} The menu control or null.
   297  */
   278  */
       
   279 
   298 function ReusableBlockConvertButton({
   280 function ReusableBlockConvertButton({
   299   clientIds,
   281   clientIds,
   300   rootClientId,
   282   rootClientId,
   301   onClose
   283   onClose
   302 }) {
   284 }) {
   303   const showRenameHint = useReusableBlocksRenameHint();
       
   304   const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined);
   285   const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined);
   305   const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
   286   const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
   306   const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
   287   const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
   307   const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => {
   288   const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => {
   308     var _getBlocksByClientId;
   289     var _getBlocksByClientId;
   327     // Hide on invalid blocks.
   308     // Hide on invalid blocks.
   328     block.isValid &&
   309     block.isValid &&
   329     // Hide when block doesn't support being made reusable.
   310     // Hide when block doesn't support being made reusable.
   330     (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) &&
   311     (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) &&
   331     // Hide when current doesn't have permission to do that.
   312     // Hide when current doesn't have permission to do that.
   332     !!canUser('create', 'blocks');
   313     // Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
       
   314     !!canUser('create', {
       
   315       kind: 'postType',
       
   316       name: 'wp_block'
       
   317     });
   333     return _canConvert;
   318     return _canConvert;
   334   }, [clientIds, rootClientId]);
   319   }, [clientIds, rootClientId]);
   335   const {
   320   const {
   336     __experimentalConvertBlocksToReusable: convertBlocksToReusable
   321     __experimentalConvertBlocksToReusable: convertBlocksToReusable
   337   } = (0,external_wp_data_namespaceObject.useDispatch)(store);
   322   } = (0,external_wp_data_namespaceObject.useDispatch)(store);
   362   }
   347   }
   363   return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
   348   return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
   364     children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
   349     children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
   365       icon: library_symbol,
   350       icon: library_symbol,
   366       onClick: () => setIsModalOpen(true),
   351       onClick: () => setIsModalOpen(true),
   367       children: showRenameHint ? (0,external_wp_i18n_namespaceObject.__)('Create pattern/reusable block') : (0,external_wp_i18n_namespaceObject.__)('Create pattern')
   352       children: (0,external_wp_i18n_namespaceObject.__)('Create pattern')
   368     }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
   353     }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
   369       title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
   354       title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
   370       onRequestClose: () => {
   355       onRequestClose: () => {
   371         setIsModalOpen(false);
   356         setIsModalOpen(false);
   372         setTitle('');
   357         setTitle('');
   380           setTitle('');
   365           setTitle('');
   381           onClose();
   366           onClose();
   382         },
   367         },
   383         children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
   368         children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
   384           spacing: "5",
   369           spacing: "5",
   385           children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlocksRenameHint, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
   370           children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
       
   371             __next40pxDefaultSize: true,
   386             __nextHasNoMarginBottom: true,
   372             __nextHasNoMarginBottom: true,
   387             label: (0,external_wp_i18n_namespaceObject.__)('Name'),
   373             label: (0,external_wp_i18n_namespaceObject.__)('Name'),
   388             value: title,
   374             value: title,
   389             onChange: setTitle,
   375             onChange: setTitle,
   390             placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern')
   376             placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern')
   391           }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
   377           }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
       
   378             __nextHasNoMarginBottom: true,
   392             label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'),
   379             label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'),
   393             help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'),
   380             help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'),
   394             checked: !syncType,
   381             checked: !syncType,
   395             onChange: () => {
   382             onChange: () => {
   396               setSyncType(!syncType ? 'unsynced' : undefined);
   383               setSyncType(!syncType ? 'unsynced' : undefined);
   397             }
   384             }
   398           }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
   385           }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
   399             justify: "right",
   386             justify: "right",
   400             children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
   387             children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
       
   388               __next40pxDefaultSize: true,
   401               variant: "tertiary",
   389               variant: "tertiary",
   402               onClick: () => {
   390               onClick: () => {
   403                 setIsModalOpen(false);
   391                 setIsModalOpen(false);
   404                 setTitle('');
   392                 setTitle('');
   405               },
   393               },
   406               children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
   394               children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
   407             }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
   395             }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
       
   396               __next40pxDefaultSize: true,
   408               variant: "primary",
   397               variant: "primary",
   409               type: "submit",
   398               type: "submit",
   410               children: (0,external_wp_i18n_namespaceObject.__)('Create')
   399               children: (0,external_wp_i18n_namespaceObject.__)('Create')
   411             })]
   400             })]
   412           })]
   401           })]
   414       })
   403       })
   415     })]
   404     })]
   416   });
   405   });
   417 }
   406 }
   418 
   407 
   419 ;// CONCATENATED MODULE: external ["wp","url"]
   408 ;// external ["wp","url"]
   420 const external_wp_url_namespaceObject = window["wp"]["url"];
   409 const external_wp_url_namespaceObject = window["wp"]["url"];
   421 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
   410 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
   422 /**
   411 /**
   423  * WordPress dependencies
   412  * WordPress dependencies
   424  */
   413  */
   425 
   414 
   426 
   415 
   431 
   420 
   432 
   421 
   433 /**
   422 /**
   434  * Internal dependencies
   423  * Internal dependencies
   435  */
   424  */
   436 
       
   437 
       
   438 
   425 
   439 
   426 
   440 function ReusableBlocksManageButton({
   427 function ReusableBlocksManageButton({
   441   clientId
   428   clientId
   442 }) {
   429 }) {
   454       canUser
   441       canUser
   455     } = select(external_wp_coreData_namespaceObject.store);
   442     } = select(external_wp_coreData_namespaceObject.store);
   456     const reusableBlock = getBlock(clientId);
   443     const reusableBlock = getBlock(clientId);
   457     return {
   444     return {
   458       canRemove: canRemoveBlock(clientId),
   445       canRemove: canRemoveBlock(clientId),
   459       isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref),
   446       isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', {
       
   447         kind: 'postType',
       
   448         name: 'wp_block',
       
   449         id: reusableBlock.attributes.ref
       
   450       }),
   460       innerBlockCount: getBlockCount(clientId),
   451       innerBlockCount: getBlockCount(clientId),
   461       // The site editor and templates both check whether the user
   452       // The site editor and templates both check whether the user
   462       // has edit_theme_options capabilities. We can leverage that here
   453       // has edit_theme_options capabilities. We can leverage that here
   463       // and omit the manage patterns link if the user can't access it.
   454       // and omit the manage patterns link if the user can't access it.
   464       managePatternsUrl: canUser('create', 'templates') ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
   455       managePatternsUrl: canUser('create', {
       
   456         kind: 'postType',
       
   457         name: 'wp_template'
       
   458       }) ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
   465         path: '/patterns'
   459         path: '/patterns'
   466       }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
   460       }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
   467         post_type: 'wp_block'
   461         post_type: 'wp_block'
   468       })
   462       })
   469     };
   463     };
   484     })]
   478     })]
   485   });
   479   });
   486 }
   480 }
   487 /* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton);
   481 /* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton);
   488 
   482 
   489 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
   483 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
   490 /**
   484 /**
   491  * WordPress dependencies
   485  * WordPress dependencies
   492  */
   486  */
   493 
   487 
   494 
   488 
   495 /**
   489 /**
   496  * Internal dependencies
   490  * Internal dependencies
   497  */
   491  */
   498 
       
   499 
       
   500 
   492 
   501 
   493 
   502 
   494 
   503 function ReusableBlocksMenuItems({
   495 function ReusableBlocksMenuItems({
   504   rootClientId
   496   rootClientId
   517       })]
   509       })]
   518     })
   510     })
   519   });
   511   });
   520 }
   512 }
   521 
   513 
   522 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
   514 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
   523 
   515 
   524 
   516 
   525 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
   517 ;// ./node_modules/@wordpress/reusable-blocks/build-module/index.js
   526 
   518 
   527 
   519 
   528 
   520 
   529 (window.wp = window.wp || {}).reusableBlocks = __webpack_exports__;
   521 (window.wp = window.wp || {}).reusableBlocks = __webpack_exports__;
   530 /******/ })()
   522 /******/ })()