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