[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ var __webpack_modules__ = ({ 4 5 /***/ 7734: 6 /***/ ((module) => { 7 8 9 10 // do not edit .js files directly - edit src/index.jst 11 12 13 var envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; 14 15 16 module.exports = function equal(a, b) { 17 if (a === b) return true; 18 19 if (a && b && typeof a == 'object' && typeof b == 'object') { 20 if (a.constructor !== b.constructor) return false; 21 22 var length, i, keys; 23 if (Array.isArray(a)) { 24 length = a.length; 25 if (length != b.length) return false; 26 for (i = length; i-- !== 0;) 27 if (!equal(a[i], b[i])) return false; 28 return true; 29 } 30 31 32 if ((a instanceof Map) && (b instanceof Map)) { 33 if (a.size !== b.size) return false; 34 for (i of a.entries()) 35 if (!b.has(i[0])) return false; 36 for (i of a.entries()) 37 if (!equal(i[1], b.get(i[0]))) return false; 38 return true; 39 } 40 41 if ((a instanceof Set) && (b instanceof Set)) { 42 if (a.size !== b.size) return false; 43 for (i of a.entries()) 44 if (!b.has(i[0])) return false; 45 return true; 46 } 47 48 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { 49 length = a.length; 50 if (length != b.length) return false; 51 for (i = length; i-- !== 0;) 52 if (a[i] !== b[i]) return false; 53 return true; 54 } 55 56 57 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; 58 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); 59 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); 60 61 keys = Object.keys(a); 62 length = keys.length; 63 if (length !== Object.keys(b).length) return false; 64 65 for (i = length; i-- !== 0;) 66 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; 67 68 for (i = length; i-- !== 0;) { 69 var key = keys[i]; 70 71 if (!equal(a[key], b[key])) return false; 72 } 73 74 return true; 75 } 76 77 // true if both NaN, false otherwise 78 return a!==a && b!==b; 79 }; 80 81 82 /***/ }) 83 84 /******/ }); 85 /************************************************************************/ 86 /******/ // The module cache 87 /******/ var __webpack_module_cache__ = {}; 88 /******/ 89 /******/ // The require function 90 /******/ function __webpack_require__(moduleId) { 91 /******/ // Check if module is in cache 92 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 93 /******/ if (cachedModule !== undefined) { 94 /******/ return cachedModule.exports; 95 /******/ } 96 /******/ // Create a new module (and put it into the cache) 97 /******/ var module = __webpack_module_cache__[moduleId] = { 98 /******/ // no module.id needed 99 /******/ // no module.loaded needed 100 /******/ exports: {} 101 /******/ }; 102 /******/ 103 /******/ // Execute the module function 104 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 105 /******/ 106 /******/ // Return the exports of the module 107 /******/ return module.exports; 108 /******/ } 109 /******/ 110 /************************************************************************/ 111 /******/ /* webpack/runtime/compat get default export */ 112 /******/ (() => { 113 /******/ // getDefaultExport function for compatibility with non-harmony modules 114 /******/ __webpack_require__.n = (module) => { 115 /******/ var getter = module && module.__esModule ? 116 /******/ () => (module['default']) : 117 /******/ () => (module); 118 /******/ __webpack_require__.d(getter, { a: getter }); 119 /******/ return getter; 120 /******/ }; 121 /******/ })(); 122 /******/ 123 /******/ /* webpack/runtime/define property getters */ 124 /******/ (() => { 125 /******/ // define getter functions for harmony exports 126 /******/ __webpack_require__.d = (exports, definition) => { 127 /******/ for(var key in definition) { 128 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 129 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 130 /******/ } 131 /******/ } 132 /******/ }; 133 /******/ })(); 134 /******/ 135 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 136 /******/ (() => { 137 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 138 /******/ })(); 139 /******/ 140 /******/ /* webpack/runtime/make namespace object */ 141 /******/ (() => { 142 /******/ // define __esModule on exports 143 /******/ __webpack_require__.r = (exports) => { 144 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 145 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 146 /******/ } 147 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 148 /******/ }; 149 /******/ })(); 150 /******/ 151 /************************************************************************/ 152 var __webpack_exports__ = {}; 153 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 154 (() => { 155 // ESM COMPAT FLAG 156 __webpack_require__.r(__webpack_exports__); 157 158 // EXPORTS 159 __webpack_require__.d(__webpack_exports__, { 160 initialize: () => (/* binding */ initialize), 161 store: () => (/* reexport */ store) 162 }); 163 164 // NAMESPACE OBJECT: ./node_modules/@wordpress/customize-widgets/build-module/store/selectors.js 165 var selectors_namespaceObject = {}; 166 __webpack_require__.r(selectors_namespaceObject); 167 __webpack_require__.d(selectors_namespaceObject, { 168 __experimentalGetInsertionPoint: () => (__experimentalGetInsertionPoint), 169 isInserterOpened: () => (isInserterOpened) 170 }); 171 172 // NAMESPACE OBJECT: ./node_modules/@wordpress/customize-widgets/build-module/store/actions.js 173 var actions_namespaceObject = {}; 174 __webpack_require__.r(actions_namespaceObject); 175 __webpack_require__.d(actions_namespaceObject, { 176 setIsInserterOpened: () => (setIsInserterOpened) 177 }); 178 179 ;// CONCATENATED MODULE: external ["wp","element"] 180 const external_wp_element_namespaceObject = window["wp"]["element"]; 181 ;// CONCATENATED MODULE: external ["wp","blockLibrary"] 182 const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; 183 ;// CONCATENATED MODULE: external ["wp","widgets"] 184 const external_wp_widgets_namespaceObject = window["wp"]["widgets"]; 185 ;// CONCATENATED MODULE: external ["wp","blocks"] 186 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 187 ;// CONCATENATED MODULE: external ["wp","data"] 188 const external_wp_data_namespaceObject = window["wp"]["data"]; 189 ;// CONCATENATED MODULE: external ["wp","preferences"] 190 const external_wp_preferences_namespaceObject = window["wp"]["preferences"]; 191 ;// CONCATENATED MODULE: external ["wp","components"] 192 const external_wp_components_namespaceObject = window["wp"]["components"]; 193 ;// CONCATENATED MODULE: external ["wp","i18n"] 194 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 195 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 196 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 197 ;// CONCATENATED MODULE: external ["wp","compose"] 198 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 199 ;// CONCATENATED MODULE: external ["wp","hooks"] 200 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 201 ;// CONCATENATED MODULE: external "ReactJSXRuntime" 202 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 203 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/error-boundary/index.js 204 /** 205 * WordPress dependencies 206 */ 207 208 209 210 211 212 213 214 function CopyButton({ 215 text, 216 children 217 }) { 218 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); 219 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button 220 // TODO: Switch to `true` (40px size) if possible 221 , { 222 __next40pxDefaultSize: false, 223 variant: "secondary", 224 ref: ref, 225 children: children 226 }); 227 } 228 class ErrorBoundary extends external_wp_element_namespaceObject.Component { 229 constructor() { 230 super(...arguments); 231 this.state = { 232 error: null 233 }; 234 } 235 componentDidCatch(error) { 236 this.setState({ 237 error 238 }); 239 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error); 240 } 241 render() { 242 const { 243 error 244 } = this.state; 245 if (!error) { 246 return this.props.children; 247 } 248 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, { 249 className: "customize-widgets-error-boundary", 250 actions: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, { 251 text: error.stack, 252 children: (0,external_wp_i18n_namespaceObject.__)('Copy Error') 253 }, "copy-error")], 254 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.') 255 }); 256 } 257 } 258 259 ;// CONCATENATED MODULE: external ["wp","coreData"] 260 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 261 ;// CONCATENATED MODULE: external ["wp","mediaUtils"] 262 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; 263 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/block-inspector-button/index.js 264 /** 265 * WordPress dependencies 266 */ 267 268 269 270 271 272 273 function BlockInspectorButton({ 274 inspector, 275 closeMenu, 276 ...props 277 }) { 278 const selectedBlockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSelectedBlockClientId(), []); 279 const selectedBlock = (0,external_wp_element_namespaceObject.useMemo)(() => document.getElementById(`block-$selectedBlockClientId}`), [selectedBlockClientId]); 280 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { 281 onClick: () => { 282 // Open the inspector. 283 inspector.open({ 284 returnFocusWhenClose: selectedBlock 285 }); 286 // Then close the dropdown menu. 287 closeMenu(); 288 }, 289 ...props, 290 children: (0,external_wp_i18n_namespaceObject.__)('Show more settings') 291 }); 292 } 293 /* harmony default export */ const block_inspector_button = (BlockInspectorButton); 294 295 ;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs 296 function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx); 297 ;// CONCATENATED MODULE: external ["wp","keycodes"] 298 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 299 ;// CONCATENATED MODULE: external ["wp","primitives"] 300 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 301 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js 302 /** 303 * WordPress dependencies 304 */ 305 306 307 const undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 308 xmlns: "http://www.w3.org/2000/svg", 309 viewBox: "0 0 24 24", 310 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 311 d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" 312 }) 313 }); 314 /* harmony default export */ const library_undo = (undo); 315 316 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js 317 /** 318 * WordPress dependencies 319 */ 320 321 322 const redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 323 xmlns: "http://www.w3.org/2000/svg", 324 viewBox: "0 0 24 24", 325 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 326 d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" 327 }) 328 }); 329 /* harmony default export */ const library_redo = (redo); 330 331 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js 332 /** 333 * WordPress dependencies 334 */ 335 336 337 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 338 xmlns: "http://www.w3.org/2000/svg", 339 viewBox: "0 0 24 24", 340 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 341 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" 342 }) 343 }); 344 /* harmony default export */ const library_plus = (plus); 345 346 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js 347 /** 348 * WordPress dependencies 349 */ 350 351 352 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 353 xmlns: "http://www.w3.org/2000/svg", 354 viewBox: "0 0 24 24", 355 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 356 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" 357 }) 358 }); 359 /* harmony default export */ const close_small = (closeSmall); 360 361 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/reducer.js 362 /** 363 * WordPress dependencies 364 */ 365 366 367 /** 368 * Reducer tracking whether the inserter is open. 369 * 370 * @param {boolean|Object} state 371 * @param {Object} action 372 */ 373 function blockInserterPanel(state = false, action) { 374 switch (action.type) { 375 case 'SET_IS_INSERTER_OPENED': 376 return action.value; 377 } 378 return state; 379 } 380 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 381 blockInserterPanel 382 })); 383 384 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/selectors.js 385 const EMPTY_INSERTION_POINT = { 386 rootClientId: undefined, 387 insertionIndex: undefined 388 }; 389 390 /** 391 * Returns true if the inserter is opened. 392 * 393 * @param {Object} state Global application state. 394 * 395 * @example 396 * ```js 397 * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets'; 398 * import { __ } from '@wordpress/i18n'; 399 * import { useSelect } from '@wordpress/data'; 400 * 401 * const ExampleComponent = () => { 402 * const { isInserterOpened } = useSelect( 403 * ( select ) => select( customizeWidgetsStore ), 404 * [] 405 * ); 406 * 407 * return isInserterOpened() 408 * ? __( 'Inserter is open' ) 409 * : __( 'Inserter is closed.' ); 410 * }; 411 * ``` 412 * 413 * @return {boolean} Whether the inserter is opened. 414 */ 415 function isInserterOpened(state) { 416 return !!state.blockInserterPanel; 417 } 418 419 /** 420 * Get the insertion point for the inserter. 421 * 422 * @param {Object} state Global application state. 423 * 424 * @return {Object} The root client ID and index to insert at. 425 */ 426 function __experimentalGetInsertionPoint(state) { 427 if (typeof state.blockInserterPanel === 'boolean') { 428 return EMPTY_INSERTION_POINT; 429 } 430 return state.blockInserterPanel; 431 } 432 433 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/actions.js 434 /** 435 * Returns an action object used to open/close the inserter. 436 * 437 * @param {boolean|Object} value Whether the inserter should be 438 * opened (true) or closed (false). 439 * To specify an insertion point, 440 * use an object. 441 * @param {string} value.rootClientId The root client ID to insert at. 442 * @param {number} value.insertionIndex The index to insert at. 443 * 444 * @example 445 * ```js 446 * import { useState } from 'react'; 447 * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets'; 448 * import { __ } from '@wordpress/i18n'; 449 * import { useDispatch } from '@wordpress/data'; 450 * import { Button } from '@wordpress/components'; 451 * 452 * const ExampleComponent = () => { 453 * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore ); 454 * const [ isOpen, setIsOpen ] = useState( false ); 455 * 456 * return ( 457 * <Button 458 * onClick={ () => { 459 * setIsInserterOpened( ! isOpen ); 460 * setIsOpen( ! isOpen ); 461 * } } 462 * > 463 * { __( 'Open/close inserter' ) } 464 * </Button> 465 * ); 466 * }; 467 * ``` 468 * 469 * @return {Object} Action object. 470 */ 471 function setIsInserterOpened(value) { 472 return { 473 type: 'SET_IS_INSERTER_OPENED', 474 value 475 }; 476 } 477 478 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/constants.js 479 /** 480 * Module Constants 481 */ 482 const STORE_NAME = 'core/customize-widgets'; 483 484 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/index.js 485 /** 486 * WordPress dependencies 487 */ 488 489 490 /** 491 * Internal dependencies 492 */ 493 494 495 496 497 498 /** 499 * Block editor data store configuration. 500 * 501 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registering-a-store 502 * 503 * @type {Object} 504 */ 505 const storeConfig = { 506 reducer: reducer, 507 selectors: selectors_namespaceObject, 508 actions: actions_namespaceObject 509 }; 510 511 /** 512 * Store definition for the edit widgets namespace. 513 * 514 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 515 * 516 * @type {Object} 517 */ 518 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); 519 (0,external_wp_data_namespaceObject.register)(store); 520 521 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/inserter/index.js 522 /** 523 * WordPress dependencies 524 */ 525 526 527 528 529 530 531 532 /** 533 * Internal dependencies 534 */ 535 536 537 538 function Inserter({ 539 setIsOpened 540 }) { 541 const inserterTitleId = (0,external_wp_compose_namespaceObject.useInstanceId)(Inserter, 'customize-widget-layout__inserter-panel-title'); 542 const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).__experimentalGetInsertionPoint(), []); 543 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 544 className: "customize-widgets-layout__inserter-panel", 545 "aria-labelledby": inserterTitleId, 546 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 547 className: "customize-widgets-layout__inserter-panel-header", 548 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", { 549 id: inserterTitleId, 550 className: "customize-widgets-layout__inserter-panel-header-title", 551 children: (0,external_wp_i18n_namespaceObject.__)('Add a block') 552 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button 553 // TODO: Switch to `true` (40px size) if possible 554 , { 555 __next40pxDefaultSize: false, 556 className: "customize-widgets-layout__inserter-panel-header-close-button", 557 icon: close_small, 558 onClick: () => setIsOpened(false), 559 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Close inserter') 560 })] 561 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 562 className: "customize-widgets-layout__inserter-panel-content", 563 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, { 564 rootClientId: insertionPoint.rootClientId, 565 __experimentalInsertionIndex: insertionPoint.insertionIndex, 566 showInserterHelpPanel: true, 567 onSelect: () => setIsOpened(false) 568 }) 569 })] 570 }); 571 } 572 /* harmony default export */ const components_inserter = (Inserter); 573 574 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js 575 /** 576 * WordPress dependencies 577 */ 578 579 580 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 581 xmlns: "http://www.w3.org/2000/svg", 582 viewBox: "0 0 24 24", 583 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 584 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" 585 }) 586 }); 587 /* harmony default export */ const more_vertical = (moreVertical); 588 589 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js 590 /** 591 * WordPress dependencies 592 */ 593 594 595 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 596 xmlns: "http://www.w3.org/2000/svg", 597 viewBox: "0 0 24 24", 598 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 599 d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" 600 }) 601 }); 602 /* harmony default export */ const library_external = (external); 603 604 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] 605 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; 606 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/config.js 607 /** 608 * WordPress dependencies 609 */ 610 611 const textFormattingShortcuts = [{ 612 keyCombination: { 613 modifier: 'primary', 614 character: 'b' 615 }, 616 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.') 617 }, { 618 keyCombination: { 619 modifier: 'primary', 620 character: 'i' 621 }, 622 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.') 623 }, { 624 keyCombination: { 625 modifier: 'primary', 626 character: 'k' 627 }, 628 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.') 629 }, { 630 keyCombination: { 631 modifier: 'primaryShift', 632 character: 'k' 633 }, 634 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.') 635 }, { 636 keyCombination: { 637 character: '[[' 638 }, 639 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.') 640 }, { 641 keyCombination: { 642 modifier: 'primary', 643 character: 'u' 644 }, 645 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.') 646 }, { 647 keyCombination: { 648 modifier: 'access', 649 character: 'd' 650 }, 651 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.') 652 }, { 653 keyCombination: { 654 modifier: 'access', 655 character: 'x' 656 }, 657 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.') 658 }, { 659 keyCombination: { 660 modifier: 'access', 661 character: '0' 662 }, 663 aliases: [{ 664 modifier: 'access', 665 character: '7' 666 }], 667 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.') 668 }, { 669 keyCombination: { 670 modifier: 'access', 671 character: '1-6' 672 }, 673 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.') 674 }, { 675 keyCombination: { 676 modifier: 'primaryShift', 677 character: 'SPACE' 678 }, 679 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.') 680 }]; 681 682 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.js 683 /** 684 * WordPress dependencies 685 */ 686 687 688 689 690 691 function KeyCombination({ 692 keyCombination, 693 forceAriaLabel 694 }) { 695 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character; 696 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character; 697 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", { 698 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination", 699 "aria-label": forceAriaLabel || ariaLabel, 700 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => { 701 if (character === '+') { 702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, { 703 children: character 704 }, index); 705 } 706 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", { 707 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key", 708 children: character 709 }, index); 710 }) 711 }); 712 } 713 function Shortcut({ 714 description, 715 keyCombination, 716 aliases = [], 717 ariaLabel 718 }) { 719 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 720 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 721 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-description", 722 children: description 723 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 724 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-term", 725 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, { 726 keyCombination: keyCombination, 727 forceAriaLabel: ariaLabel 728 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, { 729 keyCombination: alias, 730 forceAriaLabel: ariaLabel 731 }, index))] 732 })] 733 }); 734 } 735 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut); 736 737 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js 738 /** 739 * WordPress dependencies 740 */ 741 742 743 744 /** 745 * Internal dependencies 746 */ 747 748 749 function DynamicShortcut({ 750 name 751 }) { 752 const { 753 keyCombination, 754 description, 755 aliases 756 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 757 const { 758 getShortcutKeyCombination, 759 getShortcutDescription, 760 getShortcutAliases 761 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 762 return { 763 keyCombination: getShortcutKeyCombination(name), 764 aliases: getShortcutAliases(name), 765 description: getShortcutDescription(name) 766 }; 767 }, [name]); 768 if (!keyCombination) { 769 return null; 770 } 771 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, { 772 keyCombination: keyCombination, 773 description: description, 774 aliases: aliases 775 }); 776 } 777 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut); 778 779 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.js 780 /** 781 * External dependencies 782 */ 783 784 785 /** 786 * WordPress dependencies 787 */ 788 789 790 791 792 793 /** 794 * Internal dependencies 795 */ 796 797 798 799 800 801 const ShortcutList = ({ 802 shortcuts 803 }) => 804 /*#__PURE__*/ 805 /* 806 * Disable reason: The `list` ARIA role is redundant but 807 * Safari+VoiceOver won't announce the list otherwise. 808 */ 809 /* eslint-disable jsx-a11y/no-redundant-roles */ 810 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", { 811 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-list", 812 role: "list", 813 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", { 814 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut", 815 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, { 816 name: shortcut 817 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, { 818 ...shortcut 819 }) 820 }, index)) 821 }) 822 /* eslint-enable jsx-a11y/no-redundant-roles */; 823 const ShortcutSection = ({ 824 title, 825 shortcuts, 826 className 827 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", { 828 className: dist_clsx('customize-widgets-keyboard-shortcut-help-modal__section', className), 829 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", { 830 className: "customize-widgets-keyboard-shortcut-help-modal__section-title", 831 children: title 832 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, { 833 shortcuts: shortcuts 834 })] 835 }); 836 const ShortcutCategorySection = ({ 837 title, 838 categoryName, 839 additionalShortcuts = [] 840 }) => { 841 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { 842 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName); 843 }, [categoryName]); 844 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, { 845 title: title, 846 shortcuts: categoryShortcuts.concat(additionalShortcuts) 847 }); 848 }; 849 function KeyboardShortcutHelpModal({ 850 isModalActive, 851 toggleModal 852 }) { 853 const { 854 registerShortcut 855 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); 856 registerShortcut({ 857 name: 'core/customize-widgets/keyboard-shortcuts', 858 category: 'main', 859 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'), 860 keyCombination: { 861 modifier: 'access', 862 character: 'h' 863 } 864 }); 865 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/keyboard-shortcuts', toggleModal); 866 if (!isModalActive) { 867 return null; 868 } 869 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, { 870 className: "customize-widgets-keyboard-shortcut-help-modal", 871 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), 872 onRequestClose: toggleModal, 873 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, { 874 className: "customize-widgets-keyboard-shortcut-help-modal__main-shortcuts", 875 shortcuts: ['core/customize-widgets/keyboard-shortcuts'] 876 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, { 877 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'), 878 categoryName: "global" 879 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, { 880 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'), 881 categoryName: "selection" 882 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, { 883 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'), 884 categoryName: "block", 885 additionalShortcuts: [{ 886 keyCombination: { 887 character: '/' 888 }, 889 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'), 890 /* translators: The forward-slash character. e.g. '/'. */ 891 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash') 892 }] 893 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, { 894 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'), 895 shortcuts: textFormattingShortcuts 896 })] 897 }); 898 } 899 900 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/more-menu/index.js 901 /** 902 * WordPress dependencies 903 */ 904 905 906 907 908 909 910 911 912 /** 913 * Internal dependencies 914 */ 915 916 917 918 919 function MoreMenu() { 920 const [isKeyboardShortcutsModalActive, setIsKeyboardShortcutsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false); 921 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive); 922 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/keyboard-shortcuts', toggleKeyboardShortcutsModal); 923 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 924 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarDropdownMenu, { 925 icon: more_vertical, 926 label: (0,external_wp_i18n_namespaceObject.__)('Options'), 927 popoverProps: { 928 placement: 'bottom-end', 929 className: 'more-menu-dropdown__content' 930 }, 931 toggleProps: { 932 tooltipPosition: 'bottom', 933 size: 'compact' 934 }, 935 children: () => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 936 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, { 937 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'), 938 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 939 scope: "core/customize-widgets", 940 name: "fixedToolbar", 941 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'), 942 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'), 943 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'), 944 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated') 945 }) 946 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, { 947 label: (0,external_wp_i18n_namespaceObject.__)('Tools'), 948 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { 949 onClick: () => { 950 setIsKeyboardShortcutsModalVisible(true); 951 }, 952 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'), 953 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts') 954 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 955 scope: "core/customize-widgets", 956 name: "welcomeGuide", 957 label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide') 958 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, { 959 role: "menuitem", 960 icon: library_external, 961 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/block-based-widgets-editor/'), 962 target: "_blank", 963 rel: "noopener noreferrer", 964 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, { 965 as: "span", 966 children: /* translators: accessibility text */ 967 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)') 968 })] 969 })] 970 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, { 971 label: (0,external_wp_i18n_namespaceObject.__)('Preferences'), 972 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 973 scope: "core/customize-widgets", 974 name: "keepCaretInsideBlock", 975 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block'), 976 info: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'), 977 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block activated'), 978 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block deactivated') 979 }) 980 })] 981 }) 982 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyboardShortcutHelpModal, { 983 isModalActive: isKeyboardShortcutsModalActive, 984 toggleModal: toggleKeyboardShortcutsModal 985 })] 986 }); 987 } 988 989 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/header/index.js 990 /** 991 * External dependencies 992 */ 993 994 995 /** 996 * WordPress dependencies 997 */ 998 999 1000 1001 1002 1003 1004 1005 /** 1006 * Internal dependencies 1007 */ 1008 1009 1010 1011 1012 1013 function Header({ 1014 sidebar, 1015 inserter, 1016 isInserterOpened, 1017 setIsInserterOpened, 1018 isFixedToolbarActive 1019 }) { 1020 const [[hasUndo, hasRedo], setUndoRedo] = (0,external_wp_element_namespaceObject.useState)([sidebar.hasUndo(), sidebar.hasRedo()]); 1021 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y'); 1022 (0,external_wp_element_namespaceObject.useEffect)(() => { 1023 return sidebar.subscribeHistory(() => { 1024 setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]); 1025 }); 1026 }, [sidebar]); 1027 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1028 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 1029 className: dist_clsx('customize-widgets-header', { 1030 'is-fixed-toolbar-active': isFixedToolbarActive 1031 }), 1032 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.NavigableToolbar, { 1033 className: "customize-widgets-header-toolbar", 1034 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools'), 1035 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { 1036 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo 1037 /* translators: button label text should, if possible, be under 16 characters. */, 1038 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 1039 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z'), 1040 disabled: !hasUndo, 1041 onClick: sidebar.undo, 1042 className: "customize-widgets-editor-history-button undo-button" 1043 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { 1044 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo 1045 /* translators: button label text should, if possible, be under 16 characters. */, 1046 label: (0,external_wp_i18n_namespaceObject.__)('Redo'), 1047 shortcut: shortcut, 1048 disabled: !hasRedo, 1049 onClick: sidebar.redo, 1050 className: "customize-widgets-editor-history-button redo-button" 1051 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { 1052 className: "customize-widgets-header-toolbar__inserter-toggle", 1053 isPressed: isInserterOpened, 1054 variant: "primary", 1055 icon: library_plus, 1056 label: (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button'), 1057 onClick: () => { 1058 setIsInserterOpened(isOpen => !isOpen); 1059 } 1060 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})] 1061 }) 1062 }), (0,external_wp_element_namespaceObject.createPortal)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_inserter, { 1063 setIsOpened: setIsInserterOpened 1064 }), inserter.contentContainer[0])] 1065 }); 1066 } 1067 /* harmony default export */ const header = (Header); 1068 1069 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/inserter/use-inserter.js 1070 /** 1071 * WordPress dependencies 1072 */ 1073 1074 1075 1076 /** 1077 * Internal dependencies 1078 */ 1079 1080 function useInserter(inserter) { 1081 const isInserterOpened = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isInserterOpened(), []); 1082 const { 1083 setIsInserterOpened 1084 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 1085 (0,external_wp_element_namespaceObject.useEffect)(() => { 1086 if (isInserterOpened) { 1087 inserter.open(); 1088 } else { 1089 inserter.close(); 1090 } 1091 }, [inserter, isInserterOpened]); 1092 return [isInserterOpened, (0,external_wp_element_namespaceObject.useCallback)(updater => { 1093 let isOpen = updater; 1094 if (typeof updater === 'function') { 1095 isOpen = updater((0,external_wp_data_namespaceObject.select)(store).isInserterOpened()); 1096 } 1097 setIsInserterOpened(isOpen); 1098 }, [setIsInserterOpened])]; 1099 } 1100 1101 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js 1102 var es6 = __webpack_require__(7734); 1103 var es6_default = /*#__PURE__*/__webpack_require__.n(es6); 1104 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] 1105 const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; 1106 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); 1107 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/utils.js 1108 // @ts-check 1109 /** 1110 * WordPress dependencies 1111 */ 1112 1113 1114 1115 /** 1116 * Convert settingId to widgetId. 1117 * 1118 * @param {string} settingId The setting id. 1119 * @return {string} The widget id. 1120 */ 1121 function settingIdToWidgetId(settingId) { 1122 const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/); 1123 if (matches) { 1124 const idBase = matches[1]; 1125 const number = parseInt(matches[2], 10); 1126 return `$idBase}-$number}`; 1127 } 1128 return settingId; 1129 } 1130 1131 /** 1132 * Transform a block to a customizable widget. 1133 * 1134 * @param {WPBlock} block The block to be transformed from. 1135 * @param {Object} existingWidget The widget to be extended from. 1136 * @return {Object} The transformed widget. 1137 */ 1138 function blockToWidget(block, existingWidget = null) { 1139 let widget; 1140 const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance); 1141 if (isValidLegacyWidgetBlock) { 1142 if (block.attributes.id) { 1143 // Widget that does not extend WP_Widget. 1144 widget = { 1145 id: block.attributes.id 1146 }; 1147 } else { 1148 const { 1149 encoded, 1150 hash, 1151 raw, 1152 ...rest 1153 } = block.attributes.instance; 1154 1155 // Widget that extends WP_Widget. 1156 widget = { 1157 idBase: block.attributes.idBase, 1158 instance: { 1159 ...existingWidget?.instance, 1160 // Required only for the customizer. 1161 is_widget_customizer_js_value: true, 1162 encoded_serialized_instance: encoded, 1163 instance_hash_key: hash, 1164 raw_instance: raw, 1165 ...rest 1166 } 1167 }; 1168 } 1169 } else { 1170 const instance = { 1171 content: (0,external_wp_blocks_namespaceObject.serialize)(block) 1172 }; 1173 widget = { 1174 idBase: 'block', 1175 widgetClass: 'WP_Widget_Block', 1176 instance: { 1177 raw_instance: instance 1178 } 1179 }; 1180 } 1181 const { 1182 form, 1183 rendered, 1184 ...restExistingWidget 1185 } = existingWidget || {}; 1186 return { 1187 ...restExistingWidget, 1188 ...widget 1189 }; 1190 } 1191 1192 /** 1193 * Transform a widget to a block. 1194 * 1195 * @param {Object} widget The widget to be transformed from. 1196 * @param {string} widget.id The widget id. 1197 * @param {string} widget.idBase The id base of the widget. 1198 * @param {number} widget.number The number/index of the widget. 1199 * @param {Object} widget.instance The instance of the widget. 1200 * @return {WPBlock} The transformed block. 1201 */ 1202 function widgetToBlock({ 1203 id, 1204 idBase, 1205 number, 1206 instance 1207 }) { 1208 let block; 1209 const { 1210 encoded_serialized_instance: encoded, 1211 instance_hash_key: hash, 1212 raw_instance: raw, 1213 ...rest 1214 } = instance; 1215 if (idBase === 'block') { 1216 var _raw$content; 1217 const parsedBlocks = (0,external_wp_blocks_namespaceObject.parse)((_raw$content = raw.content) !== null && _raw$content !== void 0 ? _raw$content : '', { 1218 __unstableSkipAutop: true 1219 }); 1220 block = parsedBlocks.length ? parsedBlocks[0] : (0,external_wp_blocks_namespaceObject.createBlock)('core/paragraph', {}); 1221 } else if (number) { 1222 // Widget that extends WP_Widget. 1223 block = (0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', { 1224 idBase, 1225 instance: { 1226 encoded, 1227 hash, 1228 raw, 1229 ...rest 1230 } 1231 }); 1232 } else { 1233 // Widget that does not extend WP_Widget. 1234 block = (0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', { 1235 id 1236 }); 1237 } 1238 return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(block, id); 1239 } 1240 1241 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js 1242 /** 1243 * External dependencies 1244 */ 1245 1246 1247 /** 1248 * WordPress dependencies 1249 */ 1250 1251 1252 1253 1254 /** 1255 * Internal dependencies 1256 */ 1257 1258 function widgetsToBlocks(widgets) { 1259 return widgets.map(widget => widgetToBlock(widget)); 1260 } 1261 function useSidebarBlockEditor(sidebar) { 1262 const [blocks, setBlocks] = (0,external_wp_element_namespaceObject.useState)(() => widgetsToBlocks(sidebar.getWidgets())); 1263 (0,external_wp_element_namespaceObject.useEffect)(() => { 1264 return sidebar.subscribe((prevWidgets, nextWidgets) => { 1265 setBlocks(prevBlocks => { 1266 const prevWidgetsMap = new Map(prevWidgets.map(widget => [widget.id, widget])); 1267 const prevBlocksMap = new Map(prevBlocks.map(block => [(0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block), block])); 1268 const nextBlocks = nextWidgets.map(nextWidget => { 1269 const prevWidget = prevWidgetsMap.get(nextWidget.id); 1270 1271 // Bail out updates. 1272 if (prevWidget && prevWidget === nextWidget) { 1273 return prevBlocksMap.get(nextWidget.id); 1274 } 1275 return widgetToBlock(nextWidget); 1276 }); 1277 1278 // Bail out updates. 1279 if (external_wp_isShallowEqual_default()(prevBlocks, nextBlocks)) { 1280 return prevBlocks; 1281 } 1282 return nextBlocks; 1283 }); 1284 }); 1285 }, [sidebar]); 1286 const onChangeBlocks = (0,external_wp_element_namespaceObject.useCallback)(nextBlocks => { 1287 setBlocks(prevBlocks => { 1288 if (external_wp_isShallowEqual_default()(prevBlocks, nextBlocks)) { 1289 return prevBlocks; 1290 } 1291 const prevBlocksMap = new Map(prevBlocks.map(block => [(0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block), block])); 1292 const nextWidgets = nextBlocks.map(nextBlock => { 1293 const widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(nextBlock); 1294 1295 // Update existing widgets. 1296 if (widgetId && prevBlocksMap.has(widgetId)) { 1297 const prevBlock = prevBlocksMap.get(widgetId); 1298 const prevWidget = sidebar.getWidget(widgetId); 1299 1300 // Bail out updates by returning the previous widgets. 1301 // Deep equality is necessary until the block editor's internals changes. 1302 if (es6_default()(nextBlock, prevBlock) && prevWidget) { 1303 return prevWidget; 1304 } 1305 return blockToWidget(nextBlock, prevWidget); 1306 } 1307 1308 // Add a new widget. 1309 return blockToWidget(nextBlock); 1310 }); 1311 1312 // Bail out updates if the updated widgets are the same. 1313 if (external_wp_isShallowEqual_default()(sidebar.getWidgets(), nextWidgets)) { 1314 return prevBlocks; 1315 } 1316 const addedWidgetIds = sidebar.setWidgets(nextWidgets); 1317 return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => { 1318 const addedWidgetId = addedWidgetIds[index]; 1319 if (addedWidgetId !== null) { 1320 // Only create a new instance if necessary to prevent 1321 // the whole editor from re-rendering on every edit. 1322 if (updatedNextBlocks === nextBlocks) { 1323 updatedNextBlocks = nextBlocks.slice(); 1324 } 1325 updatedNextBlocks[index] = (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(nextBlock, addedWidgetId); 1326 } 1327 return updatedNextBlocks; 1328 }, nextBlocks); 1329 }); 1330 }, [sidebar]); 1331 return [blocks, onChangeBlocks, onChangeBlocks]; 1332 } 1333 1334 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/focus-control/index.js 1335 /** 1336 * WordPress dependencies 1337 */ 1338 1339 1340 /** 1341 * Internal dependencies 1342 */ 1343 1344 1345 const FocusControlContext = (0,external_wp_element_namespaceObject.createContext)(); 1346 function FocusControl({ 1347 api, 1348 sidebarControls, 1349 children 1350 }) { 1351 const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0,external_wp_element_namespaceObject.useState)({ 1352 current: null 1353 }); 1354 const focusWidget = (0,external_wp_element_namespaceObject.useCallback)(widgetId => { 1355 for (const sidebarControl of sidebarControls) { 1356 const widgets = sidebarControl.setting.get(); 1357 if (widgets.includes(widgetId)) { 1358 sidebarControl.sectionInstance.expand({ 1359 // Schedule it after the complete callback so that 1360 // it won't be overridden by the "Back" button focus. 1361 completeCallback() { 1362 // Create a "ref-like" object every time to ensure 1363 // the same widget id can also triggers the focus control. 1364 setFocusedWidgetIdRef({ 1365 current: widgetId 1366 }); 1367 } 1368 }); 1369 break; 1370 } 1371 } 1372 }, [sidebarControls]); 1373 (0,external_wp_element_namespaceObject.useEffect)(() => { 1374 function handleFocus(settingId) { 1375 const widgetId = settingIdToWidgetId(settingId); 1376 focusWidget(widgetId); 1377 } 1378 let previewBound = false; 1379 function handleReady() { 1380 api.previewer.preview.bind('focus-control-for-setting', handleFocus); 1381 previewBound = true; 1382 } 1383 api.previewer.bind('ready', handleReady); 1384 return () => { 1385 api.previewer.unbind('ready', handleReady); 1386 if (previewBound) { 1387 api.previewer.preview.unbind('focus-control-for-setting', handleFocus); 1388 } 1389 }; 1390 }, [api, focusWidget]); 1391 const context = (0,external_wp_element_namespaceObject.useMemo)(() => [focusedWidgetIdRef, focusWidget], [focusedWidgetIdRef, focusWidget]); 1392 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FocusControlContext.Provider, { 1393 value: context, 1394 children: children 1395 }); 1396 } 1397 const useFocusControl = () => (0,external_wp_element_namespaceObject.useContext)(FocusControlContext); 1398 1399 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.js 1400 /** 1401 * WordPress dependencies 1402 */ 1403 1404 1405 1406 1407 1408 /** 1409 * Internal dependencies 1410 */ 1411 1412 function useBlocksFocusControl(blocks) { 1413 const { 1414 selectBlock 1415 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 1416 const [focusedWidgetIdRef] = useFocusControl(); 1417 const blocksRef = (0,external_wp_element_namespaceObject.useRef)(blocks); 1418 (0,external_wp_element_namespaceObject.useEffect)(() => { 1419 blocksRef.current = blocks; 1420 }, [blocks]); 1421 (0,external_wp_element_namespaceObject.useEffect)(() => { 1422 if (focusedWidgetIdRef.current) { 1423 const focusedBlock = blocksRef.current.find(block => (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current); 1424 if (focusedBlock) { 1425 selectBlock(focusedBlock.clientId); 1426 // If the block is already being selected, the DOM node won't 1427 // get focused again automatically. 1428 // We select the DOM and focus it manually here. 1429 const blockNode = document.querySelector(`[data-block="$focusedBlock.clientId}"]`); 1430 blockNode?.focus(); 1431 } 1432 } 1433 }, [focusedWidgetIdRef, selectBlock]); 1434 } 1435 1436 ;// CONCATENATED MODULE: external ["wp","privateApis"] 1437 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 1438 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/lock-unlock.js 1439 /** 1440 * WordPress dependencies 1441 */ 1442 1443 const { 1444 lock, 1445 unlock 1446 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/customize-widgets'); 1447 1448 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.js 1449 /** 1450 * WordPress dependencies 1451 */ 1452 1453 1454 /** 1455 * Internal dependencies 1456 */ 1457 1458 1459 1460 1461 const { 1462 ExperimentalBlockEditorProvider 1463 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 1464 function SidebarEditorProvider({ 1465 sidebar, 1466 settings, 1467 children 1468 }) { 1469 const [blocks, onInput, onChange] = useSidebarBlockEditor(sidebar); 1470 useBlocksFocusControl(blocks); 1471 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalBlockEditorProvider, { 1472 value: blocks, 1473 onInput: onInput, 1474 onChange: onChange, 1475 settings: settings, 1476 useSubRegistry: false, 1477 children: children 1478 }); 1479 } 1480 1481 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/welcome-guide/index.js 1482 /** 1483 * WordPress dependencies 1484 */ 1485 1486 1487 1488 1489 1490 1491 function WelcomeGuide({ 1492 sidebar 1493 }) { 1494 const { 1495 toggle 1496 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 1497 const isEntirelyBlockWidgets = sidebar.getWidgets().every(widget => widget.id.startsWith('block-')); 1498 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 1499 className: "customize-widgets-welcome-guide", 1500 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 1501 className: "customize-widgets-welcome-guide__image__wrapper", 1502 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("picture", { 1503 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("source", { 1504 srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg", 1505 media: "(prefers-reduced-motion: reduce)" 1506 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", { 1507 className: "customize-widgets-welcome-guide__image", 1508 src: "https://s.w.org/images/block-editor/welcome-editor.gif", 1509 width: "312", 1510 height: "240", 1511 alt: "" 1512 })] 1513 }) 1514 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", { 1515 className: "customize-widgets-welcome-guide__heading", 1516 children: (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets') 1517 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { 1518 className: "customize-widgets-welcome-guide__text", 1519 children: isEntirelyBlockWidgets ? (0,external_wp_i18n_namespaceObject.__)('Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.') : (0,external_wp_i18n_namespaceObject.__)('You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.') 1520 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button 1521 // TODO: Switch to `true` (40px size) if possible 1522 , { 1523 __next40pxDefaultSize: false, 1524 className: "customize-widgets-welcome-guide__button", 1525 variant: "primary", 1526 onClick: () => toggle('core/customize-widgets', 'welcomeGuide'), 1527 children: (0,external_wp_i18n_namespaceObject.__)('Got it') 1528 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", { 1529 className: "customize-widgets-welcome-guide__separator" 1530 }), !isEntirelyBlockWidgets && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", { 1531 className: "customize-widgets-welcome-guide__more-info", 1532 children: [(0,external_wp_i18n_namespaceObject.__)('Want to stick with the old widgets?'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, { 1533 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/plugins/classic-widgets/'), 1534 children: (0,external_wp_i18n_namespaceObject.__)('Get the Classic Widgets plugin.') 1535 })] 1536 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", { 1537 className: "customize-widgets-welcome-guide__more-info", 1538 children: [(0,external_wp_i18n_namespaceObject.__)('New to the block editor?'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, { 1539 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'), 1540 children: (0,external_wp_i18n_namespaceObject.__)("Here's a detailed guide.") 1541 })] 1542 })] 1543 }); 1544 } 1545 1546 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcuts/index.js 1547 /** 1548 * WordPress dependencies 1549 */ 1550 1551 1552 1553 1554 1555 function KeyboardShortcuts({ 1556 undo, 1557 redo, 1558 save 1559 }) { 1560 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/undo', event => { 1561 undo(); 1562 event.preventDefault(); 1563 }); 1564 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/redo', event => { 1565 redo(); 1566 event.preventDefault(); 1567 }); 1568 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/save', event => { 1569 event.preventDefault(); 1570 save(); 1571 }); 1572 return null; 1573 } 1574 function KeyboardShortcutsRegister() { 1575 const { 1576 registerShortcut, 1577 unregisterShortcut 1578 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); 1579 (0,external_wp_element_namespaceObject.useEffect)(() => { 1580 registerShortcut({ 1581 name: 'core/customize-widgets/undo', 1582 category: 'global', 1583 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'), 1584 keyCombination: { 1585 modifier: 'primary', 1586 character: 'z' 1587 } 1588 }); 1589 registerShortcut({ 1590 name: 'core/customize-widgets/redo', 1591 category: 'global', 1592 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'), 1593 keyCombination: { 1594 modifier: 'primaryShift', 1595 character: 'z' 1596 }, 1597 // Disable on Apple OS because it conflicts with the browser's 1598 // history shortcut. It's a fine alias for both Windows and Linux. 1599 // Since there's no conflict for Ctrl+Shift+Z on both Windows and 1600 // Linux, we keep it as the default for consistency. 1601 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{ 1602 modifier: 'primary', 1603 character: 'y' 1604 }] 1605 }); 1606 registerShortcut({ 1607 name: 'core/customize-widgets/save', 1608 category: 'global', 1609 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), 1610 keyCombination: { 1611 modifier: 'primary', 1612 character: 's' 1613 } 1614 }); 1615 return () => { 1616 unregisterShortcut('core/customize-widgets/undo'); 1617 unregisterShortcut('core/customize-widgets/redo'); 1618 unregisterShortcut('core/customize-widgets/save'); 1619 }; 1620 }, [registerShortcut]); 1621 return null; 1622 } 1623 KeyboardShortcuts.Register = KeyboardShortcutsRegister; 1624 /* harmony default export */ const keyboard_shortcuts = (KeyboardShortcuts); 1625 1626 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/block-appender/index.js 1627 /** 1628 * WordPress dependencies 1629 */ 1630 1631 1632 1633 1634 function BlockAppender(props) { 1635 const ref = (0,external_wp_element_namespaceObject.useRef)(); 1636 const isBlocksListEmpty = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockCount() === 0); 1637 1638 // Move the focus to the block appender to prevent focus from 1639 // being lost when emptying the widget area. 1640 (0,external_wp_element_namespaceObject.useEffect)(() => { 1641 if (isBlocksListEmpty && ref.current) { 1642 const { 1643 ownerDocument 1644 } = ref.current; 1645 if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) { 1646 ref.current.focus(); 1647 } 1648 } 1649 }, [isBlocksListEmpty]); 1650 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.ButtonBlockAppender, { 1651 ...props, 1652 ref: ref 1653 }); 1654 } 1655 1656 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/index.js 1657 /** 1658 * WordPress dependencies 1659 */ 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 /** 1670 * Internal dependencies 1671 */ 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 const { 1684 ExperimentalBlockCanvas: BlockCanvas 1685 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 1686 const { 1687 BlockKeyboardShortcuts 1688 } = unlock(external_wp_blockLibrary_namespaceObject.privateApis); 1689 function SidebarBlockEditor({ 1690 blockEditorSettings, 1691 sidebar, 1692 inserter, 1693 inspector 1694 }) { 1695 const [isInserterOpened, setIsInserterOpened] = useInserter(inserter); 1696 const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small'); 1697 const { 1698 hasUploadPermissions, 1699 isFixedToolbarActive, 1700 keepCaretInsideBlock, 1701 isWelcomeGuideActive 1702 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 1703 var _select$canUser; 1704 const { 1705 get 1706 } = select(external_wp_preferences_namespaceObject.store); 1707 return { 1708 hasUploadPermissions: (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', { 1709 kind: 'root', 1710 name: 'media' 1711 })) !== null && _select$canUser !== void 0 ? _select$canUser : true, 1712 isFixedToolbarActive: !!get('core/customize-widgets', 'fixedToolbar'), 1713 keepCaretInsideBlock: !!get('core/customize-widgets', 'keepCaretInsideBlock'), 1714 isWelcomeGuideActive: !!get('core/customize-widgets', 'welcomeGuide') 1715 }; 1716 }, []); 1717 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { 1718 let mediaUploadBlockEditor; 1719 if (hasUploadPermissions) { 1720 mediaUploadBlockEditor = ({ 1721 onError, 1722 ...argumentsObject 1723 }) => { 1724 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({ 1725 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes, 1726 onError: ({ 1727 message 1728 }) => onError(message), 1729 ...argumentsObject 1730 }); 1731 }; 1732 } 1733 return { 1734 ...blockEditorSettings, 1735 __experimentalSetIsInserterOpened: setIsInserterOpened, 1736 mediaUpload: mediaUploadBlockEditor, 1737 hasFixedToolbar: isFixedToolbarActive || !isMediumViewport, 1738 keepCaretInsideBlock, 1739 __unstableHasCustomAppender: true 1740 }; 1741 }, [hasUploadPermissions, blockEditorSettings, isFixedToolbarActive, isMediumViewport, keepCaretInsideBlock, setIsInserterOpened]); 1742 if (isWelcomeGuideActive) { 1743 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuide, { 1744 sidebar: sidebar 1745 }); 1746 } 1747 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1748 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcuts.Register, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockKeyboardShortcuts, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(SidebarEditorProvider, { 1749 sidebar: sidebar, 1750 settings: settings, 1751 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcuts, { 1752 undo: sidebar.undo, 1753 redo: sidebar.redo, 1754 save: sidebar.save 1755 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(header, { 1756 sidebar: sidebar, 1757 inserter: inserter, 1758 isInserterOpened: isInserterOpened, 1759 setIsInserterOpened: setIsInserterOpened, 1760 isFixedToolbarActive: isFixedToolbarActive || !isMediumViewport 1761 }), (isFixedToolbarActive || !isMediumViewport) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, { 1762 hideDragHandle: true 1763 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockCanvas, { 1764 shouldIframe: false, 1765 styles: settings.defaultEditorStyles, 1766 height: "100%", 1767 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, { 1768 renderAppender: BlockAppender 1769 }) 1770 }), (0,external_wp_element_namespaceObject.createPortal)( 1771 /*#__PURE__*/ 1772 // This is a temporary hack to prevent button component inside <BlockInspector> 1773 // from submitting form when type="button" is not specified. 1774 (0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { 1775 onSubmit: event => event.preventDefault(), 1776 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {}) 1777 }), inspector.contentContainer[0])] 1778 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, { 1779 children: ({ 1780 onClose 1781 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_inspector_button, { 1782 inspector: inspector, 1783 closeMenu: onClose 1784 }) 1785 })] 1786 }); 1787 } 1788 1789 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-controls/index.js 1790 /** 1791 * WordPress dependencies 1792 */ 1793 1794 1795 const SidebarControlsContext = (0,external_wp_element_namespaceObject.createContext)(); 1796 function SidebarControls({ 1797 sidebarControls, 1798 activeSidebarControl, 1799 children 1800 }) { 1801 const context = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 1802 sidebarControls, 1803 activeSidebarControl 1804 }), [sidebarControls, activeSidebarControl]); 1805 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarControlsContext.Provider, { 1806 value: context, 1807 children: children 1808 }); 1809 } 1810 function useSidebarControls() { 1811 const { 1812 sidebarControls 1813 } = (0,external_wp_element_namespaceObject.useContext)(SidebarControlsContext); 1814 return sidebarControls; 1815 } 1816 function useActiveSidebarControl() { 1817 const { 1818 activeSidebarControl 1819 } = (0,external_wp_element_namespaceObject.useContext)(SidebarControlsContext); 1820 return activeSidebarControl; 1821 } 1822 1823 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/customize-widgets/use-clear-selected-block.js 1824 /** 1825 * WordPress dependencies 1826 */ 1827 1828 1829 1830 1831 /** 1832 * We can't just use <BlockSelectionClearer> because the customizer has 1833 * many root nodes rather than just one in the post editor. 1834 * We need to listen to the focus events in all those roots, and also in 1835 * the preview iframe. 1836 * This hook will clear the selected block when focusing outside the editor, 1837 * with a few exceptions: 1838 * 1. Focusing on popovers. 1839 * 2. Focusing on the inspector. 1840 * 3. Focusing on any modals/dialogs. 1841 * These cases are normally triggered by user interactions from the editor, 1842 * not by explicitly focusing outside the editor, hence no need for clearing. 1843 * 1844 * @param {Object} sidebarControl The sidebar control instance. 1845 * @param {Object} popoverRef The ref object of the popover node container. 1846 */ 1847 function useClearSelectedBlock(sidebarControl, popoverRef) { 1848 const { 1849 hasSelectedBlock, 1850 hasMultiSelection 1851 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); 1852 const { 1853 clearSelectedBlock 1854 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 1855 (0,external_wp_element_namespaceObject.useEffect)(() => { 1856 if (popoverRef.current && sidebarControl) { 1857 const inspector = sidebarControl.inspector; 1858 const container = sidebarControl.container[0]; 1859 const ownerDocument = container.ownerDocument; 1860 const ownerWindow = ownerDocument.defaultView; 1861 function handleClearSelectedBlock(element) { 1862 if ( 1863 // 1. Make sure there are blocks being selected. 1864 (hasSelectedBlock() || hasMultiSelection()) && 1865 // 2. The element should exist in the DOM (not deleted). 1866 element && ownerDocument.contains(element) && 1867 // 3. It should also not exist in the container, the popover, nor the dialog. 1868 !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && 1869 // 4. The inspector should not be opened. 1870 !inspector.expanded()) { 1871 clearSelectedBlock(); 1872 } 1873 } 1874 1875 // Handle mouse down in the same document. 1876 function handleMouseDown(event) { 1877 handleClearSelectedBlock(event.target); 1878 } 1879 // Handle focusing outside the current document, like to iframes. 1880 function handleBlur() { 1881 handleClearSelectedBlock(ownerDocument.activeElement); 1882 } 1883 ownerDocument.addEventListener('mousedown', handleMouseDown); 1884 ownerWindow.addEventListener('blur', handleBlur); 1885 return () => { 1886 ownerDocument.removeEventListener('mousedown', handleMouseDown); 1887 ownerWindow.removeEventListener('blur', handleBlur); 1888 }; 1889 } 1890 }, [popoverRef, sidebarControl, hasSelectedBlock, hasMultiSelection, clearSelectedBlock]); 1891 } 1892 1893 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/customize-widgets/index.js 1894 /** 1895 * WordPress dependencies 1896 */ 1897 1898 1899 1900 /** 1901 * Internal dependencies 1902 */ 1903 1904 1905 1906 1907 1908 1909 1910 function CustomizeWidgets({ 1911 api, 1912 sidebarControls, 1913 blockEditorSettings 1914 }) { 1915 const [activeSidebarControl, setActiveSidebarControl] = (0,external_wp_element_namespaceObject.useState)(null); 1916 const parentContainer = document.getElementById('customize-theme-controls'); 1917 const popoverRef = (0,external_wp_element_namespaceObject.useRef)(); 1918 useClearSelectedBlock(activeSidebarControl, popoverRef); 1919 (0,external_wp_element_namespaceObject.useEffect)(() => { 1920 const unsubscribers = sidebarControls.map(sidebarControl => sidebarControl.subscribe(expanded => { 1921 if (expanded) { 1922 setActiveSidebarControl(sidebarControl); 1923 } 1924 })); 1925 return () => { 1926 unsubscribers.forEach(unsubscriber => unsubscriber()); 1927 }; 1928 }, [sidebarControls]); 1929 const activeSidebar = activeSidebarControl && (0,external_wp_element_namespaceObject.createPortal)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ErrorBoundary, { 1930 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarBlockEditor, { 1931 blockEditorSettings: blockEditorSettings, 1932 sidebar: activeSidebarControl.sidebarAdapter, 1933 inserter: activeSidebarControl.inserter, 1934 inspector: activeSidebarControl.inspector 1935 }, activeSidebarControl.id) 1936 }), activeSidebarControl.container[0]); 1937 1938 // We have to portal this to the parent of both the editor and the inspector, 1939 // so that the popovers will appear above both of them. 1940 const popover = parentContainer && (0,external_wp_element_namespaceObject.createPortal)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 1941 className: "customize-widgets-popover", 1942 ref: popoverRef, 1943 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {}) 1944 }), parentContainer); 1945 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SlotFillProvider, { 1946 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarControls, { 1947 sidebarControls: sidebarControls, 1948 activeSidebarControl: activeSidebarControl, 1949 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(FocusControl, { 1950 api: api, 1951 sidebarControls: sidebarControls, 1952 children: [activeSidebar, popover] 1953 }) 1954 }) 1955 }); 1956 } 1957 1958 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/inspector-section.js 1959 function getInspectorSection() { 1960 const { 1961 wp: { 1962 customize 1963 } 1964 } = window; 1965 return class InspectorSection extends customize.Section { 1966 constructor(id, options) { 1967 super(id, options); 1968 this.parentSection = options.parentSection; 1969 this.returnFocusWhenClose = null; 1970 this._isOpen = false; 1971 } 1972 get isOpen() { 1973 return this._isOpen; 1974 } 1975 set isOpen(value) { 1976 this._isOpen = value; 1977 this.triggerActiveCallbacks(); 1978 } 1979 ready() { 1980 this.contentContainer[0].classList.add('customize-widgets-layout__inspector'); 1981 } 1982 isContextuallyActive() { 1983 return this.isOpen; 1984 } 1985 onChangeExpanded(expanded, args) { 1986 super.onChangeExpanded(expanded, args); 1987 if (this.parentSection && !args.unchanged) { 1988 if (expanded) { 1989 this.parentSection.collapse({ 1990 manualTransition: true 1991 }); 1992 } else { 1993 this.parentSection.expand({ 1994 manualTransition: true, 1995 completeCallback: () => { 1996 // Return focus after finishing the transition. 1997 if (this.returnFocusWhenClose && !this.contentContainer[0].contains(this.returnFocusWhenClose)) { 1998 this.returnFocusWhenClose.focus(); 1999 } 2000 } 2001 }); 2002 } 2003 } 2004 } 2005 open({ 2006 returnFocusWhenClose 2007 } = {}) { 2008 this.isOpen = true; 2009 this.returnFocusWhenClose = returnFocusWhenClose; 2010 this.expand({ 2011 allowMultiple: true 2012 }); 2013 } 2014 close() { 2015 this.collapse({ 2016 allowMultiple: true 2017 }); 2018 } 2019 collapse(options) { 2020 // Overridden collapse() function. Mostly call the parent collapse(), but also 2021 // move our .isOpen to false. 2022 // Initially, I tried tracking this with onChangeExpanded(), but it doesn't work 2023 // because the block settings sidebar is a layer "on top of" the G editor sidebar. 2024 // 2025 // For example, when closing the block settings sidebar, the G 2026 // editor sidebar would display, and onChangeExpanded in 2027 // inspector-section would run with expanded=true, but I want 2028 // isOpen to be false when the block settings is closed. 2029 this.isOpen = false; 2030 super.collapse(options); 2031 } 2032 triggerActiveCallbacks() { 2033 // Manually fire the callbacks associated with moving this.active 2034 // from false to true. "active" is always true for this section, 2035 // and "isContextuallyActive" reflects if the block settings 2036 // sidebar is currently visible, that is, it has replaced the main 2037 // Gutenberg view. 2038 // The WP customizer only checks ".isContextuallyActive()" when 2039 // ".active" changes values. But our ".active" never changes value. 2040 // The WP customizer never foresaw a section being used a way we 2041 // fit the block settings sidebar into a section. By manually 2042 // triggering the "this.active" callbacks, we force the WP 2043 // customizer to query our .isContextuallyActive() function and 2044 // update its view of our status. 2045 this.active.callbacks.fireWith(this.active, [false, true]); 2046 } 2047 }; 2048 } 2049 2050 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-section.js 2051 /** 2052 * WordPress dependencies 2053 */ 2054 2055 2056 /** 2057 * Internal dependencies 2058 */ 2059 2060 const getInspectorSectionId = sidebarId => `widgets-inspector-$sidebarId}`; 2061 function getSidebarSection() { 2062 const { 2063 wp: { 2064 customize 2065 } 2066 } = window; 2067 const reduceMotionMediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)'); 2068 let isReducedMotion = reduceMotionMediaQuery.matches; 2069 reduceMotionMediaQuery.addEventListener('change', event => { 2070 isReducedMotion = event.matches; 2071 }); 2072 return class SidebarSection extends customize.Section { 2073 ready() { 2074 const InspectorSection = getInspectorSection(); 2075 this.inspector = new InspectorSection(getInspectorSectionId(this.id), { 2076 title: (0,external_wp_i18n_namespaceObject.__)('Block Settings'), 2077 parentSection: this, 2078 customizeAction: [(0,external_wp_i18n_namespaceObject.__)('Customizing'), (0,external_wp_i18n_namespaceObject.__)('Widgets'), this.params.title].join(' ▸ ') 2079 }); 2080 customize.section.add(this.inspector); 2081 this.contentContainer[0].classList.add('customize-widgets__sidebar-section'); 2082 } 2083 hasSubSectionOpened() { 2084 return this.inspector.expanded(); 2085 } 2086 onChangeExpanded(expanded, _args) { 2087 const controls = this.controls(); 2088 const args = { 2089 ..._args, 2090 completeCallback() { 2091 controls.forEach(control => { 2092 control.onChangeSectionExpanded?.(expanded, args); 2093 }); 2094 _args.completeCallback?.(); 2095 } 2096 }; 2097 if (args.manualTransition) { 2098 if (expanded) { 2099 this.contentContainer.addClass(['busy', 'open']); 2100 this.contentContainer.removeClass('is-sub-section-open'); 2101 this.contentContainer.closest('.wp-full-overlay').addClass('section-open'); 2102 } else { 2103 this.contentContainer.addClass(['busy', 'is-sub-section-open']); 2104 this.contentContainer.closest('.wp-full-overlay').addClass('section-open'); 2105 this.contentContainer.removeClass('open'); 2106 } 2107 const handleTransitionEnd = () => { 2108 this.contentContainer.removeClass('busy'); 2109 args.completeCallback(); 2110 }; 2111 if (isReducedMotion) { 2112 handleTransitionEnd(); 2113 } else { 2114 this.contentContainer.one('transitionend', handleTransitionEnd); 2115 } 2116 } else { 2117 super.onChangeExpanded(expanded, args); 2118 } 2119 } 2120 }; 2121 } 2122 2123 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/sidebar-adapter.js 2124 /** 2125 * Internal dependencies 2126 */ 2127 2128 const { 2129 wp 2130 } = window; 2131 function parseWidgetId(widgetId) { 2132 const matches = widgetId.match(/^(.+)-(\d+)$/); 2133 if (matches) { 2134 return { 2135 idBase: matches[1], 2136 number: parseInt(matches[2], 10) 2137 }; 2138 } 2139 2140 // Likely an old single widget. 2141 return { 2142 idBase: widgetId 2143 }; 2144 } 2145 function widgetIdToSettingId(widgetId) { 2146 const { 2147 idBase, 2148 number 2149 } = parseWidgetId(widgetId); 2150 if (number) { 2151 return `widget_$idBase}[$number}]`; 2152 } 2153 return `widget_$idBase}`; 2154 } 2155 2156 /** 2157 * This is a custom debounce function to call different callbacks depending on 2158 * whether it's the _leading_ call or not. 2159 * 2160 * @param {Function} leading The callback that gets called first. 2161 * @param {Function} callback The callback that gets called after the first time. 2162 * @param {number} timeout The debounced time in milliseconds. 2163 * @return {Function} The debounced function. 2164 */ 2165 function debounce(leading, callback, timeout) { 2166 let isLeading = false; 2167 let timerID; 2168 function debounced(...args) { 2169 const result = (isLeading ? callback : leading).apply(this, args); 2170 isLeading = true; 2171 clearTimeout(timerID); 2172 timerID = setTimeout(() => { 2173 isLeading = false; 2174 }, timeout); 2175 return result; 2176 } 2177 debounced.cancel = () => { 2178 isLeading = false; 2179 clearTimeout(timerID); 2180 }; 2181 return debounced; 2182 } 2183 class SidebarAdapter { 2184 constructor(setting, api) { 2185 this.setting = setting; 2186 this.api = api; 2187 this.locked = false; 2188 this.widgetsCache = new WeakMap(); 2189 this.subscribers = new Set(); 2190 this.history = [this._getWidgetIds().map(widgetId => this.getWidget(widgetId))]; 2191 this.historyIndex = 0; 2192 this.historySubscribers = new Set(); 2193 // Debounce the input for 1 second. 2194 this._debounceSetHistory = debounce(this._pushHistory, this._replaceHistory, 1000); 2195 this.setting.bind(this._handleSettingChange.bind(this)); 2196 this.api.bind('change', this._handleAllSettingsChange.bind(this)); 2197 this.undo = this.undo.bind(this); 2198 this.redo = this.redo.bind(this); 2199 this.save = this.save.bind(this); 2200 } 2201 subscribe(callback) { 2202 this.subscribers.add(callback); 2203 return () => { 2204 this.subscribers.delete(callback); 2205 }; 2206 } 2207 getWidgets() { 2208 return this.history[this.historyIndex]; 2209 } 2210 _emit(...args) { 2211 for (const callback of this.subscribers) { 2212 callback(...args); 2213 } 2214 } 2215 _getWidgetIds() { 2216 return this.setting.get(); 2217 } 2218 _pushHistory() { 2219 this.history = [...this.history.slice(0, this.historyIndex + 1), this._getWidgetIds().map(widgetId => this.getWidget(widgetId))]; 2220 this.historyIndex += 1; 2221 this.historySubscribers.forEach(listener => listener()); 2222 } 2223 _replaceHistory() { 2224 this.history[this.historyIndex] = this._getWidgetIds().map(widgetId => this.getWidget(widgetId)); 2225 } 2226 _handleSettingChange() { 2227 if (this.locked) { 2228 return; 2229 } 2230 const prevWidgets = this.getWidgets(); 2231 this._pushHistory(); 2232 this._emit(prevWidgets, this.getWidgets()); 2233 } 2234 _handleAllSettingsChange(setting) { 2235 if (this.locked) { 2236 return; 2237 } 2238 if (!setting.id.startsWith('widget_')) { 2239 return; 2240 } 2241 const widgetId = settingIdToWidgetId(setting.id); 2242 if (!this.setting.get().includes(widgetId)) { 2243 return; 2244 } 2245 const prevWidgets = this.getWidgets(); 2246 this._pushHistory(); 2247 this._emit(prevWidgets, this.getWidgets()); 2248 } 2249 _createWidget(widget) { 2250 const widgetModel = wp.customize.Widgets.availableWidgets.findWhere({ 2251 id_base: widget.idBase 2252 }); 2253 let number = widget.number; 2254 if (widgetModel.get('is_multi') && !number) { 2255 widgetModel.set('multi_number', widgetModel.get('multi_number') + 1); 2256 number = widgetModel.get('multi_number'); 2257 } 2258 const settingId = number ? `widget_$widget.idBase}[$number}]` : `widget_$widget.idBase}`; 2259 const settingArgs = { 2260 transport: wp.customize.Widgets.data.selectiveRefreshableWidgets[widgetModel.get('id_base')] ? 'postMessage' : 'refresh', 2261 previewer: this.setting.previewer 2262 }; 2263 const setting = this.api.create(settingId, settingId, '', settingArgs); 2264 setting.set(widget.instance); 2265 const widgetId = settingIdToWidgetId(settingId); 2266 return widgetId; 2267 } 2268 _removeWidget(widget) { 2269 const settingId = widgetIdToSettingId(widget.id); 2270 const setting = this.api(settingId); 2271 if (setting) { 2272 const instance = setting.get(); 2273 this.widgetsCache.delete(instance); 2274 } 2275 this.api.remove(settingId); 2276 } 2277 _updateWidget(widget) { 2278 const prevWidget = this.getWidget(widget.id); 2279 2280 // Bail out update if nothing changed. 2281 if (prevWidget === widget) { 2282 return widget.id; 2283 } 2284 2285 // Update existing setting if only the widget's instance changed. 2286 if (prevWidget.idBase && widget.idBase && prevWidget.idBase === widget.idBase) { 2287 const settingId = widgetIdToSettingId(widget.id); 2288 this.api(settingId).set(widget.instance); 2289 return widget.id; 2290 } 2291 2292 // Otherwise delete and re-create. 2293 this._removeWidget(widget); 2294 return this._createWidget(widget); 2295 } 2296 getWidget(widgetId) { 2297 if (!widgetId) { 2298 return null; 2299 } 2300 const { 2301 idBase, 2302 number 2303 } = parseWidgetId(widgetId); 2304 const settingId = widgetIdToSettingId(widgetId); 2305 const setting = this.api(settingId); 2306 if (!setting) { 2307 return null; 2308 } 2309 const instance = setting.get(); 2310 if (this.widgetsCache.has(instance)) { 2311 return this.widgetsCache.get(instance); 2312 } 2313 const widget = { 2314 id: widgetId, 2315 idBase, 2316 number, 2317 instance 2318 }; 2319 this.widgetsCache.set(instance, widget); 2320 return widget; 2321 } 2322 _updateWidgets(nextWidgets) { 2323 this.locked = true; 2324 const addedWidgetIds = []; 2325 const nextWidgetIds = nextWidgets.map(nextWidget => { 2326 if (nextWidget.id && this.getWidget(nextWidget.id)) { 2327 addedWidgetIds.push(null); 2328 return this._updateWidget(nextWidget); 2329 } 2330 const widgetId = this._createWidget(nextWidget); 2331 addedWidgetIds.push(widgetId); 2332 return widgetId; 2333 }); 2334 const deletedWidgets = this.getWidgets().filter(widget => !nextWidgetIds.includes(widget.id)); 2335 deletedWidgets.forEach(widget => this._removeWidget(widget)); 2336 this.setting.set(nextWidgetIds); 2337 this.locked = false; 2338 return addedWidgetIds; 2339 } 2340 setWidgets(nextWidgets) { 2341 const addedWidgetIds = this._updateWidgets(nextWidgets); 2342 this._debounceSetHistory(); 2343 return addedWidgetIds; 2344 } 2345 2346 /** 2347 * Undo/Redo related features 2348 */ 2349 hasUndo() { 2350 return this.historyIndex > 0; 2351 } 2352 hasRedo() { 2353 return this.historyIndex < this.history.length - 1; 2354 } 2355 _seek(historyIndex) { 2356 const currentWidgets = this.getWidgets(); 2357 this.historyIndex = historyIndex; 2358 const widgets = this.history[this.historyIndex]; 2359 this._updateWidgets(widgets); 2360 this._emit(currentWidgets, this.getWidgets()); 2361 this.historySubscribers.forEach(listener => listener()); 2362 this._debounceSetHistory.cancel(); 2363 } 2364 undo() { 2365 if (!this.hasUndo()) { 2366 return; 2367 } 2368 this._seek(this.historyIndex - 1); 2369 } 2370 redo() { 2371 if (!this.hasRedo()) { 2372 return; 2373 } 2374 this._seek(this.historyIndex + 1); 2375 } 2376 subscribeHistory(listener) { 2377 this.historySubscribers.add(listener); 2378 return () => { 2379 this.historySubscribers.delete(listener); 2380 }; 2381 } 2382 save() { 2383 this.api.previewer.save(); 2384 } 2385 } 2386 2387 ;// CONCATENATED MODULE: external ["wp","dom"] 2388 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 2389 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/inserter-outer-section.js 2390 /** 2391 * WordPress dependencies 2392 */ 2393 2394 2395 2396 2397 /** 2398 * Internal dependencies 2399 */ 2400 2401 function getInserterOuterSection() { 2402 const { 2403 wp: { 2404 customize 2405 } 2406 } = window; 2407 const OuterSection = customize.OuterSection; 2408 // Override the OuterSection class to handle multiple outer sections. 2409 // It closes all the other outer sections whenever one is opened. 2410 // The result is that at most one outer section can be opened at the same time. 2411 customize.OuterSection = class extends OuterSection { 2412 onChangeExpanded(expanded, args) { 2413 if (expanded) { 2414 customize.section.each(section => { 2415 if (section.params.type === 'outer' && section.id !== this.id) { 2416 if (section.expanded()) { 2417 section.collapse(); 2418 } 2419 } 2420 }); 2421 } 2422 return super.onChangeExpanded(expanded, args); 2423 } 2424 }; 2425 // Handle constructor so that "params.type" can be correctly pointed to "outer". 2426 customize.sectionConstructor.outer = customize.OuterSection; 2427 return class InserterOuterSection extends customize.OuterSection { 2428 constructor(...args) { 2429 super(...args); 2430 2431 // This is necessary since we're creating a new class which is not identical to the original OuterSection. 2432 // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436 2433 this.params.type = 'outer'; 2434 this.activeElementBeforeExpanded = null; 2435 const ownerWindow = this.contentContainer[0].ownerDocument.defaultView; 2436 2437 // Handle closing the inserter when pressing the Escape key. 2438 ownerWindow.addEventListener('keydown', event => { 2439 if (this.expanded() && (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE || event.code === 'Escape') && !event.defaultPrevented) { 2440 event.preventDefault(); 2441 event.stopPropagation(); 2442 (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(false); 2443 } 2444 }, 2445 // Use capture mode to make this run before other event listeners. 2446 true); 2447 this.contentContainer.addClass('widgets-inserter'); 2448 2449 // Set a flag if the state is being changed from open() or close(). 2450 // Don't propagate the event if it's an internal action to prevent infinite loop. 2451 this.isFromInternalAction = false; 2452 this.expanded.bind(() => { 2453 if (!this.isFromInternalAction) { 2454 // Propagate the event to React to sync the state. 2455 (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(this.expanded()); 2456 } 2457 this.isFromInternalAction = false; 2458 }); 2459 } 2460 open() { 2461 if (!this.expanded()) { 2462 const contentContainer = this.contentContainer[0]; 2463 this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement; 2464 this.isFromInternalAction = true; 2465 this.expand({ 2466 completeCallback() { 2467 // We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable. 2468 // The first one should be the close button, 2469 // we want to skip it and choose the second one instead, which is the search box. 2470 const searchBox = external_wp_dom_namespaceObject.focus.tabbable.find(contentContainer)[1]; 2471 if (searchBox) { 2472 searchBox.focus(); 2473 } 2474 } 2475 }); 2476 } 2477 } 2478 close() { 2479 if (this.expanded()) { 2480 const contentContainer = this.contentContainer[0]; 2481 const activeElement = contentContainer.ownerDocument.activeElement; 2482 this.isFromInternalAction = true; 2483 this.collapse({ 2484 completeCallback() { 2485 // Return back the focus when closing the inserter. 2486 // Only do this if the active element which triggers the action is inside the inserter, 2487 // (the close button for instance). In that case the focus will be lost. 2488 // Otherwise, we don't hijack the focus when the user is focusing on other elements 2489 // (like the quick inserter). 2490 if (contentContainer.contains(activeElement)) { 2491 // Return back the focus when closing the inserter. 2492 if (this.activeElementBeforeExpanded) { 2493 this.activeElementBeforeExpanded.focus(); 2494 } 2495 } 2496 } 2497 }); 2498 } 2499 } 2500 }; 2501 } 2502 2503 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-control.js 2504 /** 2505 * WordPress dependencies 2506 */ 2507 2508 2509 /** 2510 * Internal dependencies 2511 */ 2512 2513 2514 2515 const getInserterId = controlId => `widgets-inserter-$controlId}`; 2516 function getSidebarControl() { 2517 const { 2518 wp: { 2519 customize 2520 } 2521 } = window; 2522 return class SidebarControl extends customize.Control { 2523 constructor(...args) { 2524 super(...args); 2525 this.subscribers = new Set(); 2526 } 2527 ready() { 2528 const InserterOuterSection = getInserterOuterSection(); 2529 this.inserter = new InserterOuterSection(getInserterId(this.id), {}); 2530 customize.section.add(this.inserter); 2531 this.sectionInstance = customize.section(this.section()); 2532 this.inspector = this.sectionInstance.inspector; 2533 this.sidebarAdapter = new SidebarAdapter(this.setting, customize); 2534 } 2535 subscribe(callback) { 2536 this.subscribers.add(callback); 2537 return () => { 2538 this.subscribers.delete(callback); 2539 }; 2540 } 2541 onChangeSectionExpanded(expanded, args) { 2542 if (!args.unchanged) { 2543 // Close the inserter when the section collapses. 2544 if (!expanded) { 2545 (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(false); 2546 } 2547 this.subscribers.forEach(subscriber => subscriber(expanded, args)); 2548 } 2549 } 2550 }; 2551 } 2552 2553 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/move-to-sidebar.js 2554 /** 2555 * WordPress dependencies 2556 */ 2557 2558 2559 2560 2561 2562 2563 /** 2564 * Internal dependencies 2565 */ 2566 2567 2568 2569 2570 2571 2572 const withMoveToSidebarToolbarItem = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 2573 let widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(props); 2574 const sidebarControls = useSidebarControls(); 2575 const activeSidebarControl = useActiveSidebarControl(); 2576 const hasMultipleSidebars = sidebarControls?.length > 1; 2577 const blockName = props.name; 2578 const clientId = props.clientId; 2579 const canInsertBlockInSidebar = (0,external_wp_data_namespaceObject.useSelect)(select => { 2580 // Use an empty string to represent the root block list, which 2581 // in the customizer editor represents a sidebar/widget area. 2582 return select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType(blockName, ''); 2583 }, [blockName]); 2584 const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId), [clientId]); 2585 const { 2586 removeBlock 2587 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 2588 const [, focusWidget] = useFocusControl(); 2589 function moveToSidebar(sidebarControlId) { 2590 const newSidebarControl = sidebarControls.find(sidebarControl => sidebarControl.id === sidebarControlId); 2591 if (widgetId) { 2592 /** 2593 * If there's a widgetId, move it to the other sidebar. 2594 */ 2595 const oldSetting = activeSidebarControl.setting; 2596 const newSetting = newSidebarControl.setting; 2597 oldSetting(oldSetting().filter(id => id !== widgetId)); 2598 newSetting([...newSetting(), widgetId]); 2599 } else { 2600 /** 2601 * If there isn't a widgetId, it's most likely a inner block. 2602 * First, remove the block in the original sidebar, 2603 * then, create a new widget in the new sidebar and get back its widgetId. 2604 */ 2605 const sidebarAdapter = newSidebarControl.sidebarAdapter; 2606 removeBlock(clientId); 2607 const addedWidgetIds = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]); 2608 // The last non-null id is the added widget's id. 2609 widgetId = addedWidgetIds.reverse().find(id => !!id); 2610 } 2611 2612 // Move focus to the moved widget and expand the sidebar. 2613 focusWidget(widgetId); 2614 } 2615 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 2616 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, { 2617 ...props 2618 }, "edit"), hasMultipleSidebars && canInsertBlockInSidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockControls, { 2619 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_widgets_namespaceObject.MoveToWidgetArea, { 2620 widgetAreas: sidebarControls.map(sidebarControl => ({ 2621 id: sidebarControl.id, 2622 name: sidebarControl.params.label, 2623 description: sidebarControl.params.description 2624 })), 2625 currentWidgetAreaId: activeSidebarControl?.id, 2626 onSelect: moveToSidebar 2627 }) 2628 })] 2629 }); 2630 }, 'withMoveToSidebarToolbarItem'); 2631 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/customize-widgets/block-edit', withMoveToSidebarToolbarItem); 2632 2633 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/replace-media-upload.js 2634 /** 2635 * WordPress dependencies 2636 */ 2637 2638 2639 const replaceMediaUpload = () => external_wp_mediaUtils_namespaceObject.MediaUpload; 2640 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-widgets/replace-media-upload', replaceMediaUpload); 2641 2642 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/wide-widget-display.js 2643 /** 2644 * WordPress dependencies 2645 */ 2646 2647 2648 2649 const { 2650 wp: wide_widget_display_wp 2651 } = window; 2652 const withWideWidgetDisplay = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 2653 var _wp$customize$Widgets; 2654 const { 2655 idBase 2656 } = props.attributes; 2657 const isWide = (_wp$customize$Widgets = wide_widget_display_wp.customize.Widgets.data.availableWidgets.find(widget => widget.id_base === idBase)?.is_wide) !== null && _wp$customize$Widgets !== void 0 ? _wp$customize$Widgets : false; 2658 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, { 2659 ...props, 2660 isWide: isWide 2661 }, "edit"); 2662 }, 'withWideWidgetDisplay'); 2663 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/customize-widgets/wide-widget-display', withWideWidgetDisplay); 2664 2665 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/index.js 2666 /** 2667 * Internal dependencies 2668 */ 2669 2670 2671 2672 2673 ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/index.js 2674 /** 2675 * WordPress dependencies 2676 */ 2677 2678 2679 2680 2681 2682 2683 2684 /** 2685 * Internal dependencies 2686 */ 2687 2688 2689 2690 2691 2692 const { 2693 wp: build_module_wp 2694 } = window; 2695 const DISABLED_BLOCKS = ['core/more', 'core/block', 'core/freeform', 'core/template-part']; 2696 const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; 2697 2698 /** 2699 * Initializes the widgets block editor in the customizer. 2700 * 2701 * @param {string} editorName The editor name. 2702 * @param {Object} blockEditorSettings Block editor settings. 2703 */ 2704 function initialize(editorName, blockEditorSettings) { 2705 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/customize-widgets', { 2706 fixedToolbar: false, 2707 welcomeGuide: true 2708 }); 2709 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).reapplyBlockTypeFilters(); 2710 const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(block => { 2711 return !(DISABLED_BLOCKS.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site') || block.name.startsWith('core/navigation')); 2712 }); 2713 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(coreBlocks); 2714 (0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)(); 2715 if (false) {} 2716 (0,external_wp_widgets_namespaceObject.registerLegacyWidgetVariations)(blockEditorSettings); 2717 (0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)(); 2718 2719 // As we are unregistering `core/freeform` to avoid the Classic block, we must 2720 // replace it with something as the default freeform content handler. Failure to 2721 // do this will result in errors in the default block parser. 2722 // see: https://github.com/WordPress/gutenberg/issues/33097 2723 (0,external_wp_blocks_namespaceObject.setFreeformContentHandlerName)('core/html'); 2724 const SidebarControl = getSidebarControl(blockEditorSettings); 2725 build_module_wp.customize.sectionConstructor.sidebar = getSidebarSection(); 2726 build_module_wp.customize.controlConstructor.sidebar_block_editor = SidebarControl; 2727 const container = document.createElement('div'); 2728 document.body.appendChild(container); 2729 build_module_wp.customize.bind('ready', () => { 2730 const sidebarControls = []; 2731 build_module_wp.customize.control.each(control => { 2732 if (control instanceof SidebarControl) { 2733 sidebarControls.push(control); 2734 } 2735 }); 2736 (0,external_wp_element_namespaceObject.createRoot)(container).render( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.StrictMode, { 2737 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CustomizeWidgets, { 2738 api: build_module_wp.customize, 2739 sidebarControls: sidebarControls, 2740 blockEditorSettings: blockEditorSettings 2741 }) 2742 })); 2743 }); 2744 } 2745 2746 2747 })(); 2748 2749 (window.wp = window.wp || {}).customizeWidgets = __webpack_exports__; 2750 /******/ })() 2751 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |