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