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