[ 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 "React" 225 const external_React_namespaceObject = window["React"]; 226 ;// CONCATENATED MODULE: external ["wp","element"] 227 const external_wp_element_namespaceObject = window["wp"]["element"]; 228 ;// CONCATENATED MODULE: external ["wp","components"] 229 const external_wp_components_namespaceObject = window["wp"]["components"]; 230 ;// CONCATENATED MODULE: external ["wp","primitives"] 231 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 232 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js 233 234 /** 235 * WordPress dependencies 236 */ 237 238 const symbol = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 239 xmlns: "http://www.w3.org/2000/svg", 240 viewBox: "0 0 24 24" 241 }, (0,external_React_namespaceObject.createElement)(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 /* harmony default export */ const library_symbol = (symbol); 245 246 ;// CONCATENATED MODULE: external ["wp","notices"] 247 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 248 ;// CONCATENATED MODULE: external ["wp","coreData"] 249 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 250 ;// CONCATENATED MODULE: external ["wp","privateApis"] 251 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 252 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/lock-unlock.js 253 /** 254 * WordPress dependencies 255 */ 256 257 const { 258 unlock 259 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/reusable-blocks'); 260 261 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js 262 263 /** 264 * WordPress dependencies 265 */ 266 267 268 269 270 271 272 273 274 275 276 /** 277 * Internal dependencies 278 */ 279 280 281 const { 282 useReusableBlocksRenameHint, 283 ReusableBlocksRenameHint 284 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 285 286 /** 287 * Menu control to convert block(s) to reusable block. 288 * 289 * @param {Object} props Component props. 290 * @param {string[]} props.clientIds Client ids of selected blocks. 291 * @param {string} props.rootClientId ID of the currently selected top-level block. 292 * @param {()=>void} props.onClose Callback to close the menu. 293 * @return {import('react').ComponentType} The menu control or null. 294 */ 295 function ReusableBlockConvertButton({ 296 clientIds, 297 rootClientId, 298 onClose 299 }) { 300 const showRenameHint = useReusableBlocksRenameHint(); 301 const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined); 302 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 303 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 304 const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => { 305 var _getBlocksByClientId; 306 const { 307 canUser 308 } = select(external_wp_coreData_namespaceObject.store); 309 const { 310 getBlocksByClientId, 311 canInsertBlockType, 312 getBlockRootClientId 313 } = select(external_wp_blockEditor_namespaceObject.store); 314 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined); 315 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; 316 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); 317 const _canConvert = 318 // Hide when this is already a reusable block. 319 !isReusable && 320 // Hide when reusable blocks are disabled. 321 canInsertBlockType('core/block', rootId) && blocks.every(block => 322 // Guard against the case where a regular block has *just* been converted. 323 !!block && 324 // Hide on invalid blocks. 325 block.isValid && 326 // Hide when block doesn't support being made reusable. 327 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && 328 // Hide when current doesn't have permission to do that. 329 !!canUser('create', 'blocks'); 330 return _canConvert; 331 }, [clientIds, rootClientId]); 332 const { 333 __experimentalConvertBlocksToReusable: convertBlocksToReusable 334 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 335 const { 336 createSuccessNotice, 337 createErrorNotice 338 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 339 const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) { 340 try { 341 await convertBlocksToReusable(clientIds, reusableBlockTitle, syncType); 342 createSuccessNotice(!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)( 343 // translators: %s: the name the user has given to the pattern. 344 (0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), reusableBlockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)( 345 // translators: %s: the name the user has given to the pattern. 346 (0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), reusableBlockTitle), { 347 type: 'snackbar', 348 id: 'convert-to-reusable-block-success' 349 }); 350 } catch (error) { 351 createErrorNotice(error.message, { 352 type: 'snackbar', 353 id: 'convert-to-reusable-block-error' 354 }); 355 } 356 }, [convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice]); 357 if (!canConvert) { 358 return null; 359 } 360 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 361 icon: library_symbol, 362 onClick: () => setIsModalOpen(true) 363 }, showRenameHint ? (0,external_wp_i18n_namespaceObject.__)('Create pattern/reusable block') : (0,external_wp_i18n_namespaceObject.__)('Create pattern')), isModalOpen && (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { 364 title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'), 365 onRequestClose: () => { 366 setIsModalOpen(false); 367 setTitle(''); 368 }, 369 overlayClassName: "reusable-blocks-menu-items__convert-modal" 370 }, (0,external_React_namespaceObject.createElement)("form", { 371 onSubmit: event => { 372 event.preventDefault(); 373 onConvert(title); 374 setIsModalOpen(false); 375 setTitle(''); 376 onClose(); 377 } 378 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 379 spacing: "5" 380 }, (0,external_React_namespaceObject.createElement)(ReusableBlocksRenameHint, null), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 381 __nextHasNoMarginBottom: true, 382 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 383 value: title, 384 onChange: setTitle, 385 placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern') 386 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { 387 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'Option that makes an individual pattern synchronized'), 388 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'), 389 checked: !syncType, 390 onChange: () => { 391 setSyncType(!syncType ? 'unsynced' : undefined); 392 } 393 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 394 justify: "right" 395 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 396 variant: "tertiary", 397 onClick: () => { 398 setIsModalOpen(false); 399 setTitle(''); 400 } 401 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 402 variant: "primary", 403 type: "submit" 404 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))))); 405 } 406 407 ;// CONCATENATED MODULE: external ["wp","url"] 408 const external_wp_url_namespaceObject = window["wp"]["url"]; 409 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js 410 411 /** 412 * WordPress dependencies 413 */ 414 415 416 417 418 419 420 421 422 /** 423 * Internal dependencies 424 */ 425 426 function ReusableBlocksManageButton({ 427 clientId 428 }) { 429 const { 430 canRemove, 431 isVisible, 432 managePatternsUrl 433 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 434 const { 435 getBlock, 436 canRemoveBlock, 437 getBlockCount, 438 getSettings 439 } = select(external_wp_blockEditor_namespaceObject.store); 440 const { 441 canUser 442 } = select(external_wp_coreData_namespaceObject.store); 443 const reusableBlock = getBlock(clientId); 444 const isBlockTheme = getSettings().__unstableIsBlockBasedTheme; 445 return { 446 canRemove: canRemoveBlock(clientId), 447 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref), 448 innerBlockCount: getBlockCount(clientId), 449 // The site editor and templates both check whether the user 450 // has edit_theme_options capabilities. We can leverage that here 451 // and omit the manage patterns link if the user can't access it. 452 managePatternsUrl: isBlockTheme && canUser('read', 'templates') ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { 453 path: '/patterns' 454 }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { 455 post_type: 'wp_block' 456 }) 457 }; 458 }, [clientId]); 459 const { 460 __experimentalConvertBlockToStatic: convertBlockToStatic 461 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 462 if (!isVisible) { 463 return null; 464 } 465 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 466 href: managePatternsUrl 467 }, (0,external_wp_i18n_namespaceObject.__)('Manage patterns')), canRemove && (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { 468 onClick: () => convertBlockToStatic(clientId) 469 }, (0,external_wp_i18n_namespaceObject.__)('Detach'))); 470 } 471 /* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton); 472 473 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js 474 475 /** 476 * WordPress dependencies 477 */ 478 479 480 /** 481 * Internal dependencies 482 */ 483 484 485 function ReusableBlocksMenuItems({ 486 rootClientId 487 }) { 488 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, ({ 489 onClose, 490 selectedClientIds 491 }) => (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(ReusableBlockConvertButton, { 492 clientIds: selectedClientIds, 493 rootClientId: rootClientId, 494 onClose: onClose 495 }), selectedClientIds.length === 1 && (0,external_React_namespaceObject.createElement)(reusable_blocks_manage_button, { 496 clientId: selectedClientIds[0] 497 }))); 498 } 499 500 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js 501 502 503 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js 504 505 506 507 (window.wp = window.wp || {}).reusableBlocks = __webpack_exports__; 508 /******/ })() 509 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Apr 20 08:20:01 2024 | Cross-referenced by PHPXref |