| 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 |
"reinitializeEditor": function() { return /* binding */ reinitializeEditor; } |
| 147 |
}); |
| 148 |
|
| 149 |
// NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js |
| 150 |
var actions_namespaceObject = {}; |
| 151 |
__webpack_require__.r(actions_namespaceObject); |
| 152 |
__webpack_require__.d(actions_namespaceObject, { |
| 153 |
"disableComplementaryArea": function() { return disableComplementaryArea; }, |
| 154 |
"enableComplementaryArea": function() { return enableComplementaryArea; }, |
| 155 |
"pinItem": function() { return pinItem; }, |
| 156 |
"setFeatureDefaults": function() { return setFeatureDefaults; }, |
| 157 |
"setFeatureValue": function() { return setFeatureValue; }, |
| 158 |
"toggleFeature": function() { return toggleFeature; }, |
| 159 |
"unpinItem": function() { return unpinItem; } |
| 160 |
}); |
| 161 |
|
| 162 |
// NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js |
| 163 |
var selectors_namespaceObject = {}; |
| 164 |
__webpack_require__.r(selectors_namespaceObject); |
| 165 |
__webpack_require__.d(selectors_namespaceObject, { |
| 166 |
"getActiveComplementaryArea": function() { return getActiveComplementaryArea; }, |
| 167 |
"isFeatureActive": function() { return isFeatureActive; }, |
| 168 |
"isItemPinned": function() { return isItemPinned; } |
| 169 |
}); |
| 170 |
|
| 171 |
// NAMESPACE OBJECT: ./packages/edit-widgets/build-module/store/actions.js |
| 172 |
var store_actions_namespaceObject = {}; |
| 173 |
__webpack_require__.r(store_actions_namespaceObject); |
| 174 |
__webpack_require__.d(store_actions_namespaceObject, { |
| 175 |
"closeGeneralSidebar": function() { return closeGeneralSidebar; }, |
| 176 |
"moveBlockToWidgetArea": function() { return moveBlockToWidgetArea; }, |
| 177 |
"persistStubPost": function() { return persistStubPost; }, |
| 178 |
"saveEditedWidgetAreas": function() { return saveEditedWidgetAreas; }, |
| 179 |
"saveWidgetArea": function() { return saveWidgetArea; }, |
| 180 |
"saveWidgetAreas": function() { return saveWidgetAreas; }, |
| 181 |
"setIsInserterOpened": function() { return setIsInserterOpened; }, |
| 182 |
"setIsListViewOpened": function() { return setIsListViewOpened; }, |
| 183 |
"setIsWidgetAreaOpen": function() { return setIsWidgetAreaOpen; }, |
| 184 |
"setWidgetAreasOpenState": function() { return setWidgetAreasOpenState; }, |
| 185 |
"setWidgetIdForClientId": function() { return setWidgetIdForClientId; } |
| 186 |
}); |
| 187 |
|
| 188 |
// NAMESPACE OBJECT: ./packages/edit-widgets/build-module/store/resolvers.js |
| 189 |
var resolvers_namespaceObject = {}; |
| 190 |
__webpack_require__.r(resolvers_namespaceObject); |
| 191 |
__webpack_require__.d(resolvers_namespaceObject, { |
| 192 |
"getWidgetAreas": function() { return getWidgetAreas; }, |
| 193 |
"getWidgets": function() { return getWidgets; } |
| 194 |
}); |
| 195 |
|
| 196 |
// NAMESPACE OBJECT: ./packages/edit-widgets/build-module/store/selectors.js |
| 197 |
var store_selectors_namespaceObject = {}; |
| 198 |
__webpack_require__.r(store_selectors_namespaceObject); |
| 199 |
__webpack_require__.d(store_selectors_namespaceObject, { |
| 200 |
"__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; }, |
| 201 |
"canInsertBlockInWidgetArea": function() { return canInsertBlockInWidgetArea; }, |
| 202 |
"getEditedWidgetAreas": function() { return getEditedWidgetAreas; }, |
| 203 |
"getIsWidgetAreaOpen": function() { return getIsWidgetAreaOpen; }, |
| 204 |
"getParentWidgetAreaBlock": function() { return getParentWidgetAreaBlock; }, |
| 205 |
"getReferenceWidgetBlocks": function() { return getReferenceWidgetBlocks; }, |
| 206 |
"getWidget": function() { return getWidget; }, |
| 207 |
"getWidgetAreaForWidgetId": function() { return getWidgetAreaForWidgetId; }, |
| 208 |
"getWidgetAreas": function() { return selectors_getWidgetAreas; }, |
| 209 |
"getWidgets": function() { return selectors_getWidgets; }, |
| 210 |
"isInserterOpened": function() { return isInserterOpened; }, |
| 211 |
"isListViewOpened": function() { return isListViewOpened; }, |
| 212 |
"isSavingWidgetAreas": function() { return isSavingWidgetAreas; } |
| 213 |
}); |
| 214 |
|
| 215 |
// NAMESPACE OBJECT: ./packages/edit-widgets/build-module/blocks/widget-area/index.js |
| 216 |
var widget_area_namespaceObject = {}; |
| 217 |
__webpack_require__.r(widget_area_namespaceObject); |
| 218 |
__webpack_require__.d(widget_area_namespaceObject, { |
| 219 |
"metadata": function() { return metadata; }, |
| 220 |
"name": function() { return widget_area_name; }, |
| 221 |
"settings": function() { return settings; } |
| 222 |
}); |
| 223 |
|
| 224 |
;// CONCATENATED MODULE: external ["wp","element"] |
| 225 |
var external_wp_element_namespaceObject = window["wp"]["element"]; |
| 226 |
;// CONCATENATED MODULE: external ["wp","blocks"] |
| 227 |
var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
| 228 |
;// CONCATENATED MODULE: external ["wp","data"] |
| 229 |
var external_wp_data_namespaceObject = window["wp"]["data"]; |
| 230 |
;// CONCATENATED MODULE: external ["wp","blockLibrary"] |
| 231 |
var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; |
| 232 |
;// CONCATENATED MODULE: external ["wp","coreData"] |
| 233 |
var external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
| 234 |
;// CONCATENATED MODULE: external ["wp","widgets"] |
| 235 |
var external_wp_widgets_namespaceObject = window["wp"]["widgets"]; |
| 236 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
| 237 |
function _extends() { |
| 238 |
_extends = Object.assign || function (target) { |
| 239 |
for (var i = 1; i < arguments.length; i++) { |
| 240 |
var source = arguments[i]; |
| 241 |
|
| 242 |
for (var key in source) { |
| 243 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 244 |
target[key] = source[key]; |
| 245 |
} |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
return target; |
| 250 |
}; |
| 251 |
|
| 252 |
return _extends.apply(this, arguments); |
| 253 |
} |
| 254 |
// EXTERNAL MODULE: ./node_modules/classnames/index.js |
| 255 |
var classnames = __webpack_require__(4184); |
| 256 |
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
| 257 |
;// CONCATENATED MODULE: external ["wp","components"] |
| 258 |
var external_wp_components_namespaceObject = window["wp"]["components"]; |
| 259 |
;// CONCATENATED MODULE: external ["wp","i18n"] |
| 260 |
var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
| 261 |
;// CONCATENATED MODULE: external ["wp","primitives"] |
| 262 |
var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
| 263 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js |
| 264 |
|
| 265 |
|
| 266 |
/** |
| 267 |
* WordPress dependencies |
| 268 |
*/ |
| 269 |
|
| 270 |
const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 271 |
xmlns: "http://www.w3.org/2000/svg", |
| 272 |
viewBox: "0 0 24 24" |
| 273 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 274 |
d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" |
| 275 |
})); |
| 276 |
/* harmony default export */ var library_check = (check); |
| 277 |
//# sourceMappingURL=check.js.map |
| 278 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js |
| 279 |
|
| 280 |
|
| 281 |
/** |
| 282 |
* WordPress dependencies |
| 283 |
*/ |
| 284 |
|
| 285 |
const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 286 |
xmlns: "http://www.w3.org/2000/svg", |
| 287 |
viewBox: "0 0 24 24" |
| 288 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 289 |
d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" |
| 290 |
})); |
| 291 |
/* harmony default export */ var star_filled = (starFilled); |
| 292 |
//# sourceMappingURL=star-filled.js.map |
| 293 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js |
| 294 |
|
| 295 |
|
| 296 |
/** |
| 297 |
* WordPress dependencies |
| 298 |
*/ |
| 299 |
|
| 300 |
const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 301 |
xmlns: "http://www.w3.org/2000/svg", |
| 302 |
viewBox: "0 0 24 24" |
| 303 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 304 |
fillRule: "evenodd", |
| 305 |
d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z", |
| 306 |
clipRule: "evenodd" |
| 307 |
})); |
| 308 |
/* harmony default export */ var star_empty = (starEmpty); |
| 309 |
//# sourceMappingURL=star-empty.js.map |
| 310 |
;// CONCATENATED MODULE: external ["wp","viewport"] |
| 311 |
var external_wp_viewport_namespaceObject = window["wp"]["viewport"]; |
| 312 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js |
| 313 |
|
| 314 |
|
| 315 |
/** |
| 316 |
* WordPress dependencies |
| 317 |
*/ |
| 318 |
|
| 319 |
const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 320 |
xmlns: "http://www.w3.org/2000/svg", |
| 321 |
viewBox: "0 0 24 24" |
| 322 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 323 |
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" |
| 324 |
})); |
| 325 |
/* harmony default export */ var close_small = (closeSmall); |
| 326 |
//# sourceMappingURL=close-small.js.map |
| 327 |
;// CONCATENATED MODULE: external "lodash" |
| 328 |
var external_lodash_namespaceObject = window["lodash"]; |
| 329 |
;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js |
| 330 |
/** |
| 331 |
* External dependencies |
| 332 |
*/ |
| 333 |
|
| 334 |
/** |
| 335 |
* WordPress dependencies |
| 336 |
*/ |
| 337 |
|
| 338 |
|
| 339 |
/** |
| 340 |
* Reducer to keep tract of the active area per scope. |
| 341 |
* |
| 342 |
* @param {boolean} state Previous state. |
| 343 |
* @param {Object} action Action object. |
| 344 |
* @param {string} action.type Action type. |
| 345 |
* @param {string} action.itemType Type of item. |
| 346 |
* @param {string} action.scope Item scope. |
| 347 |
* @param {string} action.item Item name. |
| 348 |
* |
| 349 |
* @return {Object} Updated state. |
| 350 |
*/ |
| 351 |
|
| 352 |
function singleEnableItems() { |
| 353 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
| 354 |
let { |
| 355 |
type, |
| 356 |
itemType, |
| 357 |
scope, |
| 358 |
item |
| 359 |
} = arguments.length > 1 ? arguments[1] : undefined; |
| 360 |
|
| 361 |
if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) { |
| 362 |
return state; |
| 363 |
} |
| 364 |
|
| 365 |
return { ...state, |
| 366 |
[itemType]: { ...state[itemType], |
| 367 |
[scope]: item || null |
| 368 |
} |
| 369 |
}; |
| 370 |
} |
| 371 |
/** |
| 372 |
* Reducer keeping track of the "pinned" items per scope. |
| 373 |
* |
| 374 |
* @param {boolean} state Previous state. |
| 375 |
* @param {Object} action Action object. |
| 376 |
* @param {string} action.type Action type. |
| 377 |
* @param {string} action.itemType Type of item. |
| 378 |
* @param {string} action.scope Item scope. |
| 379 |
* @param {string} action.item Item name. |
| 380 |
* @param {boolean} action.isEnable Whether the item is pinned. |
| 381 |
* |
| 382 |
* @return {Object} Updated state. |
| 383 |
*/ |
| 384 |
|
| 385 |
function multipleEnableItems() { |
| 386 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
| 387 |
let { |
| 388 |
type, |
| 389 |
itemType, |
| 390 |
scope, |
| 391 |
item, |
| 392 |
isEnable |
| 393 |
} = arguments.length > 1 ? arguments[1] : undefined; |
| 394 |
|
| 395 |
if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || (0,external_lodash_namespaceObject.get)(state, [itemType, scope, item]) === isEnable) { |
| 396 |
return state; |
| 397 |
} |
| 398 |
|
| 399 |
const currentTypeState = state[itemType] || {}; |
| 400 |
const currentScopeState = currentTypeState[scope] || {}; |
| 401 |
return { ...state, |
| 402 |
[itemType]: { ...currentTypeState, |
| 403 |
[scope]: { ...currentScopeState, |
| 404 |
[item]: isEnable || false |
| 405 |
} |
| 406 |
} |
| 407 |
}; |
| 408 |
} |
| 409 |
/** |
| 410 |
* Reducer returning the defaults for user preferences. |
| 411 |
* |
| 412 |
* This is kept intentionally separate from the preferences |
| 413 |
* themselves so that defaults are not persisted. |
| 414 |
* |
| 415 |
* @param {Object} state Current state. |
| 416 |
* @param {Object} action Dispatched action. |
| 417 |
* |
| 418 |
* @return {Object} Updated state. |
| 419 |
*/ |
| 420 |
|
| 421 |
const preferenceDefaults = (0,external_wp_data_namespaceObject.combineReducers)({ |
| 422 |
features() { |
| 423 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
| 424 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
| 425 |
|
| 426 |
if (action.type === 'SET_FEATURE_DEFAULTS') { |
| 427 |
const { |
| 428 |
scope, |
| 429 |
defaults |
| 430 |
} = action; |
| 431 |
return { ...state, |
| 432 |
[scope]: { ...state[scope], |
| 433 |
...defaults |
| 434 |
} |
| 435 |
}; |
| 436 |
} |
| 437 |
|
| 438 |
return state; |
| 439 |
} |
| 440 |
|
| 441 |
}); |
| 442 |
/** |
| 443 |
* Reducer returning the user preferences. |
| 444 |
* |
| 445 |
* @param {Object} state Current state. |
| 446 |
* @param {Object} action Dispatched action. |
| 447 |
* |
| 448 |
* @return {Object} Updated state. |
| 449 |
*/ |
| 450 |
|
| 451 |
const preferences = (0,external_wp_data_namespaceObject.combineReducers)({ |
| 452 |
features() { |
| 453 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
| 454 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
| 455 |
|
| 456 |
if (action.type === 'SET_FEATURE_VALUE') { |
| 457 |
const { |
| 458 |
scope, |
| 459 |
featureName, |
| 460 |
value |
| 461 |
} = action; |
| 462 |
return { ...state, |
| 463 |
[scope]: { ...state[scope], |
| 464 |
[featureName]: value |
| 465 |
} |
| 466 |
}; |
| 467 |
} |
| 468 |
|
| 469 |
return state; |
| 470 |
} |
| 471 |
|
| 472 |
}); |
| 473 |
const enableItems = (0,external_wp_data_namespaceObject.combineReducers)({ |
| 474 |
singleEnableItems, |
| 475 |
multipleEnableItems |
| 476 |
}); |
| 477 |
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
| 478 |
enableItems, |
| 479 |
preferenceDefaults, |
| 480 |
preferences |
| 481 |
})); |
| 482 |
//# sourceMappingURL=reducer.js.map |
| 483 |
;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js |
| 484 |
/** |
| 485 |
* Returns an action object used in signalling that an active area should be changed. |
| 486 |
* |
| 487 |
* @param {string} itemType Type of item. |
| 488 |
* @param {string} scope Item scope. |
| 489 |
* @param {string} item Item identifier. |
| 490 |
* |
| 491 |
* @return {Object} Action object. |
| 492 |
*/ |
| 493 |
function setSingleEnableItem(itemType, scope, item) { |
| 494 |
return { |
| 495 |
type: 'SET_SINGLE_ENABLE_ITEM', |
| 496 |
itemType, |
| 497 |
scope, |
| 498 |
item |
| 499 |
}; |
| 500 |
} |
| 501 |
/** |
| 502 |
* Returns an action object used in signalling that a complementary item should be enabled. |
| 503 |
* |
| 504 |
* @param {string} scope Complementary area scope. |
| 505 |
* @param {string} area Area identifier. |
| 506 |
* |
| 507 |
* @return {Object} Action object. |
| 508 |
*/ |
| 509 |
|
| 510 |
|
| 511 |
function enableComplementaryArea(scope, area) { |
| 512 |
return setSingleEnableItem('complementaryArea', scope, area); |
| 513 |
} |
| 514 |
/** |
| 515 |
* Returns an action object used in signalling that the complementary area of a given scope should be disabled. |
| 516 |
* |
| 517 |
* @param {string} scope Complementary area scope. |
| 518 |
* |
| 519 |
* @return {Object} Action object. |
| 520 |
*/ |
| 521 |
|
| 522 |
function disableComplementaryArea(scope) { |
| 523 |
return setSingleEnableItem('complementaryArea', scope, undefined); |
| 524 |
} |
| 525 |
/** |
| 526 |
* Returns an action object to make an area enabled/disabled. |
| 527 |
* |
| 528 |
* @param {string} itemType Type of item. |
| 529 |
* @param {string} scope Item scope. |
| 530 |
* @param {string} item Item identifier. |
| 531 |
* @param {boolean} isEnable Boolean indicating if an area should be pinned or not. |
| 532 |
* |
| 533 |
* @return {Object} Action object. |
| 534 |
*/ |
| 535 |
|
| 536 |
function setMultipleEnableItem(itemType, scope, item, isEnable) { |
| 537 |
return { |
| 538 |
type: 'SET_MULTIPLE_ENABLE_ITEM', |
| 539 |
itemType, |
| 540 |
scope, |
| 541 |
item, |
| 542 |
isEnable |
| 543 |
}; |
| 544 |
} |
| 545 |
/** |
| 546 |
* Returns an action object used in signalling that an item should be pinned. |
| 547 |
* |
| 548 |
* @param {string} scope Item scope. |
| 549 |
* @param {string} itemId Item identifier. |
| 550 |
* |
| 551 |
* @return {Object} Action object. |
| 552 |
*/ |
| 553 |
|
| 554 |
|
| 555 |
function pinItem(scope, itemId) { |
| 556 |
return setMultipleEnableItem('pinnedItems', scope, itemId, true); |
| 557 |
} |
| 558 |
/** |
| 559 |
* Returns an action object used in signalling that an item should be unpinned. |
| 560 |
* |
| 561 |
* @param {string} scope Item scope. |
| 562 |
* @param {string} itemId Item identifier. |
| 563 |
* |
| 564 |
* @return {Object} Action object. |
| 565 |
*/ |
| 566 |
|
| 567 |
function unpinItem(scope, itemId) { |
| 568 |
return setMultipleEnableItem('pinnedItems', scope, itemId, false); |
| 569 |
} |
| 570 |
/** |
| 571 |
* Returns an action object used in signalling that a feature should be toggled. |
| 572 |
* |
| 573 |
* @param {string} scope The feature scope (e.g. core/edit-post). |
| 574 |
* @param {string} featureName The feature name. |
| 575 |
*/ |
| 576 |
|
| 577 |
function toggleFeature(scope, featureName) { |
| 578 |
return function (_ref) { |
| 579 |
let { |
| 580 |
select, |
| 581 |
dispatch |
| 582 |
} = _ref; |
| 583 |
const currentValue = select.isFeatureActive(scope, featureName); |
| 584 |
dispatch.setFeatureValue(scope, featureName, !currentValue); |
| 585 |
}; |
| 586 |
} |
| 587 |
/** |
| 588 |
* Returns an action object used in signalling that a feature should be set to |
| 589 |
* a true or false value |
| 590 |
* |
| 591 |
* @param {string} scope The feature scope (e.g. core/edit-post). |
| 592 |
* @param {string} featureName The feature name. |
| 593 |
* @param {boolean} value The value to set. |
| 594 |
* |
| 595 |
* @return {Object} Action object. |
| 596 |
*/ |
| 597 |
|
| 598 |
function setFeatureValue(scope, featureName, value) { |
| 599 |
return { |
| 600 |
type: 'SET_FEATURE_VALUE', |
| 601 |
scope, |
| 602 |
featureName, |
| 603 |
value: !!value |
| 604 |
}; |
| 605 |
} |
| 606 |
/** |
| 607 |
* Returns an action object used in signalling that defaults should be set for features. |
| 608 |
* |
| 609 |
* @param {string} scope The feature scope (e.g. core/edit-post). |
| 610 |
* @param {Object<string, boolean>} defaults A key/value map of feature names to values. |
| 611 |
* |
| 612 |
* @return {Object} Action object. |
| 613 |
*/ |
| 614 |
|
| 615 |
function setFeatureDefaults(scope, defaults) { |
| 616 |
return { |
| 617 |
type: 'SET_FEATURE_DEFAULTS', |
| 618 |
scope, |
| 619 |
defaults |
| 620 |
}; |
| 621 |
} |
| 622 |
//# sourceMappingURL=actions.js.map |
| 623 |
;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js |
| 624 |
/** |
| 625 |
* External dependencies |
| 626 |
*/ |
| 627 |
|
| 628 |
/** |
| 629 |
* Returns the item that is enabled in a given scope. |
| 630 |
* |
| 631 |
* @param {Object} state Global application state. |
| 632 |
* @param {string} itemType Type of item. |
| 633 |
* @param {string} scope Item scope. |
| 634 |
* |
| 635 |
* @return {?string|null} The item that is enabled in the passed scope and type. |
| 636 |
*/ |
| 637 |
|
| 638 |
function getSingleEnableItem(state, itemType, scope) { |
| 639 |
return (0,external_lodash_namespaceObject.get)(state.enableItems.singleEnableItems, [itemType, scope]); |
| 640 |
} |
| 641 |
/** |
| 642 |
* Returns the complementary area that is active in a given scope. |
| 643 |
* |
| 644 |
* @param {Object} state Global application state. |
| 645 |
* @param {string} scope Item scope. |
| 646 |
* |
| 647 |
* @return {string} The complementary area that is active in the given scope. |
| 648 |
*/ |
| 649 |
|
| 650 |
|
| 651 |
function getActiveComplementaryArea(state, scope) { |
| 652 |
return getSingleEnableItem(state, 'complementaryArea', scope); |
| 653 |
} |
| 654 |
/** |
| 655 |
* Returns a boolean indicating if an item is enabled or not in a given scope. |
| 656 |
* |
| 657 |
* @param {Object} state Global application state. |
| 658 |
* @param {string} itemType Type of item. |
| 659 |
* @param {string} scope Scope. |
| 660 |
* @param {string} item Item to check. |
| 661 |
* |
| 662 |
* @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. |
| 663 |
*/ |
| 664 |
|
| 665 |
function isMultipleEnabledItemEnabled(state, itemType, scope, item) { |
| 666 |
return (0,external_lodash_namespaceObject.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]); |
| 667 |
} |
| 668 |
/** |
| 669 |
* Returns a boolean indicating if an item is pinned or not. |
| 670 |
* |
| 671 |
* @param {Object} state Global application state. |
| 672 |
* @param {string} scope Scope. |
| 673 |
* @param {string} item Item to check. |
| 674 |
* |
| 675 |
* @return {boolean} True if the item is pinned and false otherwise. |
| 676 |
*/ |
| 677 |
|
| 678 |
|
| 679 |
function isItemPinned(state, scope, item) { |
| 680 |
return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false; |
| 681 |
} |
| 682 |
/** |
| 683 |
* Returns a boolean indicating whether a feature is active for a particular |
| 684 |
* scope. |
| 685 |
* |
| 686 |
* @param {Object} state The store state. |
| 687 |
* @param {string} scope The scope of the feature (e.g. core/edit-post). |
| 688 |
* @param {string} featureName The name of the feature. |
| 689 |
* |
| 690 |
* @return {boolean} Is the feature enabled? |
| 691 |
*/ |
| 692 |
|
| 693 |
function isFeatureActive(state, scope, featureName) { |
| 694 |
var _state$preferences$fe, _state$preferenceDefa; |
| 695 |
|
| 696 |
const featureValue = (_state$preferences$fe = state.preferences.features[scope]) === null || _state$preferences$fe === void 0 ? void 0 : _state$preferences$fe[featureName]; |
| 697 |
const defaultedFeatureValue = featureValue !== undefined ? featureValue : (_state$preferenceDefa = state.preferenceDefaults.features[scope]) === null || _state$preferenceDefa === void 0 ? void 0 : _state$preferenceDefa[featureName]; |
| 698 |
return !!defaultedFeatureValue; |
| 699 |
} |
| 700 |
//# sourceMappingURL=selectors.js.map |
| 701 |
;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js |
| 702 |
/** |
| 703 |
* The identifier for the data store. |
| 704 |
* |
| 705 |
* @type {string} |
| 706 |
*/ |
| 707 |
const STORE_NAME = 'core/interface'; |
| 708 |
//# sourceMappingURL=constants.js.map |
| 709 |
;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js |
| 710 |
/** |
| 711 |
* WordPress dependencies |
| 712 |
*/ |
| 713 |
|
| 714 |
/** |
| 715 |
* Internal dependencies |
| 716 |
*/ |
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
/** |
| 723 |
* Store definition for the interface namespace. |
| 724 |
* |
| 725 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
| 726 |
* |
| 727 |
* @type {Object} |
| 728 |
*/ |
| 729 |
|
| 730 |
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
| 731 |
reducer: reducer, |
| 732 |
actions: actions_namespaceObject, |
| 733 |
selectors: selectors_namespaceObject, |
| 734 |
persist: ['enableItems', 'preferences'], |
| 735 |
__experimentalUseThunks: true |
| 736 |
}); // Once we build a more generic persistence plugin that works across types of stores |
| 737 |
// we'd be able to replace this with a register call. |
| 738 |
|
| 739 |
(0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, { |
| 740 |
reducer: reducer, |
| 741 |
actions: actions_namespaceObject, |
| 742 |
selectors: selectors_namespaceObject, |
| 743 |
persist: ['enableItems', 'preferences'], |
| 744 |
__experimentalUseThunks: true |
| 745 |
}); |
| 746 |
//# sourceMappingURL=index.js.map |
| 747 |
;// CONCATENATED MODULE: external ["wp","plugins"] |
| 748 |
var external_wp_plugins_namespaceObject = window["wp"]["plugins"]; |
| 749 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js |
| 750 |
/** |
| 751 |
* WordPress dependencies |
| 752 |
*/ |
| 753 |
|
| 754 |
/* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { |
| 755 |
return { |
| 756 |
icon: ownProps.icon || context.icon, |
| 757 |
identifier: ownProps.identifier || `${context.name}/${ownProps.name}` |
| 758 |
}; |
| 759 |
})); |
| 760 |
//# sourceMappingURL=index.js.map |
| 761 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js |
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
/** |
| 766 |
* External dependencies |
| 767 |
*/ |
| 768 |
|
| 769 |
/** |
| 770 |
* WordPress dependencies |
| 771 |
*/ |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
/** |
| 776 |
* Internal dependencies |
| 777 |
*/ |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
function ComplementaryAreaToggle(_ref) { |
| 783 |
let { |
| 784 |
as = external_wp_components_namespaceObject.Button, |
| 785 |
scope, |
| 786 |
identifier, |
| 787 |
icon, |
| 788 |
selectedIcon, |
| 789 |
...props |
| 790 |
} = _ref; |
| 791 |
const ComponentToUse = as; |
| 792 |
const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]); |
| 793 |
const { |
| 794 |
enableComplementaryArea, |
| 795 |
disableComplementaryArea |
| 796 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 797 |
return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({ |
| 798 |
icon: selectedIcon && isSelected ? selectedIcon : icon, |
| 799 |
onClick: () => { |
| 800 |
if (isSelected) { |
| 801 |
disableComplementaryArea(scope); |
| 802 |
} else { |
| 803 |
enableComplementaryArea(scope, identifier); |
| 804 |
} |
| 805 |
} |
| 806 |
}, (0,external_lodash_namespaceObject.omit)(props, ['name']))); |
| 807 |
} |
| 808 |
|
| 809 |
/* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle)); |
| 810 |
//# sourceMappingURL=index.js.map |
| 811 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js |
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
/** |
| 816 |
* External dependencies |
| 817 |
*/ |
| 818 |
|
| 819 |
/** |
| 820 |
* WordPress dependencies |
| 821 |
*/ |
| 822 |
|
| 823 |
|
| 824 |
/** |
| 825 |
* Internal dependencies |
| 826 |
*/ |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
const ComplementaryAreaHeader = _ref => { |
| 831 |
let { |
| 832 |
smallScreenTitle, |
| 833 |
children, |
| 834 |
className, |
| 835 |
toggleButtonProps |
| 836 |
} = _ref; |
| 837 |
const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({ |
| 838 |
icon: close_small |
| 839 |
}, toggleButtonProps)); |
| 840 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 841 |
className: "components-panel__header interface-complementary-area-header__small" |
| 842 |
}, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", { |
| 843 |
className: "interface-complementary-area-header__small-title" |
| 844 |
}, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 845 |
className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className), |
| 846 |
tabIndex: -1 |
| 847 |
}, children, toggleButton)); |
| 848 |
}; |
| 849 |
|
| 850 |
/* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader); |
| 851 |
//# sourceMappingURL=index.js.map |
| 852 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js |
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
/** |
| 857 |
* External dependencies |
| 858 |
*/ |
| 859 |
|
| 860 |
/** |
| 861 |
* WordPress dependencies |
| 862 |
*/ |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
function ActionItemSlot(_ref) { |
| 868 |
let { |
| 869 |
name, |
| 870 |
as: Component = external_wp_components_namespaceObject.ButtonGroup, |
| 871 |
fillProps = {}, |
| 872 |
bubblesVirtually, |
| 873 |
...props |
| 874 |
} = _ref; |
| 875 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { |
| 876 |
name: name, |
| 877 |
bubblesVirtually: bubblesVirtually, |
| 878 |
fillProps: fillProps |
| 879 |
}, fills => { |
| 880 |
if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) { |
| 881 |
return null; |
| 882 |
} // Special handling exists for backward compatibility. |
| 883 |
// It ensures that menu items created by plugin authors aren't |
| 884 |
// duplicated with automatically injected menu items coming |
| 885 |
// from pinnable plugin sidebars. |
| 886 |
// @see https://github.com/WordPress/gutenberg/issues/14457 |
| 887 |
|
| 888 |
|
| 889 |
const initializedByPlugins = []; |
| 890 |
external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => { |
| 891 |
let { |
| 892 |
props: { |
| 893 |
__unstableExplicitMenuItem, |
| 894 |
__unstableTarget |
| 895 |
} |
| 896 |
} = _ref2; |
| 897 |
|
| 898 |
if (__unstableTarget && __unstableExplicitMenuItem) { |
| 899 |
initializedByPlugins.push(__unstableTarget); |
| 900 |
} |
| 901 |
}); |
| 902 |
const children = external_wp_element_namespaceObject.Children.map(fills, child => { |
| 903 |
if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) { |
| 904 |
return null; |
| 905 |
} |
| 906 |
|
| 907 |
return child; |
| 908 |
}); |
| 909 |
return (0,external_wp_element_namespaceObject.createElement)(Component, props, children); |
| 910 |
}); |
| 911 |
} |
| 912 |
|
| 913 |
function ActionItem(_ref3) { |
| 914 |
let { |
| 915 |
name, |
| 916 |
as: Component = external_wp_components_namespaceObject.Button, |
| 917 |
onClick, |
| 918 |
...props |
| 919 |
} = _ref3; |
| 920 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { |
| 921 |
name: name |
| 922 |
}, _ref4 => { |
| 923 |
let { |
| 924 |
onClick: fpOnClick |
| 925 |
} = _ref4; |
| 926 |
return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({ |
| 927 |
onClick: onClick || fpOnClick ? function () { |
| 928 |
(onClick || external_lodash_namespaceObject.noop)(...arguments); |
| 929 |
(fpOnClick || external_lodash_namespaceObject.noop)(...arguments); |
| 930 |
} : undefined |
| 931 |
}, props)); |
| 932 |
}); |
| 933 |
} |
| 934 |
|
| 935 |
ActionItem.Slot = ActionItemSlot; |
| 936 |
/* harmony default export */ var action_item = (ActionItem); |
| 937 |
//# sourceMappingURL=index.js.map |
| 938 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js |
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
/** |
| 943 |
* External dependencies |
| 944 |
*/ |
| 945 |
|
| 946 |
/** |
| 947 |
* WordPress dependencies |
| 948 |
*/ |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
/** |
| 953 |
* Internal dependencies |
| 954 |
*/ |
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility. |
| 960 |
// They are removed so they don't leak to DOM elements. |
| 961 |
// @see https://github.com/WordPress/gutenberg/issues/14457 |
| 962 |
(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget'])); |
| 963 |
|
| 964 |
function ComplementaryAreaMoreMenuItem(_ref) { |
| 965 |
let { |
| 966 |
scope, |
| 967 |
target, |
| 968 |
__unstableExplicitMenuItem, |
| 969 |
...props |
| 970 |
} = _ref; |
| 971 |
return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({ |
| 972 |
as: toggleProps => { |
| 973 |
return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({ |
| 974 |
__unstableExplicitMenuItem: __unstableExplicitMenuItem, |
| 975 |
__unstableTarget: `${scope}/${target}`, |
| 976 |
as: PluginsMenuItem, |
| 977 |
name: `${scope}/plugin-more-menu` |
| 978 |
}, toggleProps)); |
| 979 |
}, |
| 980 |
role: "menuitemcheckbox", |
| 981 |
selectedIcon: library_check, |
| 982 |
name: target, |
| 983 |
scope: scope |
| 984 |
}, props)); |
| 985 |
} |
| 986 |
//# sourceMappingURL=index.js.map |
| 987 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js |
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
/** |
| 992 |
* External dependencies |
| 993 |
*/ |
| 994 |
|
| 995 |
|
| 996 |
/** |
| 997 |
* WordPress dependencies |
| 998 |
*/ |
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
function PinnedItems(_ref) { |
| 1003 |
let { |
| 1004 |
scope, |
| 1005 |
...props |
| 1006 |
} = _ref; |
| 1007 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({ |
| 1008 |
name: `PinnedItems/${scope}` |
| 1009 |
}, props)); |
| 1010 |
} |
| 1011 |
|
| 1012 |
function PinnedItemsSlot(_ref2) { |
| 1013 |
let { |
| 1014 |
scope, |
| 1015 |
className, |
| 1016 |
...props |
| 1017 |
} = _ref2; |
| 1018 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({ |
| 1019 |
name: `PinnedItems/${scope}` |
| 1020 |
}, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1021 |
className: classnames_default()(className, 'interface-pinned-items') |
| 1022 |
}, fills)); |
| 1023 |
} |
| 1024 |
|
| 1025 |
PinnedItems.Slot = PinnedItemsSlot; |
| 1026 |
/* harmony default export */ var pinned_items = (PinnedItems); |
| 1027 |
//# sourceMappingURL=index.js.map |
| 1028 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
/** |
| 1033 |
* External dependencies |
| 1034 |
*/ |
| 1035 |
|
| 1036 |
/** |
| 1037 |
* WordPress dependencies |
| 1038 |
*/ |
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
/** |
| 1047 |
* Internal dependencies |
| 1048 |
*/ |
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
function ComplementaryAreaSlot(_ref) { |
| 1058 |
let { |
| 1059 |
scope, |
| 1060 |
...props |
| 1061 |
} = _ref; |
| 1062 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({ |
| 1063 |
name: `ComplementaryArea/${scope}` |
| 1064 |
}, props)); |
| 1065 |
} |
| 1066 |
|
| 1067 |
function ComplementaryAreaFill(_ref2) { |
| 1068 |
let { |
| 1069 |
scope, |
| 1070 |
children, |
| 1071 |
className |
| 1072 |
} = _ref2; |
| 1073 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { |
| 1074 |
name: `ComplementaryArea/${scope}` |
| 1075 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1076 |
className: className |
| 1077 |
}, children)); |
| 1078 |
} |
| 1079 |
|
| 1080 |
function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { |
| 1081 |
const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false); |
| 1082 |
const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false); |
| 1083 |
const { |
| 1084 |
enableComplementaryArea, |
| 1085 |
disableComplementaryArea |
| 1086 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 1087 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 1088 |
// If the complementary area is active and the editor is switching from a big to a small window size. |
| 1089 |
if (isActive && isSmall && !previousIsSmall.current) { |
| 1090 |
// Disable the complementary area. |
| 1091 |
disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big. |
| 1092 |
|
| 1093 |
shouldOpenWhenNotSmall.current = true; |
| 1094 |
} else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size |
| 1095 |
// and we are going from a small to big window size. |
| 1096 |
shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) { |
| 1097 |
// Remove the flag indicating the complementary area should be enabled. |
| 1098 |
shouldOpenWhenNotSmall.current = false; // Enable the complementary area. |
| 1099 |
|
| 1100 |
enableComplementaryArea(scope, identifier); |
| 1101 |
} else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active, |
| 1102 |
// remove the flag. |
| 1103 |
shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) { |
| 1104 |
shouldOpenWhenNotSmall.current = false; |
| 1105 |
} |
| 1106 |
|
| 1107 |
if (isSmall !== previousIsSmall.current) { |
| 1108 |
previousIsSmall.current = isSmall; |
| 1109 |
} |
| 1110 |
}, [isActive, isSmall, scope, identifier, activeArea]); |
| 1111 |
} |
| 1112 |
|
| 1113 |
function ComplementaryArea(_ref3) { |
| 1114 |
let { |
| 1115 |
children, |
| 1116 |
className, |
| 1117 |
closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'), |
| 1118 |
identifier, |
| 1119 |
header, |
| 1120 |
headerClassName, |
| 1121 |
icon, |
| 1122 |
isPinnable = true, |
| 1123 |
panelClassName, |
| 1124 |
scope, |
| 1125 |
name, |
| 1126 |
smallScreenTitle, |
| 1127 |
title, |
| 1128 |
toggleShortcut, |
| 1129 |
isActiveByDefault, |
| 1130 |
showIconLabels = false |
| 1131 |
} = _ref3; |
| 1132 |
const { |
| 1133 |
isActive, |
| 1134 |
isPinned, |
| 1135 |
activeArea, |
| 1136 |
isSmall, |
| 1137 |
isLarge |
| 1138 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 1139 |
const { |
| 1140 |
getActiveComplementaryArea, |
| 1141 |
isItemPinned |
| 1142 |
} = select(store); |
| 1143 |
|
| 1144 |
const _activeArea = getActiveComplementaryArea(scope); |
| 1145 |
|
| 1146 |
return { |
| 1147 |
isActive: _activeArea === identifier, |
| 1148 |
isPinned: isItemPinned(scope, identifier), |
| 1149 |
activeArea: _activeArea, |
| 1150 |
isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'), |
| 1151 |
isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large') |
| 1152 |
}; |
| 1153 |
}, [identifier, scope]); |
| 1154 |
useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall); |
| 1155 |
const { |
| 1156 |
enableComplementaryArea, |
| 1157 |
disableComplementaryArea, |
| 1158 |
pinItem, |
| 1159 |
unpinItem |
| 1160 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 1161 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 1162 |
if (isActiveByDefault && activeArea === undefined && !isSmall) { |
| 1163 |
enableComplementaryArea(scope, identifier); |
| 1164 |
} |
| 1165 |
}, [activeArea, isActiveByDefault, scope, identifier, isSmall]); |
| 1166 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, { |
| 1167 |
scope: scope |
| 1168 |
}, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, { |
| 1169 |
scope: scope, |
| 1170 |
identifier: identifier, |
| 1171 |
isPressed: isActive && (!showIconLabels || isLarge), |
| 1172 |
"aria-expanded": isActive, |
| 1173 |
label: title, |
| 1174 |
icon: showIconLabels ? library_check : icon, |
| 1175 |
showTooltip: !showIconLabels, |
| 1176 |
variant: showIconLabels ? 'tertiary' : undefined |
| 1177 |
})), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, { |
| 1178 |
target: name, |
| 1179 |
scope: scope, |
| 1180 |
icon: icon |
| 1181 |
}, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, { |
| 1182 |
className: classnames_default()('interface-complementary-area', className), |
| 1183 |
scope: scope |
| 1184 |
}, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, { |
| 1185 |
className: headerClassName, |
| 1186 |
closeLabel: closeLabel, |
| 1187 |
onClose: () => disableComplementaryArea(scope), |
| 1188 |
smallScreenTitle: smallScreenTitle, |
| 1189 |
toggleButtonProps: { |
| 1190 |
label: closeLabel, |
| 1191 |
shortcut: toggleShortcut, |
| 1192 |
scope, |
| 1193 |
identifier |
| 1194 |
} |
| 1195 |
}, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 1196 |
className: "interface-complementary-area__pin-unpin-item", |
| 1197 |
icon: isPinned ? star_filled : star_empty, |
| 1198 |
label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'), |
| 1199 |
onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier), |
| 1200 |
isPressed: isPinned, |
| 1201 |
"aria-expanded": isPinned |
| 1202 |
}))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, { |
| 1203 |
className: panelClassName |
| 1204 |
}, children))); |
| 1205 |
} |
| 1206 |
|
| 1207 |
const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea); |
| 1208 |
ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot; |
| 1209 |
/* harmony default export */ var complementary_area = (ComplementaryAreaWrapped); |
| 1210 |
//# sourceMappingURL=index.js.map |
| 1211 |
;// CONCATENATED MODULE: external ["wp","compose"] |
| 1212 |
var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
| 1213 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js |
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
/** |
| 1218 |
* External dependencies |
| 1219 |
*/ |
| 1220 |
|
| 1221 |
/** |
| 1222 |
* WordPress dependencies |
| 1223 |
*/ |
| 1224 |
|
| 1225 |
/** |
| 1226 |
* WordPress dependencies |
| 1227 |
*/ |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
function useHTMLClass(className) { |
| 1235 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 1236 |
const element = document && document.querySelector(`html:not(.${className})`); |
| 1237 |
|
| 1238 |
if (!element) { |
| 1239 |
return; |
| 1240 |
} |
| 1241 |
|
| 1242 |
element.classList.toggle(className); |
| 1243 |
return () => { |
| 1244 |
element.classList.toggle(className); |
| 1245 |
}; |
| 1246 |
}, [className]); |
| 1247 |
} |
| 1248 |
|
| 1249 |
function InterfaceSkeleton(_ref, ref) { |
| 1250 |
let { |
| 1251 |
footer, |
| 1252 |
header, |
| 1253 |
sidebar, |
| 1254 |
secondarySidebar, |
| 1255 |
notices, |
| 1256 |
content, |
| 1257 |
drawer, |
| 1258 |
actions, |
| 1259 |
labels, |
| 1260 |
className, |
| 1261 |
shortcuts |
| 1262 |
} = _ref; |
| 1263 |
const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts); |
| 1264 |
useHTMLClass('interface-interface-skeleton__html-container'); |
| 1265 |
const defaultLabels = { |
| 1266 |
/* translators: accessibility text for the nav bar landmark region. */ |
| 1267 |
drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'), |
| 1268 |
|
| 1269 |
/* translators: accessibility text for the top bar landmark region. */ |
| 1270 |
header: (0,external_wp_i18n_namespaceObject.__)('Header'), |
| 1271 |
|
| 1272 |
/* translators: accessibility text for the content landmark region. */ |
| 1273 |
body: (0,external_wp_i18n_namespaceObject.__)('Content'), |
| 1274 |
|
| 1275 |
/* translators: accessibility text for the secondary sidebar landmark region. */ |
| 1276 |
secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'), |
| 1277 |
|
| 1278 |
/* translators: accessibility text for the settings landmark region. */ |
| 1279 |
sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'), |
| 1280 |
|
| 1281 |
/* translators: accessibility text for the publish landmark region. */ |
| 1282 |
actions: (0,external_wp_i18n_namespaceObject.__)('Publish'), |
| 1283 |
|
| 1284 |
/* translators: accessibility text for the footer landmark region. */ |
| 1285 |
footer: (0,external_wp_i18n_namespaceObject.__)('Footer') |
| 1286 |
}; |
| 1287 |
const mergedLabels = { ...defaultLabels, |
| 1288 |
...labels |
| 1289 |
}; |
| 1290 |
return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, { |
| 1291 |
ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]), |
| 1292 |
className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer') |
| 1293 |
}), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1294 |
className: "interface-interface-skeleton__drawer", |
| 1295 |
role: "region", |
| 1296 |
"aria-label": mergedLabels.drawer, |
| 1297 |
tabIndex: "-1" |
| 1298 |
}, drawer), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1299 |
className: "interface-interface-skeleton__editor" |
| 1300 |
}, !!header && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1301 |
className: "interface-interface-skeleton__header", |
| 1302 |
role: "region", |
| 1303 |
"aria-label": mergedLabels.header, |
| 1304 |
tabIndex: "-1" |
| 1305 |
}, header), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1306 |
className: "interface-interface-skeleton__body" |
| 1307 |
}, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1308 |
className: "interface-interface-skeleton__secondary-sidebar", |
| 1309 |
role: "region", |
| 1310 |
"aria-label": mergedLabels.secondarySidebar, |
| 1311 |
tabIndex: "-1" |
| 1312 |
}, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1313 |
className: "interface-interface-skeleton__notices" |
| 1314 |
}, notices), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1315 |
className: "interface-interface-skeleton__content", |
| 1316 |
role: "region", |
| 1317 |
"aria-label": mergedLabels.body, |
| 1318 |
tabIndex: "-1" |
| 1319 |
}, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1320 |
className: "interface-interface-skeleton__sidebar", |
| 1321 |
role: "region", |
| 1322 |
"aria-label": mergedLabels.sidebar, |
| 1323 |
tabIndex: "-1" |
| 1324 |
}, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1325 |
className: "interface-interface-skeleton__actions", |
| 1326 |
role: "region", |
| 1327 |
"aria-label": mergedLabels.actions, |
| 1328 |
tabIndex: "-1" |
| 1329 |
}, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 1330 |
className: "interface-interface-skeleton__footer", |
| 1331 |
role: "region", |
| 1332 |
"aria-label": mergedLabels.footer, |
| 1333 |
tabIndex: "-1" |
| 1334 |
}, footer)); |
| 1335 |
} |
| 1336 |
|
| 1337 |
/* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton)); |
| 1338 |
//# sourceMappingURL=index.js.map |
| 1339 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js |
| 1340 |
|
| 1341 |
|
| 1342 |
/** |
| 1343 |
* WordPress dependencies |
| 1344 |
*/ |
| 1345 |
|
| 1346 |
const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 1347 |
xmlns: "http://www.w3.org/2000/svg", |
| 1348 |
viewBox: "0 0 24 24" |
| 1349 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 1350 |
d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" |
| 1351 |
})); |
| 1352 |
/* harmony default export */ var more_vertical = (moreVertical); |
| 1353 |
//# sourceMappingURL=more-vertical.js.map |
| 1354 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js |
| 1355 |
|
| 1356 |
|
| 1357 |
/** |
| 1358 |
* External dependencies |
| 1359 |
*/ |
| 1360 |
|
| 1361 |
/** |
| 1362 |
* WordPress dependencies |
| 1363 |
*/ |
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
function MoreMenuDropdown(_ref) { |
| 1369 |
let { |
| 1370 |
as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu, |
| 1371 |
className, |
| 1372 |
|
| 1373 |
/* translators: button label text should, if possible, be under 16 characters. */ |
| 1374 |
label = (0,external_wp_i18n_namespaceObject.__)('Options'), |
| 1375 |
popoverProps, |
| 1376 |
toggleProps, |
| 1377 |
children |
| 1378 |
} = _ref; |
| 1379 |
return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, { |
| 1380 |
className: classnames_default()('interface-more-menu-dropdown', className), |
| 1381 |
icon: more_vertical, |
| 1382 |
label: label, |
| 1383 |
popoverProps: { |
| 1384 |
position: 'bottom left', |
| 1385 |
...popoverProps, |
| 1386 |
className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className) |
| 1387 |
}, |
| 1388 |
toggleProps: { |
| 1389 |
tooltipPosition: 'bottom', |
| 1390 |
...toggleProps |
| 1391 |
} |
| 1392 |
}, onClose => children(onClose)); |
| 1393 |
} |
| 1394 |
//# sourceMappingURL=index.js.map |
| 1395 |
;// CONCATENATED MODULE: external ["wp","a11y"] |
| 1396 |
var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
| 1397 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-feature-toggle/index.js |
| 1398 |
|
| 1399 |
|
| 1400 |
/** |
| 1401 |
* WordPress dependencies |
| 1402 |
*/ |
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
/** |
| 1409 |
* Internal dependencies |
| 1410 |
*/ |
| 1411 |
|
| 1412 |
|
| 1413 |
function MoreMenuFeatureToggle(_ref) { |
| 1414 |
let { |
| 1415 |
scope, |
| 1416 |
label, |
| 1417 |
info, |
| 1418 |
messageActivated, |
| 1419 |
messageDeactivated, |
| 1420 |
shortcut, |
| 1421 |
feature |
| 1422 |
} = _ref; |
| 1423 |
const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isFeatureActive(scope, feature), [feature]); |
| 1424 |
const { |
| 1425 |
toggleFeature |
| 1426 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 1427 |
|
| 1428 |
const speakMessage = () => { |
| 1429 |
if (isActive) { |
| 1430 |
(0,external_wp_a11y_namespaceObject.speak)(messageDeactivated || (0,external_wp_i18n_namespaceObject.__)('Feature deactivated')); |
| 1431 |
} else { |
| 1432 |
(0,external_wp_a11y_namespaceObject.speak)(messageActivated || (0,external_wp_i18n_namespaceObject.__)('Feature activated')); |
| 1433 |
} |
| 1434 |
}; |
| 1435 |
|
| 1436 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
| 1437 |
icon: isActive && library_check, |
| 1438 |
isSelected: isActive, |
| 1439 |
onClick: () => { |
| 1440 |
toggleFeature(scope, feature); |
| 1441 |
speakMessage(); |
| 1442 |
}, |
| 1443 |
role: "menuitemcheckbox", |
| 1444 |
info: info, |
| 1445 |
shortcut: shortcut |
| 1446 |
}, label); |
| 1447 |
} |
| 1448 |
//# sourceMappingURL=index.js.map |
| 1449 |
;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js |
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
//# sourceMappingURL=index.js.map |
| 1459 |
;// CONCATENATED MODULE: ./packages/interface/build-module/index.js |
| 1460 |
|
| 1461 |
|
| 1462 |
//# sourceMappingURL=index.js.map |
| 1463 |
;// CONCATENATED MODULE: external ["wp","apiFetch"] |
| 1464 |
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; |
| 1465 |
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); |
| 1466 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/reducer.js |
| 1467 |
/** |
| 1468 |
* WordPress dependencies |
| 1469 |
*/ |
| 1470 |
|
| 1471 |
/** |
| 1472 |
* Controls the open state of the widget areas. |
| 1473 |
* |
| 1474 |
* @param {Object} state Redux state. |
| 1475 |
* @param {Object} action Redux action. |
| 1476 |
* |
| 1477 |
* @return {Array} Updated state. |
| 1478 |
*/ |
| 1479 |
|
| 1480 |
function widgetAreasOpenState() { |
| 1481 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
| 1482 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
| 1483 |
const { |
| 1484 |
type |
| 1485 |
} = action; |
| 1486 |
|
| 1487 |
switch (type) { |
| 1488 |
case 'SET_WIDGET_AREAS_OPEN_STATE': |
| 1489 |
{ |
| 1490 |
return action.widgetAreasOpenState; |
| 1491 |
} |
| 1492 |
|
| 1493 |
case 'SET_IS_WIDGET_AREA_OPEN': |
| 1494 |
{ |
| 1495 |
const { |
| 1496 |
clientId, |
| 1497 |
isOpen |
| 1498 |
} = action; |
| 1499 |
return { ...state, |
| 1500 |
[clientId]: isOpen |
| 1501 |
}; |
| 1502 |
} |
| 1503 |
|
| 1504 |
default: |
| 1505 |
{ |
| 1506 |
return state; |
| 1507 |
} |
| 1508 |
} |
| 1509 |
} |
| 1510 |
/** |
| 1511 |
* Reducer to set the block inserter panel open or closed. |
| 1512 |
* |
| 1513 |
* Note: this reducer interacts with the list view panel reducer |
| 1514 |
* to make sure that only one of the two panels is open at the same time. |
| 1515 |
* |
| 1516 |
* @param {Object} state Current state. |
| 1517 |
* @param {Object} action Dispatched action. |
| 1518 |
*/ |
| 1519 |
|
| 1520 |
function blockInserterPanel() { |
| 1521 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 1522 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
| 1523 |
|
| 1524 |
switch (action.type) { |
| 1525 |
case 'SET_IS_LIST_VIEW_OPENED': |
| 1526 |
return action.isOpen ? false : state; |
| 1527 |
|
| 1528 |
case 'SET_IS_INSERTER_OPENED': |
| 1529 |
return action.value; |
| 1530 |
} |
| 1531 |
|
| 1532 |
return state; |
| 1533 |
} |
| 1534 |
/** |
| 1535 |
* Reducer to set the list view panel open or closed. |
| 1536 |
* |
| 1537 |
* Note: this reducer interacts with the inserter panel reducer |
| 1538 |
* to make sure that only one of the two panels is open at the same time. |
| 1539 |
* |
| 1540 |
* @param {Object} state Current state. |
| 1541 |
* @param {Object} action Dispatched action. |
| 1542 |
*/ |
| 1543 |
|
| 1544 |
function listViewPanel() { |
| 1545 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 1546 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
| 1547 |
|
| 1548 |
switch (action.type) { |
| 1549 |
case 'SET_IS_INSERTER_OPENED': |
| 1550 |
return action.value ? false : state; |
| 1551 |
|
| 1552 |
case 'SET_IS_LIST_VIEW_OPENED': |
| 1553 |
return action.isOpen; |
| 1554 |
} |
| 1555 |
|
| 1556 |
return state; |
| 1557 |
} |
| 1558 |
/* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
| 1559 |
blockInserterPanel, |
| 1560 |
listViewPanel, |
| 1561 |
widgetAreasOpenState |
| 1562 |
})); |
| 1563 |
//# sourceMappingURL=reducer.js.map |
| 1564 |
;// CONCATENATED MODULE: external ["wp","notices"] |
| 1565 |
var external_wp_notices_namespaceObject = window["wp"]["notices"]; |
| 1566 |
;// CONCATENATED MODULE: external ["wp","blockEditor"] |
| 1567 |
var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
| 1568 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/transformers.js |
| 1569 |
/** |
| 1570 |
* WordPress dependencies |
| 1571 |
*/ |
| 1572 |
|
| 1573 |
|
| 1574 |
/** |
| 1575 |
* Converts a widget entity record into a block. |
| 1576 |
* |
| 1577 |
* @param {Object} widget The widget entity record. |
| 1578 |
* @return {Object} a block (converted from the entity record). |
| 1579 |
*/ |
| 1580 |
|
| 1581 |
function transformWidgetToBlock(widget) { |
| 1582 |
if (widget.id_base === 'block') { |
| 1583 |
const parsedBlocks = (0,external_wp_blocks_namespaceObject.parse)(widget.instance.raw.content); |
| 1584 |
|
| 1585 |
if (!parsedBlocks.length) { |
| 1586 |
return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)((0,external_wp_blocks_namespaceObject.createBlock)('core/paragraph', {}, []), widget.id); |
| 1587 |
} |
| 1588 |
|
| 1589 |
return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(parsedBlocks[0], widget.id); |
| 1590 |
} |
| 1591 |
|
| 1592 |
let attributes; |
| 1593 |
|
| 1594 |
if (widget._embedded.about[0].is_multi) { |
| 1595 |
attributes = { |
| 1596 |
idBase: widget.id_base, |
| 1597 |
instance: widget.instance |
| 1598 |
}; |
| 1599 |
} else { |
| 1600 |
attributes = { |
| 1601 |
id: widget.id |
| 1602 |
}; |
| 1603 |
} |
| 1604 |
|
| 1605 |
return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)((0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', attributes, []), widget.id); |
| 1606 |
} |
| 1607 |
/** |
| 1608 |
* Converts a block to a widget entity record. |
| 1609 |
* |
| 1610 |
* @param {Object} block The block. |
| 1611 |
* @param {Object?} relatedWidget A related widget entity record from the API (optional). |
| 1612 |
* @return {Object} the widget object (converted from block). |
| 1613 |
*/ |
| 1614 |
|
| 1615 |
function transformBlockToWidget(block) { |
| 1616 |
let relatedWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| 1617 |
let widget; |
| 1618 |
const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance); |
| 1619 |
|
| 1620 |
if (isValidLegacyWidgetBlock) { |
| 1621 |
var _block$attributes$id, _block$attributes$idB, _block$attributes$ins; |
| 1622 |
|
| 1623 |
widget = { ...relatedWidget, |
| 1624 |
id: (_block$attributes$id = block.attributes.id) !== null && _block$attributes$id !== void 0 ? _block$attributes$id : relatedWidget.id, |
| 1625 |
id_base: (_block$attributes$idB = block.attributes.idBase) !== null && _block$attributes$idB !== void 0 ? _block$attributes$idB : relatedWidget.id_base, |
| 1626 |
instance: (_block$attributes$ins = block.attributes.instance) !== null && _block$attributes$ins !== void 0 ? _block$attributes$ins : relatedWidget.instance |
| 1627 |
}; |
| 1628 |
} else { |
| 1629 |
widget = { ...relatedWidget, |
| 1630 |
id_base: 'block', |
| 1631 |
instance: { |
| 1632 |
raw: { |
| 1633 |
content: (0,external_wp_blocks_namespaceObject.serialize)(block) |
| 1634 |
} |
| 1635 |
} |
| 1636 |
}; |
| 1637 |
} // Delete read-only properties. |
| 1638 |
|
| 1639 |
|
| 1640 |
delete widget.rendered; |
| 1641 |
delete widget.rendered_form; |
| 1642 |
return widget; |
| 1643 |
} |
| 1644 |
//# sourceMappingURL=transformers.js.map |
| 1645 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/utils.js |
| 1646 |
/** |
| 1647 |
* "Kind" of the navigation post. |
| 1648 |
* |
| 1649 |
* @type {string} |
| 1650 |
*/ |
| 1651 |
const KIND = 'root'; |
| 1652 |
/** |
| 1653 |
* "post type" of the navigation post. |
| 1654 |
* |
| 1655 |
* @type {string} |
| 1656 |
*/ |
| 1657 |
|
| 1658 |
const WIDGET_AREA_ENTITY_TYPE = 'sidebar'; |
| 1659 |
/** |
| 1660 |
* "post type" of the widget area post. |
| 1661 |
* |
| 1662 |
* @type {string} |
| 1663 |
*/ |
| 1664 |
|
| 1665 |
const POST_TYPE = 'postType'; |
| 1666 |
/** |
| 1667 |
* Builds an ID for a new widget area post. |
| 1668 |
* |
| 1669 |
* @param {number} widgetAreaId Widget area id. |
| 1670 |
* @return {string} An ID. |
| 1671 |
*/ |
| 1672 |
|
| 1673 |
const buildWidgetAreaPostId = widgetAreaId => `widget-area-${widgetAreaId}`; |
| 1674 |
/** |
| 1675 |
* Builds an ID for a global widget areas post. |
| 1676 |
* |
| 1677 |
* @return {string} An ID. |
| 1678 |
*/ |
| 1679 |
|
| 1680 |
const buildWidgetAreasPostId = () => `widget-areas`; |
| 1681 |
/** |
| 1682 |
* Builds a query to resolve sidebars. |
| 1683 |
* |
| 1684 |
* @return {Object} Query. |
| 1685 |
*/ |
| 1686 |
|
| 1687 |
function buildWidgetAreasQuery() { |
| 1688 |
return { |
| 1689 |
per_page: -1 |
| 1690 |
}; |
| 1691 |
} |
| 1692 |
/** |
| 1693 |
* Builds a query to resolve widgets. |
| 1694 |
* |
| 1695 |
* @return {Object} Query. |
| 1696 |
*/ |
| 1697 |
|
| 1698 |
function buildWidgetsQuery() { |
| 1699 |
return { |
| 1700 |
per_page: -1, |
| 1701 |
_embed: 'about' |
| 1702 |
}; |
| 1703 |
} |
| 1704 |
/** |
| 1705 |
* Creates a stub post with given id and set of blocks. Used as a governing entity records |
| 1706 |
* for all widget areas. |
| 1707 |
* |
| 1708 |
* @param {string} id Post ID. |
| 1709 |
* @param {Array} blocks The list of blocks. |
| 1710 |
* @return {Object} A stub post object formatted in compliance with the data layer. |
| 1711 |
*/ |
| 1712 |
|
| 1713 |
const createStubPost = (id, blocks) => ({ |
| 1714 |
id, |
| 1715 |
slug: id, |
| 1716 |
status: 'draft', |
| 1717 |
type: 'page', |
| 1718 |
blocks, |
| 1719 |
meta: { |
| 1720 |
widgetAreaId: id |
| 1721 |
} |
| 1722 |
}); |
| 1723 |
//# sourceMappingURL=utils.js.map |
| 1724 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/constants.js |
| 1725 |
/** |
| 1726 |
* Module Constants |
| 1727 |
*/ |
| 1728 |
const constants_STORE_NAME = 'core/edit-widgets'; |
| 1729 |
//# sourceMappingURL=constants.js.map |
| 1730 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/actions.js |
| 1731 |
/** |
| 1732 |
* WordPress dependencies |
| 1733 |
*/ |
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
/** |
| 1741 |
* Internal dependencies |
| 1742 |
*/ |
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
/** |
| 1748 |
* Persists a stub post with given ID to core data store. The post is meant to be in-memory only and |
| 1749 |
* shouldn't be saved via the API. |
| 1750 |
* |
| 1751 |
* @param {string} id Post ID. |
| 1752 |
* @param {Array} blocks Blocks the post should consist of. |
| 1753 |
* @return {Object} The post object. |
| 1754 |
*/ |
| 1755 |
|
| 1756 |
const persistStubPost = (id, blocks) => _ref => { |
| 1757 |
let { |
| 1758 |
registry |
| 1759 |
} = _ref; |
| 1760 |
const stubPost = createStubPost(id, blocks); |
| 1761 |
registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(KIND, POST_TYPE, stubPost, { |
| 1762 |
id: stubPost.id |
| 1763 |
}, false); |
| 1764 |
return stubPost; |
| 1765 |
}; |
| 1766 |
/** |
| 1767 |
* Converts all the blocks from edited widget areas into widgets, |
| 1768 |
* and submits a batch request to save everything at once. |
| 1769 |
* |
| 1770 |
* Creates a snackbar notice on either success or error. |
| 1771 |
* |
| 1772 |
* @return {Function} An action creator. |
| 1773 |
*/ |
| 1774 |
|
| 1775 |
const saveEditedWidgetAreas = () => async _ref2 => { |
| 1776 |
let { |
| 1777 |
select, |
| 1778 |
dispatch, |
| 1779 |
registry |
| 1780 |
} = _ref2; |
| 1781 |
const editedWidgetAreas = select.getEditedWidgetAreas(); |
| 1782 |
|
| 1783 |
if (!(editedWidgetAreas !== null && editedWidgetAreas !== void 0 && editedWidgetAreas.length)) { |
| 1784 |
return; |
| 1785 |
} |
| 1786 |
|
| 1787 |
try { |
| 1788 |
await dispatch.saveWidgetAreas(editedWidgetAreas); |
| 1789 |
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Widgets saved.'), { |
| 1790 |
type: 'snackbar' |
| 1791 |
}); |
| 1792 |
} catch (e) { |
| 1793 |
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice( |
| 1794 |
/* translators: %s: The error message. */ |
| 1795 |
(0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('There was an error. %s'), e.message), { |
| 1796 |
type: 'snackbar' |
| 1797 |
}); |
| 1798 |
} |
| 1799 |
}; |
| 1800 |
/** |
| 1801 |
* Converts all the blocks from specified widget areas into widgets, |
| 1802 |
* and submits a batch request to save everything at once. |
| 1803 |
* |
| 1804 |
* @param {Object[]} widgetAreas Widget areas to save. |
| 1805 |
* @return {Function} An action creator. |
| 1806 |
*/ |
| 1807 |
|
| 1808 |
const saveWidgetAreas = widgetAreas => async _ref3 => { |
| 1809 |
let { |
| 1810 |
dispatch, |
| 1811 |
registry |
| 1812 |
} = _ref3; |
| 1813 |
|
| 1814 |
try { |
| 1815 |
for (const widgetArea of widgetAreas) { |
| 1816 |
await dispatch.saveWidgetArea(widgetArea.id); |
| 1817 |
} |
| 1818 |
} finally { |
| 1819 |
// saveEditedEntityRecord resets the resolution status, let's fix it manually |
| 1820 |
await registry.dispatch(external_wp_coreData_namespaceObject.store).finishResolution('getEntityRecord', KIND, WIDGET_AREA_ENTITY_TYPE, buildWidgetAreasQuery()); |
| 1821 |
} |
| 1822 |
}; |
| 1823 |
/** |
| 1824 |
* Converts all the blocks from a widget area specified by ID into widgets, |
| 1825 |
* and submits a batch request to save everything at once. |
| 1826 |
* |
| 1827 |
* @param {string} widgetAreaId ID of the widget area to process. |
| 1828 |
* @return {Function} An action creator. |
| 1829 |
*/ |
| 1830 |
|
| 1831 |
const saveWidgetArea = widgetAreaId => async _ref4 => { |
| 1832 |
let { |
| 1833 |
dispatch, |
| 1834 |
select, |
| 1835 |
registry |
| 1836 |
} = _ref4; |
| 1837 |
const widgets = select.getWidgets(); |
| 1838 |
const post = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetAreaId)); // Get all widgets from this area |
| 1839 |
|
| 1840 |
const areaWidgets = Object.values(widgets).filter(_ref5 => { |
| 1841 |
let { |
| 1842 |
sidebar |
| 1843 |
} = _ref5; |
| 1844 |
return sidebar === widgetAreaId; |
| 1845 |
}); // Remove all duplicate reference widget instances for legacy widgets. |
| 1846 |
// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget |
| 1847 |
// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to |
| 1848 |
// save multiple instances of these in different sidebars you will run into undefined behaviors. |
| 1849 |
|
| 1850 |
const usedReferenceWidgets = []; |
| 1851 |
const widgetsBlocks = post.blocks.filter(block => { |
| 1852 |
const { |
| 1853 |
id |
| 1854 |
} = block.attributes; |
| 1855 |
|
| 1856 |
if (block.name === 'core/legacy-widget' && id) { |
| 1857 |
if (usedReferenceWidgets.includes(id)) { |
| 1858 |
return false; |
| 1859 |
} |
| 1860 |
|
| 1861 |
usedReferenceWidgets.push(id); |
| 1862 |
} |
| 1863 |
|
| 1864 |
return true; |
| 1865 |
}); // Determine which widgets have been deleted. We can tell if a widget is |
| 1866 |
// deleted and not just moved to a different area by looking to see if |
| 1867 |
// getWidgetAreaForWidgetId() finds something. |
| 1868 |
|
| 1869 |
const deletedWidgets = []; |
| 1870 |
|
| 1871 |
for (const widget of areaWidgets) { |
| 1872 |
const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id); |
| 1873 |
|
| 1874 |
if (!widgetsNewArea) { |
| 1875 |
deletedWidgets.push(widget); |
| 1876 |
} |
| 1877 |
} |
| 1878 |
|
| 1879 |
const batchMeta = []; |
| 1880 |
const batchTasks = []; |
| 1881 |
const sidebarWidgetsIds = []; |
| 1882 |
|
| 1883 |
for (let i = 0; i < widgetsBlocks.length; i++) { |
| 1884 |
const block = widgetsBlocks[i]; |
| 1885 |
const widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block); |
| 1886 |
const oldWidget = widgets[widgetId]; |
| 1887 |
const widget = transformBlockToWidget(block, oldWidget); // We'll replace the null widgetId after save, but we track it here |
| 1888 |
// since order is important. |
| 1889 |
|
| 1890 |
sidebarWidgetsIds.push(widgetId); // Check oldWidget as widgetId might refer to an ID which has been |
| 1891 |
// deleted, e.g. if a deleted block is restored via undo after saving. |
| 1892 |
|
| 1893 |
if (oldWidget) { |
| 1894 |
// Update an existing widget. |
| 1895 |
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('root', 'widget', widgetId, { ...widget, |
| 1896 |
sidebar: widgetAreaId |
| 1897 |
}, { |
| 1898 |
undoIgnore: true |
| 1899 |
}); |
| 1900 |
const hasEdits = registry.select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('root', 'widget', widgetId); |
| 1901 |
|
| 1902 |
if (!hasEdits) { |
| 1903 |
continue; |
| 1904 |
} |
| 1905 |
|
| 1906 |
batchTasks.push(_ref6 => { |
| 1907 |
let { |
| 1908 |
saveEditedEntityRecord |
| 1909 |
} = _ref6; |
| 1910 |
return saveEditedEntityRecord('root', 'widget', widgetId); |
| 1911 |
}); |
| 1912 |
} else { |
| 1913 |
// Create a new widget. |
| 1914 |
batchTasks.push(_ref7 => { |
| 1915 |
let { |
| 1916 |
saveEntityRecord |
| 1917 |
} = _ref7; |
| 1918 |
return saveEntityRecord('root', 'widget', { ...widget, |
| 1919 |
sidebar: widgetAreaId |
| 1920 |
}); |
| 1921 |
}); |
| 1922 |
} |
| 1923 |
|
| 1924 |
batchMeta.push({ |
| 1925 |
block, |
| 1926 |
position: i, |
| 1927 |
clientId: block.clientId |
| 1928 |
}); |
| 1929 |
} |
| 1930 |
|
| 1931 |
for (const widget of deletedWidgets) { |
| 1932 |
batchTasks.push(_ref8 => { |
| 1933 |
let { |
| 1934 |
deleteEntityRecord |
| 1935 |
} = _ref8; |
| 1936 |
return deleteEntityRecord('root', 'widget', widget.id, { |
| 1937 |
force: true |
| 1938 |
}); |
| 1939 |
}); |
| 1940 |
} |
| 1941 |
|
| 1942 |
const records = await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(batchTasks); |
| 1943 |
const preservedRecords = records.filter(record => !record.hasOwnProperty('deleted')); |
| 1944 |
const failedWidgetNames = []; |
| 1945 |
|
| 1946 |
for (let i = 0; i < preservedRecords.length; i++) { |
| 1947 |
const widget = preservedRecords[i]; |
| 1948 |
const { |
| 1949 |
block, |
| 1950 |
position |
| 1951 |
} = batchMeta[i]; // Set __internalWidgetId on the block. This will be persisted to the |
| 1952 |
// store when we dispatch receiveEntityRecords( post ) below. |
| 1953 |
|
| 1954 |
post.blocks[position].attributes.__internalWidgetId = widget.id; |
| 1955 |
const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'widget', widget.id); |
| 1956 |
|
| 1957 |
if (error) { |
| 1958 |
var _block$attributes; |
| 1959 |
|
| 1960 |
failedWidgetNames.push(((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.name) || (block === null || block === void 0 ? void 0 : block.name)); |
| 1961 |
} |
| 1962 |
|
| 1963 |
if (!sidebarWidgetsIds[position]) { |
| 1964 |
sidebarWidgetsIds[position] = widget.id; |
| 1965 |
} |
| 1966 |
} |
| 1967 |
|
| 1968 |
if (failedWidgetNames.length) { |
| 1969 |
throw new Error((0,external_wp_i18n_namespaceObject.sprintf)( |
| 1970 |
/* translators: %s: List of widget names */ |
| 1971 |
(0,external_wp_i18n_namespaceObject.__)('Could not save the following widgets: %s.'), failedWidgetNames.join(', '))); |
| 1972 |
} |
| 1973 |
|
| 1974 |
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { |
| 1975 |
widgets: sidebarWidgetsIds |
| 1976 |
}, { |
| 1977 |
undoIgnore: true |
| 1978 |
}); |
| 1979 |
dispatch(trySaveWidgetArea(widgetAreaId)); |
| 1980 |
registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(KIND, POST_TYPE, post, undefined); |
| 1981 |
}; |
| 1982 |
|
| 1983 |
const trySaveWidgetArea = widgetAreaId => _ref9 => { |
| 1984 |
let { |
| 1985 |
registry |
| 1986 |
} = _ref9; |
| 1987 |
const saveErrorBefore = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId); |
| 1988 |
registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId); |
| 1989 |
const saveErrorAfter = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId); |
| 1990 |
|
| 1991 |
if (saveErrorAfter && saveErrorBefore !== saveErrorAfter) { |
| 1992 |
throw new Error(saveErrorAfter); |
| 1993 |
} |
| 1994 |
}; |
| 1995 |
/** |
| 1996 |
* Sets the clientId stored for a particular widgetId. |
| 1997 |
* |
| 1998 |
* @param {number} clientId Client id. |
| 1999 |
* @param {number} widgetId Widget id. |
| 2000 |
* |
| 2001 |
* @return {Object} Action. |
| 2002 |
*/ |
| 2003 |
|
| 2004 |
|
| 2005 |
function setWidgetIdForClientId(clientId, widgetId) { |
| 2006 |
return { |
| 2007 |
type: 'SET_WIDGET_ID_FOR_CLIENT_ID', |
| 2008 |
clientId, |
| 2009 |
widgetId |
| 2010 |
}; |
| 2011 |
} |
| 2012 |
/** |
| 2013 |
* Sets the open state of all the widget areas. |
| 2014 |
* |
| 2015 |
* @param {Object} widgetAreasOpenState The open states of all the widget areas. |
| 2016 |
* |
| 2017 |
* @return {Object} Action. |
| 2018 |
*/ |
| 2019 |
|
| 2020 |
function setWidgetAreasOpenState(widgetAreasOpenState) { |
| 2021 |
return { |
| 2022 |
type: 'SET_WIDGET_AREAS_OPEN_STATE', |
| 2023 |
widgetAreasOpenState |
| 2024 |
}; |
| 2025 |
} |
| 2026 |
/** |
| 2027 |
* Sets the open state of the widget area. |
| 2028 |
* |
| 2029 |
* @param {string} clientId The clientId of the widget area. |
| 2030 |
* @param {boolean} isOpen Whether the widget area should be opened. |
| 2031 |
* |
| 2032 |
* @return {Object} Action. |
| 2033 |
*/ |
| 2034 |
|
| 2035 |
function setIsWidgetAreaOpen(clientId, isOpen) { |
| 2036 |
return { |
| 2037 |
type: 'SET_IS_WIDGET_AREA_OPEN', |
| 2038 |
clientId, |
| 2039 |
isOpen |
| 2040 |
}; |
| 2041 |
} |
| 2042 |
/** |
| 2043 |
* Returns an action object used to open/close the inserter. |
| 2044 |
* |
| 2045 |
* @param {boolean|Object} value Whether the inserter should be |
| 2046 |
* opened (true) or closed (false). |
| 2047 |
* To specify an insertion point, |
| 2048 |
* use an object. |
| 2049 |
* @param {string} value.rootClientId The root client ID to insert at. |
| 2050 |
* @param {number} value.insertionIndex The index to insert at. |
| 2051 |
* |
| 2052 |
* @return {Object} Action object. |
| 2053 |
*/ |
| 2054 |
|
| 2055 |
function setIsInserterOpened(value) { |
| 2056 |
return { |
| 2057 |
type: 'SET_IS_INSERTER_OPENED', |
| 2058 |
value |
| 2059 |
}; |
| 2060 |
} |
| 2061 |
/** |
| 2062 |
* Returns an action object used to open/close the list view. |
| 2063 |
* |
| 2064 |
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed. |
| 2065 |
* @return {Object} Action object. |
| 2066 |
*/ |
| 2067 |
|
| 2068 |
function setIsListViewOpened(isOpen) { |
| 2069 |
return { |
| 2070 |
type: 'SET_IS_LIST_VIEW_OPENED', |
| 2071 |
isOpen |
| 2072 |
}; |
| 2073 |
} |
| 2074 |
/** |
| 2075 |
* Returns an action object signalling that the user closed the sidebar. |
| 2076 |
* |
| 2077 |
* @return {Object} Action creator. |
| 2078 |
*/ |
| 2079 |
|
| 2080 |
const closeGeneralSidebar = () => _ref10 => { |
| 2081 |
let { |
| 2082 |
registry |
| 2083 |
} = _ref10; |
| 2084 |
registry.dispatch(store).disableComplementaryArea(constants_STORE_NAME); |
| 2085 |
}; |
| 2086 |
/** |
| 2087 |
* Action that handles moving a block between widget areas |
| 2088 |
* |
| 2089 |
* @param {string} clientId The clientId of the block to move. |
| 2090 |
* @param {string} widgetAreaId The id of the widget area to move the block to. |
| 2091 |
*/ |
| 2092 |
|
| 2093 |
const moveBlockToWidgetArea = (clientId, widgetAreaId) => async _ref11 => { |
| 2094 |
let { |
| 2095 |
dispatch, |
| 2096 |
select, |
| 2097 |
registry |
| 2098 |
} = _ref11; |
| 2099 |
const sourceRootClientId = registry.select(external_wp_blockEditor_namespaceObject.store).getBlockRootClientId([clientId]); // Search the top level blocks (widget areas) for the one with the matching |
| 2100 |
// id attribute. Makes the assumption that all top-level blocks are widget |
| 2101 |
// areas. |
| 2102 |
|
| 2103 |
const widgetAreas = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(); |
| 2104 |
const destinationWidgetAreaBlock = widgetAreas.find(_ref12 => { |
| 2105 |
let { |
| 2106 |
attributes |
| 2107 |
} = _ref12; |
| 2108 |
return attributes.id === widgetAreaId; |
| 2109 |
}); |
| 2110 |
const destinationRootClientId = destinationWidgetAreaBlock.clientId; // Get the index for moving to the end of the the destination widget area. |
| 2111 |
|
| 2112 |
const destinationInnerBlocksClientIds = registry.select(external_wp_blockEditor_namespaceObject.store).getBlockOrder(destinationRootClientId); |
| 2113 |
const destinationIndex = destinationInnerBlocksClientIds.length; // Reveal the widget area, if it's not open. |
| 2114 |
|
| 2115 |
const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(destinationRootClientId); |
| 2116 |
|
| 2117 |
if (!isDestinationWidgetAreaOpen) { |
| 2118 |
dispatch.setIsWidgetAreaOpen(destinationRootClientId, true); |
| 2119 |
} // Move the block. |
| 2120 |
|
| 2121 |
|
| 2122 |
registry.dispatch(external_wp_blockEditor_namespaceObject.store).moveBlocksToPosition([clientId], sourceRootClientId, destinationRootClientId, destinationIndex); |
| 2123 |
}; |
| 2124 |
//# sourceMappingURL=actions.js.map |
| 2125 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/resolvers.js |
| 2126 |
/** |
| 2127 |
* WordPress dependencies |
| 2128 |
*/ |
| 2129 |
|
| 2130 |
|
| 2131 |
/** |
| 2132 |
* Internal dependencies |
| 2133 |
*/ |
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
|
| 2138 |
/** |
| 2139 |
* Creates a "stub" widgets post reflecting all available widget areas. The |
| 2140 |
* post is meant as a convenient to only exists in runtime and should never be saved. It |
| 2141 |
* enables a convenient way of editing the widgets by using a regular post editor. |
| 2142 |
* |
| 2143 |
* Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them. |
| 2144 |
* |
| 2145 |
* @return {Function} An action creator. |
| 2146 |
*/ |
| 2147 |
|
| 2148 |
const getWidgetAreas = () => async _ref => { |
| 2149 |
let { |
| 2150 |
dispatch, |
| 2151 |
registry |
| 2152 |
} = _ref; |
| 2153 |
const query = buildWidgetAreasQuery(); |
| 2154 |
const widgetAreas = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query); |
| 2155 |
const widgetAreaBlocks = []; |
| 2156 |
const sortedWidgetAreas = widgetAreas.sort((a, b) => { |
| 2157 |
if (a.id === 'wp_inactive_widgets') { |
| 2158 |
return 1; |
| 2159 |
} |
| 2160 |
|
| 2161 |
if (b.id === 'wp_inactive_widgets') { |
| 2162 |
return -1; |
| 2163 |
} |
| 2164 |
|
| 2165 |
return 0; |
| 2166 |
}); |
| 2167 |
|
| 2168 |
for (const widgetArea of sortedWidgetAreas) { |
| 2169 |
widgetAreaBlocks.push((0,external_wp_blocks_namespaceObject.createBlock)('core/widget-area', { |
| 2170 |
id: widgetArea.id, |
| 2171 |
name: widgetArea.name |
| 2172 |
})); |
| 2173 |
|
| 2174 |
if (!widgetArea.widgets.length) { |
| 2175 |
// If this widget area has no widgets, it won't get a post setup by |
| 2176 |
// the getWidgets resolver. |
| 2177 |
dispatch(persistStubPost(buildWidgetAreaPostId(widgetArea.id), [])); |
| 2178 |
} |
| 2179 |
} |
| 2180 |
|
| 2181 |
const widgetAreasOpenState = {}; |
| 2182 |
widgetAreaBlocks.forEach((widgetAreaBlock, index) => { |
| 2183 |
// Defaults to open the first widget area. |
| 2184 |
widgetAreasOpenState[widgetAreaBlock.clientId] = index === 0; |
| 2185 |
}); |
| 2186 |
dispatch(setWidgetAreasOpenState(widgetAreasOpenState)); |
| 2187 |
dispatch(persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks)); |
| 2188 |
}; |
| 2189 |
/** |
| 2190 |
* Fetches all widgets from all widgets ares, and groups them by widget area Id. |
| 2191 |
* |
| 2192 |
* @return {Function} An action creator. |
| 2193 |
*/ |
| 2194 |
|
| 2195 |
const getWidgets = () => async _ref2 => { |
| 2196 |
let { |
| 2197 |
dispatch, |
| 2198 |
registry |
| 2199 |
} = _ref2; |
| 2200 |
const query = buildWidgetsQuery(); |
| 2201 |
const widgets = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecords('root', 'widget', query); |
| 2202 |
const groupedBySidebar = {}; |
| 2203 |
|
| 2204 |
for (const widget of widgets) { |
| 2205 |
const block = transformWidgetToBlock(widget); |
| 2206 |
groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || []; |
| 2207 |
groupedBySidebar[widget.sidebar].push(block); |
| 2208 |
} |
| 2209 |
|
| 2210 |
for (const sidebarId in groupedBySidebar) { |
| 2211 |
if (groupedBySidebar.hasOwnProperty(sidebarId)) { |
| 2212 |
// Persist the actual post containing the widget block |
| 2213 |
dispatch(persistStubPost(buildWidgetAreaPostId(sidebarId), groupedBySidebar[sidebarId])); |
| 2214 |
} |
| 2215 |
} |
| 2216 |
}; |
| 2217 |
//# sourceMappingURL=resolvers.js.map |
| 2218 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/selectors.js |
| 2219 |
/** |
| 2220 |
* External dependencies |
| 2221 |
*/ |
| 2222 |
|
| 2223 |
/** |
| 2224 |
* WordPress dependencies |
| 2225 |
*/ |
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
/** |
| 2232 |
* Internal dependencies |
| 2233 |
*/ |
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
/** |
| 2238 |
* Returns all API widgets. |
| 2239 |
* |
| 2240 |
* @return {Object[]} API List of widgets. |
| 2241 |
*/ |
| 2242 |
|
| 2243 |
const selectors_getWidgets = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { |
| 2244 |
const widgets = select(external_wp_coreData_namespaceObject.store).getEntityRecords('root', 'widget', buildWidgetsQuery()); |
| 2245 |
return (0,external_lodash_namespaceObject.keyBy)(widgets, 'id'); |
| 2246 |
}); |
| 2247 |
/** |
| 2248 |
* Returns API widget data for a particular widget ID. |
| 2249 |
* |
| 2250 |
* @param {number} id Widget ID. |
| 2251 |
* |
| 2252 |
* @return {Object} API widget data for a particular widget ID. |
| 2253 |
*/ |
| 2254 |
|
| 2255 |
const getWidget = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, id) => { |
| 2256 |
const widgets = select(constants_STORE_NAME).getWidgets(); |
| 2257 |
return widgets[id]; |
| 2258 |
}); |
| 2259 |
/** |
| 2260 |
* Returns all API widget areas. |
| 2261 |
* |
| 2262 |
* @return {Object[]} API List of widget areas. |
| 2263 |
*/ |
| 2264 |
|
| 2265 |
const selectors_getWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { |
| 2266 |
const query = buildWidgetAreasQuery(); |
| 2267 |
return select(external_wp_coreData_namespaceObject.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query); |
| 2268 |
}); |
| 2269 |
/** |
| 2270 |
* Returns widgetArea containing a block identify by given widgetId |
| 2271 |
* |
| 2272 |
* @param {string} widgetId The ID of the widget. |
| 2273 |
* @return {Object} Containing widget area. |
| 2274 |
*/ |
| 2275 |
|
| 2276 |
const getWidgetAreaForWidgetId = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, widgetId) => { |
| 2277 |
const widgetAreas = select(constants_STORE_NAME).getWidgetAreas(); |
| 2278 |
return widgetAreas.find(widgetArea => { |
| 2279 |
const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetArea.id)); |
| 2280 |
const blockWidgetIds = post.blocks.map(block => (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block)); |
| 2281 |
return blockWidgetIds.includes(widgetId); |
| 2282 |
}); |
| 2283 |
}); |
| 2284 |
/** |
| 2285 |
* Given a child client id, returns the parent widget area block. |
| 2286 |
* |
| 2287 |
* @param {string} clientId The client id of a block in a widget area. |
| 2288 |
* |
| 2289 |
* @return {WPBlock} The widget area block. |
| 2290 |
*/ |
| 2291 |
|
| 2292 |
const getParentWidgetAreaBlock = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, clientId) => { |
| 2293 |
const { |
| 2294 |
getBlock, |
| 2295 |
getBlockName, |
| 2296 |
getBlockParents |
| 2297 |
} = select(external_wp_blockEditor_namespaceObject.store); |
| 2298 |
const blockParents = getBlockParents(clientId); |
| 2299 |
const widgetAreaClientId = blockParents.find(parentClientId => getBlockName(parentClientId) === 'core/widget-area'); |
| 2300 |
return getBlock(widgetAreaClientId); |
| 2301 |
}); |
| 2302 |
/** |
| 2303 |
* Returns all edited widget area entity records. |
| 2304 |
* |
| 2305 |
* @return {Object[]} List of edited widget area entity records. |
| 2306 |
*/ |
| 2307 |
|
| 2308 |
const getEditedWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ids) => { |
| 2309 |
let widgetAreas = select(constants_STORE_NAME).getWidgetAreas(); |
| 2310 |
|
| 2311 |
if (!widgetAreas) { |
| 2312 |
return []; |
| 2313 |
} |
| 2314 |
|
| 2315 |
if (ids) { |
| 2316 |
widgetAreas = widgetAreas.filter(_ref => { |
| 2317 |
let { |
| 2318 |
id |
| 2319 |
} = _ref; |
| 2320 |
return ids.includes(id); |
| 2321 |
}); |
| 2322 |
} |
| 2323 |
|
| 2324 |
return widgetAreas.filter(_ref2 => { |
| 2325 |
let { |
| 2326 |
id |
| 2327 |
} = _ref2; |
| 2328 |
return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(id)); |
| 2329 |
}).map(_ref3 => { |
| 2330 |
let { |
| 2331 |
id |
| 2332 |
} = _ref3; |
| 2333 |
return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id); |
| 2334 |
}); |
| 2335 |
}); |
| 2336 |
/** |
| 2337 |
* Returns all blocks representing reference widgets. |
| 2338 |
* |
| 2339 |
* @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned. |
| 2340 |
* @return {Array} List of all blocks representing reference widgets |
| 2341 |
*/ |
| 2342 |
|
| 2343 |
const getReferenceWidgetBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => function (state) { |
| 2344 |
let referenceWidgetName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
| 2345 |
const results = []; |
| 2346 |
const widgetAreas = select(constants_STORE_NAME).getWidgetAreas(); |
| 2347 |
|
| 2348 |
for (const _widgetArea of widgetAreas) { |
| 2349 |
const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(_widgetArea.id)); |
| 2350 |
|
| 2351 |
for (const block of post.blocks) { |
| 2352 |
var _block$attributes; |
| 2353 |
|
| 2354 |
if (block.name === 'core/legacy-widget' && (!referenceWidgetName || ((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.referenceWidgetName) === referenceWidgetName)) { |
| 2355 |
results.push(block); |
| 2356 |
} |
| 2357 |
} |
| 2358 |
} |
| 2359 |
|
| 2360 |
return results; |
| 2361 |
}); |
| 2362 |
/** |
| 2363 |
* Returns true if any widget area is currently being saved. |
| 2364 |
* |
| 2365 |
* @return {boolean} True if any widget area is currently being saved. False otherwise. |
| 2366 |
*/ |
| 2367 |
|
| 2368 |
const isSavingWidgetAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { |
| 2369 |
var _select$getWidgetArea; |
| 2370 |
|
| 2371 |
const widgetAreasIds = (_select$getWidgetArea = select(constants_STORE_NAME).getWidgetAreas()) === null || _select$getWidgetArea === void 0 ? void 0 : _select$getWidgetArea.map(_ref4 => { |
| 2372 |
let { |
| 2373 |
id |
| 2374 |
} = _ref4; |
| 2375 |
return id; |
| 2376 |
}); |
| 2377 |
|
| 2378 |
if (!widgetAreasIds) { |
| 2379 |
return false; |
| 2380 |
} |
| 2381 |
|
| 2382 |
for (const id of widgetAreasIds) { |
| 2383 |
const isSaving = select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id); |
| 2384 |
|
| 2385 |
if (isSaving) { |
| 2386 |
return true; |
| 2387 |
} |
| 2388 |
} |
| 2389 |
|
| 2390 |
const widgetIds = [...Object.keys(select(constants_STORE_NAME).getWidgets()), undefined // account for new widgets without an ID |
| 2391 |
]; |
| 2392 |
|
| 2393 |
for (const id of widgetIds) { |
| 2394 |
const isSaving = select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord('root', 'widget', id); |
| 2395 |
|
| 2396 |
if (isSaving) { |
| 2397 |
return true; |
| 2398 |
} |
| 2399 |
} |
| 2400 |
|
| 2401 |
return false; |
| 2402 |
}); |
| 2403 |
/** |
| 2404 |
* Gets whether the widget area is opened. |
| 2405 |
* |
| 2406 |
* @param {Array} state The open state of the widget areas. |
| 2407 |
* @param {string} clientId The clientId of the widget area. |
| 2408 |
* |
| 2409 |
* @return {boolean} True if the widget area is open. |
| 2410 |
*/ |
| 2411 |
|
| 2412 |
const getIsWidgetAreaOpen = (state, clientId) => { |
| 2413 |
const { |
| 2414 |
widgetAreasOpenState |
| 2415 |
} = state; |
| 2416 |
return !!widgetAreasOpenState[clientId]; |
| 2417 |
}; |
| 2418 |
/** |
| 2419 |
* Returns true if the inserter is opened. |
| 2420 |
* |
| 2421 |
* @param {Object} state Global application state. |
| 2422 |
* |
| 2423 |
* @return {boolean} Whether the inserter is opened. |
| 2424 |
*/ |
| 2425 |
|
| 2426 |
function isInserterOpened(state) { |
| 2427 |
return !!state.blockInserterPanel; |
| 2428 |
} |
| 2429 |
/** |
| 2430 |
* Get the insertion point for the inserter. |
| 2431 |
* |
| 2432 |
* @param {Object} state Global application state. |
| 2433 |
* |
| 2434 |
* @return {Object} The root client ID and index to insert at. |
| 2435 |
*/ |
| 2436 |
|
| 2437 |
function __experimentalGetInsertionPoint(state) { |
| 2438 |
const { |
| 2439 |
rootClientId, |
| 2440 |
insertionIndex |
| 2441 |
} = state.blockInserterPanel; |
| 2442 |
return { |
| 2443 |
rootClientId, |
| 2444 |
insertionIndex |
| 2445 |
}; |
| 2446 |
} |
| 2447 |
/** |
| 2448 |
* Returns true if a block can be inserted into a widget area. |
| 2449 |
* |
| 2450 |
* @param {Array} state The open state of the widget areas. |
| 2451 |
* @param {string} blockName The name of the block being inserted. |
| 2452 |
* |
| 2453 |
* @return {boolean} True if the block can be inserted in a widget area. |
| 2454 |
*/ |
| 2455 |
|
| 2456 |
const canInsertBlockInWidgetArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, blockName) => { |
| 2457 |
// Widget areas are always top-level blocks, which getBlocks will return. |
| 2458 |
const widgetAreas = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); // Makes an assumption that a block that can be inserted into one |
| 2459 |
// widget area can be inserted into any widget area. Uses the first |
| 2460 |
// widget area for testing whether the block can be inserted. |
| 2461 |
|
| 2462 |
const [firstWidgetArea] = widgetAreas; |
| 2463 |
return select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType(blockName, firstWidgetArea.clientId); |
| 2464 |
}); |
| 2465 |
/** |
| 2466 |
* Returns true if the list view is opened. |
| 2467 |
* |
| 2468 |
* @param {Object} state Global application state. |
| 2469 |
* |
| 2470 |
* @return {boolean} Whether the list view is opened. |
| 2471 |
*/ |
| 2472 |
|
| 2473 |
function isListViewOpened(state) { |
| 2474 |
return state.listViewPanel; |
| 2475 |
} |
| 2476 |
//# sourceMappingURL=selectors.js.map |
| 2477 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/store/index.js |
| 2478 |
/** |
| 2479 |
* WordPress dependencies |
| 2480 |
*/ |
| 2481 |
|
| 2482 |
|
| 2483 |
/** |
| 2484 |
* Internal dependencies |
| 2485 |
*/ |
| 2486 |
|
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
|
| 2491 |
|
| 2492 |
/** |
| 2493 |
* Block editor data store configuration. |
| 2494 |
* |
| 2495 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore |
| 2496 |
* |
| 2497 |
* @type {Object} |
| 2498 |
*/ |
| 2499 |
|
| 2500 |
const storeConfig = { |
| 2501 |
reducer: store_reducer, |
| 2502 |
selectors: store_selectors_namespaceObject, |
| 2503 |
resolvers: resolvers_namespaceObject, |
| 2504 |
actions: store_actions_namespaceObject, |
| 2505 |
__experimentalUseThunks: true |
| 2506 |
}; |
| 2507 |
/** |
| 2508 |
* Store definition for the edit widgets namespace. |
| 2509 |
* |
| 2510 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
| 2511 |
* |
| 2512 |
* @type {Object} |
| 2513 |
*/ |
| 2514 |
|
| 2515 |
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 |
| 2516 |
// we'd be able to replace this with a register call. |
| 2517 |
|
| 2518 |
(0,external_wp_data_namespaceObject.registerStore)(constants_STORE_NAME, storeConfig); // This package uses a few in-memory post types as wrappers for convenience. |
| 2519 |
// This middleware prevents any network requests related to these types as they are |
| 2520 |
// bound to fail anyway. |
| 2521 |
|
| 2522 |
external_wp_apiFetch_default().use(function (options, next) { |
| 2523 |
var _options$path; |
| 2524 |
|
| 2525 |
if (((_options$path = options.path) === null || _options$path === void 0 ? void 0 : _options$path.indexOf('/wp/v2/types/widget-area')) === 0) { |
| 2526 |
return Promise.resolve({}); |
| 2527 |
} |
| 2528 |
|
| 2529 |
return next(options); |
| 2530 |
}); |
| 2531 |
//# sourceMappingURL=index.js.map |
| 2532 |
;// CONCATENATED MODULE: external ["wp","hooks"] |
| 2533 |
var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
| 2534 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/filters/move-to-widget-area.js |
| 2535 |
|
| 2536 |
|
| 2537 |
/** |
| 2538 |
* WordPress dependencies |
| 2539 |
*/ |
| 2540 |
|
| 2541 |
|
| 2542 |
|
| 2543 |
|
| 2544 |
|
| 2545 |
/** |
| 2546 |
* Internal dependencies |
| 2547 |
*/ |
| 2548 |
|
| 2549 |
|
| 2550 |
const withMoveToWidgetAreaToolbarItem = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { |
| 2551 |
const { |
| 2552 |
clientId, |
| 2553 |
name: blockName |
| 2554 |
} = props; |
| 2555 |
const { |
| 2556 |
widgetAreas, |
| 2557 |
currentWidgetAreaId, |
| 2558 |
canInsertBlockInWidgetArea |
| 2559 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 2560 |
var _widgetAreaBlock$attr; |
| 2561 |
|
| 2562 |
// Component won't display for a widget area, so don't run selectors. |
| 2563 |
if (blockName === 'core/widget-area') { |
| 2564 |
return {}; |
| 2565 |
} |
| 2566 |
|
| 2567 |
const selectors = select(store_store); |
| 2568 |
const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId); |
| 2569 |
return { |
| 2570 |
widgetAreas: selectors.getWidgetAreas(), |
| 2571 |
currentWidgetAreaId: widgetAreaBlock === null || widgetAreaBlock === void 0 ? void 0 : (_widgetAreaBlock$attr = widgetAreaBlock.attributes) === null || _widgetAreaBlock$attr === void 0 ? void 0 : _widgetAreaBlock$attr.id, |
| 2572 |
canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName) |
| 2573 |
}; |
| 2574 |
}, [clientId, blockName]); |
| 2575 |
const { |
| 2576 |
moveBlockToWidgetArea |
| 2577 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 2578 |
const hasMultipleWidgetAreas = (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) > 1; |
| 2579 |
const isMoveToWidgetAreaVisible = blockName !== 'core/widget-area' && hasMultipleWidgetAreas && canInsertBlockInWidgetArea; |
| 2580 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isMoveToWidgetAreaVisible && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_widgets_namespaceObject.MoveToWidgetArea, { |
| 2581 |
widgetAreas: widgetAreas, |
| 2582 |
currentWidgetAreaId: currentWidgetAreaId, |
| 2583 |
onSelect: widgetAreaId => { |
| 2584 |
moveBlockToWidgetArea(props.clientId, widgetAreaId); |
| 2585 |
} |
| 2586 |
}))); |
| 2587 |
}, 'withMoveToWidgetAreaToolbarItem'); |
| 2588 |
(0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-widgets/block-edit', withMoveToWidgetAreaToolbarItem); |
| 2589 |
//# sourceMappingURL=move-to-widget-area.js.map |
| 2590 |
;// CONCATENATED MODULE: external ["wp","mediaUtils"] |
| 2591 |
var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; |
| 2592 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/filters/replace-media-upload.js |
| 2593 |
/** |
| 2594 |
* WordPress dependencies |
| 2595 |
*/ |
| 2596 |
|
| 2597 |
|
| 2598 |
|
| 2599 |
const replaceMediaUpload = () => external_wp_mediaUtils_namespaceObject.MediaUpload; |
| 2600 |
|
| 2601 |
(0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-widgets/replace-media-upload', replaceMediaUpload); |
| 2602 |
//# sourceMappingURL=replace-media-upload.js.map |
| 2603 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/filters/index.js |
| 2604 |
/** |
| 2605 |
* Internal dependencies |
| 2606 |
*/ |
| 2607 |
|
| 2608 |
|
| 2609 |
//# sourceMappingURL=index.js.map |
| 2610 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/blocks/widget-area/edit/use-is-dragging-within.js |
| 2611 |
/** |
| 2612 |
* WordPress dependencies |
| 2613 |
*/ |
| 2614 |
|
| 2615 |
/** @typedef {import('@wordpress/element').RefObject} RefObject */ |
| 2616 |
|
| 2617 |
/** |
| 2618 |
* A React hook to determine if it's dragging within the target element. |
| 2619 |
* |
| 2620 |
* @param {RefObject<HTMLElement>} elementRef The target elementRef object. |
| 2621 |
* |
| 2622 |
* @return {boolean} Is dragging within the target element. |
| 2623 |
*/ |
| 2624 |
|
| 2625 |
const useIsDraggingWithin = elementRef => { |
| 2626 |
const [isDraggingWithin, setIsDraggingWithin] = (0,external_wp_element_namespaceObject.useState)(false); |
| 2627 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 2628 |
const { |
| 2629 |
ownerDocument |
| 2630 |
} = elementRef.current; |
| 2631 |
|
| 2632 |
function handleDragStart(event) { |
| 2633 |
// Check the first time when the dragging starts. |
| 2634 |
handleDragEnter(event); |
| 2635 |
} // Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape. |
| 2636 |
|
| 2637 |
|
| 2638 |
function handleDragEnd() { |
| 2639 |
setIsDraggingWithin(false); |
| 2640 |
} |
| 2641 |
|
| 2642 |
function handleDragEnter(event) { |
| 2643 |
// Check if the current target is inside the item element. |
| 2644 |
if (elementRef.current.contains(event.target)) { |
| 2645 |
setIsDraggingWithin(true); |
| 2646 |
} else { |
| 2647 |
setIsDraggingWithin(false); |
| 2648 |
} |
| 2649 |
} // Bind these events to the document to catch all drag events. |
| 2650 |
// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari. |
| 2651 |
|
| 2652 |
|
| 2653 |
ownerDocument.addEventListener('dragstart', handleDragStart); |
| 2654 |
ownerDocument.addEventListener('dragend', handleDragEnd); |
| 2655 |
ownerDocument.addEventListener('dragenter', handleDragEnter); |
| 2656 |
return () => { |
| 2657 |
ownerDocument.removeEventListener('dragstart', handleDragStart); |
| 2658 |
ownerDocument.removeEventListener('dragend', handleDragEnd); |
| 2659 |
ownerDocument.removeEventListener('dragenter', handleDragEnter); |
| 2660 |
}; |
| 2661 |
}, []); |
| 2662 |
return isDraggingWithin; |
| 2663 |
}; |
| 2664 |
|
| 2665 |
/* harmony default export */ var use_is_dragging_within = (useIsDraggingWithin); |
| 2666 |
//# sourceMappingURL=use-is-dragging-within.js.map |
| 2667 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.js |
| 2668 |
|
| 2669 |
|
| 2670 |
/** |
| 2671 |
* External dependencies |
| 2672 |
*/ |
| 2673 |
|
| 2674 |
/** |
| 2675 |
* WordPress dependencies |
| 2676 |
*/ |
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
/** |
| 2682 |
* Internal dependencies |
| 2683 |
*/ |
| 2684 |
|
| 2685 |
|
| 2686 |
function WidgetAreaInnerBlocks(_ref) { |
| 2687 |
let { |
| 2688 |
id |
| 2689 |
} = _ref; |
| 2690 |
const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('root', 'postType'); |
| 2691 |
const innerBlocksRef = (0,external_wp_element_namespaceObject.useRef)(); |
| 2692 |
const isDraggingWithinInnerBlocks = use_is_dragging_within(innerBlocksRef); |
| 2693 |
const shouldHighlightDropZone = isDraggingWithinInnerBlocks; // Using the experimental hook so that we can control the className of the element. |
| 2694 |
|
| 2695 |
const innerBlocksProps = (0,external_wp_blockEditor_namespaceObject.useInnerBlocksProps)({ |
| 2696 |
ref: innerBlocksRef |
| 2697 |
}, { |
| 2698 |
value: blocks, |
| 2699 |
onInput, |
| 2700 |
onChange, |
| 2701 |
templateLock: false, |
| 2702 |
renderAppender: external_wp_blockEditor_namespaceObject.InnerBlocks.ButtonBlockAppender |
| 2703 |
}); |
| 2704 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
| 2705 |
"data-widget-area-id": id, |
| 2706 |
className: classnames_default()('wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper', { |
| 2707 |
'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone |
| 2708 |
}) |
| 2709 |
}, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps)); |
| 2710 |
} |
| 2711 |
//# sourceMappingURL=inner-blocks.js.map |
| 2712 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/blocks/widget-area/edit/index.js |
| 2713 |
|
| 2714 |
|
| 2715 |
/** |
| 2716 |
* WordPress dependencies |
| 2717 |
*/ |
| 2718 |
|
| 2719 |
|
| 2720 |
|
| 2721 |
|
| 2722 |
/** |
| 2723 |
* Internal dependencies |
| 2724 |
*/ |
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
/** @typedef {import('@wordpress/element').RefObject} RefObject */ |
| 2730 |
|
| 2731 |
function WidgetAreaEdit(_ref) { |
| 2732 |
let { |
| 2733 |
clientId, |
| 2734 |
className, |
| 2735 |
attributes: { |
| 2736 |
id, |
| 2737 |
name |
| 2738 |
} |
| 2739 |
} = _ref; |
| 2740 |
const isOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getIsWidgetAreaOpen(clientId), [clientId]); |
| 2741 |
const { |
| 2742 |
setIsWidgetAreaOpen |
| 2743 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 2744 |
const wrapper = (0,external_wp_element_namespaceObject.useRef)(); |
| 2745 |
const setOpen = (0,external_wp_element_namespaceObject.useCallback)(openState => setIsWidgetAreaOpen(clientId, openState), [clientId]); |
| 2746 |
const isDragging = useIsDragging(wrapper); |
| 2747 |
const isDraggingWithin = use_is_dragging_within(wrapper); |
| 2748 |
const [openedWhileDragging, setOpenedWhileDragging] = (0,external_wp_element_namespaceObject.useState)(false); |
| 2749 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 2750 |
if (!isDragging) { |
| 2751 |
setOpenedWhileDragging(false); |
| 2752 |
return; |
| 2753 |
} |
| 2754 |
|
| 2755 |
if (isDraggingWithin && !isOpen) { |
| 2756 |
setOpen(true); |
| 2757 |
setOpenedWhileDragging(true); |
| 2758 |
} else if (!isDraggingWithin && isOpen && openedWhileDragging) { |
| 2759 |
setOpen(false); |
| 2760 |
} |
| 2761 |
}, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]); |
| 2762 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, { |
| 2763 |
className: className, |
| 2764 |
ref: wrapper |
| 2765 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { |
| 2766 |
title: name, |
| 2767 |
opened: isOpen, |
| 2768 |
onToggle: () => { |
| 2769 |
setIsWidgetAreaOpen(clientId, !isOpen); |
| 2770 |
}, |
| 2771 |
scrollAfterOpen: !isDragging |
| 2772 |
}, _ref2 => { |
| 2773 |
let { |
| 2774 |
opened |
| 2775 |
} = _ref2; |
| 2776 |
return (// This is required to ensure LegacyWidget blocks are not |
| 2777 |
// unmounted when the panel is collapsed. Unmounting legacy |
| 2778 |
// widgets may have unintended consequences (e.g. TinyMCE |
| 2779 |
// not being properly reinitialized) |
| 2780 |
(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableDisclosureContent, { |
| 2781 |
className: "wp-block-widget-area__panel-body-content", |
| 2782 |
visible: opened |
| 2783 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, { |
| 2784 |
kind: "root", |
| 2785 |
type: "postType", |
| 2786 |
id: `widget-area-${id}` |
| 2787 |
}, (0,external_wp_element_namespaceObject.createElement)(WidgetAreaInnerBlocks, { |
| 2788 |
id: id |
| 2789 |
}))) |
| 2790 |
); |
| 2791 |
})); |
| 2792 |
} |
| 2793 |
/** |
| 2794 |
* A React hook to determine if dragging is active. |
| 2795 |
* |
| 2796 |
* @param {RefObject<HTMLElement>} elementRef The target elementRef object. |
| 2797 |
* |
| 2798 |
* @return {boolean} Is dragging within the entire document. |
| 2799 |
*/ |
| 2800 |
|
| 2801 |
const useIsDragging = elementRef => { |
| 2802 |
const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false); |
| 2803 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 2804 |
const { |
| 2805 |
ownerDocument |
| 2806 |
} = elementRef.current; |
| 2807 |
|
| 2808 |
function handleDragStart() { |
| 2809 |
setIsDragging(true); |
| 2810 |
} |
| 2811 |
|
| 2812 |
function handleDragEnd() { |
| 2813 |
setIsDragging(false); |
| 2814 |
} |
| 2815 |
|
| 2816 |
ownerDocument.addEventListener('dragstart', handleDragStart); |
| 2817 |
ownerDocument.addEventListener('dragend', handleDragEnd); |
| 2818 |
return () => { |
| 2819 |
ownerDocument.removeEventListener('dragstart', handleDragStart); |
| 2820 |
ownerDocument.removeEventListener('dragend', handleDragEnd); |
| 2821 |
}; |
| 2822 |
}, []); |
| 2823 |
return isDragging; |
| 2824 |
}; |
| 2825 |
//# sourceMappingURL=index.js.map |
| 2826 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/blocks/widget-area/index.js |
| 2827 |
/** |
| 2828 |
* WordPress dependencies |
| 2829 |
*/ |
| 2830 |
|
| 2831 |
/** |
| 2832 |
* Internal dependencies |
| 2833 |
*/ |
| 2834 |
|
| 2835 |
const metadata = { |
| 2836 |
name: "core/widget-area", |
| 2837 |
category: "widgets", |
| 2838 |
attributes: { |
| 2839 |
id: { |
| 2840 |
type: "string" |
| 2841 |
}, |
| 2842 |
name: { |
| 2843 |
type: "string" |
| 2844 |
} |
| 2845 |
}, |
| 2846 |
supports: { |
| 2847 |
html: false, |
| 2848 |
inserter: false, |
| 2849 |
customClassName: false, |
| 2850 |
reusable: false, |
| 2851 |
__experimentalToolbar: false, |
| 2852 |
__experimentalParentSelector: false |
| 2853 |
}, |
| 2854 |
editorStyle: "wp-block-widget-area-editor", |
| 2855 |
style: "wp-block-widget-area" |
| 2856 |
}; |
| 2857 |
|
| 2858 |
const { |
| 2859 |
name: widget_area_name |
| 2860 |
} = metadata; |
| 2861 |
|
| 2862 |
const settings = { |
| 2863 |
title: (0,external_wp_i18n_namespaceObject.__)('Widget Area'), |
| 2864 |
description: (0,external_wp_i18n_namespaceObject.__)('A widget area container.'), |
| 2865 |
__experimentalLabel: _ref => { |
| 2866 |
let { |
| 2867 |
name: label |
| 2868 |
} = _ref; |
| 2869 |
return label; |
| 2870 |
}, |
| 2871 |
edit: WidgetAreaEdit |
| 2872 |
}; |
| 2873 |
//# sourceMappingURL=index.js.map |
| 2874 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/error-boundary/index.js |
| 2875 |
|
| 2876 |
|
| 2877 |
/** |
| 2878 |
* WordPress dependencies |
| 2879 |
*/ |
| 2880 |
|
| 2881 |
|
| 2882 |
|
| 2883 |
|
| 2884 |
|
| 2885 |
|
| 2886 |
function CopyButton(_ref) { |
| 2887 |
let { |
| 2888 |
text, |
| 2889 |
children |
| 2890 |
} = _ref; |
| 2891 |
const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); |
| 2892 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 2893 |
variant: "secondary", |
| 2894 |
ref: ref |
| 2895 |
}, children); |
| 2896 |
} |
| 2897 |
|
| 2898 |
class ErrorBoundary extends external_wp_element_namespaceObject.Component { |
| 2899 |
constructor() { |
| 2900 |
super(...arguments); |
| 2901 |
this.reboot = this.reboot.bind(this); |
| 2902 |
this.state = { |
| 2903 |
error: null |
| 2904 |
}; |
| 2905 |
} |
| 2906 |
|
| 2907 |
componentDidCatch(error) { |
| 2908 |
this.setState({ |
| 2909 |
error |
| 2910 |
}); |
| 2911 |
} |
| 2912 |
|
| 2913 |
reboot() { |
| 2914 |
this.props.onError(); |
| 2915 |
} |
| 2916 |
|
| 2917 |
render() { |
| 2918 |
const { |
| 2919 |
error |
| 2920 |
} = this.state; |
| 2921 |
|
| 2922 |
if (!error) { |
| 2923 |
return this.props.children; |
| 2924 |
} |
| 2925 |
|
| 2926 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, { |
| 2927 |
className: "edit-widgets-error-boundary", |
| 2928 |
actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 2929 |
key: "recovery", |
| 2930 |
onClick: this.reboot, |
| 2931 |
variant: "secondary" |
| 2932 |
}, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, { |
| 2933 |
key: "copy-error", |
| 2934 |
text: error.stack |
| 2935 |
}, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))] |
| 2936 |
}, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')); |
| 2937 |
} |
| 2938 |
|
| 2939 |
} |
| 2940 |
//# sourceMappingURL=index.js.map |
| 2941 |
;// CONCATENATED MODULE: external ["wp","reusableBlocks"] |
| 2942 |
var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"]; |
| 2943 |
;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] |
| 2944 |
var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; |
| 2945 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/keyboard-shortcuts/index.js |
| 2946 |
/** |
| 2947 |
* WordPress dependencies |
| 2948 |
*/ |
| 2949 |
|
| 2950 |
|
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
/** |
| 2955 |
* Internal dependencies |
| 2956 |
*/ |
| 2957 |
|
| 2958 |
|
| 2959 |
|
| 2960 |
function KeyboardShortcuts() { |
| 2961 |
const { |
| 2962 |
redo, |
| 2963 |
undo |
| 2964 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); |
| 2965 |
const { |
| 2966 |
saveEditedWidgetAreas |
| 2967 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 2968 |
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/undo', event => { |
| 2969 |
undo(); |
| 2970 |
event.preventDefault(); |
| 2971 |
}); |
| 2972 |
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/redo', event => { |
| 2973 |
redo(); |
| 2974 |
event.preventDefault(); |
| 2975 |
}); |
| 2976 |
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/save', event => { |
| 2977 |
event.preventDefault(); |
| 2978 |
saveEditedWidgetAreas(); |
| 2979 |
}); |
| 2980 |
return null; |
| 2981 |
} |
| 2982 |
|
| 2983 |
function KeyboardShortcutsRegister() { |
| 2984 |
// Registering the shortcuts |
| 2985 |
const { |
| 2986 |
registerShortcut |
| 2987 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); |
| 2988 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 2989 |
registerShortcut({ |
| 2990 |
name: 'core/edit-widgets/undo', |
| 2991 |
category: 'global', |
| 2992 |
description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'), |
| 2993 |
keyCombination: { |
| 2994 |
modifier: 'primary', |
| 2995 |
character: 'z' |
| 2996 |
} |
| 2997 |
}); |
| 2998 |
registerShortcut({ |
| 2999 |
name: 'core/edit-widgets/redo', |
| 3000 |
category: 'global', |
| 3001 |
description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'), |
| 3002 |
keyCombination: { |
| 3003 |
modifier: 'primaryShift', |
| 3004 |
character: 'z' |
| 3005 |
} |
| 3006 |
}); |
| 3007 |
registerShortcut({ |
| 3008 |
name: 'core/edit-widgets/save', |
| 3009 |
category: 'global', |
| 3010 |
description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), |
| 3011 |
keyCombination: { |
| 3012 |
modifier: 'primary', |
| 3013 |
character: 's' |
| 3014 |
} |
| 3015 |
}); |
| 3016 |
registerShortcut({ |
| 3017 |
name: 'core/edit-widgets/keyboard-shortcuts', |
| 3018 |
category: 'main', |
| 3019 |
description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'), |
| 3020 |
keyCombination: { |
| 3021 |
modifier: 'access', |
| 3022 |
character: 'h' |
| 3023 |
} |
| 3024 |
}); |
| 3025 |
registerShortcut({ |
| 3026 |
name: 'core/edit-widgets/next-region', |
| 3027 |
category: 'global', |
| 3028 |
description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'), |
| 3029 |
keyCombination: { |
| 3030 |
modifier: 'ctrl', |
| 3031 |
character: '`' |
| 3032 |
}, |
| 3033 |
aliases: [{ |
| 3034 |
modifier: 'access', |
| 3035 |
character: 'n' |
| 3036 |
}] |
| 3037 |
}); |
| 3038 |
registerShortcut({ |
| 3039 |
name: 'core/edit-widgets/previous-region', |
| 3040 |
category: 'global', |
| 3041 |
description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'), |
| 3042 |
keyCombination: { |
| 3043 |
modifier: 'ctrlShift', |
| 3044 |
character: '`' |
| 3045 |
}, |
| 3046 |
aliases: [{ |
| 3047 |
modifier: 'access', |
| 3048 |
character: 'p' |
| 3049 |
}] |
| 3050 |
}); |
| 3051 |
}, [registerShortcut]); |
| 3052 |
return null; |
| 3053 |
} |
| 3054 |
|
| 3055 |
KeyboardShortcuts.Register = KeyboardShortcutsRegister; |
| 3056 |
/* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts); |
| 3057 |
//# sourceMappingURL=index.js.map |
| 3058 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/hooks/use-last-selected-widget-area.js |
| 3059 |
/** |
| 3060 |
* WordPress dependencies |
| 3061 |
*/ |
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
/** |
| 3066 |
* Internal dependencies |
| 3067 |
*/ |
| 3068 |
|
| 3069 |
|
| 3070 |
|
| 3071 |
/** |
| 3072 |
* A react hook that returns the client id of the last widget area to have |
| 3073 |
* been selected, or to have a selected block within it. |
| 3074 |
* |
| 3075 |
* @return {string} clientId of the widget area last selected. |
| 3076 |
*/ |
| 3077 |
|
| 3078 |
const useLastSelectedWidgetArea = () => (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 3079 |
var _widgetAreasPost$bloc; |
| 3080 |
|
| 3081 |
const { |
| 3082 |
getBlockSelectionEnd, |
| 3083 |
getBlockName |
| 3084 |
} = select(external_wp_blockEditor_namespaceObject.store); |
| 3085 |
const selectionEndClientId = getBlockSelectionEnd(); // If the selected block is a widget area, return its clientId. |
| 3086 |
|
| 3087 |
if (getBlockName(selectionEndClientId) === 'core/widget-area') { |
| 3088 |
return selectionEndClientId; |
| 3089 |
} |
| 3090 |
|
| 3091 |
const { |
| 3092 |
getParentWidgetAreaBlock |
| 3093 |
} = select(store_store); |
| 3094 |
const widgetAreaBlock = getParentWidgetAreaBlock(selectionEndClientId); |
| 3095 |
const widgetAreaBlockClientId = widgetAreaBlock === null || widgetAreaBlock === void 0 ? void 0 : widgetAreaBlock.clientId; |
| 3096 |
|
| 3097 |
if (widgetAreaBlockClientId) { |
| 3098 |
return widgetAreaBlockClientId; |
| 3099 |
} // If no widget area has been selected, return the clientId of the first |
| 3100 |
// area. |
| 3101 |
|
| 3102 |
|
| 3103 |
const { |
| 3104 |
getEntityRecord |
| 3105 |
} = select(external_wp_coreData_namespaceObject.store); |
| 3106 |
const widgetAreasPost = getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId()); |
| 3107 |
return widgetAreasPost === null || widgetAreasPost === void 0 ? void 0 : (_widgetAreasPost$bloc = widgetAreasPost.blocks[0]) === null || _widgetAreasPost$bloc === void 0 ? void 0 : _widgetAreasPost$bloc.clientId; |
| 3108 |
}, []); |
| 3109 |
|
| 3110 |
/* harmony default export */ var use_last_selected_widget_area = (useLastSelectedWidgetArea); |
| 3111 |
//# sourceMappingURL=use-last-selected-widget-area.js.map |
| 3112 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/constants.js |
| 3113 |
const ALLOW_REUSABLE_BLOCKS = false; |
| 3114 |
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; |
| 3115 |
//# sourceMappingURL=constants.js.map |
| 3116 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.js |
| 3117 |
|
| 3118 |
|
| 3119 |
|
| 3120 |
/** |
| 3121 |
* External dependencies |
| 3122 |
*/ |
| 3123 |
|
| 3124 |
/** |
| 3125 |
* WordPress dependencies |
| 3126 |
*/ |
| 3127 |
|
| 3128 |
|
| 3129 |
|
| 3130 |
|
| 3131 |
|
| 3132 |
|
| 3133 |
|
| 3134 |
|
| 3135 |
|
| 3136 |
/** |
| 3137 |
* Internal dependencies |
| 3138 |
*/ |
| 3139 |
|
| 3140 |
|
| 3141 |
|
| 3142 |
|
| 3143 |
|
| 3144 |
|
| 3145 |
|
| 3146 |
function WidgetAreasBlockEditorProvider(_ref) { |
| 3147 |
let { |
| 3148 |
blockEditorSettings, |
| 3149 |
children, |
| 3150 |
...props |
| 3151 |
} = _ref; |
| 3152 |
const { |
| 3153 |
hasUploadPermissions, |
| 3154 |
reusableBlocks, |
| 3155 |
isFixedToolbarActive, |
| 3156 |
keepCaretInsideBlock |
| 3157 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => ({ |
| 3158 |
hasUploadPermissions: (0,external_lodash_namespaceObject.defaultTo)(select(external_wp_coreData_namespaceObject.store).canUser('create', 'media'), true), |
| 3159 |
widgetAreas: select(store_store).getWidgetAreas(), |
| 3160 |
widgets: select(store_store).getWidgets(), |
| 3161 |
reusableBlocks: ALLOW_REUSABLE_BLOCKS ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block') : [], |
| 3162 |
isFixedToolbarActive: select(store).isFeatureActive('core/edit-widgets', 'fixedToolbar'), |
| 3163 |
keepCaretInsideBlock: select(store).isFeatureActive('core/edit-widgets', 'keepCaretInsideBlock') |
| 3164 |
}), []); |
| 3165 |
const { |
| 3166 |
setIsInserterOpened |
| 3167 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 3168 |
const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { |
| 3169 |
let mediaUploadBlockEditor; |
| 3170 |
|
| 3171 |
if (hasUploadPermissions) { |
| 3172 |
mediaUploadBlockEditor = _ref2 => { |
| 3173 |
let { |
| 3174 |
onError, |
| 3175 |
...argumentsObject |
| 3176 |
} = _ref2; |
| 3177 |
(0,external_wp_mediaUtils_namespaceObject.uploadMedia)({ |
| 3178 |
wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes, |
| 3179 |
onError: _ref3 => { |
| 3180 |
let { |
| 3181 |
message |
| 3182 |
} = _ref3; |
| 3183 |
return onError(message); |
| 3184 |
}, |
| 3185 |
...argumentsObject |
| 3186 |
}); |
| 3187 |
}; |
| 3188 |
} |
| 3189 |
|
| 3190 |
return { ...blockEditorSettings, |
| 3191 |
__experimentalReusableBlocks: reusableBlocks, |
| 3192 |
hasFixedToolbar: isFixedToolbarActive, |
| 3193 |
keepCaretInsideBlock, |
| 3194 |
mediaUpload: mediaUploadBlockEditor, |
| 3195 |
templateLock: 'all', |
| 3196 |
__experimentalSetIsInserterOpened: setIsInserterOpened |
| 3197 |
}; |
| 3198 |
}, [blockEditorSettings, isFixedToolbarActive, keepCaretInsideBlock, hasUploadPermissions, reusableBlocks, setIsInserterOpened]); |
| 3199 |
const widgetAreaId = use_last_selected_widget_area(); |
| 3200 |
const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)(KIND, POST_TYPE, { |
| 3201 |
id: buildWidgetAreasPostId() |
| 3202 |
}); |
| 3203 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, 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)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, _extends({ |
| 3204 |
value: blocks, |
| 3205 |
onInput: onInput, |
| 3206 |
onChange: onChange, |
| 3207 |
settings: settings, |
| 3208 |
useSubRegistry: false |
| 3209 |
}, props), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.CopyHandler, null, children), (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, { |
| 3210 |
rootClientId: widgetAreaId |
| 3211 |
})))); |
| 3212 |
} |
| 3213 |
//# sourceMappingURL=index.js.map |
| 3214 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js |
| 3215 |
|
| 3216 |
|
| 3217 |
/** |
| 3218 |
* WordPress dependencies |
| 3219 |
*/ |
| 3220 |
|
| 3221 |
const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3222 |
xmlns: "http://www.w3.org/2000/svg", |
| 3223 |
viewBox: "0 0 24 24" |
| 3224 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3225 |
fillRule: "evenodd", |
| 3226 |
d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z", |
| 3227 |
clipRule: "evenodd" |
| 3228 |
})); |
| 3229 |
/* harmony default export */ var library_cog = (cog); |
| 3230 |
//# sourceMappingURL=cog.js.map |
| 3231 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js |
| 3232 |
|
| 3233 |
|
| 3234 |
/** |
| 3235 |
* WordPress dependencies |
| 3236 |
*/ |
| 3237 |
|
| 3238 |
const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3239 |
xmlns: "http://www.w3.org/2000/svg", |
| 3240 |
viewBox: "0 0 24 24" |
| 3241 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3242 |
d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" |
| 3243 |
})); |
| 3244 |
/* harmony default export */ var block_default = (blockDefault); |
| 3245 |
//# sourceMappingURL=block-default.js.map |
| 3246 |
;// CONCATENATED MODULE: external ["wp","url"] |
| 3247 |
var external_wp_url_namespaceObject = window["wp"]["url"]; |
| 3248 |
;// CONCATENATED MODULE: external ["wp","dom"] |
| 3249 |
var external_wp_dom_namespaceObject = window["wp"]["dom"]; |
| 3250 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/sidebar/widget-areas.js |
| 3251 |
|
| 3252 |
|
| 3253 |
/** |
| 3254 |
* WordPress dependencies |
| 3255 |
*/ |
| 3256 |
|
| 3257 |
|
| 3258 |
|
| 3259 |
|
| 3260 |
|
| 3261 |
|
| 3262 |
|
| 3263 |
|
| 3264 |
/** |
| 3265 |
* Internal dependencies |
| 3266 |
*/ |
| 3267 |
|
| 3268 |
|
| 3269 |
function WidgetAreas(_ref) { |
| 3270 |
let { |
| 3271 |
selectedWidgetAreaId |
| 3272 |
} = _ref; |
| 3273 |
const widgetAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getWidgetAreas(), []); |
| 3274 |
const selectedWidgetArea = (0,external_wp_element_namespaceObject.useMemo)(() => selectedWidgetAreaId && (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.find(widgetArea => widgetArea.id === selectedWidgetAreaId)), [selectedWidgetAreaId, widgetAreas]); |
| 3275 |
let description; |
| 3276 |
|
| 3277 |
if (!selectedWidgetArea) { |
| 3278 |
description = (0,external_wp_i18n_namespaceObject.__)('Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'); |
| 3279 |
} else if (selectedWidgetAreaId === 'wp_inactive_widgets') { |
| 3280 |
description = (0,external_wp_i18n_namespaceObject.__)('Blocks in this Widget Area will not be displayed in your site.'); |
| 3281 |
} else { |
| 3282 |
description = selectedWidgetArea.description; |
| 3283 |
} |
| 3284 |
|
| 3285 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
| 3286 |
className: "edit-widgets-widget-areas" |
| 3287 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 3288 |
className: "edit-widgets-widget-areas__top-container" |
| 3289 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { |
| 3290 |
icon: block_default |
| 3291 |
}), (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)("p", { |
| 3292 |
// Use `dangerouslySetInnerHTML` to keep backwards |
| 3293 |
// compatibility. Basic markup in the description is an |
| 3294 |
// established feature of WordPress. |
| 3295 |
// @see https://github.com/WordPress/gutenberg/issues/33106 |
| 3296 |
dangerouslySetInnerHTML: { |
| 3297 |
__html: (0,external_wp_dom_namespaceObject.safeHTML)(description) |
| 3298 |
} |
| 3299 |
}), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 3300 |
href: (0,external_wp_url_namespaceObject.addQueryArgs)('customize.php', { |
| 3301 |
'autofocus[panel]': 'widgets', |
| 3302 |
return: window.location.pathname |
| 3303 |
}), |
| 3304 |
variant: "tertiary" |
| 3305 |
}, (0,external_wp_i18n_namespaceObject.__)('Manage with live preview'))))); |
| 3306 |
} |
| 3307 |
//# sourceMappingURL=widget-areas.js.map |
| 3308 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/sidebar/index.js |
| 3309 |
|
| 3310 |
|
| 3311 |
/** |
| 3312 |
* External dependencies |
| 3313 |
*/ |
| 3314 |
|
| 3315 |
/** |
| 3316 |
* WordPress dependencies |
| 3317 |
*/ |
| 3318 |
|
| 3319 |
|
| 3320 |
|
| 3321 |
|
| 3322 |
|
| 3323 |
|
| 3324 |
|
| 3325 |
|
| 3326 |
const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({ |
| 3327 |
web: true, |
| 3328 |
native: false |
| 3329 |
}); |
| 3330 |
const BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector'; // Widget areas were one called block areas, so use 'edit-widgets/block-areas' |
| 3331 |
// for backwards compatibility. |
| 3332 |
|
| 3333 |
const WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas'; |
| 3334 |
/** |
| 3335 |
* Internal dependencies |
| 3336 |
*/ |
| 3337 |
|
| 3338 |
|
| 3339 |
|
| 3340 |
|
| 3341 |
function ComplementaryAreaTab(_ref) { |
| 3342 |
let { |
| 3343 |
identifier, |
| 3344 |
label, |
| 3345 |
isActive |
| 3346 |
} = _ref; |
| 3347 |
const { |
| 3348 |
enableComplementaryArea |
| 3349 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 3350 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 3351 |
onClick: () => enableComplementaryArea(store_store.name, identifier), |
| 3352 |
className: classnames_default()('edit-widgets-sidebar__panel-tab', { |
| 3353 |
'is-active': isActive |
| 3354 |
}), |
| 3355 |
"aria-label": isActive ? // translators: %s: sidebar label e.g: "Widget Areas". |
| 3356 |
(0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s (selected)'), label) : label, |
| 3357 |
"data-label": label |
| 3358 |
}, label); |
| 3359 |
} |
| 3360 |
|
| 3361 |
function Sidebar() { |
| 3362 |
const { |
| 3363 |
enableComplementaryArea |
| 3364 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 3365 |
const { |
| 3366 |
currentArea, |
| 3367 |
hasSelectedNonAreaBlock, |
| 3368 |
isGeneralSidebarOpen, |
| 3369 |
selectedWidgetAreaBlock |
| 3370 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 3371 |
const { |
| 3372 |
getSelectedBlock, |
| 3373 |
getBlock, |
| 3374 |
getBlockParentsByBlockName |
| 3375 |
} = select(external_wp_blockEditor_namespaceObject.store); |
| 3376 |
const { |
| 3377 |
getActiveComplementaryArea |
| 3378 |
} = select(store); |
| 3379 |
const selectedBlock = getSelectedBlock(); |
| 3380 |
const activeArea = getActiveComplementaryArea(store_store.name); |
| 3381 |
let currentSelection = activeArea; |
| 3382 |
|
| 3383 |
if (!currentSelection) { |
| 3384 |
if (selectedBlock) { |
| 3385 |
currentSelection = BLOCK_INSPECTOR_IDENTIFIER; |
| 3386 |
} else { |
| 3387 |
currentSelection = WIDGET_AREAS_IDENTIFIER; |
| 3388 |
} |
| 3389 |
} |
| 3390 |
|
| 3391 |
let widgetAreaBlock; |
| 3392 |
|
| 3393 |
if (selectedBlock) { |
| 3394 |
if (selectedBlock.name === 'core/widget-area') { |
| 3395 |
widgetAreaBlock = selectedBlock; |
| 3396 |
} else { |
| 3397 |
widgetAreaBlock = getBlock(getBlockParentsByBlockName(selectedBlock.clientId, 'core/widget-area')[0]); |
| 3398 |
} |
| 3399 |
} |
| 3400 |
|
| 3401 |
return { |
| 3402 |
currentArea: currentSelection, |
| 3403 |
hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== 'core/widget-area'), |
| 3404 |
isGeneralSidebarOpen: !!activeArea, |
| 3405 |
selectedWidgetAreaBlock: widgetAreaBlock |
| 3406 |
}; |
| 3407 |
}, []); // currentArea, and isGeneralSidebarOpen are intentionally left out from the dependencies, |
| 3408 |
// because we want to run the effect when a block is selected/unselected and not when the sidebar state changes. |
| 3409 |
|
| 3410 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 3411 |
if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) { |
| 3412 |
enableComplementaryArea('core/edit-widgets', BLOCK_INSPECTOR_IDENTIFIER); |
| 3413 |
} |
| 3414 |
|
| 3415 |
if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) { |
| 3416 |
enableComplementaryArea('core/edit-widgets', WIDGET_AREAS_IDENTIFIER); |
| 3417 |
} |
| 3418 |
}, [hasSelectedNonAreaBlock, enableComplementaryArea]); |
| 3419 |
return (0,external_wp_element_namespaceObject.createElement)(complementary_area, { |
| 3420 |
className: "edit-widgets-sidebar", |
| 3421 |
header: (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaTab, { |
| 3422 |
identifier: WIDGET_AREAS_IDENTIFIER, |
| 3423 |
label: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0,external_wp_i18n_namespaceObject.__)('Widget Areas'), |
| 3424 |
isActive: currentArea === WIDGET_AREAS_IDENTIFIER |
| 3425 |
})), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaTab, { |
| 3426 |
identifier: BLOCK_INSPECTOR_IDENTIFIER, |
| 3427 |
label: (0,external_wp_i18n_namespaceObject.__)('Block'), |
| 3428 |
isActive: currentArea === BLOCK_INSPECTOR_IDENTIFIER |
| 3429 |
}))), |
| 3430 |
headerClassName: "edit-widgets-sidebar__panel-tabs" |
| 3431 |
/* translators: button label text should, if possible, be under 16 characters. */ |
| 3432 |
, |
| 3433 |
title: (0,external_wp_i18n_namespaceObject.__)('Settings'), |
| 3434 |
closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'), |
| 3435 |
scope: "core/edit-widgets", |
| 3436 |
identifier: currentArea, |
| 3437 |
icon: library_cog, |
| 3438 |
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT |
| 3439 |
}, currentArea === WIDGET_AREAS_IDENTIFIER && (0,external_wp_element_namespaceObject.createElement)(WidgetAreas, { |
| 3440 |
selectedWidgetAreaId: selectedWidgetAreaBlock === null || selectedWidgetAreaBlock === void 0 ? void 0 : selectedWidgetAreaBlock.attributes.id |
| 3441 |
}), currentArea === BLOCK_INSPECTOR_IDENTIFIER && (hasSelectedNonAreaBlock ? (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null) : // Pretend that Widget Areas are part of the UI by not |
| 3442 |
// showing the Block Inspector when one is selected. |
| 3443 |
(0,external_wp_element_namespaceObject.createElement)("span", { |
| 3444 |
className: "block-editor-block-inspector__no-blocks" |
| 3445 |
}, (0,external_wp_i18n_namespaceObject.__)('No block selected.')))); |
| 3446 |
} |
| 3447 |
//# sourceMappingURL=index.js.map |
| 3448 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js |
| 3449 |
|
| 3450 |
|
| 3451 |
/** |
| 3452 |
* WordPress dependencies |
| 3453 |
*/ |
| 3454 |
|
| 3455 |
const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3456 |
xmlns: "http://www.w3.org/2000/svg", |
| 3457 |
viewBox: "0 0 24 24" |
| 3458 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3459 |
d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z" |
| 3460 |
})); |
| 3461 |
/* harmony default export */ var library_plus = (plus); |
| 3462 |
//# sourceMappingURL=plus.js.map |
| 3463 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js |
| 3464 |
|
| 3465 |
|
| 3466 |
/** |
| 3467 |
* WordPress dependencies |
| 3468 |
*/ |
| 3469 |
|
| 3470 |
const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3471 |
viewBox: "0 0 24 24", |
| 3472 |
xmlns: "http://www.w3.org/2000/svg" |
| 3473 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3474 |
d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z" |
| 3475 |
})); |
| 3476 |
/* harmony default export */ var list_view = (listView); |
| 3477 |
//# sourceMappingURL=list-view.js.map |
| 3478 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/save-button/index.js |
| 3479 |
|
| 3480 |
|
| 3481 |
/** |
| 3482 |
* WordPress dependencies |
| 3483 |
*/ |
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
/** |
| 3488 |
* Internal dependencies |
| 3489 |
*/ |
| 3490 |
|
| 3491 |
|
| 3492 |
|
| 3493 |
function SaveButton() { |
| 3494 |
const { |
| 3495 |
hasEditedWidgetAreaIds, |
| 3496 |
isSaving |
| 3497 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 3498 |
var _getEditedWidgetAreas; |
| 3499 |
|
| 3500 |
const { |
| 3501 |
getEditedWidgetAreas, |
| 3502 |
isSavingWidgetAreas |
| 3503 |
} = select(store_store); |
| 3504 |
return { |
| 3505 |
hasEditedWidgetAreaIds: ((_getEditedWidgetAreas = getEditedWidgetAreas()) === null || _getEditedWidgetAreas === void 0 ? void 0 : _getEditedWidgetAreas.length) > 0, |
| 3506 |
isSaving: isSavingWidgetAreas() |
| 3507 |
}; |
| 3508 |
}, []); |
| 3509 |
const { |
| 3510 |
saveEditedWidgetAreas |
| 3511 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 3512 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 3513 |
variant: "primary", |
| 3514 |
isBusy: isSaving, |
| 3515 |
"aria-disabled": isSaving, |
| 3516 |
onClick: isSaving ? undefined : saveEditedWidgetAreas, |
| 3517 |
disabled: !hasEditedWidgetAreaIds |
| 3518 |
}, isSaving ? (0,external_wp_i18n_namespaceObject.__)('Saving…') : (0,external_wp_i18n_namespaceObject.__)('Update')); |
| 3519 |
} |
| 3520 |
|
| 3521 |
/* harmony default export */ var save_button = (SaveButton); |
| 3522 |
//# sourceMappingURL=index.js.map |
| 3523 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js |
| 3524 |
|
| 3525 |
|
| 3526 |
/** |
| 3527 |
* WordPress dependencies |
| 3528 |
*/ |
| 3529 |
|
| 3530 |
const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3531 |
xmlns: "http://www.w3.org/2000/svg", |
| 3532 |
viewBox: "0 0 24 24" |
| 3533 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3534 |
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" |
| 3535 |
})); |
| 3536 |
/* harmony default export */ var library_undo = (undo); |
| 3537 |
//# sourceMappingURL=undo.js.map |
| 3538 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js |
| 3539 |
|
| 3540 |
|
| 3541 |
/** |
| 3542 |
* WordPress dependencies |
| 3543 |
*/ |
| 3544 |
|
| 3545 |
const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3546 |
xmlns: "http://www.w3.org/2000/svg", |
| 3547 |
viewBox: "0 0 24 24" |
| 3548 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3549 |
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" |
| 3550 |
})); |
| 3551 |
/* harmony default export */ var library_redo = (redo); |
| 3552 |
//# sourceMappingURL=redo.js.map |
| 3553 |
;// CONCATENATED MODULE: external ["wp","keycodes"] |
| 3554 |
var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; |
| 3555 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/header/undo-redo/undo.js |
| 3556 |
|
| 3557 |
|
| 3558 |
/** |
| 3559 |
* WordPress dependencies |
| 3560 |
*/ |
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
|
| 3567 |
function UndoButton() { |
| 3568 |
const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []); |
| 3569 |
const { |
| 3570 |
undo |
| 3571 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); |
| 3572 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { |
| 3573 |
icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo, |
| 3574 |
label: (0,external_wp_i18n_namespaceObject.__)('Undo'), |
| 3575 |
shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this |
| 3576 |
// button, because it will remove focus for keyboard users. |
| 3577 |
// See: https://github.com/WordPress/gutenberg/issues/3486 |
| 3578 |
, |
| 3579 |
"aria-disabled": !hasUndo, |
| 3580 |
onClick: hasUndo ? undo : undefined |
| 3581 |
}); |
| 3582 |
} |
| 3583 |
//# sourceMappingURL=undo.js.map |
| 3584 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/header/undo-redo/redo.js |
| 3585 |
|
| 3586 |
|
| 3587 |
/** |
| 3588 |
* WordPress dependencies |
| 3589 |
*/ |
| 3590 |
|
| 3591 |
|
| 3592 |
|
| 3593 |
|
| 3594 |
|
| 3595 |
|
| 3596 |
function RedoButton() { |
| 3597 |
const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []); |
| 3598 |
const { |
| 3599 |
redo |
| 3600 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); |
| 3601 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { |
| 3602 |
icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo, |
| 3603 |
label: (0,external_wp_i18n_namespaceObject.__)('Redo'), |
| 3604 |
shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this |
| 3605 |
// button, because it will remove focus for keyboard users. |
| 3606 |
// See: https://github.com/WordPress/gutenberg/issues/3486 |
| 3607 |
, |
| 3608 |
"aria-disabled": !hasRedo, |
| 3609 |
onClick: hasRedo ? redo : undefined |
| 3610 |
}); |
| 3611 |
} |
| 3612 |
//# sourceMappingURL=redo.js.map |
| 3613 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js |
| 3614 |
|
| 3615 |
|
| 3616 |
/** |
| 3617 |
* WordPress dependencies |
| 3618 |
*/ |
| 3619 |
|
| 3620 |
const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 3621 |
xmlns: "http://www.w3.org/2000/svg", |
| 3622 |
viewBox: "0 0 24 24" |
| 3623 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 3624 |
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" |
| 3625 |
})); |
| 3626 |
/* harmony default export */ var library_external = (external); |
| 3627 |
//# sourceMappingURL=external.js.map |
| 3628 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.js |
| 3629 |
/** |
| 3630 |
* WordPress dependencies |
| 3631 |
*/ |
| 3632 |
|
| 3633 |
const textFormattingShortcuts = [{ |
| 3634 |
keyCombination: { |
| 3635 |
modifier: 'primary', |
| 3636 |
character: 'b' |
| 3637 |
}, |
| 3638 |
description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.') |
| 3639 |
}, { |
| 3640 |
keyCombination: { |
| 3641 |
modifier: 'primary', |
| 3642 |
character: 'i' |
| 3643 |
}, |
| 3644 |
description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.') |
| 3645 |
}, { |
| 3646 |
keyCombination: { |
| 3647 |
modifier: 'primary', |
| 3648 |
character: 'k' |
| 3649 |
}, |
| 3650 |
description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.') |
| 3651 |
}, { |
| 3652 |
keyCombination: { |
| 3653 |
modifier: 'primaryShift', |
| 3654 |
character: 'k' |
| 3655 |
}, |
| 3656 |
description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.') |
| 3657 |
}, { |
| 3658 |
keyCombination: { |
| 3659 |
modifier: 'primary', |
| 3660 |
character: 'u' |
| 3661 |
}, |
| 3662 |
description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.') |
| 3663 |
}]; |
| 3664 |
//# sourceMappingURL=config.js.map |
| 3665 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.js |
| 3666 |
|
| 3667 |
|
| 3668 |
/** |
| 3669 |
* External dependencies |
| 3670 |
*/ |
| 3671 |
|
| 3672 |
/** |
| 3673 |
* WordPress dependencies |
| 3674 |
*/ |
| 3675 |
|
| 3676 |
|
| 3677 |
|
| 3678 |
|
| 3679 |
function KeyCombination(_ref) { |
| 3680 |
let { |
| 3681 |
keyCombination, |
| 3682 |
forceAriaLabel |
| 3683 |
} = _ref; |
| 3684 |
const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character; |
| 3685 |
const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character; |
| 3686 |
return (0,external_wp_element_namespaceObject.createElement)("kbd", { |
| 3687 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination", |
| 3688 |
"aria-label": forceAriaLabel || ariaLabel |
| 3689 |
}, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => { |
| 3690 |
if (character === '+') { |
| 3691 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, { |
| 3692 |
key: index |
| 3693 |
}, character); |
| 3694 |
} |
| 3695 |
|
| 3696 |
return (0,external_wp_element_namespaceObject.createElement)("kbd", { |
| 3697 |
key: index, |
| 3698 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key" |
| 3699 |
}, character); |
| 3700 |
})); |
| 3701 |
} |
| 3702 |
|
| 3703 |
function Shortcut(_ref2) { |
| 3704 |
let { |
| 3705 |
description, |
| 3706 |
keyCombination, |
| 3707 |
aliases = [], |
| 3708 |
ariaLabel |
| 3709 |
} = _ref2; |
| 3710 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 3711 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description" |
| 3712 |
}, description), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 3713 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term" |
| 3714 |
}, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, { |
| 3715 |
keyCombination: keyCombination, |
| 3716 |
forceAriaLabel: ariaLabel |
| 3717 |
}), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, { |
| 3718 |
keyCombination: alias, |
| 3719 |
forceAriaLabel: ariaLabel, |
| 3720 |
key: index |
| 3721 |
})))); |
| 3722 |
} |
| 3723 |
|
| 3724 |
/* harmony default export */ var keyboard_shortcut_help_modal_shortcut = (Shortcut); |
| 3725 |
//# sourceMappingURL=shortcut.js.map |
| 3726 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js |
| 3727 |
|
| 3728 |
|
| 3729 |
/** |
| 3730 |
* WordPress dependencies |
| 3731 |
*/ |
| 3732 |
|
| 3733 |
|
| 3734 |
/** |
| 3735 |
* Internal dependencies |
| 3736 |
*/ |
| 3737 |
|
| 3738 |
|
| 3739 |
|
| 3740 |
function DynamicShortcut(_ref) { |
| 3741 |
let { |
| 3742 |
name |
| 3743 |
} = _ref; |
| 3744 |
const { |
| 3745 |
keyCombination, |
| 3746 |
description, |
| 3747 |
aliases |
| 3748 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 3749 |
const { |
| 3750 |
getShortcutKeyCombination, |
| 3751 |
getShortcutDescription, |
| 3752 |
getShortcutAliases |
| 3753 |
} = select(external_wp_keyboardShortcuts_namespaceObject.store); |
| 3754 |
return { |
| 3755 |
keyCombination: getShortcutKeyCombination(name), |
| 3756 |
aliases: getShortcutAliases(name), |
| 3757 |
description: getShortcutDescription(name) |
| 3758 |
}; |
| 3759 |
}, [name]); |
| 3760 |
|
| 3761 |
if (!keyCombination) { |
| 3762 |
return null; |
| 3763 |
} |
| 3764 |
|
| 3765 |
return (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, { |
| 3766 |
keyCombination: keyCombination, |
| 3767 |
description: description, |
| 3768 |
aliases: aliases |
| 3769 |
}); |
| 3770 |
} |
| 3771 |
|
| 3772 |
/* harmony default export */ var dynamic_shortcut = (DynamicShortcut); |
| 3773 |
//# sourceMappingURL=dynamic-shortcut.js.map |
| 3774 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.js |
| 3775 |
|
| 3776 |
|
| 3777 |
/** |
| 3778 |
* External dependencies |
| 3779 |
*/ |
| 3780 |
|
| 3781 |
|
| 3782 |
/** |
| 3783 |
* WordPress dependencies |
| 3784 |
*/ |
| 3785 |
|
| 3786 |
|
| 3787 |
|
| 3788 |
|
| 3789 |
|
| 3790 |
/** |
| 3791 |
* Internal dependencies |
| 3792 |
*/ |
| 3793 |
|
| 3794 |
|
| 3795 |
|
| 3796 |
|
| 3797 |
|
| 3798 |
const ShortcutList = _ref => { |
| 3799 |
let { |
| 3800 |
shortcuts |
| 3801 |
} = _ref; |
| 3802 |
return ( |
| 3803 |
/* |
| 3804 |
* Disable reason: The `list` ARIA role is redundant but |
| 3805 |
* Safari+VoiceOver won't announce the list otherwise. |
| 3806 |
*/ |
| 3807 |
|
| 3808 |
/* eslint-disable jsx-a11y/no-redundant-roles */ |
| 3809 |
(0,external_wp_element_namespaceObject.createElement)("ul", { |
| 3810 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list", |
| 3811 |
role: "list" |
| 3812 |
}, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", { |
| 3813 |
className: "edit-widgets-keyboard-shortcut-help-modal__shortcut", |
| 3814 |
key: index |
| 3815 |
}, (0,external_lodash_namespaceObject.isString)(shortcut) ? (0,external_wp_element_namespaceObject.createElement)(dynamic_shortcut, { |
| 3816 |
name: shortcut |
| 3817 |
}) : (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, shortcut)))) |
| 3818 |
/* eslint-enable jsx-a11y/no-redundant-roles */ |
| 3819 |
|
| 3820 |
); |
| 3821 |
}; |
| 3822 |
|
| 3823 |
const ShortcutSection = _ref2 => { |
| 3824 |
let { |
| 3825 |
title, |
| 3826 |
shortcuts, |
| 3827 |
className |
| 3828 |
} = _ref2; |
| 3829 |
return (0,external_wp_element_namespaceObject.createElement)("section", { |
| 3830 |
className: classnames_default()('edit-widgets-keyboard-shortcut-help-modal__section', className) |
| 3831 |
}, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", { |
| 3832 |
className: "edit-widgets-keyboard-shortcut-help-modal__section-title" |
| 3833 |
}, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, { |
| 3834 |
shortcuts: shortcuts |
| 3835 |
})); |
| 3836 |
}; |
| 3837 |
|
| 3838 |
const ShortcutCategorySection = _ref3 => { |
| 3839 |
let { |
| 3840 |
title, |
| 3841 |
categoryName, |
| 3842 |
additionalShortcuts = [] |
| 3843 |
} = _ref3; |
| 3844 |
const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 3845 |
return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName); |
| 3846 |
}, [categoryName]); |
| 3847 |
return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { |
| 3848 |
title: title, |
| 3849 |
shortcuts: categoryShortcuts.concat(additionalShortcuts) |
| 3850 |
}); |
| 3851 |
}; |
| 3852 |
|
| 3853 |
function KeyboardShortcutHelpModal(_ref4) { |
| 3854 |
let { |
| 3855 |
isModalActive, |
| 3856 |
toggleModal |
| 3857 |
} = _ref4; |
| 3858 |
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/keyboard-shortcuts', toggleModal, { |
| 3859 |
bindGlobal: true |
| 3860 |
}); |
| 3861 |
|
| 3862 |
if (!isModalActive) { |
| 3863 |
return null; |
| 3864 |
} |
| 3865 |
|
| 3866 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { |
| 3867 |
className: "edit-widgets-keyboard-shortcut-help-modal", |
| 3868 |
title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), |
| 3869 |
closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'), |
| 3870 |
onRequestClose: toggleModal |
| 3871 |
}, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { |
| 3872 |
className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts", |
| 3873 |
shortcuts: ['core/edit-widgets/keyboard-shortcuts'] |
| 3874 |
}), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { |
| 3875 |
title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'), |
| 3876 |
categoryName: "global" |
| 3877 |
}), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { |
| 3878 |
title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'), |
| 3879 |
categoryName: "selection" |
| 3880 |
}), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { |
| 3881 |
title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'), |
| 3882 |
categoryName: "block", |
| 3883 |
additionalShortcuts: [{ |
| 3884 |
keyCombination: { |
| 3885 |
character: '/' |
| 3886 |
}, |
| 3887 |
description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'), |
| 3888 |
|
| 3889 |
/* translators: The forward-slash character. e.g. '/'. */ |
| 3890 |
ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash') |
| 3891 |
}] |
| 3892 |
}), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { |
| 3893 |
title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'), |
| 3894 |
shortcuts: textFormattingShortcuts |
| 3895 |
})); |
| 3896 |
} |
| 3897 |
//# sourceMappingURL=index.js.map |
| 3898 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/more-menu/index.js |
| 3899 |
|
| 3900 |
|
| 3901 |
/** |
| 3902 |
* WordPress dependencies |
| 3903 |
*/ |
| 3904 |
|
| 3905 |
|
| 3906 |
|
| 3907 |
|
| 3908 |
|
| 3909 |
|
| 3910 |
|
| 3911 |
|
| 3912 |
/** |
| 3913 |
* Internal dependencies |
| 3914 |
*/ |
| 3915 |
|
| 3916 |
|
| 3917 |
function MoreMenu() { |
| 3918 |
const [isKeyboardShortcutsModalActive, setIsKeyboardShortcutsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false); |
| 3919 |
|
| 3920 |
const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive); |
| 3921 |
|
| 3922 |
(0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-widgets/keyboard-shortcuts', toggleKeyboardShortcutsModal); |
| 3923 |
const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); |
| 3924 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { |
| 3925 |
label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun') |
| 3926 |
}, (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, { |
| 3927 |
scope: "core/edit-widgets", |
| 3928 |
feature: "fixedToolbar", |
| 3929 |
label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'), |
| 3930 |
info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'), |
| 3931 |
messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'), |
| 3932 |
messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated') |
| 3933 |
})), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { |
| 3934 |
label: (0,external_wp_i18n_namespaceObject.__)('Tools') |
| 3935 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
| 3936 |
onClick: () => { |
| 3937 |
setIsKeyboardShortcutsModalVisible(true); |
| 3938 |
}, |
| 3939 |
shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h') |
| 3940 |
}, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, { |
| 3941 |
scope: "core/edit-widgets", |
| 3942 |
feature: "welcomeGuide", |
| 3943 |
label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide') |
| 3944 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
| 3945 |
role: "menuitem", |
| 3946 |
icon: library_external, |
| 3947 |
href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/block-based-widgets-editor/'), |
| 3948 |
target: "_blank", |
| 3949 |
rel: "noopener noreferrer" |
| 3950 |
}, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { |
| 3951 |
as: "span" |
| 3952 |
}, |
| 3953 |
/* translators: accessibility text */ |
| 3954 |
(0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { |
| 3955 |
label: (0,external_wp_i18n_namespaceObject.__)('Preferences') |
| 3956 |
}, (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, { |
| 3957 |
scope: "core/edit-widgets", |
| 3958 |
feature: "keepCaretInsideBlock", |
| 3959 |
label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block'), |
| 3960 |
info: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'), |
| 3961 |
messageActivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block activated'), |
| 3962 |
messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block deactivated') |
| 3963 |
}), (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, { |
| 3964 |
scope: "core/edit-widgets", |
| 3965 |
feature: "themeStyles", |
| 3966 |
info: (0,external_wp_i18n_namespaceObject.__)('Make the editor look like your theme.'), |
| 3967 |
label: (0,external_wp_i18n_namespaceObject.__)('Use theme styles') |
| 3968 |
}), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, { |
| 3969 |
scope: "core/edit-widgets", |
| 3970 |
feature: "showBlockBreadcrumbs", |
| 3971 |
label: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs'), |
| 3972 |
info: (0,external_wp_i18n_namespaceObject.__)('Shows block breadcrumbs at the bottom of the editor.'), |
| 3973 |
messageActivated: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs activated'), |
| 3974 |
messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs deactivated') |
| 3975 |
})))), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, { |
| 3976 |
isModalActive: isKeyboardShortcutsModalActive, |
| 3977 |
toggleModal: toggleKeyboardShortcutsModal |
| 3978 |
})); |
| 3979 |
} |
| 3980 |
//# sourceMappingURL=index.js.map |
| 3981 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/header/index.js |
| 3982 |
|
| 3983 |
|
| 3984 |
/** |
| 3985 |
* WordPress dependencies |
| 3986 |
*/ |
| 3987 |
|
| 3988 |
|
| 3989 |
|
| 3990 |
|
| 3991 |
|
| 3992 |
|
| 3993 |
|
| 3994 |
|
| 3995 |
/** |
| 3996 |
* Internal dependencies |
| 3997 |
*/ |
| 3998 |
|
| 3999 |
|
| 4000 |
|
| 4001 |
|
| 4002 |
|
| 4003 |
|
| 4004 |
|
| 4005 |
|
| 4006 |
function Header() { |
| 4007 |
const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); |
| 4008 |
const inserterButton = (0,external_wp_element_namespaceObject.useRef)(); |
| 4009 |
const widgetAreaClientId = use_last_selected_widget_area(); |
| 4010 |
const isLastSelectedWidgetAreaOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getIsWidgetAreaOpen(widgetAreaClientId), [widgetAreaClientId]); |
| 4011 |
const { |
| 4012 |
isInserterOpen, |
| 4013 |
isListViewOpen |
| 4014 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4015 |
const { |
| 4016 |
isInserterOpened, |
| 4017 |
isListViewOpened |
| 4018 |
} = select(store_store); |
| 4019 |
return { |
| 4020 |
isInserterOpen: isInserterOpened(), |
| 4021 |
isListViewOpen: isListViewOpened() |
| 4022 |
}; |
| 4023 |
}, []); |
| 4024 |
const { |
| 4025 |
setIsWidgetAreaOpen, |
| 4026 |
setIsInserterOpened, |
| 4027 |
setIsListViewOpened |
| 4028 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 4029 |
const { |
| 4030 |
selectBlock |
| 4031 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); |
| 4032 |
|
| 4033 |
const handleClick = () => { |
| 4034 |
if (isInserterOpen) { |
| 4035 |
// Focusing the inserter button closes the inserter popover |
| 4036 |
setIsInserterOpened(false); |
| 4037 |
} else { |
| 4038 |
if (!isLastSelectedWidgetAreaOpen) { |
| 4039 |
// Select the last selected block if hasn't already. |
| 4040 |
selectBlock(widgetAreaClientId); // Open the last selected widget area when opening the inserter. |
| 4041 |
|
| 4042 |
setIsWidgetAreaOpen(widgetAreaClientId, true); |
| 4043 |
} // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the |
| 4044 |
// same tick and pretty much in a random order. The inserter is closed if any other part of the |
| 4045 |
// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then |
| 4046 |
// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to |
| 4047 |
// the selected block. |
| 4048 |
|
| 4049 |
|
| 4050 |
window.requestAnimationFrame(() => setIsInserterOpened(true)); |
| 4051 |
} |
| 4052 |
}; |
| 4053 |
|
| 4054 |
const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]); |
| 4055 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4056 |
className: "edit-widgets-header" |
| 4057 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4058 |
className: "edit-widgets-header__navigable-toolbar-wrapper" |
| 4059 |
}, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)("h1", { |
| 4060 |
className: "edit-widgets-header__title" |
| 4061 |
}, (0,external_wp_i18n_namespaceObject.__)('Widgets')), !isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { |
| 4062 |
as: "h1", |
| 4063 |
className: "edit-widgets-header__title" |
| 4064 |
}, (0,external_wp_i18n_namespaceObject.__)('Widgets')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, { |
| 4065 |
className: "edit-widgets-header-toolbar", |
| 4066 |
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools') |
| 4067 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { |
| 4068 |
ref: inserterButton, |
| 4069 |
as: external_wp_components_namespaceObject.Button, |
| 4070 |
className: "edit-widgets-header-toolbar__inserter-toggle", |
| 4071 |
variant: "primary", |
| 4072 |
isPressed: isInserterOpen, |
| 4073 |
onMouseDown: event => { |
| 4074 |
event.preventDefault(); |
| 4075 |
}, |
| 4076 |
onClick: handleClick, |
| 4077 |
icon: library_plus |
| 4078 |
/* translators: button label text should, if possible, be under 16 |
| 4079 |
characters. */ |
| 4080 |
, |
| 4081 |
label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button') |
| 4082 |
}), isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { |
| 4083 |
as: external_wp_components_namespaceObject.Button, |
| 4084 |
className: "edit-widgets-header-toolbar__list-view-toggle", |
| 4085 |
icon: list_view, |
| 4086 |
isPressed: isListViewOpen |
| 4087 |
/* translators: button label text should, if possible, be under 16 characters. */ |
| 4088 |
, |
| 4089 |
label: (0,external_wp_i18n_namespaceObject.__)('List View'), |
| 4090 |
onClick: toggleListView |
| 4091 |
})))), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4092 |
className: "edit-widgets-header__actions" |
| 4093 |
}, (0,external_wp_element_namespaceObject.createElement)(save_button, null), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, { |
| 4094 |
scope: "core/edit-widgets" |
| 4095 |
}), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null)))); |
| 4096 |
} |
| 4097 |
|
| 4098 |
/* harmony default export */ var header = (Header); |
| 4099 |
//# sourceMappingURL=index.js.map |
| 4100 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/notices/index.js |
| 4101 |
|
| 4102 |
|
| 4103 |
/** |
| 4104 |
* External dependencies |
| 4105 |
*/ |
| 4106 |
|
| 4107 |
/** |
| 4108 |
* WordPress dependencies |
| 4109 |
*/ |
| 4110 |
|
| 4111 |
|
| 4112 |
|
| 4113 |
|
| 4114 |
|
| 4115 |
function Notices() { |
| 4116 |
const { |
| 4117 |
removeNotice |
| 4118 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); |
| 4119 |
const { |
| 4120 |
notices |
| 4121 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4122 |
return { |
| 4123 |
notices: select(external_wp_notices_namespaceObject.store).getNotices() |
| 4124 |
}; |
| 4125 |
}, []); |
| 4126 |
const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, { |
| 4127 |
isDismissible: true, |
| 4128 |
type: 'default' |
| 4129 |
}); |
| 4130 |
const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, { |
| 4131 |
isDismissible: false, |
| 4132 |
type: 'default' |
| 4133 |
}); |
| 4134 |
const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, { |
| 4135 |
type: 'snackbar' |
| 4136 |
}); |
| 4137 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, { |
| 4138 |
notices: nonDismissibleNotices, |
| 4139 |
className: "edit-widgets-notices__pinned" |
| 4140 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, { |
| 4141 |
notices: dismissibleNotices, |
| 4142 |
className: "edit-widgets-notices__dismissible", |
| 4143 |
onRemove: removeNotice |
| 4144 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, { |
| 4145 |
notices: snackbarNotices, |
| 4146 |
className: "edit-widgets-notices__snackbar", |
| 4147 |
onRemove: removeNotice |
| 4148 |
})); |
| 4149 |
} |
| 4150 |
|
| 4151 |
/* harmony default export */ var notices = (Notices); |
| 4152 |
//# sourceMappingURL=index.js.map |
| 4153 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.js |
| 4154 |
|
| 4155 |
|
| 4156 |
/** |
| 4157 |
* WordPress dependencies |
| 4158 |
*/ |
| 4159 |
|
| 4160 |
|
| 4161 |
|
| 4162 |
|
| 4163 |
/** |
| 4164 |
* Internal dependencies |
| 4165 |
*/ |
| 4166 |
|
| 4167 |
|
| 4168 |
|
| 4169 |
function WidgetAreasBlockEditorContent(_ref) { |
| 4170 |
let { |
| 4171 |
blockEditorSettings |
| 4172 |
} = _ref; |
| 4173 |
const hasThemeStyles = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isFeatureActive('core/edit-widgets', 'themeStyles'), []); |
| 4174 |
const styles = (0,external_wp_element_namespaceObject.useMemo)(() => { |
| 4175 |
return hasThemeStyles ? blockEditorSettings.styles : []; |
| 4176 |
}, [blockEditorSettings, hasThemeStyles]); |
| 4177 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4178 |
className: "edit-widgets-block-editor" |
| 4179 |
}, (0,external_wp_element_namespaceObject.createElement)(notices, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { |
| 4180 |
styles: styles |
| 4181 |
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSelectionClearer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ObserveTyping, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { |
| 4182 |
className: "edit-widgets-main-block-list" |
| 4183 |
})))))); |
| 4184 |
} |
| 4185 |
//# sourceMappingURL=index.js.map |
| 4186 |
;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js |
| 4187 |
|
| 4188 |
|
| 4189 |
/** |
| 4190 |
* WordPress dependencies |
| 4191 |
*/ |
| 4192 |
|
| 4193 |
const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
| 4194 |
xmlns: "http://www.w3.org/2000/svg", |
| 4195 |
viewBox: "0 0 24 24" |
| 4196 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
| 4197 |
d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" |
| 4198 |
})); |
| 4199 |
/* harmony default export */ var library_close = (close_close); |
| 4200 |
//# sourceMappingURL=close.js.map |
| 4201 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/hooks/use-widget-library-insertion-point.js |
| 4202 |
/** |
| 4203 |
* WordPress dependencies |
| 4204 |
*/ |
| 4205 |
|
| 4206 |
|
| 4207 |
|
| 4208 |
/** |
| 4209 |
* Internal dependencies |
| 4210 |
*/ |
| 4211 |
|
| 4212 |
|
| 4213 |
|
| 4214 |
|
| 4215 |
const useWidgetLibraryInsertionPoint = () => { |
| 4216 |
const firstRootId = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4217 |
var _widgetAreasPost$bloc; |
| 4218 |
|
| 4219 |
// Default to the first widget area |
| 4220 |
const { |
| 4221 |
getEntityRecord |
| 4222 |
} = select(external_wp_coreData_namespaceObject.store); |
| 4223 |
const widgetAreasPost = getEntityRecord(KIND, POST_TYPE, buildWidgetAreasPostId()); |
| 4224 |
return widgetAreasPost === null || widgetAreasPost === void 0 ? void 0 : (_widgetAreasPost$bloc = widgetAreasPost.blocks[0]) === null || _widgetAreasPost$bloc === void 0 ? void 0 : _widgetAreasPost$bloc.clientId; |
| 4225 |
}, []); |
| 4226 |
return (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4227 |
const { |
| 4228 |
getBlockRootClientId, |
| 4229 |
getBlockSelectionEnd, |
| 4230 |
getBlockOrder, |
| 4231 |
getBlockIndex |
| 4232 |
} = select(external_wp_blockEditor_namespaceObject.store); |
| 4233 |
|
| 4234 |
const insertionPoint = select(store_store).__experimentalGetInsertionPoint(); // "Browse all" in the quick inserter will set the rootClientId to the current block. |
| 4235 |
// Otherwise, it will just be undefined, and we'll have to handle it differently below. |
| 4236 |
|
| 4237 |
|
| 4238 |
if (insertionPoint.rootClientId) { |
| 4239 |
return insertionPoint; |
| 4240 |
} |
| 4241 |
|
| 4242 |
const clientId = getBlockSelectionEnd() || firstRootId; |
| 4243 |
const rootClientId = getBlockRootClientId(clientId); // If the selected block is at the root level, it's a widget area and |
| 4244 |
// blocks can't be inserted here. Return this block as the root and the |
| 4245 |
// last child clientId indicating insertion at the end. |
| 4246 |
|
| 4247 |
if (clientId && rootClientId === '') { |
| 4248 |
return { |
| 4249 |
rootClientId: clientId, |
| 4250 |
insertionIndex: getBlockOrder(clientId).length |
| 4251 |
}; |
| 4252 |
} |
| 4253 |
|
| 4254 |
return { |
| 4255 |
rootClientId, |
| 4256 |
insertionIndex: getBlockIndex(clientId, rootClientId) + 1 |
| 4257 |
}; |
| 4258 |
}, [firstRootId]); |
| 4259 |
}; |
| 4260 |
|
| 4261 |
/* harmony default export */ var use_widget_library_insertion_point = (useWidgetLibraryInsertionPoint); |
| 4262 |
//# sourceMappingURL=use-widget-library-insertion-point.js.map |
| 4263 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.js |
| 4264 |
|
| 4265 |
|
| 4266 |
|
| 4267 |
/** |
| 4268 |
* WordPress dependencies |
| 4269 |
*/ |
| 4270 |
|
| 4271 |
|
| 4272 |
|
| 4273 |
|
| 4274 |
|
| 4275 |
|
| 4276 |
/** |
| 4277 |
* Internal dependencies |
| 4278 |
*/ |
| 4279 |
|
| 4280 |
|
| 4281 |
|
| 4282 |
function InserterSidebar() { |
| 4283 |
const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); |
| 4284 |
const { |
| 4285 |
rootClientId, |
| 4286 |
insertionIndex |
| 4287 |
} = use_widget_library_insertion_point(); |
| 4288 |
const { |
| 4289 |
setIsInserterOpened |
| 4290 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 4291 |
const closeInserter = (0,external_wp_element_namespaceObject.useCallback)(() => { |
| 4292 |
return () => setIsInserterOpened(false); |
| 4293 |
}, [setIsInserterOpened]); |
| 4294 |
const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({ |
| 4295 |
onClose: closeInserter |
| 4296 |
}); |
| 4297 |
return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ |
| 4298 |
ref: inserterDialogRef |
| 4299 |
}, inserterDialogProps, { |
| 4300 |
className: "edit-widgets-layout__inserter-panel" |
| 4301 |
}), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4302 |
className: "edit-widgets-layout__inserter-panel-header" |
| 4303 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 4304 |
icon: library_close, |
| 4305 |
onClick: closeInserter |
| 4306 |
})), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4307 |
className: "edit-widgets-layout__inserter-panel-content" |
| 4308 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, { |
| 4309 |
showInserterHelpPanel: true, |
| 4310 |
shouldFocusBlock: isMobileViewport, |
| 4311 |
rootClientId: rootClientId, |
| 4312 |
__experimentalInsertionIndex: insertionIndex |
| 4313 |
}))); |
| 4314 |
} |
| 4315 |
//# sourceMappingURL=inserter-sidebar.js.map |
| 4316 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.js |
| 4317 |
|
| 4318 |
|
| 4319 |
/** |
| 4320 |
* WordPress dependencies |
| 4321 |
*/ |
| 4322 |
|
| 4323 |
|
| 4324 |
|
| 4325 |
|
| 4326 |
|
| 4327 |
|
| 4328 |
|
| 4329 |
/** |
| 4330 |
* Internal dependencies |
| 4331 |
*/ |
| 4332 |
|
| 4333 |
|
| 4334 |
function ListViewSidebar() { |
| 4335 |
const { |
| 4336 |
setIsListViewOpened |
| 4337 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 4338 |
const { |
| 4339 |
clearSelectedBlock, |
| 4340 |
selectBlock |
| 4341 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); |
| 4342 |
|
| 4343 |
async function selectEditorBlock(clientId) { |
| 4344 |
await clearSelectedBlock(); |
| 4345 |
selectBlock(clientId, -1); |
| 4346 |
} |
| 4347 |
|
| 4348 |
const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement'); |
| 4349 |
const focusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)(); |
| 4350 |
|
| 4351 |
function closeOnEscape(event) { |
| 4352 |
if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) { |
| 4353 |
event.preventDefault(); |
| 4354 |
setIsListViewOpened(false); |
| 4355 |
} |
| 4356 |
} |
| 4357 |
|
| 4358 |
const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar); |
| 4359 |
const labelId = `edit-widgets-editor__list-view-panel-label-${instanceId}`; |
| 4360 |
return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions |
| 4361 |
(0,external_wp_element_namespaceObject.createElement)("div", { |
| 4362 |
"aria-labelledby": labelId, |
| 4363 |
className: "edit-widgets-editor__list-view-panel", |
| 4364 |
onKeyDown: closeOnEscape |
| 4365 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4366 |
className: "edit-widgets-editor__list-view-panel-header" |
| 4367 |
}, (0,external_wp_element_namespaceObject.createElement)("strong", { |
| 4368 |
id: labelId |
| 4369 |
}, (0,external_wp_i18n_namespaceObject.__)('List view')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
| 4370 |
icon: close_small, |
| 4371 |
label: (0,external_wp_i18n_namespaceObject.__)('Close list view sidebar'), |
| 4372 |
onClick: () => setIsListViewOpened(false) |
| 4373 |
})), (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4374 |
className: "edit-widgets-editor__list-view-panel-content", |
| 4375 |
ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([focusReturnRef, focusOnMountRef]) |
| 4376 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, { |
| 4377 |
onSelect: selectEditorBlock, |
| 4378 |
showNestedBlocks: true, |
| 4379 |
__experimentalHideContainerBlockActions: true, |
| 4380 |
__experimentalFeatures: true, |
| 4381 |
__experimentalPersistentListViewFeatures: true |
| 4382 |
}))) |
| 4383 |
); |
| 4384 |
} |
| 4385 |
//# sourceMappingURL=list-view-sidebar.js.map |
| 4386 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/secondary-sidebar/index.js |
| 4387 |
|
| 4388 |
|
| 4389 |
/** |
| 4390 |
* WordPress dependencies |
| 4391 |
*/ |
| 4392 |
|
| 4393 |
/** |
| 4394 |
* Internal dependencies |
| 4395 |
*/ |
| 4396 |
|
| 4397 |
|
| 4398 |
/** |
| 4399 |
* Internal dependencies |
| 4400 |
*/ |
| 4401 |
|
| 4402 |
|
| 4403 |
|
| 4404 |
function SecondarySidebar() { |
| 4405 |
const { |
| 4406 |
isInserterOpen, |
| 4407 |
isListViewOpen |
| 4408 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4409 |
const { |
| 4410 |
isInserterOpened, |
| 4411 |
isListViewOpened |
| 4412 |
} = select(store_store); |
| 4413 |
return { |
| 4414 |
isInserterOpen: isInserterOpened(), |
| 4415 |
isListViewOpen: isListViewOpened() |
| 4416 |
}; |
| 4417 |
}, []); |
| 4418 |
|
| 4419 |
if (isInserterOpen) { |
| 4420 |
return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null); |
| 4421 |
} |
| 4422 |
|
| 4423 |
if (isListViewOpen) { |
| 4424 |
return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null); |
| 4425 |
} |
| 4426 |
|
| 4427 |
return null; |
| 4428 |
} |
| 4429 |
//# sourceMappingURL=index.js.map |
| 4430 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/layout/interface.js |
| 4431 |
|
| 4432 |
|
| 4433 |
/** |
| 4434 |
* WordPress dependencies |
| 4435 |
*/ |
| 4436 |
|
| 4437 |
|
| 4438 |
|
| 4439 |
|
| 4440 |
|
| 4441 |
|
| 4442 |
|
| 4443 |
/** |
| 4444 |
* Internal dependencies |
| 4445 |
*/ |
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
|
| 4450 |
|
| 4451 |
const interfaceLabels = { |
| 4452 |
/* translators: accessibility text for the widgets screen top bar landmark region. */ |
| 4453 |
header: (0,external_wp_i18n_namespaceObject.__)('Widgets top bar'), |
| 4454 |
|
| 4455 |
/* translators: accessibility text for the widgets screen content landmark region. */ |
| 4456 |
body: (0,external_wp_i18n_namespaceObject.__)('Widgets and blocks'), |
| 4457 |
|
| 4458 |
/* translators: accessibility text for the widgets screen settings landmark region. */ |
| 4459 |
sidebar: (0,external_wp_i18n_namespaceObject.__)('Widgets settings'), |
| 4460 |
|
| 4461 |
/* translators: accessibility text for the widgets screen footer landmark region. */ |
| 4462 |
footer: (0,external_wp_i18n_namespaceObject.__)('Widgets footer') |
| 4463 |
}; |
| 4464 |
|
| 4465 |
function Interface(_ref) { |
| 4466 |
let { |
| 4467 |
blockEditorSettings |
| 4468 |
} = _ref; |
| 4469 |
const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); |
| 4470 |
const isHugeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('huge', '>='); |
| 4471 |
const { |
| 4472 |
setIsInserterOpened, |
| 4473 |
setIsListViewOpened, |
| 4474 |
closeGeneralSidebar |
| 4475 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store); |
| 4476 |
const { |
| 4477 |
hasBlockBreadCrumbsEnabled, |
| 4478 |
hasSidebarEnabled, |
| 4479 |
isInserterOpened, |
| 4480 |
isListViewOpened, |
| 4481 |
previousShortcut, |
| 4482 |
nextShortcut |
| 4483 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => ({ |
| 4484 |
hasSidebarEnabled: !!select(store).getActiveComplementaryArea(store_store.name), |
| 4485 |
isInserterOpened: !!select(store_store).isInserterOpened(), |
| 4486 |
isListViewOpened: !!select(store_store).isListViewOpened(), |
| 4487 |
hasBlockBreadCrumbsEnabled: select(store).isFeatureActive('core/edit-widgets', 'showBlockBreadcrumbs'), |
| 4488 |
previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-widgets/previous-region'), |
| 4489 |
nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-widgets/next-region') |
| 4490 |
}), []); // Inserter and Sidebars are mutually exclusive |
| 4491 |
|
| 4492 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 4493 |
if (hasSidebarEnabled && !isHugeViewport) { |
| 4494 |
setIsInserterOpened(false); |
| 4495 |
setIsListViewOpened(false); |
| 4496 |
} |
| 4497 |
}, [hasSidebarEnabled, isHugeViewport]); |
| 4498 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 4499 |
if ((isInserterOpened || isListViewOpened) && !isHugeViewport) { |
| 4500 |
closeGeneralSidebar(); |
| 4501 |
} |
| 4502 |
}, [isInserterOpened, isListViewOpened, isHugeViewport]); |
| 4503 |
return (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, { |
| 4504 |
labels: interfaceLabels, |
| 4505 |
header: (0,external_wp_element_namespaceObject.createElement)(header, null), |
| 4506 |
secondarySidebar: (0,external_wp_element_namespaceObject.createElement)(SecondarySidebar, null), |
| 4507 |
sidebar: hasSidebarEnabled && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, { |
| 4508 |
scope: "core/edit-widgets" |
| 4509 |
}), |
| 4510 |
content: (0,external_wp_element_namespaceObject.createElement)(WidgetAreasBlockEditorContent, { |
| 4511 |
blockEditorSettings: blockEditorSettings |
| 4512 |
}), |
| 4513 |
footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)("div", { |
| 4514 |
className: "edit-widgets-layout__footer" |
| 4515 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, { |
| 4516 |
rootLabelText: (0,external_wp_i18n_namespaceObject.__)('Widgets') |
| 4517 |
})), |
| 4518 |
shortcuts: { |
| 4519 |
previous: previousShortcut, |
| 4520 |
next: nextShortcut |
| 4521 |
} |
| 4522 |
}); |
| 4523 |
} |
| 4524 |
|
| 4525 |
/* harmony default export */ var layout_interface = (Interface); |
| 4526 |
//# sourceMappingURL=interface.js.map |
| 4527 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/layout/unsaved-changes-warning.js |
| 4528 |
/** |
| 4529 |
* WordPress dependencies |
| 4530 |
*/ |
| 4531 |
|
| 4532 |
|
| 4533 |
|
| 4534 |
/** |
| 4535 |
* Internal dependencies |
| 4536 |
*/ |
| 4537 |
|
| 4538 |
|
| 4539 |
/** |
| 4540 |
* Warns the user if there are unsaved changes before leaving the editor. |
| 4541 |
* |
| 4542 |
* This is a duplicate of the component implemented in the editor package. |
| 4543 |
* Duplicated here as edit-widgets doesn't depend on editor. |
| 4544 |
* |
| 4545 |
* @return {WPComponent} The component. |
| 4546 |
*/ |
| 4547 |
|
| 4548 |
function UnsavedChangesWarning() { |
| 4549 |
const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => { |
| 4550 |
const { |
| 4551 |
getEditedWidgetAreas |
| 4552 |
} = select(store_store); |
| 4553 |
const editedWidgetAreas = getEditedWidgetAreas(); |
| 4554 |
return (editedWidgetAreas === null || editedWidgetAreas === void 0 ? void 0 : editedWidgetAreas.length) > 0; |
| 4555 |
}, []); |
| 4556 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 4557 |
/** |
| 4558 |
* Warns the user if there are unsaved changes before leaving the editor. |
| 4559 |
* |
| 4560 |
* @param {Event} event `beforeunload` event. |
| 4561 |
* |
| 4562 |
* @return {?string} Warning prompt message, if unsaved changes exist. |
| 4563 |
*/ |
| 4564 |
const warnIfUnsavedChanges = event => { |
| 4565 |
if (isDirty) { |
| 4566 |
event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.'); |
| 4567 |
return event.returnValue; |
| 4568 |
} |
| 4569 |
}; |
| 4570 |
|
| 4571 |
window.addEventListener('beforeunload', warnIfUnsavedChanges); |
| 4572 |
return () => { |
| 4573 |
window.removeEventListener('beforeunload', warnIfUnsavedChanges); |
| 4574 |
}; |
| 4575 |
}, [isDirty]); |
| 4576 |
return null; |
| 4577 |
} |
| 4578 |
//# sourceMappingURL=unsaved-changes-warning.js.map |
| 4579 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/welcome-guide/index.js |
| 4580 |
|
| 4581 |
|
| 4582 |
/** |
| 4583 |
* WordPress dependencies |
| 4584 |
*/ |
| 4585 |
|
| 4586 |
|
| 4587 |
|
| 4588 |
|
| 4589 |
|
| 4590 |
/** |
| 4591 |
* Internal dependencies |
| 4592 |
*/ |
| 4593 |
|
| 4594 |
|
| 4595 |
function WelcomeGuide() { |
| 4596 |
var _widgetAreas$filter$l; |
| 4597 |
|
| 4598 |
const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isFeatureActive('core/edit-widgets', 'welcomeGuide'), []); |
| 4599 |
const { |
| 4600 |
toggleFeature |
| 4601 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
| 4602 |
const widgetAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getWidgetAreas({ |
| 4603 |
per_page: -1 |
| 4604 |
}), []); |
| 4605 |
|
| 4606 |
if (!isActive) { |
| 4607 |
return null; |
| 4608 |
} |
| 4609 |
|
| 4610 |
const isEntirelyBlockWidgets = widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.every(widgetArea => widgetArea.id === 'wp_inactive_widgets' || widgetArea.widgets.every(widgetId => widgetId.startsWith('block-'))); |
| 4611 |
const numWidgetAreas = (_widgetAreas$filter$l = widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.filter(widgetArea => widgetArea.id !== 'wp_inactive_widgets').length) !== null && _widgetAreas$filter$l !== void 0 ? _widgetAreas$filter$l : 0; |
| 4612 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, { |
| 4613 |
className: "edit-widgets-welcome-guide", |
| 4614 |
contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets'), |
| 4615 |
finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'), |
| 4616 |
onFinish: () => toggleFeature('core/edit-widgets', 'welcomeGuide'), |
| 4617 |
pages: [{ |
| 4618 |
image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { |
| 4619 |
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg", |
| 4620 |
animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif" |
| 4621 |
}), |
| 4622 |
content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { |
| 4623 |
className: "edit-widgets-welcome-guide__heading" |
| 4624 |
}, (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets')), isEntirelyBlockWidgets ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", { |
| 4625 |
className: "edit-widgets-welcome-guide__text" |
| 4626 |
}, (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: Number of block areas in the current theme. |
| 4627 |
(0,external_wp_i18n_namespaceObject._n)('Your theme provides %s “block” area 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.', 'Your theme provides %s 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.', numWidgetAreas), numWidgetAreas))) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", { |
| 4628 |
className: "edit-widgets-welcome-guide__text" |
| 4629 |
}, (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)("p", { |
| 4630 |
className: "edit-widgets-welcome-guide__text" |
| 4631 |
}, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Want to stick with the old widgets?')), ' ', (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { |
| 4632 |
href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/plugins/classic-widgets/') |
| 4633 |
}, (0,external_wp_i18n_namespaceObject.__)('Get the Classic Widgets plugin.'))))) |
| 4634 |
}, { |
| 4635 |
image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { |
| 4636 |
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg", |
| 4637 |
animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif" |
| 4638 |
}), |
| 4639 |
content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { |
| 4640 |
className: "edit-widgets-welcome-guide__heading" |
| 4641 |
}, (0,external_wp_i18n_namespaceObject.__)('Make each block your own')), (0,external_wp_element_namespaceObject.createElement)("p", { |
| 4642 |
className: "edit-widgets-welcome-guide__text" |
| 4643 |
}, (0,external_wp_i18n_namespaceObject.__)('Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'))) |
| 4644 |
}, { |
| 4645 |
image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { |
| 4646 |
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg", |
| 4647 |
animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif" |
| 4648 |
}), |
| 4649 |
content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { |
| 4650 |
className: "edit-widgets-welcome-guide__heading" |
| 4651 |
}, (0,external_wp_i18n_namespaceObject.__)('Get to know the block library')), (0,external_wp_element_namespaceObject.createElement)("p", { |
| 4652 |
className: "edit-widgets-welcome-guide__text" |
| 4653 |
}, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'), { |
| 4654 |
InserterIconImage: (0,external_wp_element_namespaceObject.createElement)("img", { |
| 4655 |
className: "edit-widgets-welcome-guide__inserter-icon", |
| 4656 |
alt: (0,external_wp_i18n_namespaceObject.__)('inserter'), |
| 4657 |
src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A" |
| 4658 |
}) |
| 4659 |
}))) |
| 4660 |
}, { |
| 4661 |
image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { |
| 4662 |
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg", |
| 4663 |
animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif" |
| 4664 |
}), |
| 4665 |
content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { |
| 4666 |
className: "edit-widgets-welcome-guide__heading" |
| 4667 |
}, (0,external_wp_i18n_namespaceObject.__)('Learn how to use the block editor')), (0,external_wp_element_namespaceObject.createElement)("p", { |
| 4668 |
className: "edit-widgets-welcome-guide__text" |
| 4669 |
}, (0,external_wp_i18n_namespaceObject.__)('New to the block editor? Want to learn more about using it? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { |
| 4670 |
href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/wordpress-editor/') |
| 4671 |
}, (0,external_wp_i18n_namespaceObject.__)("Here's a detailed guide.")))) |
| 4672 |
}] |
| 4673 |
}); |
| 4674 |
} |
| 4675 |
|
| 4676 |
function WelcomeGuideImage(_ref) { |
| 4677 |
let { |
| 4678 |
nonAnimatedSrc, |
| 4679 |
animatedSrc |
| 4680 |
} = _ref; |
| 4681 |
return (0,external_wp_element_namespaceObject.createElement)("picture", { |
| 4682 |
className: "edit-widgets-welcome-guide__image" |
| 4683 |
}, (0,external_wp_element_namespaceObject.createElement)("source", { |
| 4684 |
srcSet: nonAnimatedSrc, |
| 4685 |
media: "(prefers-reduced-motion: reduce)" |
| 4686 |
}), (0,external_wp_element_namespaceObject.createElement)("img", { |
| 4687 |
src: animatedSrc, |
| 4688 |
width: "312", |
| 4689 |
height: "240", |
| 4690 |
alt: "" |
| 4691 |
})); |
| 4692 |
} |
| 4693 |
//# sourceMappingURL=index.js.map |
| 4694 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/components/layout/index.js |
| 4695 |
|
| 4696 |
|
| 4697 |
/** |
| 4698 |
* WordPress dependencies |
| 4699 |
*/ |
| 4700 |
|
| 4701 |
|
| 4702 |
/** |
| 4703 |
* Internal dependencies |
| 4704 |
*/ |
| 4705 |
|
| 4706 |
|
| 4707 |
|
| 4708 |
|
| 4709 |
|
| 4710 |
|
| 4711 |
|
| 4712 |
|
| 4713 |
function Layout(_ref) { |
| 4714 |
let { |
| 4715 |
blockEditorSettings, |
| 4716 |
onError |
| 4717 |
} = _ref; |
| 4718 |
return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, { |
| 4719 |
onError: onError |
| 4720 |
}, (0,external_wp_element_namespaceObject.createElement)(WidgetAreasBlockEditorProvider, { |
| 4721 |
blockEditorSettings: blockEditorSettings |
| 4722 |
}, (0,external_wp_element_namespaceObject.createElement)(layout_interface, { |
| 4723 |
blockEditorSettings: blockEditorSettings |
| 4724 |
}), (0,external_wp_element_namespaceObject.createElement)(Sidebar, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, null), (0,external_wp_element_namespaceObject.createElement)(UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null))); |
| 4725 |
} |
| 4726 |
|
| 4727 |
/* harmony default export */ var layout = (Layout); |
| 4728 |
//# sourceMappingURL=index.js.map |
| 4729 |
;// CONCATENATED MODULE: ./packages/edit-widgets/build-module/index.js |
| 4730 |
|
| 4731 |
|
| 4732 |
/** |
| 4733 |
* WordPress dependencies |
| 4734 |
*/ |
| 4735 |
|
| 4736 |
|
| 4737 |
|
| 4738 |
|
| 4739 |
|
| 4740 |
|
| 4741 |
|
| 4742 |
/** |
| 4743 |
* Internal dependencies |
| 4744 |
*/ |
| 4745 |
|
| 4746 |
|
| 4747 |
|
| 4748 |
|
| 4749 |
|
| 4750 |
|
| 4751 |
const disabledBlocks = ['core/more', 'core/freeform', 'core/template-part', ...(ALLOW_REUSABLE_BLOCKS ? [] : ['core/block'])]; |
| 4752 |
/** |
| 4753 |
* Reinitializes the editor after the user chooses to reboot the editor after |
| 4754 |
* an unhandled error occurs, replacing previously mounted editor element using |
| 4755 |
* an initial state from prior to the crash. |
| 4756 |
* |
| 4757 |
* @param {Element} target DOM node in which editor is rendered. |
| 4758 |
* @param {?Object} settings Editor settings object. |
| 4759 |
*/ |
| 4760 |
|
| 4761 |
function reinitializeEditor(target, settings) { |
| 4762 |
(0,external_wp_element_namespaceObject.unmountComponentAtNode)(target); |
| 4763 |
const reboot = reinitializeEditor.bind(null, target, settings); |
| 4764 |
(0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(layout, { |
| 4765 |
blockEditorSettings: settings, |
| 4766 |
onError: reboot |
| 4767 |
}), target); |
| 4768 |
} |
| 4769 |
/** |
| 4770 |
* Initializes the block editor in the widgets screen. |
| 4771 |
* |
| 4772 |
* @param {string} id ID of the root element to render the screen in. |
| 4773 |
* @param {Object} settings Block editor settings. |
| 4774 |
*/ |
| 4775 |
|
| 4776 |
function initialize(id, settings) { |
| 4777 |
const target = document.getElementById(id); |
| 4778 |
const reboot = reinitializeEditor.bind(null, target, settings); |
| 4779 |
|
| 4780 |
const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(block => { |
| 4781 |
return !(disabledBlocks.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site') || block.name.startsWith('core/navigation')); |
| 4782 |
}); |
| 4783 |
|
| 4784 |
(0,external_wp_data_namespaceObject.dispatch)(store).setFeatureDefaults('core/edit-widgets', { |
| 4785 |
fixedToolbar: false, |
| 4786 |
welcomeGuide: true, |
| 4787 |
showBlockBreadcrumbs: true, |
| 4788 |
themeStyles: true |
| 4789 |
}); |
| 4790 |
|
| 4791 |
(0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters(); |
| 4792 |
|
| 4793 |
(0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(coreBlocks); |
| 4794 |
(0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)(); |
| 4795 |
|
| 4796 |
if (true) { |
| 4797 |
(0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({ |
| 4798 |
enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS |
| 4799 |
}); |
| 4800 |
} |
| 4801 |
|
| 4802 |
(0,external_wp_widgets_namespaceObject.registerLegacyWidgetVariations)(settings); |
| 4803 |
registerBlock(widget_area_namespaceObject); |
| 4804 |
(0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)(); |
| 4805 |
|
| 4806 |
settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings); // As we are unregistering `core/freeform` to avoid the Classic block, we must |
| 4807 |
// replace it with something as the default freeform content handler. Failure to |
| 4808 |
// do this will result in errors in the default block parser. |
| 4809 |
// see: https://github.com/WordPress/gutenberg/issues/33097 |
| 4810 |
|
| 4811 |
|
| 4812 |
(0,external_wp_blocks_namespaceObject.setFreeformContentHandlerName)('core/html'); |
| 4813 |
(0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(layout, { |
| 4814 |
blockEditorSettings: settings, |
| 4815 |
onError: reboot |
| 4816 |
}), target); |
| 4817 |
} |
| 4818 |
/** |
| 4819 |
* Function to register an individual block. |
| 4820 |
* |
| 4821 |
* @param {Object} block The block to be registered. |
| 4822 |
* |
| 4823 |
*/ |
| 4824 |
|
| 4825 |
const registerBlock = block => { |
| 4826 |
if (!block) { |
| 4827 |
return; |
| 4828 |
} |
| 4829 |
|
| 4830 |
const { |
| 4831 |
metadata, |
| 4832 |
settings, |
| 4833 |
name |
| 4834 |
} = block; |
| 4835 |
|
| 4836 |
if (metadata) { |
| 4837 |
(0,external_wp_blocks_namespaceObject.unstable__bootstrapServerSideBlockDefinitions)({ |
| 4838 |
[name]: metadata |
| 4839 |
}); |
| 4840 |
} |
| 4841 |
|
| 4842 |
(0,external_wp_blocks_namespaceObject.registerBlockType)(name, settings); |
| 4843 |
}; |
| 4844 |
//# sourceMappingURL=index.js.map |
| 4845 |
}(); |
| 4846 |
(window.wp = window.wp || {}).editWidgets = __webpack_exports__; |
| 4847 |
/******/ })() |
| 4848 |
; |