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