PluginProbe
Gutenberg / 13.5.1
Gutenberg v13.5.1
24.1.0 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 All 404 releases
gutenberg / build / edit-site / index.js

index.js in Gutenberg 13.5.1, at build/edit-site/index.js

13,400 lines 462.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 6411:
5 /***/ (function(module, exports) {
6
7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 autosize 4.0.2
9 license: MIT
10 http://www.jacklmoore.com/autosize
11 */
12 (function (global, factory) {
13 if (true) {
14 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
15 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
16 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
17 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
18 } else { var mod; }
19 })(this, function (module, exports) {
20 'use strict';
21
22 var map = typeof Map === "function" ? new Map() : function () {
23 var keys = [];
24 var values = [];
25
26 return {
27 has: function has(key) {
28 return keys.indexOf(key) > -1;
29 },
30 get: function get(key) {
31 return values[keys.indexOf(key)];
32 },
33 set: function set(key, value) {
34 if (keys.indexOf(key) === -1) {
35 keys.push(key);
36 values.push(value);
37 }
38 },
39 delete: function _delete(key) {
40 var index = keys.indexOf(key);
41 if (index > -1) {
42 keys.splice(index, 1);
43 values.splice(index, 1);
44 }
45 }
46 };
47 }();
48
49 var createEvent = function createEvent(name) {
50 return new Event(name, { bubbles: true });
51 };
52 try {
53 new Event('test');
54 } catch (e) {
55 // IE does not support `new Event()`
56 createEvent = function createEvent(name) {
57 var evt = document.createEvent('Event');
58 evt.initEvent(name, true, false);
59 return evt;
60 };
61 }
62
63 function assign(ta) {
64 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
65
66 var heightOffset = null;
67 var clientWidth = null;
68 var cachedHeight = null;
69
70 function init() {
71 var style = window.getComputedStyle(ta, null);
72
73 if (style.resize === 'vertical') {
74 ta.style.resize = 'none';
75 } else if (style.resize === 'both') {
76 ta.style.resize = 'horizontal';
77 }
78
79 if (style.boxSizing === 'content-box') {
80 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
81 } else {
82 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
83 }
84 // Fix when a textarea is not on document body and heightOffset is Not a Number
85 if (isNaN(heightOffset)) {
86 heightOffset = 0;
87 }
88
89 update();
90 }
91
92 function changeOverflow(value) {
93 {
94 // Chrome/Safari-specific fix:
95 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
96 // made available by removing the scrollbar. The following forces the necessary text reflow.
97 var width = ta.style.width;
98 ta.style.width = '0px';
99 // Force reflow:
100 /* jshint ignore:start */
101 ta.offsetWidth;
102 /* jshint ignore:end */
103 ta.style.width = width;
104 }
105
106 ta.style.overflowY = value;
107 }
108
109 function getParentOverflows(el) {
110 var arr = [];
111
112 while (el && el.parentNode && el.parentNode instanceof Element) {
113 if (el.parentNode.scrollTop) {
114 arr.push({
115 node: el.parentNode,
116 scrollTop: el.parentNode.scrollTop
117 });
118 }
119 el = el.parentNode;
120 }
121
122 return arr;
123 }
124
125 function resize() {
126 if (ta.scrollHeight === 0) {
127 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
128 return;
129 }
130
131 var overflows = getParentOverflows(ta);
132 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
133
134 ta.style.height = '';
135 ta.style.height = ta.scrollHeight + heightOffset + 'px';
136
137 // used to check if an update is actually necessary on window.resize
138 clientWidth = ta.clientWidth;
139
140 // prevents scroll-position jumping
141 overflows.forEach(function (el) {
142 el.node.scrollTop = el.scrollTop;
143 });
144
145 if (docTop) {
146 document.documentElement.scrollTop = docTop;
147 }
148 }
149
150 function update() {
151 resize();
152
153 var styleHeight = Math.round(parseFloat(ta.style.height));
154 var computed = window.getComputedStyle(ta, null);
155
156 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
157 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
158
159 // The actual height not matching the style height (set via the resize method) indicates that
160 // the max-height has been exceeded, in which case the overflow should be allowed.
161 if (actualHeight < styleHeight) {
162 if (computed.overflowY === 'hidden') {
163 changeOverflow('scroll');
164 resize();
165 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
166 }
167 } else {
168 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
169 if (computed.overflowY !== 'hidden') {
170 changeOverflow('hidden');
171 resize();
172 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
173 }
174 }
175
176 if (cachedHeight !== actualHeight) {
177 cachedHeight = actualHeight;
178 var evt = createEvent('autosize:resized');
179 try {
180 ta.dispatchEvent(evt);
181 } catch (err) {
182 // Firefox will throw an error on dispatchEvent for a detached element
183 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
184 }
185 }
186 }
187
188 var pageResize = function pageResize() {
189 if (ta.clientWidth !== clientWidth) {
190 update();
191 }
192 };
193
194 var destroy = function (style) {
195 window.removeEventListener('resize', pageResize, false);
196 ta.removeEventListener('input', update, false);
197 ta.removeEventListener('keyup', update, false);
198 ta.removeEventListener('autosize:destroy', destroy, false);
199 ta.removeEventListener('autosize:update', update, false);
200
201 Object.keys(style).forEach(function (key) {
202 ta.style[key] = style[key];
203 });
204
205 map.delete(ta);
206 }.bind(ta, {
207 height: ta.style.height,
208 resize: ta.style.resize,
209 overflowY: ta.style.overflowY,
210 overflowX: ta.style.overflowX,
211 wordWrap: ta.style.wordWrap
212 });
213
214 ta.addEventListener('autosize:destroy', destroy, false);
215
216 // IE9 does not fire onpropertychange or oninput for deletions,
217 // so binding to onkeyup to catch most of those events.
218 // There is no way that I know of to detect something like 'cut' in IE9.
219 if ('onpropertychange' in ta && 'oninput' in ta) {
220 ta.addEventListener('keyup', update, false);
221 }
222
223 window.addEventListener('resize', pageResize, false);
224 ta.addEventListener('input', update, false);
225 ta.addEventListener('autosize:update', update, false);
226 ta.style.overflowX = 'hidden';
227 ta.style.wordWrap = 'break-word';
228
229 map.set(ta, {
230 destroy: destroy,
231 update: update
232 });
233
234 init();
235 }
236
237 function destroy(ta) {
238 var methods = map.get(ta);
239 if (methods) {
240 methods.destroy();
241 }
242 }
243
244 function update(ta) {
245 var methods = map.get(ta);
246 if (methods) {
247 methods.update();
248 }
249 }
250
251 var autosize = null;
252
253 // Do nothing in Node.js environment and IE8 (or lower)
254 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
255 autosize = function autosize(el) {
256 return el;
257 };
258 autosize.destroy = function (el) {
259 return el;
260 };
261 autosize.update = function (el) {
262 return el;
263 };
264 } else {
265 autosize = function autosize(el, options) {
266 if (el) {
267 Array.prototype.forEach.call(el.length ? el : [el], function (x) {
268 return assign(x, options);
269 });
270 }
271 return el;
272 };
273 autosize.destroy = function (el) {
274 if (el) {
275 Array.prototype.forEach.call(el.length ? el : [el], destroy);
276 }
277 return el;
278 };
279 autosize.update = function (el) {
280 if (el) {
281 Array.prototype.forEach.call(el.length ? el : [el], update);
282 }
283 return el;
284 };
285 }
286
287 exports.default = autosize;
288 module.exports = exports['default'];
289 });
290
291 /***/ }),
292
293 /***/ 4403:
294 /***/ ((module, exports) => {
295
296 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
297 Copyright (c) 2018 Jed Watson.
298 Licensed under the MIT License (MIT), see
299 http://jedwatson.github.io/classnames
300 */
301 /* global define */
302
303 (function () {
304 'use strict';
305
306 var hasOwn = {}.hasOwnProperty;
307
308 function classNames() {
309 var classes = [];
310
311 for (var i = 0; i < arguments.length; i++) {
312 var arg = arguments[i];
313 if (!arg) continue;
314
315 var argType = typeof arg;
316
317 if (argType === 'string' || argType === 'number') {
318 classes.push(arg);
319 } else if (Array.isArray(arg)) {
320 if (arg.length) {
321 var inner = classNames.apply(null, arg);
322 if (inner) {
323 classes.push(inner);
324 }
325 }
326 } else if (argType === 'object') {
327 if (arg.toString === Object.prototype.toString) {
328 for (var key in arg) {
329 if (hasOwn.call(arg, key) && arg[key]) {
330 classes.push(key);
331 }
332 }
333 } else {
334 classes.push(arg.toString());
335 }
336 }
337 }
338
339 return classes.join(' ');
340 }
341
342 if ( true && module.exports) {
343 classNames.default = classNames;
344 module.exports = classNames;
345 } else if (true) {
346 // register as 'classnames', consistent with npm package name
347 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
348 return classNames;
349 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
350 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
351 } else {}
352 }());
353
354
355 /***/ }),
356
357 /***/ 4827:
358 /***/ ((module) => {
359
360 // This code has been refactored for 140 bytes
361 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
362 var computedStyle = function (el, prop, getComputedStyle) {
363 getComputedStyle = window.getComputedStyle;
364
365 // In one fell swoop
366 return (
367 // If we have getComputedStyle
368 getComputedStyle ?
369 // Query it
370 // TODO: From CSS-Query notes, we might need (node, null) for FF
371 getComputedStyle(el) :
372
373 // Otherwise, we are in IE and use currentStyle
374 el.currentStyle
375 )[
376 // Switch to camelCase for CSSOM
377 // DEV: Grabbed from jQuery
378 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
379 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
380 prop.replace(/-(\w)/gi, function (word, letter) {
381 return letter.toUpperCase();
382 })
383 ];
384 };
385
386 module.exports = computedStyle;
387
388
389 /***/ }),
390
391 /***/ 8981:
392 /***/ (function(module, exports) {
393
394 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;//download.js v4.2, by dandavis; 2008-2016. [MIT] see http://danml.com/download.html for tests/usage
395 // v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
396 // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
397 // v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
398 // v4 adds AMD/UMD, commonJS, and plain browser support
399 // v4.1 adds url download capability via solo URL argument (same domain/CORS only)
400 // v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
401 // https://github.com/rndme/download
402
403 (function (root, factory) {
404 if (true) {
405 // AMD. Register as an anonymous module.
406 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
407 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
408 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
409 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
410 } else {}
411 }(this, function () {
412
413 return function download(data, strFileName, strMimeType) {
414
415 var self = window, // this script is only for browsers anyway...
416 defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
417 mimeType = strMimeType || defaultMime,
418 payload = data,
419 url = !strFileName && !strMimeType && payload,
420 anchor = document.createElement("a"),
421 toString = function(a){return String(a);},
422 myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
423 fileName = strFileName || "download",
424 blob,
425 reader;
426 myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
427
428 if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
429 payload=[payload, mimeType];
430 mimeType=payload[0];
431 payload=payload[1];
432 }
433
434
435 if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
436 fileName = url.split("/").pop().split("?")[0];
437 anchor.href = url; // assign href prop to temp anchor
438 if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
439 var ajax=new XMLHttpRequest();
440 ajax.open( "GET", url, true);
441 ajax.responseType = 'blob';
442 ajax.onload= function(e){
443 download(e.target.response, fileName, defaultMime);
444 };
445 setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
446 return ajax;
447 } // end if valid url?
448 } // end if url?
449
450
451 //go ahead and download dataURLs right away
452 if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){
453
454 if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
455 payload=dataUrlToBlob(payload);
456 mimeType=payload.type || defaultMime;
457 }else{
458 return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
459 navigator.msSaveBlob(dataUrlToBlob(payload), fileName) :
460 saver(payload) ; // everyone else can save dataURLs un-processed
461 }
462
463 }else{//not data url, is it a string with special needs?
464 if(/([\x80-\xff])/.test(payload)){
465 var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length;
466 for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i);
467 payload=new myBlob([tempUiArr], {type: mimeType});
468 }
469 }
470 blob = payload instanceof myBlob ?
471 payload :
472 new myBlob([payload], {type: mimeType}) ;
473
474
475 function dataUrlToBlob(strUrl) {
476 var parts= strUrl.split(/[:;,]/),
477 type= parts[1],
478 decoder= parts[2] == "base64" ? atob : decodeURIComponent,
479 binData= decoder( parts.pop() ),
480 mx= binData.length,
481 i= 0,
482 uiArr= new Uint8Array(mx);
483
484 for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);
485
486 return new myBlob([uiArr], {type: type});
487 }
488
489 function saver(url, winMode){
490
491 if ('download' in anchor) { //html5 A[download]
492 anchor.href = url;
493 anchor.setAttribute("download", fileName);
494 anchor.className = "download-js-link";
495 anchor.innerHTML = "downloading...";
496 anchor.style.display = "none";
497 document.body.appendChild(anchor);
498 setTimeout(function() {
499 anchor.click();
500 document.body.removeChild(anchor);
501 if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
502 }, 66);
503 return true;
504 }
505
506 // handle non-a[download] safari as best we can:
507 if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
508 if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
509 if(!window.open(url)){ // popup blocked, offer direct download:
510 if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
511 }
512 return true;
513 }
514
515 //do iframe dataURL download (old ch+FF):
516 var f = document.createElement("iframe");
517 document.body.appendChild(f);
518
519 if(!winMode && /^data:/.test(url)){ // force a mime that will download:
520 url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
521 }
522 f.src=url;
523 setTimeout(function(){ document.body.removeChild(f); }, 333);
524
525 }//end saver
526
527
528
529
530 if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
531 return navigator.msSaveBlob(blob, fileName);
532 }
533
534 if(self.URL){ // simple fast and modern way using Blob and URL:
535 saver(self.URL.createObjectURL(blob), true);
536 }else{
537 // handle non-Blob()+non-URL browsers:
538 if(typeof blob === "string" || blob.constructor===toString ){
539 try{
540 return saver( "data:" + mimeType + ";base64," + self.btoa(blob) );
541 }catch(y){
542 return saver( "data:" + mimeType + "," + encodeURIComponent(blob) );
543 }
544 }
545
546 // Blob but not URL support:
547 reader=new FileReader();
548 reader.onload=function(e){
549 saver(this.result);
550 };
551 reader.readAsDataURL(blob);
552 }
553 return true;
554 }; /* end download() */
555 }));
556
557
558 /***/ }),
559
560 /***/ 9894:
561 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
562
563 // Load in dependencies
564 var computedStyle = __webpack_require__(4827);
565
566 /**
567 * Calculate the `line-height` of a given node
568 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
569 * @returns {Number} `line-height` of the element in pixels
570 */
571 function lineHeight(node) {
572 // Grab the line-height via style
573 var lnHeightStr = computedStyle(node, 'line-height');
574 var lnHeight = parseFloat(lnHeightStr, 10);
575
576 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
577 if (lnHeightStr === lnHeight + '') {
578 // Save the old lineHeight style and update the em unit to the element
579 var _lnHeightStyle = node.style.lineHeight;
580 node.style.lineHeight = lnHeightStr + 'em';
581
582 // Calculate the em based height
583 lnHeightStr = computedStyle(node, 'line-height');
584 lnHeight = parseFloat(lnHeightStr, 10);
585
586 // Revert the lineHeight style
587 if (_lnHeightStyle) {
588 node.style.lineHeight = _lnHeightStyle;
589 } else {
590 delete node.style.lineHeight;
591 }
592 }
593
594 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
595 // DEV: `em` units are converted to `pt` in IE6
596 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
597 if (lnHeightStr.indexOf('pt') !== -1) {
598 lnHeight *= 4;
599 lnHeight /= 3;
600 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
601 } else if (lnHeightStr.indexOf('mm') !== -1) {
602 lnHeight *= 96;
603 lnHeight /= 25.4;
604 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
605 } else if (lnHeightStr.indexOf('cm') !== -1) {
606 lnHeight *= 96;
607 lnHeight /= 2.54;
608 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
609 } else if (lnHeightStr.indexOf('in') !== -1) {
610 lnHeight *= 96;
611 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
612 } else if (lnHeightStr.indexOf('pc') !== -1) {
613 lnHeight *= 16;
614 }
615
616 // Continue our computation
617 lnHeight = Math.round(lnHeight);
618
619 // If the line-height is "normal", calculate by font-size
620 if (lnHeightStr === 'normal') {
621 // Create a temporary node
622 var nodeName = node.nodeName;
623 var _node = document.createElement(nodeName);
624 _node.innerHTML = '&nbsp;';
625
626 // If we have a text area, reset it to only 1 row
627 // https://github.com/twolfson/line-height/issues/4
628 if (nodeName.toUpperCase() === 'TEXTAREA') {
629 _node.setAttribute('rows', '1');
630 }
631
632 // Set the font-size of the element
633 var fontSizeStr = computedStyle(node, 'font-size');
634 _node.style.fontSize = fontSizeStr;
635
636 // Remove default padding/border which can affect offset height
637 // https://github.com/twolfson/line-height/issues/4
638 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
639 _node.style.padding = '0px';
640 _node.style.border = '0px';
641
642 // Append it to the body
643 var body = document.body;
644 body.appendChild(_node);
645
646 // Assume the line height of the element is the height
647 var height = _node.offsetHeight;
648 lnHeight = height;
649
650 // Remove our child from the DOM
651 body.removeChild(_node);
652 }
653
654 // Return the calculated height
655 return lnHeight;
656 }
657
658 // Export lineHeight
659 module.exports = lineHeight;
660
661
662 /***/ }),
663
664 /***/ 5372:
665 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
666
667 "use strict";
668 /**
669 * Copyright (c) 2013-present, Facebook, Inc.
670 *
671 * This source code is licensed under the MIT license found in the
672 * LICENSE file in the root directory of this source tree.
673 */
674
675
676
677 var ReactPropTypesSecret = __webpack_require__(9567);
678
679 function emptyFunction() {}
680 function emptyFunctionWithReset() {}
681 emptyFunctionWithReset.resetWarningCache = emptyFunction;
682
683 module.exports = function() {
684 function shim(props, propName, componentName, location, propFullName, secret) {
685 if (secret === ReactPropTypesSecret) {
686 // It is still safe when called from React.
687 return;
688 }
689 var err = new Error(
690 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
691 'Use PropTypes.checkPropTypes() to call them. ' +
692 'Read more at http://fb.me/use-check-prop-types'
693 );
694 err.name = 'Invariant Violation';
695 throw err;
696 };
697 shim.isRequired = shim;
698 function getShim() {
699 return shim;
700 };
701 // Important!
702 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
703 var ReactPropTypes = {
704 array: shim,
705 bool: shim,
706 func: shim,
707 number: shim,
708 object: shim,
709 string: shim,
710 symbol: shim,
711
712 any: shim,
713 arrayOf: getShim,
714 element: shim,
715 elementType: shim,
716 instanceOf: getShim,
717 node: shim,
718 objectOf: getShim,
719 oneOf: getShim,
720 oneOfType: getShim,
721 shape: getShim,
722 exact: getShim,
723
724 checkPropTypes: emptyFunctionWithReset,
725 resetWarningCache: emptyFunction
726 };
727
728 ReactPropTypes.PropTypes = ReactPropTypes;
729
730 return ReactPropTypes;
731 };
732
733
734 /***/ }),
735
736 /***/ 2652:
737 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
738
739 /**
740 * Copyright (c) 2013-present, Facebook, Inc.
741 *
742 * This source code is licensed under the MIT license found in the
743 * LICENSE file in the root directory of this source tree.
744 */
745
746 if (false) { var throwOnDirectAccess, ReactIs; } else {
747 // By explicitly using `prop-types` you are opting into new production behavior.
748 // http://fb.me/prop-types-in-prod
749 module.exports = __webpack_require__(5372)();
750 }
751
752
753 /***/ }),
754
755 /***/ 9567:
756 /***/ ((module) => {
757
758 "use strict";
759 /**
760 * Copyright (c) 2013-present, Facebook, Inc.
761 *
762 * This source code is licensed under the MIT license found in the
763 * LICENSE file in the root directory of this source tree.
764 */
765
766
767
768 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
769
770 module.exports = ReactPropTypesSecret;
771
772
773 /***/ }),
774
775 /***/ 5438:
776 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
777
778 "use strict";
779
780 var __extends = (this && this.__extends) || (function () {
781 var extendStatics = Object.setPrototypeOf ||
782 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
783 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
784 return function (d, b) {
785 extendStatics(d, b);
786 function __() { this.constructor = d; }
787 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
788 };
789 })();
790 var __assign = (this && this.__assign) || Object.assign || function(t) {
791 for (var s, i = 1, n = arguments.length; i < n; i++) {
792 s = arguments[i];
793 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
794 t[p] = s[p];
795 }
796 return t;
797 };
798 var __rest = (this && this.__rest) || function (s, e) {
799 var t = {};
800 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
801 t[p] = s[p];
802 if (s != null && typeof Object.getOwnPropertySymbols === "function")
803 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
804 t[p[i]] = s[p[i]];
805 return t;
806 };
807 exports.__esModule = true;
808 var React = __webpack_require__(9196);
809 var PropTypes = __webpack_require__(2652);
810 var autosize = __webpack_require__(6411);
811 var _getLineHeight = __webpack_require__(9894);
812 var getLineHeight = _getLineHeight;
813 var RESIZED = "autosize:resized";
814 /**
815 * A light replacement for built-in textarea component
816 * which automaticaly adjusts its height to match the content
817 */
818 var TextareaAutosizeClass = /** @class */ (function (_super) {
819 __extends(TextareaAutosizeClass, _super);
820 function TextareaAutosizeClass() {
821 var _this = _super !== null && _super.apply(this, arguments) || this;
822 _this.state = {
823 lineHeight: null
824 };
825 _this.textarea = null;
826 _this.onResize = function (e) {
827 if (_this.props.onResize) {
828 _this.props.onResize(e);
829 }
830 };
831 _this.updateLineHeight = function () {
832 if (_this.textarea) {
833 _this.setState({
834 lineHeight: getLineHeight(_this.textarea)
835 });
836 }
837 };
838 _this.onChange = function (e) {
839 var onChange = _this.props.onChange;
840 _this.currentValue = e.currentTarget.value;
841 onChange && onChange(e);
842 };
843 return _this;
844 }
845 TextareaAutosizeClass.prototype.componentDidMount = function () {
846 var _this = this;
847 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
848 if (typeof maxRows === "number") {
849 this.updateLineHeight();
850 }
851 if (typeof maxRows === "number" || async) {
852 /*
853 the defer is needed to:
854 - force "autosize" to activate the scrollbar when this.props.maxRows is passed
855 - support StyledComponents (see #71)
856 */
857 setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
858 }
859 else {
860 this.textarea && autosize(this.textarea);
861 }
862 if (this.textarea) {
863 this.textarea.addEventListener(RESIZED, this.onResize);
864 }
865 };
866 TextareaAutosizeClass.prototype.componentWillUnmount = function () {
867 if (this.textarea) {
868 this.textarea.removeEventListener(RESIZED, this.onResize);
869 autosize.destroy(this.textarea);
870 }
871 };
872 TextareaAutosizeClass.prototype.render = function () {
873 var _this = this;
874 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
875 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
876 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
877 _this.textarea = element;
878 if (typeof _this.props.innerRef === 'function') {
879 _this.props.innerRef(element);
880 }
881 else if (_this.props.innerRef) {
882 _this.props.innerRef.current = element;
883 }
884 } }), children));
885 };
886 TextareaAutosizeClass.prototype.componentDidUpdate = function () {
887 this.textarea && autosize.update(this.textarea);
888 };
889 TextareaAutosizeClass.defaultProps = {
890 rows: 1,
891 async: false
892 };
893 TextareaAutosizeClass.propTypes = {
894 rows: PropTypes.number,
895 maxRows: PropTypes.number,
896 onResize: PropTypes.func,
897 innerRef: PropTypes.any,
898 async: PropTypes.bool
899 };
900 return TextareaAutosizeClass;
901 }(React.Component));
902 exports.TextareaAutosize = React.forwardRef(function (props, ref) {
903 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
904 });
905
906
907 /***/ }),
908
909 /***/ 773:
910 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
911
912 "use strict";
913 var __webpack_unused_export__;
914
915 __webpack_unused_export__ = true;
916 var TextareaAutosize_1 = __webpack_require__(5438);
917 exports.Z = TextareaAutosize_1.TextareaAutosize;
918
919
920 /***/ }),
921
922 /***/ 9196:
923 /***/ ((module) => {
924
925 "use strict";
926 module.exports = window["React"];
927
928 /***/ })
929
930 /******/ });
931 /************************************************************************/
932 /******/ // The module cache
933 /******/ var __webpack_module_cache__ = {};
934 /******/
935 /******/ // The require function
936 /******/ function __webpack_require__(moduleId) {
937 /******/ // Check if module is in cache
938 /******/ var cachedModule = __webpack_module_cache__[moduleId];
939 /******/ if (cachedModule !== undefined) {
940 /******/ return cachedModule.exports;
941 /******/ }
942 /******/ // Create a new module (and put it into the cache)
943 /******/ var module = __webpack_module_cache__[moduleId] = {
944 /******/ // no module.id needed
945 /******/ // no module.loaded needed
946 /******/ exports: {}
947 /******/ };
948 /******/
949 /******/ // Execute the module function
950 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
951 /******/
952 /******/ // Return the exports of the module
953 /******/ return module.exports;
954 /******/ }
955 /******/
956 /************************************************************************/
957 /******/ /* webpack/runtime/compat get default export */
958 /******/ (() => {
959 /******/ // getDefaultExport function for compatibility with non-harmony modules
960 /******/ __webpack_require__.n = (module) => {
961 /******/ var getter = module && module.__esModule ?
962 /******/ () => (module['default']) :
963 /******/ () => (module);
964 /******/ __webpack_require__.d(getter, { a: getter });
965 /******/ return getter;
966 /******/ };
967 /******/ })();
968 /******/
969 /******/ /* webpack/runtime/define property getters */
970 /******/ (() => {
971 /******/ // define getter functions for harmony exports
972 /******/ __webpack_require__.d = (exports, definition) => {
973 /******/ for(var key in definition) {
974 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
975 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
976 /******/ }
977 /******/ }
978 /******/ };
979 /******/ })();
980 /******/
981 /******/ /* webpack/runtime/hasOwnProperty shorthand */
982 /******/ (() => {
983 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
984 /******/ })();
985 /******/
986 /******/ /* webpack/runtime/make namespace object */
987 /******/ (() => {
988 /******/ // define __esModule on exports
989 /******/ __webpack_require__.r = (exports) => {
990 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
991 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
992 /******/ }
993 /******/ Object.defineProperty(exports, '__esModule', { value: true });
994 /******/ };
995 /******/ })();
996 /******/
997 /************************************************************************/
998 var __webpack_exports__ = {};
999 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1000 (() => {
1001 "use strict";
1002 // ESM COMPAT FLAG
1003 __webpack_require__.r(__webpack_exports__);
1004
1005 // EXPORTS
1006 __webpack_require__.d(__webpack_exports__, {
1007 "PluginMoreMenuItem": () => (/* reexport */ plugin_more_menu_item),
1008 "PluginSidebar": () => (/* reexport */ PluginSidebarEditSite),
1009 "PluginSidebarMoreMenuItem": () => (/* reexport */ PluginSidebarMoreMenuItem),
1010 "__experimentalMainDashboardButton": () => (/* reexport */ main_dashboard_button),
1011 "__experimentalNavigationToggle": () => (/* reexport */ navigation_toggle),
1012 "initializeEditor": () => (/* binding */ initializeEditor),
1013 "reinitializeEditor": () => (/* binding */ reinitializeEditor)
1014 });
1015
1016 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1017 var actions_namespaceObject = {};
1018 __webpack_require__.r(actions_namespaceObject);
1019 __webpack_require__.d(actions_namespaceObject, {
1020 "disableComplementaryArea": () => (disableComplementaryArea),
1021 "enableComplementaryArea": () => (enableComplementaryArea),
1022 "pinItem": () => (pinItem),
1023 "setDefaultComplementaryArea": () => (setDefaultComplementaryArea),
1024 "setFeatureDefaults": () => (setFeatureDefaults),
1025 "setFeatureValue": () => (setFeatureValue),
1026 "toggleFeature": () => (toggleFeature),
1027 "unpinItem": () => (unpinItem)
1028 });
1029
1030 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1031 var selectors_namespaceObject = {};
1032 __webpack_require__.r(selectors_namespaceObject);
1033 __webpack_require__.d(selectors_namespaceObject, {
1034 "getActiveComplementaryArea": () => (getActiveComplementaryArea),
1035 "isFeatureActive": () => (isFeatureActive),
1036 "isItemPinned": () => (isItemPinned)
1037 });
1038
1039 // NAMESPACE OBJECT: ./packages/edit-site/build-module/store/actions.js
1040 var store_actions_namespaceObject = {};
1041 __webpack_require__.r(store_actions_namespaceObject);
1042 __webpack_require__.d(store_actions_namespaceObject, {
1043 "__experimentalSetPreviewDeviceType": () => (__experimentalSetPreviewDeviceType),
1044 "addTemplate": () => (addTemplate),
1045 "closeGeneralSidebar": () => (closeGeneralSidebar),
1046 "openGeneralSidebar": () => (openGeneralSidebar),
1047 "openNavigationPanelToMenu": () => (openNavigationPanelToMenu),
1048 "removeTemplate": () => (removeTemplate),
1049 "revertTemplate": () => (revertTemplate),
1050 "setHomeTemplateId": () => (setHomeTemplateId),
1051 "setIsInserterOpened": () => (setIsInserterOpened),
1052 "setIsListViewOpened": () => (setIsListViewOpened),
1053 "setIsNavigationPanelOpened": () => (setIsNavigationPanelOpened),
1054 "setNavigationPanelActiveMenu": () => (setNavigationPanelActiveMenu),
1055 "setPage": () => (setPage),
1056 "setTemplate": () => (setTemplate),
1057 "setTemplatePart": () => (setTemplatePart),
1058 "switchEditorMode": () => (switchEditorMode),
1059 "toggleFeature": () => (actions_toggleFeature),
1060 "updateSettings": () => (updateSettings)
1061 });
1062
1063 // NAMESPACE OBJECT: ./packages/edit-site/build-module/store/selectors.js
1064 var store_selectors_namespaceObject = {};
1065 __webpack_require__.r(store_selectors_namespaceObject);
1066 __webpack_require__.d(store_selectors_namespaceObject, {
1067 "__experimentalGetInsertionPoint": () => (__experimentalGetInsertionPoint),
1068 "__experimentalGetPreviewDeviceType": () => (__experimentalGetPreviewDeviceType),
1069 "__unstableGetPreference": () => (__unstableGetPreference),
1070 "getCanUserCreateMedia": () => (getCanUserCreateMedia),
1071 "getCurrentTemplateNavigationPanelSubMenu": () => (getCurrentTemplateNavigationPanelSubMenu),
1072 "getCurrentTemplateTemplateParts": () => (getCurrentTemplateTemplateParts),
1073 "getEditedPostId": () => (getEditedPostId),
1074 "getEditedPostType": () => (getEditedPostType),
1075 "getEditorMode": () => (getEditorMode),
1076 "getHomeTemplateId": () => (getHomeTemplateId),
1077 "getNavigationPanelActiveMenu": () => (getNavigationPanelActiveMenu),
1078 "getPage": () => (getPage),
1079 "getReusableBlocks": () => (getReusableBlocks),
1080 "getSettings": () => (getSettings),
1081 "isFeatureActive": () => (selectors_isFeatureActive),
1082 "isInserterOpened": () => (isInserterOpened),
1083 "isListViewOpened": () => (isListViewOpened),
1084 "isNavigationOpened": () => (isNavigationOpened)
1085 });
1086
1087 ;// CONCATENATED MODULE: external ["wp","element"]
1088 const external_wp_element_namespaceObject = window["wp"]["element"];
1089 ;// CONCATENATED MODULE: external ["wp","blocks"]
1090 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1091 ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
1092 const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
1093 ;// CONCATENATED MODULE: external ["wp","data"]
1094 const external_wp_data_namespaceObject = window["wp"]["data"];
1095 ;// CONCATENATED MODULE: external ["wp","coreData"]
1096 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1097 ;// CONCATENATED MODULE: external ["wp","editor"]
1098 const external_wp_editor_namespaceObject = window["wp"]["editor"];
1099 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1100 function extends_extends() {
1101 extends_extends = Object.assign || function (target) {
1102 for (var i = 1; i < arguments.length; i++) {
1103 var source = arguments[i];
1104
1105 for (var key in source) {
1106 if (Object.prototype.hasOwnProperty.call(source, key)) {
1107 target[key] = source[key];
1108 }
1109 }
1110 }
1111
1112 return target;
1113 };
1114
1115 return extends_extends.apply(this, arguments);
1116 }
1117 // EXTERNAL MODULE: ./node_modules/classnames/index.js
1118 var classnames = __webpack_require__(4403);
1119 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
1120 ;// CONCATENATED MODULE: external ["wp","components"]
1121 const external_wp_components_namespaceObject = window["wp"]["components"];
1122 ;// CONCATENATED MODULE: external ["wp","i18n"]
1123 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
1124 ;// CONCATENATED MODULE: external ["wp","primitives"]
1125 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1126 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
1127
1128
1129 /**
1130 * WordPress dependencies
1131 */
1132
1133 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1134 xmlns: "http://www.w3.org/2000/svg",
1135 viewBox: "0 0 24 24"
1136 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1137 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
1138 }));
1139 /* harmony default export */ const library_check = (check);
1140
1141 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
1142
1143
1144 /**
1145 * WordPress dependencies
1146 */
1147
1148 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1149 xmlns: "http://www.w3.org/2000/svg",
1150 viewBox: "0 0 24 24"
1151 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1152 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"
1153 }));
1154 /* harmony default export */ const star_filled = (starFilled);
1155
1156 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
1157
1158
1159 /**
1160 * WordPress dependencies
1161 */
1162
1163 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1164 xmlns: "http://www.w3.org/2000/svg",
1165 viewBox: "0 0 24 24"
1166 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1167 fillRule: "evenodd",
1168 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",
1169 clipRule: "evenodd"
1170 }));
1171 /* harmony default export */ const star_empty = (starEmpty);
1172
1173 ;// CONCATENATED MODULE: external ["wp","viewport"]
1174 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
1175 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
1176
1177
1178 /**
1179 * WordPress dependencies
1180 */
1181
1182 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1183 xmlns: "http://www.w3.org/2000/svg",
1184 viewBox: "0 0 24 24"
1185 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1186 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"
1187 }));
1188 /* harmony default export */ const close_small = (closeSmall);
1189
1190 ;// CONCATENATED MODULE: external "lodash"
1191 const external_lodash_namespaceObject = window["lodash"];
1192 ;// CONCATENATED MODULE: external ["wp","deprecated"]
1193 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
1194 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
1195 ;// CONCATENATED MODULE: external ["wp","preferences"]
1196 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
1197 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
1198 /**
1199 * WordPress dependencies
1200 */
1201
1202
1203 /**
1204 * Set a default complementary area.
1205 *
1206 * @param {string} scope Complementary area scope.
1207 * @param {string} area Area identifier.
1208 *
1209 * @return {Object} Action object.
1210 */
1211
1212 const setDefaultComplementaryArea = (scope, area) => ({
1213 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
1214 scope,
1215 area
1216 });
1217 /**
1218 * Enable the complementary area.
1219 *
1220 * @param {string} scope Complementary area scope.
1221 * @param {string} area Area identifier.
1222 */
1223
1224 const enableComplementaryArea = (scope, area) => _ref => {
1225 let {
1226 registry,
1227 dispatch
1228 } = _ref;
1229
1230 // Return early if there's no area.
1231 if (!area) {
1232 return;
1233 }
1234
1235 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
1236
1237 if (!isComplementaryAreaVisible) {
1238 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
1239 }
1240
1241 dispatch({
1242 type: 'ENABLE_COMPLEMENTARY_AREA',
1243 scope,
1244 area
1245 });
1246 };
1247 /**
1248 * Disable the complementary area.
1249 *
1250 * @param {string} scope Complementary area scope.
1251 */
1252
1253 const disableComplementaryArea = scope => _ref2 => {
1254 let {
1255 registry
1256 } = _ref2;
1257 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
1258
1259 if (isComplementaryAreaVisible) {
1260 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
1261 }
1262 };
1263 /**
1264 * Pins an item.
1265 *
1266 * @param {string} scope Item scope.
1267 * @param {string} item Item identifier.
1268 *
1269 * @return {Object} Action object.
1270 */
1271
1272 const pinItem = (scope, item) => _ref3 => {
1273 let {
1274 registry
1275 } = _ref3;
1276
1277 // Return early if there's no item.
1278 if (!item) {
1279 return;
1280 }
1281
1282 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
1283
1284 if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
1285 return;
1286 }
1287
1288 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1289 [item]: true
1290 });
1291 };
1292 /**
1293 * Unpins an item.
1294 *
1295 * @param {string} scope Item scope.
1296 * @param {string} item Item identifier.
1297 */
1298
1299 const unpinItem = (scope, item) => _ref4 => {
1300 let {
1301 registry
1302 } = _ref4;
1303
1304 // Return early if there's no item.
1305 if (!item) {
1306 return;
1307 }
1308
1309 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1310 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1311 [item]: false
1312 });
1313 };
1314 /**
1315 * Returns an action object used in signalling that a feature should be toggled.
1316 *
1317 * @param {string} scope The feature scope (e.g. core/edit-post).
1318 * @param {string} featureName The feature name.
1319 */
1320
1321 function toggleFeature(scope, featureName) {
1322 return function (_ref5) {
1323 let {
1324 registry
1325 } = _ref5;
1326 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
1327 since: '6.0',
1328 alternative: `dispatch( 'core/preferences' ).toggle`
1329 });
1330 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
1331 };
1332 }
1333 /**
1334 * Returns an action object used in signalling that a feature should be set to
1335 * a true or false value
1336 *
1337 * @param {string} scope The feature scope (e.g. core/edit-post).
1338 * @param {string} featureName The feature name.
1339 * @param {boolean} value The value to set.
1340 *
1341 * @return {Object} Action object.
1342 */
1343
1344 function setFeatureValue(scope, featureName, value) {
1345 return function (_ref6) {
1346 let {
1347 registry
1348 } = _ref6;
1349 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
1350 since: '6.0',
1351 alternative: `dispatch( 'core/preferences' ).set`
1352 });
1353 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
1354 };
1355 }
1356 /**
1357 * Returns an action object used in signalling that defaults should be set for features.
1358 *
1359 * @param {string} scope The feature scope (e.g. core/edit-post).
1360 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
1361 *
1362 * @return {Object} Action object.
1363 */
1364
1365 function setFeatureDefaults(scope, defaults) {
1366 return function (_ref7) {
1367 let {
1368 registry
1369 } = _ref7;
1370 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
1371 since: '6.0',
1372 alternative: `dispatch( 'core/preferences' ).setDefaults`
1373 });
1374 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
1375 };
1376 }
1377
1378 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
1379 /**
1380 * WordPress dependencies
1381 */
1382
1383
1384
1385 /**
1386 * Returns the complementary area that is active in a given scope.
1387 *
1388 * @param {Object} state Global application state.
1389 * @param {string} scope Item scope.
1390 *
1391 * @return {string | null | undefined} The complementary area that is active in the given scope.
1392 */
1393
1394 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
1395 var _state$complementaryA;
1396
1397 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled
1398 // visibility, this is the vanilla default. Other code relies on this
1399 // nuance in the return value.
1400
1401 if (isComplementaryAreaVisible === undefined) {
1402 return undefined;
1403 } // Return `null` to indicate the user hid the complementary area.
1404
1405
1406 if (!isComplementaryAreaVisible) {
1407 return null;
1408 }
1409
1410 return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope];
1411 });
1412 /**
1413 * Returns a boolean indicating if an item is pinned or not.
1414 *
1415 * @param {Object} state Global application state.
1416 * @param {string} scope Scope.
1417 * @param {string} item Item to check.
1418 *
1419 * @return {boolean} True if the item is pinned and false otherwise.
1420 */
1421
1422 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
1423 var _pinnedItems$item;
1424
1425 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1426 return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
1427 });
1428 /**
1429 * Returns a boolean indicating whether a feature is active for a particular
1430 * scope.
1431 *
1432 * @param {Object} state The store state.
1433 * @param {string} scope The scope of the feature (e.g. core/edit-post).
1434 * @param {string} featureName The name of the feature.
1435 *
1436 * @return {boolean} Is the feature enabled?
1437 */
1438
1439 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
1440 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
1441 since: '6.0',
1442 alternative: `select( 'core/preferences' ).get( scope, featureName )`
1443 });
1444 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
1445 });
1446
1447 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
1448 /**
1449 * WordPress dependencies
1450 */
1451
1452 function complementaryAreas() {
1453 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1454 let action = arguments.length > 1 ? arguments[1] : undefined;
1455
1456 switch (action.type) {
1457 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
1458 {
1459 const {
1460 scope,
1461 area
1462 } = action; // If there's already an area, don't overwrite it.
1463
1464 if (state[scope]) {
1465 return state;
1466 }
1467
1468 return { ...state,
1469 [scope]: area
1470 };
1471 }
1472
1473 case 'ENABLE_COMPLEMENTARY_AREA':
1474 {
1475 const {
1476 scope,
1477 area
1478 } = action;
1479 return { ...state,
1480 [scope]: area
1481 };
1482 }
1483 }
1484
1485 return state;
1486 }
1487 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1488 complementaryAreas
1489 }));
1490
1491 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
1492 /**
1493 * The identifier for the data store.
1494 *
1495 * @type {string}
1496 */
1497 const STORE_NAME = 'core/interface';
1498
1499 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
1500 /**
1501 * WordPress dependencies
1502 */
1503
1504 /**
1505 * Internal dependencies
1506 */
1507
1508
1509
1510
1511
1512 /**
1513 * Store definition for the interface namespace.
1514 *
1515 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1516 *
1517 * @type {Object}
1518 */
1519
1520 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
1521 reducer: reducer,
1522 actions: actions_namespaceObject,
1523 selectors: selectors_namespaceObject
1524 }); // Once we build a more generic persistence plugin that works across types of stores
1525 // we'd be able to replace this with a register call.
1526
1527 (0,external_wp_data_namespaceObject.register)(store);
1528
1529 ;// CONCATENATED MODULE: external ["wp","plugins"]
1530 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
1531 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
1532 /**
1533 * WordPress dependencies
1534 */
1535
1536 /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
1537 return {
1538 icon: ownProps.icon || context.icon,
1539 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
1540 };
1541 }));
1542
1543 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
1544
1545
1546
1547 /**
1548 * External dependencies
1549 */
1550
1551 /**
1552 * WordPress dependencies
1553 */
1554
1555
1556
1557 /**
1558 * Internal dependencies
1559 */
1560
1561
1562
1563
1564 function ComplementaryAreaToggle(_ref) {
1565 let {
1566 as = external_wp_components_namespaceObject.Button,
1567 scope,
1568 identifier,
1569 icon,
1570 selectedIcon,
1571 ...props
1572 } = _ref;
1573 const ComponentToUse = as;
1574 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]);
1575 const {
1576 enableComplementaryArea,
1577 disableComplementaryArea
1578 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1579 return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, extends_extends({
1580 icon: selectedIcon && isSelected ? selectedIcon : icon,
1581 onClick: () => {
1582 if (isSelected) {
1583 disableComplementaryArea(scope);
1584 } else {
1585 enableComplementaryArea(scope, identifier);
1586 }
1587 }
1588 }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
1589 }
1590
1591 /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
1592
1593 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
1594
1595
1596
1597 /**
1598 * External dependencies
1599 */
1600
1601 /**
1602 * WordPress dependencies
1603 */
1604
1605
1606 /**
1607 * Internal dependencies
1608 */
1609
1610
1611
1612 const ComplementaryAreaHeader = _ref => {
1613 let {
1614 smallScreenTitle,
1615 children,
1616 className,
1617 toggleButtonProps
1618 } = _ref;
1619 const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1620 icon: close_small
1621 }, toggleButtonProps));
1622 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
1623 className: "components-panel__header interface-complementary-area-header__small"
1624 }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
1625 className: "interface-complementary-area-header__small-title"
1626 }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
1627 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
1628 tabIndex: -1
1629 }, children, toggleButton));
1630 };
1631
1632 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
1633
1634 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
1635
1636
1637
1638 /**
1639 * External dependencies
1640 */
1641
1642 /**
1643 * WordPress dependencies
1644 */
1645
1646
1647
1648
1649 const noop = () => {};
1650
1651 function ActionItemSlot(_ref) {
1652 let {
1653 name,
1654 as: Component = external_wp_components_namespaceObject.ButtonGroup,
1655 fillProps = {},
1656 bubblesVirtually,
1657 ...props
1658 } = _ref;
1659 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
1660 name: name,
1661 bubblesVirtually: bubblesVirtually,
1662 fillProps: fillProps
1663 }, fills => {
1664 if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
1665 return null;
1666 } // Special handling exists for backward compatibility.
1667 // It ensures that menu items created by plugin authors aren't
1668 // duplicated with automatically injected menu items coming
1669 // from pinnable plugin sidebars.
1670 // @see https://github.com/WordPress/gutenberg/issues/14457
1671
1672
1673 const initializedByPlugins = [];
1674 external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
1675 let {
1676 props: {
1677 __unstableExplicitMenuItem,
1678 __unstableTarget
1679 }
1680 } = _ref2;
1681
1682 if (__unstableTarget && __unstableExplicitMenuItem) {
1683 initializedByPlugins.push(__unstableTarget);
1684 }
1685 });
1686 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
1687 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
1688 return null;
1689 }
1690
1691 return child;
1692 });
1693 return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
1694 });
1695 }
1696
1697 function ActionItem(_ref3) {
1698 let {
1699 name,
1700 as: Component = external_wp_components_namespaceObject.Button,
1701 onClick,
1702 ...props
1703 } = _ref3;
1704 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1705 name: name
1706 }, _ref4 => {
1707 let {
1708 onClick: fpOnClick
1709 } = _ref4;
1710 return (0,external_wp_element_namespaceObject.createElement)(Component, extends_extends({
1711 onClick: onClick || fpOnClick ? function () {
1712 (onClick || noop)(...arguments);
1713 (fpOnClick || noop)(...arguments);
1714 } : undefined
1715 }, props));
1716 });
1717 }
1718
1719 ActionItem.Slot = ActionItemSlot;
1720 /* harmony default export */ const action_item = (ActionItem);
1721
1722 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
1723
1724
1725
1726 /**
1727 * External dependencies
1728 */
1729
1730 /**
1731 * WordPress dependencies
1732 */
1733
1734
1735
1736 /**
1737 * Internal dependencies
1738 */
1739
1740
1741
1742
1743 const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
1744 // They are removed so they don't leak to DOM elements.
1745 // @see https://github.com/WordPress/gutenberg/issues/14457
1746 (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
1747
1748 function ComplementaryAreaMoreMenuItem(_ref) {
1749 let {
1750 scope,
1751 target,
1752 __unstableExplicitMenuItem,
1753 ...props
1754 } = _ref;
1755 return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1756 as: toggleProps => {
1757 return (0,external_wp_element_namespaceObject.createElement)(action_item, extends_extends({
1758 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
1759 __unstableTarget: `${scope}/${target}`,
1760 as: PluginsMenuItem,
1761 name: `${scope}/plugin-more-menu`
1762 }, toggleProps));
1763 },
1764 role: "menuitemcheckbox",
1765 selectedIcon: library_check,
1766 name: target,
1767 scope: scope
1768 }, props));
1769 }
1770
1771 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
1772
1773
1774
1775 /**
1776 * External dependencies
1777 */
1778
1779
1780 /**
1781 * WordPress dependencies
1782 */
1783
1784
1785
1786 function PinnedItems(_ref) {
1787 let {
1788 scope,
1789 ...props
1790 } = _ref;
1791 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, extends_extends({
1792 name: `PinnedItems/${scope}`
1793 }, props));
1794 }
1795
1796 function PinnedItemsSlot(_ref2) {
1797 let {
1798 scope,
1799 className,
1800 ...props
1801 } = _ref2;
1802 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
1803 name: `PinnedItems/${scope}`
1804 }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
1805 className: classnames_default()(className, 'interface-pinned-items')
1806 }, fills));
1807 }
1808
1809 PinnedItems.Slot = PinnedItemsSlot;
1810 /* harmony default export */ const pinned_items = (PinnedItems);
1811
1812 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
1813
1814
1815
1816 /**
1817 * External dependencies
1818 */
1819
1820 /**
1821 * WordPress dependencies
1822 */
1823
1824
1825
1826
1827
1828
1829
1830 /**
1831 * Internal dependencies
1832 */
1833
1834
1835
1836
1837
1838
1839
1840
1841 function ComplementaryAreaSlot(_ref) {
1842 let {
1843 scope,
1844 ...props
1845 } = _ref;
1846 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
1847 name: `ComplementaryArea/${scope}`
1848 }, props));
1849 }
1850
1851 function ComplementaryAreaFill(_ref2) {
1852 let {
1853 scope,
1854 children,
1855 className
1856 } = _ref2;
1857 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1858 name: `ComplementaryArea/${scope}`
1859 }, (0,external_wp_element_namespaceObject.createElement)("div", {
1860 className: className
1861 }, children));
1862 }
1863
1864 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
1865 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1866 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1867 const {
1868 enableComplementaryArea,
1869 disableComplementaryArea
1870 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1871 (0,external_wp_element_namespaceObject.useEffect)(() => {
1872 // If the complementary area is active and the editor is switching from a big to a small window size.
1873 if (isActive && isSmall && !previousIsSmall.current) {
1874 // Disable the complementary area.
1875 disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
1876
1877 shouldOpenWhenNotSmall.current = true;
1878 } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
1879 // and we are going from a small to big window size.
1880 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
1881 // Remove the flag indicating the complementary area should be enabled.
1882 shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
1883
1884 enableComplementaryArea(scope, identifier);
1885 } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
1886 // remove the flag.
1887 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
1888 shouldOpenWhenNotSmall.current = false;
1889 }
1890
1891 if (isSmall !== previousIsSmall.current) {
1892 previousIsSmall.current = isSmall;
1893 }
1894 }, [isActive, isSmall, scope, identifier, activeArea]);
1895 }
1896
1897 function ComplementaryArea(_ref3) {
1898 let {
1899 children,
1900 className,
1901 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
1902 identifier,
1903 header,
1904 headerClassName,
1905 icon,
1906 isPinnable = true,
1907 panelClassName,
1908 scope,
1909 name,
1910 smallScreenTitle,
1911 title,
1912 toggleShortcut,
1913 isActiveByDefault,
1914 showIconLabels = false
1915 } = _ref3;
1916 const {
1917 isActive,
1918 isPinned,
1919 activeArea,
1920 isSmall,
1921 isLarge
1922 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1923 const {
1924 getActiveComplementaryArea,
1925 isItemPinned
1926 } = select(store);
1927
1928 const _activeArea = getActiveComplementaryArea(scope);
1929
1930 return {
1931 isActive: _activeArea === identifier,
1932 isPinned: isItemPinned(scope, identifier),
1933 activeArea: _activeArea,
1934 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
1935 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
1936 };
1937 }, [identifier, scope]);
1938 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
1939 const {
1940 enableComplementaryArea,
1941 disableComplementaryArea,
1942 pinItem,
1943 unpinItem
1944 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1945 (0,external_wp_element_namespaceObject.useEffect)(() => {
1946 if (isActiveByDefault && activeArea === undefined && !isSmall) {
1947 enableComplementaryArea(scope, identifier);
1948 }
1949 }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
1950 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
1951 scope: scope
1952 }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
1953 scope: scope,
1954 identifier: identifier,
1955 isPressed: isActive && (!showIconLabels || isLarge),
1956 "aria-expanded": isActive,
1957 label: title,
1958 icon: showIconLabels ? library_check : icon,
1959 showTooltip: !showIconLabels,
1960 variant: showIconLabels ? 'tertiary' : undefined
1961 })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
1962 target: name,
1963 scope: scope,
1964 icon: icon
1965 }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
1966 className: classnames_default()('interface-complementary-area', className),
1967 scope: scope
1968 }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
1969 className: headerClassName,
1970 closeLabel: closeLabel,
1971 onClose: () => disableComplementaryArea(scope),
1972 smallScreenTitle: smallScreenTitle,
1973 toggleButtonProps: {
1974 label: closeLabel,
1975 shortcut: toggleShortcut,
1976 scope,
1977 identifier
1978 }
1979 }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1980 className: "interface-complementary-area__pin-unpin-item",
1981 icon: isPinned ? star_filled : star_empty,
1982 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
1983 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
1984 isPressed: isPinned,
1985 "aria-expanded": isPinned
1986 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
1987 className: panelClassName
1988 }, children)));
1989 }
1990
1991 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
1992 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
1993 /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped);
1994
1995 ;// CONCATENATED MODULE: external ["wp","compose"]
1996 const external_wp_compose_namespaceObject = window["wp"]["compose"];
1997 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
1998
1999
2000
2001 /**
2002 * External dependencies
2003 */
2004
2005 /**
2006 * WordPress dependencies
2007 */
2008
2009 /**
2010 * WordPress dependencies
2011 */
2012
2013
2014
2015
2016
2017
2018 function useHTMLClass(className) {
2019 (0,external_wp_element_namespaceObject.useEffect)(() => {
2020 const element = document && document.querySelector(`html:not(.${className})`);
2021
2022 if (!element) {
2023 return;
2024 }
2025
2026 element.classList.toggle(className);
2027 return () => {
2028 element.classList.toggle(className);
2029 };
2030 }, [className]);
2031 }
2032
2033 function InterfaceSkeleton(_ref, ref) {
2034 let {
2035 footer,
2036 header,
2037 sidebar,
2038 secondarySidebar,
2039 notices,
2040 content,
2041 drawer,
2042 actions,
2043 labels,
2044 className,
2045 shortcuts
2046 } = _ref;
2047 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
2048 useHTMLClass('interface-interface-skeleton__html-container');
2049 const defaultLabels = {
2050 /* translators: accessibility text for the nav bar landmark region. */
2051 drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
2052
2053 /* translators: accessibility text for the top bar landmark region. */
2054 header: (0,external_wp_i18n_namespaceObject.__)('Header'),
2055
2056 /* translators: accessibility text for the content landmark region. */
2057 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
2058
2059 /* translators: accessibility text for the secondary sidebar landmark region. */
2060 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
2061
2062 /* translators: accessibility text for the settings landmark region. */
2063 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
2064
2065 /* translators: accessibility text for the publish landmark region. */
2066 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
2067
2068 /* translators: accessibility text for the footer landmark region. */
2069 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
2070 };
2071 const mergedLabels = { ...defaultLabels,
2072 ...labels
2073 };
2074 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({}, navigateRegionsProps, {
2075 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
2076 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
2077 }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
2078 className: "interface-interface-skeleton__drawer",
2079 role: "region",
2080 "aria-label": mergedLabels.drawer,
2081 tabIndex: "-1"
2082 }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
2083 className: "interface-interface-skeleton__editor"
2084 }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
2085 className: "interface-interface-skeleton__header",
2086 role: "region",
2087 "aria-label": mergedLabels.header,
2088 tabIndex: "-1"
2089 }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
2090 className: "interface-interface-skeleton__body"
2091 }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
2092 className: "interface-interface-skeleton__secondary-sidebar",
2093 role: "region",
2094 "aria-label": mergedLabels.secondarySidebar,
2095 tabIndex: "-1"
2096 }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
2097 className: "interface-interface-skeleton__notices"
2098 }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
2099 className: "interface-interface-skeleton__content",
2100 role: "region",
2101 "aria-label": mergedLabels.body,
2102 tabIndex: "-1"
2103 }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
2104 className: "interface-interface-skeleton__sidebar",
2105 role: "region",
2106 "aria-label": mergedLabels.sidebar,
2107 tabIndex: "-1"
2108 }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
2109 className: "interface-interface-skeleton__actions",
2110 role: "region",
2111 "aria-label": mergedLabels.actions,
2112 tabIndex: "-1"
2113 }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
2114 className: "interface-interface-skeleton__footer",
2115 role: "region",
2116 "aria-label": mergedLabels.footer,
2117 tabIndex: "-1"
2118 }, footer));
2119 }
2120
2121 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
2122
2123 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
2124
2125
2126 /**
2127 * WordPress dependencies
2128 */
2129
2130 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2131 xmlns: "http://www.w3.org/2000/svg",
2132 viewBox: "0 0 24 24"
2133 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2134 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
2135 }));
2136 /* harmony default export */ const more_vertical = (moreVertical);
2137
2138 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
2139
2140
2141 /**
2142 * External dependencies
2143 */
2144
2145 /**
2146 * WordPress dependencies
2147 */
2148
2149
2150
2151
2152 function MoreMenuDropdown(_ref) {
2153 let {
2154 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
2155 className,
2156
2157 /* translators: button label text should, if possible, be under 16 characters. */
2158 label = (0,external_wp_i18n_namespaceObject.__)('Options'),
2159 popoverProps,
2160 toggleProps,
2161 children
2162 } = _ref;
2163 return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
2164 className: classnames_default()('interface-more-menu-dropdown', className),
2165 icon: more_vertical,
2166 label: label,
2167 popoverProps: {
2168 position: 'bottom left',
2169 ...popoverProps,
2170 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
2171 },
2172 toggleProps: {
2173 tooltipPosition: 'bottom',
2174 ...toggleProps
2175 }
2176 }, onClose => children(onClose));
2177 }
2178
2179 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal/index.js
2180
2181
2182 /**
2183 * WordPress dependencies
2184 */
2185
2186
2187 function PreferencesModal(_ref) {
2188 let {
2189 closeModal,
2190 children
2191 } = _ref;
2192 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
2193 className: "interface-preferences-modal",
2194 title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
2195 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
2196 onRequestClose: closeModal
2197 }, children);
2198 }
2199
2200 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
2201 /**
2202 * WordPress dependencies
2203 */
2204
2205 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
2206
2207 /**
2208 * Return an SVG icon.
2209 *
2210 * @param {IconProps} props icon is the SVG component to render
2211 * size is a number specifiying the icon size in pixels
2212 * Other props will be passed to wrapped SVG component
2213 *
2214 * @return {JSX.Element} Icon component
2215 */
2216
2217 function Icon(_ref) {
2218 let {
2219 icon,
2220 size = 24,
2221 ...props
2222 } = _ref;
2223 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
2224 width: size,
2225 height: size,
2226 ...props
2227 });
2228 }
2229
2230 /* harmony default export */ const icon = (Icon);
2231
2232 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
2233
2234
2235 /**
2236 * WordPress dependencies
2237 */
2238
2239 const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2240 xmlns: "http://www.w3.org/2000/svg",
2241 viewBox: "0 0 24 24"
2242 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2243 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
2244 }));
2245 /* harmony default export */ const chevron_left = (chevronLeft);
2246
2247 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
2248
2249
2250 /**
2251 * WordPress dependencies
2252 */
2253
2254 const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2255 xmlns: "http://www.w3.org/2000/svg",
2256 viewBox: "0 0 24 24"
2257 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2258 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
2259 }));
2260 /* harmony default export */ const chevron_right = (chevronRight);
2261
2262 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-tabs/index.js
2263
2264
2265 /**
2266 * WordPress dependencies
2267 */
2268
2269
2270
2271
2272
2273 const PREFERENCES_MENU = 'preferences-menu';
2274 function PreferencesModalTabs(_ref) {
2275 let {
2276 sections
2277 } = _ref;
2278 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); // This is also used to sync the two different rendered components
2279 // between small and large viewports.
2280
2281 const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
2282 /**
2283 * Create helper objects from `sections` for easier data handling.
2284 * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
2285 * is used for easier access to active tab's content.
2286 */
2287
2288 const {
2289 tabs,
2290 sectionsContentMap
2291 } = (0,external_wp_element_namespaceObject.useMemo)(() => {
2292 let mappedTabs = {
2293 tabs: [],
2294 sectionsContentMap: {}
2295 };
2296
2297 if (sections.length) {
2298 mappedTabs = sections.reduce((accumulator, _ref2) => {
2299 let {
2300 name,
2301 tabLabel: title,
2302 content
2303 } = _ref2;
2304 accumulator.tabs.push({
2305 name,
2306 title
2307 });
2308 accumulator.sectionsContentMap[name] = content;
2309 return accumulator;
2310 }, {
2311 tabs: [],
2312 sectionsContentMap: {}
2313 });
2314 }
2315
2316 return mappedTabs;
2317 }, [sections]);
2318 const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
2319 let modalContent; // We render different components based on the viewport size.
2320
2321 if (isLargeViewport) {
2322 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
2323 className: "interface-preferences__tabs",
2324 tabs: tabs,
2325 initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
2326 onSelect: setActiveMenu,
2327 orientation: "vertical"
2328 }, getCurrentTab);
2329 } else {
2330 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
2331 initialPath: "/",
2332 className: "interface-preferences__provider"
2333 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2334 path: "/"
2335 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2336 isBorderless: true,
2337 size: "small"
2338 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, tabs.map(tab => {
2339 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, {
2340 key: tab.name,
2341 path: tab.name,
2342 as: external_wp_components_namespaceObject.__experimentalItem,
2343 isAction: true
2344 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
2345 justify: "space-between"
2346 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, null, tab.title)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
2347 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
2348 }))));
2349 }))))), sections.length && sections.map(section => {
2350 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2351 key: `${section.name}-menu`,
2352 path: section.name
2353 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2354 isBorderless: true,
2355 size: "large"
2356 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardHeader, {
2357 isBorderless: false,
2358 justify: "left",
2359 size: "small",
2360 gap: "6"
2361 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
2362 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
2363 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
2364 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
2365 size: "16"
2366 }, section.tabLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, section.content)));
2367 }));
2368 }
2369
2370 return modalContent;
2371 }
2372
2373 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-section/index.js
2374
2375
2376 const Section = _ref => {
2377 let {
2378 description,
2379 title,
2380 children
2381 } = _ref;
2382 return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
2383 className: "interface-preferences-modal__section"
2384 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_element_namespaceObject.createElement)("h2", {
2385 className: "interface-preferences-modal__section-title"
2386 }, title), description && (0,external_wp_element_namespaceObject.createElement)("p", {
2387 className: "interface-preferences-modal__section-description"
2388 }, description)), children);
2389 };
2390
2391 /* harmony default export */ const preferences_modal_section = (Section);
2392
2393 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-base-option/index.js
2394
2395
2396 /**
2397 * WordPress dependencies
2398 */
2399
2400
2401 function BaseOption(_ref) {
2402 let {
2403 help,
2404 label,
2405 isChecked,
2406 onChange,
2407 children
2408 } = _ref;
2409 return (0,external_wp_element_namespaceObject.createElement)("div", {
2410 className: "interface-preferences-modal__option"
2411 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
2412 help: help,
2413 label: label,
2414 checked: isChecked,
2415 onChange: onChange
2416 }), children);
2417 }
2418
2419 /* harmony default export */ const preferences_modal_base_option = (BaseOption);
2420
2421 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
2436
2437
2438
2439 ;// CONCATENATED MODULE: external ["wp","url"]
2440 const external_wp_url_namespaceObject = window["wp"]["url"];
2441 ;// CONCATENATED MODULE: external ["wp","hooks"]
2442 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
2443 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
2444 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
2445 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/components.js
2446 /**
2447 * WordPress dependencies
2448 */
2449
2450
2451 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-site/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
2452
2453 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/index.js
2454 /**
2455 * Internal dependencies
2456 */
2457
2458
2459 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/constants.js
2460 /**
2461 * The identifier for the data store.
2462 *
2463 * @type {string}
2464 */
2465 const constants_STORE_NAME = 'core/edit-site';
2466 const TEMPLATE_PART_AREA_HEADER = 'header';
2467 const TEMPLATE_PART_AREA_FOOTER = 'footer';
2468 const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
2469 const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';
2470
2471 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/constants.js
2472 /**
2473 * WordPress dependencies
2474 */
2475
2476 /**
2477 * Internal dependencies
2478 */
2479
2480
2481 const TEMPLATES_PRIMARY = ['index', 'singular', 'archive', 'single', 'page', 'home', '404', 'search'];
2482 const TEMPLATES_SECONDARY = ['author', 'category', 'taxonomy', 'date', 'tag', 'attachment', 'single', 'front-page'];
2483 const TEMPLATES_TOP_LEVEL = [...TEMPLATES_PRIMARY, ...TEMPLATES_SECONDARY];
2484 const TEMPLATES_GENERAL = ['page-home'];
2485 const TEMPLATES_POSTS_PREFIXES = ['post-', 'author-', 'single-', 'tag-'];
2486 const TEMPLATES_PAGES_PREFIXES = ['page-'];
2487 const TEMPLATE_OVERRIDES = {
2488 singular: ['single', 'page'],
2489 index: ['archive', '404', 'search', 'singular', 'home'],
2490 home: ['front-page']
2491 };
2492 const MENU_ROOT = 'root';
2493 const MENU_TEMPLATE_PARTS = 'template-parts';
2494 const MENU_TEMPLATES = 'templates';
2495 const MENU_TEMPLATES_GENERAL = 'templates-general';
2496 const MENU_TEMPLATES_PAGES = 'templates-pages';
2497 const MENU_TEMPLATES_POSTS = 'templates-posts';
2498 const MENU_TEMPLATES_UNUSED = 'templates-unused';
2499 const MENU_TEMPLATE_PARTS_HEADERS = 'template-parts-headers';
2500 const MENU_TEMPLATE_PARTS_FOOTERS = 'template-parts-footers';
2501 const MENU_TEMPLATE_PARTS_SIDEBARS = 'template-parts-sidebars';
2502 const MENU_TEMPLATE_PARTS_GENERAL = 'template-parts-general';
2503 const TEMPLATE_PARTS_SUB_MENUS = [{
2504 area: TEMPLATE_PART_AREA_HEADER,
2505 menu: MENU_TEMPLATE_PARTS_HEADERS,
2506 title: (0,external_wp_i18n_namespaceObject.__)('headers')
2507 }, {
2508 area: TEMPLATE_PART_AREA_FOOTER,
2509 menu: MENU_TEMPLATE_PARTS_FOOTERS,
2510 title: (0,external_wp_i18n_namespaceObject.__)('footers')
2511 }, {
2512 area: TEMPLATE_PART_AREA_SIDEBAR,
2513 menu: MENU_TEMPLATE_PARTS_SIDEBARS,
2514 title: (0,external_wp_i18n_namespaceObject.__)('sidebars')
2515 }, {
2516 area: TEMPLATE_PART_AREA_GENERAL,
2517 menu: MENU_TEMPLATE_PARTS_GENERAL,
2518 title: (0,external_wp_i18n_namespaceObject.__)('general')
2519 }];
2520
2521 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/reducer.js
2522 /**
2523 * WordPress dependencies
2524 */
2525
2526 /**
2527 * Internal dependencies
2528 */
2529
2530
2531 /**
2532 * Reducer returning the editing canvas device type.
2533 *
2534 * @param {Object} state Current state.
2535 * @param {Object} action Dispatched action.
2536 *
2537 * @return {Object} Updated state.
2538 */
2539
2540 function deviceType() {
2541 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Desktop';
2542 let action = arguments.length > 1 ? arguments[1] : undefined;
2543
2544 switch (action.type) {
2545 case 'SET_PREVIEW_DEVICE_TYPE':
2546 return action.deviceType;
2547 }
2548
2549 return state;
2550 }
2551 /**
2552 * Reducer returning the settings.
2553 *
2554 * @param {Object} state Current state.
2555 * @param {Object} action Dispatched action.
2556 *
2557 * @return {Object} Updated state.
2558 */
2559
2560 function settings() {
2561 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2562 let action = arguments.length > 1 ? arguments[1] : undefined;
2563
2564 switch (action.type) {
2565 case 'UPDATE_SETTINGS':
2566 return { ...state,
2567 ...action.settings
2568 };
2569 }
2570
2571 return state;
2572 }
2573 /**
2574 * Reducer keeping track of the currently edited Post Type,
2575 * Post Id and the context provided to fill the content of the block editor.
2576 *
2577 * @param {Object} state Current edited post.
2578 * @param {Object} action Dispatched action.
2579 *
2580 * @return {Object} Updated state.
2581 */
2582
2583 function editedPost() {
2584 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2585 let action = arguments.length > 1 ? arguments[1] : undefined;
2586
2587 switch (action.type) {
2588 case 'SET_TEMPLATE':
2589 case 'SET_PAGE':
2590 return {
2591 type: 'wp_template',
2592 id: action.templateId,
2593 page: action.page
2594 };
2595
2596 case 'SET_TEMPLATE_PART':
2597 return {
2598 type: 'wp_template_part',
2599 id: action.templatePartId
2600 };
2601 }
2602
2603 return state;
2604 }
2605 /**
2606 * Reducer for information about the site's homepage.
2607 *
2608 * @param {Object} state Current state.
2609 * @param {Object} action Dispatched action.
2610 *
2611 * @return {Object} Updated state.
2612 */
2613
2614 function homeTemplateId(state, action) {
2615 switch (action.type) {
2616 case 'SET_HOME_TEMPLATE':
2617 return action.homeTemplateId;
2618 }
2619
2620 return state;
2621 }
2622 /**
2623 * Reducer for information about the navigation panel, such as its active menu
2624 * and whether it should be opened or closed.
2625 *
2626 * Note: this reducer interacts with the inserter and list view panels reducers
2627 * to make sure that only one of the three panels is open at the same time.
2628 *
2629 * @param {Object} state Current state.
2630 * @param {Object} action Dispatched action.
2631 */
2632
2633 function navigationPanel() {
2634 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2635 menu: MENU_ROOT,
2636 isOpen: false
2637 };
2638 let action = arguments.length > 1 ? arguments[1] : undefined;
2639
2640 switch (action.type) {
2641 case 'SET_NAVIGATION_PANEL_ACTIVE_MENU':
2642 return { ...state,
2643 menu: action.menu
2644 };
2645
2646 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2647 return { ...state,
2648 isOpen: true,
2649 menu: action.menu
2650 };
2651
2652 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2653 return { ...state,
2654 menu: !action.isOpen ? MENU_ROOT : state.menu,
2655 // Set menu to root when closing panel.
2656 isOpen: action.isOpen
2657 };
2658
2659 case 'SET_IS_LIST_VIEW_OPENED':
2660 return { ...state,
2661 menu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu,
2662 // Set menu to root when closing panel.
2663 isOpen: action.isOpen ? false : state.isOpen
2664 };
2665
2666 case 'SET_IS_INSERTER_OPENED':
2667 return { ...state,
2668 menu: state.isOpen && action.value ? MENU_ROOT : state.menu,
2669 // Set menu to root when closing panel.
2670 isOpen: action.value ? false : state.isOpen
2671 };
2672 }
2673
2674 return state;
2675 }
2676 /**
2677 * Reducer to set the block inserter panel open or closed.
2678 *
2679 * Note: this reducer interacts with the navigation and list view panels reducers
2680 * to make sure that only one of the three panels is open at the same time.
2681 *
2682 * @param {boolean|Object} state Current state.
2683 * @param {Object} action Dispatched action.
2684 */
2685
2686 function blockInserterPanel() {
2687 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2688 let action = arguments.length > 1 ? arguments[1] : undefined;
2689
2690 switch (action.type) {
2691 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2692 return false;
2693
2694 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2695 case 'SET_IS_LIST_VIEW_OPENED':
2696 return action.isOpen ? false : state;
2697
2698 case 'SET_IS_INSERTER_OPENED':
2699 return action.value;
2700 }
2701
2702 return state;
2703 }
2704 /**
2705 * Reducer to set the list view panel open or closed.
2706 *
2707 * Note: this reducer interacts with the navigation and inserter panels reducers
2708 * to make sure that only one of the three panels is open at the same time.
2709 *
2710 * @param {Object} state Current state.
2711 * @param {Object} action Dispatched action.
2712 */
2713
2714 function listViewPanel() {
2715 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2716 let action = arguments.length > 1 ? arguments[1] : undefined;
2717
2718 switch (action.type) {
2719 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2720 return false;
2721
2722 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2723 return action.isOpen ? false : state;
2724
2725 case 'SET_IS_INSERTER_OPENED':
2726 return action.value ? false : state;
2727
2728 case 'SET_IS_LIST_VIEW_OPENED':
2729 return action.isOpen;
2730 }
2731
2732 return state;
2733 }
2734 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2735 deviceType,
2736 settings,
2737 editedPost,
2738 homeTemplateId,
2739 navigationPanel,
2740 blockInserterPanel,
2741 listViewPanel
2742 }));
2743
2744 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
2745 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
2746 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
2747 ;// CONCATENATED MODULE: external ["wp","notices"]
2748 const external_wp_notices_namespaceObject = window["wp"]["notices"];
2749 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
2750 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
2751 ;// CONCATENATED MODULE: external ["wp","a11y"]
2752 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
2753 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-revertable.js
2754 /**
2755 * Check if a template is revertable to its original theme-provided template file.
2756 *
2757 * @param {Object} template The template entity to check.
2758 * @return {boolean} Whether the template is revertable.
2759 */
2760 function isTemplateRevertable(template) {
2761 if (!template) {
2762 return false;
2763 }
2764 /* eslint-disable camelcase */
2765
2766
2767 return (template === null || template === void 0 ? void 0 : template.source) === 'custom' && (template === null || template === void 0 ? void 0 : template.has_theme_file);
2768 /* eslint-enable camelcase */
2769 }
2770
2771 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/actions.js
2772 /**
2773 * WordPress dependencies
2774 */
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786 /**
2787 * Internal dependencies
2788 */
2789
2790
2791
2792 /**
2793 * Dispatches an action that toggles a feature flag.
2794 *
2795 * @param {string} featureName Feature name.
2796 */
2797
2798 function actions_toggleFeature(featureName) {
2799 return function (_ref) {
2800 let {
2801 registry
2802 } = _ref;
2803 external_wp_deprecated_default()("select( 'core/edit-site' ).toggleFeature( featureName )", {
2804 since: '6.0',
2805 alternative: "select( 'core/preferences').toggle( 'core/edit-site', featureName )"
2806 });
2807 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-site', featureName);
2808 };
2809 }
2810 /**
2811 * Action that changes the width of the editing canvas.
2812 *
2813 * @param {string} deviceType
2814 *
2815 * @return {Object} Action object.
2816 */
2817
2818 function __experimentalSetPreviewDeviceType(deviceType) {
2819 return {
2820 type: 'SET_PREVIEW_DEVICE_TYPE',
2821 deviceType
2822 };
2823 }
2824 /**
2825 * Action that sets a template, optionally fetching it from REST API.
2826 *
2827 * @param {number} templateId The template ID.
2828 * @param {string} templateSlug The template slug.
2829 * @return {Object} Action object.
2830 */
2831
2832 const setTemplate = (templateId, templateSlug) => async _ref2 => {
2833 let {
2834 dispatch,
2835 registry
2836 } = _ref2;
2837
2838 if (!templateSlug) {
2839 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
2840 templateSlug = template === null || template === void 0 ? void 0 : template.slug;
2841 }
2842
2843 dispatch({
2844 type: 'SET_TEMPLATE',
2845 templateId,
2846 page: {
2847 context: {
2848 templateSlug
2849 }
2850 }
2851 });
2852 };
2853 /**
2854 * Action that adds a new template and sets it as the current template.
2855 *
2856 * @param {Object} template The template.
2857 *
2858 * @return {Object} Action object used to set the current template.
2859 */
2860
2861 const addTemplate = template => async _ref3 => {
2862 let {
2863 dispatch,
2864 registry
2865 } = _ref3;
2866 const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
2867
2868 if (template.content) {
2869 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', 'wp_template', newTemplate.id, {
2870 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content)
2871 }, {
2872 undoIgnore: true
2873 });
2874 }
2875
2876 dispatch({
2877 type: 'SET_TEMPLATE',
2878 templateId: newTemplate.id,
2879 page: {
2880 context: {
2881 templateSlug: newTemplate.slug
2882 }
2883 }
2884 });
2885 };
2886 /**
2887 * Action that removes a template.
2888 *
2889 * @param {Object} template The template object.
2890 */
2891
2892 const removeTemplate = template => async _ref4 => {
2893 let {
2894 registry
2895 } = _ref4;
2896
2897 try {
2898 await registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', template.type, template.id, {
2899 force: true
2900 });
2901 const lastError = registry.select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError('postType', template.type, template.id);
2902
2903 if (lastError) {
2904 throw lastError;
2905 }
2906
2907 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
2908 /* translators: The template/part's name. */
2909 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), template.title.rendered), {
2910 type: 'snackbar'
2911 });
2912 } catch (error) {
2913 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.');
2914 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
2915 type: 'snackbar'
2916 });
2917 }
2918 };
2919 /**
2920 * Action that sets a template part.
2921 *
2922 * @param {string} templatePartId The template part ID.
2923 *
2924 * @return {Object} Action object.
2925 */
2926
2927 function setTemplatePart(templatePartId) {
2928 return {
2929 type: 'SET_TEMPLATE_PART',
2930 templatePartId
2931 };
2932 }
2933 /**
2934 * Action that sets the home template ID to the template ID of the page resolved
2935 * from a given path.
2936 *
2937 * @param {number} homeTemplateId The template ID for the homepage.
2938 */
2939
2940 function setHomeTemplateId(homeTemplateId) {
2941 return {
2942 type: 'SET_HOME_TEMPLATE',
2943 homeTemplateId
2944 };
2945 }
2946 /**
2947 * Resolves the template for a page and displays both. If no path is given, attempts
2948 * to use the postId to generate a path like `?p=${ postId }`.
2949 *
2950 * @param {Object} page The page object.
2951 * @param {string} page.type The page type.
2952 * @param {string} page.slug The page slug.
2953 * @param {string} page.path The page path.
2954 * @param {Object} page.context The page context.
2955 *
2956 * @return {number} The resolved template ID for the page route.
2957 */
2958
2959 const setPage = page => async _ref5 => {
2960 var _page$context;
2961
2962 let {
2963 dispatch,
2964 registry
2965 } = _ref5;
2966
2967 if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
2968 const entity = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
2969
2970 page.path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(entity === null || entity === void 0 ? void 0 : entity.link);
2971 }
2972
2973 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).__experimentalGetTemplateForLink(page.path);
2974
2975 if (!template) {
2976 return;
2977 }
2978
2979 dispatch({
2980 type: 'SET_PAGE',
2981 page: template.slug ? { ...page,
2982 context: { ...page.context,
2983 templateSlug: template.slug
2984 }
2985 } : page,
2986 templateId: template.id
2987 });
2988 return template.id;
2989 };
2990 /**
2991 * Action that sets the active navigation panel menu.
2992 *
2993 * @param {string} menu Menu prop of active menu.
2994 *
2995 * @return {Object} Action object.
2996 */
2997
2998 function setNavigationPanelActiveMenu(menu) {
2999 return {
3000 type: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',
3001 menu
3002 };
3003 }
3004 /**
3005 * Opens the navigation panel and sets its active menu at the same time.
3006 *
3007 * @param {string} menu Identifies the menu to open.
3008 */
3009
3010 function openNavigationPanelToMenu(menu) {
3011 return {
3012 type: 'OPEN_NAVIGATION_PANEL_TO_MENU',
3013 menu
3014 };
3015 }
3016 /**
3017 * Sets whether the navigation panel should be open.
3018 *
3019 * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It
3020 * does not toggle the state, but sets it directly.
3021 */
3022
3023 function setIsNavigationPanelOpened(isOpen) {
3024 return {
3025 type: 'SET_IS_NAVIGATION_PANEL_OPENED',
3026 isOpen
3027 };
3028 }
3029 /**
3030 * Opens or closes the inserter.
3031 *
3032 * @param {boolean|Object} value Whether the inserter should be
3033 * opened (true) or closed (false).
3034 * To specify an insertion point,
3035 * use an object.
3036 * @param {string} value.rootClientId The root client ID to insert at.
3037 * @param {number} value.insertionIndex The index to insert at.
3038 *
3039 * @return {Object} Action object.
3040 */
3041
3042 function setIsInserterOpened(value) {
3043 return {
3044 type: 'SET_IS_INSERTER_OPENED',
3045 value
3046 };
3047 }
3048 /**
3049 * Returns an action object used to update the settings.
3050 *
3051 * @param {Object} settings New settings.
3052 *
3053 * @return {Object} Action object.
3054 */
3055
3056 function updateSettings(settings) {
3057 return {
3058 type: 'UPDATE_SETTINGS',
3059 settings
3060 };
3061 }
3062 /**
3063 * Sets whether the list view panel should be open.
3064 *
3065 * @param {boolean} isOpen If true, opens the list view. If false, closes it.
3066 * It does not toggle the state, but sets it directly.
3067 */
3068
3069 function setIsListViewOpened(isOpen) {
3070 return {
3071 type: 'SET_IS_LIST_VIEW_OPENED',
3072 isOpen
3073 };
3074 }
3075 /**
3076 * Reverts a template to its original theme-provided file.
3077 *
3078 * @param {Object} template The template to revert.
3079 * @param {Object} [options]
3080 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
3081 * reverting the template. Default true.
3082 */
3083
3084 const revertTemplate = function (template) {
3085 let {
3086 allowUndo = true
3087 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3088 return async _ref6 => {
3089 let {
3090 registry
3091 } = _ref6;
3092
3093 if (!isTemplateRevertable(template)) {
3094 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
3095 type: 'snackbar'
3096 });
3097 return;
3098 }
3099
3100 try {
3101 var _fileTemplate$content;
3102
3103 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
3104
3105 if (!templateEntityConfig) {
3106 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3107 type: 'snackbar'
3108 });
3109 return;
3110 }
3111
3112 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
3113 context: 'edit',
3114 source: 'theme'
3115 });
3116 const fileTemplate = await external_wp_apiFetch_default()({
3117 path: fileTemplatePath
3118 });
3119
3120 if (!fileTemplate) {
3121 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3122 type: 'snackbar'
3123 });
3124 return;
3125 }
3126
3127 const serializeBlocks = _ref7 => {
3128 let {
3129 blocks: blocksForSerialization = []
3130 } = _ref7;
3131 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
3132 };
3133
3134 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id); // We are fixing up the undo level here to make sure we can undo
3135 // the revert in the header toolbar correctly.
3136
3137 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
3138 content: serializeBlocks,
3139 // Required to make the `undo` behave correctly.
3140 blocks: edited.blocks,
3141 // Required to revert the blocks in the editor.
3142 source: 'custom' // required to avoid turning the editor into a dirty state
3143
3144 }, {
3145 undoIgnore: true // Required to merge this edit with the last undo level.
3146
3147 });
3148 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate === null || fileTemplate === void 0 ? void 0 : (_fileTemplate$content = fileTemplate.content) === null || _fileTemplate$content === void 0 ? void 0 : _fileTemplate$content.raw);
3149 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
3150 content: serializeBlocks,
3151 blocks,
3152 source: 'theme'
3153 });
3154
3155 if (allowUndo) {
3156 const undoRevert = () => {
3157 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
3158 content: serializeBlocks,
3159 blocks: edited.blocks,
3160 source: 'custom'
3161 });
3162 };
3163
3164 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'), {
3165 type: 'snackbar',
3166 actions: [{
3167 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
3168 onClick: undoRevert
3169 }]
3170 });
3171 } else {
3172 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'));
3173 }
3174 } catch (error) {
3175 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
3176 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
3177 type: 'snackbar'
3178 });
3179 }
3180 };
3181 };
3182 /**
3183 * Action that opens an editor sidebar.
3184 *
3185 * @param {?string} name Sidebar name to be opened.
3186 */
3187
3188 const openGeneralSidebar = name => _ref8 => {
3189 let {
3190 registry
3191 } = _ref8;
3192 registry.dispatch(store).enableComplementaryArea(constants_STORE_NAME, name);
3193 };
3194 /**
3195 * Action that closes the sidebar.
3196 */
3197
3198 const closeGeneralSidebar = () => _ref9 => {
3199 let {
3200 registry
3201 } = _ref9;
3202 registry.dispatch(store).disableComplementaryArea(constants_STORE_NAME);
3203 };
3204 const switchEditorMode = mode => _ref10 => {
3205 let {
3206 registry
3207 } = _ref10;
3208 registry.dispatch('core/preferences').set('core/edit-site', 'editorMode', mode); // Unselect blocks when we switch to a non visual mode.
3209
3210 if (mode !== 'visual') {
3211 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
3212 }
3213
3214 if (mode === 'visual') {
3215 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
3216 } else if (mode === 'mosaic') {
3217 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Mosaic view selected'), 'assertive');
3218 }
3219 };
3220
3221 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
3222
3223
3224 /** @typedef {(...args: any[]) => *[]} GetDependants */
3225
3226 /** @typedef {() => void} Clear */
3227
3228 /**
3229 * @typedef {{
3230 * getDependants: GetDependants,
3231 * clear: Clear
3232 * }} EnhancedSelector
3233 */
3234
3235 /**
3236 * Internal cache entry.
3237 *
3238 * @typedef CacheNode
3239 *
3240 * @property {?CacheNode|undefined} [prev] Previous node.
3241 * @property {?CacheNode|undefined} [next] Next node.
3242 * @property {*[]} args Function arguments for cache entry.
3243 * @property {*} val Function result.
3244 */
3245
3246 /**
3247 * @typedef Cache
3248 *
3249 * @property {Clear} clear Function to clear cache.
3250 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
3251 * considering cache uniqueness. A cache is unique if dependents are all arrays
3252 * or objects.
3253 * @property {CacheNode?} [head] Cache head.
3254 * @property {*[]} [lastDependants] Dependants from previous invocation.
3255 */
3256
3257 /**
3258 * Arbitrary value used as key for referencing cache object in WeakMap tree.
3259 *
3260 * @type {{}}
3261 */
3262 var LEAF_KEY = {};
3263
3264 /**
3265 * Returns the first argument as the sole entry in an array.
3266 *
3267 * @template T
3268 *
3269 * @param {T} value Value to return.
3270 *
3271 * @return {[T]} Value returned as entry in array.
3272 */
3273 function arrayOf(value) {
3274 return [value];
3275 }
3276
3277 /**
3278 * Returns true if the value passed is object-like, or false otherwise. A value
3279 * is object-like if it can support property assignment, e.g. object or array.
3280 *
3281 * @param {*} value Value to test.
3282 *
3283 * @return {boolean} Whether value is object-like.
3284 */
3285 function isObjectLike(value) {
3286 return !!value && 'object' === typeof value;
3287 }
3288
3289 /**
3290 * Creates and returns a new cache object.
3291 *
3292 * @return {Cache} Cache object.
3293 */
3294 function createCache() {
3295 /** @type {Cache} */
3296 var cache = {
3297 clear: function () {
3298 cache.head = null;
3299 },
3300 };
3301
3302 return cache;
3303 }
3304
3305 /**
3306 * Returns true if entries within the two arrays are strictly equal by
3307 * reference from a starting index.
3308 *
3309 * @param {*[]} a First array.
3310 * @param {*[]} b Second array.
3311 * @param {number} fromIndex Index from which to start comparison.
3312 *
3313 * @return {boolean} Whether arrays are shallowly equal.
3314 */
3315 function isShallowEqual(a, b, fromIndex) {
3316 var i;
3317
3318 if (a.length !== b.length) {
3319 return false;
3320 }
3321
3322 for (i = fromIndex; i < a.length; i++) {
3323 if (a[i] !== b[i]) {
3324 return false;
3325 }
3326 }
3327
3328 return true;
3329 }
3330
3331 /**
3332 * Returns a memoized selector function. The getDependants function argument is
3333 * called before the memoized selector and is expected to return an immutable
3334 * reference or array of references on which the selector depends for computing
3335 * its own return value. The memoize cache is preserved only as long as those
3336 * dependant references remain the same. If getDependants returns a different
3337 * reference(s), the cache is cleared and the selector value regenerated.
3338 *
3339 * @template {(...args: *[]) => *} S
3340 *
3341 * @param {S} selector Selector function.
3342 * @param {GetDependants=} getDependants Dependant getter returning an array of
3343 * references used in cache bust consideration.
3344 */
3345 /* harmony default export */ function rememo(selector, getDependants) {
3346 /** @type {WeakMap<*,*>} */
3347 var rootCache;
3348
3349 /** @type {GetDependants} */
3350 var normalizedGetDependants = getDependants ? getDependants : arrayOf;
3351
3352 /**
3353 * Returns the cache for a given dependants array. When possible, a WeakMap
3354 * will be used to create a unique cache for each set of dependants. This
3355 * is feasible due to the nature of WeakMap in allowing garbage collection
3356 * to occur on entries where the key object is no longer referenced. Since
3357 * WeakMap requires the key to be an object, this is only possible when the
3358 * dependant is object-like. The root cache is created as a hierarchy where
3359 * each top-level key is the first entry in a dependants set, the value a
3360 * WeakMap where each key is the next dependant, and so on. This continues
3361 * so long as the dependants are object-like. If no dependants are object-
3362 * like, then the cache is shared across all invocations.
3363 *
3364 * @see isObjectLike
3365 *
3366 * @param {*[]} dependants Selector dependants.
3367 *
3368 * @return {Cache} Cache object.
3369 */
3370 function getCache(dependants) {
3371 var caches = rootCache,
3372 isUniqueByDependants = true,
3373 i,
3374 dependant,
3375 map,
3376 cache;
3377
3378 for (i = 0; i < dependants.length; i++) {
3379 dependant = dependants[i];
3380
3381 // Can only compose WeakMap from object-like key.
3382 if (!isObjectLike(dependant)) {
3383 isUniqueByDependants = false;
3384 break;
3385 }
3386
3387 // Does current segment of cache already have a WeakMap?
3388 if (caches.has(dependant)) {
3389 // Traverse into nested WeakMap.
3390 caches = caches.get(dependant);
3391 } else {
3392 // Create, set, and traverse into a new one.
3393 map = new WeakMap();
3394 caches.set(dependant, map);
3395 caches = map;
3396 }
3397 }
3398
3399 // We use an arbitrary (but consistent) object as key for the last item
3400 // in the WeakMap to serve as our running cache.
3401 if (!caches.has(LEAF_KEY)) {
3402 cache = createCache();
3403 cache.isUniqueByDependants = isUniqueByDependants;
3404 caches.set(LEAF_KEY, cache);
3405 }
3406
3407 return caches.get(LEAF_KEY);
3408 }
3409
3410 /**
3411 * Resets root memoization cache.
3412 */
3413 function clear() {
3414 rootCache = new WeakMap();
3415 }
3416
3417 /* eslint-disable jsdoc/check-param-names */
3418 /**
3419 * The augmented selector call, considering first whether dependants have
3420 * changed before passing it to underlying memoize function.
3421 *
3422 * @param {*} source Source object for derivation.
3423 * @param {...*} extraArgs Additional arguments to pass to selector.
3424 *
3425 * @return {*} Selector result.
3426 */
3427 /* eslint-enable jsdoc/check-param-names */
3428 function callSelector(/* source, ...extraArgs */) {
3429 var len = arguments.length,
3430 cache,
3431 node,
3432 i,
3433 args,
3434 dependants;
3435
3436 // Create copy of arguments (avoid leaking deoptimization).
3437 args = new Array(len);
3438 for (i = 0; i < len; i++) {
3439 args[i] = arguments[i];
3440 }
3441
3442 dependants = normalizedGetDependants.apply(null, args);
3443 cache = getCache(dependants);
3444
3445 // If not guaranteed uniqueness by dependants (primitive type), shallow
3446 // compare against last dependants and, if references have changed,
3447 // destroy cache to recalculate result.
3448 if (!cache.isUniqueByDependants) {
3449 if (
3450 cache.lastDependants &&
3451 !isShallowEqual(dependants, cache.lastDependants, 0)
3452 ) {
3453 cache.clear();
3454 }
3455
3456 cache.lastDependants = dependants;
3457 }
3458
3459 node = cache.head;
3460 while (node) {
3461 // Check whether node arguments match arguments
3462 if (!isShallowEqual(node.args, args, 1)) {
3463 node = node.next;
3464 continue;
3465 }
3466
3467 // At this point we can assume we've found a match
3468
3469 // Surface matched node to head if not already
3470 if (node !== cache.head) {
3471 // Adjust siblings to point to each other.
3472 /** @type {CacheNode} */ (node.prev).next = node.next;
3473 if (node.next) {
3474 node.next.prev = node.prev;
3475 }
3476
3477 node.next = cache.head;
3478 node.prev = null;
3479 /** @type {CacheNode} */ (cache.head).prev = node;
3480 cache.head = node;
3481 }
3482
3483 // Return immediately
3484 return node.val;
3485 }
3486
3487 // No cached value found. Continue to insertion phase:
3488
3489 node = /** @type {CacheNode} */ ({
3490 // Generate the result from original function
3491 val: selector.apply(null, args),
3492 });
3493
3494 // Avoid including the source object in the cache.
3495 args[0] = null;
3496 node.args = args;
3497
3498 // Don't need to check whether node is already head, since it would
3499 // have been returned above already if it was
3500
3501 // Shift existing head down list
3502 if (cache.head) {
3503 cache.head.prev = node;
3504 node.next = cache.head;
3505 }
3506
3507 cache.head = node;
3508
3509 return node.val;
3510 }
3511
3512 callSelector.getDependants = normalizedGetDependants;
3513 callSelector.clear = clear;
3514 clear();
3515
3516 return /** @type {S & EnhancedSelector} */ (callSelector);
3517 }
3518
3519 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js
3520 /**
3521 * External dependencies
3522 */
3523
3524 /**
3525 * Internal dependencies
3526 */
3527
3528
3529 function isTemplateSuperseded(slug, existingSlugs, showOnFront) {
3530 if (!TEMPLATE_OVERRIDES[slug]) {
3531 return false;
3532 } // `home` template is unused if it is superseded by `front-page`
3533 // or "show on front" is set to show a page rather than blog posts.
3534
3535
3536 if (slug === 'home' && showOnFront !== 'posts') {
3537 return true;
3538 }
3539
3540 return TEMPLATE_OVERRIDES[slug].every(overrideSlug => existingSlugs.includes(overrideSlug) || isTemplateSuperseded(overrideSlug, existingSlugs, showOnFront));
3541 }
3542 function getTemplateLocation(slug) {
3543 const isTopLevelTemplate = TEMPLATES_TOP_LEVEL.includes(slug);
3544
3545 if (isTopLevelTemplate) {
3546 return MENU_TEMPLATES;
3547 }
3548
3549 const isGeneralTemplate = TEMPLATES_GENERAL.includes(slug);
3550
3551 if (isGeneralTemplate) {
3552 return MENU_TEMPLATES_GENERAL;
3553 }
3554
3555 const isPostsTemplate = TEMPLATES_POSTS_PREFIXES.some(prefix => slug.startsWith(prefix));
3556
3557 if (isPostsTemplate) {
3558 return MENU_TEMPLATES_POSTS;
3559 }
3560
3561 const isPagesTemplate = TEMPLATES_PAGES_PREFIXES.some(prefix => slug.startsWith(prefix));
3562
3563 if (isPagesTemplate) {
3564 return MENU_TEMPLATES_PAGES;
3565 }
3566
3567 return MENU_TEMPLATES_GENERAL;
3568 }
3569 function getUnusedTemplates(templates, showOnFront) {
3570 const templateSlugs = map(templates, 'slug');
3571 const supersededTemplates = templates.filter(_ref => {
3572 let {
3573 slug
3574 } = _ref;
3575 return isTemplateSuperseded(slug, templateSlugs, showOnFront);
3576 });
3577 return supersededTemplates;
3578 }
3579 function getTemplatesLocationMap(templates) {
3580 return templates.reduce((obj, template) => {
3581 obj[template.slug] = getTemplateLocation(template.slug);
3582 return obj;
3583 }, {});
3584 }
3585
3586 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/selectors.js
3587 /**
3588 * External dependencies
3589 */
3590
3591
3592 /**
3593 * WordPress dependencies
3594 */
3595
3596
3597
3598
3599
3600
3601
3602
3603 /**
3604 * Internal dependencies
3605 */
3606
3607
3608
3609 /**
3610 * @typedef {'template'|'template_type'} TemplateType Template type.
3611 */
3612
3613 /**
3614 * Helper for getting a preference from the preferences store.
3615 *
3616 * This is only present so that `getSettings` doesn't need to be made a
3617 * registry selector.
3618 *
3619 * It's unstable because the selector needs to be exported and so part of the
3620 * public API to work.
3621 */
3622
3623 const __unstableGetPreference = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, name) => select(external_wp_preferences_namespaceObject.store).get('core/edit-site', name));
3624 /**
3625 * Returns whether the given feature is enabled or not.
3626 *
3627 * @param {Object} state Global application state.
3628 * @param {string} featureName Feature slug.
3629 *
3630 * @return {boolean} Is active.
3631 */
3632
3633 function selectors_isFeatureActive(state, featureName) {
3634 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive`, {
3635 since: '6.0',
3636 alternative: `select( 'core/preferences' ).get`
3637 });
3638 return !!__unstableGetPreference(state, featureName);
3639 }
3640 /**
3641 * Returns the current editing canvas device type.
3642 *
3643 * @param {Object} state Global application state.
3644 *
3645 * @return {string} Device type.
3646 */
3647
3648 function __experimentalGetPreviewDeviceType(state) {
3649 return state.deviceType;
3650 }
3651 /**
3652 * Returns whether the current user can create media or not.
3653 *
3654 * @param {Object} state Global application state.
3655 *
3656 * @return {Object} Whether the current user can create media or not.
3657 */
3658
3659 const getCanUserCreateMedia = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => select(external_wp_coreData_namespaceObject.store).canUser('create', 'media'));
3660 /**
3661 * Returns any available Reusable blocks.
3662 *
3663 * @param {Object} state Global application state.
3664 *
3665 * @return {Array} The available reusable blocks.
3666 */
3667
3668 const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3669 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
3670 return isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
3671 per_page: -1
3672 }) : [];
3673 });
3674 /**
3675 * Returns the settings, taking into account active features and permissions.
3676 *
3677 * @param {Object} state Global application state.
3678 * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.
3679 *
3680 * @return {Object} Settings.
3681 */
3682
3683 const getSettings = rememo((state, setIsInserterOpen) => {
3684 const settings = { ...state.settings,
3685 outlineMode: true,
3686 focusMode: !!__unstableGetPreference(state, 'focusMode'),
3687 hasFixedToolbar: !!__unstableGetPreference(state, 'fixedToolbar'),
3688 keepCaretInsideBlock: !!__unstableGetPreference(state, 'keepCaretInsideBlock'),
3689 showIconLabels: !!__unstableGetPreference(state, 'showIconLabels'),
3690 __experimentalSetIsInserterOpened: setIsInserterOpen,
3691 __experimentalReusableBlocks: getReusableBlocks(state),
3692 __experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType(state)
3693 };
3694 const canUserCreateMedia = getCanUserCreateMedia(state);
3695
3696 if (!canUserCreateMedia) {
3697 return settings;
3698 }
3699
3700 settings.mediaUpload = _ref => {
3701 let {
3702 onError,
3703 ...rest
3704 } = _ref;
3705 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
3706 wpAllowedMimeTypes: state.settings.allowedMimeTypes,
3707 onError: _ref2 => {
3708 let {
3709 message
3710 } = _ref2;
3711 return onError(message);
3712 },
3713 ...rest
3714 });
3715 };
3716
3717 return settings;
3718 }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
3719 /**
3720 * Returns the current home template ID.
3721 *
3722 * @param {Object} state Global application state.
3723 *
3724 * @return {number?} Home template ID.
3725 */
3726
3727 function getHomeTemplateId(state) {
3728 return state.homeTemplateId;
3729 }
3730
3731 function getCurrentEditedPost(state) {
3732 return state.editedPost;
3733 }
3734 /**
3735 * Returns the current edited post type (wp_template or wp_template_part).
3736 *
3737 * @param {Object} state Global application state.
3738 *
3739 * @return {TemplateType?} Template type.
3740 */
3741
3742
3743 function getEditedPostType(state) {
3744 return getCurrentEditedPost(state).type;
3745 }
3746 /**
3747 * Returns the ID of the currently edited template or template part.
3748 *
3749 * @param {Object} state Global application state.
3750 *
3751 * @return {string?} Post ID.
3752 */
3753
3754 function getEditedPostId(state) {
3755 return getCurrentEditedPost(state).id;
3756 }
3757 /**
3758 * Returns the current page object.
3759 *
3760 * @param {Object} state Global application state.
3761 *
3762 * @return {Object} Page.
3763 */
3764
3765 function getPage(state) {
3766 return getCurrentEditedPost(state).page;
3767 }
3768 /**
3769 * Returns the active menu in the navigation panel.
3770 *
3771 * @param {Object} state Global application state.
3772 *
3773 * @return {string} Active menu.
3774 */
3775
3776 function getNavigationPanelActiveMenu(state) {
3777 return state.navigationPanel.menu;
3778 }
3779 /**
3780 * Returns the current template or template part's corresponding
3781 * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.
3782 *
3783 * @param {Object} state Global application state.
3784 *
3785 * @return {string} The current template or template part's sub menu.
3786 */
3787
3788 const getCurrentTemplateNavigationPanelSubMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3789 const templateType = getEditedPostType(state);
3790 const templateId = getEditedPostId(state);
3791 const template = templateId ? select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', templateType, templateId) : null;
3792
3793 if (!template) {
3794 return MENU_ROOT;
3795 }
3796
3797 if ('wp_template_part' === templateType) {
3798 var _TEMPLATE_PARTS_SUB_M;
3799
3800 return ((_TEMPLATE_PARTS_SUB_M = TEMPLATE_PARTS_SUB_MENUS.find(submenu => submenu.area === (template === null || template === void 0 ? void 0 : template.area))) === null || _TEMPLATE_PARTS_SUB_M === void 0 ? void 0 : _TEMPLATE_PARTS_SUB_M.menu) || MENU_TEMPLATE_PARTS;
3801 }
3802
3803 const templates = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template');
3804 const showOnFront = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('root', 'site').show_on_front;
3805
3806 if (isTemplateSuperseded(template.slug, (0,external_lodash_namespaceObject.map)(templates, 'slug'), showOnFront)) {
3807 return MENU_TEMPLATES_UNUSED;
3808 }
3809
3810 return getTemplateLocation(template.slug);
3811 });
3812 /**
3813 * Returns the current opened/closed state of the navigation panel.
3814 *
3815 * @param {Object} state Global application state.
3816 *
3817 * @return {boolean} True if the navigation panel should be open; false if closed.
3818 */
3819
3820 function isNavigationOpened(state) {
3821 return state.navigationPanel.isOpen;
3822 }
3823 /**
3824 * Returns the current opened/closed state of the inserter panel.
3825 *
3826 * @param {Object} state Global application state.
3827 *
3828 * @return {boolean} True if the inserter panel should be open; false if closed.
3829 */
3830
3831 function isInserterOpened(state) {
3832 return !!state.blockInserterPanel;
3833 }
3834 /**
3835 * Get the insertion point for the inserter.
3836 *
3837 * @param {Object} state Global application state.
3838 *
3839 * @return {Object} The root client ID, index to insert at and starting filter value.
3840 */
3841
3842 function __experimentalGetInsertionPoint(state) {
3843 const {
3844 rootClientId,
3845 insertionIndex,
3846 filterValue
3847 } = state.blockInserterPanel;
3848 return {
3849 rootClientId,
3850 insertionIndex,
3851 filterValue
3852 };
3853 }
3854 /**
3855 * Returns the current opened/closed state of the list view panel.
3856 *
3857 * @param {Object} state Global application state.
3858 *
3859 * @return {boolean} True if the list view panel should be open; false if closed.
3860 */
3861
3862 function isListViewOpened(state) {
3863 return state.listViewPanel;
3864 }
3865 /**
3866 * Returns the template parts and their blocks for the current edited template.
3867 *
3868 * @param {Object} state Global application state.
3869 * @return {Array} Template parts and their blocks in an array.
3870 */
3871
3872 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3873 var _template$blocks;
3874
3875 const templateType = getEditedPostType(state);
3876 const templateId = getEditedPostId(state);
3877 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', templateType, templateId);
3878 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template_part', {
3879 per_page: -1
3880 });
3881 const templatePartsById = (0,external_lodash_namespaceObject.keyBy)(templateParts, templatePart => templatePart.id);
3882 return ((_template$blocks = template.blocks) !== null && _template$blocks !== void 0 ? _template$blocks : []).filter(block => (0,external_wp_blocks_namespaceObject.isTemplatePart)(block)).map(block => {
3883 const {
3884 attributes: {
3885 theme,
3886 slug
3887 }
3888 } = block;
3889 const templatePartId = `${theme}//${slug}`;
3890 const templatePart = templatePartsById[templatePartId];
3891 return {
3892 templatePart,
3893 block
3894 };
3895 }).filter(_ref3 => {
3896 let {
3897 templatePart
3898 } = _ref3;
3899 return !!templatePart;
3900 });
3901 });
3902 /**
3903 * Returns the current editing mode.
3904 *
3905 * @param {Object} state Global application state.
3906 *
3907 * @return {string} Editing mode.
3908 */
3909
3910 function getEditorMode(state) {
3911 return __unstableGetPreference(state, 'editorMode');
3912 }
3913
3914 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/index.js
3915 /**
3916 * WordPress dependencies
3917 */
3918
3919 /**
3920 * Internal dependencies
3921 */
3922
3923
3924
3925
3926
3927 const storeConfig = {
3928 reducer: store_reducer,
3929 actions: store_actions_namespaceObject,
3930 selectors: store_selectors_namespaceObject
3931 };
3932 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, storeConfig);
3933 (0,external_wp_data_namespaceObject.register)(store_store);
3934
3935 ;// CONCATENATED MODULE: ./node_modules/history/index.js
3936 var r,B=r||(r={});B.Pop="POP";B.Push="PUSH";B.Replace="REPLACE";var C= false?0:function(b){return b};function D(b,h){if(!b){"undefined"!==typeof console&&console.warn(h);try{throw Error(h);}catch(k){}}}function E(b){b.preventDefault();b.returnValue=""}
3937 function F(){var b=[];return{get length(){return b.length},push:function(h){b.push(h);return function(){b=b.filter(function(k){return k!==h})}},call:function(h){b.forEach(function(k){return k&&k(h)})}}}function H(){return Math.random().toString(36).substr(2,8)}function I(b){var h=b.pathname,k=b.search;b=b.hash;return(void 0===h?"/":h)+(void 0===k?"":k)+(void 0===b?"":b)}
3938 function J(b){var h={};if(b){var k=b.indexOf("#");0<=k&&(h.hash=b.substr(k),b=b.substr(0,k));k=b.indexOf("?");0<=k&&(h.search=b.substr(k),b=b.substr(0,k));b&&(h.pathname=b)}return h}
3939 function createBrowserHistory(b){function h(){var c=p.location,a=m.state||{};return[a.idx,C({pathname:c.pathname,search:c.search,hash:c.hash,state:a.usr||null,key:a.key||"default"})]}function k(c){return"string"===typeof c?c:I(c)}function x(c,a){void 0===a&&(a=null);return C(extends_extends({pathname:q.pathname,hash:"",search:""},"string"===typeof c?J(c):c,{state:a,key:H()}))}function z(c){t=c;c=h();v=c[0];q=c[1];d.call({action:t,location:q})}function A(c,a){function e(){A(c,a)}var l=r.Push,g=x(c,
3940 a);if(!f.length||(f.call({action:l,location:g,retry:e}),!1)){var n=[{usr:g.state,key:g.key,idx:v+1},k(g)];g=n[0];n=n[1];try{m.pushState(g,"",n)}catch(G){p.location.assign(n)}z(l)}}function y(c,a){function e(){y(c,a)}var l=r.Replace,g=x(c,a);f.length&&(f.call({action:l,location:g,retry:e}),1)||(g=[{usr:g.state,key:g.key,idx:v},k(g)],m.replaceState(g[0],"",g[1]),z(l))}function w(c){m.go(c)}void 0===b&&(b={});b=b.window;var p=void 0===b?document.defaultView:b,m=p.history,u=null;p.addEventListener("popstate",
3941 function(){if(u)f.call(u),u=null;else{var c=r.Pop,a=h(),e=a[0];a=a[1];if(f.length)if(null!=e){var l=v-e;l&&(u={action:c,location:a,retry:function(){w(-1*l)}},w(l))}else false?0:
3942 void 0;else z(c)}});var t=r.Pop;b=h();var v=b[0],q=b[1],d=F(),f=F();null==v&&(v=0,m.replaceState(extends_extends({},m.state,{idx:v}),""));return{get action(){return t},get location(){return q},createHref:k,push:A,replace:y,go:w,back:function(){w(-1)},forward:function(){w(1)},listen:function(c){return d.push(c)},block:function(c){var a=f.push(c);1===f.length&&p.addEventListener("beforeunload",E);return function(){a();f.length||p.removeEventListener("beforeunload",E)}}}};
3943 function createHashHistory(b){function h(){var a=J(m.location.hash.substr(1)),e=a.pathname,l=a.search;a=a.hash;var g=u.state||{};return[g.idx,C({pathname:void 0===e?"/":e,search:void 0===l?"":l,hash:void 0===a?"":a,state:g.usr||null,key:g.key||"default"})]}function k(){if(t)c.call(t),t=null;else{var a=r.Pop,e=h(),l=e[0];e=e[1];if(c.length)if(null!=l){var g=q-l;g&&(t={action:a,location:e,retry:function(){p(-1*g)}},p(g))}else false?0:
3944 void 0;else A(a)}}function x(a){var e=document.querySelector("base"),l="";e&&e.getAttribute("href")&&(e=m.location.href,l=e.indexOf("#"),l=-1===l?e:e.slice(0,l));return l+"#"+("string"===typeof a?a:I(a))}function z(a,e){void 0===e&&(e=null);return C(_extends({pathname:d.pathname,hash:"",search:""},"string"===typeof a?J(a):a,{state:e,key:H()}))}function A(a){v=a;a=h();q=a[0];d=a[1];f.call({action:v,location:d})}function y(a,e){function l(){y(a,e)}var g=r.Push,n=z(a,e); false?
3945 0:void 0;if(!c.length||(c.call({action:g,location:n,retry:l}),!1)){var G=[{usr:n.state,key:n.key,idx:q+1},x(n)];n=G[0];G=G[1];try{u.pushState(n,"",G)}catch(K){m.location.assign(G)}A(g)}}function w(a,e){function l(){w(a,e)}var g=r.Replace,n=z(a,e); false?0:void 0;c.length&&(c.call({action:g,location:n,retry:l}),1)||(n=[{usr:n.state,key:n.key,idx:q},x(n)],u.replaceState(n[0],"",n[1]),A(g))}function p(a){u.go(a)}void 0===b&&(b={});b=b.window;var m=void 0===b?document.defaultView:b,u=m.history,t=null;m.addEventListener("popstate",k);m.addEventListener("hashchange",function(){var a=h()[1];I(a)!==I(d)&&k()});var v=r.Pop;b=h();var q=b[0],d=b[1],f=F(),c=F();null==q&&(q=0,u.replaceState(_extends({},u.state,{idx:q}),""));return{get action(){return v},get location(){return d},
3946 createHref:x,push:y,replace:w,go:p,back:function(){p(-1)},forward:function(){p(1)},listen:function(a){return f.push(a)},block:function(a){var e=c.push(a);1===c.length&&m.addEventListener("beforeunload",E);return function(){e();c.length||m.removeEventListener("beforeunload",E)}}}};
3947 function createMemoryHistory(b){function h(d,f){void 0===f&&(f=null);return C(_extends({pathname:t.pathname,search:"",hash:""},"string"===typeof d?J(d):d,{state:f,key:H()}))}function k(d,f,c){return!q.length||(q.call({action:d,location:f,retry:c}),!1)}function x(d,f){u=d;t=f;v.call({action:u,location:t})}function z(d,f){var c=r.Push,a=h(d,f); false?0:
3948 void 0;k(c,a,function(){z(d,f)})&&(m+=1,p.splice(m,p.length,a),x(c,a))}function A(d,f){var c=r.Replace,a=h(d,f); false?0:void 0;k(c,a,function(){A(d,f)})&&(p[m]=a,x(c,a))}function y(d){var f=Math.min(Math.max(m+d,0),p.length-1),c=r.Pop,a=p[f];k(c,a,function(){y(d)})&&(m=f,x(c,a))}void 0===b&&(b={});var w=b;b=w.initialEntries;w=w.initialIndex;var p=(void 0===
3949 b?["/"]:b).map(function(d){var f=C(_extends({pathname:"/",search:"",hash:"",state:null,key:H()},"string"===typeof d?J(d):d)); false?0:void 0;return f}),m=Math.min(Math.max(null==w?p.length-1:w,0),p.length-1),u=r.Pop,t=p[m],v=F(),q=F();return{get index(){return m},get action(){return u},get location(){return t},createHref:function(d){return"string"===
3950 typeof d?d:I(d)},push:z,replace:A,go:y,back:function(){y(-1)},forward:function(){y(1)},listen:function(d){return v.push(d)},block:function(d){return q.push(d)}}};
3951
3952 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/history.js
3953 /**
3954 * External dependencies
3955 */
3956
3957 /**
3958 * WordPress dependencies
3959 */
3960
3961
3962 const history_history = createBrowserHistory();
3963 const originalHistoryPush = history_history.push;
3964 const originalHistoryReplace = history_history.replace;
3965
3966 function push(params, state) {
3967 return originalHistoryPush.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
3968 }
3969
3970 function replace(params, state) {
3971 return originalHistoryReplace.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
3972 }
3973
3974 history_history.push = push;
3975 history_history.replace = replace;
3976 /* harmony default export */ const utils_history = (history_history);
3977
3978 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/index.js
3979
3980
3981 /**
3982 * WordPress dependencies
3983 */
3984
3985 /**
3986 * Internal dependencies
3987 */
3988
3989
3990 const RoutesContext = (0,external_wp_element_namespaceObject.createContext)();
3991 const HistoryContext = (0,external_wp_element_namespaceObject.createContext)();
3992 function useLocation() {
3993 return (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
3994 }
3995 function useHistory() {
3996 return (0,external_wp_element_namespaceObject.useContext)(HistoryContext);
3997 }
3998
3999 function getLocationWithParams(location) {
4000 const searchParams = new URLSearchParams(location.search);
4001 return { ...location,
4002 params: Object.fromEntries(searchParams.entries())
4003 };
4004 }
4005
4006 function Routes(_ref) {
4007 let {
4008 children
4009 } = _ref;
4010 const [location, setLocation] = (0,external_wp_element_namespaceObject.useState)(() => getLocationWithParams(utils_history.location));
4011 (0,external_wp_element_namespaceObject.useEffect)(() => {
4012 return utils_history.listen(_ref2 => {
4013 let {
4014 location: updatedLocation
4015 } = _ref2;
4016 setLocation(getLocationWithParams(updatedLocation));
4017 });
4018 }, []);
4019 return (0,external_wp_element_namespaceObject.createElement)(HistoryContext.Provider, {
4020 value: utils_history
4021 }, (0,external_wp_element_namespaceObject.createElement)(RoutesContext.Provider, {
4022 value: location
4023 }, children(location)));
4024 }
4025
4026 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
4027 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
4028 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
4029
4030
4031 /**
4032 * WordPress dependencies
4033 */
4034
4035 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4036 xmlns: "http://www.w3.org/2000/svg",
4037 viewBox: "0 0 24 24"
4038 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4039 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
4040 }));
4041 /* harmony default export */ const library_plus = (plus);
4042
4043 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
4044
4045
4046 /**
4047 * WordPress dependencies
4048 */
4049
4050 const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4051 viewBox: "0 0 24 24",
4052 xmlns: "http://www.w3.org/2000/svg"
4053 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4054 d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
4055 }));
4056 /* harmony default export */ const list_view = (listView);
4057
4058 ;// CONCATENATED MODULE: external ["wp","keycodes"]
4059 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
4060 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
4061
4062
4063 /**
4064 * WordPress dependencies
4065 */
4066
4067 const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4068 xmlns: "http://www.w3.org/2000/svg",
4069 viewBox: "0 0 24 24"
4070 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4071 d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
4072 }));
4073 /* harmony default export */ const library_external = (external);
4074
4075 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js
4076 /**
4077 * WordPress dependencies
4078 */
4079
4080 const textFormattingShortcuts = [{
4081 keyCombination: {
4082 modifier: 'primary',
4083 character: 'b'
4084 },
4085 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
4086 }, {
4087 keyCombination: {
4088 modifier: 'primary',
4089 character: 'i'
4090 },
4091 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
4092 }, {
4093 keyCombination: {
4094 modifier: 'primary',
4095 character: 'k'
4096 },
4097 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
4098 }, {
4099 keyCombination: {
4100 modifier: 'primaryShift',
4101 character: 'k'
4102 },
4103 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
4104 }, {
4105 keyCombination: {
4106 modifier: 'primary',
4107 character: 'u'
4108 },
4109 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
4110 }];
4111
4112 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js
4113
4114
4115 /**
4116 * External dependencies
4117 */
4118
4119 /**
4120 * WordPress dependencies
4121 */
4122
4123
4124
4125
4126 function KeyCombination(_ref) {
4127 let {
4128 keyCombination,
4129 forceAriaLabel
4130 } = _ref;
4131 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4132 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4133 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4134 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination",
4135 "aria-label": forceAriaLabel || ariaLabel
4136 }, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => {
4137 if (character === '+') {
4138 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
4139 key: index
4140 }, character);
4141 }
4142
4143 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4144 key: index,
4145 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key"
4146 }, character);
4147 }));
4148 }
4149
4150 function Shortcut(_ref2) {
4151 let {
4152 description,
4153 keyCombination,
4154 aliases = [],
4155 ariaLabel
4156 } = _ref2;
4157 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4158 className: "edit-site-keyboard-shortcut-help-modal__shortcut-description"
4159 }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
4160 className: "edit-site-keyboard-shortcut-help-modal__shortcut-term"
4161 }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4162 keyCombination: keyCombination,
4163 forceAriaLabel: ariaLabel
4164 }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4165 keyCombination: alias,
4166 forceAriaLabel: ariaLabel,
4167 key: index
4168 }))));
4169 }
4170
4171 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
4172
4173
4174 /**
4175 * WordPress dependencies
4176 */
4177
4178
4179 /**
4180 * Internal dependencies
4181 */
4182
4183
4184 function DynamicShortcut(_ref) {
4185 let {
4186 name
4187 } = _ref;
4188 const {
4189 keyCombination,
4190 description,
4191 aliases
4192 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4193 const {
4194 getShortcutKeyCombination,
4195 getShortcutDescription,
4196 getShortcutAliases
4197 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
4198 return {
4199 keyCombination: getShortcutKeyCombination(name),
4200 aliases: getShortcutAliases(name),
4201 description: getShortcutDescription(name)
4202 };
4203 }, [name]);
4204
4205 if (!keyCombination) {
4206 return null;
4207 }
4208
4209 return (0,external_wp_element_namespaceObject.createElement)(Shortcut, {
4210 keyCombination: keyCombination,
4211 description: description,
4212 aliases: aliases
4213 });
4214 }
4215
4216 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js
4217
4218
4219 /**
4220 * External dependencies
4221 */
4222
4223
4224 /**
4225 * WordPress dependencies
4226 */
4227
4228
4229
4230
4231
4232 /**
4233 * Internal dependencies
4234 */
4235
4236
4237
4238
4239
4240 const ShortcutList = _ref => {
4241 let {
4242 shortcuts
4243 } = _ref;
4244 return (
4245 /*
4246 * Disable reason: The `list` ARIA role is redundant but
4247 * Safari+VoiceOver won't announce the list otherwise.
4248 */
4249
4250 /* eslint-disable jsx-a11y/no-redundant-roles */
4251 (0,external_wp_element_namespaceObject.createElement)("ul", {
4252 className: "edit-site-keyboard-shortcut-help-modal__shortcut-list",
4253 role: "list"
4254 }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
4255 className: "edit-site-keyboard-shortcut-help-modal__shortcut",
4256 key: index
4257 }, (0,external_lodash_namespaceObject.isString)(shortcut) ? (0,external_wp_element_namespaceObject.createElement)(DynamicShortcut, {
4258 name: shortcut
4259 }) : (0,external_wp_element_namespaceObject.createElement)(Shortcut, shortcut))))
4260 /* eslint-enable jsx-a11y/no-redundant-roles */
4261
4262 );
4263 };
4264
4265 const ShortcutSection = _ref2 => {
4266 let {
4267 title,
4268 shortcuts,
4269 className
4270 } = _ref2;
4271 return (0,external_wp_element_namespaceObject.createElement)("section", {
4272 className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className)
4273 }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
4274 className: "edit-site-keyboard-shortcut-help-modal__section-title"
4275 }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
4276 shortcuts: shortcuts
4277 }));
4278 };
4279
4280 const ShortcutCategorySection = _ref3 => {
4281 let {
4282 title,
4283 categoryName,
4284 additionalShortcuts = []
4285 } = _ref3;
4286 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
4287 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
4288 }, [categoryName]);
4289 return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4290 title: title,
4291 shortcuts: categoryShortcuts.concat(additionalShortcuts)
4292 });
4293 };
4294
4295 function KeyboardShortcutHelpModal(_ref4) {
4296 let {
4297 isModalActive,
4298 toggleModal
4299 } = _ref4;
4300
4301 if (!isModalActive) {
4302 return null;
4303 }
4304
4305 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4306 className: "edit-site-keyboard-shortcut-help-modal",
4307 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
4308 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
4309 onRequestClose: toggleModal
4310 }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4311 className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts",
4312 shortcuts: ['core/edit-site/keyboard-shortcuts']
4313 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4314 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
4315 categoryName: "global"
4316 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4317 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
4318 categoryName: "selection"
4319 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4320 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
4321 categoryName: "block",
4322 additionalShortcuts: [{
4323 keyCombination: {
4324 character: '/'
4325 },
4326 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
4327
4328 /* translators: The forward-slash character. e.g. '/'. */
4329 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
4330 }]
4331 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4332 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
4333 shortcuts: textFormattingShortcuts
4334 }));
4335 }
4336
4337 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/enable-feature.js
4338
4339
4340
4341 /**
4342 * WordPress dependencies
4343 */
4344
4345
4346
4347 function EnableFeature(props) {
4348 const {
4349 featureName,
4350 ...remainingProps
4351 } = props;
4352 const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName), [featureName]);
4353 const {
4354 toggle
4355 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4356
4357 const onChange = () => toggle('core/edit-site', featureName);
4358
4359 return (0,external_wp_element_namespaceObject.createElement)(preferences_modal_base_option, extends_extends({
4360 onChange: onChange,
4361 isChecked: isChecked
4362 }, remainingProps));
4363 }
4364
4365 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/index.js
4366
4367
4368 /**
4369 * WordPress dependencies
4370 */
4371
4372
4373
4374 /**
4375 * Internal dependencies
4376 */
4377
4378
4379 function EditSitePreferencesModal(_ref) {
4380 let {
4381 isModalActive,
4382 toggleModal
4383 } = _ref;
4384 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
4385 name: 'general',
4386 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
4387 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4388 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
4389 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the block editor interface and editing flow.')
4390 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4391 featureName: "focusMode",
4392 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
4393 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
4394 }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4395 featureName: "showIconLabels",
4396 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
4397 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons.')
4398 }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4399 featureName: "showListViewByDefault",
4400 help: (0,external_wp_i18n_namespaceObject.__)('Opens the block list view sidebar by default.'),
4401 label: (0,external_wp_i18n_namespaceObject.__)('Always open list view')
4402 }))
4403 }, {
4404 name: 'blocks',
4405 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
4406 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4407 title: (0,external_wp_i18n_namespaceObject.__)('Block interactions'),
4408 description: (0,external_wp_i18n_namespaceObject.__)('Customize how you interact with blocks in the block library and editing canvas.')
4409 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4410 featureName: "keepCaretInsideBlock",
4411 help: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
4412 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
4413 }))
4414 }]);
4415
4416 if (!isModalActive) {
4417 return null;
4418 }
4419
4420 return (0,external_wp_element_namespaceObject.createElement)(PreferencesModal, {
4421 closeModal: toggleModal
4422 }, (0,external_wp_element_namespaceObject.createElement)(PreferencesModalTabs, {
4423 sections: sections
4424 }));
4425 }
4426
4427 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/tools-more-menu-group/index.js
4428
4429
4430 /**
4431 * External dependencies
4432 */
4433
4434 /**
4435 * WordPress dependencies
4436 */
4437
4438
4439 const {
4440 Fill: ToolsMoreMenuGroup,
4441 Slot
4442 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup');
4443
4444 ToolsMoreMenuGroup.Slot = _ref => {
4445 let {
4446 fillProps
4447 } = _ref;
4448 return (0,external_wp_element_namespaceObject.createElement)(Slot, {
4449 fillProps: fillProps
4450 }, fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && fills);
4451 };
4452
4453 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
4454
4455 // EXTERNAL MODULE: ./node_modules/downloadjs/download.js
4456 var download = __webpack_require__(8981);
4457 var download_default = /*#__PURE__*/__webpack_require__.n(download);
4458 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/download.js
4459
4460
4461 /**
4462 * WordPress dependencies
4463 */
4464
4465 const download_download = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4466 xmlns: "http://www.w3.org/2000/svg",
4467 viewBox: "0 0 24 24"
4468 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4469 d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"
4470 }));
4471 /* harmony default export */ const library_download = (download_download);
4472
4473 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/site-export.js
4474
4475
4476 /**
4477 * External dependencies
4478 */
4479
4480 /**
4481 * WordPress dependencies
4482 */
4483
4484
4485
4486
4487
4488
4489
4490 function SiteExport() {
4491 const {
4492 createErrorNotice
4493 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4494
4495 async function handleExport() {
4496 try {
4497 const response = await external_wp_apiFetch_default()({
4498 path: '/wp-block-editor/v1/export',
4499 parse: false
4500 });
4501 const blob = await response.blob();
4502 const contentDisposition = response.headers.get('content-disposition');
4503 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
4504 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export';
4505 download_default()(blob, fileName + '.zip', 'application/zip');
4506 } catch (errorResponse) {
4507 let error = {};
4508
4509 try {
4510 error = await errorResponse.json();
4511 } catch (e) {}
4512
4513 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.');
4514 createErrorNotice(errorMessage, {
4515 type: 'snackbar'
4516 });
4517 }
4518 }
4519
4520 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4521 role: "menuitem",
4522 icon: library_download,
4523 onClick: handleExport,
4524 info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.')
4525 }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item'));
4526 }
4527
4528 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/welcome-guide-menu-item.js
4529
4530
4531 /**
4532 * WordPress dependencies
4533 */
4534
4535
4536
4537
4538 function WelcomeGuideMenuItem() {
4539 const {
4540 toggle
4541 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4542 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4543 onClick: () => toggle('core/edit-site', 'welcomeGuide')
4544 }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'));
4545 }
4546
4547 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/copy-content-menu-item.js
4548
4549
4550 /**
4551 * WordPress dependencies
4552 */
4553
4554
4555
4556
4557
4558
4559
4560 /**
4561 * Internal dependencies
4562 */
4563
4564
4565 function CopyContentMenuItem() {
4566 const {
4567 createNotice
4568 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4569 const getText = (0,external_wp_data_namespaceObject.useSelect)(select => {
4570 return () => {
4571 const {
4572 getEditedPostId,
4573 getEditedPostType
4574 } = select(store_store);
4575 const {
4576 getEditedEntityRecord
4577 } = select(external_wp_coreData_namespaceObject.store);
4578 const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId());
4579
4580 if (record) {
4581 if (typeof record.content === 'function') {
4582 return record.content(record);
4583 } else if (record.blocks) {
4584 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
4585 } else if (record.content) {
4586 return record.content;
4587 }
4588 }
4589
4590 return '';
4591 };
4592 }, []);
4593
4594 function onSuccess() {
4595 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
4596 isDismissible: true,
4597 type: 'snackbar'
4598 });
4599 }
4600
4601 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
4602 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4603 ref: ref
4604 }, (0,external_wp_i18n_namespaceObject.__)('Copy all blocks'));
4605 }
4606
4607 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/mode-switcher/index.js
4608
4609
4610 /**
4611 * WordPress dependencies
4612 */
4613
4614
4615
4616
4617 /**
4618 * Internal dependencies
4619 */
4620
4621 /**
4622 * Internal dependencies
4623 */
4624
4625
4626 /**
4627 * Set of available mode options.
4628 *
4629 * @type {Array}
4630 */
4631
4632 const MODES = [{
4633 value: 'visual',
4634 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
4635 }, {
4636 value: 'text',
4637 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
4638 }];
4639
4640 function ModeSwitcher() {
4641 const {
4642 shortcut,
4643 mode
4644 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
4645 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'),
4646 isRichEditingEnabled: select(store_store).getSettings().richEditingEnabled,
4647 isCodeEditingEnabled: select(store_store).getSettings().codeEditingEnabled,
4648 mode: select(store_store).getEditorMode()
4649 }), []);
4650 const {
4651 switchEditorMode
4652 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4653 const choices = MODES.map(choice => {
4654 if (choice.value !== mode) {
4655 return { ...choice,
4656 shortcut
4657 };
4658 }
4659
4660 return choice;
4661 });
4662 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4663 label: (0,external_wp_i18n_namespaceObject.__)('Editor')
4664 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
4665 choices: choices,
4666 value: mode,
4667 onSelect: switchEditorMode
4668 }));
4669 }
4670
4671 /* harmony default export */ const mode_switcher = (ModeSwitcher);
4672
4673 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/index.js
4674
4675
4676 /**
4677 * WordPress dependencies
4678 */
4679
4680
4681
4682
4683
4684
4685
4686
4687 /**
4688 * Internal dependencies
4689 */
4690
4691
4692
4693
4694
4695
4696
4697
4698 function MoreMenu() {
4699 const [isModalActive, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4700 const [isPreferencesModalActive, togglePreferencesModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4701 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal);
4702 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, _ref => {
4703 let {
4704 onClose
4705 } = _ref;
4706 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4707 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
4708 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4709 scope: "core/edit-site",
4710 name: "fixedToolbar",
4711 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
4712 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
4713 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
4714 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
4715 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4716 scope: "core/edit-site",
4717 name: "focusMode",
4718 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
4719 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
4720 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
4721 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
4722 }), (0,external_wp_element_namespaceObject.createElement)(mode_switcher, null), (0,external_wp_element_namespaceObject.createElement)(action_item.Slot, {
4723 name: "core/edit-site/plugin-more-menu",
4724 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
4725 as: external_wp_components_namespaceObject.MenuGroup,
4726 fillProps: {
4727 onClick: onClose
4728 }
4729 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4730 label: (0,external_wp_i18n_namespaceObject.__)('Tools')
4731 }, (0,external_wp_element_namespaceObject.createElement)(SiteExport, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4732 onClick: toggleModal,
4733 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
4734 }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(CopyContentMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4735 icon: library_external,
4736 role: "menuitem",
4737 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/site-editor/'),
4738 target: "_blank",
4739 rel: "noopener noreferrer"
4740 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4741 as: "span"
4742 },
4743 /* translators: accessibility text */
4744 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
4745 fillProps: {
4746 onClose
4747 }
4748 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4749 onClick: togglePreferencesModal
4750 }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))));
4751 }), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, {
4752 isModalActive: isModalActive,
4753 toggleModal: toggleModal
4754 }), (0,external_wp_element_namespaceObject.createElement)(EditSitePreferencesModal, {
4755 isModalActive: isPreferencesModalActive,
4756 toggleModal: togglePreferencesModal
4757 }));
4758 }
4759
4760 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/save-button/index.js
4761
4762
4763 /**
4764 * External dependencies
4765 */
4766
4767 /**
4768 * WordPress dependencies
4769 */
4770
4771
4772
4773
4774
4775 function SaveButton(_ref) {
4776 let {
4777 openEntitiesSavedStates,
4778 isEntitiesSavedStatesOpen
4779 } = _ref;
4780 const {
4781 isDirty,
4782 isSaving
4783 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4784 const {
4785 __experimentalGetDirtyEntityRecords,
4786 isSavingEntityRecord
4787 } = select(external_wp_coreData_namespaceObject.store);
4788
4789 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4790
4791 return {
4792 isDirty: dirtyEntityRecords.length > 0,
4793 isSaving: (0,external_lodash_namespaceObject.some)(dirtyEntityRecords, record => isSavingEntityRecord(record.kind, record.name, record.key))
4794 };
4795 }, []);
4796 const disabled = !isDirty || isSaving;
4797 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4798 variant: "primary",
4799 className: "edit-site-save-button__button",
4800 "aria-disabled": disabled,
4801 "aria-expanded": isEntitiesSavedStatesOpen,
4802 disabled: disabled,
4803 isBusy: isSaving,
4804 onClick: disabled ? undefined : openEntitiesSavedStates
4805 }, (0,external_wp_i18n_namespaceObject.__)('Save')));
4806 }
4807
4808 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
4809
4810
4811 /**
4812 * WordPress dependencies
4813 */
4814
4815 const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4816 xmlns: "http://www.w3.org/2000/svg",
4817 viewBox: "0 0 24 24"
4818 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4819 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"
4820 }));
4821 /* harmony default export */ const library_undo = (undo);
4822
4823 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
4824
4825
4826 /**
4827 * WordPress dependencies
4828 */
4829
4830 const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4831 xmlns: "http://www.w3.org/2000/svg",
4832 viewBox: "0 0 24 24"
4833 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4834 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"
4835 }));
4836 /* harmony default export */ const library_redo = (redo);
4837
4838 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/undo-redo/undo.js
4839
4840
4841 /**
4842 * WordPress dependencies
4843 */
4844
4845
4846
4847
4848
4849
4850 function UndoButton() {
4851 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
4852 const {
4853 undo
4854 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4855 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4856 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
4857 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4858 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
4859 // button, because it will remove focus for keyboard users.
4860 // See: https://github.com/WordPress/gutenberg/issues/3486
4861 ,
4862 "aria-disabled": !hasUndo,
4863 onClick: hasUndo ? undo : undefined
4864 });
4865 }
4866
4867 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/undo-redo/redo.js
4868
4869
4870 /**
4871 * WordPress dependencies
4872 */
4873
4874
4875
4876
4877
4878
4879 function RedoButton() {
4880 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
4881 const {
4882 redo
4883 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4884 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4885 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
4886 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
4887 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this
4888 // button, because it will remove focus for keyboard users.
4889 // See: https://github.com/WordPress/gutenberg/issues/3486
4890 ,
4891 "aria-disabled": !hasRedo,
4892 onClick: hasRedo ? redo : undefined
4893 });
4894 }
4895
4896 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
4897
4898
4899 /**
4900 * WordPress dependencies
4901 */
4902
4903 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4904 viewBox: "0 0 24 24",
4905 xmlns: "http://www.w3.org/2000/svg"
4906 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4907 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
4908 }));
4909 /* harmony default export */ const chevron_down = (chevronDown);
4910
4911 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/document-actions/index.js
4912
4913
4914 /**
4915 * External dependencies
4916 */
4917
4918 /**
4919 * WordPress dependencies
4920 */
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930 function getBlockDisplayText(block) {
4931 if (block) {
4932 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
4933 return blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, block.attributes) : null;
4934 }
4935
4936 return null;
4937 }
4938
4939 function useSecondaryText() {
4940 const {
4941 getBlock
4942 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
4943 const activeEntityBlockId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).__experimentalGetActiveBlockIdByBlockNames(['core/template-part']), []);
4944
4945 if (activeEntityBlockId) {
4946 return {
4947 label: getBlockDisplayText(getBlock(activeEntityBlockId)),
4948 isActive: true
4949 };
4950 }
4951
4952 return {};
4953 }
4954 /**
4955 * @param {Object} props Props for the DocumentActions component.
4956 * @param {string} props.entityTitle The title to display.
4957 * @param {string} props.entityLabel A label to use for entity-related options.
4958 * E.g. "template" would be used for "edit
4959 * template" and "show template details".
4960 * @param {boolean} props.isLoaded Whether the data is available.
4961 * @param {Function} props.children React component to use for the
4962 * information dropdown area. Should be a
4963 * function which accepts dropdown props.
4964 * @param {boolean} props.showIconLabels Whether buttons display icons or text labels.
4965 */
4966
4967
4968 function DocumentActions(_ref) {
4969 let {
4970 entityTitle,
4971 entityLabel,
4972 isLoaded,
4973 children: dropdownContent,
4974 showIconLabels
4975 } = _ref;
4976 const {
4977 label
4978 } = useSecondaryText(); // The title ref is passed to the popover as the anchorRef so that the
4979 // dropdown is centered over the whole title area rather than just one
4980 // part of it.
4981
4982 const titleRef = (0,external_wp_element_namespaceObject.useRef)(); // Return a simple loading indicator until we have information to show.
4983
4984 if (!isLoaded) {
4985 return (0,external_wp_element_namespaceObject.createElement)("div", {
4986 className: "edit-site-document-actions"
4987 }, (0,external_wp_i18n_namespaceObject.__)('Loading…'));
4988 } // Return feedback that the template does not seem to exist.
4989
4990
4991 if (!entityTitle) {
4992 return (0,external_wp_element_namespaceObject.createElement)("div", {
4993 className: "edit-site-document-actions"
4994 }, (0,external_wp_i18n_namespaceObject.__)('Template not found'));
4995 }
4996
4997 return (0,external_wp_element_namespaceObject.createElement)("div", {
4998 className: classnames_default()('edit-site-document-actions', {
4999 'has-secondary-label': !!label
5000 })
5001 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5002 ref: titleRef,
5003 className: "edit-site-document-actions__title-wrapper"
5004 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5005 size: "body",
5006 className: "edit-site-document-actions__title",
5007 as: "h1"
5008 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
5009 as: "span"
5010 }, (0,external_wp_i18n_namespaceObject.sprintf)(
5011 /* translators: %s: the entity being edited, like "template"*/
5012 (0,external_wp_i18n_namespaceObject.__)('Editing %s: '), entityLabel)), entityTitle), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5013 size: "body",
5014 className: "edit-site-document-actions__secondary-item"
5015 }, label !== null && label !== void 0 ? label : ''), dropdownContent && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
5016 popoverProps: {
5017 anchorRef: titleRef.current
5018 },
5019 position: "bottom center",
5020 renderToggle: _ref2 => {
5021 let {
5022 isOpen,
5023 onToggle
5024 } = _ref2;
5025 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5026 className: "edit-site-document-actions__get-info",
5027 icon: chevron_down,
5028 "aria-expanded": isOpen,
5029 "aria-haspopup": "true",
5030 onClick: onToggle,
5031 label: (0,external_wp_i18n_namespaceObject.sprintf)(
5032 /* translators: %s: the entity to see details about, like "template"*/
5033 (0,external_wp_i18n_namespaceObject.__)('Show %s details'), entityLabel)
5034 }, showIconLabels && (0,external_wp_i18n_namespaceObject.__)('Details'));
5035 },
5036 contentClassName: "edit-site-document-actions__info-dropdown",
5037 renderContent: dropdownContent
5038 })));
5039 }
5040
5041 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/link.js
5042
5043
5044
5045 /**
5046 * WordPress dependencies
5047 */
5048
5049 /**
5050 * Internal dependencies
5051 */
5052
5053
5054 function useLink() {
5055 let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5056 let state = arguments.length > 1 ? arguments[1] : undefined;
5057 let shouldReplace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5058 const history = useHistory();
5059
5060 function onClick(event) {
5061 event.preventDefault();
5062
5063 if (shouldReplace) {
5064 history.replace(params, state);
5065 } else {
5066 history.push(params, state);
5067 }
5068 }
5069
5070 return {
5071 href: (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params),
5072 onClick
5073 };
5074 }
5075 function Link(_ref) {
5076 let {
5077 params = {},
5078 state,
5079 replace: shouldReplace = false,
5080 children,
5081 ...props
5082 } = _ref;
5083 const {
5084 href,
5085 onClick
5086 } = useLink(params, state, shouldReplace);
5087 return (0,external_wp_element_namespaceObject.createElement)("a", extends_extends({
5088 href: href,
5089 onClick: onClick
5090 }, props), children);
5091 }
5092
5093 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/template-areas.js
5094
5095
5096
5097 /**
5098 * WordPress dependencies
5099 */
5100
5101
5102
5103
5104
5105
5106 /**
5107 * Internal dependencies
5108 */
5109
5110
5111
5112
5113
5114
5115 function TemplatePartItemMore(_ref) {
5116 var _templatePart$title;
5117
5118 let {
5119 onClose,
5120 templatePart,
5121 closeTemplateDetailsDropdown
5122 } = _ref;
5123 const {
5124 revertTemplate
5125 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5126 const {
5127 params
5128 } = useLocation();
5129 const editLinkProps = useLink({
5130 postId: templatePart.id,
5131 postType: templatePart.type
5132 }, {
5133 fromTemplateId: params.postId
5134 });
5135
5136 function editTemplatePart(event) {
5137 editLinkProps.onClick(event);
5138 onClose();
5139 closeTemplateDetailsDropdown();
5140 }
5141
5142 function clearCustomizations() {
5143 revertTemplate(templatePart);
5144 onClose();
5145 closeTemplateDetailsDropdown();
5146 }
5147
5148 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, extends_extends({}, editLinkProps, {
5149 onClick: editTemplatePart
5150 }), (0,external_wp_i18n_namespaceObject.sprintf)(
5151 /* translators: %s: template part title */
5152 (0,external_wp_i18n_namespaceObject.__)('Edit %s'), (_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered))), isTemplateRevertable(templatePart) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5153 info: (0,external_wp_i18n_namespaceObject.__)('Restore template to default state'),
5154 onClick: clearCustomizations
5155 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))));
5156 }
5157
5158 function TemplatePartItem(_ref2) {
5159 let {
5160 templatePart,
5161 clientId,
5162 closeTemplateDetailsDropdown
5163 } = _ref2;
5164 const {
5165 selectBlock,
5166 toggleBlockHighlight
5167 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5168 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
5169 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
5170
5171 return defaultAreas.find(defaultArea => defaultArea.area === templatePart.area);
5172 }, [templatePart.area]);
5173
5174 const highlightBlock = () => toggleBlockHighlight(clientId, true);
5175
5176 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
5177
5178 return (0,external_wp_element_namespaceObject.createElement)("div", {
5179 role: "menuitem",
5180 className: "edit-site-template-details__template-areas-item"
5181 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5182 role: "button",
5183 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
5184 iconPosition: "left",
5185 onClick: () => {
5186 selectBlock(clientId);
5187 },
5188 onMouseOver: highlightBlock,
5189 onMouseLeave: cancelHighlightBlock,
5190 onFocus: highlightBlock,
5191 onBlur: cancelHighlightBlock
5192 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
5193 icon: more_vertical,
5194 label: (0,external_wp_i18n_namespaceObject.__)('More options'),
5195 className: "edit-site-template-details__template-areas-item-more"
5196 }, _ref3 => {
5197 let {
5198 onClose
5199 } = _ref3;
5200 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItemMore, {
5201 onClose: onClose,
5202 templatePart: templatePart,
5203 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5204 });
5205 }));
5206 }
5207
5208 function TemplateAreas(_ref4) {
5209 let {
5210 closeTemplateDetailsDropdown
5211 } = _ref4;
5212 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
5213
5214 if (!templateParts.length) {
5215 return null;
5216 }
5217
5218 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5219 label: (0,external_wp_i18n_namespaceObject.__)('Areas'),
5220 className: "edit-site-template-details__group edit-site-template-details__template-areas"
5221 }, templateParts.map(_ref5 => {
5222 let {
5223 templatePart,
5224 block
5225 } = _ref5;
5226 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItem, {
5227 key: templatePart.slug,
5228 clientId: block.clientId,
5229 templatePart: templatePart,
5230 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5231 });
5232 }));
5233 }
5234
5235 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/edit-template-title.js
5236
5237
5238 /**
5239 * WordPress dependencies
5240 */
5241
5242
5243
5244 function EditTemplateTitle(_ref) {
5245 let {
5246 template
5247 } = _ref;
5248 const [title, setTitle] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', template.type, 'title', template.id);
5249 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
5250 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
5251 value: title,
5252 help: (0,external_wp_i18n_namespaceObject.__)('Give the template a title that indicates its purpose, e.g. "Full Width".'),
5253 onChange: newTitle => {
5254 setTitle(newTitle || template.slug);
5255 }
5256 });
5257 }
5258
5259 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/index.js
5260
5261
5262
5263 /**
5264 * WordPress dependencies
5265 */
5266
5267
5268
5269
5270
5271 /**
5272 * Internal dependencies
5273 */
5274
5275
5276
5277
5278
5279
5280
5281 function TemplateDetails(_ref) {
5282 let {
5283 template,
5284 onClose
5285 } = _ref;
5286 const {
5287 title,
5288 description
5289 } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetTemplateInfo(template), []);
5290 const {
5291 revertTemplate
5292 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5293 const templateSubMenu = (0,external_wp_element_namespaceObject.useMemo)(() => {
5294 if ((template === null || template === void 0 ? void 0 : template.type) === 'wp_template') {
5295 return {
5296 title: (0,external_wp_i18n_namespaceObject.__)('templates'),
5297 menu: MENU_TEMPLATES
5298 };
5299 }
5300
5301 return TEMPLATE_PARTS_SUB_MENUS.find(_ref2 => {
5302 let {
5303 area
5304 } = _ref2;
5305 return area === (template === null || template === void 0 ? void 0 : template.area);
5306 });
5307 }, [template]);
5308 const browseAllLinkProps = useLink({
5309 // TODO: We should update this to filter by template part's areas as well.
5310 postType: template.type,
5311 postId: undefined
5312 }); // Only user-created and non-default templates can change the name.
5313
5314 const canEditTitle = template.is_custom && !template.has_theme_file;
5315
5316 if (!template) {
5317 return null;
5318 }
5319
5320 const revert = () => {
5321 revertTemplate(template);
5322 onClose();
5323 };
5324
5325 return (0,external_wp_element_namespaceObject.createElement)("div", {
5326 className: "edit-site-template-details"
5327 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5328 className: "edit-site-template-details__group"
5329 }, canEditTitle ? (0,external_wp_element_namespaceObject.createElement)(EditTemplateTitle, {
5330 template: template
5331 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
5332 level: 4,
5333 weight: 600,
5334 className: "edit-site-template-details__title"
5335 }, title), description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5336 size: "body",
5337 className: "edit-site-template-details__description",
5338 as: "p"
5339 }, description)), (0,external_wp_element_namespaceObject.createElement)(TemplateAreas, {
5340 closeTemplateDetailsDropdown: onClose
5341 }), isTemplateRevertable(template) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5342 className: "edit-site-template-details__group edit-site-template-details__revert"
5343 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5344 className: "edit-site-template-details__revert-button",
5345 info: (0,external_wp_i18n_namespaceObject.__)('Restore template to default state'),
5346 onClick: revert
5347 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, extends_extends({
5348 className: "edit-site-template-details__show-all-button"
5349 }, browseAllLinkProps), (0,external_wp_i18n_namespaceObject.sprintf)(
5350 /* translators: the template part's area name ("Headers", "Sidebars") or "templates". */
5351 (0,external_wp_i18n_namespaceObject.__)('Browse all %s'), templateSubMenu.title)));
5352 }
5353
5354 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/index.js
5355
5356
5357 /**
5358 * WordPress dependencies
5359 */
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371 /**
5372 * Internal dependencies
5373 */
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383 const preventDefault = event => {
5384 event.preventDefault();
5385 };
5386
5387 function Header(_ref) {
5388 let {
5389 openEntitiesSavedStates,
5390 isEntitiesSavedStatesOpen,
5391 showIconLabels
5392 } = _ref;
5393 const inserterButton = (0,external_wp_element_namespaceObject.useRef)();
5394 const {
5395 deviceType,
5396 entityTitle,
5397 template,
5398 templateType,
5399 isInserterOpen,
5400 isListViewOpen,
5401 listViewShortcut,
5402 isLoaded,
5403 isVisualMode
5404 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5405 const {
5406 __experimentalGetPreviewDeviceType,
5407 getEditedPostType,
5408 getEditedPostId,
5409 isInserterOpened,
5410 isListViewOpened,
5411 getEditorMode
5412 } = select(store_store);
5413 const {
5414 getEditedEntityRecord
5415 } = select(external_wp_coreData_namespaceObject.store);
5416 const {
5417 __experimentalGetTemplateInfo: getTemplateInfo
5418 } = select(external_wp_editor_namespaceObject.store);
5419 const {
5420 getShortcutRepresentation
5421 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
5422 const postType = getEditedPostType();
5423 const postId = getEditedPostId();
5424 const record = getEditedEntityRecord('postType', postType, postId);
5425
5426 const _isLoaded = !!postId;
5427
5428 return {
5429 deviceType: __experimentalGetPreviewDeviceType(),
5430 entityTitle: getTemplateInfo(record).title,
5431 isLoaded: _isLoaded,
5432 template: record,
5433 templateType: postType,
5434 isInserterOpen: isInserterOpened(),
5435 isListViewOpen: isListViewOpened(),
5436 listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'),
5437 isVisualMode: getEditorMode() === 'visual'
5438 };
5439 }, []);
5440 const {
5441 __experimentalSetPreviewDeviceType: setPreviewDeviceType,
5442 setIsInserterOpened,
5443 setIsListViewOpened
5444 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5445 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
5446 const openInserter = (0,external_wp_element_namespaceObject.useCallback)(() => {
5447 if (isInserterOpen) {
5448 // Focusing the inserter button closes the inserter popover.
5449 inserterButton.current.focus();
5450 } else {
5451 setIsInserterOpened(true);
5452 }
5453 }, [isInserterOpen, setIsInserterOpened]);
5454 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
5455 const isFocusMode = templateType === 'wp_template_part';
5456 return (0,external_wp_element_namespaceObject.createElement)("div", {
5457 className: "edit-site-header"
5458 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5459 className: "edit-site-header_start"
5460 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5461 className: "edit-site-header__toolbar"
5462 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5463 ref: inserterButton,
5464 variant: "primary",
5465 isPressed: isInserterOpen,
5466 className: "edit-site-header-toolbar__inserter-toggle",
5467 disabled: !isVisualMode,
5468 onMouseDown: preventDefault,
5469 onClick: openInserter,
5470 icon: library_plus,
5471 label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button')
5472 }, showIconLabels && (!isInserterOpen ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close'))), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5473 as: external_wp_blockEditor_namespaceObject.ToolSelector,
5474 disabled: !isVisualMode
5475 }), (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5476 className: "edit-site-header-toolbar__list-view-toggle",
5477 disabled: !isVisualMode,
5478 icon: list_view,
5479 isPressed: isListViewOpen
5480 /* translators: button label text should, if possible, be under 16 characters. */
5481 ,
5482 label: (0,external_wp_i18n_namespaceObject.__)('List View'),
5483 onClick: toggleListView,
5484 shortcut: listViewShortcut
5485 })))), (0,external_wp_element_namespaceObject.createElement)("div", {
5486 className: "edit-site-header_center"
5487 }, (0,external_wp_element_namespaceObject.createElement)(DocumentActions, {
5488 entityTitle: entityTitle,
5489 entityLabel: templateType === 'wp_template_part' ? 'template part' : 'template',
5490 isLoaded: isLoaded,
5491 showIconLabels: showIconLabels
5492 }, _ref2 => {
5493 let {
5494 onClose
5495 } = _ref2;
5496 return (0,external_wp_element_namespaceObject.createElement)(TemplateDetails, {
5497 template: template,
5498 onClose: onClose
5499 });
5500 })), (0,external_wp_element_namespaceObject.createElement)("div", {
5501 className: "edit-site-header_end"
5502 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5503 className: "edit-site-header__actions"
5504 }, !isFocusMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPreviewOptions, {
5505 deviceType: deviceType,
5506 setDeviceType: setPreviewDeviceType
5507 }), (0,external_wp_element_namespaceObject.createElement)(SaveButton, {
5508 openEntitiesSavedStates: openEntitiesSavedStates,
5509 isEntitiesSavedStatesOpen: isEntitiesSavedStatesOpen
5510 }), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
5511 scope: "core/edit-site"
5512 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null))));
5513 }
5514
5515 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js
5516
5517
5518 /**
5519 * WordPress dependencies
5520 */
5521
5522 const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5523 xmlns: "http://www.w3.org/2000/svg",
5524 viewBox: "0 0 24 24"
5525 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5526 fillRule: "evenodd",
5527 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
5528 clipRule: "evenodd"
5529 }));
5530 /* harmony default export */ const library_cog = (cog);
5531
5532 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/default-sidebar.js
5533
5534
5535 /**
5536 * WordPress dependencies
5537 */
5538
5539 function DefaultSidebar(_ref) {
5540 let {
5541 className,
5542 identifier,
5543 title,
5544 icon,
5545 children,
5546 closeLabel,
5547 header,
5548 headerClassName,
5549 panelClassName
5550 } = _ref;
5551 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
5552 className: className,
5553 scope: "core/edit-site",
5554 identifier: identifier,
5555 title: title,
5556 icon: icon,
5557 closeLabel: closeLabel,
5558 header: header,
5559 headerClassName: headerClassName,
5560 panelClassName: panelClassName
5561 }, children), (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
5562 scope: "core/edit-site",
5563 identifier: identifier,
5564 icon: icon
5565 }, title));
5566 }
5567
5568 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/styles.js
5569
5570
5571 /**
5572 * WordPress dependencies
5573 */
5574
5575 const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5576 viewBox: "0 0 24 24",
5577 xmlns: "http://www.w3.org/2000/svg"
5578 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5579 d: "M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"
5580 }));
5581 /* harmony default export */ const library_styles = (styles);
5582
5583 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/icon-with-current-color.js
5584
5585
5586
5587 /**
5588 * External dependencies
5589 */
5590
5591 /**
5592 * WordPress dependencies
5593 */
5594
5595
5596 function IconWithCurrentColor(_ref) {
5597 let {
5598 className,
5599 ...props
5600 } = _ref;
5601 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, extends_extends({
5602 className: classnames_default()(className, 'edit-site-global-styles-icon-with-current-color')
5603 }, props));
5604 }
5605
5606 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/navigation-button.js
5607
5608
5609
5610 /**
5611 * WordPress dependencies
5612 */
5613
5614 /**
5615 * Internal dependencies
5616 */
5617
5618
5619
5620 function GenericNavigationButton(_ref) {
5621 let {
5622 icon,
5623 children,
5624 ...props
5625 } = _ref;
5626 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, props, icon && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
5627 justify: "flex-start"
5628 }, (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
5629 icon: icon,
5630 size: 24
5631 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children);
5632 }
5633
5634 function NavigationButtonAsItem(props) {
5635 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, extends_extends({
5636 as: GenericNavigationButton
5637 }, props));
5638 }
5639
5640 function NavigationBackButtonAsItem(props) {
5641 return createElement(NavigatorBackButton, _extends({
5642 as: GenericNavigationButton
5643 }, props));
5644 }
5645
5646
5647
5648 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/typography.js
5649
5650
5651 /**
5652 * WordPress dependencies
5653 */
5654
5655 const typography = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5656 xmlns: "http://www.w3.org/2000/svg",
5657 viewBox: "0 0 24 24"
5658 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5659 d: "M6.9 7L3 17.8h1.7l1-2.8h4.1l1 2.8h1.7L8.6 7H6.9zm-.7 6.6l1.5-4.3 1.5 4.3h-3zM21.6 17c-.1.1-.2.2-.3.2-.1.1-.2.1-.4.1s-.3-.1-.4-.2c-.1-.1-.1-.3-.1-.6V12c0-.5 0-1-.1-1.4-.1-.4-.3-.7-.5-1-.2-.2-.5-.4-.9-.5-.4 0-.8-.1-1.3-.1s-1 .1-1.4.2c-.4.1-.7.3-1 .4-.2.2-.4.3-.6.5-.1.2-.2.4-.2.7 0 .3.1.5.2.8.2.2.4.3.8.3.3 0 .6-.1.8-.3.2-.2.3-.4.3-.7 0-.3-.1-.5-.2-.7-.2-.2-.4-.3-.6-.4.2-.2.4-.3.7-.4.3-.1.6-.1.8-.1.3 0 .6 0 .8.1.2.1.4.3.5.5.1.2.2.5.2.9v1.1c0 .3-.1.5-.3.6-.2.2-.5.3-.9.4-.3.1-.7.3-1.1.4-.4.1-.8.3-1.1.5-.3.2-.6.4-.8.7-.2.3-.3.7-.3 1.2 0 .6.2 1.1.5 1.4.3.4.9.5 1.6.5.5 0 1-.1 1.4-.3.4-.2.8-.6 1.1-1.1 0 .4.1.7.3 1 .2.3.6.4 1.2.4.4 0 .7-.1.9-.2.2-.1.5-.3.7-.4h-.3zm-3-.9c-.2.4-.5.7-.8.8-.3.2-.6.2-.8.2-.4 0-.6-.1-.9-.3-.2-.2-.3-.6-.3-1.1 0-.5.1-.9.3-1.2s.5-.5.8-.7c.3-.2.7-.3 1-.5.3-.1.6-.3.7-.6v3.4z"
5660 }));
5661 /* harmony default export */ const library_typography = (typography);
5662
5663 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/color.js
5664
5665
5666 /**
5667 * WordPress dependencies
5668 */
5669
5670 const color = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5671 viewBox: "0 0 24 24",
5672 xmlns: "http://www.w3.org/2000/svg"
5673 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5674 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z"
5675 }));
5676 /* harmony default export */ const library_color = (color);
5677
5678 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
5679
5680
5681 /**
5682 * WordPress dependencies
5683 */
5684
5685 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5686 xmlns: "http://www.w3.org/2000/svg",
5687 viewBox: "0 0 24 24"
5688 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5689 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
5690 }));
5691 /* harmony default export */ const library_layout = (layout);
5692
5693 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/utils.js
5694 /**
5695 * External dependencies
5696 */
5697
5698 /* Supporting data. */
5699
5700 const ROOT_BLOCK_NAME = 'root';
5701 const ROOT_BLOCK_SELECTOR = 'body';
5702 const ROOT_BLOCK_SUPPORTS = (/* unused pure expression or super */ null && (['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding']));
5703 const PRESET_METADATA = [{
5704 path: ['color', 'palette'],
5705 valueKey: 'color',
5706 cssVarInfix: 'color',
5707 classes: [{
5708 classSuffix: 'color',
5709 propertyName: 'color'
5710 }, {
5711 classSuffix: 'background-color',
5712 propertyName: 'background-color'
5713 }, {
5714 classSuffix: 'border-color',
5715 propertyName: 'border-color'
5716 }]
5717 }, {
5718 path: ['color', 'gradients'],
5719 valueKey: 'gradient',
5720 cssVarInfix: 'gradient',
5721 classes: [{
5722 classSuffix: 'gradient-background',
5723 propertyName: 'background'
5724 }]
5725 }, {
5726 path: ['color', 'duotone'],
5727 cssVarInfix: 'duotone',
5728 valueFunc: _ref => {
5729 let {
5730 slug
5731 } = _ref;
5732 return `url( '#wp-duotone-${slug}' )`;
5733 },
5734 classes: []
5735 }, {
5736 path: ['typography', 'fontSizes'],
5737 valueKey: 'size',
5738 cssVarInfix: 'font-size',
5739 classes: [{
5740 classSuffix: 'font-size',
5741 propertyName: 'font-size'
5742 }]
5743 }, {
5744 path: ['typography', 'fontFamilies'],
5745 valueKey: 'fontFamily',
5746 cssVarInfix: 'font-family',
5747 classes: [{
5748 classSuffix: 'font-family',
5749 propertyName: 'font-family'
5750 }]
5751 }];
5752 const STYLE_PATH_TO_CSS_VAR_INFIX = {
5753 'color.background': 'color',
5754 'color.text': 'color',
5755 'elements.link.color.text': 'color',
5756 'color.gradient': 'gradient',
5757 'typography.fontSize': 'font-size',
5758 'typography.fontFamily': 'font-family'
5759 };
5760
5761 function findInPresetsBy(features, blockName, presetPath, presetProperty, presetValueValue) {
5762 // Block presets take priority above root level presets.
5763 const orderedPresetsByOrigin = [(0,external_lodash_namespaceObject.get)(features, ['blocks', blockName, ...presetPath]), (0,external_lodash_namespaceObject.get)(features, presetPath)];
5764
5765 for (const presetByOrigin of orderedPresetsByOrigin) {
5766 if (presetByOrigin) {
5767 // Preset origins ordered by priority.
5768 const origins = ['custom', 'theme', 'default'];
5769
5770 for (const origin of origins) {
5771 const presets = presetByOrigin[origin];
5772
5773 if (presets) {
5774 const presetObject = (0,external_lodash_namespaceObject.find)(presets, preset => preset[presetProperty] === presetValueValue);
5775
5776 if (presetObject) {
5777 if (presetProperty === 'slug') {
5778 return presetObject;
5779 } // If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
5780
5781
5782 const highestPresetObjectWithSameSlug = findInPresetsBy(features, blockName, presetPath, 'slug', presetObject.slug);
5783
5784 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
5785 return presetObject;
5786 }
5787
5788 return undefined;
5789 }
5790 }
5791 }
5792 }
5793 }
5794 }
5795
5796 function getPresetVariableFromValue(features, blockName, variableStylePath, presetPropertyValue) {
5797 if (!presetPropertyValue) {
5798 return presetPropertyValue;
5799 }
5800
5801 const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[variableStylePath];
5802 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', cssVarInfix]);
5803
5804 if (!metadata) {
5805 // The property doesn't have preset data
5806 // so the value should be returned as it is.
5807 return presetPropertyValue;
5808 }
5809
5810 const {
5811 valueKey,
5812 path
5813 } = metadata;
5814 const presetObject = findInPresetsBy(features, blockName, path, valueKey, presetPropertyValue);
5815
5816 if (!presetObject) {
5817 // Value wasn't found in the presets,
5818 // so it must be a custom value.
5819 return presetPropertyValue;
5820 }
5821
5822 return `var:preset|${cssVarInfix}|${presetObject.slug}`;
5823 }
5824
5825 function getValueFromPresetVariable(features, blockName, variable, _ref2) {
5826 let [presetType, slug] = _ref2;
5827 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', presetType]);
5828
5829 if (!metadata) {
5830 return variable;
5831 }
5832
5833 const presetObject = findInPresetsBy(features, blockName, metadata.path, 'slug', slug);
5834
5835 if (presetObject) {
5836 const {
5837 valueKey
5838 } = metadata;
5839 const result = presetObject[valueKey];
5840 return getValueFromVariable(features, blockName, result);
5841 }
5842
5843 return variable;
5844 }
5845
5846 function getValueFromCustomVariable(features, blockName, variable, path) {
5847 var _get;
5848
5849 const result = (_get = (0,external_lodash_namespaceObject.get)(features, ['blocks', blockName, 'custom', ...path])) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(features, ['custom', ...path]);
5850
5851 if (!result) {
5852 return variable;
5853 } // A variable may reference another variable so we need recursion until we find the value.
5854
5855
5856 return getValueFromVariable(features, blockName, result);
5857 }
5858
5859 function getValueFromVariable(features, blockName, variable) {
5860 if (!variable || !(0,external_lodash_namespaceObject.isString)(variable)) {
5861 return variable;
5862 }
5863
5864 const USER_VALUE_PREFIX = 'var:';
5865 const THEME_VALUE_PREFIX = 'var(--wp--';
5866 const THEME_VALUE_SUFFIX = ')';
5867 let parsedVar;
5868
5869 if (variable.startsWith(USER_VALUE_PREFIX)) {
5870 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split('|');
5871 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
5872 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split('--');
5873 } else {
5874 // We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
5875 return variable;
5876 }
5877
5878 const [type, ...path] = parsedVar;
5879
5880 if (type === 'preset') {
5881 return getValueFromPresetVariable(features, blockName, variable, path);
5882 }
5883
5884 if (type === 'custom') {
5885 return getValueFromCustomVariable(features, blockName, variable, path);
5886 }
5887
5888 return variable;
5889 }
5890
5891 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context.js
5892 /**
5893 * WordPress dependencies
5894 */
5895
5896 const DEFAULT_GLOBAL_STYLES_CONTEXT = {
5897 user: {},
5898 base: {},
5899 merged: {},
5900 setUserConfig: () => {}
5901 };
5902 const GlobalStylesContext = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_GLOBAL_STYLES_CONTEXT);
5903
5904 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/hooks.js
5905 /**
5906 * External dependencies
5907 */
5908
5909 /**
5910 * WordPress dependencies
5911 */
5912
5913
5914
5915
5916 /**
5917 * Internal dependencies
5918 */
5919
5920
5921
5922 const EMPTY_CONFIG = {
5923 settings: {},
5924 styles: {}
5925 };
5926 const useGlobalStylesReset = () => {
5927 const {
5928 user: config,
5929 setUserConfig
5930 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
5931 const canReset = !!config && !(0,external_lodash_namespaceObject.isEqual)(config, EMPTY_CONFIG);
5932 return [canReset, (0,external_wp_element_namespaceObject.useCallback)(() => setUserConfig(() => EMPTY_CONFIG), [setUserConfig])];
5933 };
5934 function useSetting(path, blockName) {
5935 var _getSettingValueForCo;
5936
5937 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
5938 const {
5939 merged: mergedConfig,
5940 base: baseConfig,
5941 user: userConfig,
5942 setUserConfig
5943 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
5944 const fullPath = !blockName ? `settings.${path}` : `settings.blocks.${blockName}.${path}`;
5945
5946 const setSetting = newValue => {
5947 setUserConfig(currentConfig => {
5948 const newUserConfig = (0,external_lodash_namespaceObject.cloneDeep)(currentConfig);
5949 const pathToSet = external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path] ? fullPath + '.custom' : fullPath;
5950 (0,external_lodash_namespaceObject.set)(newUserConfig, pathToSet, newValue);
5951 return newUserConfig;
5952 });
5953 };
5954
5955 const getSettingValueForContext = name => {
5956 const currentPath = !name ? `settings.${path}` : `settings.blocks.${name}.${path}`;
5957
5958 const getSettingValue = configToUse => {
5959 const result = (0,external_lodash_namespaceObject.get)(configToUse, currentPath);
5960
5961 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path]) {
5962 var _ref, _result$custom;
5963
5964 return (_ref = (_result$custom = result === null || result === void 0 ? void 0 : result.custom) !== null && _result$custom !== void 0 ? _result$custom : result === null || result === void 0 ? void 0 : result.theme) !== null && _ref !== void 0 ? _ref : result === null || result === void 0 ? void 0 : result.default;
5965 }
5966
5967 return result;
5968 };
5969
5970 let result;
5971
5972 switch (source) {
5973 case 'all':
5974 result = getSettingValue(mergedConfig);
5975 break;
5976
5977 case 'user':
5978 result = getSettingValue(userConfig);
5979 break;
5980
5981 case 'base':
5982 result = getSettingValue(baseConfig);
5983 break;
5984
5985 default:
5986 throw 'Unsupported source';
5987 }
5988
5989 return result;
5990 }; // Unlike styles settings get inherited from top level settings.
5991
5992
5993 const resultWithFallback = (_getSettingValueForCo = getSettingValueForContext(blockName)) !== null && _getSettingValueForCo !== void 0 ? _getSettingValueForCo : getSettingValueForContext();
5994 return [resultWithFallback, setSetting];
5995 }
5996 function useStyle(path, blockName) {
5997 var _get;
5998
5999 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
6000 const {
6001 merged: mergedConfig,
6002 base: baseConfig,
6003 user: userConfig,
6004 setUserConfig
6005 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
6006 const finalPath = !blockName ? `styles.${path}` : `styles.blocks.${blockName}.${path}`;
6007
6008 const setStyle = newValue => {
6009 setUserConfig(currentConfig => {
6010 const newUserConfig = (0,external_lodash_namespaceObject.cloneDeep)(currentConfig);
6011 (0,external_lodash_namespaceObject.set)(newUserConfig, finalPath, getPresetVariableFromValue(mergedConfig.settings, blockName, path, newValue));
6012 return newUserConfig;
6013 });
6014 };
6015
6016 let result;
6017
6018 switch (source) {
6019 case 'all':
6020 result = getValueFromVariable(mergedConfig.settings, blockName, (_get = (0,external_lodash_namespaceObject.get)(userConfig, finalPath)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
6021 break;
6022
6023 case 'user':
6024 result = getValueFromVariable(mergedConfig.settings, blockName, (0,external_lodash_namespaceObject.get)(userConfig, finalPath));
6025 break;
6026
6027 case 'base':
6028 result = getValueFromVariable(baseConfig.settings, blockName, (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
6029 break;
6030
6031 default:
6032 throw 'Unsupported source';
6033 }
6034
6035 return [result, setStyle];
6036 }
6037 const hooks_ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding'];
6038 function getSupportedGlobalStylesPanels(name) {
6039 if (!name) {
6040 return hooks_ROOT_BLOCK_SUPPORTS;
6041 }
6042
6043 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
6044
6045 if (!blockType) {
6046 return [];
6047 }
6048
6049 const supportKeys = [];
6050 Object.keys(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => {
6051 if (!external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) {
6052 return;
6053 } // Opting out means that, for certain support keys like background color,
6054 // blocks have to explicitly set the support value false. If the key is
6055 // unset, we still enable it.
6056
6057
6058 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) {
6059 if ((0,external_lodash_namespaceObject.has)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0]) && (0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) {
6060 return supportKeys.push(styleName);
6061 }
6062 }
6063
6064 if ((0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support, false)) {
6065 return supportKeys.push(styleName);
6066 }
6067 });
6068 return supportKeys;
6069 }
6070 function useColorsPerOrigin(name) {
6071 const [customColors] = useSetting('color.palette.custom', name);
6072 const [themeColors] = useSetting('color.palette.theme', name);
6073 const [defaultColors] = useSetting('color.palette.default', name);
6074 const [shouldDisplayDefaultColors] = useSetting('color.defaultPalette');
6075 return (0,external_wp_element_namespaceObject.useMemo)(() => {
6076 const result = [];
6077
6078 if (themeColors && themeColors.length) {
6079 result.push({
6080 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
6081 colors: themeColors
6082 });
6083 }
6084
6085 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
6086 result.push({
6087 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
6088 colors: defaultColors
6089 });
6090 }
6091
6092 if (customColors && customColors.length) {
6093 result.push({
6094 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
6095 colors: customColors
6096 });
6097 }
6098
6099 return result;
6100 }, [customColors, themeColors, defaultColors]);
6101 }
6102 function useGradientsPerOrigin(name) {
6103 const [customGradients] = useSetting('color.gradients.custom', name);
6104 const [themeGradients] = useSetting('color.gradients.theme', name);
6105 const [defaultGradients] = useSetting('color.gradients.default', name);
6106 const [shouldDisplayDefaultGradients] = useSetting('color.defaultGradients');
6107 return (0,external_wp_element_namespaceObject.useMemo)(() => {
6108 const result = [];
6109
6110 if (themeGradients && themeGradients.length) {
6111 result.push({
6112 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
6113 gradients: themeGradients
6114 });
6115 }
6116
6117 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
6118 result.push({
6119 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
6120 gradients: defaultGradients
6121 });
6122 }
6123
6124 if (customGradients && customGradients.length) {
6125 result.push({
6126 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
6127 gradients: customGradients
6128 });
6129 }
6130
6131 return result;
6132 }, [customGradients, themeGradients, defaultGradients]);
6133 }
6134
6135 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/border-panel.js
6136
6137
6138 /**
6139 * WordPress dependencies
6140 */
6141
6142
6143
6144
6145 /**
6146 * Internal dependencies
6147 */
6148
6149
6150 function useHasBorderPanel(name) {
6151 const controls = [useHasBorderColorControl(name), useHasBorderRadiusControl(name), useHasBorderStyleControl(name), useHasBorderWidthControl(name)];
6152 return controls.some(Boolean);
6153 }
6154
6155 function useHasBorderColorControl(name) {
6156 const supports = getSupportedGlobalStylesPanels(name);
6157 return useSetting('border.color', name)[0] && supports.includes('borderColor');
6158 }
6159
6160 function useHasBorderRadiusControl(name) {
6161 const supports = getSupportedGlobalStylesPanels(name);
6162 return useSetting('border.radius', name)[0] && supports.includes('borderRadius');
6163 }
6164
6165 function useHasBorderStyleControl(name) {
6166 const supports = getSupportedGlobalStylesPanels(name);
6167 return useSetting('border.style', name)[0] && supports.includes('borderStyle');
6168 }
6169
6170 function useHasBorderWidthControl(name) {
6171 const supports = getSupportedGlobalStylesPanels(name);
6172 return useSetting('border.width', name)[0] && supports.includes('borderWidth');
6173 }
6174
6175 function applyFallbackStyle(border) {
6176 if (!border) {
6177 return border;
6178 }
6179
6180 if (!border.style && (border.color || border.width)) {
6181 return { ...border,
6182 style: 'solid'
6183 };
6184 }
6185
6186 return border;
6187 }
6188
6189 function applyAllFallbackStyles(border) {
6190 if (!border) {
6191 return border;
6192 }
6193
6194 if ((0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(border)) {
6195 return {
6196 top: applyFallbackStyle(border.top),
6197 right: applyFallbackStyle(border.right),
6198 bottom: applyFallbackStyle(border.bottom),
6199 left: applyFallbackStyle(border.left)
6200 };
6201 }
6202
6203 return applyFallbackStyle(border);
6204 }
6205
6206 function BorderPanel(_ref) {
6207 let {
6208 name
6209 } = _ref;
6210 // To better reflect if the user has customized a value we need to
6211 // ensure the style value being checked is from the `user` origin.
6212 const [userBorderStyles] = useStyle('border', name, 'user');
6213 const [border, setBorder] = useStyle('border', name);
6214 const colors = useColorsPerOrigin(name);
6215 const showBorderColor = useHasBorderColorControl(name);
6216 const showBorderStyle = useHasBorderStyleControl(name);
6217 const showBorderWidth = useHasBorderWidthControl(name); // Border radius.
6218
6219 const showBorderRadius = useHasBorderRadiusControl(name);
6220 const [borderRadiusValues, setBorderRadius] = useStyle('border.radius', name);
6221
6222 const hasBorderRadius = () => {
6223 const borderValues = userBorderStyles === null || userBorderStyles === void 0 ? void 0 : userBorderStyles.radius;
6224
6225 if (typeof borderValues === 'object') {
6226 return Object.entries(borderValues).some(Boolean);
6227 }
6228
6229 return !!borderValues;
6230 };
6231
6232 const resetBorder = () => {
6233 if (hasBorderRadius()) {
6234 return setBorder({
6235 radius: userBorderStyles.radius
6236 });
6237 }
6238
6239 setBorder(undefined);
6240 };
6241
6242 const resetAll = (0,external_wp_element_namespaceObject.useCallback)(() => setBorder(undefined), [setBorder]);
6243 const onBorderChange = (0,external_wp_element_namespaceObject.useCallback)(newBorder => {
6244 // Ensure we have a visible border style when a border width or
6245 // color is being selected.
6246 const newBorderWithStyle = applyAllFallbackStyles(newBorder); // As we can't conditionally generate styles based on if other
6247 // style properties have been set we need to force split border
6248 // definitions for user set border styles. Border radius is derived
6249 // from the same property i.e. `border.radius` if it is a string
6250 // that is used. The longhand border radii styles are only generated
6251 // if that property is an object.
6252 //
6253 // For borders (color, style, and width) those are all properties on
6254 // the `border` style property. This means if the theme.json defined
6255 // split borders and the user condenses them into a flat border or
6256 // vice-versa we'd get both sets of styles which would conflict.
6257
6258 const updatedBorder = !(0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(newBorderWithStyle) ? {
6259 top: newBorderWithStyle,
6260 right: newBorderWithStyle,
6261 bottom: newBorderWithStyle,
6262 left: newBorderWithStyle
6263 } : {
6264 color: null,
6265 style: null,
6266 width: null,
6267 ...newBorderWithStyle
6268 }; // As radius is maintained separately to color, style, and width
6269 // maintain its value. Undefined values here will be cleaned when
6270 // global styles are saved.
6271
6272 setBorder({
6273 radius: border === null || border === void 0 ? void 0 : border.radius,
6274 ...updatedBorder
6275 });
6276 }, [setBorder]);
6277 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
6278 label: (0,external_wp_i18n_namespaceObject.__)('Border'),
6279 resetAll: resetAll
6280 }, (showBorderWidth || showBorderColor) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6281 hasValue: () => (0,external_wp_components_namespaceObject.__experimentalIsDefinedBorder)(userBorderStyles),
6282 label: (0,external_wp_i18n_namespaceObject.__)('Border'),
6283 onDeselect: () => resetBorder(),
6284 isShownByDefault: true
6285 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBorderBoxControl, {
6286 colors: colors,
6287 enableAlpha: true,
6288 onChange: onBorderChange,
6289 showStyle: showBorderStyle,
6290 value: border,
6291 popoverPlacement: "left-start",
6292 popoverOffset: 40,
6293 __experimentalHasMultipleOrigins: true,
6294 __experimentalIsRenderedInSidebar: true
6295 })), showBorderRadius && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6296 hasValue: hasBorderRadius,
6297 label: (0,external_wp_i18n_namespaceObject.__)('Radius'),
6298 onDeselect: () => setBorderRadius(undefined),
6299 isShownByDefault: true
6300 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBorderRadiusControl, {
6301 values: borderRadiusValues,
6302 onChange: value => {
6303 setBorderRadius(value || undefined);
6304 }
6305 })));
6306 }
6307
6308 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-utils.js
6309 /**
6310 * Internal dependencies
6311 */
6312
6313 function useHasColorPanel(name) {
6314 const supports = getSupportedGlobalStylesPanels(name);
6315 return supports.includes('color') || supports.includes('backgroundColor') || supports.includes('background') || supports.includes('linkColor');
6316 }
6317
6318 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/dimensions-panel.js
6319
6320
6321 /**
6322 * WordPress dependencies
6323 */
6324
6325
6326
6327 /**
6328 * Internal dependencies
6329 */
6330
6331
6332 const AXIAL_SIDES = ['horizontal', 'vertical'];
6333 function useHasDimensionsPanel(name) {
6334 const hasPadding = useHasPadding(name);
6335 const hasMargin = useHasMargin(name);
6336 const hasGap = useHasGap(name);
6337 return hasPadding || hasMargin || hasGap;
6338 }
6339
6340 function useHasPadding(name) {
6341 const supports = getSupportedGlobalStylesPanels(name);
6342 const [settings] = useSetting('spacing.padding', name);
6343 return settings && supports.includes('padding');
6344 }
6345
6346 function useHasMargin(name) {
6347 const supports = getSupportedGlobalStylesPanels(name);
6348 const [settings] = useSetting('spacing.margin', name);
6349 return settings && supports.includes('margin');
6350 }
6351
6352 function useHasGap(name) {
6353 const supports = getSupportedGlobalStylesPanels(name);
6354 const [settings] = useSetting('spacing.blockGap', name); // Do not show the gap control panel for block-level global styles
6355 // as they do not work on the frontend.
6356 // See: https://github.com/WordPress/gutenberg/pull/39845.
6357 // We can revert this condition when they're working again.
6358
6359 return !!name ? false : settings && supports.includes('--wp--style--block-gap');
6360 }
6361
6362 function filterValuesBySides(values, sides) {
6363 if (!sides) {
6364 // If no custom side configuration all sides are opted into by default.
6365 return values;
6366 } // Only include sides opted into within filtered values.
6367
6368
6369 const filteredValues = {};
6370 sides.forEach(side => {
6371 if (side === 'vertical') {
6372 filteredValues.top = values.top;
6373 filteredValues.bottom = values.bottom;
6374 }
6375
6376 if (side === 'horizontal') {
6377 filteredValues.left = values.left;
6378 filteredValues.right = values.right;
6379 }
6380
6381 filteredValues[side] = values[side];
6382 });
6383 return filteredValues;
6384 }
6385
6386 function splitStyleValue(value) {
6387 // Check for shorthand value ( a string value ).
6388 if (value && typeof value === 'string') {
6389 // Convert to value for individual sides for BoxControl.
6390 return {
6391 top: value,
6392 right: value,
6393 bottom: value,
6394 left: value
6395 };
6396 }
6397
6398 return value;
6399 }
6400
6401 function DimensionsPanel(_ref) {
6402 let {
6403 name
6404 } = _ref;
6405 const showPaddingControl = useHasPadding(name);
6406 const showMarginControl = useHasMargin(name);
6407 const showGapControl = useHasGap(name);
6408 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
6409 availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
6410 });
6411 const [rawPadding, setRawPadding] = useStyle('spacing.padding', name);
6412 const paddingValues = splitStyleValue(rawPadding);
6413 const paddingSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'padding');
6414 const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
6415
6416 const setPaddingValues = newPaddingValues => {
6417 const padding = filterValuesBySides(newPaddingValues, paddingSides);
6418 setRawPadding(padding);
6419 };
6420
6421 const resetPaddingValue = () => setPaddingValues({});
6422
6423 const hasPaddingValue = () => !!paddingValues && Object.keys(paddingValues).length;
6424
6425 const [rawMargin, setRawMargin] = useStyle('spacing.margin', name);
6426 const marginValues = splitStyleValue(rawMargin);
6427 const marginSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'margin');
6428 const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
6429
6430 const setMarginValues = newMarginValues => {
6431 const margin = filterValuesBySides(newMarginValues, marginSides);
6432 setRawMargin(margin);
6433 };
6434
6435 const resetMarginValue = () => setMarginValues({});
6436
6437 const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
6438
6439 const [gapValue, setGapValue] = useStyle('spacing.blockGap', name);
6440
6441 const resetGapValue = () => setGapValue(undefined);
6442
6443 const hasGapValue = () => !!gapValue;
6444
6445 const resetAll = () => {
6446 resetPaddingValue();
6447 resetMarginValue();
6448 resetGapValue();
6449 };
6450
6451 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
6452 label: (0,external_wp_i18n_namespaceObject.__)('Dimensions'),
6453 resetAll: resetAll
6454 }, showPaddingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6455 hasValue: hasPaddingValue,
6456 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
6457 onDeselect: resetPaddingValue,
6458 isShownByDefault: true
6459 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
6460 values: paddingValues,
6461 onChange: setPaddingValues,
6462 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
6463 sides: paddingSides,
6464 units: units,
6465 allowReset: false,
6466 splitOnAxis: isAxialPadding
6467 })), showMarginControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6468 hasValue: hasMarginValue,
6469 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
6470 onDeselect: resetMarginValue,
6471 isShownByDefault: true
6472 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
6473 values: marginValues,
6474 onChange: setMarginValues,
6475 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
6476 sides: marginSides,
6477 units: units,
6478 allowReset: false,
6479 splitOnAxis: isAxialMargin
6480 })), showGapControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6481 hasValue: hasGapValue,
6482 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
6483 onDeselect: resetGapValue,
6484 isShownByDefault: true
6485 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
6486 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
6487 __unstableInputWidth: "80px",
6488 min: 0,
6489 onChange: setGapValue,
6490 units: units,
6491 value: gapValue
6492 })));
6493 }
6494
6495 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/typography-panel.js
6496
6497
6498 /**
6499 * WordPress dependencies
6500 */
6501
6502
6503 /**
6504 * Internal dependencies
6505 */
6506
6507
6508 function useHasTypographyPanel(name) {
6509 const hasLineHeight = useHasLineHeightControl(name);
6510 const hasFontAppearance = useHasAppearanceControl(name);
6511 const hasLetterSpacing = useHasLetterSpacingControl(name);
6512 const supports = getSupportedGlobalStylesPanels(name);
6513 return hasLineHeight || hasFontAppearance || hasLetterSpacing || supports.includes('fontSize');
6514 }
6515
6516 function useHasLineHeightControl(name) {
6517 const supports = getSupportedGlobalStylesPanels(name);
6518 return useSetting('typography.lineHeight', name)[0] && supports.includes('lineHeight');
6519 }
6520
6521 function useHasAppearanceControl(name) {
6522 const supports = getSupportedGlobalStylesPanels(name);
6523 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
6524 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
6525 return hasFontStyles || hasFontWeights;
6526 }
6527
6528 function useHasLetterSpacingControl(name) {
6529 const supports = getSupportedGlobalStylesPanels(name);
6530 return useSetting('typography.letterSpacing', name)[0] && supports.includes('letterSpacing');
6531 }
6532
6533 function TypographyPanel(_ref) {
6534 let {
6535 name,
6536 element
6537 } = _ref;
6538 const supports = getSupportedGlobalStylesPanels(name);
6539 const prefix = element === 'text' || !element ? '' : `elements.${element}.`;
6540 const [fontSizes] = useSetting('typography.fontSizes', name);
6541 const disableCustomFontSizes = !useSetting('typography.customFontSize', name)[0];
6542 const [fontFamilies] = useSetting('typography.fontFamilies', name);
6543 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
6544 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
6545 const hasLineHeightEnabled = useHasLineHeightControl(name);
6546 const hasAppearanceControl = useHasAppearanceControl(name);
6547 const hasLetterSpacingControl = useHasLetterSpacingControl(name);
6548 const [fontFamily, setFontFamily] = useStyle(prefix + 'typography.fontFamily', name);
6549 const [fontSize, setFontSize] = useStyle(prefix + 'typography.fontSize', name);
6550 const [fontStyle, setFontStyle] = useStyle(prefix + 'typography.fontStyle', name);
6551 const [fontWeight, setFontWeight] = useStyle(prefix + 'typography.fontWeight', name);
6552 const [lineHeight, setLineHeight] = useStyle(prefix + 'typography.lineHeight', name);
6553 const [letterSpacing, setLetterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
6554 const [backgroundColor] = useStyle(prefix + 'color.background', name);
6555 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
6556 const [color] = useStyle(prefix + 'color.text', name);
6557 const extraStyles = element === 'link' ? {
6558 textDecoration: 'underline'
6559 } : {};
6560 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
6561 className: "edit-site-typography-panel",
6562 initialOpen: true
6563 }, (0,external_wp_element_namespaceObject.createElement)("div", {
6564 className: "edit-site-typography-panel__preview",
6565 style: {
6566 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
6567 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
6568 color,
6569 fontSize,
6570 fontStyle,
6571 fontWeight,
6572 letterSpacing,
6573 ...extraStyles
6574 }
6575 }, "Aa"), supports.includes('fontFamily') && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontFamilyControl, {
6576 fontFamilies: fontFamilies,
6577 value: fontFamily,
6578 onChange: setFontFamily
6579 }), supports.includes('fontSize') && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, {
6580 value: fontSize,
6581 onChange: setFontSize,
6582 fontSizes: fontSizes,
6583 disableCustomFontSizes: disableCustomFontSizes
6584 }), hasLineHeightEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
6585 marginBottom: 6
6586 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.LineHeightControl, {
6587 __nextHasNoMarginBottom: true,
6588 value: lineHeight,
6589 onChange: setLineHeight
6590 })), hasAppearanceControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontAppearanceControl, {
6591 value: {
6592 fontStyle,
6593 fontWeight
6594 },
6595 onChange: _ref2 => {
6596 let {
6597 fontStyle: newFontStyle,
6598 fontWeight: newFontWeight
6599 } = _ref2;
6600 setFontStyle(newFontStyle);
6601 setFontWeight(newFontWeight);
6602 },
6603 hasFontStyles: hasFontStyles,
6604 hasFontWeights: hasFontWeights
6605 }), hasLetterSpacingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLetterSpacingControl, {
6606 value: letterSpacing,
6607 onChange: setLetterSpacing
6608 }));
6609 }
6610
6611 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context-menu.js
6612
6613
6614 /**
6615 * WordPress dependencies
6616 */
6617
6618
6619
6620 /**
6621 * Internal dependencies
6622 */
6623
6624
6625
6626
6627
6628
6629
6630 function ContextMenu(_ref) {
6631 let {
6632 name,
6633 parentMenu = ''
6634 } = _ref;
6635 const hasTypographyPanel = useHasTypographyPanel(name);
6636 const hasColorPanel = useHasColorPanel(name);
6637 const hasBorderPanel = useHasBorderPanel(name);
6638 const hasDimensionsPanel = useHasDimensionsPanel(name);
6639 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
6640 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
6641 icon: library_typography,
6642 path: parentMenu + '/typography'
6643 }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
6644 icon: library_color,
6645 path: parentMenu + '/colors'
6646 }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
6647 icon: library_layout,
6648 path: parentMenu + '/layout'
6649 }, (0,external_wp_i18n_namespaceObject.__)('Layout')));
6650 }
6651
6652 /* harmony default export */ const context_menu = (ContextMenu);
6653
6654 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/constants.js
6655 const VARIABLE_REFERENCE_PREFIX = 'var:';
6656 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
6657 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
6658
6659 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/utils.js
6660 /**
6661 * External dependencies
6662 */
6663
6664 /**
6665 * Internal dependencies
6666 */
6667
6668
6669 /**
6670 * Returns a JSON representation of the generated CSS rules.
6671 *
6672 * @param style Style object.
6673 * @param options Options object with settings to adjust how the styles are generated.
6674 * @param path An array of strings representing the path to the style value in the style object.
6675 * @param ruleKey A CSS property key.
6676 *
6677 * @return GeneratedCSSRule[] CSS rules.
6678 */
6679
6680 function generateRule(style, options, path, ruleKey) {
6681 const styleValue = (0,external_lodash_namespaceObject.get)(style, path);
6682 return styleValue ? [{
6683 selector: options === null || options === void 0 ? void 0 : options.selector,
6684 key: ruleKey,
6685 value: getCSSVarFromStyleValue(styleValue)
6686 }] : [];
6687 }
6688 /**
6689 * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
6690 *
6691 * @param style Style object.
6692 * @param options Options object with settings to adjust how the styles are generated.
6693 * @param path An array of strings representing the path to the style value in the style object.
6694 * @param ruleKey A CSS property key.
6695 *
6696 * @return GeneratedCSSRule[] CSS rules.
6697 */
6698
6699 function generateBoxRules(style, options, path, ruleKey) {
6700 const boxStyle = (0,external_lodash_namespaceObject.get)(style, path);
6701
6702 if (!boxStyle) {
6703 return [];
6704 }
6705
6706 const rules = [];
6707
6708 if (typeof boxStyle === 'string') {
6709 rules.push({
6710 selector: options === null || options === void 0 ? void 0 : options.selector,
6711 key: ruleKey,
6712 value: boxStyle
6713 });
6714 } else {
6715 const sideRules = ['top', 'right', 'bottom', 'left'].reduce((acc, side) => {
6716 const value = (0,external_lodash_namespaceObject.get)(boxStyle, [side]);
6717
6718 if (value) {
6719 acc.push({
6720 selector: options === null || options === void 0 ? void 0 : options.selector,
6721 key: `${ruleKey}${(0,external_lodash_namespaceObject.upperFirst)(side)}`,
6722 value
6723 });
6724 }
6725
6726 return acc;
6727 }, []);
6728 rules.push(...sideRules);
6729 }
6730
6731 return rules;
6732 }
6733 /**
6734 * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.
6735 *
6736 * @param styleValue A raw style value.
6737 *
6738 * @return string A CSS var value.
6739 */
6740
6741 function getCSSVarFromStyleValue(styleValue) {
6742 if (typeof styleValue === 'string' && styleValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
6743 const variable = styleValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
6744 return `var(--wp--${variable})`;
6745 }
6746
6747 return styleValue;
6748 }
6749
6750 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/color/background.js
6751 /**
6752 * Internal dependencies
6753 */
6754
6755 const background = {
6756 name: 'background',
6757 generate: (style, options) => {
6758 return generateRule(style, options, ['color', 'background'], 'backgroundColor');
6759 }
6760 };
6761 /* harmony default export */ const color_background = (background);
6762
6763 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/color/gradient.js
6764 /**
6765 * Internal dependencies
6766 */
6767
6768 const gradient = {
6769 name: 'gradient',
6770 generate: (style, options) => {
6771 return generateRule(style, options, ['color', 'gradient'], 'background');
6772 }
6773 };
6774 /* harmony default export */ const color_gradient = (gradient);
6775
6776 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/color/text.js
6777 /**
6778 * Internal dependencies
6779 */
6780
6781 const text_text = {
6782 name: 'text',
6783 generate: (style, options) => {
6784 return generateRule(style, options, ['color', 'text'], 'color');
6785 }
6786 };
6787 /* harmony default export */ const color_text = (text_text);
6788
6789 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/color/index.js
6790 /**
6791 * Internal dependencies
6792 */
6793
6794
6795
6796 /* harmony default export */ const styles_color = ([color_text, color_gradient, color_background]);
6797
6798 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/spacing/padding.js
6799 /**
6800 * Internal dependencies
6801 */
6802
6803 const padding = {
6804 name: 'padding',
6805 generate: (style, options) => {
6806 return generateBoxRules(style, options, ['spacing', 'padding'], 'padding');
6807 }
6808 };
6809 /* harmony default export */ const spacing_padding = (padding);
6810
6811 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/spacing/margin.js
6812 /**
6813 * Internal dependencies
6814 */
6815
6816 const margin = {
6817 name: 'margin',
6818 generate: (style, options) => {
6819 return generateBoxRules(style, options, ['spacing', 'margin'], 'margin');
6820 }
6821 };
6822 /* harmony default export */ const spacing_margin = (margin);
6823
6824 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/spacing/index.js
6825 /**
6826 * Internal dependencies
6827 */
6828
6829
6830 /* harmony default export */ const spacing = ([spacing_margin, spacing_padding]);
6831
6832 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/typography/index.js
6833 /**
6834 * Internal dependencies
6835 */
6836
6837 const fontSize = {
6838 name: 'fontSize',
6839 generate: (style, options) => {
6840 return generateRule(style, options, ['typography', 'fontSize'], 'fontSize');
6841 }
6842 };
6843 const fontStyle = {
6844 name: 'fontStyle',
6845 generate: (style, options) => {
6846 return generateRule(style, options, ['typography', 'fontStyle'], 'fontStyle');
6847 }
6848 };
6849 const fontWeight = {
6850 name: 'fontWeight',
6851 generate: (style, options) => {
6852 return generateRule(style, options, ['typography', 'fontWeight'], 'fontWeight');
6853 }
6854 };
6855 const letterSpacing = {
6856 name: 'letterSpacing',
6857 generate: (style, options) => {
6858 return generateRule(style, options, ['typography', 'letterSpacing'], 'letterSpacing');
6859 }
6860 };
6861 const lineHeight = {
6862 name: 'letterSpacing',
6863 generate: (style, options) => {
6864 return generateRule(style, options, ['typography', 'lineHeight'], 'lineHeight');
6865 }
6866 };
6867 const textDecoration = {
6868 name: 'textDecoration',
6869 generate: (style, options) => {
6870 return generateRule(style, options, ['typography', 'textDecoration'], 'textDecoration');
6871 }
6872 };
6873 const textTransform = {
6874 name: 'textTransform',
6875 generate: (style, options) => {
6876 return generateRule(style, options, ['typography', 'textTransform'], 'textTransform');
6877 }
6878 };
6879 /* harmony default export */ const styles_typography = ([fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform]);
6880
6881 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/index.js
6882 /**
6883 * Internal dependencies
6884 */
6885
6886
6887
6888 const styleDefinitions = [...styles_color, ...spacing, ...styles_typography];
6889
6890 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/index.js
6891 /**
6892 * External dependencies
6893 */
6894
6895 /**
6896 * Internal dependencies
6897 */
6898
6899
6900 /**
6901 * Generates a stylesheet for a given style object and selector.
6902 *
6903 * @param style Style object.
6904 * @param options Options object with settings to adjust how the styles are generated.
6905 *
6906 * @return generated stylesheet.
6907 */
6908
6909 function generate(style, options) {
6910 const rules = getCSSRules(style, options); // If no selector is provided, treat generated rules as inline styles to be returned as a single string.
6911
6912 if (!(options !== null && options !== void 0 && options.selector)) {
6913 const inlineRules = [];
6914 rules.forEach(rule => {
6915 inlineRules.push(`${kebabCase(rule.key)}: ${rule.value};`);
6916 });
6917 return inlineRules.join(' ');
6918 }
6919
6920 const groupedRules = groupBy(rules, 'selector');
6921 const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
6922 acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${kebabCase(rule.key)}: ${rule.value};`).join(' ')} }`);
6923 return acc;
6924 }, []);
6925 return selectorRules.join('\n');
6926 }
6927 /**
6928 * Returns a JSON representation of the generated CSS rules.
6929 *
6930 * @param style Style object.
6931 * @param options Options object with settings to adjust how the styles are generated.
6932 *
6933 * @return generated styles.
6934 */
6935
6936 function getCSSRules(style, options) {
6937 const rules = [];
6938 styleDefinitions.forEach(definition => {
6939 if (typeof definition.generate === 'function') {
6940 rules.push(...definition.generate(style, options));
6941 }
6942 });
6943 return rules;
6944 }
6945
6946 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/use-global-styles-output.js
6947
6948
6949 /**
6950 * External dependencies
6951 */
6952
6953 /**
6954 * WordPress dependencies
6955 */
6956
6957
6958
6959
6960
6961 /**
6962 * Internal dependencies
6963 */
6964
6965
6966
6967
6968
6969 function compileStyleValue(uncompiledValue) {
6970 const VARIABLE_REFERENCE_PREFIX = 'var:';
6971 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
6972 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
6973
6974 if ((0,external_lodash_namespaceObject.startsWith)(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
6975 const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
6976 return `var(--wp--${variable})`;
6977 }
6978
6979 return uncompiledValue;
6980 }
6981 /**
6982 * Transform given preset tree into a set of style declarations.
6983 *
6984 * @param {Object} blockPresets
6985 *
6986 * @return {Array} An array of style declarations.
6987 */
6988
6989
6990 function getPresetsDeclarations() {
6991 let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6992 return (0,external_lodash_namespaceObject.reduce)(PRESET_METADATA, (declarations, _ref) => {
6993 let {
6994 path,
6995 valueKey,
6996 valueFunc,
6997 cssVarInfix
6998 } = _ref;
6999 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
7000 ['default', 'theme', 'custom'].forEach(origin => {
7001 if (presetByOrigin[origin]) {
7002 presetByOrigin[origin].forEach(value => {
7003 if (valueKey) {
7004 declarations.push(`--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(value.slug)}: ${value[valueKey]}`);
7005 } else if (valueFunc && typeof valueFunc === 'function') {
7006 declarations.push(`--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(value.slug)}: ${valueFunc(value)}`);
7007 }
7008 });
7009 }
7010 });
7011 return declarations;
7012 }, []);
7013 }
7014 /**
7015 * Transform given preset tree into a set of preset class declarations.
7016 *
7017 * @param {string} blockSelector
7018 * @param {Object} blockPresets
7019 * @return {string} CSS declarations for the preset classes.
7020 */
7021
7022
7023 function getPresetsClasses(blockSelector) {
7024 let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7025 return (0,external_lodash_namespaceObject.reduce)(PRESET_METADATA, (declarations, _ref2) => {
7026 let {
7027 path,
7028 cssVarInfix,
7029 classes
7030 } = _ref2;
7031
7032 if (!classes) {
7033 return declarations;
7034 }
7035
7036 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
7037 ['default', 'theme', 'custom'].forEach(origin => {
7038 if (presetByOrigin[origin]) {
7039 presetByOrigin[origin].forEach(_ref3 => {
7040 let {
7041 slug
7042 } = _ref3;
7043 classes.forEach(_ref4 => {
7044 let {
7045 classSuffix,
7046 propertyName
7047 } = _ref4;
7048 const classSelectorToUse = `.has-${(0,external_lodash_namespaceObject.kebabCase)(slug)}-${classSuffix}`;
7049 const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
7050 .map(selector => `${selector}${classSelectorToUse}`).join(',');
7051 const value = `var(--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(slug)})`;
7052 declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
7053 });
7054 });
7055 }
7056 });
7057 return declarations;
7058 }, '');
7059 }
7060
7061 function getPresetsSvgFilters() {
7062 let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7063 return PRESET_METADATA.filter( // Duotone are the only type of filters for now.
7064 metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
7065 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, metadata.path, {});
7066 return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstablePresetDuotoneFilter, {
7067 preset: preset,
7068 key: preset.slug
7069 })));
7070 });
7071 }
7072
7073 function flattenTree() {
7074 let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7075 let prefix = arguments.length > 1 ? arguments[1] : undefined;
7076 let token = arguments.length > 2 ? arguments[2] : undefined;
7077 let result = [];
7078 Object.keys(input).forEach(key => {
7079 const newKey = prefix + (0,external_lodash_namespaceObject.kebabCase)(key.replace('/', '-'));
7080 const newLeaf = input[key];
7081
7082 if (newLeaf instanceof Object) {
7083 const newPrefix = newKey + token;
7084 result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
7085 } else {
7086 result.push(`${newKey}: ${newLeaf}`);
7087 }
7088 });
7089 return result;
7090 }
7091 /**
7092 * Transform given style tree into a set of style declarations.
7093 *
7094 * @param {Object} blockStyles Block styles.
7095 *
7096 * @return {Array} An array of style declarations.
7097 */
7098
7099
7100 function getStylesDeclarations() {
7101 let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7102 const output = (0,external_lodash_namespaceObject.reduce)(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY, (declarations, _ref5, key) => {
7103 let {
7104 value,
7105 properties,
7106 useEngine
7107 } = _ref5;
7108 const pathToValue = value;
7109
7110 if ((0,external_lodash_namespaceObject.first)(pathToValue) === 'elements' || useEngine) {
7111 return declarations;
7112 }
7113
7114 const styleValue = (0,external_lodash_namespaceObject.get)(blockStyles, pathToValue);
7115
7116 if (!!properties && !(0,external_lodash_namespaceObject.isString)(styleValue)) {
7117 Object.entries(properties).forEach(entry => {
7118 const [name, prop] = entry;
7119
7120 if (!(0,external_lodash_namespaceObject.get)(styleValue, [prop], false)) {
7121 // Do not create a declaration
7122 // for sub-properties that don't have any value.
7123 return;
7124 }
7125
7126 const cssProperty = (0,external_lodash_namespaceObject.kebabCase)(name);
7127 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(styleValue, [prop]))}`);
7128 });
7129 } else if ((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue, false)) {
7130 const cssProperty = key.startsWith('--') ? key : (0,external_lodash_namespaceObject.kebabCase)(key);
7131 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue))}`);
7132 }
7133
7134 return declarations;
7135 }, []); // The goal is to move everything to server side generated engine styles
7136 // This is temporary as we absorb more and more styles into the engine.
7137
7138 const extraRules = getCSSRules(blockStyles);
7139 extraRules.forEach(rule => {
7140 const cssProperty = rule.key.startsWith('--') ? rule.key : (0,external_lodash_namespaceObject.kebabCase)(rule.key);
7141 output.push(`${cssProperty}: ${compileStyleValue(rule.value)}`);
7142 });
7143 return output;
7144 }
7145
7146 const getNodesWithStyles = (tree, blockSelectors) => {
7147 var _tree$styles, _tree$styles2;
7148
7149 const nodes = [];
7150
7151 if (!(tree !== null && tree !== void 0 && tree.styles)) {
7152 return nodes;
7153 }
7154
7155 const pickStyleKeys = treeToPickFrom => (0,external_lodash_namespaceObject.pickBy)(treeToPickFrom, (value, key) => ['border', 'color', 'spacing', 'typography', 'filter'].includes(key)); // Top-level.
7156
7157
7158 const styles = pickStyleKeys(tree.styles);
7159
7160 if (!!styles) {
7161 nodes.push({
7162 styles,
7163 selector: ROOT_BLOCK_SELECTOR
7164 });
7165 }
7166
7167 (0,external_lodash_namespaceObject.forEach)((_tree$styles = tree.styles) === null || _tree$styles === void 0 ? void 0 : _tree$styles.elements, (value, key) => {
7168 if (!!value && !!external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[key]) {
7169 nodes.push({
7170 styles: value,
7171 selector: external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[key]
7172 });
7173 }
7174 }); // Iterate over blocks: they can have styles & elements.
7175
7176 (0,external_lodash_namespaceObject.forEach)((_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.blocks, (node, blockName) => {
7177 var _blockSelectors$block;
7178
7179 const blockStyles = pickStyleKeys(node);
7180
7181 if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
7182 nodes.push({
7183 styles: blockStyles,
7184 selector: blockSelectors[blockName].selector,
7185 duotoneSelector: blockSelectors[blockName].duotoneSelector
7186 });
7187 }
7188
7189 (0,external_lodash_namespaceObject.forEach)(node === null || node === void 0 ? void 0 : node.elements, (value, elementName) => {
7190 if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS !== null && external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS !== void 0 && external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName])) {
7191 nodes.push({
7192 styles: value,
7193 selector: blockSelectors[blockName].selector.split(',').map(sel => sel + ' ' + external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName]).join(',')
7194 });
7195 }
7196 });
7197 });
7198 return nodes;
7199 };
7200 const getNodesWithSettings = (tree, blockSelectors) => {
7201 var _tree$settings, _tree$settings2;
7202
7203 const nodes = [];
7204
7205 if (!(tree !== null && tree !== void 0 && tree.settings)) {
7206 return nodes;
7207 }
7208
7209 const pickPresets = treeToPickFrom => {
7210 const presets = {};
7211 PRESET_METADATA.forEach(_ref6 => {
7212 let {
7213 path
7214 } = _ref6;
7215 const value = (0,external_lodash_namespaceObject.get)(treeToPickFrom, path, false);
7216
7217 if (value !== false) {
7218 (0,external_lodash_namespaceObject.set)(presets, path, value);
7219 }
7220 });
7221 return presets;
7222 }; // Top-level.
7223
7224
7225 const presets = pickPresets(tree.settings);
7226 const custom = (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.custom;
7227
7228 if (!(0,external_lodash_namespaceObject.isEmpty)(presets) || !!custom) {
7229 nodes.push({
7230 presets,
7231 custom,
7232 selector: ROOT_BLOCK_SELECTOR
7233 });
7234 } // Blocks.
7235
7236
7237 (0,external_lodash_namespaceObject.forEach)((_tree$settings2 = tree.settings) === null || _tree$settings2 === void 0 ? void 0 : _tree$settings2.blocks, (node, blockName) => {
7238 const blockPresets = pickPresets(node);
7239 const blockCustom = node.custom;
7240
7241 if (!(0,external_lodash_namespaceObject.isEmpty)(blockPresets) || !!blockCustom) {
7242 nodes.push({
7243 presets: blockPresets,
7244 custom: blockCustom,
7245 selector: blockSelectors[blockName].selector
7246 });
7247 }
7248 });
7249 return nodes;
7250 };
7251 const toCustomProperties = (tree, blockSelectors) => {
7252 const settings = getNodesWithSettings(tree, blockSelectors);
7253 let ruleset = '';
7254 settings.forEach(_ref7 => {
7255 let {
7256 presets,
7257 custom,
7258 selector
7259 } = _ref7;
7260 const declarations = getPresetsDeclarations(presets);
7261 const customProps = flattenTree(custom, '--wp--custom--', '--');
7262
7263 if (customProps.length > 0) {
7264 declarations.push(...customProps);
7265 }
7266
7267 if (declarations.length > 0) {
7268 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
7269 }
7270 });
7271 return ruleset;
7272 };
7273 const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
7274 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
7275 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
7276 /*
7277 * Reset default browser margin on the root body element.
7278 * This is set on the root selector **before** generating the ruleset
7279 * from the `theme.json`. This is to ensure that if the `theme.json` declares
7280 * `margin` in its `spacing` declaration for the `body` element then these
7281 * user-generated values take precedence in the CSS cascade.
7282 * @link https://github.com/WordPress/gutenberg/issues/36147.
7283 */
7284
7285 let ruleset = 'body {margin: 0;}';
7286 nodesWithStyles.forEach(_ref8 => {
7287 let {
7288 selector,
7289 duotoneSelector,
7290 styles
7291 } = _ref8;
7292 const duotoneStyles = {};
7293
7294 if (styles !== null && styles !== void 0 && styles.filter) {
7295 duotoneStyles.filter = styles.filter;
7296 delete styles.filter;
7297 } // Process duotone styles (they use color.__experimentalDuotone selector).
7298
7299
7300 if (duotoneSelector) {
7301 const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
7302
7303 if (duotoneDeclarations.length === 0) {
7304 return;
7305 }
7306
7307 ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
7308 } // Process the remaning block styles (they use either normal block class or __experimentalSelector).
7309
7310
7311 const declarations = getStylesDeclarations(styles);
7312
7313 if (declarations.length === 0) {
7314 return;
7315 }
7316
7317 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
7318 });
7319 /* Add alignment / layout styles */
7320
7321 ruleset = ruleset + '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
7322 ruleset = ruleset + '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
7323 ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
7324
7325 if (hasBlockGapSupport) {
7326 ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
7327 ruleset = ruleset + '.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }';
7328 }
7329
7330 nodesWithSettings.forEach(_ref9 => {
7331 let {
7332 selector,
7333 presets
7334 } = _ref9;
7335
7336 if (ROOT_BLOCK_SELECTOR === selector) {
7337 // Do not add extra specificity for top-level classes.
7338 selector = '';
7339 }
7340
7341 const classes = getPresetsClasses(selector, presets);
7342
7343 if (!(0,external_lodash_namespaceObject.isEmpty)(classes)) {
7344 ruleset = ruleset + classes;
7345 }
7346 });
7347 return ruleset;
7348 };
7349 function toSvgFilters(tree, blockSelectors) {
7350 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
7351 return nodesWithSettings.flatMap(_ref10 => {
7352 let {
7353 presets
7354 } = _ref10;
7355 return getPresetsSvgFilters(presets);
7356 });
7357 }
7358
7359 const getBlockSelectors = blockTypes => {
7360 const result = {};
7361 blockTypes.forEach(blockType => {
7362 var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$;
7363
7364 const name = blockType.name;
7365 const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
7366 const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
7367 result[name] = {
7368 name,
7369 selector,
7370 duotoneSelector
7371 };
7372 });
7373 return result;
7374 };
7375
7376 function useGlobalStylesOutput() {
7377 const [stylesheets, setStylesheets] = (0,external_wp_element_namespaceObject.useState)([]);
7378 const [settings, setSettings] = (0,external_wp_element_namespaceObject.useState)({});
7379 const [svgFilters, setSvgFilters] = (0,external_wp_element_namespaceObject.useState)({});
7380 const {
7381 merged: mergedConfig
7382 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
7383 const [blockGap] = useSetting('spacing.blockGap');
7384 const hasBlockGapSupport = blockGap !== null;
7385 (0,external_wp_element_namespaceObject.useEffect)(() => {
7386 if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
7387 return;
7388 }
7389
7390 const blockSelectors = getBlockSelectors((0,external_wp_blocks_namespaceObject.getBlockTypes)());
7391 const customProperties = toCustomProperties(mergedConfig, blockSelectors);
7392 const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport);
7393 const filters = toSvgFilters(mergedConfig, blockSelectors);
7394 setStylesheets([{
7395 css: customProperties,
7396 isGlobalStyles: true
7397 }, {
7398 css: globalStyles,
7399 isGlobalStyles: true
7400 }]);
7401 setSettings(mergedConfig.settings);
7402 setSvgFilters(filters);
7403 }, [mergedConfig]);
7404 return [stylesheets, settings, svgFilters, hasBlockGapSupport];
7405 }
7406
7407 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/preview.js
7408
7409
7410 /**
7411 * WordPress dependencies
7412 */
7413
7414
7415
7416
7417 /**
7418 * Internal dependencies
7419 */
7420
7421
7422
7423 const firstFrame = {
7424 start: {
7425 opacity: 1,
7426 display: 'block'
7427 },
7428 hover: {
7429 opacity: 0,
7430 display: 'none'
7431 }
7432 };
7433 const secondFrame = {
7434 hover: {
7435 opacity: 1,
7436 display: 'block'
7437 },
7438 start: {
7439 opacity: 0,
7440 display: 'none'
7441 }
7442 };
7443 const normalizedWidth = 248;
7444 const normalizedHeight = 152;
7445 const normalizedColorSwatchSize = 32;
7446
7447 const StylesPreview = _ref => {
7448 let {
7449 label,
7450 isFocused
7451 } = _ref;
7452 const [fontWeight] = useStyle('typography.fontWeight');
7453 const [fontFamily = 'serif'] = useStyle('typography.fontFamily');
7454 const [headingFontFamily = fontFamily] = useStyle('elements.h1.typography.fontFamily');
7455 const [headingFontWeight = fontWeight] = useStyle('elements.h1.typography.fontWeight');
7456 const [textColor = 'black'] = useStyle('color.text');
7457 const [headingColor = textColor] = useStyle('elements.h1.color.text');
7458 const [linkColor = 'blue'] = useStyle('elements.link.color.text');
7459 const [backgroundColor = 'white'] = useStyle('color.background');
7460 const [gradientValue] = useStyle('color.gradient');
7461 const [styles] = useGlobalStylesOutput();
7462 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7463 const [coreColors] = useSetting('color.palette.core');
7464 const [themeColors] = useSetting('color.palette.theme');
7465 const [customColors] = useSetting('color.palette.custom');
7466 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
7467 const [containerResizeListener, {
7468 width
7469 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
7470 const ratio = width ? width / normalizedWidth : 1;
7471 const paletteColors = (themeColors !== null && themeColors !== void 0 ? themeColors : []).concat(customColors !== null && customColors !== void 0 ? customColors : []).concat(coreColors !== null && coreColors !== void 0 ? coreColors : []);
7472 const highlightedColors = paletteColors.filter( // we exclude these two colors because they are already visible in the preview.
7473 _ref2 => {
7474 let {
7475 color
7476 } = _ref2;
7477 return color !== backgroundColor && color !== headingColor;
7478 }).slice(0, 2); // Reset leaked styles from WP common.css.
7479
7480 const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
7481 if (styles) {
7482 return [...styles, {
7483 css: 'body{min-width: 0;}',
7484 isGlobalStyles: true
7485 }];
7486 }
7487
7488 return styles;
7489 }, [styles]);
7490 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, {
7491 className: "edit-site-global-styles-preview__iframe",
7492 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
7493 styles: editorStyles
7494 }),
7495 style: {
7496 height: normalizedHeight * ratio,
7497 visibility: !width ? 'hidden' : 'visible'
7498 },
7499 onMouseEnter: () => setIsHovered(true),
7500 onMouseLeave: () => setIsHovered(false),
7501 tabIndex: -1
7502 }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7503 style: {
7504 height: normalizedHeight * ratio,
7505 width: '100%',
7506 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
7507 cursor: 'pointer'
7508 },
7509 initial: "start",
7510 animate: (isHovered || isFocused) && !disableMotion ? 'hover' : 'start'
7511 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7512 variants: firstFrame,
7513 style: {
7514 height: '100%',
7515 overflow: 'hidden'
7516 }
7517 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7518 spacing: 10 * ratio,
7519 justify: "center",
7520 style: {
7521 height: '100%',
7522 overflow: 'hidden'
7523 }
7524 }, (0,external_wp_element_namespaceObject.createElement)("div", {
7525 style: {
7526 fontFamily: headingFontFamily,
7527 fontSize: 65 * ratio,
7528 color: headingColor,
7529 fontWeight: headingFontWeight
7530 }
7531 }, "Aa"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7532 spacing: 4 * ratio
7533 }, highlightedColors.map(_ref3 => {
7534 let {
7535 slug,
7536 color
7537 } = _ref3;
7538 return (0,external_wp_element_namespaceObject.createElement)("div", {
7539 key: slug,
7540 style: {
7541 height: normalizedColorSwatchSize * ratio,
7542 width: normalizedColorSwatchSize * ratio,
7543 background: color,
7544 borderRadius: normalizedColorSwatchSize * ratio / 2
7545 }
7546 });
7547 })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7548 variants: secondFrame,
7549 style: {
7550 height: '100%',
7551 overflow: 'hidden'
7552 }
7553 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7554 spacing: 3 * ratio,
7555 justify: "center",
7556 style: {
7557 height: '100%',
7558 overflow: 'hidden',
7559 padding: 10 * ratio,
7560 boxSizing: 'border-box'
7561 }
7562 }, label && (0,external_wp_element_namespaceObject.createElement)("div", {
7563 style: {
7564 fontSize: 35 * ratio,
7565 fontFamily: headingFontFamily,
7566 color: headingColor,
7567 fontWeight: headingFontWeight,
7568 lineHeight: '1em'
7569 }
7570 }, label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7571 spacing: 2 * ratio,
7572 justify: "flex-start"
7573 }, (0,external_wp_element_namespaceObject.createElement)("div", {
7574 style: {
7575 fontFamily,
7576 fontSize: 24 * ratio,
7577 color: textColor
7578 }
7579 }, "Aa"), (0,external_wp_element_namespaceObject.createElement)("div", {
7580 style: {
7581 fontFamily,
7582 fontSize: 24 * ratio,
7583 color: linkColor
7584 }
7585 }, "Aa")), paletteColors && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7586 spacing: 0
7587 }, paletteColors.slice(0, 4).map((_ref4, index) => {
7588 let {
7589 color
7590 } = _ref4;
7591 return (0,external_wp_element_namespaceObject.createElement)("div", {
7592 key: index,
7593 style: {
7594 height: 10 * ratio,
7595 width: 30 * ratio,
7596 background: color,
7597 flexGrow: 1
7598 }
7599 });
7600 }))))));
7601 };
7602
7603 /* harmony default export */ const preview = (StylesPreview);
7604
7605 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-root.js
7606
7607
7608 /**
7609 * WordPress dependencies
7610 */
7611
7612
7613
7614
7615
7616 /**
7617 * Internal dependencies
7618 */
7619
7620
7621
7622
7623
7624
7625 function ScreenRoot() {
7626 const {
7627 variations
7628 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7629 return {
7630 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()
7631 };
7632 }, []);
7633 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
7634 size: "small"
7635 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7636 spacing: 4
7637 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardMedia, null, (0,external_wp_element_namespaceObject.createElement)(preview, null))), !!(variations !== null && variations !== void 0 && variations.length) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7638 path: "/variations"
7639 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7640 justify: "space-between"
7641 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Browse styles')), (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
7642 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
7643 })))), (0,external_wp_element_namespaceObject.createElement)(context_menu, null))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
7644 as: "p",
7645 paddingTop: 2
7646 /*
7647 * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).
7648 * This is an ad hoc override for this particular instance only and should be reconsidered before making into a pattern.
7649 */
7650 ,
7651 paddingX: "13px",
7652 marginBottom: 4
7653 }, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7654 path: "/blocks"
7655 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7656 justify: "space-between"
7657 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Blocks')), (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
7658 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
7659 }))))));
7660 }
7661
7662 /* harmony default export */ const screen_root = (ScreenRoot);
7663
7664 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/header.js
7665
7666
7667 /**
7668 * WordPress dependencies
7669 */
7670
7671
7672
7673
7674 function ScreenHeader(_ref) {
7675 let {
7676 title,
7677 description
7678 } = _ref;
7679 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7680 spacing: 0
7681 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
7682 marginBottom: 0,
7683 paddingX: 4,
7684 paddingY: 3
7685 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7686 spacing: 2
7687 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
7688 style: // TODO: This style override is also used in ToolsPanelHeader.
7689 // It should be supported out-of-the-box by Button.
7690 {
7691 minWidth: 24,
7692 padding: 0
7693 },
7694 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
7695 isSmall: true,
7696 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
7697 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
7698 level: 5
7699 }, title))))), description && (0,external_wp_element_namespaceObject.createElement)("p", {
7700 className: "edit-site-global-styles-header__description"
7701 }, description));
7702 }
7703
7704 /* harmony default export */ const header = (ScreenHeader);
7705
7706 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block-list.js
7707
7708
7709 /**
7710 * WordPress dependencies
7711 */
7712
7713
7714
7715
7716
7717
7718
7719
7720 /**
7721 * Internal dependencies
7722 */
7723
7724
7725
7726
7727
7728
7729
7730
7731 function useSortedBlockTypes() {
7732 const blockItems = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).getBlockTypes(), []); // Ensure core blocks are prioritized in the returned results,
7733 // because third party blocks can be registered earlier than
7734 // the core blocks (usually by using the `init` action),
7735 // thus affecting the display order.
7736 // We don't sort reusable blocks as they are handled differently.
7737
7738 const groupByType = (blocks, block) => {
7739 const {
7740 core,
7741 noncore
7742 } = blocks;
7743 const type = block.name.startsWith('core/') ? core : noncore;
7744 type.push(block);
7745 return blocks;
7746 };
7747
7748 const {
7749 core: coreItems,
7750 noncore: nonCoreItems
7751 } = blockItems.reduce(groupByType, {
7752 core: [],
7753 noncore: []
7754 });
7755 return [...coreItems, ...nonCoreItems];
7756 }
7757
7758 function BlockMenuItem(_ref) {
7759 let {
7760 block
7761 } = _ref;
7762 const hasTypographyPanel = useHasTypographyPanel(block.name);
7763 const hasColorPanel = useHasColorPanel(block.name);
7764 const hasBorderPanel = useHasBorderPanel(block.name);
7765 const hasDimensionsPanel = useHasDimensionsPanel(block.name);
7766 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
7767 const hasBlockMenuItem = hasTypographyPanel || hasColorPanel || hasLayoutPanel;
7768
7769 if (!hasBlockMenuItem) {
7770 return null;
7771 }
7772
7773 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7774 path: '/blocks/' + block.name
7775 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7776 justify: "flex-start"
7777 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
7778 icon: block.icon
7779 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title)));
7780 }
7781
7782 function ScreenBlockList() {
7783 const sortedBlockTypes = useSortedBlockTypes();
7784 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
7785 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
7786 const isMatchingSearchTerm = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).isMatchingSearchTerm, []);
7787 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
7788 if (!filterValue) {
7789 return sortedBlockTypes;
7790 }
7791
7792 return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
7793 }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]);
7794 const blockTypesListRef = (0,external_wp_element_namespaceObject.useRef)(); // Announce search results on change
7795
7796 (0,external_wp_element_namespaceObject.useEffect)(() => {
7797 if (!filterValue) {
7798 return;
7799 } // We extract the results from the wrapper div's `ref` because
7800 // filtered items can contain items that will eventually not
7801 // render and there is no reliable way to detect when a child
7802 // will return `null`.
7803 // TODO: We should find a better way of handling this as it's
7804 // fragile and depends on the number of rendered elements of `BlockMenuItem`,
7805 // which is now one.
7806 // @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116
7807
7808
7809 const count = blockTypesListRef.current.childElementCount;
7810 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
7811 /* translators: %d: number of results. */
7812 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
7813 debouncedSpeak(resultsFoundMessage, count);
7814 }, [filterValue, debouncedSpeak]);
7815 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7816 title: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
7817 description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks and for the whole site.')
7818 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
7819 className: "edit-site-block-types-search",
7820 onChange: setFilterValue,
7821 value: filterValue,
7822 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks'),
7823 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
7824 }), (0,external_wp_element_namespaceObject.createElement)("div", {
7825 ref: blockTypesListRef,
7826 className: "edit-site-block-types-item-list"
7827 }, filteredBlockTypes.map(block => (0,external_wp_element_namespaceObject.createElement)(BlockMenuItem, {
7828 block: block,
7829 key: 'menu-itemblock-' + block.name
7830 }))));
7831 }
7832
7833 /* harmony default export */ const screen_block_list = (ScreenBlockList);
7834
7835 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block.js
7836
7837
7838 /**
7839 * WordPress dependencies
7840 */
7841
7842 /**
7843 * Internal dependencies
7844 */
7845
7846
7847
7848
7849 function ScreenBlock(_ref) {
7850 let {
7851 name
7852 } = _ref;
7853 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
7854 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7855 title: blockType.title
7856 }), (0,external_wp_element_namespaceObject.createElement)(context_menu, {
7857 parentMenu: '/blocks/' + name,
7858 name: name
7859 }));
7860 }
7861
7862 /* harmony default export */ const screen_block = (ScreenBlock);
7863
7864 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/subtitle.js
7865
7866
7867 /**
7868 * WordPress dependencies
7869 */
7870
7871
7872 function Subtitle(_ref) {
7873 let {
7874 children
7875 } = _ref;
7876 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
7877 className: "edit-site-global-styles-subtitle",
7878 level: 2
7879 }, children);
7880 }
7881
7882 /* harmony default export */ const subtitle = (Subtitle);
7883
7884 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography.js
7885
7886
7887 /**
7888 * WordPress dependencies
7889 */
7890
7891
7892 /**
7893 * Internal dependencies
7894 */
7895
7896
7897
7898
7899
7900
7901
7902 function Item(_ref) {
7903 let {
7904 name,
7905 parentMenu,
7906 element,
7907 label
7908 } = _ref;
7909 const hasSupport = !name;
7910 const prefix = element === 'text' || !element ? '' : `elements.${element}.`;
7911 const extraStyles = element === 'link' ? {
7912 textDecoration: 'underline'
7913 } : {};
7914 const [fontFamily] = useStyle(prefix + 'typography.fontFamily', name);
7915 const [fontStyle] = useStyle(prefix + 'typography.fontStyle', name);
7916 const [fontWeight] = useStyle(prefix + 'typography.fontWeight', name);
7917 const [letterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
7918 const [backgroundColor] = useStyle(prefix + 'color.background', name);
7919 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
7920 const [color] = useStyle(prefix + 'color.text', name);
7921
7922 if (!hasSupport) {
7923 return null;
7924 }
7925
7926 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7927 path: parentMenu + '/typography/' + element
7928 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7929 justify: "flex-start"
7930 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
7931 className: "edit-site-global-styles-screen-typography__indicator",
7932 style: {
7933 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
7934 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
7935 color,
7936 fontStyle,
7937 fontWeight,
7938 letterSpacing,
7939 ...extraStyles
7940 }
7941 }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, label)));
7942 }
7943
7944 function ScreenTypography(_ref2) {
7945 let {
7946 name
7947 } = _ref2;
7948 const parentMenu = name === undefined ? '' : '/blocks/' + name;
7949 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7950 title: (0,external_wp_i18n_namespaceObject.__)('Typography'),
7951 description: (0,external_wp_i18n_namespaceObject.__)('Manage the typography settings for different elements.')
7952 }), !name && (0,external_wp_element_namespaceObject.createElement)("div", {
7953 className: "edit-site-global-styles-screen-typography"
7954 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7955 spacing: 3
7956 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
7957 isBordered: true,
7958 isSeparated: true
7959 }, (0,external_wp_element_namespaceObject.createElement)(Item, {
7960 name: name,
7961 parentMenu: parentMenu,
7962 element: "text",
7963 label: (0,external_wp_i18n_namespaceObject.__)('Text')
7964 }), (0,external_wp_element_namespaceObject.createElement)(Item, {
7965 name: name,
7966 parentMenu: parentMenu,
7967 element: "link",
7968 label: (0,external_wp_i18n_namespaceObject.__)('Links')
7969 })))), !!name && (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
7970 name: name,
7971 element: "text"
7972 }));
7973 }
7974
7975 /* harmony default export */ const screen_typography = (ScreenTypography);
7976
7977 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography-element.js
7978
7979
7980 /**
7981 * WordPress dependencies
7982 */
7983
7984 /**
7985 * Internal dependencies
7986 */
7987
7988
7989
7990 const screen_typography_element_elements = {
7991 text: {
7992 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts used on the site.'),
7993 title: (0,external_wp_i18n_namespaceObject.__)('Text')
7994 },
7995 link: {
7996 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on the links.'),
7997 title: (0,external_wp_i18n_namespaceObject.__)('Links')
7998 }
7999 };
8000
8001 function ScreenTypographyElement(_ref) {
8002 let {
8003 name,
8004 element
8005 } = _ref;
8006 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8007 title: screen_typography_element_elements[element].title,
8008 description: screen_typography_element_elements[element].description
8009 }), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
8010 name: name,
8011 element: element
8012 }));
8013 }
8014
8015 /* harmony default export */ const screen_typography_element = (ScreenTypographyElement);
8016
8017 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-indicator-wrapper.js
8018
8019
8020
8021 /**
8022 * External dependencies
8023 */
8024
8025 /**
8026 * WordPress dependencies
8027 */
8028
8029
8030
8031 function ColorIndicatorWrapper(_ref) {
8032 let {
8033 className,
8034 ...props
8035 } = _ref;
8036 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, extends_extends({
8037 className: classnames_default()('edit-site-global-styles__color-indicator-wrapper', className)
8038 }, props));
8039 }
8040
8041 /* harmony default export */ const color_indicator_wrapper = (ColorIndicatorWrapper);
8042
8043 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/palette.js
8044
8045
8046 /**
8047 * WordPress dependencies
8048 */
8049
8050
8051
8052 /**
8053 * Internal dependencies
8054 */
8055
8056
8057
8058
8059
8060 const EMPTY_COLORS = [];
8061
8062 function Palette(_ref) {
8063 let {
8064 name
8065 } = _ref;
8066 const [customColors] = useSetting('color.palette.custom');
8067 const [themeColors] = useSetting('color.palette.theme');
8068 const [defaultColors] = useSetting('color.palette.default');
8069 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
8070 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(customColors || EMPTY_COLORS), ...(themeColors || EMPTY_COLORS), ...(defaultColors && defaultPaletteEnabled ? defaultColors : EMPTY_COLORS)], [customColors, themeColors, defaultColors, defaultPaletteEnabled]);
8071 const screenPath = !name ? '/colors/palette' : '/blocks/' + name + '/colors/palette';
8072 const paletteButtonText = colors.length > 0 ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of palette colors.
8073 (0,external_wp_i18n_namespaceObject._n)('%d color', '%d colors', colors.length), colors.length) : (0,external_wp_i18n_namespaceObject.__)('Add custom colors');
8074 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8075 spacing: 3
8076 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Palette')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
8077 isBordered: true,
8078 isSeparated: true
8079 }, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8080 path: screenPath
8081 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8082 direction: colors.length === 0 ? 'row-reverse' : 'row'
8083 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
8084 isLayered: false,
8085 offset: -8
8086 }, colors.slice(0, 5).map(_ref2 => {
8087 let {
8088 color
8089 } = _ref2;
8090 return (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
8091 key: color
8092 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
8093 colorValue: color
8094 }));
8095 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))));
8096 }
8097
8098 /* harmony default export */ const palette = (Palette);
8099
8100 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-colors.js
8101
8102
8103 /**
8104 * WordPress dependencies
8105 */
8106
8107
8108 /**
8109 * Internal dependencies
8110 */
8111
8112
8113
8114
8115
8116
8117
8118
8119 function BackgroundColorItem(_ref) {
8120 let {
8121 name,
8122 parentMenu
8123 } = _ref;
8124 const supports = getSupportedGlobalStylesPanels(name);
8125 const hasSupport = supports.includes('backgroundColor') || supports.includes('background');
8126 const [backgroundColor] = useStyle('color.background', name);
8127 const [gradientValue] = useStyle('color.gradient', name);
8128
8129 if (!hasSupport) {
8130 return null;
8131 }
8132
8133 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8134 path: parentMenu + '/colors/background'
8135 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8136 justify: "flex-start"
8137 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
8138 expanded: false
8139 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
8140 colorValue: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor
8141 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Background'))));
8142 }
8143
8144 function TextColorItem(_ref2) {
8145 let {
8146 name,
8147 parentMenu
8148 } = _ref2;
8149 const supports = getSupportedGlobalStylesPanels(name);
8150 const hasSupport = supports.includes('color');
8151 const [color] = useStyle('color.text', name);
8152
8153 if (!hasSupport) {
8154 return null;
8155 }
8156
8157 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8158 path: parentMenu + '/colors/text'
8159 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8160 justify: "flex-start"
8161 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
8162 expanded: false
8163 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
8164 colorValue: color
8165 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Text'))));
8166 }
8167
8168 function LinkColorItem(_ref3) {
8169 let {
8170 name,
8171 parentMenu
8172 } = _ref3;
8173 const supports = getSupportedGlobalStylesPanels(name);
8174 const hasSupport = supports.includes('linkColor');
8175 const [color] = useStyle('elements.link.color.text', name);
8176
8177 if (!hasSupport) {
8178 return null;
8179 }
8180
8181 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8182 path: parentMenu + '/colors/link'
8183 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8184 justify: "flex-start"
8185 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
8186 expanded: false
8187 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
8188 colorValue: color
8189 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Links'))));
8190 }
8191
8192 function ScreenColors(_ref4) {
8193 let {
8194 name
8195 } = _ref4;
8196 const parentMenu = name === undefined ? '' : '/blocks/' + name;
8197 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8198 title: (0,external_wp_i18n_namespaceObject.__)('Colors'),
8199 description: (0,external_wp_i18n_namespaceObject.__)('Manage palettes and the default color of different global elements on the site.')
8200 }), (0,external_wp_element_namespaceObject.createElement)("div", {
8201 className: "edit-site-global-styles-screen-colors"
8202 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8203 spacing: 10
8204 }, (0,external_wp_element_namespaceObject.createElement)(palette, {
8205 name: name
8206 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8207 spacing: 3
8208 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
8209 isBordered: true,
8210 isSeparated: true
8211 }, (0,external_wp_element_namespaceObject.createElement)(BackgroundColorItem, {
8212 name: name,
8213 parentMenu: parentMenu
8214 }), (0,external_wp_element_namespaceObject.createElement)(TextColorItem, {
8215 name: name,
8216 parentMenu: parentMenu
8217 }), (0,external_wp_element_namespaceObject.createElement)(LinkColorItem, {
8218 name: name,
8219 parentMenu: parentMenu
8220 }))))));
8221 }
8222
8223 /* harmony default export */ const screen_colors = (ScreenColors);
8224
8225 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-palette-panel.js
8226
8227
8228 /**
8229 * WordPress dependencies
8230 */
8231
8232
8233 /**
8234 * Internal dependencies
8235 */
8236
8237
8238 function ColorPalettePanel(_ref) {
8239 let {
8240 name
8241 } = _ref;
8242 const [themeColors, setThemeColors] = useSetting('color.palette.theme', name);
8243 const [baseThemeColors] = useSetting('color.palette.theme', name, 'base');
8244 const [defaultColors, setDefaultColors] = useSetting('color.palette.default', name);
8245 const [baseDefaultColors] = useSetting('color.palette.default', name, 'base');
8246 const [customColors, setCustomColors] = useSetting('color.palette.custom', name);
8247 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
8248 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8249 className: "edit-site-global-styles-color-palette-panel",
8250 spacing: 10
8251 }, !!themeColors && !!themeColors.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8252 canReset: themeColors !== baseThemeColors,
8253 canOnlyChangeValues: true,
8254 colors: themeColors,
8255 onChange: setThemeColors,
8256 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
8257 }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8258 canReset: defaultColors !== baseDefaultColors,
8259 canOnlyChangeValues: true,
8260 colors: defaultColors,
8261 onChange: setDefaultColors,
8262 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
8263 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8264 colors: customColors,
8265 onChange: setCustomColors,
8266 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
8267 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom colors are empty! Add some colors to create your own color palette.'),
8268 slugPrefix: "custom-"
8269 }));
8270 }
8271
8272 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/gradients-palette-panel.js
8273
8274
8275 /**
8276 * WordPress dependencies
8277 */
8278
8279
8280 /**
8281 * Internal dependencies
8282 */
8283
8284
8285
8286
8287 const gradients_palette_panel_noop = () => {};
8288
8289 function GradientPalettePanel(_ref) {
8290 let {
8291 name
8292 } = _ref;
8293 const [themeGradients, setThemeGradients] = useSetting('color.gradients.theme', name);
8294 const [baseThemeGradients] = useSetting('color.gradients.theme', name, 'base');
8295 const [defaultGradients, setDefaultGradients] = useSetting('color.gradients.default', name);
8296 const [baseDefaultGradients] = useSetting('color.gradients.default', name, 'base');
8297 const [customGradients, setCustomGradients] = useSetting('color.gradients.custom', name);
8298 const [defaultPaletteEnabled] = useSetting('color.defaultGradients', name);
8299 const [duotonePalette] = useSetting('color.duotone') || [];
8300 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8301 className: "edit-site-global-styles-gradient-palette-panel",
8302 spacing: 10
8303 }, !!themeGradients && !!themeGradients.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8304 canReset: themeGradients !== baseThemeGradients,
8305 canOnlyChangeValues: true,
8306 gradients: themeGradients,
8307 onChange: setThemeGradients,
8308 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
8309 }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8310 canReset: defaultGradients !== baseDefaultGradients,
8311 canOnlyChangeValues: true,
8312 gradients: defaultGradients,
8313 onChange: setDefaultGradients,
8314 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
8315 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
8316 gradients: customGradients,
8317 onChange: setCustomGradients,
8318 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
8319 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom gradients are empty! Add some gradients to create your own palette.'),
8320 slugPrefix: "custom-"
8321 }), (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Duotone')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
8322 margin: 3
8323 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, {
8324 duotonePalette: duotonePalette,
8325 disableCustomDuotone: true,
8326 disableCustomColors: true,
8327 clearable: false,
8328 onChange: gradients_palette_panel_noop
8329 })));
8330 }
8331
8332 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-color-palette.js
8333
8334
8335 /**
8336 * WordPress dependencies
8337 */
8338
8339
8340
8341 /**
8342 * Internal dependencies
8343 */
8344
8345
8346
8347
8348
8349 function ScreenColorPalette(_ref) {
8350 let {
8351 name
8352 } = _ref;
8353 const [currentTab, setCurrentTab] = (0,external_wp_element_namespaceObject.useState)('solid');
8354 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8355 title: (0,external_wp_i18n_namespaceObject.__)('Palette'),
8356 description: (0,external_wp_i18n_namespaceObject.__)('Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.')
8357 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, {
8358 className: "edit-site-screen-color-palette-toggle",
8359 value: currentTab,
8360 onChange: setCurrentTab,
8361 label: (0,external_wp_i18n_namespaceObject.__)('Select palette type'),
8362 hideLabelFromVision: true,
8363 isBlock: true
8364 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
8365 value: "solid",
8366 label: (0,external_wp_i18n_namespaceObject.__)('Solid')
8367 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
8368 value: "gradient",
8369 label: (0,external_wp_i18n_namespaceObject.__)('Gradient')
8370 })), currentTab === 'solid' && (0,external_wp_element_namespaceObject.createElement)(ColorPalettePanel, {
8371 name: name
8372 }), currentTab === 'gradient' && (0,external_wp_element_namespaceObject.createElement)(GradientPalettePanel, {
8373 name: name
8374 }));
8375 }
8376
8377 /* harmony default export */ const screen_color_palette = (ScreenColorPalette);
8378
8379 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-background-color.js
8380
8381
8382
8383 /**
8384 * WordPress dependencies
8385 */
8386
8387
8388 /**
8389 * Internal dependencies
8390 */
8391
8392
8393
8394
8395 function ScreenBackgroundColor(_ref) {
8396 let {
8397 name
8398 } = _ref;
8399 const supports = getSupportedGlobalStylesPanels(name);
8400 const [solids] = useSetting('color.palette', name);
8401 const [gradients] = useSetting('color.gradients', name);
8402 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
8403 const [areCustomGradientsEnabled] = useSetting('color.customGradient', name);
8404 const colorsPerOrigin = useColorsPerOrigin(name);
8405 const gradientsPerOrigin = useGradientsPerOrigin(name);
8406 const [isBackgroundEnabled] = useSetting('color.background', name);
8407 const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
8408 const hasGradientColor = supports.includes('background') && (gradients.length > 0 || areCustomGradientsEnabled);
8409 const [backgroundColor, setBackgroundColor] = useStyle('color.background', name);
8410 const [userBackgroundColor] = useStyle('color.background', name, 'user');
8411 const [gradient, setGradient] = useStyle('color.gradient', name);
8412 const [userGradient] = useStyle('color.gradient', name, 'user');
8413
8414 if (!hasBackgroundColor && !hasGradientColor) {
8415 return null;
8416 }
8417
8418 let backgroundSettings = {};
8419
8420 if (hasBackgroundColor) {
8421 backgroundSettings = {
8422 colorValue: backgroundColor,
8423 onColorChange: setBackgroundColor
8424 };
8425
8426 if (backgroundColor) {
8427 backgroundSettings.clearable = backgroundColor === userBackgroundColor;
8428 }
8429 }
8430
8431 let gradientSettings = {};
8432
8433 if (hasGradientColor) {
8434 gradientSettings = {
8435 gradientValue: gradient,
8436 onGradientChange: setGradient
8437 };
8438
8439 if (gradient) {
8440 gradientSettings.clearable = gradient === userGradient;
8441 }
8442 }
8443
8444 const controlProps = { ...backgroundSettings,
8445 ...gradientSettings
8446 };
8447 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8448 title: (0,external_wp_i18n_namespaceObject.__)('Background'),
8449 description: (0,external_wp_i18n_namespaceObject.__)('Set a background color or gradient for the whole site.')
8450 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, extends_extends({
8451 className: "edit-site-screen-background-color__control",
8452 colors: colorsPerOrigin,
8453 gradients: gradientsPerOrigin,
8454 disableCustomColors: !areCustomSolidsEnabled,
8455 disableCustomGradients: !areCustomGradientsEnabled,
8456 __experimentalHasMultipleOrigins: true,
8457 showTitle: false,
8458 enableAlpha: true,
8459 __experimentalIsRenderedInSidebar: true
8460 }, controlProps)));
8461 }
8462
8463 /* harmony default export */ const screen_background_color = (ScreenBackgroundColor);
8464
8465 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-text-color.js
8466
8467
8468 /**
8469 * WordPress dependencies
8470 */
8471
8472
8473 /**
8474 * Internal dependencies
8475 */
8476
8477
8478
8479
8480 function ScreenTextColor(_ref) {
8481 let {
8482 name
8483 } = _ref;
8484 const supports = getSupportedGlobalStylesPanels(name);
8485 const [solids] = useSetting('color.palette', name);
8486 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
8487 const [isTextEnabled] = useSetting('color.text', name);
8488 const colorsPerOrigin = useColorsPerOrigin(name);
8489 const hasTextColor = supports.includes('color') && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
8490 const [color, setColor] = useStyle('color.text', name);
8491 const [userColor] = useStyle('color.text', name, 'user');
8492
8493 if (!hasTextColor) {
8494 return null;
8495 }
8496
8497 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8498 title: (0,external_wp_i18n_namespaceObject.__)('Text'),
8499 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for text across the site.')
8500 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
8501 className: "edit-site-screen-text-color__control",
8502 colors: colorsPerOrigin,
8503 disableCustomColors: !areCustomSolidsEnabled,
8504 __experimentalHasMultipleOrigins: true,
8505 showTitle: false,
8506 enableAlpha: true,
8507 __experimentalIsRenderedInSidebar: true,
8508 colorValue: color,
8509 onColorChange: setColor,
8510 clearable: color === userColor
8511 }));
8512 }
8513
8514 /* harmony default export */ const screen_text_color = (ScreenTextColor);
8515
8516 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-link-color.js
8517
8518
8519 /**
8520 * WordPress dependencies
8521 */
8522
8523
8524 /**
8525 * Internal dependencies
8526 */
8527
8528
8529
8530
8531 function ScreenLinkColor(_ref) {
8532 let {
8533 name
8534 } = _ref;
8535 const supports = getSupportedGlobalStylesPanels(name);
8536 const [solids] = useSetting('color.palette', name);
8537 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
8538 const colorsPerOrigin = useColorsPerOrigin(name);
8539 const [isLinkEnabled] = useSetting('color.link', name);
8540 const hasLinkColor = supports.includes('linkColor') && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
8541 const [linkColor, setLinkColor] = useStyle('elements.link.color.text', name);
8542 const [userLinkColor] = useStyle('elements.link.color.text', name, 'user');
8543
8544 if (!hasLinkColor) {
8545 return null;
8546 }
8547
8548 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8549 title: (0,external_wp_i18n_namespaceObject.__)('Links'),
8550 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for links across the site.')
8551 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
8552 className: "edit-site-screen-link-color__control",
8553 colors: colorsPerOrigin,
8554 disableCustomColors: !areCustomSolidsEnabled,
8555 __experimentalHasMultipleOrigins: true,
8556 showTitle: false,
8557 enableAlpha: true,
8558 __experimentalIsRenderedInSidebar: true,
8559 colorValue: linkColor,
8560 onColorChange: setLinkColor,
8561 clearable: linkColor === userLinkColor
8562 }));
8563 }
8564
8565 /* harmony default export */ const screen_link_color = (ScreenLinkColor);
8566
8567 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-layout.js
8568
8569
8570 /**
8571 * WordPress dependencies
8572 */
8573
8574 /**
8575 * Internal dependencies
8576 */
8577
8578
8579
8580
8581
8582 function ScreenLayout(_ref) {
8583 let {
8584 name
8585 } = _ref;
8586 const hasBorderPanel = useHasBorderPanel(name);
8587 const hasDimensionsPanel = useHasDimensionsPanel(name);
8588 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8589 title: (0,external_wp_i18n_namespaceObject.__)('Layout')
8590 }), hasDimensionsPanel && (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, {
8591 name: name
8592 }), hasBorderPanel && (0,external_wp_element_namespaceObject.createElement)(BorderPanel, {
8593 name: name
8594 }));
8595 }
8596
8597 /* harmony default export */ const screen_layout = (ScreenLayout);
8598
8599 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/global-styles-provider.js
8600
8601
8602 /**
8603 * External dependencies
8604 */
8605
8606 /**
8607 * WordPress dependencies
8608 */
8609
8610
8611
8612
8613 /**
8614 * Internal dependencies
8615 */
8616
8617
8618
8619 function mergeTreesCustomizer(_, srcValue) {
8620 // We only pass as arrays the presets,
8621 // in which case we want the new array of values
8622 // to override the old array (no merging).
8623 if (Array.isArray(srcValue)) {
8624 return srcValue;
8625 }
8626 }
8627
8628 function mergeBaseAndUserConfigs(base, user) {
8629 return (0,external_lodash_namespaceObject.mergeWith)({}, base, user, mergeTreesCustomizer);
8630 }
8631
8632 const cleanEmptyObject = object => {
8633 if (!(0,external_lodash_namespaceObject.isObject)(object) || Array.isArray(object)) {
8634 return object;
8635 }
8636
8637 const cleanedNestedObjects = (0,external_lodash_namespaceObject.pickBy)((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject), external_lodash_namespaceObject.identity);
8638 return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
8639 };
8640
8641 function useGlobalStylesUserConfig() {
8642 const {
8643 globalStylesId,
8644 settings,
8645 styles
8646 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8647 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
8648
8649 const record = _globalStylesId ? select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
8650 return {
8651 globalStylesId: _globalStylesId,
8652 settings: record === null || record === void 0 ? void 0 : record.settings,
8653 styles: record === null || record === void 0 ? void 0 : record.styles
8654 };
8655 }, []);
8656 const {
8657 getEditedEntityRecord
8658 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
8659 const {
8660 editEntityRecord
8661 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8662 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
8663 return {
8664 settings: settings !== null && settings !== void 0 ? settings : {},
8665 styles: styles !== null && styles !== void 0 ? styles : {}
8666 };
8667 }, [settings, styles]);
8668 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(callback => {
8669 var _record$styles, _record$settings;
8670
8671 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
8672 const currentConfig = {
8673 styles: (_record$styles = record === null || record === void 0 ? void 0 : record.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
8674 settings: (_record$settings = record === null || record === void 0 ? void 0 : record.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
8675 };
8676 const updatedConfig = callback(currentConfig);
8677 editEntityRecord('root', 'globalStyles', globalStylesId, {
8678 styles: cleanEmptyObject(updatedConfig.styles) || {},
8679 settings: cleanEmptyObject(updatedConfig.settings) || {}
8680 });
8681 }, [globalStylesId]);
8682 return [!!settings || !!styles, config, setConfig];
8683 }
8684
8685 function useGlobalStylesBaseConfig() {
8686 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
8687 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles();
8688 }, []);
8689 return [!!baseConfig, baseConfig];
8690 }
8691
8692 function useGlobalStylesContext() {
8693 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
8694 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
8695 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
8696 if (!baseConfig || !userConfig) {
8697 return {};
8698 }
8699
8700 return mergeBaseAndUserConfigs(baseConfig, userConfig);
8701 }, [userConfig, baseConfig]);
8702 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
8703 return {
8704 isReady: isUserConfigReady && isBaseConfigReady,
8705 user: userConfig,
8706 base: baseConfig,
8707 merged: mergedConfig,
8708 setUserConfig
8709 };
8710 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
8711 return context;
8712 }
8713
8714 function GlobalStylesProvider(_ref) {
8715 let {
8716 children
8717 } = _ref;
8718 const context = useGlobalStylesContext();
8719
8720 if (!context.isReady) {
8721 return null;
8722 }
8723
8724 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
8725 value: context
8726 }, children);
8727 }
8728
8729 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-style-variations.js
8730
8731
8732 /**
8733 * External dependencies
8734 */
8735
8736
8737 /**
8738 * WordPress dependencies
8739 */
8740
8741
8742
8743
8744
8745
8746
8747 /**
8748 * Internal dependencies
8749 */
8750
8751
8752
8753
8754
8755
8756 function compareVariations(a, b) {
8757 return (0,external_lodash_namespaceObject.isEqual)(a.styles, b.styles) && (0,external_lodash_namespaceObject.isEqual)(a.settings, b.settings);
8758 }
8759
8760 function Variation(_ref) {
8761 let {
8762 variation
8763 } = _ref;
8764 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
8765 const {
8766 base,
8767 user,
8768 setUserConfig
8769 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
8770 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
8771 var _variation$settings, _variation$styles;
8772
8773 return {
8774 user: {
8775 settings: (_variation$settings = variation.settings) !== null && _variation$settings !== void 0 ? _variation$settings : {},
8776 styles: (_variation$styles = variation.styles) !== null && _variation$styles !== void 0 ? _variation$styles : {}
8777 },
8778 base,
8779 merged: mergeBaseAndUserConfigs(base, variation),
8780 setUserConfig: () => {}
8781 };
8782 }, [variation, base]);
8783
8784 const selectVariation = () => {
8785 setUserConfig(() => {
8786 return {
8787 settings: variation.settings,
8788 styles: variation.styles
8789 };
8790 });
8791 };
8792
8793 const selectOnEnter = event => {
8794 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
8795 event.preventDefault();
8796 selectVariation();
8797 }
8798 };
8799
8800 const isActive = (0,external_wp_element_namespaceObject.useMemo)(() => {
8801 return compareVariations(user, variation);
8802 }, [user, variation]);
8803 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
8804 value: context
8805 }, (0,external_wp_element_namespaceObject.createElement)("div", {
8806 className: classnames_default()('edit-site-global-styles-variations_item', {
8807 'is-active': isActive
8808 }),
8809 role: "button",
8810 onClick: selectVariation,
8811 onKeyDown: selectOnEnter,
8812 tabIndex: "0",
8813 "aria-label": variation === null || variation === void 0 ? void 0 : variation.title,
8814 "aria-current": isActive,
8815 onFocus: () => setIsFocused(true),
8816 onBlur: () => setIsFocused(false)
8817 }, (0,external_wp_element_namespaceObject.createElement)("div", {
8818 className: "edit-site-global-styles-variations_item-preview"
8819 }, (0,external_wp_element_namespaceObject.createElement)(preview, {
8820 label: variation === null || variation === void 0 ? void 0 : variation.title,
8821 isFocused: isFocused
8822 }))));
8823 }
8824
8825 function ScreenStyleVariations() {
8826 const {
8827 variations
8828 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8829 return {
8830 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()
8831 };
8832 }, []);
8833 const withEmptyVariation = (0,external_wp_element_namespaceObject.useMemo)(() => {
8834 return [{
8835 title: (0,external_wp_i18n_namespaceObject.__)('Default'),
8836 settings: {},
8837 styles: {}
8838 }, ...variations.map(variation => {
8839 var _variation$settings2, _variation$styles2;
8840
8841 return { ...variation,
8842 settings: (_variation$settings2 = variation.settings) !== null && _variation$settings2 !== void 0 ? _variation$settings2 : {},
8843 styles: (_variation$styles2 = variation.styles) !== null && _variation$styles2 !== void 0 ? _variation$styles2 : {}
8844 };
8845 })];
8846 }, [variations]);
8847 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8848 back: "/",
8849 title: (0,external_wp_i18n_namespaceObject.__)('Browse styles'),
8850 description: (0,external_wp_i18n_namespaceObject.__)('Choose a different style combination for the theme styles')
8851 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
8852 size: "small",
8853 isBorderless: true
8854 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalGrid, {
8855 columns: 2
8856 }, withEmptyVariation === null || withEmptyVariation === void 0 ? void 0 : withEmptyVariation.map((variation, index) => (0,external_wp_element_namespaceObject.createElement)(Variation, {
8857 key: index,
8858 variation: variation
8859 }))))));
8860 }
8861
8862 /* harmony default export */ const screen_style_variations = (ScreenStyleVariations);
8863
8864 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/ui.js
8865
8866
8867
8868 /**
8869 * WordPress dependencies
8870 */
8871
8872
8873 /**
8874 * Internal dependencies
8875 */
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890 function GlobalStylesNavigationScreen(_ref) {
8891 let {
8892 className,
8893 ...props
8894 } = _ref;
8895 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, extends_extends({
8896 className: ['edit-site-global-styles-sidebar__navigator-screen', className].filter(Boolean).join(' ')
8897 }, props));
8898 }
8899
8900 function ContextScreens(_ref2) {
8901 let {
8902 name
8903 } = _ref2;
8904 const parentMenu = name === undefined ? '' : '/blocks/' + name;
8905 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8906 path: parentMenu + '/typography'
8907 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography, {
8908 name: name
8909 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8910 path: parentMenu + '/typography/text'
8911 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
8912 name: name,
8913 element: "text"
8914 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8915 path: parentMenu + '/typography/link'
8916 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
8917 name: name,
8918 element: "link"
8919 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8920 path: parentMenu + '/colors'
8921 }, (0,external_wp_element_namespaceObject.createElement)(screen_colors, {
8922 name: name
8923 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8924 path: parentMenu + '/colors/palette'
8925 }, (0,external_wp_element_namespaceObject.createElement)(screen_color_palette, {
8926 name: name
8927 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8928 path: parentMenu + '/colors/background'
8929 }, (0,external_wp_element_namespaceObject.createElement)(screen_background_color, {
8930 name: name
8931 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8932 path: parentMenu + '/colors/text'
8933 }, (0,external_wp_element_namespaceObject.createElement)(screen_text_color, {
8934 name: name
8935 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8936 path: parentMenu + '/colors/link'
8937 }, (0,external_wp_element_namespaceObject.createElement)(screen_link_color, {
8938 name: name
8939 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8940 path: parentMenu + '/layout'
8941 }, (0,external_wp_element_namespaceObject.createElement)(screen_layout, {
8942 name: name
8943 })));
8944 }
8945
8946 function GlobalStylesUI() {
8947 const blocks = (0,external_wp_blocks_namespaceObject.getBlockTypes)();
8948 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
8949 className: "edit-site-global-styles-sidebar__navigator-provider",
8950 initialPath: "/"
8951 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8952 path: "/"
8953 }, (0,external_wp_element_namespaceObject.createElement)(screen_root, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8954 path: "/variations"
8955 }, (0,external_wp_element_namespaceObject.createElement)(screen_style_variations, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8956 path: "/blocks"
8957 }, (0,external_wp_element_namespaceObject.createElement)(screen_block_list, null)), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8958 key: 'menu-block-' + block.name,
8959 path: '/blocks/' + block.name
8960 }, (0,external_wp_element_namespaceObject.createElement)(screen_block, {
8961 name: block.name
8962 }))), (0,external_wp_element_namespaceObject.createElement)(ContextScreens, null), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(ContextScreens, {
8963 key: 'screens-block-' + block.name,
8964 name: block.name
8965 })));
8966 }
8967
8968 /* harmony default export */ const ui = (GlobalStylesUI);
8969
8970 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/index.js
8971
8972
8973
8974
8975 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/global-styles-sidebar.js
8976
8977
8978 /**
8979 * WordPress dependencies
8980 */
8981
8982
8983
8984
8985
8986 /**
8987 * Internal dependencies
8988 */
8989
8990
8991
8992 function GlobalStylesSidebar() {
8993 const [canReset, onReset] = useGlobalStylesReset();
8994 const {
8995 toggle
8996 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
8997 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
8998 className: "edit-site-global-styles-sidebar",
8999 identifier: "edit-site/global-styles",
9000 title: (0,external_wp_i18n_namespaceObject.__)('Styles'),
9001 icon: library_styles,
9002 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close global styles sidebar'),
9003 panelClassName: "edit-site-global-styles-sidebar__panel",
9004 header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_wp_element_namespaceObject.createElement)("span", {
9005 className: "edit-site-global-styles-sidebar__beta"
9006 }, (0,external_wp_i18n_namespaceObject.__)('Beta'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
9007 icon: more_vertical,
9008 label: (0,external_wp_i18n_namespaceObject.__)('More Global Styles Actions'),
9009 controls: [{
9010 title: (0,external_wp_i18n_namespaceObject.__)('Reset to defaults'),
9011 onClick: onReset,
9012 isDisabled: !canReset
9013 }, {
9014 title: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'),
9015 onClick: () => toggle('core/edit-site', 'welcomeGuideStyles')
9016 }]
9017 })))
9018 }, (0,external_wp_element_namespaceObject.createElement)(ui, null));
9019 }
9020
9021 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
9022
9023
9024 /**
9025 * WordPress dependencies
9026 */
9027
9028 const navigation = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9029 viewBox: "0 0 24 24",
9030 xmlns: "http://www.w3.org/2000/svg"
9031 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9032 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
9033 }));
9034 /* harmony default export */ const library_navigation = (navigation);
9035
9036 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js
9037
9038
9039 /**
9040 * WordPress dependencies
9041 */
9042
9043
9044
9045 const ALLOWED_BLOCKS = {
9046 'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
9047 'core/social-links': ['core/social-link'],
9048 'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
9049 'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
9050 };
9051 function NavigationMenu(_ref) {
9052 let {
9053 innerBlocks,
9054 id
9055 } = _ref;
9056 const {
9057 updateBlockListSettings
9058 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
9059 //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
9060
9061 (0,external_wp_element_namespaceObject.useEffect)(() => {
9062 updateBlockListSettings('', {
9063 allowedBlocks: ALLOWED_BLOCKS['core/navigation']
9064 });
9065 innerBlocks.forEach(block => {
9066 if (ALLOWED_BLOCKS[block.name]) {
9067 updateBlockListSettings(block.clientId, {
9068 allowedBlocks: ALLOWED_BLOCKS[block.name]
9069 });
9070 }
9071 });
9072 }, [updateBlockListSettings, innerBlocks]);
9073 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
9074 id: id
9075 }));
9076 }
9077
9078 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js
9079
9080
9081 /**
9082 * WordPress dependencies
9083 */
9084
9085
9086
9087
9088
9089
9090
9091
9092 /**
9093 * Internal dependencies
9094 */
9095
9096
9097 const NAVIGATION_MENUS_QUERY = [{
9098 per_page: -1,
9099 status: 'publish'
9100 }];
9101 function NavigationInspector() {
9102 var _navigationMenus$;
9103
9104 const {
9105 selectedNavigationBlockId,
9106 clientIdToRef,
9107 navigationMenus,
9108 isResolvingNavigationMenus,
9109 hasResolvedNavigationMenus,
9110 firstNavigationBlockId
9111 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9112 const {
9113 __experimentalGetActiveBlockIdByBlockNames,
9114 __experimentalGetGlobalBlocksByName,
9115 getBlock
9116 } = select(external_wp_blockEditor_namespaceObject.store);
9117 const {
9118 getEntityRecords,
9119 hasFinishedResolution,
9120 isResolving
9121 } = select(external_wp_coreData_namespaceObject.store);
9122 const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
9123
9124 const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
9125
9126
9127 const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
9128
9129 const idToRef = {};
9130 navBlockIds.forEach(id => {
9131 var _getBlock, _getBlock$attributes;
9132
9133 idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
9134 });
9135 return {
9136 selectedNavigationBlockId: selectedNavId,
9137 firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
9138 clientIdToRef: idToRef,
9139 navigationMenus: getEntityRecords(...navigationMenusQuery),
9140 isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
9141 hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
9142 };
9143 }, []);
9144 const navMenuListId = (0,external_wp_compose_namespaceObject.useInstanceId)(NavigationMenu, 'edit-site-navigation-inspector-menu');
9145 const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
9146 const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
9147 // - the Navigation Menu referenced by the first Nav block within the template.
9148 // - the first of the available Navigation Menus (`wp_navigation`) posts.
9149
9150 const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
9151
9152 const [currentMenuId, setCurrentMenuId] = (0,external_wp_element_namespaceObject.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
9153 // Navigation Menu referenced by it's `ref` attribute to be
9154 // active within the Navigation sidebar.
9155
9156 (0,external_wp_element_namespaceObject.useEffect)(() => {
9157 if (selectedNavigationBlockId) {
9158 setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
9159 }
9160 }, [selectedNavigationBlockId]);
9161 let options = [];
9162
9163 if (navigationMenus) {
9164 options = navigationMenus.map(_ref => {
9165 let {
9166 id,
9167 title
9168 } = _ref;
9169 return {
9170 value: id,
9171 label: title.rendered
9172 };
9173 });
9174 }
9175
9176 const [innerBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', 'wp_navigation', {
9177 id: currentMenuId || defaultNavigationMenuId
9178 });
9179 const {
9180 isLoadingInnerBlocks,
9181 hasLoadedInnerBlocks
9182 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9183 const {
9184 isResolving,
9185 hasFinishedResolution
9186 } = select(external_wp_coreData_namespaceObject.store);
9187 return {
9188 isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
9189 hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
9190 };
9191 }, [currentMenuId, defaultNavigationMenuId]);
9192 const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
9193 const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
9194 const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
9195 // Guard by only allowing their usage if there are published Nav Menus.
9196
9197 const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
9198 const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
9199 (0,external_wp_element_namespaceObject.useEffect)(() => {
9200 if (isResolvingNavigationMenus) {
9201 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar menus.');
9202 }
9203
9204 if (hasResolvedNavigationMenus) {
9205 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar menus have loaded.');
9206 }
9207 }, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
9208 (0,external_wp_element_namespaceObject.useEffect)(() => {
9209 if (isLoadingInnerBlocks) {
9210 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar selected menu items.');
9211 }
9212
9213 if (hasLoadedInnerBlocks) {
9214 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar selected menu items have loaded.');
9215 }
9216 }, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
9217 return (0,external_wp_element_namespaceObject.createElement)("div", {
9218 className: "edit-site-navigation-inspector"
9219 }, hasResolvedNavigationMenus && !hasNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("p", {
9220 className: "edit-site-navigation-inspector__empty-msg"
9221 }, (0,external_wp_i18n_namespaceObject.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("div", {
9222 className: "edit-site-navigation-inspector__placeholder"
9223 }), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
9224 "aria-controls": // aria-controls should only apply when referenced element is in DOM
9225 hasLoadedInnerBlocks ? navMenuListId : undefined,
9226 value: currentMenuId || defaultNavigationMenuId,
9227 options: options,
9228 onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
9229 }), isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
9230 className: "edit-site-navigation-inspector__placeholder is-child"
9231 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9232 className: "edit-site-navigation-inspector__placeholder is-child"
9233 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9234 className: "edit-site-navigation-inspector__placeholder is-child"
9235 })), hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
9236 value: publishedInnerBlocks,
9237 onChange: onChange,
9238 onInput: onInput
9239 }, (0,external_wp_element_namespaceObject.createElement)(NavigationMenu, {
9240 id: navMenuListId,
9241 innerBlocks: publishedInnerBlocks
9242 })), !hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)("p", {
9243 className: "edit-site-navigation-inspector__empty-msg"
9244 }, (0,external_wp_i18n_namespaceObject.__)('Navigation Menu is empty.')));
9245 }
9246
9247 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/index.js
9248
9249
9250 /**
9251 * WordPress dependencies
9252 */
9253
9254
9255
9256 /**
9257 * Internal dependencies
9258 */
9259
9260
9261
9262 function NavigationMenuSidebar() {
9263 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
9264 className: "edit-site-navigation-menu-sidebar",
9265 identifier: "edit-site/navigation-menu",
9266 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
9267 icon: library_navigation,
9268 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close navigation menu sidebar'),
9269 panelClassName: "edit-site-navigation-menu-sidebar__panel",
9270 header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Navigation Menus')), (0,external_wp_element_namespaceObject.createElement)("span", {
9271 className: "edit-site-navigation-sidebar__beta"
9272 }, (0,external_wp_i18n_namespaceObject.__)('Beta'))))
9273 }, (0,external_wp_element_namespaceObject.createElement)(NavigationInspector, null));
9274 }
9275
9276 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/constants.js
9277 const SIDEBAR_TEMPLATE = 'edit-site/template';
9278 const SIDEBAR_BLOCK = 'edit-site/block-inspector';
9279
9280 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/settings-header/index.js
9281
9282
9283 /**
9284 * WordPress dependencies
9285 */
9286
9287
9288
9289
9290 /**
9291 * Internal dependencies
9292 */
9293
9294
9295
9296
9297 const SettingsHeader = _ref => {
9298 let {
9299 sidebarName
9300 } = _ref;
9301 const {
9302 enableComplementaryArea
9303 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
9304
9305 const openTemplateSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE);
9306
9307 const openBlockSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
9308
9309 const [templateAriaLabel, templateActiveClass] = sidebarName === SIDEBAR_TEMPLATE ? // translators: ARIA label for the Template sidebar tab, selected.
9310 [(0,external_wp_i18n_namespaceObject.__)('Template (selected)'), 'is-active'] : // translators: ARIA label for the Template Settings Sidebar tab, not selected.
9311 [(0,external_wp_i18n_namespaceObject.__)('Template'), ''];
9312 const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
9313 [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
9314 [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
9315 /* Use a list so screen readers will announce how many tabs there are. */
9316
9317 return (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9318 onClick: openTemplateSettings,
9319 className: `edit-site-sidebar__panel-tab ${templateActiveClass}`,
9320 "aria-label": templateAriaLabel // translators: Data label for the Template Settings Sidebar tab.
9321 ,
9322 "data-label": (0,external_wp_i18n_namespaceObject.__)('Template')
9323 }, // translators: Text label for the Template Settings Sidebar tab.
9324 (0,external_wp_i18n_namespaceObject.__)('Template'))), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9325 onClick: openBlockSettings,
9326 className: `edit-site-sidebar__panel-tab ${blockActiveClass}`,
9327 "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
9328 ,
9329 "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
9330 }, // translators: Text label for the Block Settings Sidebar tab.
9331 (0,external_wp_i18n_namespaceObject.__)('Block'))));
9332 };
9333
9334 /* harmony default export */ const settings_header = (SettingsHeader);
9335
9336 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/template-card/template-areas.js
9337
9338
9339 /**
9340 * WordPress dependencies
9341 */
9342
9343
9344
9345
9346
9347 /**
9348 * Internal dependencies
9349 */
9350
9351
9352
9353 function TemplateAreaItem(_ref) {
9354 let {
9355 area,
9356 clientId
9357 } = _ref;
9358 const {
9359 selectBlock,
9360 toggleBlockHighlight
9361 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
9362 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
9363 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
9364
9365 return defaultAreas.find(defaultArea => defaultArea.area === area);
9366 }, [area]);
9367
9368 const highlightBlock = () => toggleBlockHighlight(clientId, true);
9369
9370 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
9371
9372 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9373 className: "edit-site-template-card__template-areas-item",
9374 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
9375 onMouseOver: highlightBlock,
9376 onMouseLeave: cancelHighlightBlock,
9377 onFocus: highlightBlock,
9378 onBlur: cancelHighlightBlock,
9379 onClick: () => {
9380 selectBlock(clientId);
9381 }
9382 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label);
9383 }
9384
9385 function template_areas_TemplateAreas() {
9386 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
9387
9388 if (!templateParts.length) {
9389 return null;
9390 }
9391
9392 return (0,external_wp_element_namespaceObject.createElement)("section", {
9393 className: "edit-site-template-card__template-areas"
9394 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
9395 level: 3,
9396 className: "edit-site-template-card__template-areas-title"
9397 }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_wp_element_namespaceObject.createElement)("ul", {
9398 className: "edit-site-template-card__template-areas-list"
9399 }, templateParts.map(_ref2 => {
9400 let {
9401 templatePart,
9402 block
9403 } = _ref2;
9404 return (0,external_wp_element_namespaceObject.createElement)("li", {
9405 key: templatePart.slug
9406 }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreaItem, {
9407 area: templatePart.area,
9408 clientId: block.clientId
9409 }));
9410 })));
9411 }
9412
9413 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/template-card/index.js
9414
9415
9416 /**
9417 * WordPress dependencies
9418 */
9419
9420
9421
9422
9423 /**
9424 * Internal dependencies
9425 */
9426
9427
9428
9429 function TemplateCard() {
9430 const {
9431 title,
9432 description,
9433 icon
9434 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9435 const {
9436 getEditedPostType,
9437 getEditedPostId
9438 } = select(store_store);
9439 const {
9440 getEntityRecord
9441 } = select(external_wp_coreData_namespaceObject.store);
9442 const {
9443 __experimentalGetTemplateInfo: getTemplateInfo
9444 } = select(external_wp_editor_namespaceObject.store);
9445 const postType = getEditedPostType();
9446 const postId = getEditedPostId();
9447 const record = getEntityRecord('postType', postType, postId);
9448 const info = record ? getTemplateInfo(record) : {};
9449 return info;
9450 }, []);
9451
9452 if (!title && !description) {
9453 return null;
9454 }
9455
9456 return (0,external_wp_element_namespaceObject.createElement)("div", {
9457 className: "edit-site-template-card"
9458 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9459 className: "edit-site-template-card__icon",
9460 icon: icon
9461 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9462 className: "edit-site-template-card__content"
9463 }, (0,external_wp_element_namespaceObject.createElement)("h2", {
9464 className: "edit-site-template-card__title"
9465 }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
9466 className: "edit-site-template-card__description"
9467 }, description), (0,external_wp_element_namespaceObject.createElement)(template_areas_TemplateAreas, null)));
9468 }
9469
9470 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/index.js
9471
9472
9473 /**
9474 * WordPress dependencies
9475 */
9476
9477
9478
9479
9480
9481
9482
9483 /**
9484 * Internal dependencies
9485 */
9486
9487
9488
9489
9490
9491
9492
9493
9494 const {
9495 Slot: InspectorSlot,
9496 Fill: InspectorFill
9497 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteSidebarInspector');
9498 const SidebarInspectorFill = InspectorFill;
9499 function SidebarComplementaryAreaFills() {
9500 const {
9501 sidebar,
9502 isEditorSidebarOpened,
9503 hasBlockSelection
9504 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9505 const _sidebar = select(store).getActiveComplementaryArea(constants_STORE_NAME);
9506
9507 const _isEditorSidebarOpened = [SIDEBAR_BLOCK, SIDEBAR_TEMPLATE].includes(_sidebar);
9508
9509 return {
9510 sidebar: _sidebar,
9511 isEditorSidebarOpened: _isEditorSidebarOpened,
9512 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
9513 };
9514 }, []);
9515 const {
9516 enableComplementaryArea
9517 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
9518 (0,external_wp_element_namespaceObject.useEffect)(() => {
9519 if (!isEditorSidebarOpened) return;
9520
9521 if (hasBlockSelection) {
9522 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
9523 } else {
9524 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE);
9525 }
9526 }, [hasBlockSelection, isEditorSidebarOpened]);
9527 let sidebarName = sidebar;
9528
9529 if (!isEditorSidebarOpened) {
9530 sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
9531 } // Conditionally include NavMenu sidebar in Plugin only.
9532 // Optimise for dead code elimination.
9533 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
9534
9535
9536 let MaybeNavigationMenuSidebar = external_wp_element_namespaceObject.Fragment;
9537
9538 if (true) {
9539 MaybeNavigationMenuSidebar = NavigationMenuSidebar;
9540 }
9541
9542 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
9543 identifier: sidebarName,
9544 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
9545 icon: library_cog,
9546 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings sidebar'),
9547 header: (0,external_wp_element_namespaceObject.createElement)(settings_header, {
9548 sidebarName: sidebarName
9549 }),
9550 headerClassName: "edit-site-sidebar__panel-tabs"
9551 }, sidebarName === SIDEBAR_TEMPLATE && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(TemplateCard, null)), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(InspectorSlot, {
9552 bubblesVirtually: true
9553 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesSidebar, null), (0,external_wp_element_namespaceObject.createElement)(MaybeNavigationMenuSidebar, null));
9554 }
9555
9556 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
9557 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
9558 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/home.js
9559
9560
9561 /**
9562 * WordPress dependencies
9563 */
9564
9565 const home = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9566 xmlns: "http://www.w3.org/2000/svg",
9567 viewBox: "0 0 24 24"
9568 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9569 d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z"
9570 }));
9571 /* harmony default export */ const library_home = (home);
9572
9573 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
9574
9575
9576 /**
9577 * WordPress dependencies
9578 */
9579
9580 const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9581 xmlns: "http://www.w3.org/2000/svg",
9582 viewBox: "0 0 24 24"
9583 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9584 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
9585 }));
9586 /* harmony default export */ const symbol_filled = (symbolFilled);
9587
9588 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/main-dashboard-button/index.js
9589
9590
9591 /**
9592 * WordPress dependencies
9593 */
9594
9595 const slotName = '__experimentalMainDashboardButton';
9596 const {
9597 Fill,
9598 Slot: MainDashboardButtonSlot
9599 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
9600 const MainDashboardButton = Fill;
9601
9602 const main_dashboard_button_Slot = _ref => {
9603 let {
9604 children
9605 } = _ref;
9606 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(slotName);
9607 const hasFills = Boolean(slot.fills && slot.fills.length);
9608
9609 if (!hasFills) {
9610 return children;
9611 }
9612
9613 return (0,external_wp_element_namespaceObject.createElement)(MainDashboardButtonSlot, {
9614 bubblesVirtually: true
9615 });
9616 };
9617
9618 MainDashboardButton.Slot = main_dashboard_button_Slot;
9619 /* harmony default export */ const main_dashboard_button = (MainDashboardButton);
9620
9621 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/index.js
9622
9623
9624
9625 /**
9626 * External dependencies
9627 */
9628
9629 /**
9630 * WordPress dependencies
9631 */
9632
9633
9634
9635
9636
9637
9638
9639
9640 /**
9641 * Internal dependencies
9642 */
9643
9644
9645
9646
9647 const SITE_EDITOR_KEY = 'site-editor';
9648
9649 function NavLink(_ref) {
9650 let {
9651 params,
9652 replace,
9653 ...props
9654 } = _ref;
9655 const linkProps = useLink(params, replace);
9656 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationItem, extends_extends({}, linkProps, props));
9657 }
9658
9659 const NavigationPanel = _ref2 => {
9660 let {
9661 activeItem = SITE_EDITOR_KEY
9662 } = _ref2;
9663 const {
9664 homeTemplate,
9665 isNavigationOpen,
9666 siteTitle
9667 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9668 const {
9669 getEntityRecord
9670 } = select(external_wp_coreData_namespaceObject.store);
9671 const {
9672 getSettings,
9673 isNavigationOpened
9674 } = select(store_store);
9675 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
9676 return {
9677 siteTitle: siteData.name,
9678 homeTemplate: getSettings().__unstableHomeTemplate,
9679 isNavigationOpen: isNavigationOpened()
9680 };
9681 }, []);
9682 const {
9683 setIsNavigationPanelOpened
9684 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9685
9686 const closeOnEscape = event => {
9687 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
9688 event.preventDefault();
9689 setIsNavigationPanelOpened(false);
9690 }
9691 };
9692
9693 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
9694 (0,external_wp_element_namespaceObject.createElement)("div", {
9695 className: classnames_default()(`edit-site-navigation-panel`, {
9696 'is-open': isNavigationOpen
9697 }),
9698 onKeyDown: closeOnEscape
9699 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9700 className: "edit-site-navigation-panel__inner"
9701 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9702 className: "edit-site-navigation-panel__site-title-container"
9703 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9704 className: "edit-site-navigation-panel__site-title"
9705 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), (0,external_wp_element_namespaceObject.createElement)("div", {
9706 className: "edit-site-navigation-panel__scroll-container"
9707 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigation, {
9708 activeItem: activeItem
9709 }, (0,external_wp_element_namespaceObject.createElement)(main_dashboard_button.Slot, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationBackButton, {
9710 backButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Dashboard'),
9711 className: "edit-site-navigation-panel__back-to-dashboard",
9712 href: "index.php"
9713 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationMenu, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationGroup, {
9714 title: (0,external_wp_i18n_namespaceObject.__)('Editor')
9715 }, (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9716 icon: library_home,
9717 title: (0,external_wp_i18n_namespaceObject.__)('Site'),
9718 item: SITE_EDITOR_KEY,
9719 params: {
9720 postId: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postId,
9721 postType: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postType
9722 }
9723 }), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9724 icon: library_layout,
9725 title: (0,external_wp_i18n_namespaceObject.__)('Templates'),
9726 item: "wp_template",
9727 params: {
9728 postId: undefined,
9729 postType: 'wp_template'
9730 }
9731 }), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9732 icon: symbol_filled,
9733 title: (0,external_wp_i18n_namespaceObject.__)('Template Parts'),
9734 item: "wp_template_part",
9735 params: {
9736 postId: undefined,
9737 postType: 'wp_template_part'
9738 }
9739 })))))))
9740 );
9741 };
9742
9743 /* harmony default export */ const navigation_panel = (NavigationPanel);
9744
9745 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
9746
9747
9748 /**
9749 * WordPress dependencies
9750 */
9751
9752 const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9753 xmlns: "http://www.w3.org/2000/svg",
9754 viewBox: "-2 -2 24 24"
9755 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9756 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
9757 }));
9758 /* harmony default export */ const library_wordpress = (wordpress);
9759
9760 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-toggle/index.js
9761
9762
9763 /**
9764 * External dependencies
9765 */
9766
9767 /**
9768 * WordPress dependencies
9769 */
9770
9771
9772
9773
9774
9775
9776
9777
9778 /**
9779 * Internal dependencies
9780 */
9781
9782
9783
9784 function NavigationToggle(_ref) {
9785 let {
9786 icon
9787 } = _ref;
9788 const {
9789 isNavigationOpen,
9790 isRequestingSiteIcon,
9791 siteIconUrl
9792 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9793 const {
9794 getEntityRecord,
9795 isResolving
9796 } = select(external_wp_coreData_namespaceObject.store);
9797 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
9798 return {
9799 isNavigationOpen: select(store_store).isNavigationOpened(),
9800 isRequestingSiteIcon: isResolving('core', 'getEntityRecord', ['root', '__unstableBase', undefined]),
9801 siteIconUrl: siteData.site_icon_url
9802 };
9803 }, []);
9804 const {
9805 setIsNavigationPanelOpened
9806 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9807 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
9808 const navigationToggleRef = (0,external_wp_element_namespaceObject.useRef)();
9809 (0,external_wp_element_namespaceObject.useEffect)(() => {
9810 // TODO: Remove this effect when alternative solution is merged.
9811 // See: https://github.com/WordPress/gutenberg/pull/37314
9812 if (!isNavigationOpen) {
9813 navigationToggleRef.current.focus();
9814 }
9815 }, [isNavigationOpen]);
9816
9817 const toggleNavigationPanel = () => setIsNavigationPanelOpened(!isNavigationOpen);
9818
9819 let buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9820 size: "36px",
9821 icon: library_wordpress
9822 });
9823 const effect = {
9824 expand: {
9825 scale: 1.25,
9826 transition: {
9827 type: 'tween',
9828 duration: '0.3'
9829 }
9830 }
9831 };
9832
9833 if (siteIconUrl) {
9834 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.img, {
9835 variants: !disableMotion && effect,
9836 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
9837 className: "edit-site-navigation-toggle__site-icon",
9838 src: siteIconUrl
9839 });
9840 } else if (isRequestingSiteIcon) {
9841 buttonIcon = null;
9842 } else if (icon) {
9843 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9844 size: "36px",
9845 icon: icon
9846 });
9847 }
9848
9849 const classes = classnames_default()({
9850 'edit-site-navigation-toggle__button': true,
9851 'has-icon': siteIconUrl
9852 });
9853 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
9854 className: 'edit-site-navigation-toggle' + (isNavigationOpen ? ' is-open' : ''),
9855 whileHover: "expand"
9856 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9857 className: classes,
9858 label: (0,external_wp_i18n_namespaceObject.__)('Toggle navigation'),
9859 ref: navigationToggleRef // isPressed will add unwanted styles.
9860 ,
9861 "aria-pressed": isNavigationOpen,
9862 onClick: toggleNavigationPanel,
9863 showTooltip: true
9864 }, buttonIcon));
9865 }
9866
9867 /* harmony default export */ const navigation_toggle = (NavigationToggle);
9868
9869 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/index.js
9870
9871
9872 /**
9873 * WordPress dependencies
9874 */
9875
9876
9877
9878
9879 /**
9880 * Internal dependencies
9881 */
9882
9883
9884
9885
9886 const {
9887 Fill: NavigationPanelPreviewFill,
9888 Slot: NavigationPanelPreviewSlot
9889 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationPanelPreview');
9890 const {
9891 Fill: NavigationSidebarFill,
9892 Slot: NavigationSidebarSlot
9893 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationSidebar');
9894
9895 function NavigationSidebar(_ref) {
9896 let {
9897 isDefaultOpen = false,
9898 activeTemplateType
9899 } = _ref;
9900 const isDesktopViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
9901 const {
9902 setIsNavigationPanelOpened
9903 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9904 (0,external_wp_element_namespaceObject.useEffect)(function autoOpenNavigationPanelOnViewportChange() {
9905 setIsNavigationPanelOpened(isDefaultOpen && isDesktopViewport);
9906 }, [isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened]);
9907 return (0,external_wp_element_namespaceObject.createElement)(NavigationSidebarFill, null, (0,external_wp_element_namespaceObject.createElement)(navigation_toggle, null), (0,external_wp_element_namespaceObject.createElement)(navigation_panel, {
9908 activeItem: activeTemplateType
9909 }), (0,external_wp_element_namespaceObject.createElement)(NavigationPanelPreviewSlot, null));
9910 }
9911
9912 NavigationSidebar.Slot = NavigationSidebarSlot;
9913 /* harmony default export */ const navigation_sidebar = (NavigationSidebar);
9914
9915 ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
9916 const external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
9917 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-regular.js
9918
9919
9920 /**
9921 * WordPress dependencies
9922 */
9923
9924
9925
9926
9927 function ConvertToRegularBlocks(_ref) {
9928 let {
9929 clientId
9930 } = _ref;
9931 const {
9932 getBlocks
9933 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
9934 const {
9935 replaceBlocks
9936 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
9937 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
9938
9939 if (!canRemove) {
9940 return null;
9941 }
9942
9943 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => {
9944 let {
9945 onClose
9946 } = _ref2;
9947 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
9948 onClick: () => {
9949 replaceBlocks(clientId, getBlocks(clientId));
9950 onClose();
9951 }
9952 }, (0,external_wp_i18n_namespaceObject.__)('Detach blocks from template part'));
9953 });
9954 }
9955
9956 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/create-template-part-modal/index.js
9957
9958
9959 /**
9960 * WordPress dependencies
9961 */
9962
9963
9964
9965
9966
9967
9968
9969 /**
9970 * Internal dependencies
9971 */
9972
9973
9974 function CreateTemplatePartModal(_ref) {
9975 let {
9976 closeModal,
9977 onCreate
9978 } = _ref;
9979 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
9980 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(TEMPLATE_PART_AREA_GENERAL);
9981 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
9982 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
9983 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []);
9984 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
9985 title: (0,external_wp_i18n_namespaceObject.__)('Create a template part'),
9986 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
9987 onRequestClose: closeModal,
9988 overlayClassName: "edit-site-create-template-part-modal"
9989 }, (0,external_wp_element_namespaceObject.createElement)("form", {
9990 onSubmit: async event => {
9991 event.preventDefault();
9992
9993 if (!title) {
9994 return;
9995 }
9996
9997 setIsSubmitting(true);
9998 await onCreate({
9999 title,
10000 area
10001 });
10002 }
10003 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
10004 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
10005 value: title,
10006 onChange: setTitle,
10007 required: true
10008 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
10009 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
10010 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
10011 className: "edit-site-create-template-part-modal__area-base-control"
10012 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
10013 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
10014 className: "edit-site-create-template-part-modal__area-radio-group",
10015 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
10016 onChange: setArea,
10017 checked: area
10018 }, templatePartAreas.map(_ref2 => {
10019 let {
10020 icon,
10021 label,
10022 area: value,
10023 description
10024 } = _ref2;
10025 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadio, {
10026 key: label,
10027 value: value,
10028 className: "edit-site-create-template-part-modal__area-radio"
10029 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
10030 align: "start",
10031 justify: "start"
10032 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
10033 icon: icon
10034 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, {
10035 className: "edit-site-create-template-part-modal__option-label"
10036 }, label, (0,external_wp_element_namespaceObject.createElement)("div", null, description)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
10037 className: "edit-site-create-template-part-modal__checkbox"
10038 }, area === value && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
10039 icon: library_check
10040 }))));
10041 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
10042 className: "edit-site-create-template-part-modal__modal-actions",
10043 justify: "flex-end"
10044 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10045 variant: "secondary",
10046 onClick: () => {
10047 closeModal();
10048 }
10049 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10050 variant: "primary",
10051 type: "submit",
10052 disabled: !title,
10053 isBusy: isSubmitting
10054 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))));
10055 }
10056
10057 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-template-part.js
10058
10059
10060 /**
10061 * External dependencies
10062 */
10063
10064 /**
10065 * WordPress dependencies
10066 */
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076 /**
10077 * Internal dependencies
10078 */
10079
10080
10081 function ConvertToTemplatePart(_ref) {
10082 let {
10083 clientIds,
10084 blocks
10085 } = _ref;
10086 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
10087 const {
10088 replaceBlocks
10089 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
10090 const {
10091 saveEntityRecord
10092 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
10093 const {
10094 createSuccessNotice
10095 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
10096
10097 const onConvert = async _ref2 => {
10098 let {
10099 title,
10100 area
10101 } = _ref2;
10102 // Currently template parts only allow latin chars.
10103 // Fallback slug will receive suffix by default.
10104 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
10105 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
10106 slug: cleanSlug,
10107 title,
10108 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
10109 area
10110 });
10111 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
10112 slug: templatePart.slug,
10113 theme: templatePart.theme
10114 }));
10115 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
10116 type: 'snackbar'
10117 }); // The modal and this component will be unmounted because of `replaceBlocks` above,
10118 // so no need to call `closeModal` or `onClose`.
10119 };
10120
10121 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
10122 onClick: () => {
10123 setIsModalOpen(true);
10124 }
10125 }, (0,external_wp_i18n_namespaceObject.__)('Make template part'))), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
10126 closeModal: () => {
10127 setIsModalOpen(false);
10128 },
10129 onCreate: onConvert
10130 }));
10131 }
10132
10133 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/index.js
10134
10135
10136 /**
10137 * WordPress dependencies
10138 */
10139
10140
10141 /**
10142 * Internal dependencies
10143 */
10144
10145
10146
10147 function TemplatePartConverter() {
10148 var _blocks$;
10149
10150 const {
10151 clientIds,
10152 blocks
10153 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10154 const {
10155 getSelectedBlockClientIds,
10156 getBlocksByClientId
10157 } = select(external_wp_blockEditor_namespaceObject.store);
10158 const selectedBlockClientIds = getSelectedBlockClientIds();
10159 return {
10160 clientIds: selectedBlockClientIds,
10161 blocks: getBlocksByClientId(selectedBlockClientIds)
10162 };
10163 }, []); // Allow converting a single template part to standard blocks.
10164
10165 if (blocks.length === 1 && ((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.name) === 'core/template-part') {
10166 return (0,external_wp_element_namespaceObject.createElement)(ConvertToRegularBlocks, {
10167 clientId: clientIds[0]
10168 });
10169 }
10170
10171 return (0,external_wp_element_namespaceObject.createElement)(ConvertToTemplatePart, {
10172 clientIds: clientIds,
10173 blocks: blocks
10174 });
10175 }
10176
10177 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
10178
10179
10180 /**
10181 * WordPress dependencies
10182 */
10183
10184 const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10185 xmlns: "http://www.w3.org/2000/svg",
10186 viewBox: "0 0 24 24"
10187 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10188 d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"
10189 }));
10190 /* harmony default export */ const library_pencil = (pencil);
10191
10192 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
10193 /**
10194 * Internal dependencies
10195 */
10196
10197 /* harmony default export */ const edit = (library_pencil);
10198
10199 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigate-to-link/index.js
10200
10201
10202 /**
10203 * WordPress dependencies
10204 */
10205
10206
10207
10208
10209
10210
10211
10212 function NavigateToLink(_ref) {
10213 let {
10214 type,
10215 id,
10216 activePage,
10217 onActivePageChange
10218 } = _ref;
10219 const post = (0,external_wp_data_namespaceObject.useSelect)(select => type && id && type !== 'URL' && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', type, id), [type, id]);
10220 const onClick = (0,external_wp_element_namespaceObject.useMemo)(() => {
10221 if (!(post !== null && post !== void 0 && post.link)) return null;
10222 const path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(post.link);
10223 if (path === (activePage === null || activePage === void 0 ? void 0 : activePage.path)) return null;
10224 return () => onActivePageChange({
10225 type,
10226 slug: post.slug,
10227 path,
10228 context: {
10229 postType: post.type,
10230 postId: post.id
10231 }
10232 });
10233 }, [post, activePage === null || activePage === void 0 ? void 0 : activePage.path, onActivePageChange]);
10234 return onClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10235 icon: edit,
10236 label: (0,external_wp_i18n_namespaceObject.__)('Edit Page Template'),
10237 onClick: onClick
10238 });
10239 }
10240
10241 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/block-inspector-button.js
10242
10243
10244 /**
10245 * WordPress dependencies
10246 */
10247
10248
10249
10250
10251
10252
10253 /**
10254 * Internal dependencies
10255 */
10256
10257
10258
10259
10260 function BlockInspectorButton(_ref) {
10261 let {
10262 onClick = () => {}
10263 } = _ref;
10264 const {
10265 shortcut,
10266 isBlockInspectorOpen
10267 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
10268 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-block-settings-sidebar'),
10269 isBlockInspectorOpen: select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK
10270 }), []);
10271 const {
10272 enableComplementaryArea,
10273 disableComplementaryArea
10274 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10275 const label = isBlockInspectorOpen ? (0,external_wp_i18n_namespaceObject.__)('Hide more settings') : (0,external_wp_i18n_namespaceObject.__)('Show more settings');
10276 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
10277 onClick: () => {
10278 if (isBlockInspectorOpen) {
10279 disableComplementaryArea(constants_STORE_NAME);
10280 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Block settings closed'));
10281 } else {
10282 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
10283 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Additional settings are now available in the Editor block settings sidebar'));
10284 } // Close dropdown menu.
10285
10286
10287 onClick();
10288 },
10289 shortcut: shortcut
10290 }, label);
10291 }
10292
10293 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/edit-template-part-menu-button/index.js
10294
10295
10296
10297 /**
10298 * WordPress dependencies
10299 */
10300
10301
10302
10303
10304
10305
10306 /**
10307 * Internal dependencies
10308 */
10309
10310
10311
10312 function EditTemplatePartMenuButton() {
10313 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref => {
10314 let {
10315 selectedClientIds,
10316 onClose
10317 } = _ref;
10318 return (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuItem, {
10319 selectedClientId: selectedClientIds[0],
10320 onClose: onClose
10321 });
10322 });
10323 }
10324
10325 function EditTemplatePartMenuItem(_ref2) {
10326 let {
10327 selectedClientId,
10328 onClose
10329 } = _ref2;
10330 const {
10331 params
10332 } = useLocation();
10333 const selectedTemplatePart = (0,external_wp_data_namespaceObject.useSelect)(select => {
10334 const block = select(external_wp_blockEditor_namespaceObject.store).getBlock(selectedClientId);
10335
10336 if (block && (0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) {
10337 const {
10338 theme,
10339 slug
10340 } = block.attributes;
10341 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template_part', // Ideally this should be an official public API.
10342 `${theme}//${slug}`);
10343 }
10344 }, [selectedClientId]);
10345 const linkProps = useLink({
10346 postId: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.id,
10347 postType: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.type
10348 }, {
10349 fromTemplateId: params.postId
10350 });
10351
10352 if (!selectedTemplatePart) {
10353 return null;
10354 }
10355
10356 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, extends_extends({}, linkProps, {
10357 onClick: event => {
10358 linkProps.onClick(event);
10359 onClose();
10360 }
10361 }),
10362 /* translators: %s: template part title */
10363 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Edit %s'), selectedTemplatePart.slug));
10364 }
10365
10366 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/arrow-left.js
10367
10368
10369 /**
10370 * WordPress dependencies
10371 */
10372
10373 const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10374 xmlns: "http://www.w3.org/2000/svg",
10375 viewBox: "0 0 24 24"
10376 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10377 d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z"
10378 }));
10379 /* harmony default export */ const arrow_left = (arrowLeft);
10380
10381 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/back-button.js
10382
10383
10384 /**
10385 * WordPress dependencies
10386 */
10387
10388
10389
10390 /**
10391 * Internal dependencies
10392 */
10393
10394
10395
10396 function BackButton() {
10397 var _location$state;
10398
10399 const location = useLocation();
10400 const history = useHistory();
10401 const isTemplatePart = location.params.postType === 'wp_template_part';
10402 const previousTemplateId = (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.fromTemplateId;
10403
10404 if (!isTemplatePart || !previousTemplateId) {
10405 return null;
10406 }
10407
10408 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10409 className: "edit-site-visual-editor__back-button",
10410 icon: arrow_left,
10411 onClick: () => {
10412 history.back();
10413 }
10414 }, (0,external_wp_i18n_namespaceObject.__)('Back'));
10415 }
10416
10417 /* harmony default export */ const back_button = (BackButton);
10418
10419 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resize-handle.js
10420
10421
10422 /**
10423 * WordPress dependencies
10424 */
10425
10426
10427
10428 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
10429
10430 function ResizeHandle(_ref) {
10431 let {
10432 direction,
10433 resizeWidthBy
10434 } = _ref;
10435
10436 function handleKeyDown(event) {
10437 const {
10438 keyCode
10439 } = event;
10440
10441 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
10442 resizeWidthBy(DELTA_DISTANCE);
10443 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
10444 resizeWidthBy(-DELTA_DISTANCE);
10445 }
10446 }
10447
10448 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("button", {
10449 className: `resizable-editor__drag-handle is-${direction}`,
10450 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
10451 "aria-describedby": `resizable-editor__resize-help-${direction}`,
10452 onKeyDown: handleKeyDown
10453 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
10454 id: `resizable-editor__resize-help-${direction}`
10455 }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')));
10456 }
10457
10458 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resizable-editor.js
10459
10460
10461
10462 /**
10463 * WordPress dependencies
10464 */
10465
10466
10467
10468
10469
10470 /**
10471 * Internal dependencies
10472 */
10473
10474
10475
10476 const DEFAULT_STYLES = {
10477 width: '100%',
10478 height: '100%'
10479 }; // Removes the inline styles in the drag handles.
10480
10481 const HANDLE_STYLES_OVERRIDE = {
10482 position: undefined,
10483 userSelect: undefined,
10484 cursor: undefined,
10485 width: undefined,
10486 height: undefined,
10487 top: undefined,
10488 right: undefined,
10489 bottom: undefined,
10490 left: undefined
10491 };
10492
10493 function ResizableEditor(_ref) {
10494 let {
10495 enableResizing,
10496 settings,
10497 children,
10498 ...props
10499 } = _ref;
10500 const deviceType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetPreviewDeviceType(), []);
10501 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
10502 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_STYLES.width);
10503 const [height, setHeight] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_STYLES.height);
10504 const iframeRef = (0,external_wp_element_namespaceObject.useRef)();
10505 const mouseMoveTypingResetRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseMouseMoveTypingReset)();
10506 const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([iframeRef, mouseMoveTypingResetRef]);
10507 (0,external_wp_element_namespaceObject.useEffect)(function autoResizeIframeHeight() {
10508 const iframe = iframeRef.current;
10509
10510 if (!iframe || !enableResizing) {
10511 return;
10512 }
10513
10514 let animationFrame = null;
10515
10516 function resizeHeight() {
10517 if (!animationFrame) {
10518 // Throttle the updates on animation frame.
10519 animationFrame = iframe.contentWindow.requestAnimationFrame(() => {
10520 setHeight(iframe.contentDocument.documentElement.scrollHeight);
10521 animationFrame = null;
10522 });
10523 }
10524 }
10525
10526 let resizeObserver;
10527
10528 function registerObserver() {
10529 var _resizeObserver;
10530
10531 (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
10532 resizeObserver = new iframe.contentWindow.ResizeObserver(resizeHeight); // Observing the <html> rather than the <body> because the latter
10533 // gets destroyed and remounted after initialization in <Iframe>.
10534
10535 resizeObserver.observe(iframe.contentDocument.documentElement);
10536 resizeHeight();
10537 } // This is only required in Firefox for some unknown reasons.
10538
10539
10540 iframe.addEventListener('load', registerObserver); // This is required in Chrome and Safari.
10541
10542 registerObserver();
10543 return () => {
10544 var _iframe$contentWindow, _resizeObserver2;
10545
10546 (_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : _iframe$contentWindow.cancelAnimationFrame(animationFrame);
10547 (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : _resizeObserver2.disconnect();
10548 iframe.removeEventListener('load', registerObserver);
10549 };
10550 }, [enableResizing]);
10551 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
10552 if (iframeRef.current) {
10553 setWidth(iframeRef.current.offsetWidth + deltaPixels);
10554 }
10555 }, []);
10556 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResizableBox, {
10557 size: {
10558 width,
10559 height
10560 },
10561 onResizeStop: (event, direction, element) => {
10562 setWidth(element.style.width);
10563 },
10564 minWidth: 300,
10565 maxWidth: "100%",
10566 maxHeight: "100%",
10567 enable: {
10568 right: enableResizing,
10569 left: enableResizing
10570 },
10571 showHandle: enableResizing // The editor is centered horizontally, resizing it only
10572 // moves half the distance. Hence double the ratio to correctly
10573 // align the cursor to the resizer handle.
10574 ,
10575 resizeRatio: 2,
10576 handleComponent: {
10577 left: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
10578 direction: "left",
10579 resizeWidthBy: resizeWidthBy
10580 }),
10581 right: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
10582 direction: "right",
10583 resizeWidthBy: resizeWidthBy
10584 })
10585 },
10586 handleClasses: undefined,
10587 handleStyles: {
10588 left: HANDLE_STYLES_OVERRIDE,
10589 right: HANDLE_STYLES_OVERRIDE
10590 }
10591 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, extends_extends({
10592 style: enableResizing ? undefined : deviceStyles,
10593 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
10594 styles: settings.styles
10595 }), (0,external_wp_element_namespaceObject.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
10596 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
10597 `.is-root-container { display: flow-root; }`), enableResizing && (0,external_wp_element_namespaceObject.createElement)("style", null, // Force the <html> and <body>'s heights to fit the content.
10598 `html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`, // Some themes will have `min-height: 100vh` for the root container,
10599 // which isn't a requirement in auto resize mode.
10600 `.is-root-container { min-height: 0 !important; }`)),
10601 assets: settings.__unstableResolvedAssets,
10602 ref: ref,
10603 name: "editor-canvas",
10604 className: "edit-site-visual-editor__editor-canvas"
10605 }, props), settings.svgFilters, children));
10606 }
10607
10608 /* harmony default export */ const resizable_editor = (ResizableEditor);
10609
10610 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/index.js
10611
10612
10613
10614 /**
10615 * External dependencies
10616 */
10617
10618
10619 /**
10620 * WordPress dependencies
10621 */
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633 /**
10634 * Internal dependencies
10635 */
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645 const LAYOUT = {
10646 type: 'default',
10647 // At the root level of the site editor, no alignments should be allowed.
10648 alignments: []
10649 };
10650 function BlockEditor(_ref) {
10651 var _storedSettings$__exp, _storedSettings$__exp2;
10652
10653 let {
10654 setIsInserterOpen
10655 } = _ref;
10656 const {
10657 storedSettings,
10658 templateType,
10659 templateId,
10660 page
10661 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10662 const {
10663 getSettings,
10664 getEditedPostType,
10665 getEditedPostId,
10666 getPage
10667 } = select(store_store);
10668 return {
10669 storedSettings: getSettings(setIsInserterOpen),
10670 templateType: getEditedPostType(),
10671 templateId: getEditedPostId(),
10672 page: getPage()
10673 };
10674 }, [setIsInserterOpen]);
10675 const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : // WP 6.0
10676 storedSettings.__experimentalBlockPatterns; // WP 5.9
10677
10678 const settingsBlockPatternCategories = (_storedSettings$__exp2 = storedSettings.__experimentalAdditionalBlockPatternCategories) !== null && _storedSettings$__exp2 !== void 0 ? _storedSettings$__exp2 : // WP 6.0
10679 storedSettings.__experimentalBlockPatternCategories; // WP 5.9
10680
10681 const {
10682 restBlockPatterns,
10683 restBlockPatternCategories
10684 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
10685 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
10686 restBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()
10687 }), []);
10688 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatterns, restBlockPatterns, 'name'), [settingsBlockPatterns, restBlockPatterns]);
10689 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatternCategories, restBlockPatternCategories, 'name'), [settingsBlockPatternCategories, restBlockPatternCategories]);
10690 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(0,external_lodash_namespaceObject.omit)(storedSettings, ['__experimentalAdditionalBlockPatterns', '__experimentalAdditionalBlockPatternCategories']),
10691 __experimentalBlockPatterns: blockPatterns,
10692 __experimentalBlockPatternCategories: blockPatternCategories
10693 }), [storedSettings, blockPatterns, blockPatternCategories]);
10694 const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType);
10695 const {
10696 setPage
10697 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10698 const {
10699 enableComplementaryArea
10700 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10701 const openNavigationSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
10702 enableComplementaryArea('core/edit-site', 'edit-site/navigation-menu');
10703 }, [enableComplementaryArea]);
10704 const contentRef = (0,external_wp_element_namespaceObject.useRef)();
10705 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)()]);
10706 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
10707 const {
10708 clearSelectedBlock
10709 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
10710 const isTemplatePart = templateType === 'wp_template_part';
10711 const hasBlocks = blocks.length !== 0;
10712
10713 const NavMenuSidebarToggle = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
10714 className: "components-toolbar__control",
10715 label: (0,external_wp_i18n_namespaceObject.__)('Open list view'),
10716 onClick: openNavigationSidebar,
10717 icon: list_view
10718 })); // Conditionally include NavMenu sidebar in Plugin only.
10719 // Optimise for dead code elimination.
10720 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
10721
10722
10723 let MaybeNavMenuSidebarToggle = external_wp_element_namespaceObject.Fragment;
10724
10725 if (true) {
10726 MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
10727 }
10728
10729 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
10730 settings: settings,
10731 value: blocks,
10732 onInput: onInput,
10733 onChange: onChange,
10734 useSubRegistry: false
10735 }, (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuButton, null), (0,external_wp_element_namespaceObject.createElement)(TemplatePartConverter, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl.ViewerFill, null, (0,external_wp_element_namespaceObject.useCallback)(fillProps => (0,external_wp_element_namespaceObject.createElement)(NavigateToLink, extends_extends({}, fillProps, {
10736 activePage: page,
10737 onActivePageChange: setPage
10738 })), [page])), (0,external_wp_element_namespaceObject.createElement)(SidebarInspectorFill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, {
10739 className: classnames_default()('edit-site-visual-editor', {
10740 'is-focus-mode': isTemplatePart
10741 }),
10742 __unstableContentRef: contentRef,
10743 onClick: event => {
10744 // Clear selected block when clicking on the gray background.
10745 if (event.target === event.currentTarget) {
10746 clearSelectedBlock();
10747 }
10748 }
10749 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(back_button, null), (0,external_wp_element_namespaceObject.createElement)(resizable_editor // Reinitialize the editor and reset the states when the template changes.
10750 , {
10751 key: templateId,
10752 enableResizing: isTemplatePart && // Disable resizing in mobile viewport.
10753 !isMobileViewport,
10754 settings: settings,
10755 contentRef: mergedRefs
10756 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
10757 className: "edit-site-block-editor__block-list wp-site-blocks",
10758 __experimentalLayout: LAYOUT,
10759 renderAppender: isTemplatePart && hasBlocks ? false : undefined
10760 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, null, _ref2 => {
10761 let {
10762 onClose
10763 } = _ref2;
10764 return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorButton, {
10765 onClick: onClose
10766 });
10767 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockToolbarLastItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockNameContext.Consumer, null, blockName => blockName === 'core/navigation' && (0,external_wp_element_namespaceObject.createElement)(MaybeNavMenuSidebarToggle, null)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, null));
10768 }
10769
10770 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
10771 var lib = __webpack_require__(773);
10772 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/code-editor-text-area.js
10773
10774
10775 /**
10776 * External dependencies
10777 */
10778
10779 /**
10780 * WordPress dependencies
10781 */
10782
10783
10784
10785
10786
10787 function CodeEditorTextArea(_ref) {
10788 let {
10789 value,
10790 onChange,
10791 onInput
10792 } = _ref;
10793 const [stateValue, setStateValue] = (0,external_wp_element_namespaceObject.useState)(value);
10794 const [isDirty, setIsDirty] = (0,external_wp_element_namespaceObject.useState)(false);
10795 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CodeEditorTextArea);
10796 const valueRef = (0,external_wp_element_namespaceObject.useRef)();
10797
10798 if (!isDirty && stateValue !== value) {
10799 setStateValue(value);
10800 }
10801 /**
10802 * Handles a textarea change event to notify the onChange prop callback and
10803 * reflect the new value in the component's own state. This marks the start
10804 * of the user's edits, if not already changed, preventing future props
10805 * changes to value from replacing the rendered value. This is expected to
10806 * be followed by a reset to dirty state via `stopEditing`.
10807 *
10808 * @see stopEditing
10809 *
10810 * @param {Event} event Change event.
10811 */
10812
10813
10814 const onChangeHandler = event => {
10815 const newValue = event.target.value;
10816 onInput(newValue);
10817 setStateValue(newValue);
10818 setIsDirty(true);
10819 valueRef.current = newValue;
10820 };
10821 /**
10822 * Function called when the user has completed their edits, responsible for
10823 * ensuring that changes, if made, are surfaced to the onPersist prop
10824 * callback and resetting dirty state.
10825 */
10826
10827
10828 const stopEditing = () => {
10829 if (isDirty) {
10830 onChange(stateValue);
10831 setIsDirty(false);
10832 }
10833 }; // Ensure changes aren't lost when component unmounts.
10834
10835
10836 (0,external_wp_element_namespaceObject.useEffect)(() => {
10837 return () => {
10838 if (valueRef.current) {
10839 onChange(valueRef.current);
10840 }
10841 };
10842 }, []);
10843 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
10844 as: "label",
10845 htmlFor: `code-editor-text-area-${instanceId}`
10846 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
10847 autoComplete: "off",
10848 dir: "auto",
10849 value: stateValue,
10850 onChange: onChangeHandler,
10851 onBlur: stopEditing,
10852 className: "edit-site-code-editor-text-area",
10853 id: `code-editor-text-area-${instanceId}`,
10854 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
10855 }));
10856 }
10857
10858 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/index.js
10859
10860
10861 /**
10862 * WordPress dependencies
10863 */
10864
10865
10866
10867
10868
10869
10870 /**
10871 * Internal dependencies
10872 */
10873
10874
10875
10876 function CodeEditor() {
10877 const {
10878 templateType,
10879 shortcut
10880 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10881 const {
10882 getEditedPostType
10883 } = select(store_store);
10884 const {
10885 getShortcutRepresentation
10886 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
10887 return {
10888 templateType: getEditedPostType(),
10889 shortcut: getShortcutRepresentation('core/edit-site/toggle-mode')
10890 };
10891 }, []);
10892 const [contentStructure, setContent] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', templateType, 'content');
10893 const [blocks,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType);
10894 const content = contentStructure instanceof Function ? contentStructure({
10895 blocks
10896 }) : contentStructure;
10897 const {
10898 switchEditorMode
10899 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10900 return (0,external_wp_element_namespaceObject.createElement)("div", {
10901 className: "edit-site-code-editor"
10902 }, (0,external_wp_element_namespaceObject.createElement)("div", {
10903 className: "edit-site-code-editor__toolbar"
10904 }, (0,external_wp_element_namespaceObject.createElement)("h2", null, (0,external_wp_i18n_namespaceObject.__)('Editing code')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10905 variant: "tertiary",
10906 onClick: () => switchEditorMode('visual'),
10907 shortcut: shortcut
10908 }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_wp_element_namespaceObject.createElement)("div", {
10909 className: "edit-site-code-editor__body"
10910 }, (0,external_wp_element_namespaceObject.createElement)(CodeEditorTextArea, {
10911 value: content,
10912 onChange: newContent => {
10913 onChange((0,external_wp_blocks_namespaceObject.parse)(newContent), {
10914 selection: undefined
10915 });
10916 },
10917 onInput: setContent
10918 })));
10919 }
10920
10921 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcuts/index.js
10922 /**
10923 * WordPress dependencies
10924 */
10925
10926
10927
10928
10929
10930
10931 /**
10932 * Internal dependencies
10933 */
10934
10935
10936
10937
10938
10939 function KeyboardShortcuts(_ref) {
10940 let {
10941 openEntitiesSavedStates
10942 } = _ref;
10943 const {
10944 __experimentalGetDirtyEntityRecords,
10945 isSavingEntityRecord
10946 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
10947 const {
10948 getEditorMode
10949 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
10950 const isListViewOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isListViewOpened(), []);
10951 const isBlockInspectorOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK, []);
10952 const {
10953 redo,
10954 undo
10955 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
10956 const {
10957 setIsListViewOpened,
10958 switchEditorMode
10959 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10960 const {
10961 enableComplementaryArea,
10962 disableComplementaryArea
10963 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10964 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => {
10965 event.preventDefault();
10966
10967 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
10968
10969 const isDirty = !!dirtyEntityRecords.length;
10970 const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key));
10971
10972 if (!isSaving && isDirty) {
10973 openEntitiesSavedStates();
10974 }
10975 });
10976 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/undo', event => {
10977 undo();
10978 event.preventDefault();
10979 });
10980 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/redo', event => {
10981 redo();
10982 event.preventDefault();
10983 });
10984 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-list-view', () => {
10985 setIsListViewOpened(!isListViewOpen);
10986 });
10987 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => {
10988 // This shortcut has no known clashes, but use preventDefault to prevent any
10989 // obscure shortcuts from triggering.
10990 event.preventDefault();
10991
10992 if (isBlockInspectorOpen) {
10993 disableComplementaryArea(constants_STORE_NAME);
10994 } else {
10995 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
10996 }
10997 });
10998 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-mode', () => {
10999 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
11000 });
11001 return null;
11002 }
11003
11004 function KeyboardShortcutsRegister() {
11005 // Registering the shortcuts.
11006 const {
11007 registerShortcut
11008 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
11009 (0,external_wp_element_namespaceObject.useEffect)(() => {
11010 registerShortcut({
11011 name: 'core/edit-site/save',
11012 category: 'global',
11013 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
11014 keyCombination: {
11015 modifier: 'primary',
11016 character: 's'
11017 }
11018 });
11019 registerShortcut({
11020 name: 'core/edit-site/undo',
11021 category: 'global',
11022 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
11023 keyCombination: {
11024 modifier: 'primary',
11025 character: 'z'
11026 }
11027 });
11028 registerShortcut({
11029 name: 'core/edit-site/redo',
11030 category: 'global',
11031 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
11032 keyCombination: {
11033 modifier: 'primaryShift',
11034 character: 'z'
11035 }
11036 });
11037 registerShortcut({
11038 name: 'core/edit-site/toggle-list-view',
11039 category: 'global',
11040 description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'),
11041 keyCombination: {
11042 modifier: 'access',
11043 character: 'o'
11044 }
11045 });
11046 registerShortcut({
11047 name: 'core/edit-site/toggle-block-settings-sidebar',
11048 category: 'global',
11049 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the block settings sidebar.'),
11050 keyCombination: {
11051 modifier: 'primaryShift',
11052 character: ','
11053 }
11054 });
11055 registerShortcut({
11056 name: 'core/edit-site/keyboard-shortcuts',
11057 category: 'main',
11058 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
11059 keyCombination: {
11060 modifier: 'access',
11061 character: 'h'
11062 }
11063 });
11064 registerShortcut({
11065 name: 'core/edit-site/next-region',
11066 category: 'global',
11067 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
11068 keyCombination: {
11069 modifier: 'ctrl',
11070 character: '`'
11071 },
11072 aliases: [{
11073 modifier: 'access',
11074 character: 'n'
11075 }]
11076 });
11077 registerShortcut({
11078 name: 'core/edit-site/previous-region',
11079 category: 'global',
11080 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
11081 keyCombination: {
11082 modifier: 'ctrlShift',
11083 character: '`'
11084 },
11085 aliases: [{
11086 modifier: 'access',
11087 character: 'p'
11088 }]
11089 });
11090 registerShortcut({
11091 name: 'core/edit-site/toggle-mode',
11092 category: 'global',
11093 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
11094 keyCombination: {
11095 modifier: 'secondary',
11096 character: 'm'
11097 }
11098 });
11099 }, [registerShortcut]);
11100 return null;
11101 }
11102
11103 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
11104 /* harmony default export */ const keyboard_shortcuts = (KeyboardShortcuts);
11105
11106 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/url-query-controller/index.js
11107 /**
11108 * WordPress dependencies
11109 */
11110
11111
11112 /**
11113 * Internal dependencies
11114 */
11115
11116
11117
11118 function URLQueryController() {
11119 const {
11120 setTemplate,
11121 setTemplatePart,
11122 setPage
11123 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11124 const {
11125 params: {
11126 postId,
11127 postType
11128 }
11129 } = useLocation(); // Set correct entity on page navigation.
11130
11131 (0,external_wp_element_namespaceObject.useEffect)(() => {
11132 if ('page' === postType || 'post' === postType) {
11133 setPage({
11134 context: {
11135 postType,
11136 postId
11137 }
11138 }); // Resolves correct template based on ID.
11139 } else if ('wp_template' === postType) {
11140 setTemplate(postId);
11141 } else if ('wp_template_part' === postType) {
11142 setTemplatePart(postId);
11143 }
11144 }, [postId, postType]);
11145 return null;
11146 }
11147
11148 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
11149
11150
11151 /**
11152 * WordPress dependencies
11153 */
11154
11155 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11156 xmlns: "http://www.w3.org/2000/svg",
11157 viewBox: "0 0 24 24"
11158 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11159 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
11160 }));
11161 /* harmony default export */ const library_close = (close_close);
11162
11163 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/inserter-sidebar.js
11164
11165
11166
11167 /**
11168 * WordPress dependencies
11169 */
11170
11171
11172
11173
11174
11175
11176
11177 /**
11178 * Internal dependencies
11179 */
11180
11181
11182 function InserterSidebar() {
11183 const {
11184 setIsInserterOpened
11185 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11186 const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetInsertionPoint(), []);
11187 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
11188 const TagName = !isMobile ? external_wp_components_namespaceObject.VisuallyHidden : 'div';
11189 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
11190 onClose: () => setIsInserterOpened(false),
11191 focusOnMount: null
11192 });
11193 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
11194 (0,external_wp_element_namespaceObject.useEffect)(() => {
11195 libraryRef.current.focusSearch();
11196 }, []);
11197 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({
11198 ref: inserterDialogRef
11199 }, inserterDialogProps, {
11200 className: "edit-site-editor__inserter-panel"
11201 }), (0,external_wp_element_namespaceObject.createElement)(TagName, {
11202 className: "edit-site-editor__inserter-panel-header"
11203 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11204 icon: library_close,
11205 label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'),
11206 onClick: () => setIsInserterOpened(false)
11207 })), (0,external_wp_element_namespaceObject.createElement)("div", {
11208 className: "edit-site-editor__inserter-panel-content"
11209 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
11210 showInserterHelpPanel: true,
11211 shouldFocusBlock: isMobile,
11212 rootClientId: insertionPoint.rootClientId,
11213 __experimentalInsertionIndex: insertionPoint.insertionIndex,
11214 __experimentalFilterValue: insertionPoint.filterValue,
11215 ref: libraryRef
11216 })));
11217 }
11218
11219 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/list-view-sidebar.js
11220
11221
11222 /**
11223 * WordPress dependencies
11224 */
11225
11226
11227
11228
11229
11230
11231
11232 /**
11233 * Internal dependencies
11234 */
11235
11236
11237 function ListViewSidebar() {
11238 const {
11239 setIsListViewOpened
11240 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11241 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
11242 const headerFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
11243 const contentFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
11244
11245 function closeOnEscape(event) {
11246 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
11247 setIsListViewOpened(false);
11248 }
11249 }
11250
11251 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar);
11252 const labelId = `edit-site-editor__list-view-panel-label-${instanceId}`;
11253 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
11254 (0,external_wp_element_namespaceObject.createElement)("div", {
11255 "aria-labelledby": labelId,
11256 className: "edit-site-editor__list-view-panel",
11257 onKeyDown: closeOnEscape
11258 }, (0,external_wp_element_namespaceObject.createElement)("div", {
11259 className: "edit-site-editor__list-view-panel-header",
11260 ref: headerFocusReturnRef
11261 }, (0,external_wp_element_namespaceObject.createElement)("strong", {
11262 id: labelId
11263 }, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11264 icon: close_small,
11265 label: (0,external_wp_i18n_namespaceObject.__)('Close List View Sidebar'),
11266 onClick: () => setIsListViewOpened(false)
11267 })), (0,external_wp_element_namespaceObject.createElement)("div", {
11268 className: "edit-site-editor__list-view-panel-content",
11269 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
11270 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, null)))
11271 );
11272 }
11273
11274 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/warning.js
11275
11276
11277 /**
11278 * WordPress dependencies
11279 */
11280
11281
11282
11283
11284
11285 function CopyButton(_ref) {
11286 let {
11287 text,
11288 children
11289 } = _ref;
11290 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
11291 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11292 variant: "secondary",
11293 ref: ref
11294 }, children);
11295 }
11296
11297 function ErrorBoundaryWarning(_ref2) {
11298 let {
11299 message,
11300 error,
11301 reboot,
11302 dashboardLink
11303 } = _ref2;
11304 const actions = [];
11305
11306 if (reboot) {
11307 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11308 key: "recovery",
11309 onClick: reboot,
11310 variant: "secondary"
11311 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')));
11312 }
11313
11314 if (error) {
11315 actions.push((0,external_wp_element_namespaceObject.createElement)(CopyButton, {
11316 key: "copy-error",
11317 text: error.stack
11318 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error')));
11319 }
11320
11321 if (dashboardLink) {
11322 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11323 key: "back-to-dashboard",
11324 variant: "secondary",
11325 href: dashboardLink
11326 }, (0,external_wp_i18n_namespaceObject.__)('Back to dashboard')));
11327 }
11328
11329 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
11330 className: "editor-error-boundary",
11331 actions: actions
11332 }, message);
11333 }
11334
11335 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/index.js
11336
11337
11338 /**
11339 * WordPress dependencies
11340 */
11341
11342
11343 /**
11344 * Internal dependencies
11345 */
11346
11347
11348 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
11349 constructor() {
11350 super(...arguments);
11351 this.reboot = this.reboot.bind(this);
11352 this.state = {
11353 error: null
11354 };
11355 }
11356
11357 static getDerivedStateFromError(error) {
11358 return {
11359 error
11360 };
11361 }
11362
11363 reboot() {
11364 this.props.onError();
11365 }
11366
11367 render() {
11368 const {
11369 error
11370 } = this.state;
11371
11372 if (!error) {
11373 return this.props.children;
11374 }
11375
11376 return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
11377 message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'),
11378 error: error,
11379 reboot: this.reboot
11380 });
11381 }
11382
11383 }
11384
11385 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/image.js
11386
11387 function WelcomeGuideImage(_ref) {
11388 let {
11389 nonAnimatedSrc,
11390 animatedSrc
11391 } = _ref;
11392 return (0,external_wp_element_namespaceObject.createElement)("picture", {
11393 className: "edit-site-welcome-guide__image"
11394 }, (0,external_wp_element_namespaceObject.createElement)("source", {
11395 srcSet: nonAnimatedSrc,
11396 media: "(prefers-reduced-motion: reduce)"
11397 }), (0,external_wp_element_namespaceObject.createElement)("img", {
11398 src: animatedSrc,
11399 width: "312",
11400 height: "240",
11401 alt: ""
11402 }));
11403 }
11404
11405 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/editor.js
11406
11407
11408 /**
11409 * WordPress dependencies
11410 */
11411
11412
11413
11414
11415
11416 /**
11417 * Internal dependencies
11418 */
11419
11420
11421 function WelcomeGuideEditor() {
11422 const {
11423 toggle
11424 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
11425 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), []);
11426
11427 if (!isActive) {
11428 return null;
11429 }
11430
11431 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
11432 className: "edit-site-welcome-guide",
11433 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the site editor'),
11434 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
11435 onFinish: () => toggle('core/edit-site', 'welcomeGuide'),
11436 pages: [{
11437 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11438 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1",
11439 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1"
11440 }),
11441 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11442 className: "edit-site-welcome-guide__heading"
11443 }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_wp_element_namespaceObject.createElement)("p", {
11444 className: "edit-site-welcome-guide__text"
11445 }, (0,external_wp_i18n_namespaceObject.__)('Design everything on your site — from the header right down to the footer — using blocks.')), (0,external_wp_element_namespaceObject.createElement)("p", {
11446 className: "edit-site-welcome-guide__text"
11447 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'), {
11448 StylesIconImage: (0,external_wp_element_namespaceObject.createElement)("img", {
11449 alt: (0,external_wp_i18n_namespaceObject.__)('styles'),
11450 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A"
11451 })
11452 })))
11453 }]
11454 });
11455 }
11456
11457 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/styles.js
11458
11459
11460 /**
11461 * WordPress dependencies
11462 */
11463
11464
11465
11466
11467
11468 /**
11469 * Internal dependencies
11470 */
11471
11472
11473
11474 function WelcomeGuideStyles() {
11475 const {
11476 toggle
11477 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
11478 const {
11479 isActive,
11480 isStylesOpen
11481 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11482 const sidebar = select(store).getActiveComplementaryArea(store_store.name);
11483 return {
11484 isActive: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideStyles'),
11485 isStylesOpen: sidebar === 'edit-site/global-styles'
11486 };
11487 }, []);
11488
11489 if (!isActive || !isStylesOpen) {
11490 return null;
11491 }
11492
11493 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
11494 className: "edit-site-welcome-guide",
11495 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to styles'),
11496 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
11497 onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'),
11498 pages: [{
11499 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11500 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
11501 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
11502 }),
11503 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11504 className: "edit-site-welcome-guide__heading"
11505 }, (0,external_wp_i18n_namespaceObject.__)('Welcome to Styles')), (0,external_wp_element_namespaceObject.createElement)("p", {
11506 className: "edit-site-welcome-guide__text"
11507 }, (0,external_wp_i18n_namespaceObject.__)('Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.')))
11508 }, {
11509 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11510 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1",
11511 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1"
11512 }),
11513 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11514 className: "edit-site-welcome-guide__heading"
11515 }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_wp_element_namespaceObject.createElement)("p", {
11516 className: "edit-site-welcome-guide__text"
11517 }, (0,external_wp_i18n_namespaceObject.__)('You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle! ')))
11518 }, {
11519 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11520 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1",
11521 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1"
11522 }),
11523 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11524 className: "edit-site-welcome-guide__heading"
11525 }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_wp_element_namespaceObject.createElement)("p", {
11526 className: "edit-site-welcome-guide__text"
11527 }, (0,external_wp_i18n_namespaceObject.__)('You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.')))
11528 }, {
11529 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11530 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
11531 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
11532 }),
11533 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11534 className: "edit-site-welcome-guide__heading"
11535 }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_wp_element_namespaceObject.createElement)("p", {
11536 className: "edit-site-welcome-guide__text"
11537 }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
11538 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/styles-overview/')
11539 }, (0,external_wp_i18n_namespaceObject.__)('Here’s a detailed guide to learn how to make the most of it.'))))
11540 }]
11541 });
11542 }
11543
11544 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/index.js
11545
11546
11547 /**
11548 * Internal dependencies
11549 */
11550
11551
11552 function WelcomeGuide() {
11553 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideEditor, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideStyles, null));
11554 }
11555
11556 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/global-styles-renderer.js
11557 /**
11558 * External dependencies
11559 */
11560
11561 /**
11562 * WordPress dependencies
11563 */
11564
11565
11566
11567 /**
11568 * Internal dependencies
11569 */
11570
11571
11572 /**
11573 * Internal dependencies
11574 */
11575
11576
11577
11578 function useGlobalStylesRenderer() {
11579 const [styles, settings, svgFilters] = useGlobalStylesOutput();
11580 const {
11581 getSettings
11582 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
11583 const {
11584 updateSettings
11585 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11586 (0,external_wp_element_namespaceObject.useEffect)(() => {
11587 if (!styles || !settings) {
11588 return;
11589 }
11590
11591 const currentStoreSettings = getSettings();
11592 const nonGlobalStyles = (0,external_lodash_namespaceObject.filter)(currentStoreSettings.styles, style => !style.isGlobalStyles);
11593 updateSettings({ ...currentStoreSettings,
11594 styles: [...nonGlobalStyles, ...styles],
11595 svgFilters,
11596 __experimentalFeatures: settings
11597 });
11598 }, [styles, settings]);
11599 }
11600
11601 function GlobalStylesRenderer() {
11602 useGlobalStylesRenderer();
11603 return null;
11604 }
11605
11606 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/use-title.js
11607 /**
11608 * WordPress dependencies
11609 */
11610
11611
11612
11613
11614
11615
11616 /**
11617 * Internal dependencies
11618 */
11619
11620
11621 function useTitle(title) {
11622 const location = useLocation();
11623 const siteTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
11624 var _select$getEntityReco;
11625
11626 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.title;
11627 }, []);
11628 const isInitialLocationRef = (0,external_wp_element_namespaceObject.useRef)(true);
11629 (0,external_wp_element_namespaceObject.useEffect)(() => {
11630 isInitialLocationRef.current = false;
11631 }, [location]);
11632 (0,external_wp_element_namespaceObject.useEffect)(() => {
11633 // Don't update or announce the title for initial page load.
11634 if (isInitialLocationRef.current) {
11635 return;
11636 }
11637
11638 if (title && siteTitle) {
11639 // @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
11640 const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)(
11641 /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
11642 (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s — WordPress'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle));
11643 document.title = formattedTitle; // Announce title on route change for screen readers.
11644
11645 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)(
11646 /* translators: The page title that is currently displaying. */
11647 (0,external_wp_i18n_namespaceObject.__)('Now displaying: %s'), document.title), 'assertive');
11648 }
11649 }, [title, siteTitle, location]);
11650 }
11651
11652 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/index.js
11653
11654
11655 /**
11656 * WordPress dependencies
11657 */
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668 /**
11669 * Internal dependencies
11670 */
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687 const interfaceLabels = {
11688 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar')
11689 };
11690
11691 function Editor(_ref) {
11692 let {
11693 onError
11694 } = _ref;
11695 const {
11696 isInserterOpen,
11697 isListViewOpen,
11698 sidebarIsOpened,
11699 settings,
11700 entityId,
11701 templateType,
11702 page,
11703 template,
11704 templateResolved,
11705 isNavigationOpen,
11706 previousShortcut,
11707 nextShortcut,
11708 editorMode,
11709 showIconLabels
11710 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11711 const {
11712 isInserterOpened,
11713 isListViewOpened,
11714 getSettings,
11715 getEditedPostType,
11716 getEditedPostId,
11717 getPage,
11718 isNavigationOpened,
11719 getEditorMode
11720 } = select(store_store);
11721 const {
11722 hasFinishedResolution,
11723 getEntityRecord
11724 } = select(external_wp_coreData_namespaceObject.store);
11725 const postType = getEditedPostType();
11726 const postId = getEditedPostId(); // The currently selected entity to display. Typically template or template part.
11727
11728 return {
11729 isInserterOpen: isInserterOpened(),
11730 isListViewOpen: isListViewOpened(),
11731 sidebarIsOpened: !!select(store).getActiveComplementaryArea(store_store.name),
11732 settings: getSettings(),
11733 templateType: postType,
11734 page: getPage(),
11735 template: postId ? getEntityRecord('postType', postType, postId) : null,
11736 templateResolved: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
11737 entityId: postId,
11738 isNavigationOpen: isNavigationOpened(),
11739 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
11740 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
11741 editorMode: getEditorMode(),
11742 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showIconLabels')
11743 };
11744 }, []);
11745 const {
11746 setPage,
11747 setIsInserterOpened
11748 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11749 const {
11750 enableComplementaryArea
11751 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
11752 const [isEntitiesSavedStatesOpen, setIsEntitiesSavedStatesOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11753 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setIsEntitiesSavedStatesOpen(true), []);
11754 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => {
11755 setIsEntitiesSavedStatesOpen(false);
11756 }, []);
11757 const blockContext = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(page === null || page === void 0 ? void 0 : page.context),
11758 queryContext: [(page === null || page === void 0 ? void 0 : page.context.queryContext) || {
11759 page: 1
11760 }, newQueryContext => setPage({ ...page,
11761 context: { ...(page === null || page === void 0 ? void 0 : page.context),
11762 queryContext: { ...(page === null || page === void 0 ? void 0 : page.context.queryContext),
11763 ...newQueryContext
11764 }
11765 }
11766 })]
11767 }), [page === null || page === void 0 ? void 0 : page.context]);
11768 (0,external_wp_element_namespaceObject.useEffect)(() => {
11769 if (isNavigationOpen) {
11770 document.body.classList.add('is-navigation-sidebar-open');
11771 } else {
11772 document.body.classList.remove('is-navigation-sidebar-open');
11773 }
11774 }, [isNavigationOpen]);
11775 (0,external_wp_element_namespaceObject.useEffect)(function openGlobalStylesOnLoad() {
11776 const searchParams = new URLSearchParams(window.location.search);
11777
11778 if (searchParams.get('styles') === 'open') {
11779 enableComplementaryArea('core/edit-site', 'edit-site/global-styles');
11780 }
11781 }, [enableComplementaryArea]); // Don't render the Editor until the settings are set and loaded.
11782
11783 const isReady = (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && templateType !== undefined && entityId !== undefined;
11784 const secondarySidebarLabel = isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
11785
11786 const secondarySidebar = () => {
11787 if (editorMode === 'visual' && isInserterOpen) {
11788 return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null);
11789 }
11790
11791 if (editorMode === 'visual' && isListViewOpen) {
11792 return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null);
11793 }
11794
11795 return null;
11796 }; // Only announce the title once the editor is ready to prevent "Replace"
11797 // action in <URlQueryController> from double-announcing.
11798
11799
11800 useTitle(isReady && (0,external_wp_i18n_namespaceObject.__)('Editor (beta)'));
11801 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(URLQueryController, null), isReady && (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
11802 kind: "root",
11803 type: "site"
11804 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
11805 kind: "postType",
11806 type: templateType,
11807 id: entityId
11808 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
11809 value: blockContext
11810 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesRenderer, null), (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, {
11811 onError: onError
11812 }, (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(SidebarComplementaryAreaFills, null), (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
11813 labels: { ...interfaceLabels,
11814 secondarySidebar: secondarySidebarLabel
11815 },
11816 className: showIconLabels && 'show-icon-labels',
11817 secondarySidebar: secondarySidebar(),
11818 sidebar: sidebarIsOpened && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
11819 scope: "core/edit-site"
11820 }),
11821 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
11822 header: (0,external_wp_element_namespaceObject.createElement)(Header, {
11823 openEntitiesSavedStates: openEntitiesSavedStates,
11824 showIconLabels: showIconLabels
11825 }),
11826 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
11827 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockStyles.Slot, {
11828 scope: "core/block-inspector"
11829 }), editorMode === 'visual' && template && (0,external_wp_element_namespaceObject.createElement)(BlockEditor, {
11830 setIsInserterOpen: setIsInserterOpened
11831 }), editorMode === 'text' && template && (0,external_wp_element_namespaceObject.createElement)(CodeEditor, null), templateResolved && !template && (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && entityId && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
11832 status: "warning",
11833 isDismissible: false
11834 }, (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, {
11835 openEntitiesSavedStates: openEntitiesSavedStates
11836 })),
11837 actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isEntitiesSavedStatesOpen ? (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, {
11838 close: closeEntitiesSavedStates
11839 }) : (0,external_wp_element_namespaceObject.createElement)("div", {
11840 className: "edit-site-editor__toggle-save-panel"
11841 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11842 variant: "secondary",
11843 className: "edit-site-editor__toggle-save-panel-button",
11844 onClick: openEntitiesSavedStates,
11845 "aria-expanded": false
11846 }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))),
11847 footer: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
11848 rootLabelText: (0,external_wp_i18n_namespaceObject.__)('Template')
11849 }),
11850 shortcuts: {
11851 previous: previousShortcut,
11852 next: nextShortcut
11853 }
11854 }), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null))))))));
11855 }
11856
11857 /* harmony default export */ const editor = (Editor);
11858
11859 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/use-register-shortcuts.js
11860 /**
11861 * WordPress dependencies
11862 */
11863
11864
11865
11866
11867 function useRegisterShortcuts() {
11868 const {
11869 registerShortcut
11870 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
11871 (0,external_wp_element_namespaceObject.useEffect)(() => {
11872 registerShortcut({
11873 name: 'core/edit-site/next-region',
11874 category: 'global',
11875 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
11876 keyCombination: {
11877 modifier: 'ctrl',
11878 character: '`'
11879 },
11880 aliases: [{
11881 modifier: 'access',
11882 character: 'n'
11883 }]
11884 });
11885 registerShortcut({
11886 name: 'core/edit-site/previous-region',
11887 category: 'global',
11888 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
11889 keyCombination: {
11890 modifier: 'ctrlShift',
11891 character: '`'
11892 },
11893 aliases: [{
11894 modifier: 'access',
11895 character: 'p'
11896 }]
11897 });
11898 }, []);
11899 }
11900
11901 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post.js
11902
11903
11904 /**
11905 * WordPress dependencies
11906 */
11907
11908 const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11909 xmlns: "http://www.w3.org/2000/svg",
11910 viewBox: "0 0 24 24"
11911 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11912 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z"
11913 }));
11914 /* harmony default export */ const library_post = (post);
11915
11916 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
11917
11918
11919 /**
11920 * WordPress dependencies
11921 */
11922
11923 const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11924 xmlns: "http://www.w3.org/2000/svg",
11925 viewBox: "0 0 24 24"
11926 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11927 d: "M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
11928 }));
11929 /* harmony default export */ const library_page = (page);
11930
11931 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/archive.js
11932
11933
11934 /**
11935 * WordPress dependencies
11936 */
11937
11938 const archive = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11939 viewBox: "0 0 24 24",
11940 xmlns: "http://www.w3.org/2000/svg"
11941 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11942 d: "M19 6.2h-5.9l-.6-1.1c-.3-.7-1-1.1-1.8-1.1H5c-1.1 0-2 .9-2 2v11.8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8.2c0-1.1-.9-2-2-2zm.5 11.6c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h5.8c.2 0 .4.1.4.3l1 2H19c.3 0 .5.2.5.5v9.5zM8 12.8h8v-1.5H8v1.5zm0 3h8v-1.5H8v1.5z"
11943 }));
11944 /* harmony default export */ const library_archive = (archive);
11945
11946 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/search.js
11947
11948
11949 /**
11950 * WordPress dependencies
11951 */
11952
11953 const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11954 xmlns: "http://www.w3.org/2000/svg",
11955 viewBox: "0 0 24 24"
11956 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11957 d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"
11958 }));
11959 /* harmony default export */ const library_search = (search);
11960
11961 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/not-found.js
11962
11963
11964 /**
11965 * WordPress dependencies
11966 */
11967
11968 const notFound = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11969 xmlns: "http://www.w3.org/2000/svg",
11970 viewBox: "0 0 24 24"
11971 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11972 d: "M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm.5 12c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v10zm-11-7.6h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-.9 3.5H6.3l1.2-1.7v1.7zm5.6-3.2c-.4-.2-.8-.4-1.2-.4-.5 0-.9.1-1.2.4-.4.2-.6.6-.8 1-.2.4-.3.9-.3 1.5s.1 1.1.3 1.6c.2.4.5.8.8 1 .4.2.8.4 1.2.4.5 0 .9-.1 1.2-.4.4-.2.6-.6.8-1 .2-.4.3-1 .3-1.6 0-.6-.1-1.1-.3-1.5-.1-.5-.4-.8-.8-1zm0 3.6c-.1.3-.3.5-.5.7-.2.1-.4.2-.7.2-.3 0-.5-.1-.7-.2-.2-.1-.4-.4-.5-.7-.1-.3-.2-.7-.2-1.2 0-.7.1-1.2.4-1.5.3-.3.6-.5 1-.5s.7.2 1 .5c.3.3.4.8.4 1.5-.1.5-.1.9-.2 1.2zm5-3.9h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-1 3.5H16l1.2-1.7v1.7z"
11973 }));
11974 /* harmony default export */ const not_found = (notFound);
11975
11976 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list.js
11977
11978
11979 /**
11980 * WordPress dependencies
11981 */
11982
11983 const list = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11984 viewBox: "0 0 24 24",
11985 xmlns: "http://www.w3.org/2000/svg"
11986 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11987 d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"
11988 }));
11989 /* harmony default export */ const library_list = (list);
11990
11991 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/category.js
11992
11993
11994 /**
11995 * WordPress dependencies
11996 */
11997
11998 const category = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11999 viewBox: "0 0 24 24",
12000 xmlns: "http://www.w3.org/2000/svg"
12001 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12002 d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z",
12003 fillRule: "evenodd",
12004 clipRule: "evenodd"
12005 }));
12006 /* harmony default export */ const library_category = (category);
12007
12008 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-author.js
12009
12010
12011 /**
12012 * WordPress dependencies
12013 */
12014
12015 const postAuthor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12016 viewBox: "0 0 24 24",
12017 xmlns: "http://www.w3.org/2000/svg"
12018 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12019 d: "M10 4.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0zm2.25 7.5v-1A2.75 2.75 0 0011 8.25H7A2.75 2.75 0 004.25 11v1h1.5v-1c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v1h1.5zM4 20h9v-1.5H4V20zm16-4H4v-1.5h16V16z",
12020 fillRule: "evenodd",
12021 clipRule: "evenodd"
12022 }));
12023 /* harmony default export */ const post_author = (postAuthor);
12024
12025 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-meta.js
12026
12027
12028 /**
12029 * WordPress dependencies
12030 */
12031
12032 const blockMeta = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12033 xmlns: "http://www.w3.org/2000/svg",
12034 viewBox: "0 0 24 24"
12035 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12036 fillRule: "evenodd",
12037 d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z",
12038 clipRule: "evenodd"
12039 }));
12040 /* harmony default export */ const block_meta = (blockMeta);
12041
12042 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-date.js
12043
12044
12045 /**
12046 * WordPress dependencies
12047 */
12048
12049 const postDate = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12050 xmlns: "http://www.w3.org/2000/svg",
12051 viewBox: "0 0 24 24"
12052 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12053 d: "M11.696 13.972c.356-.546.599-.958.728-1.235a1.79 1.79 0 00.203-.783c0-.264-.077-.47-.23-.618-.148-.153-.354-.23-.618-.23-.295 0-.569.07-.82.212a3.413 3.413 0 00-.738.571l-.147-1.188c.289-.234.59-.41.903-.526.313-.117.66-.175 1.041-.175.375 0 .695.08.959.24.264.153.46.362.59.626.135.265.203.556.203.876 0 .362-.08.734-.24 1.115-.154.381-.427.87-.82 1.466l-.756 1.152H14v1.106h-4l1.696-2.609z"
12054 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12055 d: "M19.5 7h-15v12a.5.5 0 00.5.5h14a.5.5 0 00.5-.5V7zM3 7V5a2 2 0 012-2h14a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"
12056 }));
12057 /* harmony default export */ const post_date = (postDate);
12058
12059 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tag.js
12060
12061
12062 /**
12063 * WordPress dependencies
12064 */
12065
12066 const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12067 xmlns: "http://www.w3.org/2000/svg",
12068 viewBox: "0 0 24 24"
12069 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12070 d: "M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
12071 }));
12072 /* harmony default export */ const library_tag = (tag);
12073
12074 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/media.js
12075
12076
12077 /**
12078 * WordPress dependencies
12079 */
12080
12081 const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12082 xmlns: "http://www.w3.org/2000/svg",
12083 viewBox: "0 0 24 24"
12084 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12085 d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z"
12086 }));
12087 /* harmony default export */ const library_media = (media);
12088
12089 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template.js
12090
12091
12092 /**
12093 * External dependencies
12094 */
12095
12096 /**
12097 * WordPress dependencies
12098 */
12099
12100
12101
12102
12103
12104
12105
12106
12107 /**
12108 * Internal dependencies
12109 */
12110
12111
12112
12113 const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
12114 const TEMPLATE_ICONS = {
12115 'front-page': library_home,
12116 single: library_post,
12117 page: library_page,
12118 archive: library_archive,
12119 search: library_search,
12120 404: not_found,
12121 index: library_list,
12122 category: library_category,
12123 author: post_author,
12124 taxonomy: block_meta,
12125 date: post_date,
12126 tag: library_tag,
12127 attachment: library_media
12128 };
12129 function NewTemplate(_ref) {
12130 let {
12131 postType
12132 } = _ref;
12133 const history = useHistory();
12134 const {
12135 templates,
12136 defaultTemplateTypes
12137 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12138 templates: select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
12139 per_page: -1
12140 }),
12141 defaultTemplateTypes: select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplateTypes()
12142 }), []);
12143 const {
12144 saveEntityRecord
12145 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12146 const {
12147 createErrorNotice
12148 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12149 const {
12150 setTemplate
12151 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12152
12153 async function createTemplate(template) {
12154 try {
12155 const {
12156 title,
12157 description,
12158 slug
12159 } = template;
12160 const newTemplate = await saveEntityRecord('postType', 'wp_template', {
12161 description,
12162 // Slugs need to be strings, so this is for template `404`
12163 slug: slug.toString(),
12164 status: 'publish',
12165 title,
12166 // This adds a post meta field in template that is part of `is_custom` value calculation.
12167 is_wp_suggestion: true
12168 }, {
12169 throwOnError: true
12170 }); // Set template before navigating away to avoid initial stale value.
12171
12172 setTemplate(newTemplate.id, newTemplate.slug); // Navigate to the created template editor.
12173
12174 history.push({
12175 postId: newTemplate.id,
12176 postType: newTemplate.type
12177 }); // TODO: Add a success notice?
12178 } catch (error) {
12179 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template.');
12180 createErrorNotice(errorMessage, {
12181 type: 'snackbar'
12182 });
12183 }
12184 }
12185
12186 const existingTemplateSlugs = (0,external_lodash_namespaceObject.map)(templates, 'slug');
12187 const missingTemplates = (0,external_lodash_namespaceObject.filter)(defaultTemplateTypes, template => (0,external_lodash_namespaceObject.includes)(DEFAULT_TEMPLATE_SLUGS, template.slug) && !(0,external_lodash_namespaceObject.includes)(existingTemplateSlugs, template.slug));
12188
12189 if (!missingTemplates.length) {
12190 return null;
12191 } // Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.
12192
12193
12194 missingTemplates.sort((template1, template2) => {
12195 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug);
12196 });
12197 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
12198 className: "edit-site-new-template-dropdown",
12199 icon: null,
12200 text: postType.labels.add_new,
12201 label: postType.labels.add_new_item,
12202 popoverProps: {
12203 noArrow: false
12204 },
12205 toggleProps: {
12206 variant: 'primary'
12207 }
12208 }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
12209 className: "edit-site-new-template-dropdown__popover"
12210 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
12211 label: postType.labels.add_new_item
12212 }, (0,external_lodash_namespaceObject.map)(missingTemplates, template => {
12213 const {
12214 title,
12215 description,
12216 slug
12217 } = template;
12218 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12219 icon: TEMPLATE_ICONS[slug],
12220 iconPosition: "left",
12221 info: description,
12222 key: slug,
12223 onClick: () => {
12224 createTemplate(template); // We will be navigated way so no need to close the dropdown.
12225 }
12226 }, title);
12227 }))));
12228 }
12229
12230 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template-part.js
12231
12232
12233 /**
12234 * External dependencies
12235 */
12236
12237 /**
12238 * WordPress dependencies
12239 */
12240
12241
12242
12243
12244
12245
12246
12247 /**
12248 * Internal dependencies
12249 */
12250
12251
12252
12253 function NewTemplatePart(_ref) {
12254 let {
12255 postType
12256 } = _ref;
12257 const history = useHistory();
12258 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
12259 const {
12260 createErrorNotice
12261 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12262 const {
12263 saveEntityRecord
12264 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12265
12266 async function createTemplatePart(_ref2) {
12267 let {
12268 title,
12269 area
12270 } = _ref2;
12271
12272 if (!title) {
12273 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Title is not defined.'), {
12274 type: 'snackbar'
12275 });
12276 return;
12277 }
12278
12279 try {
12280 // Currently template parts only allow latin chars.
12281 // Fallback slug will receive suffix by default.
12282 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
12283 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
12284 slug: cleanSlug,
12285 title,
12286 content: '',
12287 area
12288 }, {
12289 throwOnError: true
12290 });
12291 setIsModalOpen(false); // Navigate to the created template part editor.
12292
12293 history.push({
12294 postId: templatePart.id,
12295 postType: templatePart.type
12296 }); // TODO: Add a success notice?
12297 } catch (error) {
12298 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
12299 createErrorNotice(errorMessage, {
12300 type: 'snackbar'
12301 });
12302 setIsModalOpen(false);
12303 }
12304 }
12305
12306 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12307 variant: "primary",
12308 onClick: () => {
12309 setIsModalOpen(true);
12310 }
12311 }, postType.labels.add_new), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
12312 closeModal: () => setIsModalOpen(false),
12313 onCreate: createTemplatePart
12314 }));
12315 }
12316
12317 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/index.js
12318
12319
12320 /**
12321 * WordPress dependencies
12322 */
12323
12324
12325 /**
12326 * Internal dependencies
12327 */
12328
12329
12330
12331 function AddNewTemplate(_ref) {
12332 let {
12333 templateType = 'wp_template'
12334 } = _ref;
12335 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12336
12337 if (!postType) {
12338 return null;
12339 }
12340
12341 if (templateType === 'wp_template') {
12342 return (0,external_wp_element_namespaceObject.createElement)(NewTemplate, {
12343 postType: postType
12344 });
12345 } else if (templateType === 'wp_template_part') {
12346 return (0,external_wp_element_namespaceObject.createElement)(NewTemplatePart, {
12347 postType: postType
12348 });
12349 }
12350
12351 return null;
12352 }
12353
12354 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/header.js
12355
12356
12357 /**
12358 * WordPress dependencies
12359 */
12360
12361
12362
12363 /**
12364 * Internal dependencies
12365 */
12366
12367
12368 function header_Header(_ref) {
12369 var _postType$labels;
12370
12371 let {
12372 templateType
12373 } = _ref;
12374 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12375
12376 if (!postType) {
12377 return null;
12378 }
12379
12380 return (0,external_wp_element_namespaceObject.createElement)("header", {
12381 className: "edit-site-list-header"
12382 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
12383 level: 1,
12384 className: "edit-site-list-header__title"
12385 }, (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name), (0,external_wp_element_namespaceObject.createElement)("div", {
12386 className: "edit-site-list-header__right"
12387 }, (0,external_wp_element_namespaceObject.createElement)(AddNewTemplate, {
12388 templateType: templateType
12389 })));
12390 }
12391
12392 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-removable.js
12393 /**
12394 * Check if a template is removable.
12395 *
12396 * @param {Object} template The template entity to check.
12397 * @return {boolean} Whether the template is revertable.
12398 */
12399 function isTemplateRemovable(template) {
12400 if (!template) {
12401 return false;
12402 }
12403
12404 return template.source === 'custom' && !template.has_theme_file;
12405 }
12406
12407 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/rename-menu-item.js
12408
12409
12410 /**
12411 * WordPress dependencies
12412 */
12413
12414
12415
12416
12417
12418
12419 function RenameMenuItem(_ref) {
12420 let {
12421 template,
12422 onClose
12423 } = _ref;
12424 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => template.title.rendered);
12425 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
12426 const {
12427 editEntityRecord,
12428 saveEditedEntityRecord
12429 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12430 const {
12431 createSuccessNotice,
12432 createErrorNotice
12433 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12434
12435 if (!template.is_custom) {
12436 return null;
12437 }
12438
12439 async function onTemplateRename(event) {
12440 event.preventDefault();
12441
12442 try {
12443 await editEntityRecord('postType', template.type, template.id, {
12444 title
12445 }); // Update state before saving rerenders the list.
12446
12447 setTitle('');
12448 setIsModalOpen(false);
12449 onClose(); // Persist edited entity.
12450
12451 await saveEditedEntityRecord('postType', template.type, template.id, {
12452 throwOnError: true
12453 });
12454 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity renamed.'), {
12455 type: 'snackbar'
12456 });
12457 } catch (error) {
12458 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the entity.');
12459 createErrorNotice(errorMessage, {
12460 type: 'snackbar'
12461 });
12462 }
12463 }
12464
12465 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12466 onClick: () => {
12467 setIsModalOpen(true);
12468 setTitle(template.title.rendered);
12469 }
12470 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
12471 title: (0,external_wp_i18n_namespaceObject.__)('Rename'),
12472 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
12473 onRequestClose: () => {
12474 setIsModalOpen(false);
12475 },
12476 overlayClassName: "edit-site-list__rename-modal"
12477 }, (0,external_wp_element_namespaceObject.createElement)("form", {
12478 onSubmit: onTemplateRename
12479 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
12480 align: "flex-start",
12481 gap: 8
12482 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
12483 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
12484 value: title,
12485 onChange: setTitle,
12486 required: true
12487 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
12488 className: "edit-site-list__rename-modal-actions",
12489 justify: "flex-end",
12490 expanded: false
12491 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12492 variant: "tertiary",
12493 onClick: () => {
12494 setIsModalOpen(false);
12495 }
12496 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12497 variant: "primary",
12498 type: "submit"
12499 }, (0,external_wp_i18n_namespaceObject.__)('Save')))))));
12500 }
12501
12502 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/index.js
12503
12504
12505 /**
12506 * WordPress dependencies
12507 */
12508
12509
12510
12511
12512
12513
12514 /**
12515 * Internal dependencies
12516 */
12517
12518
12519
12520
12521
12522 function Actions(_ref) {
12523 let {
12524 template
12525 } = _ref;
12526 const {
12527 removeTemplate,
12528 revertTemplate
12529 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12530 const {
12531 saveEditedEntityRecord
12532 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12533 const {
12534 createSuccessNotice,
12535 createErrorNotice
12536 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12537 const isRemovable = isTemplateRemovable(template);
12538 const isRevertable = isTemplateRevertable(template);
12539
12540 if (!isRemovable && !isRevertable) {
12541 return null;
12542 }
12543
12544 async function revertAndSaveTemplate() {
12545 try {
12546 await revertTemplate(template, {
12547 allowUndo: false
12548 });
12549 await saveEditedEntityRecord('postType', template.type, template.id);
12550 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity reverted.'), {
12551 type: 'snackbar'
12552 });
12553 } catch (error) {
12554 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the entity.');
12555 createErrorNotice(errorMessage, {
12556 type: 'snackbar'
12557 });
12558 }
12559 }
12560
12561 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
12562 icon: more_vertical,
12563 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
12564 className: "edit-site-list-table__actions"
12565 }, _ref2 => {
12566 let {
12567 onClose
12568 } = _ref2;
12569 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRemovable && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(RenameMenuItem, {
12570 template: template,
12571 onClose: onClose
12572 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12573 isDestructive: true,
12574 isTertiary: true,
12575 onClick: () => {
12576 removeTemplate(template);
12577 onClose();
12578 }
12579 }, (0,external_wp_i18n_namespaceObject.__)('Delete'))), isRevertable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12580 info: (0,external_wp_i18n_namespaceObject.__)('Restore to default state'),
12581 onClick: () => {
12582 revertAndSaveTemplate();
12583 onClose();
12584 }
12585 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')));
12586 });
12587 }
12588
12589 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plugins.js
12590
12591
12592 /**
12593 * WordPress dependencies
12594 */
12595
12596 const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12597 xmlns: "http://www.w3.org/2000/svg",
12598 viewBox: "0 0 24 24"
12599 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12600 d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"
12601 }));
12602 /* harmony default export */ const library_plugins = (plugins);
12603
12604 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/comment-author-avatar.js
12605
12606
12607 /**
12608 * WordPress dependencies
12609 */
12610
12611 const commentAuthorAvatar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12612 xmlns: "http://www.w3.org/2000/svg",
12613 viewBox: "0 0 24 24"
12614 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12615 fillRule: "evenodd",
12616 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",
12617 clipRule: "evenodd"
12618 }));
12619 /* harmony default export */ const comment_author_avatar = (commentAuthorAvatar);
12620
12621 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/globe.js
12622
12623
12624 /**
12625 * WordPress dependencies
12626 */
12627
12628 const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12629 xmlns: "http://www.w3.org/2000/svg",
12630 viewBox: "0 0 24 24"
12631 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12632 d: "M12 3.3c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8s-4-8.8-8.8-8.8zm6.5 5.5h-2.6C15.4 7.3 14.8 6 14 5c2 .6 3.6 2 4.5 3.8zm.7 3.2c0 .6-.1 1.2-.2 1.8h-2.9c.1-.6.1-1.2.1-1.8s-.1-1.2-.1-1.8H19c.2.6.2 1.2.2 1.8zM12 18.7c-1-.7-1.8-1.9-2.3-3.5h4.6c-.5 1.6-1.3 2.9-2.3 3.5zm-2.6-4.9c-.1-.6-.1-1.1-.1-1.8 0-.6.1-1.2.1-1.8h5.2c.1.6.1 1.1.1 1.8s-.1 1.2-.1 1.8H9.4zM4.8 12c0-.6.1-1.2.2-1.8h2.9c-.1.6-.1 1.2-.1 1.8 0 .6.1 1.2.1 1.8H5c-.2-.6-.2-1.2-.2-1.8zM12 5.3c1 .7 1.8 1.9 2.3 3.5H9.7c.5-1.6 1.3-2.9 2.3-3.5zM10 5c-.8 1-1.4 2.3-1.8 3.8H5.5C6.4 7 8 5.6 10 5zM5.5 15.3h2.6c.4 1.5 1 2.8 1.8 3.7-1.8-.6-3.5-2-4.4-3.7zM14 19c.8-1 1.4-2.2 1.8-3.7h2.6C17.6 17 16 18.4 14 19z"
12633 }));
12634 /* harmony default export */ const library_globe = (globe);
12635
12636 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/added-by.js
12637
12638
12639 /**
12640 * External dependencies
12641 */
12642
12643 /**
12644 * WordPress dependencies
12645 */
12646
12647
12648
12649
12650
12651
12652
12653 const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
12654
12655 function CustomizedTooltip(_ref) {
12656 let {
12657 isCustomized,
12658 children
12659 } = _ref;
12660
12661 if (!isCustomized) {
12662 return children;
12663 }
12664
12665 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
12666 text: (0,external_wp_i18n_namespaceObject.__)('This template has been customized')
12667 }, children);
12668 }
12669
12670 function BaseAddedBy(_ref2) {
12671 let {
12672 text,
12673 icon,
12674 imageUrl,
12675 isCustomized
12676 } = _ref2;
12677 const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false);
12678 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
12679 alignment: "left"
12680 }, (0,external_wp_element_namespaceObject.createElement)(CustomizedTooltip, {
12681 isCustomized: isCustomized
12682 }, imageUrl ? (0,external_wp_element_namespaceObject.createElement)("div", {
12683 className: classnames_default()('edit-site-list-added-by__avatar', {
12684 'is-loaded': isImageLoaded
12685 })
12686 }, (0,external_wp_element_namespaceObject.createElement)("img", {
12687 onLoad: () => setIsImageLoaded(true),
12688 alt: "",
12689 src: imageUrl
12690 })) : (0,external_wp_element_namespaceObject.createElement)("div", {
12691 className: classnames_default()('edit-site-list-added-by__icon', {
12692 'is-customized': isCustomized
12693 })
12694 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
12695 icon: icon
12696 }))), (0,external_wp_element_namespaceObject.createElement)("span", null, text));
12697 }
12698
12699 function AddedByTheme(_ref3) {
12700 var _theme$name;
12701
12702 let {
12703 slug,
12704 isCustomized
12705 } = _ref3;
12706 const theme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getTheme(slug), [slug]);
12707 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12708 icon: library_layout,
12709 text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
12710 isCustomized: isCustomized
12711 });
12712 }
12713
12714 function AddedByPlugin(_ref4) {
12715 let {
12716 slug,
12717 isCustomized
12718 } = _ref4;
12719 const plugin = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPlugin(slug), [slug]);
12720 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12721 icon: library_plugins,
12722 text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
12723 isCustomized: isCustomized
12724 });
12725 }
12726
12727 function AddedByAuthor(_ref5) {
12728 var _user$avatar_urls;
12729
12730 let {
12731 id
12732 } = _ref5;
12733 const user = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getUser(id), [id]);
12734 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12735 icon: comment_author_avatar,
12736 imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
12737 text: user === null || user === void 0 ? void 0 : user.nickname
12738 });
12739 }
12740
12741 function AddedBySite() {
12742 const {
12743 name,
12744 logoURL
12745 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12746 var _getMedia;
12747
12748 const {
12749 getEntityRecord,
12750 getMedia
12751 } = select(external_wp_coreData_namespaceObject.store);
12752 const siteData = getEntityRecord('root', '__unstableBase');
12753 return {
12754 name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
12755 logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
12756 };
12757 }, []);
12758 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12759 icon: library_globe,
12760 imageUrl: logoURL,
12761 text: name
12762 });
12763 }
12764
12765 function AddedBy(_ref6) {
12766 let {
12767 templateType,
12768 template
12769 } = _ref6;
12770
12771 if (!template) {
12772 return;
12773 }
12774
12775 if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
12776 // Template originally provided by a theme, but customized by a user.
12777 // Templates originally didn't have the 'origin' field so identify
12778 // older customized templates by checking for no origin and a 'theme'
12779 // or 'custom' source.
12780 if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
12781 return (0,external_wp_element_namespaceObject.createElement)(AddedByTheme, {
12782 slug: template.theme,
12783 isCustomized: template.source === 'custom'
12784 });
12785 } // Template originally provided by a plugin, but customized by a user.
12786
12787
12788 if (template.has_theme_file && template.origin === 'plugin') {
12789 return (0,external_wp_element_namespaceObject.createElement)(AddedByPlugin, {
12790 slug: template.theme,
12791 isCustomized: template.source === 'custom'
12792 });
12793 } // Template was created from scratch, but has no author. Author support
12794 // was only added to templates in WordPress 5.9. Fallback to showing the
12795 // site logo and title.
12796
12797
12798 if (!template.has_theme_file && template.source === 'custom' && !template.author) {
12799 return (0,external_wp_element_namespaceObject.createElement)(AddedBySite, null);
12800 }
12801 } // Simply show the author for templates created from scratch that have an
12802 // author or for any other post type.
12803
12804
12805 return (0,external_wp_element_namespaceObject.createElement)(AddedByAuthor, {
12806 id: template.author
12807 });
12808 }
12809
12810 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/table.js
12811
12812
12813 /**
12814 * WordPress dependencies
12815 */
12816
12817
12818
12819
12820
12821 /**
12822 * Internal dependencies
12823 */
12824
12825
12826
12827
12828 function Table(_ref) {
12829 let {
12830 templateType
12831 } = _ref;
12832 const {
12833 records: templates,
12834 isResolving: isLoading
12835 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', templateType, {
12836 per_page: -1
12837 });
12838 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12839
12840 if (!templates || isLoading) {
12841 return null;
12842 }
12843
12844 if (!templates.length) {
12845 var _postType$labels, _postType$labels$name;
12846
12847 return (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_i18n_namespaceObject.sprintf)( // translators: The template type name, should be either "templates" or "template parts".
12848 (0,external_wp_i18n_namespaceObject.__)('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
12849 }
12850
12851 return (// These explicit aria roles are needed for Safari.
12852 // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
12853 (0,external_wp_element_namespaceObject.createElement)("table", {
12854 className: "edit-site-list-table",
12855 role: "table"
12856 }, (0,external_wp_element_namespaceObject.createElement)("thead", null, (0,external_wp_element_namespaceObject.createElement)("tr", {
12857 className: "edit-site-list-table-head",
12858 role: "row"
12859 }, (0,external_wp_element_namespaceObject.createElement)("th", {
12860 className: "edit-site-list-table-column",
12861 role: "columnheader"
12862 }, (0,external_wp_i18n_namespaceObject.__)('Template')), (0,external_wp_element_namespaceObject.createElement)("th", {
12863 className: "edit-site-list-table-column",
12864 role: "columnheader"
12865 }, (0,external_wp_i18n_namespaceObject.__)('Added by')), (0,external_wp_element_namespaceObject.createElement)("th", {
12866 className: "edit-site-list-table-column",
12867 role: "columnheader"
12868 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Actions'))))), (0,external_wp_element_namespaceObject.createElement)("tbody", null, templates.map(template => {
12869 var _template$title;
12870
12871 return (0,external_wp_element_namespaceObject.createElement)("tr", {
12872 key: template.id,
12873 className: "edit-site-list-table-row",
12874 role: "row"
12875 }, (0,external_wp_element_namespaceObject.createElement)("td", {
12876 className: "edit-site-list-table-column",
12877 role: "cell"
12878 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
12879 level: 4
12880 }, (0,external_wp_element_namespaceObject.createElement)(Link, {
12881 params: {
12882 postId: template.id,
12883 postType: template.type
12884 }
12885 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), template.description), (0,external_wp_element_namespaceObject.createElement)("td", {
12886 className: "edit-site-list-table-column",
12887 role: "cell"
12888 }, (0,external_wp_element_namespaceObject.createElement)(AddedBy, {
12889 templateType: templateType,
12890 template: template
12891 })), (0,external_wp_element_namespaceObject.createElement)("td", {
12892 className: "edit-site-list-table-column",
12893 role: "cell"
12894 }, (0,external_wp_element_namespaceObject.createElement)(Actions, {
12895 template: template
12896 })));
12897 })))
12898 );
12899 }
12900
12901 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/index.js
12902
12903
12904 /**
12905 * External dependencies
12906 */
12907
12908 /**
12909 * WordPress dependencies
12910 */
12911
12912
12913
12914
12915
12916
12917
12918 /**
12919 * Internal dependencies
12920 */
12921
12922
12923
12924
12925
12926
12927
12928
12929 function List() {
12930 var _postType$labels, _postType$labels2;
12931
12932 const {
12933 params: {
12934 postType: templateType
12935 }
12936 } = useLocation();
12937 useRegisterShortcuts();
12938 const {
12939 previousShortcut,
12940 nextShortcut,
12941 isNavigationOpen
12942 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12943 return {
12944 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
12945 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
12946 isNavigationOpen: select(store_store).isNavigationOpened()
12947 };
12948 }, []);
12949 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12950 useTitle(postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name); // `postType` could load in asynchronously. Only provide the detailed region labels if
12951 // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
12952
12953 const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels2 = postType.labels) === null || _postType$labels2 === void 0 ? void 0 : _postType$labels2.items_list;
12954 const detailedRegionLabels = postType ? {
12955 header: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Header' as in the header area of that page.
12956 (0,external_wp_i18n_namespaceObject.__)('%s - Header'), itemsListLabel),
12957 body: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Content' as in the content area of that page.
12958 (0,external_wp_i18n_namespaceObject.__)('%s - Content'), itemsListLabel)
12959 } : undefined;
12960 return (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
12961 className: classnames_default()('edit-site-list', {
12962 'is-navigation-open': isNavigationOpen
12963 }),
12964 labels: {
12965 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar'),
12966 ...detailedRegionLabels
12967 },
12968 header: (0,external_wp_element_namespaceObject.createElement)(header_Header, {
12969 templateType: templateType
12970 }),
12971 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
12972 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
12973 content: (0,external_wp_element_namespaceObject.createElement)(Table, {
12974 templateType: templateType
12975 }),
12976 shortcuts: {
12977 previous: previousShortcut,
12978 next: nextShortcut
12979 }
12980 });
12981 }
12982
12983 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/get-is-list-page.js
12984 /**
12985 * Returns if the params match the list page route.
12986 *
12987 * @param {Object} params The search params.
12988 * @param {string} params.postId The post ID.
12989 * @param {string} params.postType The post type.
12990 * @return {boolean} Is list page or not.
12991 */
12992 function getIsListPage(_ref) {
12993 let {
12994 postId,
12995 postType
12996 } = _ref;
12997 return !!(!postId && postType);
12998 }
12999
13000 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/app/index.js
13001
13002
13003 /**
13004 * WordPress dependencies
13005 */
13006
13007
13008
13009
13010
13011
13012 /**
13013 * Internal dependencies
13014 */
13015
13016
13017
13018
13019
13020
13021 function EditSiteApp(_ref) {
13022 let {
13023 reboot
13024 } = _ref;
13025 const {
13026 createErrorNotice
13027 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
13028
13029 function onPluginAreaError(name) {
13030 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
13031 /* translators: %s: plugin name */
13032 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
13033 }
13034
13035 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(Routes, null, _ref2 => {
13036 let {
13037 params
13038 } = _ref2;
13039 const isListPage = getIsListPage(params);
13040 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isListPage ? (0,external_wp_element_namespaceObject.createElement)(List, null) : (0,external_wp_element_namespaceObject.createElement)(editor, {
13041 onError: reboot
13042 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, {
13043 onError: onPluginAreaError
13044 }), (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar // Open the navigation sidebar by default when in the list page.
13045 , {
13046 isDefaultOpen: !!isListPage,
13047 activeTemplateType: isListPage ? params.postType : undefined
13048 }));
13049 }));
13050 }
13051
13052 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/plugin-sidebar/index.js
13053
13054
13055
13056 /**
13057 * WordPress dependencies
13058 */
13059
13060 /**
13061 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
13062 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
13063 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
13064 *
13065 * ```js
13066 * wp.data.dispatch( 'core/edit-site' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
13067 * ```
13068 *
13069 * @see PluginSidebarMoreMenuItem
13070 *
13071 * @param {Object} props Element props.
13072 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
13073 * @param {string} [props.className] An optional class name added to the sidebar body.
13074 * @param {string} props.title Title displayed at the top of the sidebar.
13075 * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.
13076 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
13077 *
13078 * @example
13079 * ```js
13080 * // Using ES5 syntax
13081 * var __ = wp.i18n.__;
13082 * var el = wp.element.createElement;
13083 * var PanelBody = wp.components.PanelBody;
13084 * var PluginSidebar = wp.editSite.PluginSidebar;
13085 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
13086 *
13087 * function MyPluginSidebar() {
13088 * return el(
13089 * PluginSidebar,
13090 * {
13091 * name: 'my-sidebar',
13092 * title: 'My sidebar title',
13093 * icon: moreIcon,
13094 * },
13095 * el(
13096 * PanelBody,
13097 * {},
13098 * __( 'My sidebar content' )
13099 * )
13100 * );
13101 * }
13102 * ```
13103 *
13104 * @example
13105 * ```jsx
13106 * // Using ESNext syntax
13107 * import { __ } from '@wordpress/i18n';
13108 * import { PanelBody } from '@wordpress/components';
13109 * import { PluginSidebar } from '@wordpress/edit-site';
13110 * import { more } from '@wordpress/icons';
13111 *
13112 * const MyPluginSidebar = () => (
13113 * <PluginSidebar
13114 * name="my-sidebar"
13115 * title="My sidebar title"
13116 * icon={ more }
13117 * >
13118 * <PanelBody>
13119 * { __( 'My sidebar content' ) }
13120 * </PanelBody>
13121 * </PluginSidebar>
13122 * );
13123 * ```
13124 */
13125
13126 function PluginSidebarEditSite(_ref) {
13127 let {
13128 className,
13129 ...props
13130 } = _ref;
13131 return (0,external_wp_element_namespaceObject.createElement)(complementary_area, extends_extends({
13132 panelClassName: className,
13133 className: "edit-site-sidebar",
13134 scope: "core/edit-site"
13135 }, props));
13136 }
13137
13138 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/plugin-sidebar-more-menu-item/index.js
13139
13140
13141
13142 /**
13143 * WordPress dependencies
13144 */
13145
13146 /**
13147 * Renders a menu item in `Plugins` group in `More Menu` drop down,
13148 * and can be used to activate the corresponding `PluginSidebar` component.
13149 * The text within the component appears as the menu item label.
13150 *
13151 * @param {Object} props Component props.
13152 * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
13153 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
13154 *
13155 * @example
13156 * ```js
13157 * // Using ES5 syntax
13158 * var __ = wp.i18n.__;
13159 * var PluginSidebarMoreMenuItem = wp.editSite.PluginSidebarMoreMenuItem;
13160 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
13161 *
13162 * function MySidebarMoreMenuItem() {
13163 * return wp.element.createElement(
13164 * PluginSidebarMoreMenuItem,
13165 * {
13166 * target: 'my-sidebar',
13167 * icon: moreIcon,
13168 * },
13169 * __( 'My sidebar title' )
13170 * )
13171 * }
13172 * ```
13173 *
13174 * @example
13175 * ```jsx
13176 * // Using ESNext syntax
13177 * import { __ } from '@wordpress/i18n';
13178 * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-site';
13179 * import { more } from '@wordpress/icons';
13180 *
13181 * const MySidebarMoreMenuItem = () => (
13182 * <PluginSidebarMoreMenuItem
13183 * target="my-sidebar"
13184 * icon={ more }
13185 * >
13186 * { __( 'My sidebar title' ) }
13187 * </PluginSidebarMoreMenuItem>
13188 * );
13189 * ```
13190 *
13191 * @return {WPComponent} The component to be rendered.
13192 */
13193
13194 function PluginSidebarMoreMenuItem(props) {
13195 return (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem // Menu item is marked with unstable prop for backward compatibility.
13196 // @see https://github.com/WordPress/gutenberg/issues/14457
13197 , extends_extends({
13198 __unstableExplicitMenuItem: true,
13199 scope: "core/edit-site"
13200 }, props));
13201 }
13202
13203 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/plugin-more-menu-item/index.js
13204 /**
13205 * WordPress dependencies
13206 */
13207
13208
13209
13210
13211 /**
13212 * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
13213 * The text within the component appears as the menu item label.
13214 *
13215 * @param {Object} props Component properties.
13216 * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
13217 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
13218 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
13219 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
13220 *
13221 * @example
13222 * ```js
13223 * // Using ES5 syntax
13224 * var __ = wp.i18n.__;
13225 * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem;
13226 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
13227 *
13228 * function onButtonClick() {
13229 * alert( 'Button clicked.' );
13230 * }
13231 *
13232 * function MyButtonMoreMenuItem() {
13233 * return wp.element.createElement(
13234 * PluginMoreMenuItem,
13235 * {
13236 * icon: moreIcon,
13237 * onClick: onButtonClick,
13238 * },
13239 * __( 'My button title' )
13240 * );
13241 * }
13242 * ```
13243 *
13244 * @example
13245 * ```jsx
13246 * // Using ESNext syntax
13247 * import { __ } from '@wordpress/i18n';
13248 * import { PluginMoreMenuItem } from '@wordpress/edit-site';
13249 * import { more } from '@wordpress/icons';
13250 *
13251 * function onButtonClick() {
13252 * alert( 'Button clicked.' );
13253 * }
13254 *
13255 * const MyButtonMoreMenuItem = () => (
13256 * <PluginMoreMenuItem
13257 * icon={ more }
13258 * onClick={ onButtonClick }
13259 * >
13260 * { __( 'My button title' ) }
13261 * </PluginMoreMenuItem>
13262 * );
13263 * ```
13264 *
13265 * @return {WPComponent} The component to be rendered.
13266 */
13267
13268 /* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
13269 var _ownProps$as;
13270
13271 return {
13272 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
13273 icon: ownProps.icon || context.icon,
13274 name: 'core/edit-site/plugin-more-menu'
13275 };
13276 }))(action_item));
13277
13278 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/index.js
13279
13280
13281 /**
13282 * WordPress dependencies
13283 */
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295 /**
13296 * Internal dependencies
13297 */
13298
13299
13300
13301
13302
13303
13304 /**
13305 * Reinitializes the editor after the user chooses to reboot the editor after
13306 * an unhandled error occurs, replacing previously mounted editor element using
13307 * an initial state from prior to the crash.
13308 *
13309 * @param {Element} target DOM node in which editor is rendered.
13310 * @param {?Object} settings Editor settings object.
13311 */
13312
13313 function reinitializeEditor(target, settings) {
13314 // Display warning if editor wasn't able to resolve homepage template.
13315 if (!settings.__unstableHomeTemplate) {
13316 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
13317 message: (0,external_wp_i18n_namespaceObject.__)('The editor is unable to find a block template for the homepage.'),
13318 dashboardLink: "index.php"
13319 }), target);
13320 return;
13321 } // This will be a no-op if the target doesn't have any React nodes.
13322
13323
13324 (0,external_wp_element_namespaceObject.unmountComponentAtNode)(target);
13325 const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
13326 // so that we won't trigger unnecessary re-renders with useEffect.
13327
13328 {
13329 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-site', {
13330 editorMode: 'visual',
13331 fixedToolbar: false,
13332 focusMode: false,
13333 keepCaretInsideBlock: false,
13334 welcomeGuide: true,
13335 welcomeGuideStyles: true,
13336 shouldListViewOpenByDefault: false
13337 }); // Check if the block list view should be open by default.
13338
13339 if ((0,external_wp_data_namespaceObject.select)(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showListViewByDefault')) {
13340 (0,external_wp_data_namespaceObject.dispatch)(store_store).setIsListViewOpened(true);
13341 }
13342
13343 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultComplementaryArea('core/edit-site', 'edit-site/template');
13344 (0,external_wp_data_namespaceObject.dispatch)(store_store).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
13345 // so that they can be selected with core/editor selectors in any editor.
13346 // This is needed because edit-site doesn't initialize with EditorProvider,
13347 // which internally uses updateEditorSettings as well.
13348
13349 (0,external_wp_data_namespaceObject.dispatch)(external_wp_editor_namespaceObject.store).updateEditorSettings({
13350 defaultTemplateTypes: settings.defaultTemplateTypes,
13351 defaultTemplatePartAreas: settings.defaultTemplatePartAreas
13352 });
13353 const isLandingOnListPage = getIsListPage((0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href));
13354
13355 if (isLandingOnListPage) {
13356 // Default the navigation panel to be opened when we're in a bigger
13357 // screen and land in the list screen.
13358 (0,external_wp_data_namespaceObject.dispatch)(store_store).setIsNavigationPanelOpened((0,external_wp_data_namespaceObject.select)(external_wp_viewport_namespaceObject.store).isViewportMatch('medium'));
13359 }
13360 }
13361 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(EditSiteApp, {
13362 reboot: reboot
13363 }), target);
13364 }
13365 /**
13366 * Initializes the site editor screen.
13367 *
13368 * @param {string} id ID of the root element to render the screen in.
13369 * @param {Object} settings Editor settings.
13370 */
13371
13372 function initializeEditor(id, settings) {
13373 settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings);
13374
13375 settings.__experimentalFetchRichUrlData = external_wp_coreData_namespaceObject.__experimentalFetchUrlData;
13376 const target = document.getElementById(id);
13377
13378 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
13379
13380 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
13381
13382 if (true) {
13383 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({
13384 enableFSEBlocks: true
13385 });
13386 }
13387
13388 reinitializeEditor(target, settings);
13389 }
13390
13391
13392
13393
13394
13395
13396 })();
13397
13398 (window.wp = window.wp || {}).editSite = __webpack_exports__;
13399 /******/ })()
13400 ;