[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /******/ (function() { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/compat get default export */ 8 /******/ !function() { 9 /******/ // getDefaultExport function for compatibility with non-harmony modules 10 /******/ __webpack_require__.n = function(module) { 11 /******/ var getter = module && module.__esModule ? 12 /******/ function() { return module['default']; } : 13 /******/ function() { return module; }; 14 /******/ __webpack_require__.d(getter, { a: getter }); 15 /******/ return getter; 16 /******/ }; 17 /******/ }(); 18 /******/ 19 /******/ /* webpack/runtime/define property getters */ 20 /******/ !function() { 21 /******/ // define getter functions for harmony exports 22 /******/ __webpack_require__.d = function(exports, definition) { 23 /******/ for(var key in definition) { 24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 26 /******/ } 27 /******/ } 28 /******/ }; 29 /******/ }(); 30 /******/ 31 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 32 /******/ !function() { 33 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 34 /******/ }(); 35 /******/ 36 /******/ /* webpack/runtime/make namespace object */ 37 /******/ !function() { 38 /******/ // define __esModule on exports 39 /******/ __webpack_require__.r = function(exports) { 40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 42 /******/ } 43 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 44 /******/ }; 45 /******/ }(); 46 /******/ 47 /************************************************************************/ 48 var __webpack_exports__ = {}; 49 // ESM COMPAT FLAG 50 __webpack_require__.r(__webpack_exports__); 51 52 // EXPORTS 53 __webpack_require__.d(__webpack_exports__, { 54 "store": function() { return /* reexport */ store; } 55 }); 56 57 // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js 58 var selectors_namespaceObject = {}; 59 __webpack_require__.r(selectors_namespaceObject); 60 __webpack_require__.d(selectors_namespaceObject, { 61 "getDownloadableBlocks": function() { return getDownloadableBlocks; }, 62 "getErrorNoticeForBlock": function() { return getErrorNoticeForBlock; }, 63 "getErrorNotices": function() { return getErrorNotices; }, 64 "getInstalledBlockTypes": function() { return getInstalledBlockTypes; }, 65 "getNewBlockTypes": function() { return getNewBlockTypes; }, 66 "getUnusedBlockTypes": function() { return getUnusedBlockTypes; }, 67 "isInstalling": function() { return isInstalling; }, 68 "isRequestingDownloadableBlocks": function() { return isRequestingDownloadableBlocks; } 69 }); 70 71 // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/actions.js 72 var actions_namespaceObject = {}; 73 __webpack_require__.r(actions_namespaceObject); 74 __webpack_require__.d(actions_namespaceObject, { 75 "addInstalledBlockType": function() { return addInstalledBlockType; }, 76 "clearErrorNotice": function() { return clearErrorNotice; }, 77 "fetchDownloadableBlocks": function() { return fetchDownloadableBlocks; }, 78 "installBlockType": function() { return installBlockType; }, 79 "receiveDownloadableBlocks": function() { return receiveDownloadableBlocks; }, 80 "removeInstalledBlockType": function() { return removeInstalledBlockType; }, 81 "setErrorNotice": function() { return setErrorNotice; }, 82 "setIsInstalling": function() { return setIsInstalling; }, 83 "uninstallBlockType": function() { return uninstallBlockType; } 84 }); 85 86 // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js 87 var resolvers_namespaceObject = {}; 88 __webpack_require__.r(resolvers_namespaceObject); 89 __webpack_require__.d(resolvers_namespaceObject, { 90 "getDownloadableBlocks": function() { return resolvers_getDownloadableBlocks; } 91 }); 92 93 ;// CONCATENATED MODULE: external ["wp","element"] 94 var external_wp_element_namespaceObject = window["wp"]["element"]; 95 ;// CONCATENATED MODULE: external ["wp","plugins"] 96 var external_wp_plugins_namespaceObject = window["wp"]["plugins"]; 97 ;// CONCATENATED MODULE: external ["wp","hooks"] 98 var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 99 ;// CONCATENATED MODULE: external ["wp","blocks"] 100 var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 101 ;// CONCATENATED MODULE: external ["wp","data"] 102 var external_wp_data_namespaceObject = window["wp"]["data"]; 103 ;// CONCATENATED MODULE: external ["wp","editor"] 104 var external_wp_editor_namespaceObject = window["wp"]["editor"]; 105 ;// CONCATENATED MODULE: external "lodash" 106 var external_lodash_namespaceObject = window["lodash"]; 107 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/reducer.js 108 /** 109 * External dependencies 110 */ 111 112 /** 113 * WordPress dependencies 114 */ 115 116 117 /** 118 * Reducer returning an array of downloadable blocks. 119 * 120 * @param {Object} state Current state. 121 * @param {Object} action Dispatched action. 122 * 123 * @return {Object} Updated state. 124 */ 125 126 const downloadableBlocks = function () { 127 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 128 let action = arguments.length > 1 ? arguments[1] : undefined; 129 130 switch (action.type) { 131 case 'FETCH_DOWNLOADABLE_BLOCKS': 132 return { ...state, 133 [action.filterValue]: { 134 isRequesting: true 135 } 136 }; 137 138 case 'RECEIVE_DOWNLOADABLE_BLOCKS': 139 return { ...state, 140 [action.filterValue]: { 141 results: action.downloadableBlocks, 142 isRequesting: false 143 } 144 }; 145 } 146 147 return state; 148 }; 149 /** 150 * Reducer managing the installation and deletion of blocks. 151 * 152 * @param {Object} state Current state. 153 * @param {Object} action Dispatched action. 154 * 155 * @return {Object} Updated state. 156 */ 157 158 const blockManagement = function () { 159 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 160 installedBlockTypes: [], 161 isInstalling: {} 162 }; 163 let action = arguments.length > 1 ? arguments[1] : undefined; 164 165 switch (action.type) { 166 case 'ADD_INSTALLED_BLOCK_TYPE': 167 return { ...state, 168 installedBlockTypes: [...state.installedBlockTypes, action.item] 169 }; 170 171 case 'REMOVE_INSTALLED_BLOCK_TYPE': 172 return { ...state, 173 installedBlockTypes: state.installedBlockTypes.filter(blockType => blockType.name !== action.item.name) 174 }; 175 176 case 'SET_INSTALLING_BLOCK': 177 return { ...state, 178 isInstalling: { ...state.isInstalling, 179 [action.blockId]: action.isInstalling 180 } 181 }; 182 } 183 184 return state; 185 }; 186 /** 187 * Reducer returning an object of error notices. 188 * 189 * @param {Object} state Current state. 190 * @param {Object} action Dispatched action. 191 * 192 * @return {Object} Updated state. 193 */ 194 195 const errorNotices = function () { 196 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 197 let action = arguments.length > 1 ? arguments[1] : undefined; 198 199 switch (action.type) { 200 case 'SET_ERROR_NOTICE': 201 return { ...state, 202 [action.blockId]: { 203 message: action.message, 204 isFatal: action.isFatal 205 } 206 }; 207 208 case 'CLEAR_ERROR_NOTICE': 209 return (0,external_lodash_namespaceObject.omit)(state, action.blockId); 210 } 211 212 return state; 213 }; 214 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 215 downloadableBlocks, 216 blockManagement, 217 errorNotices 218 })); 219 220 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 221 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 222 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/has-block-type.js 223 /** 224 * Check if a block list contains a specific block type. Recursively searches 225 * through `innerBlocks` if they exist. 226 * 227 * @param {Object} blockType A block object to search for. 228 * @param {Object[]} blocks The list of blocks to look through. 229 * 230 * @return {boolean} Whether the blockType is found. 231 */ 232 function hasBlockType(blockType) { 233 let blocks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 234 235 if (!blocks.length) { 236 return false; 237 } 238 239 if (blocks.some(_ref => { 240 let { 241 name 242 } = _ref; 243 return name === blockType.name; 244 })) { 245 return true; 246 } 247 248 for (let i = 0; i < blocks.length; i++) { 249 if (hasBlockType(blockType, blocks[i].innerBlocks)) { 250 return true; 251 } 252 } 253 254 return false; 255 } 256 257 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js 258 /** 259 * WordPress dependencies 260 */ 261 262 263 /** 264 * Internal dependencies 265 */ 266 267 268 /** 269 * Returns true if application is requesting for downloadable blocks. 270 * 271 * @param {Object} state Global application state. 272 * @param {string} filterValue Search string. 273 * 274 * @return {boolean} Whether a request is in progress for the blocks list. 275 */ 276 277 function isRequestingDownloadableBlocks(state, filterValue) { 278 var _state$downloadableBl, _state$downloadableBl2; 279 280 return (_state$downloadableBl = (_state$downloadableBl2 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl2 === void 0 ? void 0 : _state$downloadableBl2.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false; 281 } 282 /** 283 * Returns the available uninstalled blocks. 284 * 285 * @param {Object} state Global application state. 286 * @param {string} filterValue Search string. 287 * 288 * @return {Array} Downloadable blocks. 289 */ 290 291 function getDownloadableBlocks(state, filterValue) { 292 var _state$downloadableBl3, _state$downloadableBl4; 293 294 return (_state$downloadableBl3 = (_state$downloadableBl4 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl4 === void 0 ? void 0 : _state$downloadableBl4.results) !== null && _state$downloadableBl3 !== void 0 ? _state$downloadableBl3 : []; 295 } 296 /** 297 * Returns the block types that have been installed on the server in this 298 * session. 299 * 300 * @param {Object} state Global application state. 301 * 302 * @return {Array} Block type items 303 */ 304 305 function getInstalledBlockTypes(state) { 306 return state.blockManagement.installedBlockTypes; 307 } 308 /** 309 * Returns block types that have been installed on the server and used in the 310 * current post. 311 * 312 * @param {Object} state Global application state. 313 * 314 * @return {Array} Block type items. 315 */ 316 317 const getNewBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 318 const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); 319 const installedBlockTypes = getInstalledBlockTypes(state); 320 return installedBlockTypes.filter(blockType => hasBlockType(blockType, usedBlockTree)); 321 }); 322 /** 323 * Returns the block types that have been installed on the server but are not 324 * used in the current post. 325 * 326 * @param {Object} state Global application state. 327 * 328 * @return {Array} Block type items. 329 */ 330 331 const getUnusedBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { 332 const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); 333 const installedBlockTypes = getInstalledBlockTypes(state); 334 return installedBlockTypes.filter(blockType => !hasBlockType(blockType, usedBlockTree)); 335 }); 336 /** 337 * Returns true if a block plugin install is in progress. 338 * 339 * @param {Object} state Global application state. 340 * @param {string} blockId Id of the block. 341 * 342 * @return {boolean} Whether this block is currently being installed. 343 */ 344 345 function isInstalling(state, blockId) { 346 return state.blockManagement.isInstalling[blockId] || false; 347 } 348 /** 349 * Returns all block error notices. 350 * 351 * @param {Object} state Global application state. 352 * 353 * @return {Object} Object with error notices. 354 */ 355 356 function getErrorNotices(state) { 357 return state.errorNotices; 358 } 359 /** 360 * Returns the error notice for a given block. 361 * 362 * @param {Object} state Global application state. 363 * @param {string} blockId The ID of the block plugin. eg: my-block 364 * 365 * @return {string|boolean} The error text, or false if no error. 366 */ 367 368 function getErrorNoticeForBlock(state, blockId) { 369 return state.errorNotices[blockId]; 370 } 371 372 ;// CONCATENATED MODULE: external ["wp","i18n"] 373 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 374 ;// CONCATENATED MODULE: external ["wp","apiFetch"] 375 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 376 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 377 ;// CONCATENATED MODULE: external ["wp","notices"] 378 var external_wp_notices_namespaceObject = window["wp"]["notices"]; 379 ;// CONCATENATED MODULE: external ["wp","url"] 380 var external_wp_url_namespaceObject = window["wp"]["url"]; 381 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/load-assets.js 382 /** 383 * WordPress dependencies 384 */ 385 386 /** 387 * Load an asset for a block. 388 * 389 * This function returns a Promise that will resolve once the asset is loaded, 390 * or in the case of Stylesheets and Inline JavaScript, will resolve immediately. 391 * 392 * @param {HTMLElement} el A HTML Element asset to inject. 393 * 394 * @return {Promise} Promise which will resolve when the asset is loaded. 395 */ 396 397 const loadAsset = el => { 398 return new Promise((resolve, reject) => { 399 /* 400 * Reconstruct the passed element, this is required as inserting the Node directly 401 * won't always fire the required onload events, even if the asset wasn't already loaded. 402 */ 403 const newNode = document.createElement(el.nodeName); 404 ['id', 'rel', 'src', 'href', 'type'].forEach(attr => { 405 if (el[attr]) { 406 newNode[attr] = el[attr]; 407 } 408 }); // Append inline <script> contents. 409 410 if (el.innerHTML) { 411 newNode.appendChild(document.createTextNode(el.innerHTML)); 412 } 413 414 newNode.onload = () => resolve(true); 415 416 newNode.onerror = () => reject(new Error('Error loading asset.')); 417 418 document.body.appendChild(newNode); // Resolve Stylesheets and Inline JavaScript immediately. 419 420 if ('link' === newNode.nodeName.toLowerCase() || 'script' === newNode.nodeName.toLowerCase() && !newNode.src) { 421 resolve(); 422 } 423 }); 424 }; 425 /** 426 * Load the asset files for a block 427 */ 428 429 async function loadAssets() { 430 /* 431 * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the 432 * JavaScript and CSS assets loaded between the pages. This imports the required assets 433 * for the block into the current page while not requiring that we know them up-front. 434 * In the future this can be improved by reliance upon block.json and/or a script-loader 435 * dependency API. 436 */ 437 const response = await external_wp_apiFetch_default()({ 438 url: document.location.href, 439 parse: false 440 }); 441 const data = await response.text(); 442 const doc = new window.DOMParser().parseFromString(data, 'text/html'); 443 const newAssets = Array.from(doc.querySelectorAll('link[rel="stylesheet"],script')).filter(asset => asset.id && !document.getElementById(asset.id)); 444 /* 445 * Load each asset in order, as they may depend upon an earlier loaded script. 446 * Stylesheets and Inline Scripts will resolve immediately upon insertion. 447 */ 448 449 for (const newAsset of newAssets) { 450 await loadAsset(newAsset); 451 } 452 } 453 454 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/get-plugin-url.js 455 /** 456 * Get the plugin's direct API link out of a block-directory response. 457 * 458 * @param {Object} block The block object 459 * 460 * @return {string} The plugin URL, if exists. 461 */ 462 function getPluginUrl(block) { 463 if (!block) { 464 return false; 465 } 466 467 const link = block.links['wp:plugin'] || block.links.self; 468 469 if (link && link.length) { 470 return link[0].href; 471 } 472 473 return false; 474 } 475 476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/actions.js 477 /** 478 * External dependencies 479 */ 480 481 /** 482 * WordPress dependencies 483 */ 484 485 486 487 488 489 490 /** 491 * Internal dependencies 492 */ 493 494 495 496 /** 497 * Returns an action object used in signalling that the downloadable blocks 498 * have been requested and are loading. 499 * 500 * @param {string} filterValue Search string. 501 * 502 * @return {Object} Action object. 503 */ 504 505 function fetchDownloadableBlocks(filterValue) { 506 return { 507 type: 'FETCH_DOWNLOADABLE_BLOCKS', 508 filterValue 509 }; 510 } 511 /** 512 * Returns an action object used in signalling that the downloadable blocks 513 * have been updated. 514 * 515 * @param {Array} downloadableBlocks Downloadable blocks. 516 * @param {string} filterValue Search string. 517 * 518 * @return {Object} Action object. 519 */ 520 521 function receiveDownloadableBlocks(downloadableBlocks, filterValue) { 522 return { 523 type: 'RECEIVE_DOWNLOADABLE_BLOCKS', 524 downloadableBlocks, 525 filterValue 526 }; 527 } 528 /** 529 * Action triggered to install a block plugin. 530 * 531 * @param {Object} block The block item returned by search. 532 * 533 * @return {boolean} Whether the block was successfully installed & loaded. 534 */ 535 536 const installBlockType = block => async _ref => { 537 let { 538 registry, 539 dispatch 540 } = _ref; 541 const { 542 id, 543 name 544 } = block; 545 let success = false; 546 dispatch.clearErrorNotice(id); 547 548 try { 549 dispatch.setIsInstalling(id, true); // If we have a wp:plugin link, the plugin is installed but inactive. 550 551 const url = getPluginUrl(block); 552 let links = {}; 553 554 if (url) { 555 await external_wp_apiFetch_default()({ 556 method: 'PUT', 557 url, 558 data: { 559 status: 'active' 560 } 561 }); 562 } else { 563 const response = await external_wp_apiFetch_default()({ 564 method: 'POST', 565 path: 'wp/v2/plugins', 566 data: { 567 slug: id, 568 status: 'active' 569 } 570 }); // Add the `self` link for newly-installed blocks. 571 572 links = response._links; 573 } 574 575 dispatch.addInstalledBlockType({ ...block, 576 links: { ...block.links, 577 ...links 578 } 579 }); // Ensures that the block metadata is propagated to the editor when registered on the server. 580 581 const metadataFields = ['api_version', 'title', 'category', 'parent', 'icon', 'description', 'keywords', 'attributes', 'provides_context', 'uses_context', 'supports', 'styles', 'example', 'variations']; 582 await external_wp_apiFetch_default()({ 583 path: (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-types/$name}`, { 584 _fields: metadataFields 585 }) 586 }) // Ignore when the block is not registered on the server. 587 .catch(() => {}).then(response => { 588 if (!response) { 589 return; 590 } 591 592 (0,external_wp_blocks_namespaceObject.unstable__bootstrapServerSideBlockDefinitions)({ 593 [name]: (0,external_lodash_namespaceObject.pick)(response, metadataFields) 594 }); 595 }); 596 await loadAssets(); 597 const registeredBlocks = registry.select(external_wp_blocks_namespaceObject.store).getBlockTypes(); 598 599 if (!registeredBlocks.some(i => i.name === name)) { 600 throw new Error((0,external_wp_i18n_namespaceObject.__)('Error registering block. Try reloading the page.')); 601 } 602 603 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is the block title. 604 (0,external_wp_i18n_namespaceObject.__)('Block %s installed and added.'), block.title), { 605 speak: true, 606 type: 'snackbar' 607 }); 608 success = true; 609 } catch (error) { 610 let message = error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.'); // Errors we throw are fatal. 611 612 613 let isFatal = error instanceof Error; // Specific API errors that are fatal. 614 615 const fatalAPIErrors = { 616 folder_exists: (0,external_wp_i18n_namespaceObject.__)('This block is already installed. Try reloading the page.'), 617 unable_to_connect_to_filesystem: (0,external_wp_i18n_namespaceObject.__)('Error installing block. You can reload the page and try again.') 618 }; 619 620 if (fatalAPIErrors[error.code]) { 621 isFatal = true; 622 message = fatalAPIErrors[error.code]; 623 } 624 625 dispatch.setErrorNotice(id, message, isFatal); 626 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(message, { 627 speak: true, 628 isDismissible: true 629 }); 630 } 631 632 dispatch.setIsInstalling(id, false); 633 return success; 634 }; 635 /** 636 * Action triggered to uninstall a block plugin. 637 * 638 * @param {Object} block The blockType object. 639 */ 640 641 const uninstallBlockType = block => async _ref2 => { 642 let { 643 registry, 644 dispatch 645 } = _ref2; 646 647 try { 648 const url = getPluginUrl(block); 649 await external_wp_apiFetch_default()({ 650 method: 'PUT', 651 url, 652 data: { 653 status: 'inactive' 654 } 655 }); 656 await external_wp_apiFetch_default()({ 657 method: 'DELETE', 658 url 659 }); 660 dispatch.removeInstalledBlockType(block); 661 } catch (error) { 662 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.')); 663 } 664 }; 665 /** 666 * Returns an action object used to add a block type to the "newly installed" 667 * tracking list. 668 * 669 * @param {Object} item The block item with the block id and name. 670 * 671 * @return {Object} Action object. 672 */ 673 674 function addInstalledBlockType(item) { 675 return { 676 type: 'ADD_INSTALLED_BLOCK_TYPE', 677 item 678 }; 679 } 680 /** 681 * Returns an action object used to remove a block type from the "newly installed" 682 * tracking list. 683 * 684 * @param {string} item The block item with the block id and name. 685 * 686 * @return {Object} Action object. 687 */ 688 689 function removeInstalledBlockType(item) { 690 return { 691 type: 'REMOVE_INSTALLED_BLOCK_TYPE', 692 item 693 }; 694 } 695 /** 696 * Returns an action object used to indicate install in progress. 697 * 698 * @param {string} blockId 699 * @param {boolean} isInstalling 700 * 701 * @return {Object} Action object. 702 */ 703 704 function setIsInstalling(blockId, isInstalling) { 705 return { 706 type: 'SET_INSTALLING_BLOCK', 707 blockId, 708 isInstalling 709 }; 710 } 711 /** 712 * Sets an error notice to be displayed to the user for a given block. 713 * 714 * @param {string} blockId The ID of the block plugin. eg: my-block 715 * @param {string} message The message shown in the notice. 716 * @param {boolean} isFatal Whether the user can recover from the error. 717 * 718 * @return {Object} Action object. 719 */ 720 721 function setErrorNotice(blockId, message) { 722 let isFatal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 723 return { 724 type: 'SET_ERROR_NOTICE', 725 blockId, 726 message, 727 isFatal 728 }; 729 } 730 /** 731 * Sets the error notice to empty for specific block. 732 * 733 * @param {string} blockId The ID of the block plugin. eg: my-block 734 * 735 * @return {Object} Action object. 736 */ 737 738 function clearErrorNotice(blockId) { 739 return { 740 type: 'CLEAR_ERROR_NOTICE', 741 blockId 742 }; 743 } 744 745 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js 746 /** 747 * External dependencies 748 */ 749 750 /** 751 * WordPress dependencies 752 */ 753 754 755 /** 756 * Internal dependencies 757 */ 758 759 760 const resolvers_getDownloadableBlocks = filterValue => async _ref => { 761 let { 762 dispatch 763 } = _ref; 764 765 if (!filterValue) { 766 return; 767 } 768 769 try { 770 dispatch(fetchDownloadableBlocks(filterValue)); 771 const results = await external_wp_apiFetch_default()({ 772 path: `wp/v2/block-directory/search?term=$filterValue}` 773 }); 774 const blocks = results.map(result => (0,external_lodash_namespaceObject.mapKeys)(result, (value, key) => (0,external_lodash_namespaceObject.camelCase)(key))); 775 dispatch(receiveDownloadableBlocks(blocks, filterValue)); 776 } catch {} 777 }; 778 779 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/index.js 780 /** 781 * WordPress dependencies 782 */ 783 784 /** 785 * Internal dependencies 786 */ 787 788 789 790 791 792 /** 793 * Module Constants 794 */ 795 796 const STORE_NAME = 'core/block-directory'; 797 /** 798 * Block editor data store configuration. 799 * 800 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore 801 * 802 * @type {Object} 803 */ 804 805 const storeConfig = { 806 reducer: reducer, 807 selectors: selectors_namespaceObject, 808 actions: actions_namespaceObject, 809 resolvers: resolvers_namespaceObject 810 }; 811 /** 812 * Store definition for the block directory namespace. 813 * 814 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 815 * 816 * @type {Object} 817 */ 818 819 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); 820 (0,external_wp_data_namespaceObject.register)(store); 821 822 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/auto-block-uninstaller/index.js 823 /** 824 * WordPress dependencies 825 */ 826 827 828 829 830 /** 831 * Internal dependencies 832 */ 833 834 835 function AutoBlockUninstaller() { 836 const { 837 uninstallBlockType 838 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 839 const shouldRemoveBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => { 840 const { 841 isAutosavingPost, 842 isSavingPost 843 } = select(external_wp_editor_namespaceObject.store); 844 return isSavingPost() && !isAutosavingPost(); 845 }, []); 846 const unusedBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getUnusedBlockTypes(), []); 847 (0,external_wp_element_namespaceObject.useEffect)(() => { 848 if (shouldRemoveBlockTypes && unusedBlockTypes.length) { 849 unusedBlockTypes.forEach(blockType => { 850 uninstallBlockType(blockType); 851 (0,external_wp_blocks_namespaceObject.unregisterBlockType)(blockType.name); 852 }); 853 } 854 }, [shouldRemoveBlockTypes]); 855 return null; 856 } 857 858 ;// CONCATENATED MODULE: external ["wp","components"] 859 var external_wp_components_namespaceObject = window["wp"]["components"]; 860 ;// CONCATENATED MODULE: external ["wp","compose"] 861 var external_wp_compose_namespaceObject = window["wp"]["compose"]; 862 ;// CONCATENATED MODULE: external ["wp","coreData"] 863 var external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 864 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js 865 function _extends() { 866 _extends = Object.assign || function (target) { 867 for (var i = 1; i < arguments.length; i++) { 868 var source = arguments[i]; 869 870 for (var key in source) { 871 if (Object.prototype.hasOwnProperty.call(source, key)) { 872 target[key] = source[key]; 873 } 874 } 875 } 876 877 return target; 878 }; 879 880 return _extends.apply(this, arguments); 881 } 882 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] 883 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; 884 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js 885 /** 886 * WordPress dependencies 887 */ 888 889 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ 890 891 /** 892 * Return an SVG icon. 893 * 894 * @param {IconProps} props icon is the SVG component to render 895 * size is a number specifiying the icon size in pixels 896 * Other props will be passed to wrapped SVG component 897 * 898 * @return {JSX.Element} Icon component 899 */ 900 901 function Icon(_ref) { 902 let { 903 icon, 904 size = 24, 905 ...props 906 } = _ref; 907 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { 908 width: size, 909 height: size, 910 ...props 911 }); 912 } 913 914 /* harmony default export */ var icon = (Icon); 915 916 ;// CONCATENATED MODULE: external ["wp","primitives"] 917 var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 918 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js 919 920 921 /** 922 * WordPress dependencies 923 */ 924 925 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 926 xmlns: "http://www.w3.org/2000/svg", 927 viewBox: "0 0 24 24" 928 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 929 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" 930 })); 931 /* harmony default export */ var star_filled = (starFilled); 932 933 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-half.js 934 935 936 /** 937 * WordPress dependencies 938 */ 939 940 const starHalf = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 941 xmlns: "http://www.w3.org/2000/svg", 942 viewBox: "0 0 24 24" 943 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 944 d: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z" 945 })); 946 /* harmony default export */ var star_half = (starHalf); 947 948 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js 949 950 951 /** 952 * WordPress dependencies 953 */ 954 955 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 956 xmlns: "http://www.w3.org/2000/svg", 957 viewBox: "0 0 24 24" 958 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 959 fillRule: "evenodd", 960 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z", 961 clipRule: "evenodd" 962 })); 963 /* harmony default export */ var star_empty = (starEmpty); 964 965 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/stars.js 966 967 968 /** 969 * External dependencies 970 */ 971 972 /** 973 * WordPress dependencies 974 */ 975 976 977 978 979 function Stars(_ref) { 980 let { 981 rating 982 } = _ref; 983 const stars = Math.round(rating / 0.5) * 0.5; 984 const fullStarCount = Math.floor(rating); 985 const halfStarCount = Math.ceil(rating - fullStarCount); 986 const emptyStarCount = 5 - (fullStarCount + halfStarCount); 987 return (0,external_wp_element_namespaceObject.createElement)("span", { 988 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( 989 /* translators: %s: number of stars. */ 990 (0,external_wp_i18n_namespaceObject.__)('%s out of 5 stars'), stars) 991 }, (0,external_lodash_namespaceObject.times)(fullStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { 992 key: `full_stars_$i}`, 993 className: "block-directory-block-ratings__star-full", 994 icon: star_filled, 995 size: 16 996 })), (0,external_lodash_namespaceObject.times)(halfStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { 997 key: `half_stars_$i}`, 998 className: "block-directory-block-ratings__star-half-full", 999 icon: star_half, 1000 size: 16 1001 })), (0,external_lodash_namespaceObject.times)(emptyStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { 1002 key: `empty_stars_$i}`, 1003 className: "block-directory-block-ratings__star-empty", 1004 icon: star_empty, 1005 size: 16 1006 }))); 1007 } 1008 1009 /* harmony default export */ var stars = (Stars); 1010 1011 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/index.js 1012 1013 1014 /** 1015 * Internal dependencies 1016 */ 1017 1018 const BlockRatings = _ref => { 1019 let { 1020 rating 1021 } = _ref; 1022 return (0,external_wp_element_namespaceObject.createElement)("span", { 1023 className: "block-directory-block-ratings" 1024 }, (0,external_wp_element_namespaceObject.createElement)(stars, { 1025 rating: rating 1026 })); 1027 }; 1028 /* harmony default export */ var block_ratings = (BlockRatings); 1029 1030 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-icon/index.js 1031 1032 1033 /** 1034 * WordPress dependencies 1035 */ 1036 1037 1038 function DownloadableBlockIcon(_ref) { 1039 let { 1040 icon 1041 } = _ref; 1042 const className = 'block-directory-downloadable-block-icon'; 1043 return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? (0,external_wp_element_namespaceObject.createElement)("img", { 1044 className: className, 1045 src: icon, 1046 alt: "" 1047 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { 1048 className: className, 1049 icon: icon, 1050 showColors: true 1051 }); 1052 } 1053 1054 /* harmony default export */ var downloadable_block_icon = (DownloadableBlockIcon); 1055 1056 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-notice/index.js 1057 1058 1059 /** 1060 * WordPress dependencies 1061 */ 1062 1063 1064 /** 1065 * Internal dependencies 1066 */ 1067 1068 1069 const DownloadableBlockNotice = _ref => { 1070 let { 1071 block 1072 } = _ref; 1073 const errorNotice = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getErrorNoticeForBlock(block.id), [block]); 1074 1075 if (!errorNotice) { 1076 return null; 1077 } 1078 1079 return (0,external_wp_element_namespaceObject.createElement)("div", { 1080 className: "block-directory-downloadable-block-notice" 1081 }, (0,external_wp_element_namespaceObject.createElement)("div", { 1082 className: "block-directory-downloadable-block-notice__content" 1083 }, errorNotice.message, errorNotice.isFatal ? ' ' + (0,external_wp_i18n_namespaceObject.__)('Try reloading the page.') : null)); 1084 }; 1085 /* harmony default export */ var downloadable_block_notice = (DownloadableBlockNotice); 1086 1087 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-list-item/index.js 1088 1089 1090 1091 /** 1092 * WordPress dependencies 1093 */ 1094 1095 1096 1097 1098 1099 1100 /** 1101 * Internal dependencies 1102 */ 1103 1104 1105 1106 1107 // Return the appropriate block item label, given the block data and status. 1108 1109 function getDownloadableBlockLabel(_ref, _ref2) { 1110 let { 1111 title, 1112 rating, 1113 ratingCount 1114 } = _ref; 1115 let { 1116 hasNotice, 1117 isInstalled, 1118 isInstalling 1119 } = _ref2; 1120 const stars = Math.round(rating / 0.5) * 0.5; 1121 1122 if (!isInstalled && hasNotice) { 1123 /* translators: %1$s: block title */ 1124 return (0,external_wp_i18n_namespaceObject.sprintf)('Retry installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); 1125 } 1126 1127 if (isInstalled) { 1128 /* translators: %1$s: block title */ 1129 return (0,external_wp_i18n_namespaceObject.sprintf)('Add %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); 1130 } 1131 1132 if (isInstalling) { 1133 /* translators: %1$s: block title */ 1134 return (0,external_wp_i18n_namespaceObject.sprintf)('Installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); 1135 } // No ratings yet, just use the title. 1136 1137 1138 if (ratingCount < 1) { 1139 /* translators: %1$s: block title */ 1140 return (0,external_wp_i18n_namespaceObject.sprintf)('Install %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); 1141 } 1142 1143 return (0,external_wp_i18n_namespaceObject.sprintf)( 1144 /* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */ 1145 (0,external_wp_i18n_namespaceObject._n)('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), stars, ratingCount); 1146 } 1147 1148 function DownloadableBlockListItem(_ref3) { 1149 let { 1150 composite, 1151 item, 1152 onClick 1153 } = _ref3; 1154 const { 1155 author, 1156 description, 1157 icon, 1158 rating, 1159 title 1160 } = item; // getBlockType returns a block object if this block exists, or null if not. 1161 1162 const isInstalled = !!(0,external_wp_blocks_namespaceObject.getBlockType)(item.name); 1163 const { 1164 hasNotice, 1165 isInstalling, 1166 isInstallable 1167 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 1168 const { 1169 getErrorNoticeForBlock, 1170 isInstalling: isBlockInstalling 1171 } = select(store); 1172 const notice = getErrorNoticeForBlock(item.id); 1173 const hasFatal = notice && notice.isFatal; 1174 return { 1175 hasNotice: !!notice, 1176 isInstalling: isBlockInstalling(item.id), 1177 isInstallable: !hasFatal 1178 }; 1179 }, [item]); 1180 let statusText = ''; 1181 1182 if (isInstalled) { 1183 statusText = (0,external_wp_i18n_namespaceObject.__)('Installed!'); 1184 } else if (isInstalling) { 1185 statusText = (0,external_wp_i18n_namespaceObject.__)('Installing…'); 1186 } 1187 1188 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ 1189 __experimentalIsFocusable: true, 1190 role: "option", 1191 as: external_wp_components_namespaceObject.Button 1192 }, composite, { 1193 className: "block-directory-downloadable-block-list-item", 1194 onClick: event => { 1195 event.preventDefault(); 1196 onClick(); 1197 }, 1198 isBusy: isInstalling, 1199 disabled: isInstalling || !isInstallable, 1200 label: getDownloadableBlockLabel(item, { 1201 hasNotice, 1202 isInstalled, 1203 isInstalling 1204 }), 1205 showTooltip: true, 1206 tooltipPosition: "top center" 1207 }), (0,external_wp_element_namespaceObject.createElement)("div", { 1208 className: "block-directory-downloadable-block-list-item__icon" 1209 }, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, { 1210 icon: icon, 1211 title: title 1212 }), isInstalling ? (0,external_wp_element_namespaceObject.createElement)("span", { 1213 className: "block-directory-downloadable-block-list-item__spinner" 1214 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)) : (0,external_wp_element_namespaceObject.createElement)(block_ratings, { 1215 rating: rating 1216 })), (0,external_wp_element_namespaceObject.createElement)("span", { 1217 className: "block-directory-downloadable-block-list-item__details" 1218 }, (0,external_wp_element_namespaceObject.createElement)("span", { 1219 className: "block-directory-downloadable-block-list-item__title" 1220 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( 1221 /* translators: %1$s: block title, %2$s: author name. */ 1222 (0,external_wp_i18n_namespaceObject.__)('%1$s <span>by %2$s</span>'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), author), { 1223 span: (0,external_wp_element_namespaceObject.createElement)("span", { 1224 className: "block-directory-downloadable-block-list-item__author" 1225 }) 1226 })), hasNotice ? (0,external_wp_element_namespaceObject.createElement)(downloadable_block_notice, { 1227 block: item 1228 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", { 1229 className: "block-directory-downloadable-block-list-item__desc" 1230 }, !!statusText ? statusText : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description)), isInstallable && !(isInstalled || isInstalling) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Install block'))))); 1231 } 1232 1233 /* harmony default export */ var downloadable_block_list_item = (DownloadableBlockListItem); 1234 1235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-list/index.js 1236 1237 1238 1239 /** 1240 * External dependencies 1241 */ 1242 1243 /** 1244 * WordPress dependencies 1245 */ 1246 1247 1248 1249 1250 1251 /** 1252 * Internal dependencies 1253 */ 1254 1255 1256 1257 1258 function DownloadableBlocksList(_ref) { 1259 let { 1260 items, 1261 onHover = external_lodash_namespaceObject.noop, 1262 onSelect 1263 } = _ref; 1264 const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)(); 1265 const { 1266 installBlockType 1267 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 1268 1269 if (!items.length) { 1270 return null; 1271 } 1272 1273 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, { 1274 role: "listbox", 1275 className: "block-directory-downloadable-blocks-list", 1276 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks available for install') 1277 }), items.map(item => { 1278 return (0,external_wp_element_namespaceObject.createElement)(downloadable_block_list_item, { 1279 key: item.id, 1280 composite: composite, 1281 onClick: () => { 1282 // Check if the block is registered (`getBlockType` 1283 // will return an object). If so, insert the block. 1284 // This prevents installing existing plugins. 1285 if ((0,external_wp_blocks_namespaceObject.getBlockType)(item.name)) { 1286 onSelect(item); 1287 } else { 1288 installBlockType(item).then(success => { 1289 if (success) { 1290 onSelect(item); 1291 } 1292 }); 1293 } 1294 1295 onHover(null); 1296 }, 1297 onHover: onHover, 1298 item: item 1299 }); 1300 })); 1301 } 1302 1303 /* harmony default export */ var downloadable_blocks_list = (DownloadableBlocksList); 1304 1305 ;// CONCATENATED MODULE: external ["wp","a11y"] 1306 var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 1307 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.js 1308 1309 1310 /** 1311 * WordPress dependencies 1312 */ 1313 1314 1315 1316 1317 function DownloadableBlocksInserterPanel(_ref) { 1318 let { 1319 children, 1320 downloadableItems, 1321 hasLocalBlocks 1322 } = _ref; 1323 const count = downloadableItems.length; 1324 (0,external_wp_element_namespaceObject.useEffect)(() => { 1325 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( 1326 /* translators: %d: number of available blocks. */ 1327 (0,external_wp_i18n_namespaceObject._n)('%d additional block is available to install.', '%d additional blocks are available to install.', count), count)); 1328 }, [count]); 1329 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)("p", { 1330 className: "block-directory-downloadable-blocks-panel__no-local" 1331 }, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", { 1332 className: "block-editor-inserter__quick-inserter-separator" 1333 }), (0,external_wp_element_namespaceObject.createElement)("div", { 1334 className: "block-directory-downloadable-blocks-panel" 1335 }, (0,external_wp_element_namespaceObject.createElement)("div", { 1336 className: "block-directory-downloadable-blocks-panel__header" 1337 }, (0,external_wp_element_namespaceObject.createElement)("h2", { 1338 className: "block-directory-downloadable-blocks-panel__title" 1339 }, (0,external_wp_i18n_namespaceObject.__)('Available to install')), (0,external_wp_element_namespaceObject.createElement)("p", { 1340 className: "block-directory-downloadable-blocks-panel__description" 1341 }, (0,external_wp_i18n_namespaceObject.__)('Select a block to install and add it to your post.'))), children)); 1342 } 1343 1344 /* harmony default export */ var inserter_panel = (DownloadableBlocksInserterPanel); 1345 1346 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js 1347 1348 1349 /** 1350 * WordPress dependencies 1351 */ 1352 1353 const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1354 xmlns: "http://www.w3.org/2000/svg", 1355 viewBox: "0 0 24 24" 1356 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1357 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" 1358 })); 1359 /* harmony default export */ var block_default = (blockDefault); 1360 1361 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/no-results.js 1362 1363 1364 /** 1365 * WordPress dependencies 1366 */ 1367 1368 1369 1370 function DownloadableBlocksNoResults() { 1371 return (0,external_wp_element_namespaceObject.createElement)("div", { 1372 className: "block-editor-inserter__no-results" 1373 }, (0,external_wp_element_namespaceObject.createElement)(icon, { 1374 className: "block-editor-inserter__no-results-icon", 1375 icon: block_default 1376 }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.'))); 1377 } 1378 1379 /* harmony default export */ var no_results = (DownloadableBlocksNoResults); 1380 1381 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/index.js 1382 1383 1384 /** 1385 * WordPress dependencies 1386 */ 1387 1388 1389 1390 1391 1392 1393 /** 1394 * Internal dependencies 1395 */ 1396 1397 1398 1399 1400 1401 1402 function DownloadableBlocksPanel(_ref) { 1403 let { 1404 downloadableItems, 1405 onSelect, 1406 onHover, 1407 hasLocalBlocks, 1408 hasPermission, 1409 isLoading, 1410 isTyping 1411 } = _ref; 1412 1413 if (typeof hasPermission === 'undefined' || isLoading || isTyping) { 1414 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, hasPermission && !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", { 1415 className: "block-directory-downloadable-blocks-panel__no-local" 1416 }, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", { 1417 className: "block-editor-inserter__quick-inserter-separator" 1418 })), (0,external_wp_element_namespaceObject.createElement)("div", { 1419 className: "block-directory-downloadable-blocks-panel has-blocks-loading" 1420 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null))); 1421 } 1422 1423 if (false === hasPermission) { 1424 if (!hasLocalBlocks) { 1425 return (0,external_wp_element_namespaceObject.createElement)(no_results, null); 1426 } 1427 1428 return null; 1429 } 1430 1431 return !!downloadableItems.length ? (0,external_wp_element_namespaceObject.createElement)(inserter_panel, { 1432 downloadableItems: downloadableItems, 1433 hasLocalBlocks: hasLocalBlocks 1434 }, (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_list, { 1435 items: downloadableItems, 1436 onSelect: onSelect, 1437 onHover: onHover 1438 })) : !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(no_results, null); 1439 } 1440 1441 /* harmony default export */ var downloadable_blocks_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { 1442 let { 1443 filterValue, 1444 rootClientId = null 1445 } = _ref2; 1446 const { 1447 getDownloadableBlocks, 1448 isRequestingDownloadableBlocks 1449 } = select(store); 1450 const { 1451 canInsertBlockType 1452 } = select(external_wp_blockEditor_namespaceObject.store); 1453 const hasPermission = select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search'); 1454 1455 function getInstallableBlocks(term) { 1456 return getDownloadableBlocks(term).filter(block => canInsertBlockType(block, rootClientId, true)); 1457 } 1458 1459 const downloadableItems = hasPermission ? getInstallableBlocks(filterValue) : []; 1460 const isLoading = isRequestingDownloadableBlocks(filterValue); 1461 return { 1462 downloadableItems, 1463 hasPermission, 1464 isLoading 1465 }; 1466 })])(DownloadableBlocksPanel)); 1467 1468 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js 1469 1470 1471 /** 1472 * External dependencies 1473 */ 1474 1475 /** 1476 * WordPress dependencies 1477 */ 1478 1479 1480 1481 /** 1482 * Internal dependencies 1483 */ 1484 1485 1486 1487 function InserterMenuDownloadableBlocksPanel() { 1488 const [debouncedFilterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); 1489 const debouncedSetFilterValue = (0,external_lodash_namespaceObject.debounce)(setFilterValue, 400); 1490 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableInserterMenuExtension, null, _ref => { 1491 let { 1492 onSelect, 1493 onHover, 1494 filterValue, 1495 hasItems, 1496 rootClientId 1497 } = _ref; 1498 1499 if (debouncedFilterValue !== filterValue) { 1500 debouncedSetFilterValue(filterValue); 1501 } 1502 1503 if (!debouncedFilterValue) { 1504 return null; 1505 } 1506 1507 return (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_panel, { 1508 onSelect: onSelect, 1509 onHover: onHover, 1510 rootClientId: rootClientId, 1511 filterValue: debouncedFilterValue, 1512 hasLocalBlocks: hasItems, 1513 isTyping: filterValue !== debouncedFilterValue 1514 }); 1515 }); 1516 } 1517 1518 /* harmony default export */ var inserter_menu_downloadable_blocks_panel = (InserterMenuDownloadableBlocksPanel); 1519 1520 ;// CONCATENATED MODULE: external ["wp","editPost"] 1521 var external_wp_editPost_namespaceObject = window["wp"]["editPost"]; 1522 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/compact-list/index.js 1523 1524 1525 /** 1526 * WordPress dependencies 1527 */ 1528 1529 /** 1530 * Internal dependencies 1531 */ 1532 1533 1534 function CompactList(_ref) { 1535 let { 1536 items 1537 } = _ref; 1538 1539 if (!items.length) { 1540 return null; 1541 } 1542 1543 return (0,external_wp_element_namespaceObject.createElement)("ul", { 1544 className: "block-directory-compact-list" 1545 }, items.map(_ref2 => { 1546 let { 1547 icon, 1548 id, 1549 title, 1550 author 1551 } = _ref2; 1552 return (0,external_wp_element_namespaceObject.createElement)("li", { 1553 key: id, 1554 className: "block-directory-compact-list__item" 1555 }, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, { 1556 icon: icon, 1557 title: title 1558 }), (0,external_wp_element_namespaceObject.createElement)("div", { 1559 className: "block-directory-compact-list__item-details" 1560 }, (0,external_wp_element_namespaceObject.createElement)("div", { 1561 className: "block-directory-compact-list__item-title" 1562 }, title), (0,external_wp_element_namespaceObject.createElement)("div", { 1563 className: "block-directory-compact-list__item-author" 1564 }, (0,external_wp_i18n_namespaceObject.sprintf)( 1565 /* translators: %s: Name of the block author. */ 1566 (0,external_wp_i18n_namespaceObject.__)('By %s'), author)))); 1567 })); 1568 } 1569 1570 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.js 1571 1572 1573 /** 1574 * WordPress dependencies 1575 */ 1576 1577 1578 1579 1580 /** 1581 * Internal dependencies 1582 */ 1583 1584 1585 1586 function InstalledBlocksPrePublishPanel() { 1587 const newBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getNewBlockTypes(), []); 1588 1589 if (!newBlockTypes.length) { 1590 return null; 1591 } 1592 1593 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editPost_namespaceObject.PluginPrePublishPanel, { 1594 icon: block_default, 1595 title: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: number of blocks (number). 1596 (0,external_wp_i18n_namespaceObject._n)('Added: %d block', 'Added: %d blocks', newBlockTypes.length), newBlockTypes.length), 1597 initialOpen: true 1598 }, (0,external_wp_element_namespaceObject.createElement)("p", { 1599 className: "installed-blocks-pre-publish-panel__copy" 1600 }, (0,external_wp_i18n_namespaceObject._n)('The following block has been added to your site.', 'The following blocks have been added to your site.', newBlockTypes.length)), (0,external_wp_element_namespaceObject.createElement)(CompactList, { 1601 items: newBlockTypes 1602 })); 1603 } 1604 1605 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/install-button.js 1606 1607 1608 /** 1609 * WordPress dependencies 1610 */ 1611 1612 1613 1614 1615 1616 /** 1617 * Internal dependencies 1618 */ 1619 1620 1621 function InstallButton(_ref) { 1622 let { 1623 attributes, 1624 block, 1625 clientId 1626 } = _ref; 1627 const isInstallingBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isInstalling(block.id), [block.id]); 1628 const { 1629 installBlockType 1630 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 1631 const { 1632 replaceBlock 1633 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 1634 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 1635 onClick: () => installBlockType(block).then(success => { 1636 if (success) { 1637 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name); 1638 const [originalBlock] = (0,external_wp_blocks_namespaceObject.parse)(attributes.originalContent); 1639 1640 if (originalBlock && blockType) { 1641 replaceBlock(clientId, (0,external_wp_blocks_namespaceObject.createBlock)(blockType.name, originalBlock.attributes, originalBlock.innerBlocks)); 1642 } 1643 } 1644 }), 1645 disabled: isInstallingBlock, 1646 isBusy: isInstallingBlock, 1647 variant: "primary" 1648 }, (0,external_wp_i18n_namespaceObject.sprintf)( 1649 /* translators: %s: block name */ 1650 (0,external_wp_i18n_namespaceObject.__)('Install %s'), block.title)); 1651 } 1652 1653 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/index.js 1654 1655 1656 1657 /** 1658 * WordPress dependencies 1659 */ 1660 1661 1662 1663 1664 1665 1666 1667 /** 1668 * Internal dependencies 1669 */ 1670 1671 1672 1673 1674 const getInstallMissing = OriginalComponent => props => { 1675 const { 1676 originalName 1677 } = props.attributes; // Disable reason: This is a valid component, but it's mistaken for a callback. 1678 // eslint-disable-next-line react-hooks/rules-of-hooks 1679 1680 const { 1681 block, 1682 hasPermission 1683 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 1684 const { 1685 getDownloadableBlocks 1686 } = select(store); 1687 const blocks = getDownloadableBlocks('block:' + originalName).filter(_ref => { 1688 let { 1689 name 1690 } = _ref; 1691 return originalName === name; 1692 }); 1693 return { 1694 hasPermission: select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search'), 1695 block: blocks.length && blocks[0] 1696 }; 1697 }, [originalName]); // The user can't install blocks, or the block isn't available for download. 1698 1699 if (!hasPermission || !block) { 1700 return (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, props); 1701 } 1702 1703 return (0,external_wp_element_namespaceObject.createElement)(ModifiedWarning, _extends({}, props, { 1704 originalBlock: block 1705 })); 1706 }; 1707 1708 const ModifiedWarning = _ref2 => { 1709 let { 1710 originalBlock, 1711 ...props 1712 } = _ref2; 1713 const { 1714 originalName, 1715 originalUndelimitedContent 1716 } = props.attributes; 1717 const { 1718 replaceBlock 1719 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 1720 1721 const convertToHTML = () => { 1722 replaceBlock(props.clientId, (0,external_wp_blocks_namespaceObject.createBlock)('core/html', { 1723 content: originalUndelimitedContent 1724 })); 1725 }; 1726 1727 const hasContent = !!originalUndelimitedContent; 1728 const hasHTMLBlock = (0,external_wp_blocks_namespaceObject.getBlockType)('core/html'); 1729 let messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( 1730 /* translators: %s: block name */ 1731 (0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName); 1732 const actions = [(0,external_wp_element_namespaceObject.createElement)(InstallButton, { 1733 key: "install", 1734 block: originalBlock, 1735 attributes: props.attributes, 1736 clientId: props.clientId 1737 })]; 1738 1739 if (hasContent && hasHTMLBlock) { 1740 messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( 1741 /* translators: %s: block name */ 1742 (0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName); 1743 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 1744 key: "convert", 1745 onClick: convertToHTML, 1746 variant: "link" 1747 }, (0,external_wp_i18n_namespaceObject.__)('Keep as HTML'))); 1748 } 1749 1750 return (0,external_wp_element_namespaceObject.createElement)("div", (0,external_wp_blockEditor_namespaceObject.useBlockProps)(), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, { 1751 actions: actions 1752 }, messageHTML), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, originalUndelimitedContent)); 1753 }; 1754 1755 /* harmony default export */ var get_install_missing = (getInstallMissing); 1756 1757 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/index.js 1758 1759 1760 /** 1761 * WordPress dependencies 1762 */ 1763 1764 1765 /** 1766 * Internal dependencies 1767 */ 1768 1769 1770 1771 1772 1773 (0,external_wp_plugins_namespaceObject.registerPlugin)('block-directory', { 1774 render() { 1775 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AutoBlockUninstaller, null), (0,external_wp_element_namespaceObject.createElement)(inserter_menu_downloadable_blocks_panel, null), (0,external_wp_element_namespaceObject.createElement)(InstalledBlocksPrePublishPanel, null)); 1776 } 1777 1778 }); 1779 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'block-directory/fallback', (settings, name) => { 1780 if (name !== 'core/missing') { 1781 return settings; 1782 } 1783 1784 settings.edit = get_install_missing(settings.edit); 1785 return settings; 1786 }); 1787 1788 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/index.js 1789 /** 1790 * Internal dependencies 1791 */ 1792 1793 1794 1795 (window.wp = window.wp || {}).blockDirectory = __webpack_exports__; 1796 /******/ })() 1797 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |