PluginProbe
Gutenberg / 19.6.4
Gutenberg v19.6.4
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / edit-widgets / index.js

index.js in Gutenberg 19.6.4, at build/edit-widgets/index.js

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