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