[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ (() => { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = (exports, definition) => { 11 /******/ for(var key in definition) { 12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14 /******/ } 15 /******/ } 16 /******/ }; 17 /******/ })(); 18 /******/ 19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 20 /******/ (() => { 21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22 /******/ })(); 23 /******/ 24 /******/ /* webpack/runtime/make namespace object */ 25 /******/ (() => { 26 /******/ // define __esModule on exports 27 /******/ __webpack_require__.r = (exports) => { 28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30 /******/ } 31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 32 /******/ }; 33 /******/ })(); 34 /******/ 35 /************************************************************************/ 36 var __webpack_exports__ = {}; 37 // ESM COMPAT FLAG 38 __webpack_require__.r(__webpack_exports__); 39 40 // EXPORTS 41 __webpack_require__.d(__webpack_exports__, { 42 ReusableBlocksMenuItems: () => (/* reexport */ ReusableBlocksMenuItems), 43 store: () => (/* reexport */ store) 44 }); 45 46 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js 47 var actions_namespaceObject = {}; 48 __webpack_require__.r(actions_namespaceObject); 49 __webpack_require__.d(actions_namespaceObject, { 50 __experimentalConvertBlockToStatic: () => (__experimentalConvertBlockToStatic), 51 __experimentalConvertBlocksToReusable: () => (__experimentalConvertBlocksToReusable), 52 __experimentalDeleteReusableBlock: () => (__experimentalDeleteReusableBlock), 53 __experimentalSetEditingReusableBlock: () => (__experimentalSetEditingReusableBlock) 54 }); 55 56 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js 57 var selectors_namespaceObject = {}; 58 __webpack_require__.r(selectors_namespaceObject); 59 __webpack_require__.d(selectors_namespaceObject, { 60 __experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock) 61 }); 62 63 ;// CONCATENATED MODULE: external ["wp","data"] 64 const external_wp_data_namespaceObject = window["wp"]["data"]; 65 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 66 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 67 ;// CONCATENATED MODULE: external ["wp","blocks"] 68 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 69 ;// CONCATENATED MODULE: external ["wp","i18n"] 70 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 71 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js 72 /** 73 * WordPress dependencies 74 */ 75 76 77 78 79 /** 80 * Returns a generator converting a reusable block into a static block. 81 * 82 * @param {string} clientId The client ID of the block to attach. 83 */ 84 const __experimentalConvertBlockToStatic = clientId => ({ 85 registry 86 }) => { 87 const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId); 88 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref); 89 const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(typeof reusableBlock.content === 'function' ? reusableBlock.content(reusableBlock) : reusableBlock.content); 90 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks); 91 }; 92 93 /** 94 * Returns a generator converting one or more static blocks into a pattern. 95 * 96 * @param {string[]} clientIds The client IDs of the block to detach. 97 * @param {string} title Pattern title. 98 * @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'. 99 */ 100 const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ 101 registry, 102 dispatch 103 }) => { 104 const meta = syncType === 'unsynced' ? { 105 wp_pattern_sync_status: syncType 106 } : undefined; 107 const reusableBlock = { 108 title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled pattern block'), 109 content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)), 110 status: 'publish', 111 meta 112 }; 113 const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock); 114 if (syncType === 'unsynced') { 115 return; 116 } 117 const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', { 118 ref: updatedRecord.id 119 }); 120 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock); 121 dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true); 122 }; 123 124 /** 125 * Returns a generator deleting a reusable block. 126 * 127 * @param {string} id The ID of the reusable block to delete. 128 */ 129 const __experimentalDeleteReusableBlock = id => async ({ 130 registry 131 }) => { 132 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); 133 134 // Don't allow a reusable block with a temporary ID to be deleted. 135 if (!reusableBlock) { 136 return; 137 } 138 139 // Remove any other blocks that reference this reusable block. 140 const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(); 141 const associatedBlocks = allBlocks.filter(block => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id); 142 const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); 143 144 // Remove the parsed block. 145 if (associatedBlockClientIds.length) { 146 registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds); 147 } 148 await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id); 149 }; 150 151 /** 152 * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action. 153 * 154 * @param {string} clientId The clientID of the reusable block to target. 155 * @param {boolean} isEditing Whether the block should be in editing state. 156 * @return {Object} Action descriptor. 157 */ 158 function __experimentalSetEditingReusableBlock(clientId, isEditing) { 159 return { 160 type: 'SET_EDITING_REUSABLE_BLOCK', 161 clientId, 162 isEditing 163 }; 164 } 165 166 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js 167 /** 168 * WordPress dependencies 169 */ 170 171 function isEditingReusableBlock(state = {}, action) { 172 if (action?.type === 'SET_EDITING_REUSABLE_BLOCK') { 173 return { 174 ...state, 175 [action.clientId]: action.isEditing 176 }; 177 } 178 return state; 179 } 180 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 181 isEditingReusableBlock 182 })); 183 184 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js 185 /** 186 * Returns true if reusable block is in the editing state. 187 * 188 * @param {Object} state Global application state. 189 * @param {number} clientId the clientID of the block. 190 * @return {boolean} Whether the reusable block is in the editing state. 191 */ 192 function __experimentalIsEditingReusableBlock(state, clientId) { 193 return state.isEditingReusableBlock[clientId]; 194 } 195 196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js 197 /** 198 * WordPress dependencies 199 */ 200 201 202 /** 203 * Internal dependencies 204 */ 205 206 207 208 const STORE_NAME = 'core/reusable-blocks'; 209 210 /** 211 * Store definition for the reusable blocks namespace. 212 * 213 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 214 * 215 * @type {Object} 216 */ 217 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 218 actions: actions_namespaceObject, 219 reducer: reducer, 220 selectors: selectors_namespaceObject 221 }); 222 (0,external_wp_data_namespaceObject.register)(store); 223 224 ;// CONCATENATED MODULE: external ["wp","element"] 225 const external_wp_element_namespaceObject = window["wp"]["element"]; 226 ;// CONCATENATED MODULE: external ["wp","components"] 227 const external_wp_components_namespaceObject = window["wp"]["components"]; 228 ;// CONCATENATED MODULE: external ["wp","primitives"] 229 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 230 ;// CONCATENATED MODULE: external "ReactJSXRuntime" 231 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 232 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js 233 /** 234 * WordPress dependencies 235 */ 236 237 238 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 239 xmlns: "http://www.w3.org/2000/svg", 240 viewBox: "0 0 24 24", 241 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 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 }) 244 }); 245 /* harmony default export */ const library_symbol = (symbol); 246 247 ;// CONCATENATED MODULE: external ["wp","notices"] 248 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 249 ;// CONCATENATED MODULE: external ["wp","coreData"] 250 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 251 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js 252 /** 253 * WordPress dependencies 254 */ 255 256 257 258 259 260 261 262 263 264 265 /** 266 * Internal dependencies 267 */ 268 269 270 /** 271 * Menu control to convert block(s) to reusable block. 272 * 273 * @param {Object} props Component props. 274 * @param {string[]} props.clientIds Client ids of selected blocks. 275 * @param {string} props.rootClientId ID of the currently selected top-level block. 276 * @param {()=>void} props.onClose Callback to close the menu. 277 * @return {import('react').ComponentType} The menu control or null. 278 */ 279 280 281 282 function ReusableBlockConvertButton({ 283 clientIds, 284 rootClientId, 285 onClose 286 }) { 287 const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined); 288 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 289 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 290 const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => { 291 var _getBlocksByClientId; 292 const { 293 canUser 294 } = select(external_wp_coreData_namespaceObject.store); 295 const { 296 getBlocksByClientId, 297 canInsertBlockType, 298 getBlockRootClientId 299 } = select(external_wp_blockEditor_namespaceObject.store); 300 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined); 301 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; 302 const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref); 303 const _canConvert = 304 // Hide when this is already a reusable block. 305 !isReusable && 306 // Hide when reusable blocks are disabled. 307 canInsertBlockType('core/block', rootId) && blocks.every(block => 308 // Guard against the case where a regular block has *just* been converted. 309 !!block && 310 // Hide on invalid blocks. 311 block.isValid && 312 // Hide when block doesn't support being made reusable. 313 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && 314 // Hide when current doesn't have permission to do that. 315 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. 316 !!canUser('create', { 317 kind: 'postType', 318 name: 'wp_block' 319 }); 320 return _canConvert; 321 }, [clientIds, rootClientId]); 322 const { 323 __experimentalConvertBlocksToReusable: convertBlocksToReusable 324 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 325 const { 326 createSuccessNotice, 327 createErrorNotice 328 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 329 const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) { 330 try { 331 await convertBlocksToReusable(clientIds, reusableBlockTitle, syncType); 332 createSuccessNotice(!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)( 333 // translators: %s: the name the user has given to the pattern. 334 (0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), reusableBlockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)( 335 // translators: %s: the name the user has given to the pattern. 336 (0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), reusableBlockTitle), { 337 type: 'snackbar', 338 id: 'convert-to-reusable-block-success' 339 }); 340 } catch (error) { 341 createErrorNotice(error.message, { 342 type: 'snackbar', 343 id: 'convert-to-reusable-block-error' 344 }); 345 } 346 }, [convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice]); 347 if (!canConvert) { 348 return null; 349 } 350 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 351 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { 352 icon: library_symbol, 353 onClick: () => setIsModalOpen(true), 354 children: (0,external_wp_i18n_namespaceObject.__)('Create pattern') 355 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { 356 title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'), 357 onRequestClose: () => { 358 setIsModalOpen(false); 359 setTitle(''); 360 }, 361 overlayClassName: "reusable-blocks-menu-items__convert-modal", 362 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { 363 onSubmit: event => { 364 event.preventDefault(); 365 onConvert(title); 366 setIsModalOpen(false); 367 setTitle(''); 368 onClose(); 369 }, 370 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { 371 spacing: "5", 372 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, { 373 __next40pxDefaultSize: true, 374 __nextHasNoMarginBottom: true, 375 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 376 value: title, 377 onChange: setTitle, 378 placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern') 379 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, { 380 __nextHasNoMarginBottom: true, 381 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'), 382 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'), 383 checked: !syncType, 384 onChange: () => { 385 setSyncType(!syncType ? 'unsynced' : undefined); 386 } 387 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { 388 justify: "right", 389 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { 390 __next40pxDefaultSize: true, 391 variant: "tertiary", 392 onClick: () => { 393 setIsModalOpen(false); 394 setTitle(''); 395 }, 396 children: (0,external_wp_i18n_namespaceObject.__)('Cancel') 397 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { 398 __next40pxDefaultSize: true, 399 variant: "primary", 400 type: "submit", 401 children: (0,external_wp_i18n_namespaceObject.__)('Create') 402 })] 403 })] 404 }) 405 }) 406 })] 407 }); 408 } 409 410 ;// CONCATENATED MODULE: external ["wp","url"] 411 const external_wp_url_namespaceObject = window["wp"]["url"]; 412 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js 413 /** 414 * WordPress dependencies 415 */ 416 417 418 419 420 421 422 423 424 /** 425 * Internal dependencies 426 */ 427 428 429 430 431 function ReusableBlocksManageButton({ 432 clientId 433 }) { 434 const { 435 canRemove, 436 isVisible, 437 managePatternsUrl 438 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 439 const { 440 getBlock, 441 canRemoveBlock, 442 getBlockCount 443 } = select(external_wp_blockEditor_namespaceObject.store); 444 const { 445 canUser 446 } = select(external_wp_coreData_namespaceObject.store); 447 const reusableBlock = getBlock(clientId); 448 return { 449 canRemove: canRemoveBlock(clientId), 450 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', { 451 kind: 'postType', 452 name: 'wp_block', 453 id: reusableBlock.attributes.ref 454 }), 455 innerBlockCount: getBlockCount(clientId), 456 // The site editor and templates both check whether the user 457 // has edit_theme_options capabilities. We can leverage that here 458 // and omit the manage patterns link if the user can't access it. 459 managePatternsUrl: canUser('create', { 460 kind: 'postType', 461 name: 'wp_template' 462 }) ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { 463 path: '/patterns' 464 }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { 465 post_type: 'wp_block' 466 }) 467 }; 468 }, [clientId]); 469 const { 470 __experimentalConvertBlockToStatic: convertBlockToStatic 471 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 472 if (!isVisible) { 473 return null; 474 } 475 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 476 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { 477 href: managePatternsUrl, 478 children: (0,external_wp_i18n_namespaceObject.__)('Manage patterns') 479 }), canRemove && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { 480 onClick: () => convertBlockToStatic(clientId), 481 children: (0,external_wp_i18n_namespaceObject.__)('Detach') 482 })] 483 }); 484 } 485 /* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton); 486 487 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js 488 /** 489 * WordPress dependencies 490 */ 491 492 493 /** 494 * Internal dependencies 495 */ 496 497 498 499 500 501 function ReusableBlocksMenuItems({ 502 rootClientId 503 }) { 504 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, { 505 children: ({ 506 onClose, 507 selectedClientIds 508 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 509 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlockConvertButton, { 510 clientIds: selectedClientIds, 511 rootClientId: rootClientId, 512 onClose: onClose 513 }), selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(reusable_blocks_manage_button, { 514 clientId: selectedClientIds[0] 515 })] 516 }) 517 }); 518 } 519 520 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js 521 522 523 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js 524 525 526 527 (window.wp = window.wp || {}).reusableBlocks = __webpack_exports__; 528 /******/ })() 529 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Nov 24 08:20:01 2024 | Cross-referenced by PHPXref |