PluginProbe
Gutenberg / 18.6.1
Gutenberg v18.6.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 / editor / index.js

index.js in Gutenberg 18.6.1, at build/editor/index.js

28,713 lines 989.7 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 /***/ 4827:
294 /***/ ((module) => {
295
296 // This code has been refactored for 140 bytes
297 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
298 var computedStyle = function (el, prop, getComputedStyle) {
299 getComputedStyle = window.getComputedStyle;
300
301 // In one fell swoop
302 return (
303 // If we have getComputedStyle
304 getComputedStyle ?
305 // Query it
306 // TODO: From CSS-Query notes, we might need (node, null) for FF
307 getComputedStyle(el) :
308
309 // Otherwise, we are in IE and use currentStyle
310 el.currentStyle
311 )[
312 // Switch to camelCase for CSSOM
313 // DEV: Grabbed from jQuery
314 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
315 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
316 prop.replace(/-(\w)/gi, function (word, letter) {
317 return letter.toUpperCase();
318 })
319 ];
320 };
321
322 module.exports = computedStyle;
323
324
325 /***/ }),
326
327 /***/ 1919:
328 /***/ ((module) => {
329
330 "use strict";
331
332
333 var isMergeableObject = function isMergeableObject(value) {
334 return isNonNullObject(value)
335 && !isSpecial(value)
336 };
337
338 function isNonNullObject(value) {
339 return !!value && typeof value === 'object'
340 }
341
342 function isSpecial(value) {
343 var stringValue = Object.prototype.toString.call(value);
344
345 return stringValue === '[object RegExp]'
346 || stringValue === '[object Date]'
347 || isReactElement(value)
348 }
349
350 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
351 var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
352 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
353
354 function isReactElement(value) {
355 return value.$$typeof === REACT_ELEMENT_TYPE
356 }
357
358 function emptyTarget(val) {
359 return Array.isArray(val) ? [] : {}
360 }
361
362 function cloneUnlessOtherwiseSpecified(value, options) {
363 return (options.clone !== false && options.isMergeableObject(value))
364 ? deepmerge(emptyTarget(value), value, options)
365 : value
366 }
367
368 function defaultArrayMerge(target, source, options) {
369 return target.concat(source).map(function(element) {
370 return cloneUnlessOtherwiseSpecified(element, options)
371 })
372 }
373
374 function getMergeFunction(key, options) {
375 if (!options.customMerge) {
376 return deepmerge
377 }
378 var customMerge = options.customMerge(key);
379 return typeof customMerge === 'function' ? customMerge : deepmerge
380 }
381
382 function getEnumerableOwnPropertySymbols(target) {
383 return Object.getOwnPropertySymbols
384 ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
385 return Object.propertyIsEnumerable.call(target, symbol)
386 })
387 : []
388 }
389
390 function getKeys(target) {
391 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
392 }
393
394 function propertyIsOnObject(object, property) {
395 try {
396 return property in object
397 } catch(_) {
398 return false
399 }
400 }
401
402 // Protects from prototype poisoning and unexpected merging up the prototype chain.
403 function propertyIsUnsafe(target, key) {
404 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
405 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
406 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
407 }
408
409 function mergeObject(target, source, options) {
410 var destination = {};
411 if (options.isMergeableObject(target)) {
412 getKeys(target).forEach(function(key) {
413 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
414 });
415 }
416 getKeys(source).forEach(function(key) {
417 if (propertyIsUnsafe(target, key)) {
418 return
419 }
420
421 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
422 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
423 } else {
424 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
425 }
426 });
427 return destination
428 }
429
430 function deepmerge(target, source, options) {
431 options = options || {};
432 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
433 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
434 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
435 // implementations can use it. The caller may not replace it.
436 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
437
438 var sourceIsArray = Array.isArray(source);
439 var targetIsArray = Array.isArray(target);
440 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
441
442 if (!sourceAndTargetTypesMatch) {
443 return cloneUnlessOtherwiseSpecified(source, options)
444 } else if (sourceIsArray) {
445 return options.arrayMerge(target, source, options)
446 } else {
447 return mergeObject(target, source, options)
448 }
449 }
450
451 deepmerge.all = function deepmergeAll(array, options) {
452 if (!Array.isArray(array)) {
453 throw new Error('first argument should be an array')
454 }
455
456 return array.reduce(function(prev, next) {
457 return deepmerge(prev, next, options)
458 }, {})
459 };
460
461 var deepmerge_1 = deepmerge;
462
463 module.exports = deepmerge_1;
464
465
466 /***/ }),
467
468 /***/ 2303:
469 /***/ ((module) => {
470
471 "use strict";
472
473
474 // do not edit .js files directly - edit src/index.jst
475
476
477
478 module.exports = function equal(a, b) {
479 if (a === b) return true;
480
481 if (a && b && typeof a == 'object' && typeof b == 'object') {
482 if (a.constructor !== b.constructor) return false;
483
484 var length, i, keys;
485 if (Array.isArray(a)) {
486 length = a.length;
487 if (length != b.length) return false;
488 for (i = length; i-- !== 0;)
489 if (!equal(a[i], b[i])) return false;
490 return true;
491 }
492
493
494
495 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
496 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
497 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
498
499 keys = Object.keys(a);
500 length = keys.length;
501 if (length !== Object.keys(b).length) return false;
502
503 for (i = length; i-- !== 0;)
504 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
505
506 for (i = length; i-- !== 0;) {
507 var key = keys[i];
508
509 if (!equal(a[key], b[key])) return false;
510 }
511
512 return true;
513 }
514
515 // true if both NaN, false otherwise
516 return a!==a && b!==b;
517 };
518
519
520 /***/ }),
521
522 /***/ 9894:
523 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
524
525 // Load in dependencies
526 var computedStyle = __webpack_require__(4827);
527
528 /**
529 * Calculate the `line-height` of a given node
530 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
531 * @returns {Number} `line-height` of the element in pixels
532 */
533 function lineHeight(node) {
534 // Grab the line-height via style
535 var lnHeightStr = computedStyle(node, 'line-height');
536 var lnHeight = parseFloat(lnHeightStr, 10);
537
538 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
539 if (lnHeightStr === lnHeight + '') {
540 // Save the old lineHeight style and update the em unit to the element
541 var _lnHeightStyle = node.style.lineHeight;
542 node.style.lineHeight = lnHeightStr + 'em';
543
544 // Calculate the em based height
545 lnHeightStr = computedStyle(node, 'line-height');
546 lnHeight = parseFloat(lnHeightStr, 10);
547
548 // Revert the lineHeight style
549 if (_lnHeightStyle) {
550 node.style.lineHeight = _lnHeightStyle;
551 } else {
552 delete node.style.lineHeight;
553 }
554 }
555
556 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
557 // DEV: `em` units are converted to `pt` in IE6
558 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
559 if (lnHeightStr.indexOf('pt') !== -1) {
560 lnHeight *= 4;
561 lnHeight /= 3;
562 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
563 } else if (lnHeightStr.indexOf('mm') !== -1) {
564 lnHeight *= 96;
565 lnHeight /= 25.4;
566 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
567 } else if (lnHeightStr.indexOf('cm') !== -1) {
568 lnHeight *= 96;
569 lnHeight /= 2.54;
570 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
571 } else if (lnHeightStr.indexOf('in') !== -1) {
572 lnHeight *= 96;
573 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
574 } else if (lnHeightStr.indexOf('pc') !== -1) {
575 lnHeight *= 16;
576 }
577
578 // Continue our computation
579 lnHeight = Math.round(lnHeight);
580
581 // If the line-height is "normal", calculate by font-size
582 if (lnHeightStr === 'normal') {
583 // Create a temporary node
584 var nodeName = node.nodeName;
585 var _node = document.createElement(nodeName);
586 _node.innerHTML = '&nbsp;';
587
588 // If we have a text area, reset it to only 1 row
589 // https://github.com/twolfson/line-height/issues/4
590 if (nodeName.toUpperCase() === 'TEXTAREA') {
591 _node.setAttribute('rows', '1');
592 }
593
594 // Set the font-size of the element
595 var fontSizeStr = computedStyle(node, 'font-size');
596 _node.style.fontSize = fontSizeStr;
597
598 // Remove default padding/border which can affect offset height
599 // https://github.com/twolfson/line-height/issues/4
600 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
601 _node.style.padding = '0px';
602 _node.style.border = '0px';
603
604 // Append it to the body
605 var body = document.body;
606 body.appendChild(_node);
607
608 // Assume the line height of the element is the height
609 var height = _node.offsetHeight;
610 lnHeight = height;
611
612 // Remove our child from the DOM
613 body.removeChild(_node);
614 }
615
616 // Return the calculated height
617 return lnHeight;
618 }
619
620 // Export lineHeight
621 module.exports = lineHeight;
622
623
624 /***/ }),
625
626 /***/ 5372:
627 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
628
629 "use strict";
630 /**
631 * Copyright (c) 2013-present, Facebook, Inc.
632 *
633 * This source code is licensed under the MIT license found in the
634 * LICENSE file in the root directory of this source tree.
635 */
636
637
638
639 var ReactPropTypesSecret = __webpack_require__(9567);
640
641 function emptyFunction() {}
642 function emptyFunctionWithReset() {}
643 emptyFunctionWithReset.resetWarningCache = emptyFunction;
644
645 module.exports = function() {
646 function shim(props, propName, componentName, location, propFullName, secret) {
647 if (secret === ReactPropTypesSecret) {
648 // It is still safe when called from React.
649 return;
650 }
651 var err = new Error(
652 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
653 'Use PropTypes.checkPropTypes() to call them. ' +
654 'Read more at http://fb.me/use-check-prop-types'
655 );
656 err.name = 'Invariant Violation';
657 throw err;
658 };
659 shim.isRequired = shim;
660 function getShim() {
661 return shim;
662 };
663 // Important!
664 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
665 var ReactPropTypes = {
666 array: shim,
667 bigint: shim,
668 bool: shim,
669 func: shim,
670 number: shim,
671 object: shim,
672 string: shim,
673 symbol: shim,
674
675 any: shim,
676 arrayOf: getShim,
677 element: shim,
678 elementType: shim,
679 instanceOf: getShim,
680 node: shim,
681 objectOf: getShim,
682 oneOf: getShim,
683 oneOfType: getShim,
684 shape: getShim,
685 exact: getShim,
686
687 checkPropTypes: emptyFunctionWithReset,
688 resetWarningCache: emptyFunction
689 };
690
691 ReactPropTypes.PropTypes = ReactPropTypes;
692
693 return ReactPropTypes;
694 };
695
696
697 /***/ }),
698
699 /***/ 2652:
700 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
701
702 /**
703 * Copyright (c) 2013-present, Facebook, Inc.
704 *
705 * This source code is licensed under the MIT license found in the
706 * LICENSE file in the root directory of this source tree.
707 */
708
709 if (false) { var throwOnDirectAccess, ReactIs; } else {
710 // By explicitly using `prop-types` you are opting into new production behavior.
711 // http://fb.me/prop-types-in-prod
712 module.exports = __webpack_require__(5372)();
713 }
714
715
716 /***/ }),
717
718 /***/ 9567:
719 /***/ ((module) => {
720
721 "use strict";
722 /**
723 * Copyright (c) 2013-present, Facebook, Inc.
724 *
725 * This source code is licensed under the MIT license found in the
726 * LICENSE file in the root directory of this source tree.
727 */
728
729
730
731 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
732
733 module.exports = ReactPropTypesSecret;
734
735
736 /***/ }),
737
738 /***/ 5438:
739 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
740
741 "use strict";
742
743 var __extends = (this && this.__extends) || (function () {
744 var extendStatics = Object.setPrototypeOf ||
745 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
746 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
747 return function (d, b) {
748 extendStatics(d, b);
749 function __() { this.constructor = d; }
750 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
751 };
752 })();
753 var __assign = (this && this.__assign) || Object.assign || function(t) {
754 for (var s, i = 1, n = arguments.length; i < n; i++) {
755 s = arguments[i];
756 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
757 t[p] = s[p];
758 }
759 return t;
760 };
761 var __rest = (this && this.__rest) || function (s, e) {
762 var t = {};
763 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
764 t[p] = s[p];
765 if (s != null && typeof Object.getOwnPropertySymbols === "function")
766 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
767 t[p[i]] = s[p[i]];
768 return t;
769 };
770 exports.__esModule = true;
771 var React = __webpack_require__(9196);
772 var PropTypes = __webpack_require__(2652);
773 var autosize = __webpack_require__(6411);
774 var _getLineHeight = __webpack_require__(9894);
775 var getLineHeight = _getLineHeight;
776 var RESIZED = "autosize:resized";
777 /**
778 * A light replacement for built-in textarea component
779 * which automaticaly adjusts its height to match the content
780 */
781 var TextareaAutosizeClass = /** @class */ (function (_super) {
782 __extends(TextareaAutosizeClass, _super);
783 function TextareaAutosizeClass() {
784 var _this = _super !== null && _super.apply(this, arguments) || this;
785 _this.state = {
786 lineHeight: null
787 };
788 _this.textarea = null;
789 _this.onResize = function (e) {
790 if (_this.props.onResize) {
791 _this.props.onResize(e);
792 }
793 };
794 _this.updateLineHeight = function () {
795 if (_this.textarea) {
796 _this.setState({
797 lineHeight: getLineHeight(_this.textarea)
798 });
799 }
800 };
801 _this.onChange = function (e) {
802 var onChange = _this.props.onChange;
803 _this.currentValue = e.currentTarget.value;
804 onChange && onChange(e);
805 };
806 return _this;
807 }
808 TextareaAutosizeClass.prototype.componentDidMount = function () {
809 var _this = this;
810 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
811 if (typeof maxRows === "number") {
812 this.updateLineHeight();
813 }
814 if (typeof maxRows === "number" || async) {
815 /*
816 the defer is needed to:
817 - force "autosize" to activate the scrollbar when this.props.maxRows is passed
818 - support StyledComponents (see #71)
819 */
820 setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
821 }
822 else {
823 this.textarea && autosize(this.textarea);
824 }
825 if (this.textarea) {
826 this.textarea.addEventListener(RESIZED, this.onResize);
827 }
828 };
829 TextareaAutosizeClass.prototype.componentWillUnmount = function () {
830 if (this.textarea) {
831 this.textarea.removeEventListener(RESIZED, this.onResize);
832 autosize.destroy(this.textarea);
833 }
834 };
835 TextareaAutosizeClass.prototype.render = function () {
836 var _this = this;
837 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;
838 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
839 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
840 _this.textarea = element;
841 if (typeof _this.props.innerRef === 'function') {
842 _this.props.innerRef(element);
843 }
844 else if (_this.props.innerRef) {
845 _this.props.innerRef.current = element;
846 }
847 } }), children));
848 };
849 TextareaAutosizeClass.prototype.componentDidUpdate = function () {
850 this.textarea && autosize.update(this.textarea);
851 };
852 TextareaAutosizeClass.defaultProps = {
853 rows: 1,
854 async: false
855 };
856 TextareaAutosizeClass.propTypes = {
857 rows: PropTypes.number,
858 maxRows: PropTypes.number,
859 onResize: PropTypes.func,
860 innerRef: PropTypes.any,
861 async: PropTypes.bool
862 };
863 return TextareaAutosizeClass;
864 }(React.Component));
865 exports.TextareaAutosize = React.forwardRef(function (props, ref) {
866 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
867 });
868
869
870 /***/ }),
871
872 /***/ 773:
873 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
874
875 "use strict";
876 var __webpack_unused_export__;
877
878 __webpack_unused_export__ = true;
879 var TextareaAutosize_1 = __webpack_require__(5438);
880 exports.Z = TextareaAutosize_1.TextareaAutosize;
881
882
883 /***/ }),
884
885 /***/ 4793:
886 /***/ ((module) => {
887
888 var characterMap = {
889 "À": "A",
890 "Á": "A",
891 "Â": "A",
892 "Ã": "A",
893 "Ä": "A",
894 "Å": "A",
895 "Ấ": "A",
896 "Ắ": "A",
897 "Ẳ": "A",
898 "Ẵ": "A",
899 "Ặ": "A",
900 "Æ": "AE",
901 "Ầ": "A",
902 "Ằ": "A",
903 "Ȃ": "A",
904 "Ả": "A",
905 "Ạ": "A",
906 "Ẩ": "A",
907 "Ẫ": "A",
908 "Ậ": "A",
909 "Ç": "C",
910 "Ḉ": "C",
911 "È": "E",
912 "É": "E",
913 "Ê": "E",
914 "Ë": "E",
915 "Ế": "E",
916 "Ḗ": "E",
917 "Ề": "E",
918 "Ḕ": "E",
919 "Ḝ": "E",
920 "Ȇ": "E",
921 "Ẻ": "E",
922 "Ẽ": "E",
923 "Ẹ": "E",
924 "Ể": "E",
925 "Ễ": "E",
926 "Ệ": "E",
927 "Ì": "I",
928 "Í": "I",
929 "Î": "I",
930 "Ï": "I",
931 "Ḯ": "I",
932 "Ȋ": "I",
933 "Ỉ": "I",
934 "Ị": "I",
935 "Ð": "D",
936 "Ñ": "N",
937 "Ò": "O",
938 "Ó": "O",
939 "Ô": "O",
940 "Õ": "O",
941 "Ö": "O",
942 "Ø": "O",
943 "Ố": "O",
944 "Ṍ": "O",
945 "Ṓ": "O",
946 "Ȏ": "O",
947 "Ỏ": "O",
948 "Ọ": "O",
949 "Ổ": "O",
950 "Ỗ": "O",
951 "Ộ": "O",
952 "Ờ": "O",
953 "Ở": "O",
954 "Ỡ": "O",
955 "Ớ": "O",
956 "Ợ": "O",
957 "Ù": "U",
958 "Ú": "U",
959 "Û": "U",
960 "Ü": "U",
961 "Ủ": "U",
962 "Ụ": "U",
963 "Ử": "U",
964 "Ữ": "U",
965 "Ự": "U",
966 "Ý": "Y",
967 "à": "a",
968 "á": "a",
969 "â": "a",
970 "ã": "a",
971 "ä": "a",
972 "å": "a",
973 "ấ": "a",
974 "ắ": "a",
975 "ẳ": "a",
976 "ẵ": "a",
977 "ặ": "a",
978 "æ": "ae",
979 "ầ": "a",
980 "ằ": "a",
981 "ȃ": "a",
982 "ả": "a",
983 "ạ": "a",
984 "ẩ": "a",
985 "ẫ": "a",
986 "ậ": "a",
987 "ç": "c",
988 "ḉ": "c",
989 "è": "e",
990 "é": "e",
991 "ê": "e",
992 "ë": "e",
993 "ế": "e",
994 "ḗ": "e",
995 "ề": "e",
996 "ḕ": "e",
997 "ḝ": "e",
998 "ȇ": "e",
999 "ẻ": "e",
1000 "ẽ": "e",
1001 "ẹ": "e",
1002 "ể": "e",
1003 "ễ": "e",
1004 "ệ": "e",
1005 "ì": "i",
1006 "í": "i",
1007 "î": "i",
1008 "ï": "i",
1009 "ḯ": "i",
1010 "ȋ": "i",
1011 "ỉ": "i",
1012 "ị": "i",
1013 "ð": "d",
1014 "ñ": "n",
1015 "ò": "o",
1016 "ó": "o",
1017 "ô": "o",
1018 "õ": "o",
1019 "ö": "o",
1020 "ø": "o",
1021 "ố": "o",
1022 "ṍ": "o",
1023 "ṓ": "o",
1024 "ȏ": "o",
1025 "ỏ": "o",
1026 "ọ": "o",
1027 "ổ": "o",
1028 "ỗ": "o",
1029 "ộ": "o",
1030 "ờ": "o",
1031 "ở": "o",
1032 "ỡ": "o",
1033 "ớ": "o",
1034 "ợ": "o",
1035 "ù": "u",
1036 "ú": "u",
1037 "û": "u",
1038 "ü": "u",
1039 "ủ": "u",
1040 "ụ": "u",
1041 "ử": "u",
1042 "ữ": "u",
1043 "ự": "u",
1044 "ý": "y",
1045 "ÿ": "y",
1046 "Ā": "A",
1047 "ā": "a",
1048 "Ă": "A",
1049 "ă": "a",
1050 "Ą": "A",
1051 "ą": "a",
1052 "Ć": "C",
1053 "ć": "c",
1054 "Ĉ": "C",
1055 "ĉ": "c",
1056 "Ċ": "C",
1057 "ċ": "c",
1058 "Č": "C",
1059 "č": "c",
1060 "C̆": "C",
1061 "c̆": "c",
1062 "Ď": "D",
1063 "ď": "d",
1064 "Đ": "D",
1065 "đ": "d",
1066 "Ē": "E",
1067 "ē": "e",
1068 "Ĕ": "E",
1069 "ĕ": "e",
1070 "Ė": "E",
1071 "ė": "e",
1072 "Ę": "E",
1073 "ę": "e",
1074 "Ě": "E",
1075 "ě": "e",
1076 "Ĝ": "G",
1077 "Ǵ": "G",
1078 "ĝ": "g",
1079 "ǵ": "g",
1080 "Ğ": "G",
1081 "ğ": "g",
1082 "Ġ": "G",
1083 "ġ": "g",
1084 "Ģ": "G",
1085 "ģ": "g",
1086 "Ĥ": "H",
1087 "ĥ": "h",
1088 "Ħ": "H",
1089 "ħ": "h",
1090 "Ḫ": "H",
1091 "ḫ": "h",
1092 "Ĩ": "I",
1093 "ĩ": "i",
1094 "Ī": "I",
1095 "ī": "i",
1096 "Ĭ": "I",
1097 "ĭ": "i",
1098 "Į": "I",
1099 "į": "i",
1100 "İ": "I",
1101 "ı": "i",
1102 "IJ": "IJ",
1103 "ij": "ij",
1104 "Ĵ": "J",
1105 "ĵ": "j",
1106 "Ķ": "K",
1107 "ķ": "k",
1108 "Ḱ": "K",
1109 "ḱ": "k",
1110 "K̆": "K",
1111 "k̆": "k",
1112 "Ĺ": "L",
1113 "ĺ": "l",
1114 "Ļ": "L",
1115 "ļ": "l",
1116 "Ľ": "L",
1117 "ľ": "l",
1118 "Ŀ": "L",
1119 "ŀ": "l",
1120 "Ł": "l",
1121 "ł": "l",
1122 "Ḿ": "M",
1123 "ḿ": "m",
1124 "M̆": "M",
1125 "m̆": "m",
1126 "Ń": "N",
1127 "ń": "n",
1128 "Ņ": "N",
1129 "ņ": "n",
1130 "Ň": "N",
1131 "ň": "n",
1132 "ʼn": "n",
1133 "N̆": "N",
1134 "n̆": "n",
1135 "Ō": "O",
1136 "ō": "o",
1137 "Ŏ": "O",
1138 "ŏ": "o",
1139 "Ő": "O",
1140 "ő": "o",
1141 "Œ": "OE",
1142 "œ": "oe",
1143 "P̆": "P",
1144 "p̆": "p",
1145 "Ŕ": "R",
1146 "ŕ": "r",
1147 "Ŗ": "R",
1148 "ŗ": "r",
1149 "Ř": "R",
1150 "ř": "r",
1151 "R̆": "R",
1152 "r̆": "r",
1153 "Ȓ": "R",
1154 "ȓ": "r",
1155 "Ś": "S",
1156 "ś": "s",
1157 "Ŝ": "S",
1158 "ŝ": "s",
1159 "Ş": "S",
1160 "Ș": "S",
1161 "ș": "s",
1162 "ş": "s",
1163 "Š": "S",
1164 "š": "s",
1165 "Ţ": "T",
1166 "ţ": "t",
1167 "ț": "t",
1168 "Ț": "T",
1169 "Ť": "T",
1170 "ť": "t",
1171 "Ŧ": "T",
1172 "ŧ": "t",
1173 "T̆": "T",
1174 "t̆": "t",
1175 "Ũ": "U",
1176 "ũ": "u",
1177 "Ū": "U",
1178 "ū": "u",
1179 "Ŭ": "U",
1180 "ŭ": "u",
1181 "Ů": "U",
1182 "ů": "u",
1183 "Ű": "U",
1184 "ű": "u",
1185 "Ų": "U",
1186 "ų": "u",
1187 "Ȗ": "U",
1188 "ȗ": "u",
1189 "V̆": "V",
1190 "v̆": "v",
1191 "Ŵ": "W",
1192 "ŵ": "w",
1193 "Ẃ": "W",
1194 "ẃ": "w",
1195 "X̆": "X",
1196 "x̆": "x",
1197 "Ŷ": "Y",
1198 "ŷ": "y",
1199 "Ÿ": "Y",
1200 "Y̆": "Y",
1201 "y̆": "y",
1202 "Ź": "Z",
1203 "ź": "z",
1204 "Ż": "Z",
1205 "ż": "z",
1206 "Ž": "Z",
1207 "ž": "z",
1208 "ſ": "s",
1209 "ƒ": "f",
1210 "Ơ": "O",
1211 "ơ": "o",
1212 "Ư": "U",
1213 "ư": "u",
1214 "Ǎ": "A",
1215 "ǎ": "a",
1216 "Ǐ": "I",
1217 "ǐ": "i",
1218 "Ǒ": "O",
1219 "ǒ": "o",
1220 "Ǔ": "U",
1221 "ǔ": "u",
1222 "Ǖ": "U",
1223 "ǖ": "u",
1224 "Ǘ": "U",
1225 "ǘ": "u",
1226 "Ǚ": "U",
1227 "ǚ": "u",
1228 "Ǜ": "U",
1229 "ǜ": "u",
1230 "Ứ": "U",
1231 "ứ": "u",
1232 "Ṹ": "U",
1233 "ṹ": "u",
1234 "Ǻ": "A",
1235 "ǻ": "a",
1236 "Ǽ": "AE",
1237 "ǽ": "ae",
1238 "Ǿ": "O",
1239 "ǿ": "o",
1240 "Þ": "TH",
1241 "þ": "th",
1242 "Ṕ": "P",
1243 "ṕ": "p",
1244 "Ṥ": "S",
1245 "ṥ": "s",
1246 "X́": "X",
1247 "x́": "x",
1248 "Ѓ": "Г",
1249 "ѓ": "г",
1250 "Ќ": "К",
1251 "ќ": "к",
1252 "A̋": "A",
1253 "a̋": "a",
1254 "E̋": "E",
1255 "e̋": "e",
1256 "I̋": "I",
1257 "i̋": "i",
1258 "Ǹ": "N",
1259 "ǹ": "n",
1260 "Ồ": "O",
1261 "ồ": "o",
1262 "Ṑ": "O",
1263 "ṑ": "o",
1264 "Ừ": "U",
1265 "ừ": "u",
1266 "Ẁ": "W",
1267 "ẁ": "w",
1268 "Ỳ": "Y",
1269 "ỳ": "y",
1270 "Ȁ": "A",
1271 "ȁ": "a",
1272 "Ȅ": "E",
1273 "ȅ": "e",
1274 "Ȉ": "I",
1275 "ȉ": "i",
1276 "Ȍ": "O",
1277 "ȍ": "o",
1278 "Ȑ": "R",
1279 "ȑ": "r",
1280 "Ȕ": "U",
1281 "ȕ": "u",
1282 "B̌": "B",
1283 "b̌": "b",
1284 "Č̣": "C",
1285 "č̣": "c",
1286 "Ê̌": "E",
1287 "ê̌": "e",
1288 "F̌": "F",
1289 "f̌": "f",
1290 "Ǧ": "G",
1291 "ǧ": "g",
1292 "Ȟ": "H",
1293 "ȟ": "h",
1294 "J̌": "J",
1295 "ǰ": "j",
1296 "Ǩ": "K",
1297 "ǩ": "k",
1298 "M̌": "M",
1299 "m̌": "m",
1300 "P̌": "P",
1301 "p̌": "p",
1302 "Q̌": "Q",
1303 "q̌": "q",
1304 "Ř̩": "R",
1305 "ř̩": "r",
1306 "Ṧ": "S",
1307 "ṧ": "s",
1308 "V̌": "V",
1309 "v̌": "v",
1310 "W̌": "W",
1311 "w̌": "w",
1312 "X̌": "X",
1313 "x̌": "x",
1314 "Y̌": "Y",
1315 "y̌": "y",
1316 "A̧": "A",
1317 "a̧": "a",
1318 "B̧": "B",
1319 "b̧": "b",
1320 "Ḑ": "D",
1321 "ḑ": "d",
1322 "Ȩ": "E",
1323 "ȩ": "e",
1324 "Ɛ̧": "E",
1325 "ɛ̧": "e",
1326 "Ḩ": "H",
1327 "ḩ": "h",
1328 "I̧": "I",
1329 "i̧": "i",
1330 "Ɨ̧": "I",
1331 "ɨ̧": "i",
1332 "M̧": "M",
1333 "m̧": "m",
1334 "O̧": "O",
1335 "o̧": "o",
1336 "Q̧": "Q",
1337 "q̧": "q",
1338 "U̧": "U",
1339 "u̧": "u",
1340 "X̧": "X",
1341 "x̧": "x",
1342 "Z̧": "Z",
1343 "z̧": "z",
1344 "й":"и",
1345 "Й":"И",
1346 "ё":"е",
1347 "Ё":"Е",
1348 };
1349
1350 var chars = Object.keys(characterMap).join('|');
1351 var allAccents = new RegExp(chars, 'g');
1352 var firstAccent = new RegExp(chars, '');
1353
1354 function matcher(match) {
1355 return characterMap[match];
1356 }
1357
1358 var removeAccents = function(string) {
1359 return string.replace(allAccents, matcher);
1360 };
1361
1362 var hasAccents = function(string) {
1363 return !!string.match(firstAccent);
1364 };
1365
1366 module.exports = removeAccents;
1367 module.exports.has = hasAccents;
1368 module.exports.remove = removeAccents;
1369
1370
1371 /***/ }),
1372
1373 /***/ 9196:
1374 /***/ ((module) => {
1375
1376 "use strict";
1377 module.exports = window["React"];
1378
1379 /***/ })
1380
1381 /******/ });
1382 /************************************************************************/
1383 /******/ // The module cache
1384 /******/ var __webpack_module_cache__ = {};
1385 /******/
1386 /******/ // The require function
1387 /******/ function __webpack_require__(moduleId) {
1388 /******/ // Check if module is in cache
1389 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1390 /******/ if (cachedModule !== undefined) {
1391 /******/ return cachedModule.exports;
1392 /******/ }
1393 /******/ // Create a new module (and put it into the cache)
1394 /******/ var module = __webpack_module_cache__[moduleId] = {
1395 /******/ // no module.id needed
1396 /******/ // no module.loaded needed
1397 /******/ exports: {}
1398 /******/ };
1399 /******/
1400 /******/ // Execute the module function
1401 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
1402 /******/
1403 /******/ // Return the exports of the module
1404 /******/ return module.exports;
1405 /******/ }
1406 /******/
1407 /************************************************************************/
1408 /******/ /* webpack/runtime/compat get default export */
1409 /******/ (() => {
1410 /******/ // getDefaultExport function for compatibility with non-harmony modules
1411 /******/ __webpack_require__.n = (module) => {
1412 /******/ var getter = module && module.__esModule ?
1413 /******/ () => (module['default']) :
1414 /******/ () => (module);
1415 /******/ __webpack_require__.d(getter, { a: getter });
1416 /******/ return getter;
1417 /******/ };
1418 /******/ })();
1419 /******/
1420 /******/ /* webpack/runtime/define property getters */
1421 /******/ (() => {
1422 /******/ // define getter functions for harmony exports
1423 /******/ __webpack_require__.d = (exports, definition) => {
1424 /******/ for(var key in definition) {
1425 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1426 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1427 /******/ }
1428 /******/ }
1429 /******/ };
1430 /******/ })();
1431 /******/
1432 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1433 /******/ (() => {
1434 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1435 /******/ })();
1436 /******/
1437 /******/ /* webpack/runtime/make namespace object */
1438 /******/ (() => {
1439 /******/ // define __esModule on exports
1440 /******/ __webpack_require__.r = (exports) => {
1441 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1442 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1443 /******/ }
1444 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1445 /******/ };
1446 /******/ })();
1447 /******/
1448 /************************************************************************/
1449 var __webpack_exports__ = {};
1450 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1451 (() => {
1452 "use strict";
1453 // ESM COMPAT FLAG
1454 __webpack_require__.r(__webpack_exports__);
1455
1456 // EXPORTS
1457 __webpack_require__.d(__webpack_exports__, {
1458 AlignmentToolbar: () => (/* reexport */ AlignmentToolbar),
1459 Autocomplete: () => (/* reexport */ Autocomplete),
1460 AutosaveMonitor: () => (/* reexport */ autosave_monitor),
1461 BlockAlignmentToolbar: () => (/* reexport */ BlockAlignmentToolbar),
1462 BlockControls: () => (/* reexport */ BlockControls),
1463 BlockEdit: () => (/* reexport */ BlockEdit),
1464 BlockEditorKeyboardShortcuts: () => (/* reexport */ BlockEditorKeyboardShortcuts),
1465 BlockFormatControls: () => (/* reexport */ BlockFormatControls),
1466 BlockIcon: () => (/* reexport */ BlockIcon),
1467 BlockInspector: () => (/* reexport */ BlockInspector),
1468 BlockList: () => (/* reexport */ BlockList),
1469 BlockMover: () => (/* reexport */ BlockMover),
1470 BlockNavigationDropdown: () => (/* reexport */ BlockNavigationDropdown),
1471 BlockSelectionClearer: () => (/* reexport */ BlockSelectionClearer),
1472 BlockSettingsMenu: () => (/* reexport */ BlockSettingsMenu),
1473 BlockTitle: () => (/* reexport */ BlockTitle),
1474 BlockToolbar: () => (/* reexport */ BlockToolbar),
1475 CharacterCount: () => (/* reexport */ CharacterCount),
1476 ColorPalette: () => (/* reexport */ ColorPalette),
1477 ContrastChecker: () => (/* reexport */ ContrastChecker),
1478 CopyHandler: () => (/* reexport */ CopyHandler),
1479 DefaultBlockAppender: () => (/* reexport */ DefaultBlockAppender),
1480 DocumentBar: () => (/* reexport */ DocumentBar),
1481 DocumentOutline: () => (/* reexport */ DocumentOutline),
1482 DocumentOutlineCheck: () => (/* reexport */ DocumentOutlineCheck),
1483 EditorHistoryRedo: () => (/* reexport */ editor_history_redo),
1484 EditorHistoryUndo: () => (/* reexport */ editor_history_undo),
1485 EditorKeyboardShortcuts: () => (/* reexport */ EditorKeyboardShortcuts),
1486 EditorKeyboardShortcutsRegister: () => (/* reexport */ register_shortcuts),
1487 EditorNotices: () => (/* reexport */ editor_notices),
1488 EditorProvider: () => (/* reexport */ provider),
1489 EditorSnackbars: () => (/* reexport */ EditorSnackbars),
1490 EntitiesSavedStates: () => (/* reexport */ EntitiesSavedStates),
1491 ErrorBoundary: () => (/* reexport */ error_boundary),
1492 FontSizePicker: () => (/* reexport */ FontSizePicker),
1493 InnerBlocks: () => (/* reexport */ InnerBlocks),
1494 Inserter: () => (/* reexport */ Inserter),
1495 InspectorAdvancedControls: () => (/* reexport */ InspectorAdvancedControls),
1496 InspectorControls: () => (/* reexport */ InspectorControls),
1497 LocalAutosaveMonitor: () => (/* reexport */ local_autosave_monitor),
1498 MediaPlaceholder: () => (/* reexport */ MediaPlaceholder),
1499 MediaUpload: () => (/* reexport */ MediaUpload),
1500 MediaUploadCheck: () => (/* reexport */ MediaUploadCheck),
1501 MultiSelectScrollIntoView: () => (/* reexport */ MultiSelectScrollIntoView),
1502 NavigableToolbar: () => (/* reexport */ NavigableToolbar),
1503 ObserveTyping: () => (/* reexport */ ObserveTyping),
1504 PageAttributesCheck: () => (/* reexport */ page_attributes_check),
1505 PageAttributesOrder: () => (/* reexport */ PageAttributesOrderWithChecks),
1506 PageAttributesPanel: () => (/* reexport */ PageAttributesPanel),
1507 PageAttributesParent: () => (/* reexport */ page_attributes_parent),
1508 PageTemplate: () => (/* reexport */ classic_theme),
1509 PanelColorSettings: () => (/* reexport */ PanelColorSettings),
1510 PlainText: () => (/* reexport */ PlainText),
1511 PluginBlockSettingsMenuItem: () => (/* reexport */ plugin_block_settings_menu_item),
1512 PluginDocumentSettingPanel: () => (/* reexport */ plugin_document_setting_panel),
1513 PluginMoreMenuItem: () => (/* reexport */ plugin_more_menu_item),
1514 PluginPostPublishPanel: () => (/* reexport */ plugin_post_publish_panel),
1515 PluginPostStatusInfo: () => (/* reexport */ plugin_post_status_info),
1516 PluginPrePublishPanel: () => (/* reexport */ plugin_pre_publish_panel),
1517 PluginSidebar: () => (/* reexport */ PluginSidebar),
1518 PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem),
1519 PostAuthor: () => (/* reexport */ post_author),
1520 PostAuthorCheck: () => (/* reexport */ PostAuthorCheck),
1521 PostAuthorPanel: () => (/* reexport */ panel),
1522 PostComments: () => (/* reexport */ post_comments),
1523 PostDiscussionPanel: () => (/* reexport */ PostDiscussionPanel),
1524 PostExcerpt: () => (/* reexport */ PostExcerpt),
1525 PostExcerptCheck: () => (/* reexport */ post_excerpt_check),
1526 PostExcerptPanel: () => (/* reexport */ PostExcerptPanel),
1527 PostFeaturedImage: () => (/* reexport */ post_featured_image),
1528 PostFeaturedImageCheck: () => (/* reexport */ post_featured_image_check),
1529 PostFeaturedImagePanel: () => (/* reexport */ PostFeaturedImagePanel),
1530 PostFormat: () => (/* reexport */ PostFormat),
1531 PostFormatCheck: () => (/* reexport */ post_format_check),
1532 PostLastRevision: () => (/* reexport */ post_last_revision),
1533 PostLastRevisionCheck: () => (/* reexport */ post_last_revision_check),
1534 PostLastRevisionPanel: () => (/* reexport */ post_last_revision_panel),
1535 PostLockedModal: () => (/* reexport */ PostLockedModal),
1536 PostPendingStatus: () => (/* reexport */ post_pending_status),
1537 PostPendingStatusCheck: () => (/* reexport */ post_pending_status_check),
1538 PostPingbacks: () => (/* reexport */ post_pingbacks),
1539 PostPreviewButton: () => (/* reexport */ PostPreviewButton),
1540 PostPublishButton: () => (/* reexport */ post_publish_button),
1541 PostPublishButtonLabel: () => (/* reexport */ PublishButtonLabel),
1542 PostPublishPanel: () => (/* reexport */ post_publish_panel),
1543 PostSavedState: () => (/* reexport */ PostSavedState),
1544 PostSchedule: () => (/* reexport */ PostSchedule),
1545 PostScheduleCheck: () => (/* reexport */ PostScheduleCheck),
1546 PostScheduleLabel: () => (/* reexport */ PostScheduleLabel),
1547 PostSchedulePanel: () => (/* reexport */ PostSchedulePanel),
1548 PostSlug: () => (/* reexport */ PostSlug),
1549 PostSlugCheck: () => (/* reexport */ PostSlugCheck),
1550 PostSticky: () => (/* reexport */ PostSticky),
1551 PostStickyCheck: () => (/* reexport */ PostStickyCheck),
1552 PostSwitchToDraftButton: () => (/* reexport */ PostSwitchToDraftButton),
1553 PostSyncStatus: () => (/* reexport */ PostSyncStatus),
1554 PostTaxonomies: () => (/* reexport */ post_taxonomies),
1555 PostTaxonomiesCheck: () => (/* reexport */ PostTaxonomiesCheck),
1556 PostTaxonomiesFlatTermSelector: () => (/* reexport */ FlatTermSelector),
1557 PostTaxonomiesHierarchicalTermSelector: () => (/* reexport */ HierarchicalTermSelector),
1558 PostTaxonomiesPanel: () => (/* reexport */ post_taxonomies_panel),
1559 PostTemplatePanel: () => (/* reexport */ PostTemplatePanel),
1560 PostTextEditor: () => (/* reexport */ PostTextEditor),
1561 PostTitle: () => (/* reexport */ post_title),
1562 PostTitleRaw: () => (/* reexport */ post_title_raw),
1563 PostTrash: () => (/* reexport */ PostTrash),
1564 PostTrashCheck: () => (/* reexport */ PostTrashCheck),
1565 PostTypeSupportCheck: () => (/* reexport */ post_type_support_check),
1566 PostURL: () => (/* reexport */ PostURL),
1567 PostURLCheck: () => (/* reexport */ PostURLCheck),
1568 PostURLLabel: () => (/* reexport */ PostURLLabel),
1569 PostURLPanel: () => (/* reexport */ PostURLPanel),
1570 PostVisibility: () => (/* reexport */ PostVisibility),
1571 PostVisibilityCheck: () => (/* reexport */ PostVisibilityCheck),
1572 PostVisibilityLabel: () => (/* reexport */ PostVisibilityLabel),
1573 RichText: () => (/* reexport */ RichText),
1574 RichTextShortcut: () => (/* reexport */ RichTextShortcut),
1575 RichTextToolbarButton: () => (/* reexport */ RichTextToolbarButton),
1576 ServerSideRender: () => (/* reexport */ (external_wp_serverSideRender_default())),
1577 SkipToSelectedBlock: () => (/* reexport */ SkipToSelectedBlock),
1578 TableOfContents: () => (/* reexport */ table_of_contents),
1579 TextEditorGlobalKeyboardShortcuts: () => (/* reexport */ TextEditorGlobalKeyboardShortcuts),
1580 ThemeSupportCheck: () => (/* reexport */ ThemeSupportCheck),
1581 TimeToRead: () => (/* reexport */ TimeToRead),
1582 URLInput: () => (/* reexport */ URLInput),
1583 URLInputButton: () => (/* reexport */ URLInputButton),
1584 URLPopover: () => (/* reexport */ URLPopover),
1585 UnsavedChangesWarning: () => (/* reexport */ UnsavedChangesWarning),
1586 VisualEditorGlobalKeyboardShortcuts: () => (/* reexport */ VisualEditorGlobalKeyboardShortcuts),
1587 Warning: () => (/* reexport */ Warning),
1588 WordCount: () => (/* reexport */ WordCount),
1589 WritingFlow: () => (/* reexport */ WritingFlow),
1590 __unstableRichTextInputEvent: () => (/* reexport */ __unstableRichTextInputEvent),
1591 cleanForSlug: () => (/* reexport */ cleanForSlug),
1592 createCustomColorsHOC: () => (/* reexport */ createCustomColorsHOC),
1593 getColorClassName: () => (/* reexport */ getColorClassName),
1594 getColorObjectByAttributeValues: () => (/* reexport */ getColorObjectByAttributeValues),
1595 getColorObjectByColorValue: () => (/* reexport */ getColorObjectByColorValue),
1596 getFontSize: () => (/* reexport */ getFontSize),
1597 getFontSizeClass: () => (/* reexport */ getFontSizeClass),
1598 getTemplatePartIcon: () => (/* reexport */ getTemplatePartIcon),
1599 mediaUpload: () => (/* reexport */ mediaUpload),
1600 privateApis: () => (/* reexport */ privateApis),
1601 registerEntityAction: () => (/* reexport */ api_registerEntityAction),
1602 store: () => (/* reexport */ store_store),
1603 storeConfig: () => (/* reexport */ storeConfig),
1604 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
1605 unregisterEntityAction: () => (/* reexport */ api_unregisterEntityAction),
1606 useEntitiesSavedStatesIsDirty: () => (/* reexport */ useIsDirty),
1607 usePostScheduleLabel: () => (/* reexport */ usePostScheduleLabel),
1608 usePostURLLabel: () => (/* reexport */ usePostURLLabel),
1609 usePostVisibilityLabel: () => (/* reexport */ usePostVisibilityLabel),
1610 userAutocompleter: () => (/* reexport */ user),
1611 withColorContext: () => (/* reexport */ withColorContext),
1612 withColors: () => (/* reexport */ withColors),
1613 withFontSizes: () => (/* reexport */ withFontSizes)
1614 });
1615
1616 // NAMESPACE OBJECT: ./packages/editor/build-module/store/selectors.js
1617 var selectors_namespaceObject = {};
1618 __webpack_require__.r(selectors_namespaceObject);
1619 __webpack_require__.d(selectors_namespaceObject, {
1620 __experimentalGetDefaultTemplatePartAreas: () => (__experimentalGetDefaultTemplatePartAreas),
1621 __experimentalGetDefaultTemplateType: () => (__experimentalGetDefaultTemplateType),
1622 __experimentalGetDefaultTemplateTypes: () => (__experimentalGetDefaultTemplateTypes),
1623 __experimentalGetTemplateInfo: () => (__experimentalGetTemplateInfo),
1624 __unstableIsEditorReady: () => (__unstableIsEditorReady),
1625 canInsertBlockType: () => (canInsertBlockType),
1626 canUserUseUnfilteredHTML: () => (canUserUseUnfilteredHTML),
1627 didPostSaveRequestFail: () => (didPostSaveRequestFail),
1628 didPostSaveRequestSucceed: () => (didPostSaveRequestSucceed),
1629 getActivePostLock: () => (getActivePostLock),
1630 getAdjacentBlockClientId: () => (getAdjacentBlockClientId),
1631 getAutosaveAttribute: () => (getAutosaveAttribute),
1632 getBlock: () => (getBlock),
1633 getBlockAttributes: () => (getBlockAttributes),
1634 getBlockCount: () => (getBlockCount),
1635 getBlockHierarchyRootClientId: () => (getBlockHierarchyRootClientId),
1636 getBlockIndex: () => (getBlockIndex),
1637 getBlockInsertionPoint: () => (getBlockInsertionPoint),
1638 getBlockListSettings: () => (getBlockListSettings),
1639 getBlockMode: () => (getBlockMode),
1640 getBlockName: () => (getBlockName),
1641 getBlockOrder: () => (getBlockOrder),
1642 getBlockRootClientId: () => (getBlockRootClientId),
1643 getBlockSelectionEnd: () => (getBlockSelectionEnd),
1644 getBlockSelectionStart: () => (getBlockSelectionStart),
1645 getBlocks: () => (getBlocks),
1646 getBlocksByClientId: () => (getBlocksByClientId),
1647 getClientIdsOfDescendants: () => (getClientIdsOfDescendants),
1648 getClientIdsWithDescendants: () => (getClientIdsWithDescendants),
1649 getCurrentPost: () => (getCurrentPost),
1650 getCurrentPostAttribute: () => (getCurrentPostAttribute),
1651 getCurrentPostId: () => (getCurrentPostId),
1652 getCurrentPostLastRevisionId: () => (getCurrentPostLastRevisionId),
1653 getCurrentPostRevisionsCount: () => (getCurrentPostRevisionsCount),
1654 getCurrentPostType: () => (getCurrentPostType),
1655 getCurrentTemplateId: () => (getCurrentTemplateId),
1656 getDeviceType: () => (getDeviceType),
1657 getEditedPostAttribute: () => (getEditedPostAttribute),
1658 getEditedPostContent: () => (getEditedPostContent),
1659 getEditedPostPreviewLink: () => (getEditedPostPreviewLink),
1660 getEditedPostSlug: () => (getEditedPostSlug),
1661 getEditedPostVisibility: () => (getEditedPostVisibility),
1662 getEditorBlocks: () => (getEditorBlocks),
1663 getEditorMode: () => (getEditorMode),
1664 getEditorSelection: () => (getEditorSelection),
1665 getEditorSelectionEnd: () => (getEditorSelectionEnd),
1666 getEditorSelectionStart: () => (getEditorSelectionStart),
1667 getEditorSettings: () => (getEditorSettings),
1668 getFirstMultiSelectedBlockClientId: () => (getFirstMultiSelectedBlockClientId),
1669 getGlobalBlockCount: () => (getGlobalBlockCount),
1670 getInserterItems: () => (getInserterItems),
1671 getLastMultiSelectedBlockClientId: () => (getLastMultiSelectedBlockClientId),
1672 getMultiSelectedBlockClientIds: () => (getMultiSelectedBlockClientIds),
1673 getMultiSelectedBlocks: () => (getMultiSelectedBlocks),
1674 getMultiSelectedBlocksEndClientId: () => (getMultiSelectedBlocksEndClientId),
1675 getMultiSelectedBlocksStartClientId: () => (getMultiSelectedBlocksStartClientId),
1676 getNextBlockClientId: () => (getNextBlockClientId),
1677 getPermalink: () => (getPermalink),
1678 getPermalinkParts: () => (getPermalinkParts),
1679 getPostEdits: () => (getPostEdits),
1680 getPostLockUser: () => (getPostLockUser),
1681 getPostTypeLabel: () => (getPostTypeLabel),
1682 getPreviousBlockClientId: () => (getPreviousBlockClientId),
1683 getRenderingMode: () => (getRenderingMode),
1684 getSelectedBlock: () => (getSelectedBlock),
1685 getSelectedBlockClientId: () => (getSelectedBlockClientId),
1686 getSelectedBlockCount: () => (getSelectedBlockCount),
1687 getSelectedBlocksInitialCaretPosition: () => (getSelectedBlocksInitialCaretPosition),
1688 getStateBeforeOptimisticTransaction: () => (getStateBeforeOptimisticTransaction),
1689 getSuggestedPostFormat: () => (getSuggestedPostFormat),
1690 getTemplate: () => (getTemplate),
1691 getTemplateLock: () => (getTemplateLock),
1692 hasChangedContent: () => (hasChangedContent),
1693 hasEditorRedo: () => (hasEditorRedo),
1694 hasEditorUndo: () => (hasEditorUndo),
1695 hasInserterItems: () => (hasInserterItems),
1696 hasMultiSelection: () => (hasMultiSelection),
1697 hasNonPostEntityChanges: () => (hasNonPostEntityChanges),
1698 hasSelectedBlock: () => (hasSelectedBlock),
1699 hasSelectedInnerBlock: () => (hasSelectedInnerBlock),
1700 inSomeHistory: () => (inSomeHistory),
1701 isAncestorMultiSelected: () => (isAncestorMultiSelected),
1702 isAutosavingPost: () => (isAutosavingPost),
1703 isBlockInsertionPointVisible: () => (isBlockInsertionPointVisible),
1704 isBlockMultiSelected: () => (isBlockMultiSelected),
1705 isBlockSelected: () => (isBlockSelected),
1706 isBlockValid: () => (isBlockValid),
1707 isBlockWithinSelection: () => (isBlockWithinSelection),
1708 isCaretWithinFormattedText: () => (isCaretWithinFormattedText),
1709 isCleanNewPost: () => (isCleanNewPost),
1710 isCurrentPostPending: () => (isCurrentPostPending),
1711 isCurrentPostPublished: () => (isCurrentPostPublished),
1712 isCurrentPostScheduled: () => (isCurrentPostScheduled),
1713 isDeletingPost: () => (isDeletingPost),
1714 isEditedPostAutosaveable: () => (isEditedPostAutosaveable),
1715 isEditedPostBeingScheduled: () => (isEditedPostBeingScheduled),
1716 isEditedPostDateFloating: () => (isEditedPostDateFloating),
1717 isEditedPostDirty: () => (isEditedPostDirty),
1718 isEditedPostEmpty: () => (isEditedPostEmpty),
1719 isEditedPostNew: () => (isEditedPostNew),
1720 isEditedPostPublishable: () => (isEditedPostPublishable),
1721 isEditedPostSaveable: () => (isEditedPostSaveable),
1722 isEditorPanelEnabled: () => (isEditorPanelEnabled),
1723 isEditorPanelOpened: () => (isEditorPanelOpened),
1724 isEditorPanelRemoved: () => (isEditorPanelRemoved),
1725 isFirstMultiSelectedBlock: () => (isFirstMultiSelectedBlock),
1726 isInserterOpened: () => (isInserterOpened),
1727 isListViewOpened: () => (isListViewOpened),
1728 isMultiSelecting: () => (isMultiSelecting),
1729 isPermalinkEditable: () => (isPermalinkEditable),
1730 isPostAutosavingLocked: () => (isPostAutosavingLocked),
1731 isPostLockTakeover: () => (isPostLockTakeover),
1732 isPostLocked: () => (isPostLocked),
1733 isPostSavingLocked: () => (isPostSavingLocked),
1734 isPreviewingPost: () => (isPreviewingPost),
1735 isPublishSidebarEnabled: () => (isPublishSidebarEnabled),
1736 isPublishSidebarOpened: () => (isPublishSidebarOpened),
1737 isPublishingPost: () => (isPublishingPost),
1738 isSavingNonPostEntityChanges: () => (isSavingNonPostEntityChanges),
1739 isSavingPost: () => (isSavingPost),
1740 isSelectionEnabled: () => (isSelectionEnabled),
1741 isTyping: () => (isTyping),
1742 isValidTemplate: () => (isValidTemplate)
1743 });
1744
1745 // NAMESPACE OBJECT: ./packages/editor/build-module/store/actions.js
1746 var actions_namespaceObject = {};
1747 __webpack_require__.r(actions_namespaceObject);
1748 __webpack_require__.d(actions_namespaceObject, {
1749 __experimentalTearDownEditor: () => (__experimentalTearDownEditor),
1750 __unstableSaveForPreview: () => (__unstableSaveForPreview),
1751 autosave: () => (autosave),
1752 clearSelectedBlock: () => (clearSelectedBlock),
1753 closePublishSidebar: () => (closePublishSidebar),
1754 createUndoLevel: () => (createUndoLevel),
1755 disablePublishSidebar: () => (disablePublishSidebar),
1756 editPost: () => (editPost),
1757 enablePublishSidebar: () => (enablePublishSidebar),
1758 enterFormattedText: () => (enterFormattedText),
1759 exitFormattedText: () => (exitFormattedText),
1760 hideInsertionPoint: () => (hideInsertionPoint),
1761 insertBlock: () => (insertBlock),
1762 insertBlocks: () => (insertBlocks),
1763 insertDefaultBlock: () => (insertDefaultBlock),
1764 lockPostAutosaving: () => (lockPostAutosaving),
1765 lockPostSaving: () => (lockPostSaving),
1766 mergeBlocks: () => (mergeBlocks),
1767 moveBlockToPosition: () => (moveBlockToPosition),
1768 moveBlocksDown: () => (moveBlocksDown),
1769 moveBlocksUp: () => (moveBlocksUp),
1770 multiSelect: () => (multiSelect),
1771 openPublishSidebar: () => (openPublishSidebar),
1772 receiveBlocks: () => (receiveBlocks),
1773 redo: () => (redo),
1774 refreshPost: () => (refreshPost),
1775 removeBlock: () => (removeBlock),
1776 removeBlocks: () => (removeBlocks),
1777 removeEditorPanel: () => (removeEditorPanel),
1778 replaceBlock: () => (replaceBlock),
1779 replaceBlocks: () => (replaceBlocks),
1780 resetBlocks: () => (resetBlocks),
1781 resetEditorBlocks: () => (resetEditorBlocks),
1782 resetPost: () => (resetPost),
1783 savePost: () => (savePost),
1784 selectBlock: () => (selectBlock),
1785 setDeviceType: () => (setDeviceType),
1786 setEditedPost: () => (setEditedPost),
1787 setIsInserterOpened: () => (setIsInserterOpened),
1788 setIsListViewOpened: () => (setIsListViewOpened),
1789 setRenderingMode: () => (setRenderingMode),
1790 setTemplateValidity: () => (setTemplateValidity),
1791 setupEditor: () => (setupEditor),
1792 setupEditorState: () => (setupEditorState),
1793 showInsertionPoint: () => (showInsertionPoint),
1794 startMultiSelect: () => (startMultiSelect),
1795 startTyping: () => (startTyping),
1796 stopMultiSelect: () => (stopMultiSelect),
1797 stopTyping: () => (stopTyping),
1798 switchEditorMode: () => (switchEditorMode),
1799 synchronizeTemplate: () => (synchronizeTemplate),
1800 toggleBlockMode: () => (toggleBlockMode),
1801 toggleDistractionFree: () => (toggleDistractionFree),
1802 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled),
1803 toggleEditorPanelOpened: () => (toggleEditorPanelOpened),
1804 togglePublishSidebar: () => (togglePublishSidebar),
1805 toggleSelection: () => (toggleSelection),
1806 trashPost: () => (trashPost),
1807 undo: () => (undo),
1808 unlockPostAutosaving: () => (unlockPostAutosaving),
1809 unlockPostSaving: () => (unlockPostSaving),
1810 updateBlock: () => (updateBlock),
1811 updateBlockAttributes: () => (updateBlockAttributes),
1812 updateBlockListSettings: () => (updateBlockListSettings),
1813 updateEditorSettings: () => (updateEditorSettings),
1814 updatePost: () => (updatePost),
1815 updatePostLock: () => (updatePostLock)
1816 });
1817
1818 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-actions.js
1819 var store_private_actions_namespaceObject = {};
1820 __webpack_require__.r(store_private_actions_namespaceObject);
1821 __webpack_require__.d(store_private_actions_namespaceObject, {
1822 createTemplate: () => (createTemplate),
1823 hideBlockTypes: () => (hideBlockTypes),
1824 registerEntityAction: () => (registerEntityAction),
1825 removeTemplates: () => (removeTemplates),
1826 revertTemplate: () => (revertTemplate),
1827 saveDirtyEntities: () => (saveDirtyEntities),
1828 setCurrentTemplateId: () => (setCurrentTemplateId),
1829 showBlockTypes: () => (showBlockTypes),
1830 unregisterEntityAction: () => (unregisterEntityAction)
1831 });
1832
1833 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-selectors.js
1834 var store_private_selectors_namespaceObject = {};
1835 __webpack_require__.r(store_private_selectors_namespaceObject);
1836 __webpack_require__.d(store_private_selectors_namespaceObject, {
1837 getCurrentTemplateTemplateParts: () => (getCurrentTemplateTemplateParts),
1838 getEntityActions: () => (private_selectors_getEntityActions),
1839 getInserterSidebarToggleRef: () => (getInserterSidebarToggleRef),
1840 getInsertionPoint: () => (getInsertionPoint),
1841 getListViewToggleRef: () => (getListViewToggleRef),
1842 getPostIcon: () => (getPostIcon),
1843 hasPostMetaChanges: () => (hasPostMetaChanges)
1844 });
1845
1846 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1847 var store_actions_namespaceObject = {};
1848 __webpack_require__.r(store_actions_namespaceObject);
1849 __webpack_require__.d(store_actions_namespaceObject, {
1850 closeModal: () => (closeModal),
1851 disableComplementaryArea: () => (disableComplementaryArea),
1852 enableComplementaryArea: () => (enableComplementaryArea),
1853 openModal: () => (openModal),
1854 pinItem: () => (pinItem),
1855 setDefaultComplementaryArea: () => (setDefaultComplementaryArea),
1856 setFeatureDefaults: () => (setFeatureDefaults),
1857 setFeatureValue: () => (setFeatureValue),
1858 toggleFeature: () => (toggleFeature),
1859 unpinItem: () => (unpinItem)
1860 });
1861
1862 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1863 var store_selectors_namespaceObject = {};
1864 __webpack_require__.r(store_selectors_namespaceObject);
1865 __webpack_require__.d(store_selectors_namespaceObject, {
1866 getActiveComplementaryArea: () => (getActiveComplementaryArea),
1867 isComplementaryAreaLoading: () => (isComplementaryAreaLoading),
1868 isFeatureActive: () => (isFeatureActive),
1869 isItemPinned: () => (isItemPinned),
1870 isModalActive: () => (isModalActive)
1871 });
1872
1873 // NAMESPACE OBJECT: ./packages/interface/build-module/index.js
1874 var build_module_namespaceObject = {};
1875 __webpack_require__.r(build_module_namespaceObject);
1876 __webpack_require__.d(build_module_namespaceObject, {
1877 ActionItem: () => (action_item),
1878 ComplementaryArea: () => (complementary_area),
1879 ComplementaryAreaMoreMenuItem: () => (ComplementaryAreaMoreMenuItem),
1880 FullscreenMode: () => (fullscreen_mode),
1881 InterfaceSkeleton: () => (interface_skeleton),
1882 NavigableRegion: () => (NavigableRegion),
1883 PinnedItems: () => (pinned_items),
1884 store: () => (store)
1885 });
1886
1887 ;// CONCATENATED MODULE: external ["wp","blocks"]
1888 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1889 ;// CONCATENATED MODULE: external ["wp","data"]
1890 const external_wp_data_namespaceObject = window["wp"]["data"];
1891 ;// CONCATENATED MODULE: external ["wp","privateApis"]
1892 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
1893 ;// CONCATENATED MODULE: ./packages/editor/build-module/lock-unlock.js
1894 /**
1895 * WordPress dependencies
1896 */
1897
1898 const {
1899 lock,
1900 unlock
1901 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor');
1902
1903 ;// CONCATENATED MODULE: external ["wp","i18n"]
1904 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
1905 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1906 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1907 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/pattern-overrides.js
1908 /**
1909 * WordPress dependencies
1910 */
1911
1912
1913 const CONTENT = 'content';
1914 /* harmony default export */ const pattern_overrides = ({
1915 name: 'core/pattern-overrides',
1916 label: (0,external_wp_i18n_namespaceObject._x)('Pattern Overrides', 'block bindings source'),
1917 getValue({
1918 registry,
1919 clientId,
1920 attributeName
1921 }) {
1922 const {
1923 getBlockAttributes,
1924 getBlockParentsByBlockName
1925 } = registry.select(external_wp_blockEditor_namespaceObject.store);
1926 const currentBlockAttributes = getBlockAttributes(clientId);
1927 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
1928 const overridableValue = getBlockAttributes(patternClientId)?.[CONTENT]?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
1929
1930 // If there is no pattern client ID, or it is not overwritten, return the default value.
1931 if (!patternClientId || overridableValue === undefined) {
1932 return currentBlockAttributes[attributeName];
1933 }
1934 return overridableValue === '' ? undefined : overridableValue;
1935 },
1936 setValues({
1937 registry,
1938 clientId,
1939 attributes
1940 }) {
1941 const {
1942 getBlockAttributes,
1943 getBlockParentsByBlockName,
1944 getBlocks
1945 } = registry.select(external_wp_blockEditor_namespaceObject.store);
1946 const currentBlockAttributes = getBlockAttributes(clientId);
1947 const blockName = currentBlockAttributes?.metadata?.name;
1948 if (!blockName) {
1949 return;
1950 }
1951 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
1952
1953 // If there is no pattern client ID, sync blocks with the same name and same attributes.
1954 if (!patternClientId) {
1955 const syncBlocksWithSameName = blocks => {
1956 for (const block of blocks) {
1957 if (block.attributes?.metadata?.name === blockName) {
1958 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(block.clientId, attributes);
1959 }
1960 syncBlocksWithSameName(block.innerBlocks);
1961 }
1962 };
1963 syncBlocksWithSameName(getBlocks());
1964 return;
1965 }
1966 const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
1967 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(patternClientId, {
1968 [CONTENT]: {
1969 ...currentBindingValue,
1970 [blockName]: {
1971 ...currentBindingValue?.[blockName],
1972 ...Object.entries(attributes).reduce((acc, [key, value]) => {
1973 // TODO: We need a way to represent `undefined` in the serialized overrides.
1974 // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
1975 // We use an empty string to represent undefined for now until
1976 // we support a richer format for overrides and the block bindings API.
1977 acc[key] = value === undefined ? '' : value;
1978 return acc;
1979 }, {})
1980 }
1981 }
1982 });
1983 },
1984 canUserEditValue: () => true
1985 });
1986
1987 ;// CONCATENATED MODULE: external ["wp","coreData"]
1988 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1989 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/defaults.js
1990 /**
1991 * WordPress dependencies
1992 */
1993
1994
1995 /**
1996 * The default post editor settings.
1997 *
1998 * @property {boolean|Array} allowedBlockTypes Allowed block types
1999 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
2000 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
2001 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
2002 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
2003 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
2004 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
2005 * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
2006 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
2007 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
2008 * @property {Array?} availableTemplates The available post templates
2009 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
2010 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
2011 * @property {number} maxUploadFileSize Maximum upload file size
2012 * @property {boolean} supportsLayout Whether the editor supports layouts.
2013 */
2014 const EDITOR_SETTINGS_DEFAULTS = {
2015 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
2016 richEditingEnabled: true,
2017 codeEditingEnabled: true,
2018 fontLibraryEnabled: true,
2019 enableCustomFields: undefined,
2020 defaultRenderingMode: 'post-only'
2021 };
2022
2023 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/reducer.js
2024 /**
2025 * WordPress dependencies
2026 */
2027
2028 function actions(state = {}, action) {
2029 var _state$action$kind$ac;
2030 switch (action.type) {
2031 case 'REGISTER_ENTITY_ACTION':
2032 return {
2033 ...state,
2034 [action.kind]: {
2035 [action.name]: [...((_state$action$kind$ac = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac !== void 0 ? _state$action$kind$ac : []), action.config]
2036 }
2037 };
2038 case 'UNREGISTER_ENTITY_ACTION':
2039 {
2040 var _state$action$kind$ac2;
2041 return {
2042 ...state,
2043 [action.kind]: ((_state$action$kind$ac2 = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac2 !== void 0 ? _state$action$kind$ac2 : []).filter(_action => _action.id !== action.actionId)
2044 };
2045 }
2046 }
2047 return state;
2048 }
2049 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2050 actions
2051 }));
2052
2053 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/reducer.js
2054 /**
2055 * WordPress dependencies
2056 */
2057
2058
2059 /**
2060 * Internal dependencies
2061 */
2062
2063
2064
2065 /**
2066 * Returns a post attribute value, flattening nested rendered content using its
2067 * raw value in place of its original object form.
2068 *
2069 * @param {*} value Original value.
2070 *
2071 * @return {*} Raw value.
2072 */
2073 function getPostRawValue(value) {
2074 if (value && 'object' === typeof value && 'raw' in value) {
2075 return value.raw;
2076 }
2077 return value;
2078 }
2079
2080 /**
2081 * Returns true if the two object arguments have the same keys, or false
2082 * otherwise.
2083 *
2084 * @param {Object} a First object.
2085 * @param {Object} b Second object.
2086 *
2087 * @return {boolean} Whether the two objects have the same keys.
2088 */
2089 function hasSameKeys(a, b) {
2090 const keysA = Object.keys(a).sort();
2091 const keysB = Object.keys(b).sort();
2092 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key);
2093 }
2094
2095 /**
2096 * Returns true if, given the currently dispatching action and the previously
2097 * dispatched action, the two actions are editing the same post property, or
2098 * false otherwise.
2099 *
2100 * @param {Object} action Currently dispatching action.
2101 * @param {Object} previousAction Previously dispatched action.
2102 *
2103 * @return {boolean} Whether actions are updating the same post property.
2104 */
2105 function isUpdatingSamePostProperty(action, previousAction) {
2106 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
2107 }
2108
2109 /**
2110 * Returns true if, given the currently dispatching action and the previously
2111 * dispatched action, the two actions are modifying the same property such that
2112 * undo history should be batched.
2113 *
2114 * @param {Object} action Currently dispatching action.
2115 * @param {Object} previousAction Previously dispatched action.
2116 *
2117 * @return {boolean} Whether to overwrite present state.
2118 */
2119 function shouldOverwriteState(action, previousAction) {
2120 if (action.type === 'RESET_EDITOR_BLOCKS') {
2121 return !action.shouldCreateUndoLevel;
2122 }
2123 if (!previousAction || action.type !== previousAction.type) {
2124 return false;
2125 }
2126 return isUpdatingSamePostProperty(action, previousAction);
2127 }
2128 function postId(state = null, action) {
2129 switch (action.type) {
2130 case 'SET_EDITED_POST':
2131 return action.postId;
2132 }
2133 return state;
2134 }
2135 function templateId(state = null, action) {
2136 switch (action.type) {
2137 case 'SET_CURRENT_TEMPLATE_ID':
2138 return action.id;
2139 }
2140 return state;
2141 }
2142 function postType(state = null, action) {
2143 switch (action.type) {
2144 case 'SET_EDITED_POST':
2145 return action.postType;
2146 }
2147 return state;
2148 }
2149
2150 /**
2151 * Reducer returning whether the post blocks match the defined template or not.
2152 *
2153 * @param {Object} state Current state.
2154 * @param {Object} action Dispatched action.
2155 *
2156 * @return {boolean} Updated state.
2157 */
2158 function template(state = {
2159 isValid: true
2160 }, action) {
2161 switch (action.type) {
2162 case 'SET_TEMPLATE_VALIDITY':
2163 return {
2164 ...state,
2165 isValid: action.isValid
2166 };
2167 }
2168 return state;
2169 }
2170
2171 /**
2172 * Reducer returning current network request state (whether a request to
2173 * the WP REST API is in progress, successful, or failed).
2174 *
2175 * @param {Object} state Current state.
2176 * @param {Object} action Dispatched action.
2177 *
2178 * @return {Object} Updated state.
2179 */
2180 function saving(state = {}, action) {
2181 switch (action.type) {
2182 case 'REQUEST_POST_UPDATE_START':
2183 case 'REQUEST_POST_UPDATE_FINISH':
2184 return {
2185 pending: action.type === 'REQUEST_POST_UPDATE_START',
2186 options: action.options || {}
2187 };
2188 }
2189 return state;
2190 }
2191
2192 /**
2193 * Reducer returning deleting post request state.
2194 *
2195 * @param {Object} state Current state.
2196 * @param {Object} action Dispatched action.
2197 *
2198 * @return {Object} Updated state.
2199 */
2200 function deleting(state = {}, action) {
2201 switch (action.type) {
2202 case 'REQUEST_POST_DELETE_START':
2203 case 'REQUEST_POST_DELETE_FINISH':
2204 return {
2205 pending: action.type === 'REQUEST_POST_DELETE_START'
2206 };
2207 }
2208 return state;
2209 }
2210
2211 /**
2212 * Post Lock State.
2213 *
2214 * @typedef {Object} PostLockState
2215 *
2216 * @property {boolean} isLocked Whether the post is locked.
2217 * @property {?boolean} isTakeover Whether the post editing has been taken over.
2218 * @property {?boolean} activePostLock Active post lock value.
2219 * @property {?Object} user User that took over the post.
2220 */
2221
2222 /**
2223 * Reducer returning the post lock status.
2224 *
2225 * @param {PostLockState} state Current state.
2226 * @param {Object} action Dispatched action.
2227 *
2228 * @return {PostLockState} Updated state.
2229 */
2230 function postLock(state = {
2231 isLocked: false
2232 }, action) {
2233 switch (action.type) {
2234 case 'UPDATE_POST_LOCK':
2235 return action.lock;
2236 }
2237 return state;
2238 }
2239
2240 /**
2241 * Post saving lock.
2242 *
2243 * When post saving is locked, the post cannot be published or updated.
2244 *
2245 * @param {PostLockState} state Current state.
2246 * @param {Object} action Dispatched action.
2247 *
2248 * @return {PostLockState} Updated state.
2249 */
2250 function postSavingLock(state = {}, action) {
2251 switch (action.type) {
2252 case 'LOCK_POST_SAVING':
2253 return {
2254 ...state,
2255 [action.lockName]: true
2256 };
2257 case 'UNLOCK_POST_SAVING':
2258 {
2259 const {
2260 [action.lockName]: removedLockName,
2261 ...restState
2262 } = state;
2263 return restState;
2264 }
2265 }
2266 return state;
2267 }
2268
2269 /**
2270 * Post autosaving lock.
2271 *
2272 * When post autosaving is locked, the post will not autosave.
2273 *
2274 * @param {PostLockState} state Current state.
2275 * @param {Object} action Dispatched action.
2276 *
2277 * @return {PostLockState} Updated state.
2278 */
2279 function postAutosavingLock(state = {}, action) {
2280 switch (action.type) {
2281 case 'LOCK_POST_AUTOSAVING':
2282 return {
2283 ...state,
2284 [action.lockName]: true
2285 };
2286 case 'UNLOCK_POST_AUTOSAVING':
2287 {
2288 const {
2289 [action.lockName]: removedLockName,
2290 ...restState
2291 } = state;
2292 return restState;
2293 }
2294 }
2295 return state;
2296 }
2297
2298 /**
2299 * Reducer returning the post editor setting.
2300 *
2301 * @param {Object} state Current state.
2302 * @param {Object} action Dispatched action.
2303 *
2304 * @return {Object} Updated state.
2305 */
2306 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2307 switch (action.type) {
2308 case 'UPDATE_EDITOR_SETTINGS':
2309 return {
2310 ...state,
2311 ...action.settings
2312 };
2313 }
2314 return state;
2315 }
2316 function renderingMode(state = 'post-only', action) {
2317 switch (action.type) {
2318 case 'SET_RENDERING_MODE':
2319 return action.mode;
2320 }
2321 return state;
2322 }
2323
2324 /**
2325 * Reducer returning the editing canvas device type.
2326 *
2327 * @param {Object} state Current state.
2328 * @param {Object} action Dispatched action.
2329 *
2330 * @return {Object} Updated state.
2331 */
2332 function deviceType(state = 'Desktop', action) {
2333 switch (action.type) {
2334 case 'SET_DEVICE_TYPE':
2335 return action.deviceType;
2336 }
2337 return state;
2338 }
2339
2340 /**
2341 * Reducer storing the list of all programmatically removed panels.
2342 *
2343 * @param {Array} state Current state.
2344 * @param {Object} action Action object.
2345 *
2346 * @return {Array} Updated state.
2347 */
2348 function removedPanels(state = [], action) {
2349 switch (action.type) {
2350 case 'REMOVE_PANEL':
2351 if (!state.includes(action.panelName)) {
2352 return [...state, action.panelName];
2353 }
2354 }
2355 return state;
2356 }
2357
2358 /**
2359 * Reducer to set the block inserter panel open or closed.
2360 *
2361 * Note: this reducer interacts with the list view panel reducer
2362 * to make sure that only one of the two panels is open at the same time.
2363 *
2364 * @param {Object} state Current state.
2365 * @param {Object} action Dispatched action.
2366 */
2367 function blockInserterPanel(state = false, action) {
2368 switch (action.type) {
2369 case 'SET_IS_LIST_VIEW_OPENED':
2370 return action.isOpen ? false : state;
2371 case 'SET_IS_INSERTER_OPENED':
2372 return action.value;
2373 }
2374 return state;
2375 }
2376
2377 /**
2378 * Reducer to set the list view panel open or closed.
2379 *
2380 * Note: this reducer interacts with the inserter panel reducer
2381 * to make sure that only one of the two panels is open at the same time.
2382 *
2383 * @param {Object} state Current state.
2384 * @param {Object} action Dispatched action.
2385 */
2386 function listViewPanel(state = false, action) {
2387 switch (action.type) {
2388 case 'SET_IS_INSERTER_OPENED':
2389 return action.value ? false : state;
2390 case 'SET_IS_LIST_VIEW_OPENED':
2391 return action.isOpen;
2392 }
2393 return state;
2394 }
2395
2396 /**
2397 * This reducer does nothing aside initializing a ref to the list view toggle.
2398 * We will have a unique ref per "editor" instance.
2399 *
2400 * @param {Object} state
2401 * @return {Object} Reference to the list view toggle button.
2402 */
2403 function listViewToggleRef(state = {
2404 current: null
2405 }) {
2406 return state;
2407 }
2408
2409 /**
2410 * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
2411 * We will have a unique ref per "editor" instance.
2412 *
2413 * @param {Object} state
2414 * @return {Object} Reference to the inserter sidebar toggle button.
2415 */
2416 function inserterSidebarToggleRef(state = {
2417 current: null
2418 }) {
2419 return state;
2420 }
2421 function publishSidebarActive(state = false, action) {
2422 switch (action.type) {
2423 case 'OPEN_PUBLISH_SIDEBAR':
2424 return true;
2425 case 'CLOSE_PUBLISH_SIDEBAR':
2426 return false;
2427 case 'TOGGLE_PUBLISH_SIDEBAR':
2428 return !state;
2429 }
2430 return state;
2431 }
2432 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2433 postId,
2434 postType,
2435 templateId,
2436 saving,
2437 deleting,
2438 postLock,
2439 template,
2440 postSavingLock,
2441 editorSettings,
2442 postAutosavingLock,
2443 renderingMode,
2444 deviceType,
2445 removedPanels,
2446 blockInserterPanel,
2447 inserterSidebarToggleRef,
2448 listViewPanel,
2449 listViewToggleRef,
2450 publishSidebarActive,
2451 dataviews: reducer
2452 }));
2453
2454 ;// CONCATENATED MODULE: external ["wp","date"]
2455 const external_wp_date_namespaceObject = window["wp"]["date"];
2456 ;// CONCATENATED MODULE: external ["wp","url"]
2457 const external_wp_url_namespaceObject = window["wp"]["url"];
2458 ;// CONCATENATED MODULE: external ["wp","deprecated"]
2459 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2460 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2461 ;// CONCATENATED MODULE: external ["wp","element"]
2462 const external_wp_element_namespaceObject = window["wp"]["element"];
2463 ;// CONCATENATED MODULE: external ["wp","primitives"]
2464 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
2465 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
2466 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
2467 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
2468 /**
2469 * WordPress dependencies
2470 */
2471
2472
2473 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2474 xmlns: "http://www.w3.org/2000/svg",
2475 viewBox: "0 0 24 24",
2476 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2477 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"
2478 })
2479 });
2480 /* harmony default export */ const library_layout = (layout);
2481
2482 ;// CONCATENATED MODULE: external ["wp","preferences"]
2483 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
2484 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/constants.js
2485 /**
2486 * Set of post properties for which edits should assume a merging behavior,
2487 * assuming an object value.
2488 *
2489 * @type {Set}
2490 */
2491 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
2492
2493 /**
2494 * Constant for the store module (or reducer) key.
2495 *
2496 * @type {string}
2497 */
2498 const STORE_NAME = 'core/editor';
2499 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
2500 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
2501 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
2502 const ONE_MINUTE_IN_MS = 60 * 1000;
2503 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
2504 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';
2505 const TEMPLATE_POST_TYPE = 'wp_template';
2506 const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
2507 const PATTERN_POST_TYPE = 'wp_block';
2508 const NAVIGATION_POST_TYPE = 'wp_navigation';
2509 const TEMPLATE_ORIGINS = {
2510 custom: 'custom',
2511 theme: 'theme',
2512 plugin: 'plugin'
2513 };
2514 const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
2515 const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
2516
2517 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/header.js
2518 /**
2519 * WordPress dependencies
2520 */
2521
2522
2523 const header = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2524 xmlns: "http://www.w3.org/2000/svg",
2525 viewBox: "0 0 24 24",
2526 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2527 d: "M18.5 10.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"
2528 })
2529 });
2530 /* harmony default export */ const library_header = (header);
2531
2532 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/footer.js
2533 /**
2534 * WordPress dependencies
2535 */
2536
2537
2538 const footer = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2539 xmlns: "http://www.w3.org/2000/svg",
2540 viewBox: "0 0 24 24",
2541 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2542 fillRule: "evenodd",
2543 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
2544 })
2545 });
2546 /* harmony default export */ const library_footer = (footer);
2547
2548 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/sidebar.js
2549 /**
2550 * WordPress dependencies
2551 */
2552
2553
2554 const sidebar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2555 xmlns: "http://www.w3.org/2000/svg",
2556 viewBox: "0 0 24 24",
2557 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2558 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.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
2559 })
2560 });
2561 /* harmony default export */ const library_sidebar = (sidebar);
2562
2563 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
2564 /**
2565 * WordPress dependencies
2566 */
2567
2568
2569 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2570 xmlns: "http://www.w3.org/2000/svg",
2571 viewBox: "0 0 24 24",
2572 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2573 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"
2574 })
2575 });
2576 /* harmony default export */ const symbol_filled = (symbolFilled);
2577
2578 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/get-template-part-icon.js
2579 /**
2580 * WordPress dependencies
2581 */
2582
2583 /**
2584 * Helper function to retrieve the corresponding icon by name.
2585 *
2586 * @param {string} iconName The name of the icon.
2587 *
2588 * @return {Object} The corresponding icon.
2589 */
2590 function getTemplatePartIcon(iconName) {
2591 if ('header' === iconName) {
2592 return library_header;
2593 } else if ('footer' === iconName) {
2594 return library_footer;
2595 } else if ('sidebar' === iconName) {
2596 return library_sidebar;
2597 }
2598 return symbol_filled;
2599 }
2600
2601 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/selectors.js
2602 /**
2603 * WordPress dependencies
2604 */
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616 /**
2617 * Internal dependencies
2618 */
2619
2620
2621
2622
2623 /**
2624 * Shared reference to an empty object for cases where it is important to avoid
2625 * returning a new object reference on every invocation, as in a connected or
2626 * other pure component which performs `shouldComponentUpdate` check on props.
2627 * This should be used as a last resort, since the normalized data should be
2628 * maintained by the reducer result in state.
2629 */
2630 const EMPTY_OBJECT = {};
2631
2632 /**
2633 * Returns true if any past editor history snapshots exist, or false otherwise.
2634 *
2635 * @param {Object} state Global application state.
2636 *
2637 * @return {boolean} Whether undo history exists.
2638 */
2639 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2640 return select(external_wp_coreData_namespaceObject.store).hasUndo();
2641 });
2642
2643 /**
2644 * Returns true if any future editor history snapshots exist, or false
2645 * otherwise.
2646 *
2647 * @param {Object} state Global application state.
2648 *
2649 * @return {boolean} Whether redo history exists.
2650 */
2651 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2652 return select(external_wp_coreData_namespaceObject.store).hasRedo();
2653 });
2654
2655 /**
2656 * Returns true if the currently edited post is yet to be saved, or false if
2657 * the post has been saved.
2658 *
2659 * @param {Object} state Global application state.
2660 *
2661 * @return {boolean} Whether the post is new.
2662 */
2663 function isEditedPostNew(state) {
2664 return getCurrentPost(state).status === 'auto-draft';
2665 }
2666
2667 /**
2668 * Returns true if content includes unsaved changes, or false otherwise.
2669 *
2670 * @param {Object} state Editor state.
2671 *
2672 * @return {boolean} Whether content includes unsaved changes.
2673 */
2674 function hasChangedContent(state) {
2675 const edits = getPostEdits(state);
2676 return 'content' in edits;
2677 }
2678
2679 /**
2680 * Returns true if there are unsaved values for the current edit session, or
2681 * false if the editing state matches the saved or new post.
2682 *
2683 * @param {Object} state Global application state.
2684 *
2685 * @return {boolean} Whether unsaved values exist.
2686 */
2687 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2688 // Edits should contain only fields which differ from the saved post (reset
2689 // at initial load and save complete). Thus, a non-empty edits state can be
2690 // inferred to contain unsaved values.
2691 const postType = getCurrentPostType(state);
2692 const postId = getCurrentPostId(state);
2693 return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId);
2694 });
2695
2696 /**
2697 * Returns true if there are unsaved edits for entities other than
2698 * the editor's post, and false otherwise.
2699 *
2700 * @param {Object} state Global application state.
2701 *
2702 * @return {boolean} Whether there are edits or not.
2703 */
2704 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2705 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2706 const {
2707 type,
2708 id
2709 } = getCurrentPost(state);
2710 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2711 });
2712
2713 /**
2714 * Returns true if there are no unsaved values for the current edit session and
2715 * if the currently edited post is new (has never been saved before).
2716 *
2717 * @param {Object} state Global application state.
2718 *
2719 * @return {boolean} Whether new post and unsaved values exist.
2720 */
2721 function isCleanNewPost(state) {
2722 return !isEditedPostDirty(state) && isEditedPostNew(state);
2723 }
2724
2725 /**
2726 * Returns the post currently being edited in its last known saved state, not
2727 * including unsaved edits. Returns an object containing relevant default post
2728 * values if the post has not yet been saved.
2729 *
2730 * @param {Object} state Global application state.
2731 *
2732 * @return {Object} Post object.
2733 */
2734 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2735 const postId = getCurrentPostId(state);
2736 const postType = getCurrentPostType(state);
2737 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2738 if (post) {
2739 return post;
2740 }
2741
2742 // This exists for compatibility with the previous selector behavior
2743 // which would guarantee an object return based on the editor reducer's
2744 // default empty object state.
2745 return EMPTY_OBJECT;
2746 });
2747
2748 /**
2749 * Returns the post type of the post currently being edited.
2750 *
2751 * @param {Object} state Global application state.
2752 *
2753 * @return {string} Post type.
2754 */
2755 function getCurrentPostType(state) {
2756 return state.postType;
2757 }
2758
2759 /**
2760 * Returns the ID of the post currently being edited, or null if the post has
2761 * not yet been saved.
2762 *
2763 * @param {Object} state Global application state.
2764 *
2765 * @return {?number} ID of current post.
2766 */
2767 function getCurrentPostId(state) {
2768 return state.postId;
2769 }
2770
2771 /**
2772 * Returns the template ID currently being rendered/edited
2773 *
2774 * @param {Object} state Global application state.
2775 *
2776 * @return {string?} Template ID.
2777 */
2778 function getCurrentTemplateId(state) {
2779 return state.templateId;
2780 }
2781
2782 /**
2783 * Returns the number of revisions of the post currently being edited.
2784 *
2785 * @param {Object} state Global application state.
2786 *
2787 * @return {number} Number of revisions.
2788 */
2789 function getCurrentPostRevisionsCount(state) {
2790 var _getCurrentPost$_link;
2791 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0;
2792 }
2793
2794 /**
2795 * Returns the last revision ID of the post currently being edited,
2796 * or null if the post has no revisions.
2797 *
2798 * @param {Object} state Global application state.
2799 *
2800 * @return {?number} ID of the last revision.
2801 */
2802 function getCurrentPostLastRevisionId(state) {
2803 var _getCurrentPost$_link2;
2804 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null;
2805 }
2806
2807 /**
2808 * Returns any post values which have been changed in the editor but not yet
2809 * been saved.
2810 *
2811 * @param {Object} state Global application state.
2812 *
2813 * @return {Object} Object of key value pairs comprising unsaved edits.
2814 */
2815 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2816 const postType = getCurrentPostType(state);
2817 const postId = getCurrentPostId(state);
2818 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
2819 });
2820
2821 /**
2822 * Returns an attribute value of the saved post.
2823 *
2824 * @param {Object} state Global application state.
2825 * @param {string} attributeName Post attribute name.
2826 *
2827 * @return {*} Post attribute value.
2828 */
2829 function getCurrentPostAttribute(state, attributeName) {
2830 switch (attributeName) {
2831 case 'type':
2832 return getCurrentPostType(state);
2833 case 'id':
2834 return getCurrentPostId(state);
2835 default:
2836 const post = getCurrentPost(state);
2837 if (!post.hasOwnProperty(attributeName)) {
2838 break;
2839 }
2840 return getPostRawValue(post[attributeName]);
2841 }
2842 }
2843
2844 /**
2845 * Returns a single attribute of the post being edited, preferring the unsaved
2846 * edit if one exists, but merging with the attribute value for the last known
2847 * saved state of the post (this is needed for some nested attributes like meta).
2848 *
2849 * @param {Object} state Global application state.
2850 * @param {string} attributeName Post attribute name.
2851 *
2852 * @return {*} Post attribute value.
2853 */
2854 const getNestedEditedPostProperty = (0,external_wp_data_namespaceObject.createSelector)((state, attributeName) => {
2855 const edits = getPostEdits(state);
2856 if (!edits.hasOwnProperty(attributeName)) {
2857 return getCurrentPostAttribute(state, attributeName);
2858 }
2859 return {
2860 ...getCurrentPostAttribute(state, attributeName),
2861 ...edits[attributeName]
2862 };
2863 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]);
2864
2865 /**
2866 * Returns a single attribute of the post being edited, preferring the unsaved
2867 * edit if one exists, but falling back to the attribute for the last known
2868 * saved state of the post.
2869 *
2870 * @param {Object} state Global application state.
2871 * @param {string} attributeName Post attribute name.
2872 *
2873 * @return {*} Post attribute value.
2874 */
2875 function getEditedPostAttribute(state, attributeName) {
2876 // Special cases.
2877 switch (attributeName) {
2878 case 'content':
2879 return getEditedPostContent(state);
2880 }
2881
2882 // Fall back to saved post value if not edited.
2883 const edits = getPostEdits(state);
2884 if (!edits.hasOwnProperty(attributeName)) {
2885 return getCurrentPostAttribute(state, attributeName);
2886 }
2887
2888 // Merge properties are objects which contain only the patch edit in state,
2889 // and thus must be merged with the current post attribute.
2890 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2891 return getNestedEditedPostProperty(state, attributeName);
2892 }
2893 return edits[attributeName];
2894 }
2895
2896 /**
2897 * Returns an attribute value of the current autosave revision for a post, or
2898 * null if there is no autosave for the post.
2899 *
2900 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2901 * from the '@wordpress/core-data' package and access properties on the returned
2902 * autosave object using getPostRawValue.
2903 *
2904 * @param {Object} state Global application state.
2905 * @param {string} attributeName Autosave attribute name.
2906 *
2907 * @return {*} Autosave attribute value.
2908 */
2909 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2910 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') {
2911 return;
2912 }
2913 const postType = getCurrentPostType(state);
2914
2915 // Currently template autosaving is not supported.
2916 if (postType === 'wp_template') {
2917 return false;
2918 }
2919 const postId = getCurrentPostId(state);
2920 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
2921 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2922 if (autosave) {
2923 return getPostRawValue(autosave[attributeName]);
2924 }
2925 });
2926
2927 /**
2928 * Returns the current visibility of the post being edited, preferring the
2929 * unsaved value if different than the saved post. The return value is one of
2930 * "private", "password", or "public".
2931 *
2932 * @param {Object} state Global application state.
2933 *
2934 * @return {string} Post visibility.
2935 */
2936 function getEditedPostVisibility(state) {
2937 const status = getEditedPostAttribute(state, 'status');
2938 if (status === 'private') {
2939 return 'private';
2940 }
2941 const password = getEditedPostAttribute(state, 'password');
2942 if (password) {
2943 return 'password';
2944 }
2945 return 'public';
2946 }
2947
2948 /**
2949 * Returns true if post is pending review.
2950 *
2951 * @param {Object} state Global application state.
2952 *
2953 * @return {boolean} Whether current post is pending review.
2954 */
2955 function isCurrentPostPending(state) {
2956 return getCurrentPost(state).status === 'pending';
2957 }
2958
2959 /**
2960 * Return true if the current post has already been published.
2961 *
2962 * @param {Object} state Global application state.
2963 * @param {Object?} currentPost Explicit current post for bypassing registry selector.
2964 *
2965 * @return {boolean} Whether the post has been published.
2966 */
2967 function isCurrentPostPublished(state, currentPost) {
2968 const post = currentPost || getCurrentPost(state);
2969 return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !(0,external_wp_date_namespaceObject.isInTheFuture)(new Date(Number((0,external_wp_date_namespaceObject.getDate)(post.date)) - ONE_MINUTE_IN_MS));
2970 }
2971
2972 /**
2973 * Returns true if post is already scheduled.
2974 *
2975 * @param {Object} state Global application state.
2976 *
2977 * @return {boolean} Whether current post is scheduled to be posted.
2978 */
2979 function isCurrentPostScheduled(state) {
2980 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
2981 }
2982
2983 /**
2984 * Return true if the post being edited can be published.
2985 *
2986 * @param {Object} state Global application state.
2987 *
2988 * @return {boolean} Whether the post can been published.
2989 */
2990 function isEditedPostPublishable(state) {
2991 const post = getCurrentPost(state);
2992
2993 // TODO: Post being publishable should be superset of condition of post
2994 // being saveable. Currently this restriction is imposed at UI.
2995 //
2996 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
2997
2998 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
2999 }
3000
3001 /**
3002 * Returns true if the post can be saved, or false otherwise. A post must
3003 * contain a title, an excerpt, or non-empty content to be valid for save.
3004 *
3005 * @param {Object} state Global application state.
3006 *
3007 * @return {boolean} Whether the post can be saved.
3008 */
3009 function isEditedPostSaveable(state) {
3010 if (isSavingPost(state)) {
3011 return false;
3012 }
3013
3014 // TODO: Post should not be saveable if not dirty. Cannot be added here at
3015 // this time since posts where meta boxes are present can be saved even if
3016 // the post is not dirty. Currently this restriction is imposed at UI, but
3017 // should be moved here.
3018 //
3019 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
3020 // See: <PostSavedState /> (`forceIsDirty` prop)
3021 // See: <PostPublishButton /> (`forceIsDirty` prop)
3022 // See: https://github.com/WordPress/gutenberg/pull/4184.
3023
3024 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
3025 }
3026
3027 /**
3028 * Returns true if the edited post has content. A post has content if it has at
3029 * least one saveable block or otherwise has a non-empty content property
3030 * assigned.
3031 *
3032 * @param {Object} state Global application state.
3033 *
3034 * @return {boolean} Whether post has content.
3035 */
3036 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3037 // While the condition of truthy content string is sufficient to determine
3038 // emptiness, testing saveable blocks length is a trivial operation. Since
3039 // this function can be called frequently, optimize for the fast case as a
3040 // condition of the mere existence of blocks. Note that the value of edited
3041 // content takes precedent over block content, and must fall through to the
3042 // default logic.
3043 const postId = getCurrentPostId(state);
3044 const postType = getCurrentPostType(state);
3045 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3046 if (typeof record.content !== 'function') {
3047 return !record.content;
3048 }
3049 const blocks = getEditedPostAttribute(state, 'blocks');
3050 if (blocks.length === 0) {
3051 return true;
3052 }
3053
3054 // Pierce the abstraction of the serializer in knowing that blocks are
3055 // joined with newlines such that even if every individual block
3056 // produces an empty save result, the serialized content is non-empty.
3057 if (blocks.length > 1) {
3058 return false;
3059 }
3060
3061 // There are two conditions under which the optimization cannot be
3062 // assumed, and a fallthrough to getEditedPostContent must occur:
3063 //
3064 // 1. getBlocksForSerialization has special treatment in omitting a
3065 // single unmodified default block.
3066 // 2. Comment delimiters are omitted for a freeform or unregistered
3067 // block in its serialization. The freeform block specifically may
3068 // produce an empty string in its saved output.
3069 //
3070 // For all other content, the single block is assumed to make a post
3071 // non-empty, if only by virtue of its own comment delimiters.
3072 const blockName = blocks[0].name;
3073 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
3074 return false;
3075 }
3076 return !getEditedPostContent(state);
3077 });
3078
3079 /**
3080 * Returns true if the post can be autosaved, or false otherwise.
3081 *
3082 * @param {Object} state Global application state.
3083 * @param {Object} autosave A raw autosave object from the REST API.
3084 *
3085 * @return {boolean} Whether the post can be autosaved.
3086 */
3087 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3088 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
3089 if (!isEditedPostSaveable(state)) {
3090 return false;
3091 }
3092
3093 // A post is not autosavable when there is a post autosave lock.
3094 if (isPostAutosavingLocked(state)) {
3095 return false;
3096 }
3097 const postType = getCurrentPostType(state);
3098
3099 // Currently template autosaving is not supported.
3100 if (postType === 'wp_template') {
3101 return false;
3102 }
3103 const postId = getCurrentPostId(state);
3104 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
3105 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
3106
3107 // Disable reason - this line causes the side-effect of fetching the autosave
3108 // via a resolver, moving below the return would result in the autosave never
3109 // being fetched.
3110 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
3111 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
3112
3113 // If any existing autosaves have not yet been fetched, this function is
3114 // unable to determine if the post is autosaveable, so return false.
3115 if (!hasFetchedAutosave) {
3116 return false;
3117 }
3118
3119 // If we don't already have an autosave, the post is autosaveable.
3120 if (!autosave) {
3121 return true;
3122 }
3123
3124 // To avoid an expensive content serialization, use the content dirtiness
3125 // flag in place of content field comparison against the known autosave.
3126 // This is not strictly accurate, and relies on a tolerance toward autosave
3127 // request failures for unnecessary saves.
3128 if (hasChangedContent(state)) {
3129 return true;
3130 }
3131
3132 // If title, excerpt, or meta have changed, the post is autosaveable.
3133 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
3134 });
3135
3136 /**
3137 * Return true if the post being edited is being scheduled. Preferring the
3138 * unsaved status values.
3139 *
3140 * @param {Object} state Global application state.
3141 *
3142 * @return {boolean} Whether the post has been published.
3143 */
3144 function isEditedPostBeingScheduled(state) {
3145 const date = getEditedPostAttribute(state, 'date');
3146 // Offset the date by one minute (network latency).
3147 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
3148 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
3149 }
3150
3151 /**
3152 * Returns whether the current post should be considered to have a "floating"
3153 * date (i.e. that it would publish "Immediately" rather than at a set time).
3154 *
3155 * Unlike in the PHP backend, the REST API returns a full date string for posts
3156 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
3157 * infer that a post is set to publish "Immediately" we check whether the date
3158 * and modified date are the same.
3159 *
3160 * @param {Object} state Editor state.
3161 *
3162 * @return {boolean} Whether the edited post has a floating date value.
3163 */
3164 function isEditedPostDateFloating(state) {
3165 const date = getEditedPostAttribute(state, 'date');
3166 const modified = getEditedPostAttribute(state, 'modified');
3167
3168 // This should be the status of the persisted post
3169 // It shouldn't use the "edited" status otherwise it breaks the
3170 // inferred post data floating status
3171 // See https://github.com/WordPress/gutenberg/issues/28083.
3172 const status = getCurrentPost(state).status;
3173 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
3174 return date === modified || date === null;
3175 }
3176 return false;
3177 }
3178
3179 /**
3180 * Returns true if the post is currently being deleted, or false otherwise.
3181 *
3182 * @param {Object} state Editor state.
3183 *
3184 * @return {boolean} Whether post is being deleted.
3185 */
3186 function isDeletingPost(state) {
3187 return !!state.deleting.pending;
3188 }
3189
3190 /**
3191 * Returns true if the post is currently being saved, or false otherwise.
3192 *
3193 * @param {Object} state Global application state.
3194 *
3195 * @return {boolean} Whether post is being saved.
3196 */
3197 function isSavingPost(state) {
3198 return !!state.saving.pending;
3199 }
3200
3201 /**
3202 * Returns true if non-post entities are currently being saved, or false otherwise.
3203 *
3204 * @param {Object} state Global application state.
3205 *
3206 * @return {boolean} Whether non-post entities are being saved.
3207 */
3208 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3209 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
3210 const {
3211 type,
3212 id
3213 } = getCurrentPost(state);
3214 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
3215 });
3216
3217 /**
3218 * Returns true if a previous post save was attempted successfully, or false
3219 * otherwise.
3220 *
3221 * @param {Object} state Global application state.
3222 *
3223 * @return {boolean} Whether the post was saved successfully.
3224 */
3225 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3226 const postType = getCurrentPostType(state);
3227 const postId = getCurrentPostId(state);
3228 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3229 });
3230
3231 /**
3232 * Returns true if a previous post save was attempted but failed, or false
3233 * otherwise.
3234 *
3235 * @param {Object} state Global application state.
3236 *
3237 * @return {boolean} Whether the post save failed.
3238 */
3239 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3240 const postType = getCurrentPostType(state);
3241 const postId = getCurrentPostId(state);
3242 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3243 });
3244
3245 /**
3246 * Returns true if the post is autosaving, or false otherwise.
3247 *
3248 * @param {Object} state Global application state.
3249 *
3250 * @return {boolean} Whether the post is autosaving.
3251 */
3252 function isAutosavingPost(state) {
3253 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3254 }
3255
3256 /**
3257 * Returns true if the post is being previewed, or false otherwise.
3258 *
3259 * @param {Object} state Global application state.
3260 *
3261 * @return {boolean} Whether the post is being previewed.
3262 */
3263 function isPreviewingPost(state) {
3264 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3265 }
3266
3267 /**
3268 * Returns the post preview link
3269 *
3270 * @param {Object} state Global application state.
3271 *
3272 * @return {string | undefined} Preview Link.
3273 */
3274 function getEditedPostPreviewLink(state) {
3275 if (state.saving.pending || isSavingPost(state)) {
3276 return;
3277 }
3278 let previewLink = getAutosaveAttribute(state, 'preview_link');
3279 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
3280 // If the post is draft, ignore the preview link from the autosave record,
3281 // because the preview could be a stale autosave if the post was switched from
3282 // published to draft.
3283 // See: https://github.com/WordPress/gutenberg/pull/37952.
3284 if (!previewLink || 'draft' === getCurrentPost(state).status) {
3285 previewLink = getEditedPostAttribute(state, 'link');
3286 if (previewLink) {
3287 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3288 preview: true
3289 });
3290 }
3291 }
3292 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
3293 if (previewLink && featuredImageId) {
3294 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3295 _thumbnail_id: featuredImageId
3296 });
3297 }
3298 return previewLink;
3299 }
3300
3301 /**
3302 * Returns a suggested post format for the current post, inferred only if there
3303 * is a single block within the post and it is of a type known to match a
3304 * default post format. Returns null if the format cannot be determined.
3305 *
3306 * @return {?string} Suggested post format.
3307 */
3308 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3309 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
3310 if (blocks.length > 2) {
3311 return null;
3312 }
3313 let name;
3314 // If there is only one block in the content of the post grab its name
3315 // so we can derive a suitable post format from it.
3316 if (blocks.length === 1) {
3317 name = blocks[0].name;
3318 // Check for core/embed `video` and `audio` eligible suggestions.
3319 if (name === 'core/embed') {
3320 const provider = blocks[0].attributes?.providerNameSlug;
3321 if (['youtube', 'vimeo'].includes(provider)) {
3322 name = 'core/video';
3323 } else if (['spotify', 'soundcloud'].includes(provider)) {
3324 name = 'core/audio';
3325 }
3326 }
3327 }
3328
3329 // If there are two blocks in the content and the last one is a text blocks
3330 // grab the name of the first one to also suggest a post format from it.
3331 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
3332 name = blocks[0].name;
3333 }
3334
3335 // We only convert to default post formats in core.
3336 switch (name) {
3337 case 'core/image':
3338 return 'image';
3339 case 'core/quote':
3340 case 'core/pullquote':
3341 return 'quote';
3342 case 'core/gallery':
3343 return 'gallery';
3344 case 'core/video':
3345 return 'video';
3346 case 'core/audio':
3347 return 'audio';
3348 default:
3349 return null;
3350 }
3351 });
3352
3353 /**
3354 * Returns the content of the post being edited.
3355 *
3356 * @param {Object} state Global application state.
3357 *
3358 * @return {string} Post content.
3359 */
3360 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3361 const postId = getCurrentPostId(state);
3362 const postType = getCurrentPostType(state);
3363 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3364 if (record) {
3365 if (typeof record.content === 'function') {
3366 return record.content(record);
3367 } else if (record.blocks) {
3368 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
3369 } else if (record.content) {
3370 return record.content;
3371 }
3372 }
3373 return '';
3374 });
3375
3376 /**
3377 * Returns true if the post is being published, or false otherwise.
3378 *
3379 * @param {Object} state Global application state.
3380 *
3381 * @return {boolean} Whether post is being published.
3382 */
3383 function isPublishingPost(state) {
3384 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
3385 }
3386
3387 /**
3388 * Returns whether the permalink is editable or not.
3389 *
3390 * @param {Object} state Editor state.
3391 *
3392 * @return {boolean} Whether or not the permalink is editable.
3393 */
3394 function isPermalinkEditable(state) {
3395 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3396 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
3397 }
3398
3399 /**
3400 * Returns the permalink for the post.
3401 *
3402 * @param {Object} state Editor state.
3403 *
3404 * @return {?string} The permalink, or null if the post is not viewable.
3405 */
3406 function getPermalink(state) {
3407 const permalinkParts = getPermalinkParts(state);
3408 if (!permalinkParts) {
3409 return null;
3410 }
3411 const {
3412 prefix,
3413 postName,
3414 suffix
3415 } = permalinkParts;
3416 if (isPermalinkEditable(state)) {
3417 return prefix + postName + suffix;
3418 }
3419 return prefix;
3420 }
3421
3422 /**
3423 * Returns the slug for the post being edited, preferring a manually edited
3424 * value if one exists, then a sanitized version of the current post title, and
3425 * finally the post ID.
3426 *
3427 * @param {Object} state Editor state.
3428 *
3429 * @return {string} The current slug to be displayed in the editor
3430 */
3431 function getEditedPostSlug(state) {
3432 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
3433 }
3434
3435 /**
3436 * Returns the permalink for a post, split into its three parts: the prefix,
3437 * the postName, and the suffix.
3438 *
3439 * @param {Object} state Editor state.
3440 *
3441 * @return {Object} An object containing the prefix, postName, and suffix for
3442 * the permalink, or null if the post is not viewable.
3443 */
3444 function getPermalinkParts(state) {
3445 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3446 if (!permalinkTemplate) {
3447 return null;
3448 }
3449 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
3450 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
3451 return {
3452 prefix,
3453 postName,
3454 suffix
3455 };
3456 }
3457
3458 /**
3459 * Returns whether the post is locked.
3460 *
3461 * @param {Object} state Global application state.
3462 *
3463 * @return {boolean} Is locked.
3464 */
3465 function isPostLocked(state) {
3466 return state.postLock.isLocked;
3467 }
3468
3469 /**
3470 * Returns whether post saving is locked.
3471 *
3472 * @param {Object} state Global application state.
3473 *
3474 * @return {boolean} Is locked.
3475 */
3476 function isPostSavingLocked(state) {
3477 return Object.keys(state.postSavingLock).length > 0;
3478 }
3479
3480 /**
3481 * Returns whether post autosaving is locked.
3482 *
3483 * @param {Object} state Global application state.
3484 *
3485 * @return {boolean} Is locked.
3486 */
3487 function isPostAutosavingLocked(state) {
3488 return Object.keys(state.postAutosavingLock).length > 0;
3489 }
3490
3491 /**
3492 * Returns whether the edition of the post has been taken over.
3493 *
3494 * @param {Object} state Global application state.
3495 *
3496 * @return {boolean} Is post lock takeover.
3497 */
3498 function isPostLockTakeover(state) {
3499 return state.postLock.isTakeover;
3500 }
3501
3502 /**
3503 * Returns details about the post lock user.
3504 *
3505 * @param {Object} state Global application state.
3506 *
3507 * @return {Object} A user object.
3508 */
3509 function getPostLockUser(state) {
3510 return state.postLock.user;
3511 }
3512
3513 /**
3514 * Returns the active post lock.
3515 *
3516 * @param {Object} state Global application state.
3517 *
3518 * @return {Object} The lock object.
3519 */
3520 function getActivePostLock(state) {
3521 return state.postLock.activePostLock;
3522 }
3523
3524 /**
3525 * Returns whether or not the user has the unfiltered_html capability.
3526 *
3527 * @param {Object} state Editor state.
3528 *
3529 * @return {boolean} Whether the user can or can't post unfiltered HTML.
3530 */
3531 function canUserUseUnfilteredHTML(state) {
3532 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
3533 }
3534
3535 /**
3536 * Returns whether the pre-publish panel should be shown
3537 * or skipped when the user clicks the "publish" button.
3538 *
3539 * @return {boolean} Whether the pre-publish panel should be shown or not.
3540 */
3541 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core', 'isPublishSidebarEnabled'));
3542
3543 /**
3544 * Return the current block list.
3545 *
3546 * @param {Object} state
3547 * @return {Array} Block list.
3548 */
3549 const getEditorBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
3550 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state));
3551 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]);
3552
3553 /**
3554 * Returns true if the given panel was programmatically removed, or false otherwise.
3555 * All panels are not removed by default.
3556 *
3557 * @param {Object} state Global application state.
3558 * @param {string} panelName A string that identifies the panel.
3559 *
3560 * @return {boolean} Whether or not the panel is removed.
3561 */
3562 function isEditorPanelRemoved(state, panelName) {
3563 return state.removedPanels.includes(panelName);
3564 }
3565
3566 /**
3567 * Returns true if the given panel is enabled, or false otherwise. Panels are
3568 * enabled by default.
3569 *
3570 * @param {Object} state Global application state.
3571 * @param {string} panelName A string that identifies the panel.
3572 *
3573 * @return {boolean} Whether or not the panel is enabled.
3574 */
3575 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3576 // For backward compatibility, we check edit-post
3577 // even though now this is in "editor" package.
3578 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
3579 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
3580 });
3581
3582 /**
3583 * Returns true if the given panel is open, or false otherwise. Panels are
3584 * closed by default.
3585 *
3586 * @param {Object} state Global application state.
3587 * @param {string} panelName A string that identifies the panel.
3588 *
3589 * @return {boolean} Whether or not the panel is open.
3590 */
3591 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3592 // For backward compatibility, we check edit-post
3593 // even though now this is in "editor" package.
3594 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
3595 return !!openPanels?.includes(panelName);
3596 });
3597
3598 /**
3599 * A block selection object.
3600 *
3601 * @typedef {Object} WPBlockSelection
3602 *
3603 * @property {string} clientId A block client ID.
3604 * @property {string} attributeKey A block attribute key.
3605 * @property {number} offset An attribute value offset, based on the rich
3606 * text value. See `wp.richText.create`.
3607 */
3608
3609 /**
3610 * Returns the current selection start.
3611 *
3612 * @param {Object} state
3613 * @return {WPBlockSelection} The selection start.
3614 *
3615 * @deprecated since Gutenberg 10.0.0.
3616 */
3617 function getEditorSelectionStart(state) {
3618 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3619 since: '5.8',
3620 alternative: "select('core/editor').getEditorSelection"
3621 });
3622 return getEditedPostAttribute(state, 'selection')?.selectionStart;
3623 }
3624
3625 /**
3626 * Returns the current selection end.
3627 *
3628 * @param {Object} state
3629 * @return {WPBlockSelection} The selection end.
3630 *
3631 * @deprecated since Gutenberg 10.0.0.
3632 */
3633 function getEditorSelectionEnd(state) {
3634 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3635 since: '5.8',
3636 alternative: "select('core/editor').getEditorSelection"
3637 });
3638 return getEditedPostAttribute(state, 'selection')?.selectionEnd;
3639 }
3640
3641 /**
3642 * Returns the current selection.
3643 *
3644 * @param {Object} state
3645 * @return {WPBlockSelection} The selection end.
3646 */
3647 function getEditorSelection(state) {
3648 return getEditedPostAttribute(state, 'selection');
3649 }
3650
3651 /**
3652 * Is the editor ready
3653 *
3654 * @param {Object} state
3655 * @return {boolean} is Ready.
3656 */
3657 function __unstableIsEditorReady(state) {
3658 return !!state.postId;
3659 }
3660
3661 /**
3662 * Returns the post editor settings.
3663 *
3664 * @param {Object} state Editor state.
3665 *
3666 * @return {Object} The editor settings object.
3667 */
3668 function getEditorSettings(state) {
3669 return state.editorSettings;
3670 }
3671
3672 /**
3673 * Returns the post editor's rendering mode.
3674 *
3675 * @param {Object} state Editor state.
3676 *
3677 * @return {string} Rendering mode.
3678 */
3679 function getRenderingMode(state) {
3680 return state.renderingMode;
3681 }
3682
3683 /**
3684 * Returns the current editing canvas device type.
3685 *
3686 * @param {Object} state Global application state.
3687 *
3688 * @return {string} Device type.
3689 */
3690 function getDeviceType(state) {
3691 return state.deviceType;
3692 }
3693
3694 /**
3695 * Returns true if the list view is opened.
3696 *
3697 * @param {Object} state Global application state.
3698 *
3699 * @return {boolean} Whether the list view is opened.
3700 */
3701 function isListViewOpened(state) {
3702 return state.listViewPanel;
3703 }
3704
3705 /**
3706 * Returns true if the inserter is opened.
3707 *
3708 * @param {Object} state Global application state.
3709 *
3710 * @return {boolean} Whether the inserter is opened.
3711 */
3712 function isInserterOpened(state) {
3713 return !!state.blockInserterPanel;
3714 }
3715
3716 /**
3717 * Returns the current editing mode.
3718 *
3719 * @param {Object} state Global application state.
3720 *
3721 * @return {string} Editing mode.
3722 */
3723 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3724 var _select$get;
3725 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
3726 });
3727
3728 /*
3729 * Backward compatibility
3730 */
3731
3732 /**
3733 * Returns state object prior to a specified optimist transaction ID, or `null`
3734 * if the transaction corresponding to the given ID cannot be found.
3735 *
3736 * @deprecated since Gutenberg 9.7.0.
3737 */
3738 function getStateBeforeOptimisticTransaction() {
3739 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3740 since: '5.7',
3741 hint: 'No state history is kept on this store anymore'
3742 });
3743 return null;
3744 }
3745 /**
3746 * Returns true if an optimistic transaction is pending commit, for which the
3747 * before state satisfies the given predicate function.
3748 *
3749 * @deprecated since Gutenberg 9.7.0.
3750 */
3751 function inSomeHistory() {
3752 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3753 since: '5.7',
3754 hint: 'No state history is kept on this store anymore'
3755 });
3756 return false;
3757 }
3758 function getBlockEditorSelector(name) {
3759 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => {
3760 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3761 since: '5.3',
3762 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3763 version: '6.2'
3764 });
3765 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3766 });
3767 }
3768
3769 /**
3770 * @see getBlockName in core/block-editor store.
3771 */
3772 const getBlockName = getBlockEditorSelector('getBlockName');
3773
3774 /**
3775 * @see isBlockValid in core/block-editor store.
3776 */
3777 const isBlockValid = getBlockEditorSelector('isBlockValid');
3778
3779 /**
3780 * @see getBlockAttributes in core/block-editor store.
3781 */
3782 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3783
3784 /**
3785 * @see getBlock in core/block-editor store.
3786 */
3787 const getBlock = getBlockEditorSelector('getBlock');
3788
3789 /**
3790 * @see getBlocks in core/block-editor store.
3791 */
3792 const getBlocks = getBlockEditorSelector('getBlocks');
3793
3794 /**
3795 * @see getClientIdsOfDescendants in core/block-editor store.
3796 */
3797 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3798
3799 /**
3800 * @see getClientIdsWithDescendants in core/block-editor store.
3801 */
3802 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3803
3804 /**
3805 * @see getGlobalBlockCount in core/block-editor store.
3806 */
3807 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3808
3809 /**
3810 * @see getBlocksByClientId in core/block-editor store.
3811 */
3812 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3813
3814 /**
3815 * @see getBlockCount in core/block-editor store.
3816 */
3817 const getBlockCount = getBlockEditorSelector('getBlockCount');
3818
3819 /**
3820 * @see getBlockSelectionStart in core/block-editor store.
3821 */
3822 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3823
3824 /**
3825 * @see getBlockSelectionEnd in core/block-editor store.
3826 */
3827 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3828
3829 /**
3830 * @see getSelectedBlockCount in core/block-editor store.
3831 */
3832 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3833
3834 /**
3835 * @see hasSelectedBlock in core/block-editor store.
3836 */
3837 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3838
3839 /**
3840 * @see getSelectedBlockClientId in core/block-editor store.
3841 */
3842 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3843
3844 /**
3845 * @see getSelectedBlock in core/block-editor store.
3846 */
3847 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3848
3849 /**
3850 * @see getBlockRootClientId in core/block-editor store.
3851 */
3852 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3853
3854 /**
3855 * @see getBlockHierarchyRootClientId in core/block-editor store.
3856 */
3857 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3858
3859 /**
3860 * @see getAdjacentBlockClientId in core/block-editor store.
3861 */
3862 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3863
3864 /**
3865 * @see getPreviousBlockClientId in core/block-editor store.
3866 */
3867 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3868
3869 /**
3870 * @see getNextBlockClientId in core/block-editor store.
3871 */
3872 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3873
3874 /**
3875 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3876 */
3877 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3878
3879 /**
3880 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3881 */
3882 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3883
3884 /**
3885 * @see getMultiSelectedBlocks in core/block-editor store.
3886 */
3887 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3888
3889 /**
3890 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3891 */
3892 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3893
3894 /**
3895 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3896 */
3897 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3898
3899 /**
3900 * @see isFirstMultiSelectedBlock in core/block-editor store.
3901 */
3902 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3903
3904 /**
3905 * @see isBlockMultiSelected in core/block-editor store.
3906 */
3907 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3908
3909 /**
3910 * @see isAncestorMultiSelected in core/block-editor store.
3911 */
3912 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3913
3914 /**
3915 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3916 */
3917 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3918
3919 /**
3920 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3921 */
3922 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3923
3924 /**
3925 * @see getBlockOrder in core/block-editor store.
3926 */
3927 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3928
3929 /**
3930 * @see getBlockIndex in core/block-editor store.
3931 */
3932 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3933
3934 /**
3935 * @see isBlockSelected in core/block-editor store.
3936 */
3937 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3938
3939 /**
3940 * @see hasSelectedInnerBlock in core/block-editor store.
3941 */
3942 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3943
3944 /**
3945 * @see isBlockWithinSelection in core/block-editor store.
3946 */
3947 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3948
3949 /**
3950 * @see hasMultiSelection in core/block-editor store.
3951 */
3952 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
3953
3954 /**
3955 * @see isMultiSelecting in core/block-editor store.
3956 */
3957 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
3958
3959 /**
3960 * @see isSelectionEnabled in core/block-editor store.
3961 */
3962 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
3963
3964 /**
3965 * @see getBlockMode in core/block-editor store.
3966 */
3967 const getBlockMode = getBlockEditorSelector('getBlockMode');
3968
3969 /**
3970 * @see isTyping in core/block-editor store.
3971 */
3972 const isTyping = getBlockEditorSelector('isTyping');
3973
3974 /**
3975 * @see isCaretWithinFormattedText in core/block-editor store.
3976 */
3977 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
3978
3979 /**
3980 * @see getBlockInsertionPoint in core/block-editor store.
3981 */
3982 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
3983
3984 /**
3985 * @see isBlockInsertionPointVisible in core/block-editor store.
3986 */
3987 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
3988
3989 /**
3990 * @see isValidTemplate in core/block-editor store.
3991 */
3992 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
3993
3994 /**
3995 * @see getTemplate in core/block-editor store.
3996 */
3997 const getTemplate = getBlockEditorSelector('getTemplate');
3998
3999 /**
4000 * @see getTemplateLock in core/block-editor store.
4001 */
4002 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
4003
4004 /**
4005 * @see canInsertBlockType in core/block-editor store.
4006 */
4007 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
4008
4009 /**
4010 * @see getInserterItems in core/block-editor store.
4011 */
4012 const getInserterItems = getBlockEditorSelector('getInserterItems');
4013
4014 /**
4015 * @see hasInserterItems in core/block-editor store.
4016 */
4017 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
4018
4019 /**
4020 * @see getBlockListSettings in core/block-editor store.
4021 */
4022 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
4023
4024 /**
4025 * Returns the default template types.
4026 *
4027 * @param {Object} state Global application state.
4028 *
4029 * @return {Object} The template types.
4030 */
4031 function __experimentalGetDefaultTemplateTypes(state) {
4032 return getEditorSettings(state)?.defaultTemplateTypes;
4033 }
4034
4035 /**
4036 * Returns the default template part areas.
4037 *
4038 * @param {Object} state Global application state.
4039 *
4040 * @return {Array} The template part areas.
4041 */
4042 const __experimentalGetDefaultTemplatePartAreas = (0,external_wp_data_namespaceObject.createSelector)(state => {
4043 var _getEditorSettings$de;
4044 const areas = (_getEditorSettings$de = getEditorSettings(state)?.defaultTemplatePartAreas) !== null && _getEditorSettings$de !== void 0 ? _getEditorSettings$de : [];
4045 return areas.map(item => {
4046 return {
4047 ...item,
4048 icon: getTemplatePartIcon(item.icon)
4049 };
4050 });
4051 }, state => [getEditorSettings(state)?.defaultTemplatePartAreas]);
4052
4053 /**
4054 * Returns a default template type searched by slug.
4055 *
4056 * @param {Object} state Global application state.
4057 * @param {string} slug The template type slug.
4058 *
4059 * @return {Object} The template type.
4060 */
4061 const __experimentalGetDefaultTemplateType = (0,external_wp_data_namespaceObject.createSelector)((state, slug) => {
4062 var _Object$values$find;
4063 const templateTypes = __experimentalGetDefaultTemplateTypes(state);
4064 if (!templateTypes) {
4065 return EMPTY_OBJECT;
4066 }
4067 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT;
4068 }, state => [__experimentalGetDefaultTemplateTypes(state)]);
4069
4070 /**
4071 * Given a template entity, return information about it which is ready to be
4072 * rendered, such as the title, description, and icon.
4073 *
4074 * @param {Object} state Global application state.
4075 * @param {Object} template The template for which we need information.
4076 * @return {Object} Information about the template, including title, description, and icon.
4077 */
4078 const __experimentalGetTemplateInfo = (0,external_wp_data_namespaceObject.createSelector)((state, template) => {
4079 if (!template) {
4080 return EMPTY_OBJECT;
4081 }
4082 const {
4083 description,
4084 slug,
4085 title,
4086 area
4087 } = template;
4088 const {
4089 title: defaultTitle,
4090 description: defaultDescription
4091 } = __experimentalGetDefaultTemplateType(state, slug);
4092 const templateTitle = typeof title === 'string' ? title : title?.rendered;
4093 const templateDescription = typeof description === 'string' ? description : description?.raw;
4094 const templateIcon = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)?.icon || library_layout;
4095 return {
4096 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
4097 description: templateDescription || defaultDescription,
4098 icon: templateIcon
4099 };
4100 }, state => [__experimentalGetDefaultTemplateTypes(state), __experimentalGetDefaultTemplatePartAreas(state)]);
4101
4102 /**
4103 * Returns a post type label depending on the current post.
4104 *
4105 * @param {Object} state Global application state.
4106 *
4107 * @return {string|undefined} The post type label if available, otherwise undefined.
4108 */
4109 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4110 const currentPostType = getCurrentPostType(state);
4111 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType);
4112 // Disable reason: Post type labels object is shaped like this.
4113 // eslint-disable-next-line camelcase
4114 return postType?.labels?.singular_name;
4115 });
4116
4117 /**
4118 * Returns true if the publish sidebar is opened.
4119 *
4120 * @param {Object} state Global application state
4121 *
4122 * @return {boolean} Whether the publish sidebar is open.
4123 */
4124 function isPublishSidebarOpened(state) {
4125 return state.publishSidebarActive;
4126 }
4127
4128 ;// CONCATENATED MODULE: external ["wp","a11y"]
4129 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
4130 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
4131 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
4132 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
4133 ;// CONCATENATED MODULE: external ["wp","notices"]
4134 const external_wp_notices_namespaceObject = window["wp"]["notices"];
4135 ;// CONCATENATED MODULE: external ["wp","hooks"]
4136 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
4137 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/local-autosave.js
4138 /**
4139 * Function returning a sessionStorage key to set or retrieve a given post's
4140 * automatic session backup.
4141 *
4142 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
4143 * `loggedout` handler can clear sessionStorage of any user-private content.
4144 *
4145 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
4146 *
4147 * @param {string} postId Post ID.
4148 * @param {boolean} isPostNew Whether post new.
4149 *
4150 * @return {string} sessionStorage key
4151 */
4152 function postKey(postId, isPostNew) {
4153 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
4154 }
4155 function localAutosaveGet(postId, isPostNew) {
4156 return window.sessionStorage.getItem(postKey(postId, isPostNew));
4157 }
4158 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
4159 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
4160 post_title: title,
4161 content,
4162 excerpt
4163 }));
4164 }
4165 function localAutosaveClear(postId, isPostNew) {
4166 window.sessionStorage.removeItem(postKey(postId, isPostNew));
4167 }
4168
4169 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/notice-builder.js
4170 /**
4171 * WordPress dependencies
4172 */
4173
4174
4175 /**
4176 * Internal dependencies
4177 */
4178
4179
4180 /**
4181 * Builds the arguments for a success notification dispatch.
4182 *
4183 * @param {Object} data Incoming data to build the arguments from.
4184 *
4185 * @return {Array} Arguments for dispatch. An empty array signals no
4186 * notification should be sent.
4187 */
4188 function getNotificationArgumentsForSaveSuccess(data) {
4189 var _postType$viewable;
4190 const {
4191 previousPost,
4192 post,
4193 postType
4194 } = data;
4195 // Autosaves are neither shown a notice nor redirected.
4196 if (data.options?.isAutosave) {
4197 return [];
4198 }
4199 const publishStatus = ['publish', 'private', 'future'];
4200 const isPublished = publishStatus.includes(previousPost.status);
4201 const willPublish = publishStatus.includes(post.status);
4202 const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
4203 let noticeMessage;
4204 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
4205 let isDraft;
4206
4207 // Always should a notice, which will be spoken for accessibility.
4208 if (willTrash) {
4209 noticeMessage = postType.labels.item_trashed;
4210 shouldShowLink = false;
4211 } else if (!isPublished && !willPublish) {
4212 // If saving a non-published post, don't show notice.
4213 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
4214 isDraft = true;
4215 } else if (isPublished && !willPublish) {
4216 // If undoing publish status, show specific notice.
4217 noticeMessage = postType.labels.item_reverted_to_draft;
4218 shouldShowLink = false;
4219 } else if (!isPublished && willPublish) {
4220 // If publishing or scheduling a post, show the corresponding
4221 // publish message.
4222 noticeMessage = {
4223 publish: postType.labels.item_published,
4224 private: postType.labels.item_published_privately,
4225 future: postType.labels.item_scheduled
4226 }[post.status];
4227 } else {
4228 // Generic fallback notice.
4229 noticeMessage = postType.labels.item_updated;
4230 }
4231 const actions = [];
4232 if (shouldShowLink) {
4233 actions.push({
4234 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
4235 url: post.link
4236 });
4237 }
4238 return [noticeMessage, {
4239 id: SAVE_POST_NOTICE_ID,
4240 type: 'snackbar',
4241 actions
4242 }];
4243 }
4244
4245 /**
4246 * Builds the fail notification arguments for dispatch.
4247 *
4248 * @param {Object} data Incoming data to build the arguments with.
4249 *
4250 * @return {Array} Arguments for dispatch. An empty array signals no
4251 * notification should be sent.
4252 */
4253 function getNotificationArgumentsForSaveFail(data) {
4254 const {
4255 post,
4256 edits,
4257 error
4258 } = data;
4259 if (error && 'rest_autosave_no_changes' === error.code) {
4260 // Autosave requested a new autosave, but there were no changes. This shouldn't
4261 // result in an error notice for the user.
4262 return [];
4263 }
4264 const publishStatus = ['publish', 'private', 'future'];
4265 const isPublished = publishStatus.indexOf(post.status) !== -1;
4266 // If the post was being published, we show the corresponding publish error message
4267 // Unless we publish an "updating failed" message.
4268 const messages = {
4269 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4270 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4271 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
4272 };
4273 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.');
4274
4275 // Check if message string contains HTML. Notice text is currently only
4276 // supported as plaintext, and stripping the tags may muddle the meaning.
4277 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4278 noticeMessage = [noticeMessage, error.message].join(' ');
4279 }
4280 return [noticeMessage, {
4281 id: SAVE_POST_NOTICE_ID
4282 }];
4283 }
4284
4285 /**
4286 * Builds the trash fail notification arguments for dispatch.
4287 *
4288 * @param {Object} data
4289 *
4290 * @return {Array} Arguments for dispatch.
4291 */
4292 function getNotificationArgumentsForTrashFail(data) {
4293 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
4294 id: TRASH_POST_NOTICE_ID
4295 }];
4296 }
4297
4298 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/actions.js
4299 /**
4300 * WordPress dependencies
4301 */
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313 /**
4314 * Internal dependencies
4315 */
4316
4317
4318
4319
4320 /**
4321 * Returns an action generator used in signalling that editor has initialized with
4322 * the specified post object and editor settings.
4323 *
4324 * @param {Object} post Post object.
4325 * @param {Object} edits Initial edited attributes object.
4326 * @param {Array?} template Block Template.
4327 */
4328 const setupEditor = (post, edits, template) => ({
4329 dispatch
4330 }) => {
4331 dispatch.setEditedPost(post.type, post.id);
4332 // Apply a template for new posts only, if exists.
4333 const isNewPost = post.status === 'auto-draft';
4334 if (isNewPost && template) {
4335 // In order to ensure maximum of a single parse during setup, edits are
4336 // included as part of editor setup action. Assume edited content as
4337 // canonical if provided, falling back to post.
4338 let content;
4339 if ('content' in edits) {
4340 content = edits.content;
4341 } else {
4342 content = post.content.raw;
4343 }
4344 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
4345 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
4346 dispatch.resetEditorBlocks(blocks, {
4347 __unstableShouldCreateUndoLevel: false
4348 });
4349 }
4350 if (edits && Object.values(edits).some(([key, edit]) => {
4351 var _post$key$raw;
4352 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
4353 })) {
4354 dispatch.editPost(edits);
4355 }
4356 };
4357
4358 /**
4359 * Returns an action object signalling that the editor is being destroyed and
4360 * that any necessary state or side-effect cleanup should occur.
4361 *
4362 * @deprecated
4363 *
4364 * @return {Object} Action object.
4365 */
4366 function __experimentalTearDownEditor() {
4367 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
4368 since: '6.5'
4369 });
4370 return {
4371 type: 'DO_NOTHING'
4372 };
4373 }
4374
4375 /**
4376 * Returns an action object used in signalling that the latest version of the
4377 * post has been received, either by initialization or save.
4378 *
4379 * @deprecated Since WordPress 6.0.
4380 */
4381 function resetPost() {
4382 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
4383 since: '6.0',
4384 version: '6.3',
4385 alternative: 'Initialize the editor with the setupEditorState action'
4386 });
4387 return {
4388 type: 'DO_NOTHING'
4389 };
4390 }
4391
4392 /**
4393 * Returns an action object used in signalling that a patch of updates for the
4394 * latest version of the post have been received.
4395 *
4396 * @return {Object} Action object.
4397 * @deprecated since Gutenberg 9.7.0.
4398 */
4399 function updatePost() {
4400 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
4401 since: '5.7',
4402 alternative: 'Use the core entities store instead'
4403 });
4404 return {
4405 type: 'DO_NOTHING'
4406 };
4407 }
4408
4409 /**
4410 * Setup the editor state.
4411 *
4412 * @deprecated
4413 *
4414 * @param {Object} post Post object.
4415 */
4416 function setupEditorState(post) {
4417 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4418 since: '6.5',
4419 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4420 });
4421 return setEditedPost(post.type, post.id);
4422 }
4423
4424 /**
4425 * Returns an action that sets the current post Type and post ID.
4426 *
4427 * @param {string} postType Post Type.
4428 * @param {string} postId Post ID.
4429 *
4430 * @return {Object} Action object.
4431 */
4432 function setEditedPost(postType, postId) {
4433 return {
4434 type: 'SET_EDITED_POST',
4435 postType,
4436 postId
4437 };
4438 }
4439
4440 /**
4441 * Returns an action object used in signalling that attributes of the post have
4442 * been edited.
4443 *
4444 * @param {Object} edits Post attributes to edit.
4445 * @param {Object} options Options for the edit.
4446 */
4447 const editPost = (edits, options) => ({
4448 select,
4449 registry
4450 }) => {
4451 const {
4452 id,
4453 type
4454 } = select.getCurrentPost();
4455 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
4456 };
4457
4458 /**
4459 * Action for saving the current post in the editor.
4460 *
4461 * @param {Object} options
4462 */
4463 const savePost = (options = {}) => async ({
4464 select,
4465 dispatch,
4466 registry
4467 }) => {
4468 if (!select.isEditedPostSaveable()) {
4469 return;
4470 }
4471 const content = select.getEditedPostContent();
4472 if (!options.isAutosave) {
4473 dispatch.editPost({
4474 content
4475 }, {
4476 undoIgnore: true
4477 });
4478 }
4479 const previousRecord = select.getCurrentPost();
4480 const edits = {
4481 id: previousRecord.id,
4482 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
4483 content
4484 };
4485 dispatch({
4486 type: 'REQUEST_POST_UPDATE_START',
4487 options
4488 });
4489 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
4490 let error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
4491 if (!error) {
4492 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options).catch(err => {
4493 error = err;
4494 });
4495 }
4496 dispatch({
4497 type: 'REQUEST_POST_UPDATE_FINISH',
4498 options
4499 });
4500 if (error) {
4501 const args = getNotificationArgumentsForSaveFail({
4502 post: previousRecord,
4503 edits,
4504 error
4505 });
4506 if (args.length) {
4507 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
4508 }
4509 } else {
4510 const updatedRecord = select.getCurrentPost();
4511 const args = getNotificationArgumentsForSaveSuccess({
4512 previousPost: previousRecord,
4513 post: updatedRecord,
4514 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
4515 options
4516 });
4517 if (args.length) {
4518 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
4519 }
4520 // Make sure that any edits after saving create an undo level and are
4521 // considered for change detection.
4522 if (!options.isAutosave) {
4523 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
4524 }
4525 }
4526 };
4527
4528 /**
4529 * Action for refreshing the current post.
4530 *
4531 * @deprecated Since WordPress 6.0.
4532 */
4533 function refreshPost() {
4534 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
4535 since: '6.0',
4536 version: '6.3',
4537 alternative: 'Use the core entities store instead'
4538 });
4539 return {
4540 type: 'DO_NOTHING'
4541 };
4542 }
4543
4544 /**
4545 * Action for trashing the current post in the editor.
4546 */
4547 const trashPost = () => async ({
4548 select,
4549 dispatch,
4550 registry
4551 }) => {
4552 const postTypeSlug = select.getCurrentPostType();
4553 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
4554 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
4555 const {
4556 rest_base: restBase,
4557 rest_namespace: restNamespace = 'wp/v2'
4558 } = postType;
4559 dispatch({
4560 type: 'REQUEST_POST_DELETE_START'
4561 });
4562 try {
4563 const post = select.getCurrentPost();
4564 await external_wp_apiFetch_default()({
4565 path: `/${restNamespace}/${restBase}/${post.id}`,
4566 method: 'DELETE'
4567 });
4568 await dispatch.savePost();
4569 } catch (error) {
4570 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
4571 error
4572 }));
4573 }
4574 dispatch({
4575 type: 'REQUEST_POST_DELETE_FINISH'
4576 });
4577 };
4578
4579 /**
4580 * Action that autosaves the current post. This
4581 * includes server-side autosaving (default) and client-side (a.k.a. local)
4582 * autosaving (e.g. on the Web, the post might be committed to Session
4583 * Storage).
4584 *
4585 * @param {Object?} options Extra flags to identify the autosave.
4586 */
4587 const autosave = ({
4588 local = false,
4589 ...options
4590 } = {}) => async ({
4591 select,
4592 dispatch
4593 }) => {
4594 const post = select.getCurrentPost();
4595
4596 // Currently template autosaving is not supported.
4597 if (post.type === 'wp_template') {
4598 return;
4599 }
4600 if (local) {
4601 const isPostNew = select.isEditedPostNew();
4602 const title = select.getEditedPostAttribute('title');
4603 const content = select.getEditedPostAttribute('content');
4604 const excerpt = select.getEditedPostAttribute('excerpt');
4605 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
4606 } else {
4607 await dispatch.savePost({
4608 isAutosave: true,
4609 ...options
4610 });
4611 }
4612 };
4613 const __unstableSaveForPreview = ({
4614 forceIsAutosaveable
4615 } = {}) => async ({
4616 select,
4617 dispatch
4618 }) => {
4619 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
4620 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
4621 if (isDraft) {
4622 await dispatch.savePost({
4623 isPreview: true
4624 });
4625 } else {
4626 await dispatch.autosave({
4627 isPreview: true
4628 });
4629 }
4630 }
4631 return select.getEditedPostPreviewLink();
4632 };
4633
4634 /**
4635 * Action that restores last popped state in undo history.
4636 */
4637 const redo = () => ({
4638 registry
4639 }) => {
4640 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
4641 };
4642
4643 /**
4644 * Action that pops a record from undo history and undoes the edit.
4645 */
4646 const undo = () => ({
4647 registry
4648 }) => {
4649 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
4650 };
4651
4652 /**
4653 * Action that creates an undo history record.
4654 *
4655 * @deprecated Since WordPress 6.0
4656 */
4657 function createUndoLevel() {
4658 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4659 since: '6.0',
4660 version: '6.3',
4661 alternative: 'Use the core entities store instead'
4662 });
4663 return {
4664 type: 'DO_NOTHING'
4665 };
4666 }
4667
4668 /**
4669 * Action that locks the editor.
4670 *
4671 * @param {Object} lock Details about the post lock status, user, and nonce.
4672 * @return {Object} Action object.
4673 */
4674 function updatePostLock(lock) {
4675 return {
4676 type: 'UPDATE_POST_LOCK',
4677 lock
4678 };
4679 }
4680
4681 /**
4682 * Enable the publish sidebar.
4683 */
4684 const enablePublishSidebar = () => ({
4685 registry
4686 }) => {
4687 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
4688 };
4689
4690 /**
4691 * Disables the publish sidebar.
4692 */
4693 const disablePublishSidebar = () => ({
4694 registry
4695 }) => {
4696 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
4697 };
4698
4699 /**
4700 * Action that locks post saving.
4701 *
4702 * @param {string} lockName The lock name.
4703 *
4704 * @example
4705 * ```
4706 * const { subscribe } = wp.data;
4707 *
4708 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4709 *
4710 * // Only allow publishing posts that are set to a future date.
4711 * if ( 'publish' !== initialPostStatus ) {
4712 *
4713 * // Track locking.
4714 * let locked = false;
4715 *
4716 * // Watch for the publish event.
4717 * let unssubscribe = subscribe( () => {
4718 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4719 * if ( 'publish' !== currentPostStatus ) {
4720 *
4721 * // Compare the post date to the current date, lock the post if the date isn't in the future.
4722 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
4723 * const currentDate = new Date();
4724 * if ( postDate.getTime() <= currentDate.getTime() ) {
4725 * if ( ! locked ) {
4726 * locked = true;
4727 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
4728 * }
4729 * } else {
4730 * if ( locked ) {
4731 * locked = false;
4732 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
4733 * }
4734 * }
4735 * }
4736 * } );
4737 * }
4738 * ```
4739 *
4740 * @return {Object} Action object
4741 */
4742 function lockPostSaving(lockName) {
4743 return {
4744 type: 'LOCK_POST_SAVING',
4745 lockName
4746 };
4747 }
4748
4749 /**
4750 * Action that unlocks post saving.
4751 *
4752 * @param {string} lockName The lock name.
4753 *
4754 * @example
4755 * ```
4756 * // Unlock post saving with the lock key `mylock`:
4757 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4758 * ```
4759 *
4760 * @return {Object} Action object
4761 */
4762 function unlockPostSaving(lockName) {
4763 return {
4764 type: 'UNLOCK_POST_SAVING',
4765 lockName
4766 };
4767 }
4768
4769 /**
4770 * Action that locks post autosaving.
4771 *
4772 * @param {string} lockName The lock name.
4773 *
4774 * @example
4775 * ```
4776 * // Lock post autosaving with the lock key `mylock`:
4777 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4778 * ```
4779 *
4780 * @return {Object} Action object
4781 */
4782 function lockPostAutosaving(lockName) {
4783 return {
4784 type: 'LOCK_POST_AUTOSAVING',
4785 lockName
4786 };
4787 }
4788
4789 /**
4790 * Action that unlocks post autosaving.
4791 *
4792 * @param {string} lockName The lock name.
4793 *
4794 * @example
4795 * ```
4796 * // Unlock post saving with the lock key `mylock`:
4797 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4798 * ```
4799 *
4800 * @return {Object} Action object
4801 */
4802 function unlockPostAutosaving(lockName) {
4803 return {
4804 type: 'UNLOCK_POST_AUTOSAVING',
4805 lockName
4806 };
4807 }
4808
4809 /**
4810 * Returns an action object used to signal that the blocks have been updated.
4811 *
4812 * @param {Array} blocks Block Array.
4813 * @param {?Object} options Optional options.
4814 */
4815 const resetEditorBlocks = (blocks, options = {}) => ({
4816 select,
4817 dispatch,
4818 registry
4819 }) => {
4820 const {
4821 __unstableShouldCreateUndoLevel,
4822 selection
4823 } = options;
4824 const edits = {
4825 blocks,
4826 selection
4827 };
4828 if (__unstableShouldCreateUndoLevel !== false) {
4829 const {
4830 id,
4831 type
4832 } = select.getCurrentPost();
4833 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4834 if (noChange) {
4835 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4836 return;
4837 }
4838
4839 // We create a new function here on every persistent edit
4840 // to make sure the edit makes the post dirty and creates
4841 // a new undo level.
4842 edits.content = ({
4843 blocks: blocksForSerialization = []
4844 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4845 }
4846 dispatch.editPost(edits);
4847 };
4848
4849 /*
4850 * Returns an action object used in signalling that the post editor settings have been updated.
4851 *
4852 * @param {Object} settings Updated settings
4853 *
4854 * @return {Object} Action object
4855 */
4856 function updateEditorSettings(settings) {
4857 return {
4858 type: 'UPDATE_EDITOR_SETTINGS',
4859 settings
4860 };
4861 }
4862
4863 /**
4864 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
4865 *
4866 * - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template.
4867 * - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable.
4868 *
4869 * @param {string} mode Mode (one of 'post-only' or 'template-locked').
4870 */
4871 const setRenderingMode = mode => ({
4872 dispatch,
4873 registry,
4874 select
4875 }) => {
4876 if (select.__unstableIsEditorReady()) {
4877 // We clear the block selection but we also need to clear the selection from the core store.
4878 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4879 dispatch.editPost({
4880 selection: undefined
4881 }, {
4882 undoIgnore: true
4883 });
4884 }
4885 dispatch({
4886 type: 'SET_RENDERING_MODE',
4887 mode
4888 });
4889 };
4890
4891 /**
4892 * Action that changes the width of the editing canvas.
4893 *
4894 * @param {string} deviceType
4895 *
4896 * @return {Object} Action object.
4897 */
4898 function setDeviceType(deviceType) {
4899 return {
4900 type: 'SET_DEVICE_TYPE',
4901 deviceType
4902 };
4903 }
4904
4905 /**
4906 * Returns an action object used to enable or disable a panel in the editor.
4907 *
4908 * @param {string} panelName A string that identifies the panel to enable or disable.
4909 *
4910 * @return {Object} Action object.
4911 */
4912 const toggleEditorPanelEnabled = panelName => ({
4913 registry
4914 }) => {
4915 var _registry$select$get;
4916 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
4917 const isPanelInactive = !!inactivePanels?.includes(panelName);
4918
4919 // If the panel is inactive, remove it to enable it, else add it to
4920 // make it inactive.
4921 let updatedInactivePanels;
4922 if (isPanelInactive) {
4923 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
4924 } else {
4925 updatedInactivePanels = [...inactivePanels, panelName];
4926 }
4927 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
4928 };
4929
4930 /**
4931 * Opens a closed panel and closes an open panel.
4932 *
4933 * @param {string} panelName A string that identifies the panel to open or close.
4934 */
4935 const toggleEditorPanelOpened = panelName => ({
4936 registry
4937 }) => {
4938 var _registry$select$get2;
4939 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
4940 const isPanelOpen = !!openPanels?.includes(panelName);
4941
4942 // If the panel is open, remove it to close it, else add it to
4943 // make it open.
4944 let updatedOpenPanels;
4945 if (isPanelOpen) {
4946 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
4947 } else {
4948 updatedOpenPanels = [...openPanels, panelName];
4949 }
4950 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
4951 };
4952
4953 /**
4954 * Returns an action object used to remove a panel from the editor.
4955 *
4956 * @param {string} panelName A string that identifies the panel to remove.
4957 *
4958 * @return {Object} Action object.
4959 */
4960 function removeEditorPanel(panelName) {
4961 return {
4962 type: 'REMOVE_PANEL',
4963 panelName
4964 };
4965 }
4966
4967 /**
4968 * Returns an action object used to open/close the inserter.
4969 *
4970 * @param {boolean|Object} value Whether the inserter should be
4971 * opened (true) or closed (false).
4972 * To specify an insertion point,
4973 * use an object.
4974 * @param {string} value.rootClientId The root client ID to insert at.
4975 * @param {number} value.insertionIndex The index to insert at.
4976 *
4977 * @return {Object} Action object.
4978 */
4979 function setIsInserterOpened(value) {
4980 return {
4981 type: 'SET_IS_INSERTER_OPENED',
4982 value
4983 };
4984 }
4985
4986 /**
4987 * Returns an action object used to open/close the list view.
4988 *
4989 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
4990 * @return {Object} Action object.
4991 */
4992 function setIsListViewOpened(isOpen) {
4993 return {
4994 type: 'SET_IS_LIST_VIEW_OPENED',
4995 isOpen
4996 };
4997 }
4998
4999 /**
5000 * Action that toggles Distraction free mode.
5001 * Distraction free mode expects there are no sidebars, as due to the
5002 * z-index values set, you can't close sidebars.
5003 */
5004 const toggleDistractionFree = () => ({
5005 dispatch,
5006 registry
5007 }) => {
5008 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5009 if (isDistractionFree) {
5010 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
5011 }
5012 if (!isDistractionFree) {
5013 registry.batch(() => {
5014 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
5015 dispatch.setIsInserterOpened(false);
5016 dispatch.setIsListViewOpened(false);
5017 });
5018 }
5019 registry.batch(() => {
5020 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
5021 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free off.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free on.'), {
5022 id: 'core/editor/distraction-free-mode/notice',
5023 type: 'snackbar',
5024 actions: [{
5025 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5026 onClick: () => {
5027 registry.batch(() => {
5028 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
5029 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');
5030 });
5031 }
5032 }]
5033 });
5034 });
5035 };
5036
5037 /**
5038 * Triggers an action used to switch editor mode.
5039 *
5040 * @param {string} mode The editor mode.
5041 */
5042 const switchEditorMode = mode => ({
5043 dispatch,
5044 registry
5045 }) => {
5046 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
5047
5048 // Unselect blocks when we switch to a non visual mode.
5049 if (mode !== 'visual') {
5050 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
5051 }
5052 if (mode === 'visual') {
5053 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
5054 } else if (mode === 'text') {
5055 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5056 if (isDistractionFree) {
5057 dispatch.toggleDistractionFree();
5058 }
5059 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
5060 }
5061 };
5062
5063 /**
5064 * Returns an action object used in signalling that the user opened the publish
5065 * sidebar.
5066 *
5067 * @return {Object} Action object
5068 */
5069 function openPublishSidebar() {
5070 return {
5071 type: 'OPEN_PUBLISH_SIDEBAR'
5072 };
5073 }
5074
5075 /**
5076 * Returns an action object used in signalling that the user closed the
5077 * publish sidebar.
5078 *
5079 * @return {Object} Action object.
5080 */
5081 function closePublishSidebar() {
5082 return {
5083 type: 'CLOSE_PUBLISH_SIDEBAR'
5084 };
5085 }
5086
5087 /**
5088 * Returns an action object used in signalling that the user toggles the publish sidebar.
5089 *
5090 * @return {Object} Action object
5091 */
5092 function togglePublishSidebar() {
5093 return {
5094 type: 'TOGGLE_PUBLISH_SIDEBAR'
5095 };
5096 }
5097
5098 /**
5099 * Backward compatibility
5100 */
5101
5102 const getBlockEditorAction = name => (...args) => ({
5103 registry
5104 }) => {
5105 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
5106 since: '5.3',
5107 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
5108 version: '6.2'
5109 });
5110 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
5111 };
5112
5113 /**
5114 * @see resetBlocks in core/block-editor store.
5115 */
5116 const resetBlocks = getBlockEditorAction('resetBlocks');
5117
5118 /**
5119 * @see receiveBlocks in core/block-editor store.
5120 */
5121 const receiveBlocks = getBlockEditorAction('receiveBlocks');
5122
5123 /**
5124 * @see updateBlock in core/block-editor store.
5125 */
5126 const updateBlock = getBlockEditorAction('updateBlock');
5127
5128 /**
5129 * @see updateBlockAttributes in core/block-editor store.
5130 */
5131 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
5132
5133 /**
5134 * @see selectBlock in core/block-editor store.
5135 */
5136 const selectBlock = getBlockEditorAction('selectBlock');
5137
5138 /**
5139 * @see startMultiSelect in core/block-editor store.
5140 */
5141 const startMultiSelect = getBlockEditorAction('startMultiSelect');
5142
5143 /**
5144 * @see stopMultiSelect in core/block-editor store.
5145 */
5146 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
5147
5148 /**
5149 * @see multiSelect in core/block-editor store.
5150 */
5151 const multiSelect = getBlockEditorAction('multiSelect');
5152
5153 /**
5154 * @see clearSelectedBlock in core/block-editor store.
5155 */
5156 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
5157
5158 /**
5159 * @see toggleSelection in core/block-editor store.
5160 */
5161 const toggleSelection = getBlockEditorAction('toggleSelection');
5162
5163 /**
5164 * @see replaceBlocks in core/block-editor store.
5165 */
5166 const replaceBlocks = getBlockEditorAction('replaceBlocks');
5167
5168 /**
5169 * @see replaceBlock in core/block-editor store.
5170 */
5171 const replaceBlock = getBlockEditorAction('replaceBlock');
5172
5173 /**
5174 * @see moveBlocksDown in core/block-editor store.
5175 */
5176 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
5177
5178 /**
5179 * @see moveBlocksUp in core/block-editor store.
5180 */
5181 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
5182
5183 /**
5184 * @see moveBlockToPosition in core/block-editor store.
5185 */
5186 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
5187
5188 /**
5189 * @see insertBlock in core/block-editor store.
5190 */
5191 const insertBlock = getBlockEditorAction('insertBlock');
5192
5193 /**
5194 * @see insertBlocks in core/block-editor store.
5195 */
5196 const insertBlocks = getBlockEditorAction('insertBlocks');
5197
5198 /**
5199 * @see showInsertionPoint in core/block-editor store.
5200 */
5201 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
5202
5203 /**
5204 * @see hideInsertionPoint in core/block-editor store.
5205 */
5206 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
5207
5208 /**
5209 * @see setTemplateValidity in core/block-editor store.
5210 */
5211 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
5212
5213 /**
5214 * @see synchronizeTemplate in core/block-editor store.
5215 */
5216 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
5217
5218 /**
5219 * @see mergeBlocks in core/block-editor store.
5220 */
5221 const mergeBlocks = getBlockEditorAction('mergeBlocks');
5222
5223 /**
5224 * @see removeBlocks in core/block-editor store.
5225 */
5226 const removeBlocks = getBlockEditorAction('removeBlocks');
5227
5228 /**
5229 * @see removeBlock in core/block-editor store.
5230 */
5231 const removeBlock = getBlockEditorAction('removeBlock');
5232
5233 /**
5234 * @see toggleBlockMode in core/block-editor store.
5235 */
5236 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
5237
5238 /**
5239 * @see startTyping in core/block-editor store.
5240 */
5241 const startTyping = getBlockEditorAction('startTyping');
5242
5243 /**
5244 * @see stopTyping in core/block-editor store.
5245 */
5246 const stopTyping = getBlockEditorAction('stopTyping');
5247
5248 /**
5249 * @see enterFormattedText in core/block-editor store.
5250 */
5251 const enterFormattedText = getBlockEditorAction('enterFormattedText');
5252
5253 /**
5254 * @see exitFormattedText in core/block-editor store.
5255 */
5256 const exitFormattedText = getBlockEditorAction('exitFormattedText');
5257
5258 /**
5259 * @see insertDefaultBlock in core/block-editor store.
5260 */
5261 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
5262
5263 /**
5264 * @see updateBlockListSettings in core/block-editor store.
5265 */
5266 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
5267
5268 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5269 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5270 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/is-template-revertable.js
5271 /**
5272 * Internal dependencies
5273 */
5274
5275
5276 // Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
5277
5278 /**
5279 * Check if a template is revertable to its original theme-provided template file.
5280 *
5281 * @param {Object} template The template entity to check.
5282 * @return {boolean} Whether the template is revertable.
5283 */
5284 function isTemplateRevertable(template) {
5285 if (!template) {
5286 return false;
5287 }
5288 /* eslint-disable camelcase */
5289 return template?.source === TEMPLATE_ORIGINS.custom && template?.has_theme_file;
5290 /* eslint-enable camelcase */
5291 }
5292
5293 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/private-actions.js
5294 /**
5295 * WordPress dependencies
5296 */
5297
5298 function registerEntityAction(kind, name, config) {
5299 return {
5300 type: 'REGISTER_ENTITY_ACTION',
5301 kind,
5302 name,
5303 config
5304 };
5305 }
5306 function unregisterEntityAction(kind, name, actionId) {
5307 return {
5308 type: 'UNREGISTER_ENTITY_ACTION',
5309 kind,
5310 name,
5311 actionId
5312 };
5313 }
5314
5315 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-actions.js
5316 /**
5317 * WordPress dependencies
5318 */
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329 /**
5330 * Internal dependencies
5331 */
5332
5333
5334
5335 /**
5336 * Returns an action object used to set which template is currently being used/edited.
5337 *
5338 * @param {string} id Template Id.
5339 *
5340 * @return {Object} Action object.
5341 */
5342 function setCurrentTemplateId(id) {
5343 return {
5344 type: 'SET_CURRENT_TEMPLATE_ID',
5345 id
5346 };
5347 }
5348
5349 /**
5350 * Create a block based template.
5351 *
5352 * @param {Object?} template Template to create and assign.
5353 */
5354 const createTemplate = template => async ({
5355 select,
5356 dispatch,
5357 registry
5358 }) => {
5359 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
5360 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
5361 template: savedTemplate.slug
5362 });
5363 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
5364 type: 'snackbar',
5365 actions: [{
5366 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
5367 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
5368 }]
5369 });
5370 return savedTemplate;
5371 };
5372
5373 /**
5374 * Update the provided block types to be visible.
5375 *
5376 * @param {string[]} blockNames Names of block types to show.
5377 */
5378 const showBlockTypes = blockNames => ({
5379 registry
5380 }) => {
5381 var _registry$select$get;
5382 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
5383 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
5384 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
5385 };
5386
5387 /**
5388 * Update the provided block types to be hidden.
5389 *
5390 * @param {string[]} blockNames Names of block types to hide.
5391 */
5392 const hideBlockTypes = blockNames => ({
5393 registry
5394 }) => {
5395 var _registry$select$get2;
5396 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
5397 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
5398 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
5399 };
5400
5401 /**
5402 * Save entity records marked as dirty.
5403 *
5404 * @param {Object} options Options for the action.
5405 * @param {Function} [options.onSave] Callback when saving happens.
5406 * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
5407 * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
5408 * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
5409 */
5410 const saveDirtyEntities = ({
5411 onSave,
5412 dirtyEntityRecords = [],
5413 entitiesToSkip = [],
5414 close
5415 } = {}) => ({
5416 registry
5417 }) => {
5418 const PUBLISH_ON_SAVE_ENTITIES = [{
5419 kind: 'postType',
5420 name: 'wp_navigation'
5421 }];
5422 const saveNoticeId = 'site-editor-save-success';
5423 const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getUnstableBase()?.home;
5424 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
5425 const entitiesToSave = dirtyEntityRecords.filter(({
5426 kind,
5427 name,
5428 key,
5429 property
5430 }) => {
5431 return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
5432 });
5433 close?.(entitiesToSave);
5434 const siteItemsToSave = [];
5435 const pendingSavedRecords = [];
5436 entitiesToSave.forEach(({
5437 kind,
5438 name,
5439 key,
5440 property
5441 }) => {
5442 if ('root' === kind && 'site' === name) {
5443 siteItemsToSave.push(property);
5444 } else {
5445 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
5446 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
5447 status: 'publish'
5448 });
5449 }
5450 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
5451 }
5452 });
5453 if (siteItemsToSave.length) {
5454 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
5455 }
5456 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
5457 Promise.all(pendingSavedRecords).then(values => {
5458 return onSave ? onSave(values) : values;
5459 }).then(values => {
5460 if (values.some(value => typeof value === 'undefined')) {
5461 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
5462 } else {
5463 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
5464 type: 'snackbar',
5465 id: saveNoticeId,
5466 actions: [{
5467 label: (0,external_wp_i18n_namespaceObject.__)('View site'),
5468 url: homeUrl
5469 }]
5470 });
5471 }
5472 }).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
5473 };
5474
5475 /**
5476 * Reverts a template to its original theme-provided file.
5477 *
5478 * @param {Object} template The template to revert.
5479 * @param {Object} [options]
5480 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
5481 * reverting the template. Default true.
5482 */
5483 const revertTemplate = (template, {
5484 allowUndo = true
5485 } = {}) => async ({
5486 registry
5487 }) => {
5488 const noticeId = 'edit-site-template-reverted';
5489 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
5490 if (!isTemplateRevertable(template)) {
5491 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
5492 type: 'snackbar'
5493 });
5494 return;
5495 }
5496 try {
5497 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
5498 if (!templateEntityConfig) {
5499 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5500 type: 'snackbar'
5501 });
5502 return;
5503 }
5504 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
5505 context: 'edit',
5506 source: 'theme'
5507 });
5508 const fileTemplate = await external_wp_apiFetch_default()({
5509 path: fileTemplatePath
5510 });
5511 if (!fileTemplate) {
5512 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5513 type: 'snackbar'
5514 });
5515 return;
5516 }
5517 const serializeBlocks = ({
5518 blocks: blocksForSerialization = []
5519 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
5520 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
5521
5522 // We are fixing up the undo level here to make sure we can undo
5523 // the revert in the header toolbar correctly.
5524 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
5525 content: serializeBlocks,
5526 // Required to make the `undo` behave correctly.
5527 blocks: edited.blocks,
5528 // Required to revert the blocks in the editor.
5529 source: 'custom' // required to avoid turning the editor into a dirty state
5530 }, {
5531 undoIgnore: true // Required to merge this edit with the last undo level.
5532 });
5533 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
5534 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
5535 content: serializeBlocks,
5536 blocks,
5537 source: 'theme'
5538 });
5539 if (allowUndo) {
5540 const undoRevert = () => {
5541 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
5542 content: serializeBlocks,
5543 blocks: edited.blocks,
5544 source: 'custom'
5545 });
5546 };
5547 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
5548 type: 'snackbar',
5549 id: noticeId,
5550 actions: [{
5551 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5552 onClick: undoRevert
5553 }]
5554 });
5555 }
5556 } catch (error) {
5557 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
5558 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5559 type: 'snackbar'
5560 });
5561 }
5562 };
5563
5564 /**
5565 * Action that removes an array of templates, template parts or patterns.
5566 *
5567 * @param {Array} items An array of template,template part or pattern objects to remove.
5568 */
5569 const removeTemplates = items => async ({
5570 registry
5571 }) => {
5572 const promiseResult = await Promise.allSettled(items.map(item => {
5573 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
5574 force: true
5575 }, {
5576 throwOnError: true
5577 });
5578 }));
5579
5580 // If all the promises were fulfilled with sucess.
5581 if (promiseResult.every(({
5582 status
5583 }) => status === 'fulfilled')) {
5584 let successMessage;
5585 if (items.length === 1) {
5586 // Depending on how the entity was retrieved its title might be
5587 // an object or simple string.
5588 const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered;
5589 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
5590 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
5591 } else {
5592 successMessage = (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
5593 }
5594 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
5595 type: 'snackbar',
5596 id: 'editor-template-deleted-success'
5597 });
5598 } else {
5599 // If there was at lease one failure.
5600 let errorMessage;
5601 // If we were trying to delete a single template.
5602 if (promiseResult.length === 1) {
5603 if (promiseResult[0].reason?.message) {
5604 errorMessage = promiseResult[0].reason.message;
5605 } else {
5606 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
5607 }
5608 // If we were trying to delete a multiple templates
5609 } else {
5610 const errorMessages = new Set();
5611 const failedPromises = promiseResult.filter(({
5612 status
5613 }) => status === 'rejected');
5614 for (const failedPromise of failedPromises) {
5615 if (failedPromise.reason?.message) {
5616 errorMessages.add(failedPromise.reason.message);
5617 }
5618 }
5619 if (errorMessages.size === 0) {
5620 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
5621 } else if (errorMessages.size === 1) {
5622 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
5623 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
5624 } else {
5625 (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
5626 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
5627 }
5628 }
5629 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5630 type: 'snackbar'
5631 });
5632 }
5633 };
5634
5635 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
5636 var fast_deep_equal = __webpack_require__(2303);
5637 var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
5638 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol.js
5639 /**
5640 * WordPress dependencies
5641 */
5642
5643
5644 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5645 xmlns: "http://www.w3.org/2000/svg",
5646 viewBox: "0 0 24 24",
5647 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5648 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-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 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"
5649 })
5650 });
5651 /* harmony default export */ const library_symbol = (symbol);
5652
5653 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
5654 /**
5655 * WordPress dependencies
5656 */
5657
5658
5659 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5660 viewBox: "0 0 24 24",
5661 xmlns: "http://www.w3.org/2000/svg",
5662 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5663 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"
5664 })
5665 });
5666 /* harmony default export */ const library_navigation = (navigation);
5667
5668 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
5669 /**
5670 * WordPress dependencies
5671 */
5672
5673
5674
5675 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
5676 xmlns: "http://www.w3.org/2000/svg",
5677 viewBox: "0 0 24 24",
5678 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5679 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
5680 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5681 d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
5682 })]
5683 });
5684 /* harmony default export */ const library_page = (page);
5685
5686 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/verse.js
5687 /**
5688 * WordPress dependencies
5689 */
5690
5691
5692 const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5693 viewBox: "0 0 24 24",
5694 xmlns: "http://www.w3.org/2000/svg",
5695 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5696 d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z"
5697 })
5698 });
5699 /* harmony default export */ const library_verse = (verse);
5700
5701 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
5702 /**
5703 * Memize options object.
5704 *
5705 * @typedef MemizeOptions
5706 *
5707 * @property {number} [maxSize] Maximum size of the cache.
5708 */
5709
5710 /**
5711 * Internal cache entry.
5712 *
5713 * @typedef MemizeCacheNode
5714 *
5715 * @property {?MemizeCacheNode|undefined} [prev] Previous node.
5716 * @property {?MemizeCacheNode|undefined} [next] Next node.
5717 * @property {Array<*>} args Function arguments for cache
5718 * entry.
5719 * @property {*} val Function result.
5720 */
5721
5722 /**
5723 * Properties of the enhanced function for controlling cache.
5724 *
5725 * @typedef MemizeMemoizedFunction
5726 *
5727 * @property {()=>void} clear Clear the cache.
5728 */
5729
5730 /**
5731 * Accepts a function to be memoized, and returns a new memoized function, with
5732 * optional options.
5733 *
5734 * @template {(...args: any[]) => any} F
5735 *
5736 * @param {F} fn Function to memoize.
5737 * @param {MemizeOptions} [options] Options object.
5738 *
5739 * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
5740 */
5741 function memize(fn, options) {
5742 var size = 0;
5743
5744 /** @type {?MemizeCacheNode|undefined} */
5745 var head;
5746
5747 /** @type {?MemizeCacheNode|undefined} */
5748 var tail;
5749
5750 options = options || {};
5751
5752 function memoized(/* ...args */) {
5753 var node = head,
5754 len = arguments.length,
5755 args,
5756 i;
5757
5758 searchCache: while (node) {
5759 // Perform a shallow equality test to confirm that whether the node
5760 // under test is a candidate for the arguments passed. Two arrays
5761 // are shallowly equal if their length matches and each entry is
5762 // strictly equal between the two sets. Avoid abstracting to a
5763 // function which could incur an arguments leaking deoptimization.
5764
5765 // Check whether node arguments match arguments length
5766 if (node.args.length !== arguments.length) {
5767 node = node.next;
5768 continue;
5769 }
5770
5771 // Check whether node arguments match arguments values
5772 for (i = 0; i < len; i++) {
5773 if (node.args[i] !== arguments[i]) {
5774 node = node.next;
5775 continue searchCache;
5776 }
5777 }
5778
5779 // At this point we can assume we've found a match
5780
5781 // Surface matched node to head if not already
5782 if (node !== head) {
5783 // As tail, shift to previous. Must only shift if not also
5784 // head, since if both head and tail, there is no previous.
5785 if (node === tail) {
5786 tail = node.prev;
5787 }
5788
5789 // Adjust siblings to point to each other. If node was tail,
5790 // this also handles new tail's empty `next` assignment.
5791 /** @type {MemizeCacheNode} */ (node.prev).next = node.next;
5792 if (node.next) {
5793 node.next.prev = node.prev;
5794 }
5795
5796 node.next = head;
5797 node.prev = null;
5798 /** @type {MemizeCacheNode} */ (head).prev = node;
5799 head = node;
5800 }
5801
5802 // Return immediately
5803 return node.val;
5804 }
5805
5806 // No cached value found. Continue to insertion phase:
5807
5808 // Create a copy of arguments (avoid leaking deoptimization)
5809 args = new Array(len);
5810 for (i = 0; i < len; i++) {
5811 args[i] = arguments[i];
5812 }
5813
5814 node = {
5815 args: args,
5816
5817 // Generate the result from original function
5818 val: fn.apply(null, args),
5819 };
5820
5821 // Don't need to check whether node is already head, since it would
5822 // have been returned above already if it was
5823
5824 // Shift existing head down list
5825 if (head) {
5826 head.prev = node;
5827 node.next = head;
5828 } else {
5829 // If no head, follows that there's no tail (at initial or reset)
5830 tail = node;
5831 }
5832
5833 // Trim tail if we're reached max size and are pending cache insertion
5834 if (size === /** @type {MemizeOptions} */ (options).maxSize) {
5835 tail = /** @type {MemizeCacheNode} */ (tail).prev;
5836 /** @type {MemizeCacheNode} */ (tail).next = null;
5837 } else {
5838 size++;
5839 }
5840
5841 head = node;
5842
5843 return node.val;
5844 }
5845
5846 memoized.clear = function () {
5847 head = null;
5848 tail = null;
5849 size = 0;
5850 };
5851
5852 // Ignore reason: There's not a clear solution to create an intersection of
5853 // the function with additional properties, where the goal is to retain the
5854 // function signature of the incoming argument and add control properties
5855 // on the return value.
5856
5857 // @ts-ignore
5858 return memoized;
5859 }
5860
5861
5862
5863 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/get-filtered-template-parts.js
5864 /**
5865 * External dependencies
5866 */
5867
5868
5869 /**
5870 * WordPress dependencies
5871 */
5872
5873 const EMPTY_ARRAY = [];
5874
5875 /**
5876 * Get a flattened and filtered list of template parts and the matching block for that template part.
5877 *
5878 * Takes a list of blocks defined within a template, and a list of template parts, and returns a
5879 * flattened list of template parts and the matching block for that template part.
5880 *
5881 * @param {Array} blocks Blocks to flatten.
5882 * @param {?Array} templateParts Available template parts.
5883 * @return {Array} An array of template parts and their blocks.
5884 */
5885 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
5886 const templatePartsById = templateParts ?
5887 // Key template parts by their ID.
5888 templateParts.reduce((newTemplateParts, part) => ({
5889 ...newTemplateParts,
5890 [part.id]: part
5891 }), {}) : {};
5892 const result = [];
5893
5894 // Iterate over all blocks, recursing into inner blocks.
5895 // Output will be based on a depth-first traversal.
5896 const stack = [...blocks];
5897 while (stack.length) {
5898 const {
5899 innerBlocks,
5900 ...block
5901 } = stack.shift();
5902 // Place inner blocks at the beginning of the stack to preserve order.
5903 stack.unshift(...innerBlocks);
5904 if ((0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) {
5905 const {
5906 attributes: {
5907 theme,
5908 slug
5909 }
5910 } = block;
5911 const templatePartId = `${theme}//${slug}`;
5912 const templatePart = templatePartsById[templatePartId];
5913
5914 // Only add to output if the found template part block is in the list of available template parts.
5915 if (templatePart) {
5916 result.push({
5917 templatePart,
5918 block
5919 });
5920 }
5921 }
5922 }
5923 return result;
5924 }
5925 const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBlocks);
5926
5927
5928 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/private-selectors.js
5929 /**
5930 * WordPress dependencies
5931 */
5932
5933 /**
5934 * Internal dependencies
5935 */
5936
5937 const private_selectors_EMPTY_ARRAY = [];
5938 function getEntityActions(state, kind, name) {
5939 var _state$actions$kind$n;
5940 return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : private_selectors_EMPTY_ARRAY;
5941 }
5942
5943 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-selectors.js
5944 /**
5945 * External dependencies
5946 */
5947
5948
5949 /**
5950 * WordPress dependencies
5951 */
5952
5953
5954
5955
5956
5957 /**
5958 * Internal dependencies
5959 */
5960
5961
5962
5963
5964 const EMPTY_INSERTION_POINT = {
5965 rootClientId: undefined,
5966 insertionIndex: undefined,
5967 filterValue: undefined
5968 };
5969
5970 /**
5971 * Get the insertion point for the inserter.
5972 *
5973 * @param {Object} state Global application state.
5974 *
5975 * @return {Object} The root client ID, index to insert at and starting filter value.
5976 */
5977 const getInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
5978 if (typeof state.blockInserterPanel === 'object') {
5979 return state.blockInserterPanel;
5980 }
5981 if (getRenderingMode(state) === 'template-locked') {
5982 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5983 if (postContentClientId) {
5984 return {
5985 rootClientId: postContentClientId,
5986 insertionIndex: undefined,
5987 filterValue: undefined
5988 };
5989 }
5990 }
5991 return EMPTY_INSERTION_POINT;
5992 }, state => {
5993 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5994 return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
5995 }));
5996 function getListViewToggleRef(state) {
5997 return state.listViewToggleRef;
5998 }
5999 function getInserterSidebarToggleRef(state) {
6000 return state.inserterSidebarToggleRef;
6001 }
6002 const CARD_ICONS = {
6003 wp_block: library_symbol,
6004 wp_navigation: library_navigation,
6005 page: library_page,
6006 post: library_verse
6007 };
6008 const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
6009 {
6010 if (postType === 'wp_template_part' || postType === 'wp_template') {
6011 return __experimentalGetDefaultTemplatePartAreas(state).find(item => options.area === item.area)?.icon || library_layout;
6012 }
6013 if (CARD_ICONS[postType]) {
6014 return CARD_ICONS[postType];
6015 }
6016 const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
6017 // `icon` is the `menu_icon` property of a post type. We
6018 // only handle `dashicons` for now, even if the `menu_icon`
6019 // also supports urls and svg as values.
6020 if (postTypeEntity?.icon?.startsWith('dashicons-')) {
6021 return postTypeEntity.icon.slice(10);
6022 }
6023 return library_page;
6024 }
6025 });
6026
6027 /**
6028 * Returns the template parts and their blocks for the current edited template.
6029 *
6030 * @param {Object} state Global application state.
6031 * @return {Array} Template parts and their blocks in an array.
6032 */
6033 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
6034 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
6035 per_page: -1
6036 });
6037 const clientIds = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/template-part');
6038 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds);
6039 return memoizedGetFilteredTemplatePartBlocks(blocks, templateParts);
6040 });
6041
6042 /**
6043 * Returns true if there are unsaved changes to the
6044 * post's meta fields, and false otherwise.
6045 *
6046 * @param {Object} state Global application state.
6047 * @param {string} postType The post type of the post.
6048 * @param {number} postId The ID of the post.
6049 *
6050 * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
6051 */
6052 const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
6053 const {
6054 type: currentPostType,
6055 id: currentPostId
6056 } = getCurrentPost(state);
6057 // If no postType or postId is passed, use the current post.
6058 const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
6059 if (!edits?.meta) {
6060 return false;
6061 }
6062
6063 // Compare if anything apart from `footnotes` has changed.
6064 const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
6065 return !fast_deep_equal_default()({
6066 ...originalPostMeta,
6067 footnotes: undefined
6068 }, {
6069 ...edits.meta,
6070 footnotes: undefined
6071 });
6072 });
6073 function private_selectors_getEntityActions(state, ...args) {
6074 return getEntityActions(state.dataviews, ...args);
6075 }
6076
6077 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/index.js
6078 /**
6079 * WordPress dependencies
6080 */
6081
6082
6083 /**
6084 * Internal dependencies
6085 */
6086
6087
6088
6089
6090
6091
6092
6093
6094 /**
6095 * Post editor data store configuration.
6096 *
6097 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
6098 *
6099 * @type {Object}
6100 */
6101 const storeConfig = {
6102 reducer: store_reducer,
6103 selectors: selectors_namespaceObject,
6104 actions: actions_namespaceObject
6105 };
6106
6107 /**
6108 * Store definition for the editor namespace.
6109 *
6110 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
6111 *
6112 * @type {Object}
6113 */
6114 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
6115 ...storeConfig
6116 });
6117 (0,external_wp_data_namespaceObject.register)(store_store);
6118 unlock(store_store).registerPrivateActions(store_private_actions_namespaceObject);
6119 unlock(store_store).registerPrivateSelectors(store_private_selectors_namespaceObject);
6120
6121 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/post-meta.js
6122 /**
6123 * WordPress dependencies
6124 */
6125
6126
6127
6128 /**
6129 * Internal dependencies
6130 */
6131
6132 /* harmony default export */ const post_meta = ({
6133 name: 'core/post-meta',
6134 label: (0,external_wp_i18n_namespaceObject._x)('Post Meta', 'block bindings source'),
6135 getPlaceholder({
6136 args
6137 }) {
6138 return args.key;
6139 },
6140 getValue({
6141 registry,
6142 context,
6143 args
6144 }) {
6145 return registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', context?.postType, context?.postId).meta?.[args.key];
6146 },
6147 setValue({
6148 registry,
6149 context,
6150 args,
6151 value
6152 }) {
6153 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', context?.postType, context?.postId, {
6154 meta: {
6155 [args.key]: value
6156 }
6157 });
6158 },
6159 canUserEditValue({
6160 select,
6161 context,
6162 args
6163 }) {
6164 const postType = context?.postType || select(store_store).getCurrentPostType();
6165
6166 // Check that editing is happening in the post editor and not a template.
6167 if (postType === 'wp_template') {
6168 return false;
6169 }
6170
6171 // Check that the custom field is not protected and available in the REST API.
6172 const isFieldExposed = !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, context?.postId)?.meta?.[args.key];
6173 if (!isFieldExposed) {
6174 return false;
6175 }
6176
6177 // Check that the user has the capability to edit post meta.
6178 const canUserEdit = select(external_wp_coreData_namespaceObject.store).canUserEditEntityRecord('postType', context?.postType, context?.postId);
6179 if (!canUserEdit) {
6180 return false;
6181 }
6182 return true;
6183 }
6184 });
6185
6186 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/index.js
6187 /**
6188 * WordPress dependencies
6189 */
6190
6191
6192 /**
6193 * Internal dependencies
6194 */
6195
6196
6197
6198 const {
6199 registerBlockBindingsSource
6200 } = unlock((0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store));
6201 registerBlockBindingsSource(post_meta);
6202 registerBlockBindingsSource(pattern_overrides);
6203
6204 ;// CONCATENATED MODULE: external ["wp","compose"]
6205 const external_wp_compose_namespaceObject = window["wp"]["compose"];
6206 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
6207 /**
6208 * WordPress dependencies
6209 */
6210
6211
6212
6213
6214
6215
6216 /**
6217 * Internal dependencies
6218 */
6219
6220
6221 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
6222 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
6223
6224 /**
6225 * Object whose keys are the names of block attributes, where each value
6226 * represents the meta key to which the block attribute is intended to save.
6227 *
6228 * @see https://developer.wordpress.org/reference/functions/register_meta/
6229 *
6230 * @typedef {Object<string,string>} WPMetaAttributeMapping
6231 */
6232
6233 /**
6234 * Given a mapping of attribute names (meta source attributes) to their
6235 * associated meta key, returns a higher order component that overrides its
6236 * `attributes` and `setAttributes` props to sync any changes with the edited
6237 * post's meta keys.
6238 *
6239 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
6240 *
6241 * @return {WPHigherOrderComponent} Higher-order component.
6242 */
6243
6244 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({
6245 attributes,
6246 setAttributes,
6247 ...props
6248 }) => {
6249 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
6250 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
6251 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({
6252 ...attributes,
6253 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]]))
6254 }), [attributes, meta]);
6255 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
6256 attributes: mergedAttributes,
6257 setAttributes: nextAttributes => {
6258 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter(
6259 // Filter to intersection of keys between the updated
6260 // attributes and those with an associated meta key.
6261 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [
6262 // Rename the keys to the expected meta key name.
6263 metaAttributes[attributeKey], value]));
6264 if (Object.entries(nextMeta).length) {
6265 setMeta(nextMeta);
6266 }
6267 setAttributes(nextAttributes);
6268 },
6269 ...props
6270 });
6271 }, 'withMetaAttributeSource');
6272
6273 /**
6274 * Filters a registered block's settings to enhance a block's `edit` component
6275 * to upgrade meta-sourced attributes to use the post's meta entity property.
6276 *
6277 * @param {WPBlockSettings} settings Registered block settings.
6278 *
6279 * @return {WPBlockSettings} Filtered block settings.
6280 */
6281 function shimAttributeSource(settings) {
6282 var _settings$attributes;
6283 /** @type {WPMetaAttributeMapping} */
6284 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, {
6285 source
6286 }]) => source === 'meta').map(([attributeKey, {
6287 meta
6288 }]) => [attributeKey, meta]));
6289 if (Object.entries(metaAttributes).length) {
6290 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
6291 }
6292 return settings;
6293 }
6294 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
6295
6296 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/user.js
6297 /**
6298 * WordPress dependencies
6299 */
6300
6301
6302
6303
6304 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
6305
6306
6307
6308 function getUserLabel(user) {
6309 const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
6310 className: "editor-autocompleters__user-avatar",
6311 alt: "",
6312 src: user.avatar_urls[24]
6313 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6314 className: "editor-autocompleters__no-avatar"
6315 });
6316 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6317 children: [avatar, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6318 className: "editor-autocompleters__user-name",
6319 children: user.name
6320 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6321 className: "editor-autocompleters__user-slug",
6322 children: user.slug
6323 })]
6324 });
6325 }
6326
6327 /**
6328 * A user mentions completer.
6329 *
6330 * @type {WPCompleter}
6331 */
6332 /* harmony default export */ const user = ({
6333 name: 'users',
6334 className: 'editor-autocompleters__user',
6335 triggerPrefix: '@',
6336 useItems(filterValue) {
6337 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
6338 const {
6339 getUsers
6340 } = select(external_wp_coreData_namespaceObject.store);
6341 return getUsers({
6342 context: 'view',
6343 search: encodeURIComponent(filterValue)
6344 });
6345 }, [filterValue]);
6346 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
6347 key: `user-${user.slug}`,
6348 value: user,
6349 label: getUserLabel(user)
6350 })) : [], [users]);
6351 return [options];
6352 },
6353 getOptionCompletion(user) {
6354 return `@${user.slug}`;
6355 }
6356 });
6357
6358 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/default-autocompleters.js
6359 /**
6360 * WordPress dependencies
6361 */
6362
6363
6364 /**
6365 * Internal dependencies
6366 */
6367
6368 function setDefaultCompleters(completers = []) {
6369 // Provide copies so filters may directly modify them.
6370 completers.push({
6371 ...user
6372 });
6373 return completers;
6374 }
6375 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
6376
6377 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
6378 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
6379 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/media-upload.js
6380 /**
6381 * WordPress dependencies
6382 */
6383
6384
6385 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
6386
6387 ;// CONCATENATED MODULE: external ["wp","patterns"]
6388 const external_wp_patterns_namespaceObject = window["wp"]["patterns"];
6389 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/pattern-overrides.js
6390 /**
6391 * WordPress dependencies
6392 */
6393
6394
6395
6396
6397
6398
6399
6400 /**
6401 * Internal dependencies
6402 */
6403
6404
6405
6406
6407
6408 const {
6409 PatternOverridesControls,
6410 ResetOverridesControl,
6411 PatternOverridesBlockControls,
6412 PATTERN_TYPES,
6413 PARTIAL_SYNCING_SUPPORTED_BLOCKS,
6414 PATTERN_SYNC_TYPES
6415 } = unlock(external_wp_patterns_namespaceObject.privateApis);
6416
6417 /**
6418 * Override the default edit UI to include a new block inspector control for
6419 * assigning a partial syncing controls to supported blocks in the pattern editor.
6420 * Currently, only the `core/paragraph` block is supported.
6421 *
6422 * @param {Component} BlockEdit Original component.
6423 *
6424 * @return {Component} Wrapped component.
6425 */
6426 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
6427 const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
6428 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6429 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
6430 ...props
6431 }), props.isSelected && isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ControlsWithStoreSubscription, {
6432 ...props
6433 }), isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesBlockControls, {})]
6434 });
6435 });
6436
6437 // Split into a separate component to avoid a store subscription
6438 // on every block.
6439 function ControlsWithStoreSubscription(props) {
6440 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)();
6441 const {
6442 hasPatternOverridesSource,
6443 isEditingSyncedPattern
6444 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6445 const {
6446 getBlockBindingsSource
6447 } = unlock(select(external_wp_blocks_namespaceObject.store));
6448 const {
6449 getCurrentPostType,
6450 getEditedPostAttribute
6451 } = select(store_store);
6452 return {
6453 // For editing link to the site editor if the theme and user permissions support it.
6454 hasPatternOverridesSource: !!getBlockBindingsSource('core/pattern-overrides'),
6455 isEditingSyncedPattern: getCurrentPostType() === PATTERN_TYPES.user && getEditedPostAttribute('meta')?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute('wp_pattern_sync_status') !== PATTERN_SYNC_TYPES.unsynced
6456 };
6457 }, []);
6458 const bindings = props.attributes.metadata?.bindings;
6459 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
6460 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === 'default';
6461 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
6462 if (!hasPatternOverridesSource) {
6463 return null;
6464 }
6465 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6466 children: [shouldShowPatternOverridesControls && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesControls, {
6467 ...props
6468 }), shouldShowResetOverridesControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetOverridesControl, {
6469 ...props
6470 })]
6471 });
6472 }
6473 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
6474
6475 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/index.js
6476 /**
6477 * Internal dependencies
6478 */
6479
6480
6481
6482
6483
6484 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
6485 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
6486 ;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs
6487 function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
6488 ;// CONCATENATED MODULE: external ["wp","components"]
6489 const external_wp_components_namespaceObject = window["wp"]["components"];
6490 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
6491 /**
6492 * WordPress dependencies
6493 */
6494
6495
6496 const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6497 xmlns: "http://www.w3.org/2000/svg",
6498 viewBox: "0 0 24 24",
6499 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6500 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
6501 })
6502 });
6503 /* harmony default export */ const library_check = (check);
6504
6505 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
6506 /**
6507 * WordPress dependencies
6508 */
6509
6510
6511 const starFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6512 xmlns: "http://www.w3.org/2000/svg",
6513 viewBox: "0 0 24 24",
6514 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6515 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"
6516 })
6517 });
6518 /* harmony default export */ const star_filled = (starFilled);
6519
6520 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
6521 /**
6522 * WordPress dependencies
6523 */
6524
6525
6526 const starEmpty = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6527 xmlns: "http://www.w3.org/2000/svg",
6528 viewBox: "0 0 24 24",
6529 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6530 fillRule: "evenodd",
6531 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",
6532 clipRule: "evenodd"
6533 })
6534 });
6535 /* harmony default export */ const star_empty = (starEmpty);
6536
6537 ;// CONCATENATED MODULE: external ["wp","viewport"]
6538 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
6539 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
6540 /**
6541 * WordPress dependencies
6542 */
6543
6544
6545 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6546 xmlns: "http://www.w3.org/2000/svg",
6547 viewBox: "0 0 24 24",
6548 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6549 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"
6550 })
6551 });
6552 /* harmony default export */ const close_small = (closeSmall);
6553
6554 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/deprecated.js
6555 /**
6556 * WordPress dependencies
6557 */
6558
6559 function normalizeComplementaryAreaScope(scope) {
6560 if (['core/edit-post', 'core/edit-site'].includes(scope)) {
6561 external_wp_deprecated_default()(`${scope} interface scope`, {
6562 alternative: 'core interface scope',
6563 hint: 'core/edit-post and core/edit-site are merging.',
6564 version: '6.6'
6565 });
6566 return 'core';
6567 }
6568 return scope;
6569 }
6570 function normalizeComplementaryAreaName(scope, name) {
6571 if (scope === 'core' && name === 'edit-site/template') {
6572 external_wp_deprecated_default()(`edit-site/template sidebar`, {
6573 alternative: 'edit-post/document',
6574 version: '6.6'
6575 });
6576 return 'edit-post/document';
6577 }
6578 if (scope === 'core' && name === 'edit-site/block-inspector') {
6579 external_wp_deprecated_default()(`edit-site/block-inspector sidebar`, {
6580 alternative: 'edit-post/block',
6581 version: '6.6'
6582 });
6583 return 'edit-post/block';
6584 }
6585 return name;
6586 }
6587
6588 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
6589 /**
6590 * WordPress dependencies
6591 */
6592
6593
6594
6595 /**
6596 * Internal dependencies
6597 */
6598
6599
6600 /**
6601 * Set a default complementary area.
6602 *
6603 * @param {string} scope Complementary area scope.
6604 * @param {string} area Area identifier.
6605 *
6606 * @return {Object} Action object.
6607 */
6608 const setDefaultComplementaryArea = (scope, area) => {
6609 scope = normalizeComplementaryAreaScope(scope);
6610 area = normalizeComplementaryAreaName(scope, area);
6611 return {
6612 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
6613 scope,
6614 area
6615 };
6616 };
6617
6618 /**
6619 * Enable the complementary area.
6620 *
6621 * @param {string} scope Complementary area scope.
6622 * @param {string} area Area identifier.
6623 */
6624 const enableComplementaryArea = (scope, area) => ({
6625 registry,
6626 dispatch
6627 }) => {
6628 // Return early if there's no area.
6629 if (!area) {
6630 return;
6631 }
6632 scope = normalizeComplementaryAreaScope(scope);
6633 area = normalizeComplementaryAreaName(scope, area);
6634 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6635 if (!isComplementaryAreaVisible) {
6636 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
6637 }
6638 dispatch({
6639 type: 'ENABLE_COMPLEMENTARY_AREA',
6640 scope,
6641 area
6642 });
6643 };
6644
6645 /**
6646 * Disable the complementary area.
6647 *
6648 * @param {string} scope Complementary area scope.
6649 */
6650 const disableComplementaryArea = scope => ({
6651 registry
6652 }) => {
6653 scope = normalizeComplementaryAreaScope(scope);
6654 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6655 if (isComplementaryAreaVisible) {
6656 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
6657 }
6658 };
6659
6660 /**
6661 * Pins an item.
6662 *
6663 * @param {string} scope Item scope.
6664 * @param {string} item Item identifier.
6665 *
6666 * @return {Object} Action object.
6667 */
6668 const pinItem = (scope, item) => ({
6669 registry
6670 }) => {
6671 // Return early if there's no item.
6672 if (!item) {
6673 return;
6674 }
6675 scope = normalizeComplementaryAreaScope(scope);
6676 item = normalizeComplementaryAreaName(scope, item);
6677 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6678
6679 // The item is already pinned, there's nothing to do.
6680 if (pinnedItems?.[item] === true) {
6681 return;
6682 }
6683 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6684 ...pinnedItems,
6685 [item]: true
6686 });
6687 };
6688
6689 /**
6690 * Unpins an item.
6691 *
6692 * @param {string} scope Item scope.
6693 * @param {string} item Item identifier.
6694 */
6695 const unpinItem = (scope, item) => ({
6696 registry
6697 }) => {
6698 // Return early if there's no item.
6699 if (!item) {
6700 return;
6701 }
6702 scope = normalizeComplementaryAreaScope(scope);
6703 item = normalizeComplementaryAreaName(scope, item);
6704 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6705 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6706 ...pinnedItems,
6707 [item]: false
6708 });
6709 };
6710
6711 /**
6712 * Returns an action object used in signalling that a feature should be toggled.
6713 *
6714 * @param {string} scope The feature scope (e.g. core/edit-post).
6715 * @param {string} featureName The feature name.
6716 */
6717 function toggleFeature(scope, featureName) {
6718 return function ({
6719 registry
6720 }) {
6721 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
6722 since: '6.0',
6723 alternative: `dispatch( 'core/preferences' ).toggle`
6724 });
6725 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
6726 };
6727 }
6728
6729 /**
6730 * Returns an action object used in signalling that a feature should be set to
6731 * a true or false value
6732 *
6733 * @param {string} scope The feature scope (e.g. core/edit-post).
6734 * @param {string} featureName The feature name.
6735 * @param {boolean} value The value to set.
6736 *
6737 * @return {Object} Action object.
6738 */
6739 function setFeatureValue(scope, featureName, value) {
6740 return function ({
6741 registry
6742 }) {
6743 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
6744 since: '6.0',
6745 alternative: `dispatch( 'core/preferences' ).set`
6746 });
6747 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
6748 };
6749 }
6750
6751 /**
6752 * Returns an action object used in signalling that defaults should be set for features.
6753 *
6754 * @param {string} scope The feature scope (e.g. core/edit-post).
6755 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
6756 *
6757 * @return {Object} Action object.
6758 */
6759 function setFeatureDefaults(scope, defaults) {
6760 return function ({
6761 registry
6762 }) {
6763 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
6764 since: '6.0',
6765 alternative: `dispatch( 'core/preferences' ).setDefaults`
6766 });
6767 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
6768 };
6769 }
6770
6771 /**
6772 * Returns an action object used in signalling that the user opened a modal.
6773 *
6774 * @param {string} name A string that uniquely identifies the modal.
6775 *
6776 * @return {Object} Action object.
6777 */
6778 function openModal(name) {
6779 return {
6780 type: 'OPEN_MODAL',
6781 name
6782 };
6783 }
6784
6785 /**
6786 * Returns an action object signalling that the user closed a modal.
6787 *
6788 * @return {Object} Action object.
6789 */
6790 function closeModal() {
6791 return {
6792 type: 'CLOSE_MODAL'
6793 };
6794 }
6795
6796 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
6797 /**
6798 * WordPress dependencies
6799 */
6800
6801
6802
6803
6804 /**
6805 * Internal dependencies
6806 */
6807
6808
6809 /**
6810 * Returns the complementary area that is active in a given scope.
6811 *
6812 * @param {Object} state Global application state.
6813 * @param {string} scope Item scope.
6814 *
6815 * @return {string | null | undefined} The complementary area that is active in the given scope.
6816 */
6817 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6818 scope = normalizeComplementaryAreaScope(scope);
6819 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6820
6821 // Return `undefined` to indicate that the user has never toggled
6822 // visibility, this is the vanilla default. Other code relies on this
6823 // nuance in the return value.
6824 if (isComplementaryAreaVisible === undefined) {
6825 return undefined;
6826 }
6827
6828 // Return `null` to indicate the user hid the complementary area.
6829 if (isComplementaryAreaVisible === false) {
6830 return null;
6831 }
6832 return state?.complementaryAreas?.[scope];
6833 });
6834 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6835 scope = normalizeComplementaryAreaScope(scope);
6836 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6837 const identifier = state?.complementaryAreas?.[scope];
6838 return isVisible && identifier === undefined;
6839 });
6840
6841 /**
6842 * Returns a boolean indicating if an item is pinned or not.
6843 *
6844 * @param {Object} state Global application state.
6845 * @param {string} scope Scope.
6846 * @param {string} item Item to check.
6847 *
6848 * @return {boolean} True if the item is pinned and false otherwise.
6849 */
6850 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
6851 var _pinnedItems$item;
6852 scope = normalizeComplementaryAreaScope(scope);
6853 item = normalizeComplementaryAreaName(scope, item);
6854 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6855 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
6856 });
6857
6858 /**
6859 * Returns a boolean indicating whether a feature is active for a particular
6860 * scope.
6861 *
6862 * @param {Object} state The store state.
6863 * @param {string} scope The scope of the feature (e.g. core/edit-post).
6864 * @param {string} featureName The name of the feature.
6865 *
6866 * @return {boolean} Is the feature enabled?
6867 */
6868 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
6869 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
6870 since: '6.0',
6871 alternative: `select( 'core/preferences' ).get( scope, featureName )`
6872 });
6873 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
6874 });
6875
6876 /**
6877 * Returns true if a modal is active, or false otherwise.
6878 *
6879 * @param {Object} state Global application state.
6880 * @param {string} modalName A string that uniquely identifies the modal.
6881 *
6882 * @return {boolean} Whether the modal is active.
6883 */
6884 function isModalActive(state, modalName) {
6885 return state.activeModal === modalName;
6886 }
6887
6888 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
6889 /**
6890 * WordPress dependencies
6891 */
6892
6893 function complementaryAreas(state = {}, action) {
6894 switch (action.type) {
6895 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
6896 {
6897 const {
6898 scope,
6899 area
6900 } = action;
6901
6902 // If there's already an area, don't overwrite it.
6903 if (state[scope]) {
6904 return state;
6905 }
6906 return {
6907 ...state,
6908 [scope]: area
6909 };
6910 }
6911 case 'ENABLE_COMPLEMENTARY_AREA':
6912 {
6913 const {
6914 scope,
6915 area
6916 } = action;
6917 return {
6918 ...state,
6919 [scope]: area
6920 };
6921 }
6922 }
6923 return state;
6924 }
6925
6926 /**
6927 * Reducer for storing the name of the open modal, or null if no modal is open.
6928 *
6929 * @param {Object} state Previous state.
6930 * @param {Object} action Action object containing the `name` of the modal
6931 *
6932 * @return {Object} Updated state
6933 */
6934 function activeModal(state = null, action) {
6935 switch (action.type) {
6936 case 'OPEN_MODAL':
6937 return action.name;
6938 case 'CLOSE_MODAL':
6939 return null;
6940 }
6941 return state;
6942 }
6943 /* harmony default export */ const build_module_store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
6944 complementaryAreas,
6945 activeModal
6946 }));
6947
6948 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
6949 /**
6950 * The identifier for the data store.
6951 *
6952 * @type {string}
6953 */
6954 const constants_STORE_NAME = 'core/interface';
6955
6956 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
6957 /**
6958 * WordPress dependencies
6959 */
6960
6961
6962 /**
6963 * Internal dependencies
6964 */
6965
6966
6967
6968
6969
6970 /**
6971 * Store definition for the interface namespace.
6972 *
6973 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
6974 *
6975 * @type {Object}
6976 */
6977 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
6978 reducer: build_module_store_reducer,
6979 actions: store_actions_namespaceObject,
6980 selectors: store_selectors_namespaceObject
6981 });
6982
6983 // Once we build a more generic persistence plugin that works across types of stores
6984 // we'd be able to replace this with a register call.
6985 (0,external_wp_data_namespaceObject.register)(store);
6986
6987 ;// CONCATENATED MODULE: external ["wp","plugins"]
6988 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
6989 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
6990 /**
6991 * WordPress dependencies
6992 */
6993
6994 /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
6995 return {
6996 icon: ownProps.icon || context.icon,
6997 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
6998 };
6999 }));
7000
7001 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
7002 /**
7003 * WordPress dependencies
7004 */
7005
7006
7007
7008 /**
7009 * Internal dependencies
7010 */
7011
7012
7013
7014 function ComplementaryAreaToggle({
7015 as = external_wp_components_namespaceObject.Button,
7016 scope,
7017 identifier,
7018 icon,
7019 selectedIcon,
7020 name,
7021 ...props
7022 }) {
7023 const ComponentToUse = as;
7024 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]);
7025 const {
7026 enableComplementaryArea,
7027 disableComplementaryArea
7028 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7029 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComponentToUse, {
7030 icon: selectedIcon && isSelected ? selectedIcon : icon,
7031 "aria-controls": identifier.replace('/', ':'),
7032 onClick: () => {
7033 if (isSelected) {
7034 disableComplementaryArea(scope);
7035 } else {
7036 enableComplementaryArea(scope, identifier);
7037 }
7038 },
7039 ...props
7040 });
7041 }
7042 /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
7043
7044 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
7045 /**
7046 * External dependencies
7047 */
7048
7049
7050 /**
7051 * WordPress dependencies
7052 */
7053
7054
7055 /**
7056 * Internal dependencies
7057 */
7058
7059
7060
7061
7062 const ComplementaryAreaHeader = ({
7063 smallScreenTitle,
7064 children,
7065 className,
7066 toggleButtonProps
7067 }) => {
7068 const toggleButton = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7069 icon: close_small,
7070 ...toggleButtonProps
7071 });
7072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7073 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7074 className: "components-panel__header interface-complementary-area-header__small",
7075 children: [smallScreenTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
7076 className: "interface-complementary-area-header__small-title",
7077 children: smallScreenTitle
7078 }), toggleButton]
7079 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7080 className: dist_clsx('components-panel__header', 'interface-complementary-area-header', className),
7081 tabIndex: -1,
7082 children: [children, toggleButton]
7083 })]
7084 });
7085 };
7086 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
7087
7088 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
7089 /**
7090 * WordPress dependencies
7091 */
7092
7093
7094
7095 const noop = () => {};
7096 function ActionItemSlot({
7097 name,
7098 as: Component = external_wp_components_namespaceObject.ButtonGroup,
7099 fillProps = {},
7100 bubblesVirtually,
7101 ...props
7102 }) {
7103 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7104 name: name,
7105 bubblesVirtually: bubblesVirtually,
7106 fillProps: fillProps,
7107 children: fills => {
7108 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
7109 return null;
7110 }
7111
7112 // Special handling exists for backward compatibility.
7113 // It ensures that menu items created by plugin authors aren't
7114 // duplicated with automatically injected menu items coming
7115 // from pinnable plugin sidebars.
7116 // @see https://github.com/WordPress/gutenberg/issues/14457
7117 const initializedByPlugins = [];
7118 external_wp_element_namespaceObject.Children.forEach(fills, ({
7119 props: {
7120 __unstableExplicitMenuItem,
7121 __unstableTarget
7122 }
7123 }) => {
7124 if (__unstableTarget && __unstableExplicitMenuItem) {
7125 initializedByPlugins.push(__unstableTarget);
7126 }
7127 });
7128 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
7129 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
7130 return null;
7131 }
7132 return child;
7133 });
7134 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
7135 ...props,
7136 children: children
7137 });
7138 }
7139 });
7140 }
7141 function ActionItem({
7142 name,
7143 as: Component = external_wp_components_namespaceObject.Button,
7144 onClick,
7145 ...props
7146 }) {
7147 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7148 name: name,
7149 children: ({
7150 onClick: fpOnClick
7151 }) => {
7152 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
7153 onClick: onClick || fpOnClick ? (...args) => {
7154 (onClick || noop)(...args);
7155 (fpOnClick || noop)(...args);
7156 } : undefined,
7157 ...props
7158 });
7159 }
7160 });
7161 }
7162 ActionItem.Slot = ActionItemSlot;
7163 /* harmony default export */ const action_item = (ActionItem);
7164
7165 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
7166 /**
7167 * WordPress dependencies
7168 */
7169
7170
7171
7172 /**
7173 * Internal dependencies
7174 */
7175
7176
7177
7178 const PluginsMenuItem = ({
7179 // Menu item is marked with unstable prop for backward compatibility.
7180 // They are removed so they don't leak to DOM elements.
7181 // @see https://github.com/WordPress/gutenberg/issues/14457
7182 __unstableExplicitMenuItem,
7183 __unstableTarget,
7184 ...restProps
7185 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
7186 ...restProps
7187 });
7188 function ComplementaryAreaMoreMenuItem({
7189 scope,
7190 target,
7191 __unstableExplicitMenuItem,
7192 ...props
7193 }) {
7194 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7195 as: toggleProps => {
7196 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
7197 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
7198 __unstableTarget: `${scope}/${target}`,
7199 as: PluginsMenuItem,
7200 name: `${scope}/plugin-more-menu`,
7201 ...toggleProps
7202 });
7203 },
7204 role: "menuitemcheckbox",
7205 selectedIcon: library_check,
7206 name: target,
7207 scope: scope,
7208 ...props
7209 });
7210 }
7211
7212 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
7213 /**
7214 * External dependencies
7215 */
7216
7217
7218 /**
7219 * WordPress dependencies
7220 */
7221
7222
7223 function PinnedItems({
7224 scope,
7225 ...props
7226 }) {
7227 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7228 name: `PinnedItems/${scope}`,
7229 ...props
7230 });
7231 }
7232 function PinnedItemsSlot({
7233 scope,
7234 className,
7235 ...props
7236 }) {
7237 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7238 name: `PinnedItems/${scope}`,
7239 ...props,
7240 children: fills => fills?.length > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7241 className: dist_clsx(className, 'interface-pinned-items'),
7242 children: fills
7243 })
7244 });
7245 }
7246 PinnedItems.Slot = PinnedItemsSlot;
7247 /* harmony default export */ const pinned_items = (PinnedItems);
7248
7249 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
7250 /**
7251 * External dependencies
7252 */
7253
7254
7255 /**
7256 * WordPress dependencies
7257 */
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267 /**
7268 * Internal dependencies
7269 */
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279 const ANIMATION_DURATION = 0.3;
7280 function ComplementaryAreaSlot({
7281 scope,
7282 ...props
7283 }) {
7284 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7285 name: `ComplementaryArea/${scope}`,
7286 ...props
7287 });
7288 }
7289 const SIDEBAR_WIDTH = 280;
7290 const variants = {
7291 open: {
7292 width: SIDEBAR_WIDTH
7293 },
7294 closed: {
7295 width: 0
7296 },
7297 mobileOpen: {
7298 width: '100vw'
7299 }
7300 };
7301 function ComplementaryAreaFill({
7302 activeArea,
7303 isActive,
7304 scope,
7305 children,
7306 className,
7307 id
7308 }) {
7309 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7310 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
7311 // This is used to delay the exit animation to the next tick.
7312 // The reason this is done is to allow us to apply the right transition properties
7313 // When we switch from an open sidebar to another open sidebar.
7314 // we don't want to animate in this case.
7315 const previousActiveArea = (0,external_wp_compose_namespaceObject.usePrevious)(activeArea);
7316 const previousIsActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive);
7317 const [, setState] = (0,external_wp_element_namespaceObject.useState)({});
7318 (0,external_wp_element_namespaceObject.useEffect)(() => {
7319 setState({});
7320 }, [isActive]);
7321 const transition = {
7322 type: 'tween',
7323 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
7324 ease: [0.6, 0, 0.4, 1]
7325 };
7326 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7327 name: `ComplementaryArea/${scope}`,
7328 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7329 initial: false,
7330 children: (previousIsActive || isActive) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
7331 variants: variants,
7332 initial: "closed",
7333 animate: isMobileViewport ? 'mobileOpen' : 'open',
7334 exit: "closed",
7335 transition: transition,
7336 className: "interface-complementary-area__fill",
7337 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7338 id: id,
7339 className: className,
7340 style: {
7341 width: isMobileViewport ? '100vw' : SIDEBAR_WIDTH
7342 },
7343 children: children
7344 })
7345 })
7346 })
7347 });
7348 }
7349 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
7350 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
7351 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
7352 const {
7353 enableComplementaryArea,
7354 disableComplementaryArea
7355 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7356 (0,external_wp_element_namespaceObject.useEffect)(() => {
7357 // If the complementary area is active and the editor is switching from
7358 // a big to a small window size.
7359 if (isActive && isSmall && !previousIsSmall.current) {
7360 disableComplementaryArea(scope);
7361 // Flag the complementary area to be reopened when the window size
7362 // goes from small to big.
7363 shouldOpenWhenNotSmall.current = true;
7364 } else if (
7365 // If there is a flag indicating the complementary area should be
7366 // enabled when we go from small to big window size and we are going
7367 // from a small to big window size.
7368 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
7369 // Remove the flag indicating the complementary area should be
7370 // enabled.
7371 shouldOpenWhenNotSmall.current = false;
7372 enableComplementaryArea(scope, identifier);
7373 } else if (
7374 // If the flag is indicating the current complementary should be
7375 // reopened but another complementary area becomes active, remove
7376 // the flag.
7377 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
7378 shouldOpenWhenNotSmall.current = false;
7379 }
7380 if (isSmall !== previousIsSmall.current) {
7381 previousIsSmall.current = isSmall;
7382 }
7383 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]);
7384 }
7385 function ComplementaryArea({
7386 children,
7387 className,
7388 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
7389 identifier,
7390 header,
7391 headerClassName,
7392 icon,
7393 isPinnable = true,
7394 panelClassName,
7395 scope,
7396 name,
7397 smallScreenTitle,
7398 title,
7399 toggleShortcut,
7400 isActiveByDefault
7401 }) {
7402 // This state is used to delay the rendering of the Fill
7403 // until the initial effect runs.
7404 // This prevents the animation from running on mount if
7405 // the complementary area is active by default.
7406 const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
7407 const {
7408 isLoading,
7409 isActive,
7410 isPinned,
7411 activeArea,
7412 isSmall,
7413 isLarge,
7414 showIconLabels
7415 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7416 const {
7417 getActiveComplementaryArea,
7418 isComplementaryAreaLoading,
7419 isItemPinned
7420 } = select(store);
7421 const {
7422 get
7423 } = select(external_wp_preferences_namespaceObject.store);
7424 const _activeArea = getActiveComplementaryArea(scope);
7425 return {
7426 isLoading: isComplementaryAreaLoading(scope),
7427 isActive: _activeArea === identifier,
7428 isPinned: isItemPinned(scope, identifier),
7429 activeArea: _activeArea,
7430 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
7431 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'),
7432 showIconLabels: get('core', 'showIconLabels')
7433 };
7434 }, [identifier, scope]);
7435 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
7436 const {
7437 enableComplementaryArea,
7438 disableComplementaryArea,
7439 pinItem,
7440 unpinItem
7441 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7442 (0,external_wp_element_namespaceObject.useEffect)(() => {
7443 // Set initial visibility: For large screens, enable if it's active by
7444 // default. For small screens, always initially disable.
7445 if (isActiveByDefault && activeArea === undefined && !isSmall) {
7446 enableComplementaryArea(scope, identifier);
7447 } else if (activeArea === undefined && isSmall) {
7448 disableComplementaryArea(scope, identifier);
7449 }
7450 setIsReady(true);
7451 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]);
7452 if (!isReady) {
7453 return;
7454 }
7455 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7456 children: [isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items, {
7457 scope: scope,
7458 children: isPinned && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7459 scope: scope,
7460 identifier: identifier,
7461 isPressed: isActive && (!showIconLabels || isLarge),
7462 "aria-expanded": isActive,
7463 "aria-disabled": isLoading,
7464 label: title,
7465 icon: showIconLabels ? library_check : icon,
7466 showTooltip: !showIconLabels,
7467 variant: showIconLabels ? 'tertiary' : undefined,
7468 size: "compact"
7469 })
7470 }), name && isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem, {
7471 target: name,
7472 scope: scope,
7473 icon: icon,
7474 children: title
7475 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ComplementaryAreaFill, {
7476 activeArea: activeArea,
7477 isActive: isActive,
7478 className: dist_clsx('interface-complementary-area', className),
7479 scope: scope,
7480 id: identifier.replace('/', ':'),
7481 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_header, {
7482 className: headerClassName,
7483 closeLabel: closeLabel,
7484 onClose: () => disableComplementaryArea(scope),
7485 smallScreenTitle: smallScreenTitle,
7486 toggleButtonProps: {
7487 label: closeLabel,
7488 size: 'small',
7489 shortcut: toggleShortcut,
7490 scope,
7491 identifier
7492 },
7493 children: header || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7494 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
7495 className: "interface-complementary-area-header__title",
7496 children: title
7497 }), isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7498 className: "interface-complementary-area__pin-unpin-item",
7499 icon: isPinned ? star_filled : star_empty,
7500 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
7501 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
7502 isPressed: isPinned,
7503 "aria-expanded": isPinned,
7504 size: "compact"
7505 })]
7506 })
7507 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Panel, {
7508 className: panelClassName,
7509 children: children
7510 })]
7511 })]
7512 });
7513 }
7514 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
7515 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
7516 /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped);
7517
7518 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/fullscreen-mode/index.js
7519 /**
7520 * WordPress dependencies
7521 */
7522
7523 const FullscreenMode = ({
7524 isActive
7525 }) => {
7526 (0,external_wp_element_namespaceObject.useEffect)(() => {
7527 let isSticky = false;
7528 // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
7529 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
7530 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
7531 // a consequence of the FullscreenMode setup.
7532 if (document.body.classList.contains('sticky-menu')) {
7533 isSticky = true;
7534 document.body.classList.remove('sticky-menu');
7535 }
7536 return () => {
7537 if (isSticky) {
7538 document.body.classList.add('sticky-menu');
7539 }
7540 };
7541 }, []);
7542 (0,external_wp_element_namespaceObject.useEffect)(() => {
7543 if (isActive) {
7544 document.body.classList.add('is-fullscreen-mode');
7545 } else {
7546 document.body.classList.remove('is-fullscreen-mode');
7547 }
7548 return () => {
7549 if (isActive) {
7550 document.body.classList.remove('is-fullscreen-mode');
7551 }
7552 };
7553 }, [isActive]);
7554 return null;
7555 };
7556 /* harmony default export */ const fullscreen_mode = (FullscreenMode);
7557
7558 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/navigable-region/index.js
7559 /**
7560 * External dependencies
7561 */
7562
7563
7564 function NavigableRegion({
7565 children,
7566 className,
7567 ariaLabel,
7568 as: Tag = 'div',
7569 ...props
7570 }) {
7571 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tag, {
7572 className: dist_clsx('interface-navigable-region', className),
7573 "aria-label": ariaLabel,
7574 role: "region",
7575 tabIndex: "-1",
7576 ...props,
7577 children: children
7578 });
7579 }
7580
7581 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
7582 /**
7583 * External dependencies
7584 */
7585
7586
7587 /**
7588 * WordPress dependencies
7589 */
7590
7591
7592
7593
7594
7595 /**
7596 * Internal dependencies
7597 */
7598
7599
7600
7601 const interface_skeleton_ANIMATION_DURATION = 0.25;
7602 const commonTransition = {
7603 type: 'tween',
7604 duration: interface_skeleton_ANIMATION_DURATION,
7605 ease: [0.6, 0, 0.4, 1]
7606 };
7607 function useHTMLClass(className) {
7608 (0,external_wp_element_namespaceObject.useEffect)(() => {
7609 const element = document && document.querySelector(`html:not(.${className})`);
7610 if (!element) {
7611 return;
7612 }
7613 element.classList.toggle(className);
7614 return () => {
7615 element.classList.toggle(className);
7616 };
7617 }, [className]);
7618 }
7619 const headerVariants = {
7620 hidden: {
7621 opacity: 1,
7622 marginTop: -60
7623 },
7624 visible: {
7625 opacity: 1,
7626 marginTop: 0
7627 },
7628 distractionFreeHover: {
7629 opacity: 1,
7630 marginTop: 0,
7631 transition: {
7632 ...commonTransition,
7633 delay: 0.2,
7634 delayChildren: 0.2
7635 }
7636 },
7637 distractionFreeHidden: {
7638 opacity: 0,
7639 marginTop: -60
7640 },
7641 distractionFreeDisabled: {
7642 opacity: 0,
7643 marginTop: 0,
7644 transition: {
7645 ...commonTransition,
7646 delay: 0.8,
7647 delayChildren: 0.8
7648 }
7649 }
7650 };
7651 function InterfaceSkeleton({
7652 isDistractionFree,
7653 footer,
7654 header,
7655 editorNotices,
7656 sidebar,
7657 secondarySidebar,
7658 content,
7659 actions,
7660 labels,
7661 className,
7662 enableRegionNavigation = true,
7663 // Todo: does this need to be a prop.
7664 // Can we use a dependency to keyboard-shortcuts directly?
7665 shortcuts
7666 }, ref) {
7667 const [secondarySidebarResizeListener, secondarySidebarSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
7668 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
7669 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7670 const defaultTransition = {
7671 type: 'tween',
7672 duration: disableMotion ? 0 : interface_skeleton_ANIMATION_DURATION,
7673 ease: [0.6, 0, 0.4, 1]
7674 };
7675 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
7676 useHTMLClass('interface-interface-skeleton__html-container');
7677 const defaultLabels = {
7678 /* translators: accessibility text for the top bar landmark region. */
7679 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'),
7680 /* translators: accessibility text for the content landmark region. */
7681 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
7682 /* translators: accessibility text for the secondary sidebar landmark region. */
7683 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
7684 /* translators: accessibility text for the settings landmark region. */
7685 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
7686 /* translators: accessibility text for the publish landmark region. */
7687 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
7688 /* translators: accessibility text for the footer landmark region. */
7689 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
7690 };
7691 const mergedLabels = {
7692 ...defaultLabels,
7693 ...labels
7694 };
7695 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7696 ...(enableRegionNavigation ? navigateRegionsProps : {}),
7697 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, enableRegionNavigation ? navigateRegionsProps.ref : undefined]),
7698 className: dist_clsx(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer'),
7699 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7700 className: "interface-interface-skeleton__editor",
7701 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7702 initial: false,
7703 children: !!header && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7704 as: external_wp_components_namespaceObject.__unstableMotion.div,
7705 className: "interface-interface-skeleton__header",
7706 "aria-label": mergedLabels.header,
7707 initial: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7708 whileHover: isDistractionFree ? 'distractionFreeHover' : 'visible',
7709 animate: isDistractionFree ? 'distractionFreeDisabled' : 'visible',
7710 exit: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7711 variants: headerVariants,
7712 transition: defaultTransition,
7713 children: header
7714 })
7715 }), isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7716 className: "interface-interface-skeleton__header",
7717 children: editorNotices
7718 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7719 className: "interface-interface-skeleton__body",
7720 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7721 initial: false,
7722 children: !!secondarySidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7723 className: "interface-interface-skeleton__secondary-sidebar",
7724 ariaLabel: mergedLabels.secondarySidebar,
7725 as: external_wp_components_namespaceObject.__unstableMotion.div,
7726 initial: "closed",
7727 animate: isMobileViewport ? 'mobileOpen' : 'open',
7728 exit: "closed",
7729 variants: {
7730 open: {
7731 width: secondarySidebarSize.width
7732 },
7733 closed: {
7734 width: 0
7735 },
7736 mobileOpen: {
7737 width: '100vw'
7738 }
7739 },
7740 transition: defaultTransition,
7741 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7742 style: {
7743 position: 'absolute',
7744 width: isMobileViewport ? '100vw' : 'fit-content',
7745 height: '100%',
7746 right: 0
7747 },
7748 children: [secondarySidebarResizeListener, secondarySidebar]
7749 })
7750 })
7751 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7752 className: "interface-interface-skeleton__content",
7753 ariaLabel: mergedLabels.body,
7754 children: content
7755 }), !!sidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7756 className: "interface-interface-skeleton__sidebar",
7757 ariaLabel: mergedLabels.sidebar,
7758 children: sidebar
7759 }), !!actions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7760 className: "interface-interface-skeleton__actions",
7761 ariaLabel: mergedLabels.actions,
7762 children: actions
7763 })]
7764 })]
7765 }), !!footer && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7766 className: "interface-interface-skeleton__footer",
7767 ariaLabel: mergedLabels.footer,
7768 children: footer
7769 })]
7770 });
7771 }
7772 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
7773
7774 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
7775
7776
7777
7778
7779
7780
7781
7782
7783 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
7784
7785
7786
7787 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/index.js
7788 /**
7789 * WordPress dependencies
7790 */
7791
7792
7793
7794
7795
7796 /**
7797 * Internal dependencies
7798 */
7799
7800
7801 /**
7802 * Component handles the keyboard shortcuts for the editor.
7803 *
7804 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
7805 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
7806 * and toggling the sidebar.
7807 */
7808 function EditorKeyboardShortcuts() {
7809 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
7810 const {
7811 richEditingEnabled,
7812 codeEditingEnabled
7813 } = select(store_store).getEditorSettings();
7814 return !richEditingEnabled || !codeEditingEnabled;
7815 }, []);
7816 const {
7817 getBlockSelectionStart
7818 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
7819 const {
7820 getActiveComplementaryArea
7821 } = (0,external_wp_data_namespaceObject.useSelect)(store);
7822 const {
7823 enableComplementaryArea,
7824 disableComplementaryArea
7825 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7826 const {
7827 redo,
7828 undo,
7829 savePost,
7830 setIsListViewOpened,
7831 switchEditorMode,
7832 toggleDistractionFree
7833 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7834 const {
7835 isEditedPostDirty,
7836 isPostSavingLocked,
7837 isListViewOpened,
7838 getEditorMode
7839 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
7840 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-mode', () => {
7841 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
7842 }, {
7843 isDisabled: isModeToggleDisabled
7844 });
7845 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-distraction-free', () => {
7846 toggleDistractionFree();
7847 });
7848 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
7849 undo();
7850 event.preventDefault();
7851 });
7852 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
7853 redo();
7854 event.preventDefault();
7855 });
7856 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
7857 event.preventDefault();
7858
7859 /**
7860 * Do not save the post if post saving is locked.
7861 */
7862 if (isPostSavingLocked()) {
7863 return;
7864 }
7865
7866 // TODO: This should be handled in the `savePost` effect in
7867 // considering `isSaveable`. See note on `isEditedPostSaveable`
7868 // selector about dirtiness and meta-boxes.
7869 //
7870 // See: `isEditedPostSaveable`
7871 if (!isEditedPostDirty()) {
7872 return;
7873 }
7874 savePost();
7875 });
7876
7877 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
7878 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => {
7879 if (!isListViewOpened()) {
7880 event.preventDefault();
7881 setIsListViewOpened(true);
7882 }
7883 });
7884 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-sidebar', event => {
7885 // This shortcut has no known clashes, but use preventDefault to prevent any
7886 // obscure shortcuts from triggering.
7887 event.preventDefault();
7888 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(getActiveComplementaryArea('core'));
7889 if (isEditorSidebarOpened) {
7890 disableComplementaryArea('core');
7891 } else {
7892 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
7893 enableComplementaryArea('core', sidebarToOpen);
7894 }
7895 });
7896 return null;
7897 }
7898
7899 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/index.js
7900
7901
7902 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autosave-monitor/index.js
7903 /**
7904 * WordPress dependencies
7905 */
7906
7907
7908
7909
7910
7911 /**
7912 * Internal dependencies
7913 */
7914
7915 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
7916 constructor(props) {
7917 super(props);
7918 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
7919 }
7920 componentDidMount() {
7921 if (!this.props.disableIntervalChecks) {
7922 this.setAutosaveTimer();
7923 }
7924 }
7925 componentDidUpdate(prevProps) {
7926 if (this.props.disableIntervalChecks) {
7927 if (this.props.editsReference !== prevProps.editsReference) {
7928 this.props.autosave();
7929 }
7930 return;
7931 }
7932 if (this.props.interval !== prevProps.interval) {
7933 clearTimeout(this.timerId);
7934 this.setAutosaveTimer();
7935 }
7936 if (!this.props.isDirty) {
7937 this.needsAutosave = false;
7938 return;
7939 }
7940 if (this.props.isAutosaving && !prevProps.isAutosaving) {
7941 this.needsAutosave = false;
7942 return;
7943 }
7944 if (this.props.editsReference !== prevProps.editsReference) {
7945 this.needsAutosave = true;
7946 }
7947 }
7948 componentWillUnmount() {
7949 clearTimeout(this.timerId);
7950 }
7951 setAutosaveTimer(timeout = this.props.interval * 1000) {
7952 this.timerId = setTimeout(() => {
7953 this.autosaveTimerHandler();
7954 }, timeout);
7955 }
7956 autosaveTimerHandler() {
7957 if (!this.props.isAutosaveable) {
7958 this.setAutosaveTimer(1000);
7959 return;
7960 }
7961 if (this.needsAutosave) {
7962 this.needsAutosave = false;
7963 this.props.autosave();
7964 }
7965 this.setAutosaveTimer();
7966 }
7967 render() {
7968 return null;
7969 }
7970 }
7971
7972 /**
7973 * Monitors the changes made to the edited post and triggers autosave if necessary.
7974 *
7975 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
7976 * The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as
7977 * the specific way of detecting changes.
7978 *
7979 * There are two caveats:
7980 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
7981 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
7982 *
7983 * @param {Object} props - The properties passed to the component.
7984 * @param {Function} props.autosave - The function to call when changes need to be saved.
7985 * @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
7986 * @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
7987 * @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
7988 * @param {boolean} props.isDirty - Indicates if there are unsaved changes.
7989 *
7990 * @example
7991 * ```jsx
7992 * <AutosaveMonitor interval={30000} />
7993 * ```
7994 */
7995 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
7996 const {
7997 getReferenceByDistinctEdits
7998 } = select(external_wp_coreData_namespaceObject.store);
7999 const {
8000 isEditedPostDirty,
8001 isEditedPostAutosaveable,
8002 isAutosavingPost,
8003 getEditorSettings
8004 } = select(store_store);
8005 const {
8006 interval = getEditorSettings().autosaveInterval
8007 } = ownProps;
8008 return {
8009 editsReference: getReferenceByDistinctEdits(),
8010 isDirty: isEditedPostDirty(),
8011 isAutosaveable: isEditedPostAutosaveable(),
8012 isAutosaving: isAutosavingPost(),
8013 interval
8014 };
8015 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
8016 autosave() {
8017 const {
8018 autosave = dispatch(store_store).autosave
8019 } = ownProps;
8020 autosave();
8021 }
8022 }))])(AutosaveMonitor));
8023
8024 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right-small.js
8025 /**
8026 * WordPress dependencies
8027 */
8028
8029
8030 const chevronRightSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8031 xmlns: "http://www.w3.org/2000/svg",
8032 viewBox: "0 0 24 24",
8033 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8034 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
8035 })
8036 });
8037 /* harmony default export */ const chevron_right_small = (chevronRightSmall);
8038
8039 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left-small.js
8040 /**
8041 * WordPress dependencies
8042 */
8043
8044
8045 const chevronLeftSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8046 xmlns: "http://www.w3.org/2000/svg",
8047 viewBox: "0 0 24 24",
8048 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8049 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
8050 })
8051 });
8052 /* harmony default export */ const chevron_left_small = (chevronLeftSmall);
8053
8054 ;// CONCATENATED MODULE: external ["wp","keycodes"]
8055 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
8056 ;// CONCATENATED MODULE: external ["wp","commands"]
8057 const external_wp_commands_namespaceObject = window["wp"]["commands"];
8058 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-bar/index.js
8059 /**
8060 * External dependencies
8061 */
8062
8063
8064 /**
8065 * WordPress dependencies
8066 */
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079 /**
8080 * Internal dependencies
8081 */
8082
8083
8084
8085
8086
8087 const TYPE_LABELS = {
8088 // translators: 1: Pattern title.
8089 wp_pattern: (0,external_wp_i18n_namespaceObject.__)('Editing pattern: %s'),
8090 // translators: 1: Navigation menu title.
8091 wp_navigation: (0,external_wp_i18n_namespaceObject.__)('Editing navigation menu: %s'),
8092 // translators: 1: Template title.
8093 wp_template: (0,external_wp_i18n_namespaceObject.__)('Editing template: %s'),
8094 // translators: 1: Template part title.
8095 wp_template_part: (0,external_wp_i18n_namespaceObject.__)('Editing template part: %s')
8096 };
8097 const MotionButton = (0,external_wp_components_namespaceObject.__unstableMotion)(external_wp_components_namespaceObject.Button);
8098
8099 /**
8100 * This component renders a navigation bar at the top of the editor. It displays the title of the current document,
8101 * a back button (if applicable), and a command center button. It also handles different states of the document,
8102 * such as "not found" or "unsynced".
8103 *
8104 * @example
8105 * ```jsx
8106 * <DocumentBar />
8107 * ```
8108 *
8109 * @return {JSX.Element} The rendered DocumentBar component.
8110 */
8111 function DocumentBar() {
8112 const {
8113 postType,
8114 documentTitle,
8115 isNotFound,
8116 isUnsyncedPattern,
8117 templateIcon,
8118 templateTitle,
8119 onNavigateToPreviousEntityRecord
8120 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8121 const {
8122 getCurrentPostType,
8123 getCurrentPostId,
8124 getEditorSettings,
8125 __experimentalGetTemplateInfo: getTemplateInfo
8126 } = select(store_store);
8127 const {
8128 getEditedEntityRecord,
8129 isResolving: isResolvingSelector
8130 } = select(external_wp_coreData_namespaceObject.store);
8131 const _postType = getCurrentPostType();
8132 const _postId = getCurrentPostId();
8133 const _document = getEditedEntityRecord('postType', _postType, _postId);
8134 const _templateInfo = getTemplateInfo(_document);
8135 return {
8136 postType: _postType,
8137 documentTitle: _document.title,
8138 isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
8139 isUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',
8140 templateIcon: unlock(select(store_store)).getPostIcon(_postType, {
8141 area: _document?.area
8142 }),
8143 templateTitle: _templateInfo.title,
8144 onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
8145 };
8146 }, []);
8147 const {
8148 open: openCommandCenter
8149 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store);
8150 const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
8151 const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
8152 const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
8153 const hasBackButton = !!onNavigateToPreviousEntityRecord;
8154 const title = isTemplate ? templateTitle : documentTitle;
8155 const mounted = (0,external_wp_element_namespaceObject.useRef)(false);
8156 (0,external_wp_element_namespaceObject.useEffect)(() => {
8157 mounted.current = true;
8158 }, []);
8159 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8160 className: dist_clsx('editor-document-bar', {
8161 'has-back-button': hasBackButton,
8162 'is-global': isGlobalEntity && !isUnsyncedPattern
8163 }),
8164 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
8165 children: hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MotionButton, {
8166 className: "editor-document-bar__back",
8167 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small,
8168 onClick: event => {
8169 event.stopPropagation();
8170 onNavigateToPreviousEntityRecord();
8171 },
8172 size: "compact",
8173 initial: mounted.current ? {
8174 opacity: 0,
8175 transform: 'translateX(15%)'
8176 } : false // Don't show entry animation when DocumentBar mounts.
8177 ,
8178 animate: {
8179 opacity: 1,
8180 transform: 'translateX(0%)'
8181 },
8182 exit: {
8183 opacity: 0,
8184 transform: 'translateX(15%)'
8185 },
8186 transition: isReducedMotion ? {
8187 duration: 0
8188 } : undefined,
8189 children: (0,external_wp_i18n_namespaceObject.__)('Back')
8190 })
8191 }), isNotFound ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8192 children: (0,external_wp_i18n_namespaceObject.__)('Document not found')
8193 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
8194 className: "editor-document-bar__command",
8195 onClick: () => openCommandCenter(),
8196 size: "compact",
8197 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
8198 className: "editor-document-bar__title"
8199 // Force entry animation when the back button is added or removed.
8200 ,
8201
8202 initial: mounted.current ? {
8203 opacity: 0,
8204 transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
8205 } : false // Don't show entry animation when DocumentBar mounts.
8206 ,
8207 animate: {
8208 opacity: 1,
8209 transform: 'translateX(0%)'
8210 },
8211 transition: isReducedMotion ? {
8212 duration: 0
8213 } : undefined,
8214 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
8215 icon: templateIcon
8216 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8217 size: "body",
8218 as: "h1",
8219 "aria-label": TYPE_LABELS[postType] ?
8220 // eslint-disable-next-line @wordpress/valid-sprintf
8221 (0,external_wp_i18n_namespaceObject.sprintf)(TYPE_LABELS[postType], title) : undefined,
8222 children: title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title')
8223 })]
8224 }, hasBackButton), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8225 className: "editor-document-bar__shortcut",
8226 children: external_wp_keycodes_namespaceObject.displayShortcut.primary('k')
8227 })]
8228 })]
8229 });
8230 }
8231
8232 ;// CONCATENATED MODULE: external ["wp","richText"]
8233 const external_wp_richText_namespaceObject = window["wp"]["richText"];
8234 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/item.js
8235 /**
8236 * External dependencies
8237 */
8238
8239
8240
8241 const TableOfContentsItem = ({
8242 children,
8243 isValid,
8244 level,
8245 href,
8246 onSelect
8247 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
8248 className: dist_clsx('document-outline__item', `is-${level.toLowerCase()}`, {
8249 'is-invalid': !isValid
8250 }),
8251 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("a", {
8252 href: href,
8253 className: "document-outline__button",
8254 onClick: onSelect,
8255 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8256 className: "document-outline__emdash",
8257 "aria-hidden": "true"
8258 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
8259 className: "document-outline__level",
8260 children: level
8261 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8262 className: "document-outline__item-content",
8263 children: children
8264 })]
8265 })
8266 });
8267 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
8268
8269 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/index.js
8270 /**
8271 * WordPress dependencies
8272 */
8273
8274
8275
8276
8277
8278
8279
8280 /**
8281 * Internal dependencies
8282 */
8283
8284
8285
8286 /**
8287 * Module constants
8288 */
8289
8290
8291 const emptyHeadingContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8292 children: (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')
8293 });
8294 const incorrectLevelContent = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8295 children: (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)')
8296 }, "incorrect-message")];
8297 const singleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8298 children: (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)')
8299 }, "incorrect-message-h1")];
8300 const multipleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-multiple-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8301 children: (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)')
8302 }, "incorrect-message-multiple-h1")];
8303 function EmptyOutlineIllustration() {
8304 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
8305 width: "138",
8306 height: "148",
8307 viewBox: "0 0 138 148",
8308 fill: "none",
8309 xmlns: "http://www.w3.org/2000/svg",
8310 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8311 width: "138",
8312 height: "148",
8313 rx: "4",
8314 fill: "#F0F6FC"
8315 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8316 x1: "44",
8317 y1: "28",
8318 x2: "24",
8319 y2: "28",
8320 stroke: "#DDDDDD"
8321 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8322 x: "48",
8323 y: "16",
8324 width: "27",
8325 height: "23",
8326 rx: "4",
8327 fill: "#DDDDDD"
8328 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8329 d: "M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z",
8330 fill: "black"
8331 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8332 x1: "55",
8333 y1: "59",
8334 x2: "24",
8335 y2: "59",
8336 stroke: "#DDDDDD"
8337 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8338 x: "59",
8339 y: "47",
8340 width: "29",
8341 height: "23",
8342 rx: "4",
8343 fill: "#DDDDDD"
8344 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8345 d: "M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z",
8346 fill: "black"
8347 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8348 x1: "80",
8349 y1: "90",
8350 x2: "24",
8351 y2: "90",
8352 stroke: "#DDDDDD"
8353 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8354 x: "84",
8355 y: "78",
8356 width: "30",
8357 height: "23",
8358 rx: "4",
8359 fill: "#F0B849"
8360 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8361 d: "M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z",
8362 fill: "black"
8363 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8364 x1: "66",
8365 y1: "121",
8366 x2: "24",
8367 y2: "121",
8368 stroke: "#DDDDDD"
8369 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8370 x: "70",
8371 y: "109",
8372 width: "29",
8373 height: "23",
8374 rx: "4",
8375 fill: "#DDDDDD"
8376 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8377 d: "M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z",
8378 fill: "black"
8379 })]
8380 });
8381 }
8382
8383 /**
8384 * Returns an array of heading blocks enhanced with the following properties:
8385 * level - An integer with the heading level.
8386 * isEmpty - Flag indicating if the heading has no content.
8387 *
8388 * @param {?Array} blocks An array of blocks.
8389 *
8390 * @return {Array} An array of heading blocks enhanced with the properties described above.
8391 */
8392 const computeOutlineHeadings = (blocks = []) => {
8393 return blocks.flatMap((block = {}) => {
8394 if (block.name === 'core/heading') {
8395 return {
8396 ...block,
8397 level: block.attributes.level,
8398 isEmpty: isEmptyHeading(block)
8399 };
8400 }
8401 return computeOutlineHeadings(block.innerBlocks);
8402 });
8403 };
8404 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.trim().length === 0;
8405
8406 /**
8407 * Renders a document outline component.
8408 *
8409 * @param {Object} props Props.
8410 * @param {Function} props.onSelect Function to be called when an outline item is selected.
8411 * @param {boolean} props.isTitleSupported Indicates whether the title is supported.
8412 * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
8413 *
8414 * @return {Component} The component to be rendered.
8415 */
8416 function DocumentOutline({
8417 onSelect,
8418 isTitleSupported,
8419 hasOutlineItemsDisabled
8420 }) {
8421 const {
8422 selectBlock
8423 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8424 const {
8425 blocks,
8426 title
8427 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8428 var _postType$supports$ti;
8429 const {
8430 getBlocks
8431 } = select(external_wp_blockEditor_namespaceObject.store);
8432 const {
8433 getEditedPostAttribute
8434 } = select(store_store);
8435 const {
8436 getPostType
8437 } = select(external_wp_coreData_namespaceObject.store);
8438 const postType = getPostType(getEditedPostAttribute('type'));
8439 return {
8440 title: getEditedPostAttribute('title'),
8441 blocks: getBlocks(),
8442 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
8443 };
8444 });
8445 const headings = computeOutlineHeadings(blocks);
8446 if (headings.length < 1) {
8447 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8448 className: "editor-document-outline has-no-headings",
8449 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyOutlineIllustration, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
8450 children: (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.')
8451 })]
8452 });
8453 }
8454 let prevHeadingLevel = 1;
8455
8456 // Not great but it's the simplest way to locate the title right now.
8457 const titleNode = document.querySelector('.editor-post-title__input');
8458 const hasTitle = isTitleSupported && title && titleNode;
8459 const countByLevel = headings.reduce((acc, heading) => ({
8460 ...acc,
8461 [heading.level]: (acc[heading.level] || 0) + 1
8462 }), {});
8463 const hasMultipleH1 = countByLevel[1] > 1;
8464 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8465 className: "document-outline",
8466 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
8467 children: [hasTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_outline_item, {
8468 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
8469 isValid: true,
8470 onSelect: onSelect,
8471 href: `#${titleNode.id}`,
8472 isDisabled: hasOutlineItemsDisabled,
8473 children: title
8474 }), headings.map((item, index) => {
8475 // Headings remain the same, go up by one, or down by any amount.
8476 // Otherwise there are missing levels.
8477 const isIncorrectLevel = item.level > prevHeadingLevel + 1;
8478 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
8479 prevHeadingLevel = item.level;
8480 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(document_outline_item, {
8481 level: `H${item.level}`,
8482 isValid: isValid,
8483 isDisabled: hasOutlineItemsDisabled,
8484 href: `#block-${item.clientId}`,
8485 onSelect: () => {
8486 selectBlock(item.clientId);
8487 onSelect?.();
8488 },
8489 children: [item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
8490 html: item.attributes.content
8491 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
8492 }, index);
8493 })]
8494 })
8495 });
8496 }
8497
8498 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/check.js
8499 /**
8500 * WordPress dependencies
8501 */
8502
8503
8504
8505 /**
8506 * Component check if there are any headings (core/heading blocks) present in the document.
8507 *
8508 * @param {Object} props Props.
8509 * @param {Element} props.children Children to be rendered.
8510 *
8511 * @return {Component|null} The component to be rendered or null if there are headings.
8512 */
8513 function DocumentOutlineCheck({
8514 children
8515 }) {
8516 const hasHeadings = (0,external_wp_data_namespaceObject.useSelect)(select => {
8517 const {
8518 getGlobalBlockCount
8519 } = select(external_wp_blockEditor_namespaceObject.store);
8520 return getGlobalBlockCount('core/heading') > 0;
8521 });
8522 if (hasHeadings) {
8523 return null;
8524 }
8525 return children;
8526 }
8527
8528 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
8529 /**
8530 * WordPress dependencies
8531 */
8532
8533
8534
8535
8536
8537
8538
8539 /**
8540 * Component for registering editor keyboard shortcuts.
8541 *
8542 * @return {Element} The component to be rendered.
8543 */
8544
8545 function EditorKeyboardShortcutsRegister() {
8546 // Registering the shortcuts.
8547 const {
8548 registerShortcut
8549 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
8550 (0,external_wp_element_namespaceObject.useEffect)(() => {
8551 registerShortcut({
8552 name: 'core/editor/toggle-mode',
8553 category: 'global',
8554 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
8555 keyCombination: {
8556 modifier: 'secondary',
8557 character: 'm'
8558 }
8559 });
8560 registerShortcut({
8561 name: 'core/editor/save',
8562 category: 'global',
8563 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
8564 keyCombination: {
8565 modifier: 'primary',
8566 character: 's'
8567 }
8568 });
8569 registerShortcut({
8570 name: 'core/editor/undo',
8571 category: 'global',
8572 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
8573 keyCombination: {
8574 modifier: 'primary',
8575 character: 'z'
8576 }
8577 });
8578 registerShortcut({
8579 name: 'core/editor/redo',
8580 category: 'global',
8581 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
8582 keyCombination: {
8583 modifier: 'primaryShift',
8584 character: 'z'
8585 },
8586 // Disable on Apple OS because it conflicts with the browser's
8587 // history shortcut. It's a fine alias for both Windows and Linux.
8588 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
8589 // Linux, we keep it as the default for consistency.
8590 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{
8591 modifier: 'primary',
8592 character: 'y'
8593 }]
8594 });
8595 registerShortcut({
8596 name: 'core/editor/toggle-list-view',
8597 category: 'global',
8598 description: (0,external_wp_i18n_namespaceObject.__)('Open the List View.'),
8599 keyCombination: {
8600 modifier: 'access',
8601 character: 'o'
8602 }
8603 });
8604 registerShortcut({
8605 name: 'core/editor/toggle-distraction-free',
8606 category: 'global',
8607 description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'),
8608 keyCombination: {
8609 modifier: 'primaryShift',
8610 character: '\\'
8611 }
8612 });
8613 registerShortcut({
8614 name: 'core/editor/toggle-sidebar',
8615 category: 'global',
8616 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'),
8617 keyCombination: {
8618 modifier: 'primaryShift',
8619 character: ','
8620 }
8621 });
8622 registerShortcut({
8623 name: 'core/editor/keyboard-shortcuts',
8624 category: 'main',
8625 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
8626 keyCombination: {
8627 modifier: 'access',
8628 character: 'h'
8629 }
8630 });
8631 registerShortcut({
8632 name: 'core/editor/next-region',
8633 category: 'global',
8634 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
8635 keyCombination: {
8636 modifier: 'ctrl',
8637 character: '`'
8638 },
8639 aliases: [{
8640 modifier: 'access',
8641 character: 'n'
8642 }]
8643 });
8644 registerShortcut({
8645 name: 'core/editor/previous-region',
8646 category: 'global',
8647 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
8648 keyCombination: {
8649 modifier: 'ctrlShift',
8650 character: '`'
8651 },
8652 aliases: [{
8653 modifier: 'access',
8654 character: 'p'
8655 }, {
8656 modifier: 'ctrlShift',
8657 character: '~'
8658 }]
8659 });
8660 }, [registerShortcut]);
8661 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, {});
8662 }
8663 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
8664
8665 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
8666 /**
8667 * WordPress dependencies
8668 */
8669
8670
8671 const redo_redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8672 xmlns: "http://www.w3.org/2000/svg",
8673 viewBox: "0 0 24 24",
8674 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8675 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"
8676 })
8677 });
8678 /* harmony default export */ const library_redo = (redo_redo);
8679
8680 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
8681 /**
8682 * WordPress dependencies
8683 */
8684
8685
8686 const undo_undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8687 xmlns: "http://www.w3.org/2000/svg",
8688 viewBox: "0 0 24 24",
8689 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8690 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"
8691 })
8692 });
8693 /* harmony default export */ const library_undo = (undo_undo);
8694
8695 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/redo.js
8696 /**
8697 * WordPress dependencies
8698 */
8699
8700
8701
8702
8703
8704
8705
8706 /**
8707 * Internal dependencies
8708 */
8709
8710
8711 function EditorHistoryRedo(props, ref) {
8712 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
8713 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
8714 const {
8715 redo
8716 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8717 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8718 ...props,
8719 ref: ref,
8720 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
8721 /* translators: button label text should, if possible, be under 16 characters. */,
8722 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
8723 shortcut: shortcut
8724 // If there are no redo levels we don't want to actually disable this
8725 // button, because it will remove focus for keyboard users.
8726 // See: https://github.com/WordPress/gutenberg/issues/3486
8727 ,
8728 "aria-disabled": !hasRedo,
8729 onClick: hasRedo ? redo : undefined,
8730 className: "editor-history__redo"
8731 });
8732 }
8733
8734 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8735
8736 /**
8737 * Renders the redo button for the editor history.
8738 *
8739 * @param {Object} props - Props.
8740 * @param {Ref} ref - Forwarded ref.
8741 *
8742 * @return {Component} The component to be rendered.
8743 */
8744 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
8745
8746 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/undo.js
8747 /**
8748 * WordPress dependencies
8749 */
8750
8751
8752
8753
8754
8755
8756
8757 /**
8758 * Internal dependencies
8759 */
8760
8761
8762 function EditorHistoryUndo(props, ref) {
8763 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
8764 const {
8765 undo
8766 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8767 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8768 ...props,
8769 ref: ref,
8770 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
8771 /* translators: button label text should, if possible, be under 16 characters. */,
8772 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
8773 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z')
8774 // If there are no undo levels we don't want to actually disable this
8775 // button, because it will remove focus for keyboard users.
8776 // See: https://github.com/WordPress/gutenberg/issues/3486
8777 ,
8778 "aria-disabled": !hasUndo,
8779 onClick: hasUndo ? undo : undefined,
8780 className: "editor-history__undo"
8781 });
8782 }
8783
8784 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8785
8786 /**
8787 * Renders the undo button for the editor history.
8788 *
8789 * @param {Object} props - Props.
8790 * @param {Ref} ref - Forwarded ref.
8791 *
8792 * @return {Component} The component to be rendered.
8793 */
8794 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
8795
8796 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-validation-notice/index.js
8797 /**
8798 * WordPress dependencies
8799 */
8800
8801
8802
8803
8804
8805
8806
8807
8808 function TemplateValidationNotice() {
8809 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
8810 const isValid = (0,external_wp_data_namespaceObject.useSelect)(select => {
8811 return select(external_wp_blockEditor_namespaceObject.store).isValidTemplate();
8812 }, []);
8813 const {
8814 setTemplateValidity,
8815 synchronizeTemplate
8816 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8817 if (isValid) {
8818 return null;
8819 }
8820 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8821 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
8822 className: "editor-template-validation-notice",
8823 isDismissible: false,
8824 status: "warning",
8825 actions: [{
8826 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
8827 onClick: () => setTemplateValidity(true)
8828 }, {
8829 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
8830 onClick: () => setShowConfirmDialog(true)
8831 }],
8832 children: (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')
8833 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
8834 isOpen: showConfirmDialog,
8835 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Reset'),
8836 onConfirm: () => {
8837 setShowConfirmDialog(false);
8838 synchronizeTemplate();
8839 },
8840 onCancel: () => setShowConfirmDialog(false),
8841 size: "medium",
8842 children: (0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?')
8843 })]
8844 });
8845 }
8846
8847 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-notices/index.js
8848 /**
8849 * WordPress dependencies
8850 */
8851
8852
8853
8854
8855 /**
8856 * Internal dependencies
8857 */
8858
8859
8860 /**
8861 * This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
8862 *
8863 * @example
8864 * ```jsx
8865 * <EditorNotices />
8866 * ```
8867 *
8868 * @return {JSX.Element} The rendered EditorNotices component.
8869 */
8870
8871
8872
8873 function EditorNotices() {
8874 const {
8875 notices
8876 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8877 notices: select(external_wp_notices_namespaceObject.store).getNotices()
8878 }), []);
8879 const {
8880 removeNotice
8881 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8882 const dismissibleNotices = notices.filter(({
8883 isDismissible,
8884 type
8885 }) => isDismissible && type === 'default');
8886 const nonDismissibleNotices = notices.filter(({
8887 isDismissible,
8888 type
8889 }) => !isDismissible && type === 'default');
8890 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8891 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8892 notices: nonDismissibleNotices,
8893 className: "components-editor-notices__pinned"
8894 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8895 notices: dismissibleNotices,
8896 className: "components-editor-notices__dismissible",
8897 onRemove: removeNotice,
8898 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateValidationNotice, {})
8899 })]
8900 });
8901 }
8902 /* harmony default export */ const editor_notices = (EditorNotices);
8903
8904 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-snackbars/index.js
8905 /**
8906 * WordPress dependencies
8907 */
8908
8909
8910
8911
8912 // Last three notices. Slices from the tail end of the list.
8913
8914 const MAX_VISIBLE_NOTICES = -3;
8915
8916 /**
8917 * Renders the editor snackbars component.
8918 *
8919 * @return {JSX.Element} The rendered component.
8920 */
8921 function EditorSnackbars() {
8922 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
8923 const {
8924 removeNotice
8925 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8926 const snackbarNotices = notices.filter(({
8927 type
8928 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES);
8929 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SnackbarList, {
8930 notices: snackbarNotices,
8931 className: "components-editor-notices__snackbar",
8932 onRemove: removeNotice
8933 });
8934 }
8935
8936 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/connection.js
8937 /**
8938 * WordPress dependencies
8939 */
8940
8941
8942 const connection = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8943 viewBox: "0 0 24 24",
8944 xmlns: "http://www.w3.org/2000/svg",
8945 fillRule: "evenodd",
8946 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8947 d: "M19.53 4.47a.75.75 0 0 1 0 1.06L17.06 8l.77.769a3.155 3.155 0 0 1 .685 3.439 3.15 3.15 0 0 1-.685 1.022v.001L13.23 17.83v.001a3.15 3.15 0 0 1-4.462 0L8 17.06l-2.47 2.47a.75.75 0 0 1-1.06-1.06L6.94 16l-.77-.769a3.154 3.154 0 0 1-.685-3.439 3.15 3.15 0 0 1 .685-1.023l4.599-4.598a3.152 3.152 0 0 1 4.462 0l.769.768 2.47-2.47a.75.75 0 0 1 1.06 0Zm-2.76 7.7L15 13.94 10.06 9l1.771-1.77a1.65 1.65 0 0 1 2.338 0L16.77 9.83a1.649 1.649 0 0 1 0 2.338h-.001ZM13.94 15 9 10.06l-1.77 1.771a1.65 1.65 0 0 0 0 2.338l2.601 2.602a1.649 1.649 0 0 0 2.338 0v-.001L13.94 15Z"
8948 })
8949 });
8950 /* harmony default export */ const library_connection = (connection);
8951
8952 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
8953 /**
8954 * WordPress dependencies
8955 */
8956
8957
8958
8959
8960
8961
8962
8963 /**
8964 * Internal dependencies
8965 */
8966
8967
8968
8969
8970
8971 function EntityRecordItem({
8972 record,
8973 checked,
8974 onChange
8975 }) {
8976 const {
8977 name,
8978 kind,
8979 title,
8980 key
8981 } = record;
8982
8983 // Handle templates that might use default descriptive titles.
8984 const {
8985 entityRecordTitle,
8986 hasPostMetaChanges
8987 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8988 if ('postType' !== kind || 'wp_template' !== name) {
8989 return {
8990 entityRecordTitle: title,
8991 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8992 };
8993 }
8994 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
8995 return {
8996 entityRecordTitle: select(store_store).__experimentalGetTemplateInfo(template).title,
8997 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8998 };
8999 }, [name, kind, title, key]);
9000 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9001 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
9002 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
9003 __nextHasNoMarginBottom: true,
9004 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'),
9005 checked: checked,
9006 onChange: onChange
9007 })
9008 }), hasPostMetaChanges && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
9009 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
9010 className: "entities-saved-states__post-meta",
9011 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
9012 className: "entities-saved-states__connections-icon",
9013 icon: library_connection,
9014 size: 24
9015 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9016 className: "entities-saved-states__bindings-text",
9017 children: (0,external_wp_i18n_namespaceObject.__)('Post Meta.')
9018 })]
9019 })
9020 })]
9021 });
9022 }
9023
9024 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
9025 /**
9026 * WordPress dependencies
9027 */
9028
9029
9030
9031
9032
9033
9034
9035 /**
9036 * Internal dependencies
9037 */
9038
9039
9040
9041
9042 const {
9043 getGlobalStylesChanges,
9044 GlobalStylesContext
9045 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
9046 function getEntityDescription(entity, count) {
9047 switch (entity) {
9048 case 'site':
9049 return 1 === count ? (0,external_wp_i18n_namespaceObject.__)('This change will affect your whole site.') : (0,external_wp_i18n_namespaceObject.__)('These changes will affect your whole site.');
9050 case 'wp_template':
9051 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
9052 case 'page':
9053 case 'post':
9054 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.');
9055 }
9056 }
9057 function GlobalStylesDescription({
9058 record
9059 }) {
9060 const {
9061 user: currentEditorGlobalStyles
9062 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
9063 const savedRecord = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecord(record.kind, record.name, record.key), [record.kind, record.name, record.key]);
9064 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, {
9065 maxResults: 10
9066 });
9067 return globalStylesChanges.length ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
9068 className: "entities-saved-states__changes",
9069 children: globalStylesChanges.map(change => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
9070 children: change
9071 }, change))
9072 }) : null;
9073 }
9074 function EntityDescription({
9075 record,
9076 count
9077 }) {
9078 if ('globalStyles' === record?.name) {
9079 return null;
9080 }
9081 const description = getEntityDescription(record?.name, count);
9082 return description ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
9083 children: description
9084 }) : null;
9085 }
9086 function EntityTypeList({
9087 list,
9088 unselectedEntities,
9089 setUnselectedEntities
9090 }) {
9091 const count = list.length;
9092 const firstRecord = list[0];
9093 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
9094 let entityLabel = entityConfig.label;
9095 if (firstRecord?.name === 'wp_template_part') {
9096 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
9097 }
9098 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
9099 title: entityLabel,
9100 initialOpen: true,
9101 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
9102 record: firstRecord,
9103 count: count
9104 }), list.map(record => {
9105 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
9106 record: record,
9107 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
9108 onChange: value => setUnselectedEntities(record, value)
9109 }, record.key || record.property);
9110 }), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
9111 record: firstRecord
9112 })]
9113 });
9114 }
9115
9116 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
9117 /**
9118 * WordPress dependencies
9119 */
9120
9121
9122
9123
9124 /**
9125 * Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
9126 *
9127 * @return {Object} An object containing the following properties:
9128 * - dirtyEntityRecords: An array of dirty entity records.
9129 * - isDirty: A boolean indicating if there are any dirty entity records.
9130 * - setUnselectedEntities: A function to set the unselected entities.
9131 * - unselectedEntities: An array of unselected entities.
9132 */
9133 const useIsDirty = () => {
9134 const {
9135 editedEntities,
9136 siteEdits,
9137 siteEntityConfig
9138 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9139 const {
9140 __experimentalGetDirtyEntityRecords,
9141 getEntityRecordEdits,
9142 getEntityConfig
9143 } = select(external_wp_coreData_namespaceObject.store);
9144 return {
9145 editedEntities: __experimentalGetDirtyEntityRecords(),
9146 siteEdits: getEntityRecordEdits('root', 'site'),
9147 siteEntityConfig: getEntityConfig('root', 'site')
9148 };
9149 }, []);
9150 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
9151 var _siteEntityConfig$met;
9152 // Remove site object and decouple into its edited pieces.
9153 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
9154 const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
9155 const editedSiteEntities = [];
9156 for (const property in siteEdits) {
9157 editedSiteEntities.push({
9158 kind: 'root',
9159 name: 'site',
9160 title: siteEntityLabels[property] || property,
9161 property
9162 });
9163 }
9164 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
9165 }, [editedEntities, siteEdits, siteEntityConfig]);
9166
9167 // Unchecked entities to be ignored by save function.
9168 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
9169 const setUnselectedEntities = ({
9170 kind,
9171 name,
9172 key,
9173 property
9174 }, checked) => {
9175 if (checked) {
9176 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
9177 } else {
9178 _setUnselectedEntities([...unselectedEntities, {
9179 kind,
9180 name,
9181 key,
9182 property
9183 }]);
9184 }
9185 };
9186 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
9187 return {
9188 dirtyEntityRecords,
9189 isDirty,
9190 setUnselectedEntities,
9191 unselectedEntities
9192 };
9193 };
9194
9195 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/index.js
9196 /**
9197 * WordPress dependencies
9198 */
9199
9200
9201
9202
9203
9204
9205 /**
9206 * Internal dependencies
9207 */
9208
9209
9210
9211
9212
9213
9214 function identity(values) {
9215 return values;
9216 }
9217
9218 /**
9219 * Renders the component for managing saved states of entities.
9220 *
9221 * @param {Object} props The component props.
9222 * @param {Function} props.close The function to close the dialog.
9223 * @param {Function} props.renderDialog The function to render the dialog.
9224 *
9225 * @return {JSX.Element} The rendered component.
9226 */
9227 function EntitiesSavedStates({
9228 close,
9229 renderDialog = undefined
9230 }) {
9231 const isDirtyProps = useIsDirty();
9232 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
9233 close: close,
9234 renderDialog: renderDialog,
9235 ...isDirtyProps
9236 });
9237 }
9238
9239 /**
9240 * Renders a panel for saving entities with dirty records.
9241 *
9242 * @param {Object} props The component props.
9243 * @param {string} props.additionalPrompt Additional prompt to display.
9244 * @param {Function} props.close Function to close the panel.
9245 * @param {Function} props.onSave Function to call when saving entities.
9246 * @param {boolean} props.saveEnabled Flag indicating if save is enabled.
9247 * @param {string} props.saveLabel Label for the save button.
9248 * @param {Function} props.renderDialog Function to render a custom dialog.
9249 * @param {Array} props.dirtyEntityRecords Array of dirty entity records.
9250 * @param {boolean} props.isDirty Flag indicating if there are dirty entities.
9251 * @param {Function} props.setUnselectedEntities Function to set unselected entities.
9252 * @param {Array} props.unselectedEntities Array of unselected entities.
9253 *
9254 * @return {JSX.Element} The rendered component.
9255 */
9256 function EntitiesSavedStatesExtensible({
9257 additionalPrompt = undefined,
9258 close,
9259 onSave = identity,
9260 saveEnabled: saveEnabledProp = undefined,
9261 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
9262 renderDialog = undefined,
9263 dirtyEntityRecords,
9264 isDirty,
9265 setUnselectedEntities,
9266 unselectedEntities
9267 }) {
9268 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
9269 const {
9270 saveDirtyEntities
9271 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
9272 // To group entities by type.
9273 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
9274 const {
9275 name
9276 } = record;
9277 if (!acc[name]) {
9278 acc[name] = [];
9279 }
9280 acc[name].push(record);
9281 return acc;
9282 }, {});
9283
9284 // Sort entity groups.
9285 const {
9286 site: siteSavables,
9287 wp_template: templateSavables,
9288 wp_template_part: templatePartSavables,
9289 ...contentSavables
9290 } = partitionedSavables;
9291 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
9292 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
9293 // Explicitly define this with no argument passed. Using `close` on
9294 // its own will use the event object in place of the expected saved entities.
9295 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
9296 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
9297 onClose: () => dismissPanel()
9298 });
9299 const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
9300 const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
9301 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9302 ref: saveDialogRef,
9303 ...saveDialogProps,
9304 className: "entities-saved-states__panel",
9305 role: renderDialog ? 'dialog' : undefined,
9306 "aria-labelledby": renderDialog ? dialogLabel : undefined,
9307 "aria-describedby": renderDialog ? dialogDescription : undefined,
9308 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
9309 className: "entities-saved-states__panel-header",
9310 gap: 2,
9311 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
9312 isBlock: true,
9313 as: external_wp_components_namespaceObject.Button,
9314 ref: saveButtonRef,
9315 variant: "primary",
9316 disabled: !saveEnabled,
9317 __experimentalIsFocusable: true,
9318 onClick: () => saveDirtyEntities({
9319 onSave,
9320 dirtyEntityRecords,
9321 entitiesToSkip: unselectedEntities,
9322 close
9323 }),
9324 className: "editor-entities-saved-states__save-button",
9325 children: saveLabel
9326 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
9327 isBlock: true,
9328 as: external_wp_components_namespaceObject.Button,
9329 variant: "secondary",
9330 onClick: dismissPanel,
9331 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
9332 })]
9333 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9334 className: "entities-saved-states__text-prompt",
9335 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9336 className: "entities-saved-states__text-prompt--header-wrapper",
9337 id: renderDialog ? dialogLabel : undefined,
9338 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
9339 className: "entities-saved-states__text-prompt--header",
9340 children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
9341 }), additionalPrompt]
9342 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
9343 id: renderDialog ? dialogDescription : undefined,
9344 children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of site changes waiting to be saved. */
9345 (0,external_wp_i18n_namespaceObject._n)('There is <strong>%d site change</strong> waiting to be saved.', 'There are <strong>%d site changes</strong> waiting to be saved.', sortedPartitionedSavables.length), sortedPartitionedSavables.length), {
9346 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
9347 }) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.')
9348 })]
9349 }), sortedPartitionedSavables.map(list => {
9350 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
9351 list: list,
9352 unselectedEntities: unselectedEntities,
9353 setUnselectedEntities: setUnselectedEntities
9354 }, list[0].name);
9355 })]
9356 });
9357 }
9358
9359 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/error-boundary/index.js
9360 /**
9361 * WordPress dependencies
9362 */
9363
9364
9365
9366
9367
9368
9369
9370
9371 /**
9372 * Internal dependencies
9373 */
9374
9375
9376 function getContent() {
9377 try {
9378 // While `select` in a component is generally discouraged, it is
9379 // used here because it (a) reduces the chance of data loss in the
9380 // case of additional errors by performing a direct retrieval and
9381 // (b) avoids the performance cost associated with unnecessary
9382 // content serialization throughout the lifetime of a non-erroring
9383 // application.
9384 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
9385 } catch (error) {}
9386 }
9387 function CopyButton({
9388 text,
9389 children
9390 }) {
9391 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
9392 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9393 variant: "secondary",
9394 ref: ref,
9395 children: children
9396 });
9397 }
9398 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
9399 constructor() {
9400 super(...arguments);
9401 this.state = {
9402 error: null
9403 };
9404 }
9405 componentDidCatch(error) {
9406 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
9407 }
9408 static getDerivedStateFromError(error) {
9409 return {
9410 error
9411 };
9412 }
9413 render() {
9414 const {
9415 error
9416 } = this.state;
9417 if (!error) {
9418 return this.props.children;
9419 }
9420 const actions = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9421 text: getContent,
9422 children: (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')
9423 }, "copy-post"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9424 text: error.stack,
9425 children: (0,external_wp_i18n_namespaceObject.__)('Copy Error')
9426 }, "copy-error")];
9427 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, {
9428 className: "editor-error-boundary",
9429 actions: actions,
9430 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
9431 });
9432 }
9433 }
9434
9435 /**
9436 * ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
9437 *
9438 * It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
9439 *
9440 * getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
9441 *
9442 * @class ErrorBoundary
9443 * @augments Component
9444 */
9445 /* harmony default export */ const error_boundary = (ErrorBoundary);
9446
9447 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/local-autosave-monitor/index.js
9448 /**
9449 * WordPress dependencies
9450 */
9451
9452
9453
9454
9455
9456
9457
9458 /**
9459 * Internal dependencies
9460 */
9461
9462
9463
9464
9465 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
9466 let hasStorageSupport;
9467
9468 /**
9469 * Function which returns true if the current environment supports browser
9470 * sessionStorage, or false otherwise. The result of this function is cached and
9471 * reused in subsequent invocations.
9472 */
9473 const hasSessionStorageSupport = () => {
9474 if (hasStorageSupport !== undefined) {
9475 return hasStorageSupport;
9476 }
9477 try {
9478 // Private Browsing in Safari 10 and earlier will throw an error when
9479 // attempting to set into sessionStorage. The test here is intentional in
9480 // causing a thrown error as condition bailing from local autosave.
9481 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
9482 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
9483 hasStorageSupport = true;
9484 } catch {
9485 hasStorageSupport = false;
9486 }
9487 return hasStorageSupport;
9488 };
9489
9490 /**
9491 * Custom hook which manages the creation of a notice prompting the user to
9492 * restore a local autosave, if one exists.
9493 */
9494 function useAutosaveNotice() {
9495 const {
9496 postId,
9497 isEditedPostNew,
9498 hasRemoteAutosave
9499 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9500 postId: select(store_store).getCurrentPostId(),
9501 isEditedPostNew: select(store_store).isEditedPostNew(),
9502 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
9503 }), []);
9504 const {
9505 getEditedPostAttribute
9506 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
9507 const {
9508 createWarningNotice,
9509 removeNotice
9510 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
9511 const {
9512 editPost,
9513 resetEditorBlocks
9514 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9515 (0,external_wp_element_namespaceObject.useEffect)(() => {
9516 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
9517 if (!localAutosave) {
9518 return;
9519 }
9520 try {
9521 localAutosave = JSON.parse(localAutosave);
9522 } catch {
9523 // Not usable if it can't be parsed.
9524 return;
9525 }
9526 const {
9527 post_title: title,
9528 content,
9529 excerpt
9530 } = localAutosave;
9531 const edits = {
9532 title,
9533 content,
9534 excerpt
9535 };
9536 {
9537 // Only display a notice if there is a difference between what has been
9538 // saved and that which is stored in sessionStorage.
9539 const hasDifference = Object.keys(edits).some(key => {
9540 return edits[key] !== getEditedPostAttribute(key);
9541 });
9542 if (!hasDifference) {
9543 // If there is no difference, it can be safely ejected from storage.
9544 localAutosaveClear(postId, isEditedPostNew);
9545 return;
9546 }
9547 }
9548 if (hasRemoteAutosave) {
9549 return;
9550 }
9551 const id = 'wpEditorAutosaveRestore';
9552 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
9553 id,
9554 actions: [{
9555 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
9556 onClick() {
9557 const {
9558 content: editsContent,
9559 ...editsWithoutContent
9560 } = edits;
9561 editPost(editsWithoutContent);
9562 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
9563 removeNotice(id);
9564 }
9565 }]
9566 });
9567 }, [isEditedPostNew, postId]);
9568 }
9569
9570 /**
9571 * Custom hook which ejects a local autosave after a successful save occurs.
9572 */
9573 function useAutosavePurge() {
9574 const {
9575 postId,
9576 isEditedPostNew,
9577 isDirty,
9578 isAutosaving,
9579 didError
9580 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9581 postId: select(store_store).getCurrentPostId(),
9582 isEditedPostNew: select(store_store).isEditedPostNew(),
9583 isDirty: select(store_store).isEditedPostDirty(),
9584 isAutosaving: select(store_store).isAutosavingPost(),
9585 didError: select(store_store).didPostSaveRequestFail()
9586 }), []);
9587 const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
9588 const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
9589 (0,external_wp_element_namespaceObject.useEffect)(() => {
9590 if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
9591 localAutosaveClear(postId, isEditedPostNew);
9592 }
9593 lastIsDirty.current = isDirty;
9594 lastIsAutosaving.current = isAutosaving;
9595 }, [isDirty, isAutosaving, didError]);
9596
9597 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
9598 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
9599 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
9600 (0,external_wp_element_namespaceObject.useEffect)(() => {
9601 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
9602 localAutosaveClear(postId, true);
9603 }
9604 }, [isEditedPostNew, postId]);
9605 }
9606 function LocalAutosaveMonitor() {
9607 const {
9608 autosave
9609 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9610 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
9611 requestIdleCallback(() => autosave({
9612 local: true
9613 }));
9614 }, []);
9615 useAutosaveNotice();
9616 useAutosavePurge();
9617 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
9618 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
9619 interval: localAutosaveInterval,
9620 autosave: deferredAutosave
9621 });
9622 }
9623
9624 /**
9625 * Monitors local autosaves of a post in the editor.
9626 * It uses several hooks and functions to manage autosave behavior:
9627 * - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
9628 * - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
9629 * - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
9630 * - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
9631 *
9632 * The module also checks for sessionStorage support and conditionally exports the `LocalAutosaveMonitor` component based on that.
9633 *
9634 * @module LocalAutosaveMonitor
9635 */
9636 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
9637
9638 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/check.js
9639 /**
9640 * WordPress dependencies
9641 */
9642
9643
9644
9645 /**
9646 * Internal dependencies
9647 */
9648
9649
9650 /**
9651 * Wrapper component that renders its children only if the post type supports page attributes.
9652 *
9653 * @param {Object} props - The component props.
9654 * @param {Element} props.children - The child components to render.
9655 *
9656 * @return {Component|null} The rendered child components or null if page attributes are not supported.
9657 */
9658 function PageAttributesCheck({
9659 children
9660 }) {
9661 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
9662 const {
9663 getEditedPostAttribute
9664 } = select(store_store);
9665 const {
9666 getPostType
9667 } = select(external_wp_coreData_namespaceObject.store);
9668 const postType = getPostType(getEditedPostAttribute('type'));
9669 return !!postType?.supports?.['page-attributes'];
9670 }, []);
9671
9672 // Only render fields if post type supports page attributes or available templates exist.
9673 if (!supportsPageAttributes) {
9674 return null;
9675 }
9676 return children;
9677 }
9678 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
9679
9680 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-row/index.js
9681 /**
9682 * External dependencies
9683 */
9684
9685
9686 /**
9687 * WordPress dependencies
9688 */
9689
9690
9691
9692
9693 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({
9694 className,
9695 label,
9696 children
9697 }, ref) => {
9698 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9699 className: dist_clsx('editor-post-panel__row', className),
9700 ref: ref,
9701 children: [label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9702 className: "editor-post-panel__row-label",
9703 children: label
9704 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9705 className: "editor-post-panel__row-control",
9706 children: children
9707 })]
9708 });
9709 });
9710 /* harmony default export */ const post_panel_row = (PostPanelRow);
9711
9712 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-type-support-check/index.js
9713 /**
9714 * WordPress dependencies
9715 */
9716
9717
9718
9719 /**
9720 * Internal dependencies
9721 */
9722
9723
9724 /**
9725 * A component which renders its own children only if the current editor post
9726 * type supports one of the given `supportKeys` prop.
9727 *
9728 * @param {Object} props Props.
9729 * @param {Element} props.children Children to be rendered if post
9730 * type supports.
9731 * @param {(string|string[])} props.supportKeys String or string array of keys
9732 * to test.
9733 *
9734 * @return {Component} The component to be rendered.
9735 */
9736 function PostTypeSupportCheck({
9737 children,
9738 supportKeys
9739 }) {
9740 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
9741 const {
9742 getEditedPostAttribute
9743 } = select(store_store);
9744 const {
9745 getPostType
9746 } = select(external_wp_coreData_namespaceObject.store);
9747 return getPostType(getEditedPostAttribute('type'));
9748 }, []);
9749 let isSupported = !!postType;
9750 if (postType) {
9751 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
9752 }
9753 if (!isSupported) {
9754 return null;
9755 }
9756 return children;
9757 }
9758 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck);
9759
9760 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/order.js
9761 /**
9762 * WordPress dependencies
9763 */
9764
9765
9766
9767
9768
9769
9770 /**
9771 * Internal dependencies
9772 */
9773
9774
9775
9776
9777
9778 function PageAttributesOrder() {
9779 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
9780 var _select$getEditedPost;
9781 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0;
9782 }, []);
9783 const {
9784 editPost
9785 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9786 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
9787 const setUpdatedOrder = value => {
9788 setOrderInput(value);
9789 const newOrder = Number(value);
9790 if (Number.isInteger(newOrder) && value.trim?.() !== '') {
9791 editPost({
9792 menu_order: newOrder
9793 });
9794 }
9795 };
9796 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order;
9797 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
9798 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, {
9799 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
9800 __next40pxDefaultSize: true,
9801 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
9802 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
9803 value: value,
9804 onChange: setUpdatedOrder,
9805 hideLabelFromVision: true,
9806 onBlur: () => {
9807 setOrderInput(null);
9808 }
9809 })
9810 })
9811 });
9812 }
9813
9814 /**
9815 * Renders the Page Attributes Order component. A number input in an editor interface
9816 * for setting the order of a given page.
9817 *
9818 * @return {Component} The component to be rendered.
9819 */
9820 function PageAttributesOrderWithChecks() {
9821 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
9822 supportKeys: "page-attributes",
9823 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})
9824 });
9825 }
9826 function PostOrderToggle({
9827 isOpen,
9828 onClick
9829 }) {
9830 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
9831 var _select$getEditedPost2;
9832 return (_select$getEditedPost2 = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost2 !== void 0 ? _select$getEditedPost2 : 0;
9833 }, []);
9834 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9835 size: "compact",
9836 className: "editor-post-order__panel-toggle",
9837 variant: "tertiary",
9838 "aria-expanded": isOpen
9839 // translators: %s: Current post parent.
9840 ,
9841 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change order: %s'), order),
9842 onClick: onClick,
9843 children: order
9844 });
9845 }
9846 function OrderRow() {
9847 // Use internal state instead of a ref to make sure that the component
9848 // re-renders when the popover's anchor updates.
9849 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
9850 // Memoize popoverProps to avoid returning a new object every time.
9851 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
9852 // Anchor the popover to the middle of the entire row so that it doesn't
9853 // move around when the label changes.
9854 anchor: popoverAnchor,
9855 placement: 'left-start',
9856 offset: 36,
9857 shift: true
9858 }), [popoverAnchor]);
9859 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
9860 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
9861 ref: setPopoverAnchor,
9862 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
9863 popoverProps: popoverProps,
9864 className: "editor-post-order__panel-dropdown",
9865 contentClassName: "editor-post-order__panel-dialog",
9866 focusOnMount: true,
9867 renderToggle: ({
9868 isOpen,
9869 onToggle
9870 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostOrderToggle, {
9871 isOpen: isOpen,
9872 onClick: onToggle
9873 }),
9874 renderContent: ({
9875 onClose
9876 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9877 className: "editor-post-order",
9878 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
9879 title: (0,external_wp_i18n_namespaceObject.__)('Order'),
9880 onClose: onClose
9881 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9882 children: [(0,external_wp_i18n_namespaceObject.__)('This attribute determines the order of pages in the Pages List block.'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
9883 children: (0,external_wp_i18n_namespaceObject.__)('Pages with the same order value will sorted alphabetically. Negative order values are also supported.')
9884 })]
9885 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})]
9886 })
9887 })
9888 });
9889 }
9890
9891 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
9892 var remove_accents = __webpack_require__(4793);
9893 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
9894 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/terms.js
9895 /**
9896 * WordPress dependencies
9897 */
9898
9899
9900 /**
9901 * Returns terms in a tree form.
9902 *
9903 * @param {Array} flatTerms Array of terms in flat format.
9904 *
9905 * @return {Array} Array of terms in tree format.
9906 */
9907 function buildTermsTree(flatTerms) {
9908 const flatTermsWithParentAndChildren = flatTerms.map(term => {
9909 return {
9910 children: [],
9911 parent: null,
9912 ...term
9913 };
9914 });
9915
9916 // All terms should have a `parent` because we're about to index them by it.
9917 if (flatTermsWithParentAndChildren.some(({
9918 parent
9919 }) => parent === null)) {
9920 return flatTermsWithParentAndChildren;
9921 }
9922 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
9923 const {
9924 parent
9925 } = term;
9926 if (!acc[parent]) {
9927 acc[parent] = [];
9928 }
9929 acc[parent].push(term);
9930 return acc;
9931 }, {});
9932 const fillWithChildren = terms => {
9933 return terms.map(term => {
9934 const children = termsByParent[term.id];
9935 return {
9936 ...term,
9937 children: children && children.length ? fillWithChildren(children) : []
9938 };
9939 });
9940 };
9941 return fillWithChildren(termsByParent['0'] || []);
9942 }
9943 const unescapeString = arg => {
9944 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
9945 };
9946
9947 /**
9948 * Returns a term object with name unescaped.
9949 *
9950 * @param {Object} term The term object to unescape.
9951 *
9952 * @return {Object} Term object with name property unescaped.
9953 */
9954 const unescapeTerm = term => {
9955 return {
9956 ...term,
9957 name: unescapeString(term.name)
9958 };
9959 };
9960
9961 /**
9962 * Returns an array of term objects with names unescaped.
9963 * The unescape of each term is performed using the unescapeTerm function.
9964 *
9965 * @param {Object[]} terms Array of term objects to unescape.
9966 *
9967 * @return {Object[]} Array of term objects unescaped.
9968 */
9969 const unescapeTerms = terms => {
9970 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm);
9971 };
9972
9973 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/parent.js
9974 /**
9975 * External dependencies
9976 */
9977
9978
9979 /**
9980 * WordPress dependencies
9981 */
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991 /**
9992 * Internal dependencies
9993 */
9994
9995
9996
9997
9998
9999 function getTitle(post) {
10000 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
10001 }
10002 const getItemPriority = (name, searchValue) => {
10003 const normalizedName = remove_accents_default()(name || '').toLowerCase();
10004 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
10005 if (normalizedName === normalizedSearch) {
10006 return 0;
10007 }
10008 if (normalizedName.startsWith(normalizedSearch)) {
10009 return normalizedName.length;
10010 }
10011 return Infinity;
10012 };
10013
10014 /**
10015 * Renders the Page Attributes Parent component. A dropdown menu in an editor interface
10016 * for selecting the parent page of a given page.
10017 *
10018 * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical.
10019 */
10020 function PageAttributesParent() {
10021 const {
10022 editPost
10023 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10024 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
10025 const {
10026 isHierarchical,
10027 parentPostId,
10028 parentPostTitle,
10029 pageItems
10030 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10031 var _pType$hierarchical;
10032 const {
10033 getPostType,
10034 getEntityRecords,
10035 getEntityRecord
10036 } = select(external_wp_coreData_namespaceObject.store);
10037 const {
10038 getCurrentPostId,
10039 getEditedPostAttribute
10040 } = select(store_store);
10041 const postTypeSlug = getEditedPostAttribute('type');
10042 const pageId = getEditedPostAttribute('parent');
10043 const pType = getPostType(postTypeSlug);
10044 const postId = getCurrentPostId();
10045 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
10046 const query = {
10047 per_page: 100,
10048 exclude: postId,
10049 parent_exclude: postId,
10050 orderby: 'menu_order',
10051 order: 'asc',
10052 _fields: 'id,title,parent'
10053 };
10054
10055 // Perform a search when the field is changed.
10056 if (!!fieldValue) {
10057 query.search = fieldValue;
10058 }
10059 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
10060 return {
10061 isHierarchical: postIsHierarchical,
10062 parentPostId: pageId,
10063 parentPostTitle: parentPost ? getTitle(parentPost) : '',
10064 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
10065 };
10066 }, [fieldValue]);
10067 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
10068 const getOptionsFromTree = (tree, level = 0) => {
10069 const mappedNodes = tree.map(treeNode => [{
10070 value: treeNode.id,
10071 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
10072 rawName: treeNode.name
10073 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
10074 const sortedNodes = mappedNodes.sort(([a], [b]) => {
10075 const priorityA = getItemPriority(a.rawName, fieldValue);
10076 const priorityB = getItemPriority(b.rawName, fieldValue);
10077 return priorityA >= priorityB ? 1 : -1;
10078 });
10079 return sortedNodes.flat();
10080 };
10081 if (!pageItems) {
10082 return [];
10083 }
10084 let tree = pageItems.map(item => ({
10085 id: item.id,
10086 parent: item.parent,
10087 name: getTitle(item)
10088 }));
10089
10090 // Only build a hierarchical tree when not searching.
10091 if (!fieldValue) {
10092 tree = buildTermsTree(tree);
10093 }
10094 const opts = getOptionsFromTree(tree);
10095
10096 // Ensure the current parent is in the options list.
10097 const optsHasParent = opts.find(item => item.value === parentPostId);
10098 if (parentPostTitle && !optsHasParent) {
10099 opts.unshift({
10100 value: parentPostId,
10101 label: parentPostTitle
10102 });
10103 }
10104 return opts;
10105 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
10106 if (!isHierarchical) {
10107 return null;
10108 }
10109 /**
10110 * Handle user input.
10111 *
10112 * @param {string} inputValue The current value of the input field.
10113 */
10114 const handleKeydown = inputValue => {
10115 setFieldValue(inputValue);
10116 };
10117
10118 /**
10119 * Handle author selection.
10120 *
10121 * @param {Object} selectedPostId The selected Author.
10122 */
10123 const handleChange = selectedPostId => {
10124 editPost({
10125 parent: selectedPostId
10126 });
10127 };
10128 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
10129 __nextHasNoMarginBottom: true,
10130 __next40pxDefaultSize: true,
10131 className: "editor-page-attributes__parent",
10132 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10133 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
10134 value: parentPostId,
10135 options: parentOptions,
10136 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
10137 onChange: handleChange,
10138 hideLabelFromVision: true
10139 });
10140 }
10141 function PostParentToggle({
10142 isOpen,
10143 onClick
10144 }) {
10145 const parentPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
10146 const {
10147 getEditedPostAttribute
10148 } = select(store_store);
10149 const parentPostId = getEditedPostAttribute('parent');
10150 if (!parentPostId) {
10151 return null;
10152 }
10153 const {
10154 getEntityRecord
10155 } = select(external_wp_coreData_namespaceObject.store);
10156 const postTypeSlug = getEditedPostAttribute('type');
10157 return getEntityRecord('postType', postTypeSlug, parentPostId);
10158 }, []);
10159 const parentTitle = (0,external_wp_element_namespaceObject.useMemo)(() => !parentPost ? (0,external_wp_i18n_namespaceObject.__)('None') : getTitle(parentPost), [parentPost]);
10160 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10161 size: "compact",
10162 className: "editor-post-parent__panel-toggle",
10163 variant: "tertiary",
10164 "aria-expanded": isOpen
10165 // translators: %s: Current post parent.
10166 ,
10167 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change parent: %s'), parentTitle),
10168 onClick: onClick,
10169 children: parentTitle
10170 });
10171 }
10172 function ParentRow() {
10173 // Use internal state instead of a ref to make sure that the component
10174 // re-renders when the popover's anchor updates.
10175 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
10176 // Memoize popoverProps to avoid returning a new object every time.
10177 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
10178 // Anchor the popover to the middle of the entire row so that it doesn't
10179 // move around when the label changes.
10180 anchor: popoverAnchor,
10181 placement: 'left-start',
10182 offset: 36,
10183 shift: true
10184 }), [popoverAnchor]);
10185 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
10186 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10187 ref: setPopoverAnchor,
10188 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10189 popoverProps: popoverProps,
10190 className: "editor-post-parent__panel-dropdown",
10191 contentClassName: "editor-post-parent__panel-dialog",
10192 focusOnMount: true,
10193 renderToggle: ({
10194 isOpen,
10195 onToggle
10196 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostParentToggle, {
10197 isOpen: isOpen,
10198 onClick: onToggle
10199 }),
10200 renderContent: ({
10201 onClose
10202 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10203 className: "editor-post-parent",
10204 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
10205 title: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10206 onClose: onClose
10207 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10208 children: [(0,external_wp_i18n_namespaceObject.__)("Child pages inherit characteristics from their parent, such as URL structure. For instance, if 'Web Design' is a child of 'Services,' its URL would be mysite.com/services/web-design."), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", {
10209 children: [(0,external_wp_i18n_namespaceObject.__)('They also show up as sub-items in the default navigation menu. '), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
10210 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'),
10211 children: (0,external_wp_i18n_namespaceObject.__)('Learn more')
10212 })]
10213 })]
10214 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesParent, {})]
10215 })
10216 })
10217 });
10218 }
10219 /* harmony default export */ const page_attributes_parent = (PageAttributesParent);
10220
10221 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/panel.js
10222 /**
10223 * WordPress dependencies
10224 */
10225
10226
10227 /**
10228 * Internal dependencies
10229 */
10230
10231
10232
10233
10234
10235
10236
10237 const PANEL_NAME = 'page-attributes';
10238 function AttributesPanel() {
10239 const {
10240 isEnabled,
10241 postType
10242 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10243 const {
10244 getEditedPostAttribute,
10245 isEditorPanelEnabled
10246 } = select(store_store);
10247 const {
10248 getPostType
10249 } = select(external_wp_coreData_namespaceObject.store);
10250 return {
10251 isEnabled: isEditorPanelEnabled(PANEL_NAME),
10252 postType: getPostType(getEditedPostAttribute('type'))
10253 };
10254 }, []);
10255 if (!isEnabled || !postType) {
10256 return null;
10257 }
10258 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10259 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ParentRow, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OrderRow, {})]
10260 });
10261 }
10262
10263 /**
10264 * Renders the Page Attributes Panel component.
10265 *
10266 * @return {Component} The component to be rendered.
10267 */
10268 function PageAttributesPanel() {
10269 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
10270 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AttributesPanel, {})
10271 });
10272 }
10273
10274 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/add-template.js
10275 /**
10276 * WordPress dependencies
10277 */
10278
10279
10280 const addTemplate = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10281 viewBox: "0 0 24 24",
10282 xmlns: "http://www.w3.org/2000/svg",
10283 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10284 fillRule: "evenodd",
10285 clipRule: "evenodd",
10286 d: "M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z"
10287 })
10288 });
10289 /* harmony default export */ const add_template = (addTemplate);
10290
10291 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template-modal.js
10292 /**
10293 * WordPress dependencies
10294 */
10295
10296
10297
10298
10299
10300
10301
10302 /**
10303 * Internal dependencies
10304 */
10305
10306
10307
10308
10309 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
10310 function CreateNewTemplateModal({
10311 onClose
10312 }) {
10313 const {
10314 defaultBlockTemplate,
10315 onNavigateToEntityRecord
10316 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10317 const {
10318 getEditorSettings,
10319 getCurrentTemplateId
10320 } = select(store_store);
10321 return {
10322 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
10323 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
10324 getTemplateId: getCurrentTemplateId
10325 };
10326 });
10327 const {
10328 createTemplate
10329 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
10330 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
10331 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
10332 const cancel = () => {
10333 setTitle('');
10334 onClose();
10335 };
10336 const submit = async event => {
10337 event.preventDefault();
10338 if (isBusy) {
10339 return;
10340 }
10341 setIsBusy(true);
10342 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10343 tagName: 'header',
10344 layout: {
10345 inherit: true
10346 }
10347 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/site-title'), (0,external_wp_blocks_namespaceObject.createBlock)('core/site-tagline')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/separator'), (0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10348 tagName: 'main'
10349 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10350 layout: {
10351 inherit: true
10352 }
10353 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
10354 layout: {
10355 inherit: true
10356 }
10357 })])]);
10358 const newTemplate = await createTemplate({
10359 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE),
10360 content: newTemplateContent,
10361 title: title || DEFAULT_TITLE
10362 });
10363 setIsBusy(false);
10364 onNavigateToEntityRecord({
10365 postId: newTemplate.id,
10366 postType: 'wp_template'
10367 });
10368 cancel();
10369 };
10370 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
10371 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
10372 onRequestClose: cancel,
10373 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
10374 className: "editor-post-template__create-form",
10375 onSubmit: submit,
10376 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
10377 spacing: "3",
10378 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
10379 __nextHasNoMarginBottom: true,
10380 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
10381 value: title,
10382 onChange: setTitle,
10383 placeholder: DEFAULT_TITLE,
10384 disabled: isBusy,
10385 help: (0,external_wp_i18n_namespaceObject.__)('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
10386 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
10387 justify: "right",
10388 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10389 variant: "tertiary",
10390 onClick: cancel,
10391 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
10392 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10393 variant: "primary",
10394 type: "submit",
10395 isBusy: isBusy,
10396 "aria-disabled": isBusy,
10397 children: (0,external_wp_i18n_namespaceObject.__)('Create')
10398 })]
10399 })]
10400 })
10401 })
10402 });
10403 }
10404
10405 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/hooks.js
10406 /**
10407 * WordPress dependencies
10408 */
10409
10410
10411
10412
10413 /**
10414 * Internal dependencies
10415 */
10416
10417 function useEditedPostContext() {
10418 return (0,external_wp_data_namespaceObject.useSelect)(select => {
10419 const {
10420 getCurrentPostId,
10421 getCurrentPostType
10422 } = select(store_store);
10423 return {
10424 postId: getCurrentPostId(),
10425 postType: getCurrentPostType()
10426 };
10427 }, []);
10428 }
10429 function useAllowSwitchingTemplates() {
10430 const {
10431 postType,
10432 postId
10433 } = useEditedPostContext();
10434 return (0,external_wp_data_namespaceObject.useSelect)(select => {
10435 const {
10436 getEntityRecord,
10437 getEntityRecords
10438 } = select(external_wp_coreData_namespaceObject.store);
10439 const siteSettings = getEntityRecord('root', 'site');
10440 const templates = getEntityRecords('postType', 'wp_template', {
10441 per_page: -1
10442 });
10443 const isPostsPage = +postId === siteSettings?.page_for_posts;
10444 // If current page is set front page or posts page, we also need
10445 // to check if the current theme has a template for it. If not
10446 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
10447 slug
10448 }) => slug === 'front-page');
10449 return !isPostsPage && !isFrontPage;
10450 }, [postId, postType]);
10451 }
10452 function useTemplates(postType) {
10453 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
10454 per_page: -1,
10455 post_type: postType
10456 }), [postType]);
10457 }
10458 function useAvailableTemplates(postType) {
10459 const currentTemplateSlug = useCurrentTemplateSlug();
10460 const allowSwitchingTemplate = useAllowSwitchingTemplates();
10461 const templates = useTemplates(postType);
10462 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
10463 ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
10464 }
10465 function useCurrentTemplateSlug() {
10466 const {
10467 postType,
10468 postId
10469 } = useEditedPostContext();
10470 const templates = useTemplates(postType);
10471 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
10472 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
10473 return post?.template;
10474 }, [postType, postId]);
10475 if (!entityTemplate) {
10476 return;
10477 }
10478 // If a page has a `template` set and is not included in the list
10479 // of the theme's templates, do not return it, in order to resolve
10480 // to the current theme's default template.
10481 return templates?.find(template => template.slug === entityTemplate)?.slug;
10482 }
10483
10484 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/classic-theme.js
10485 /**
10486 * WordPress dependencies
10487 */
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497 /**
10498 * Internal dependencies
10499 */
10500
10501
10502
10503
10504
10505 const POPOVER_PROPS = {
10506 className: 'editor-post-template__dropdown',
10507 placement: 'bottom-start'
10508 };
10509 function PostTemplateToggle({
10510 isOpen,
10511 onClick
10512 }) {
10513 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
10514 const templateSlug = select(store_store).getEditedPostAttribute('template');
10515 const {
10516 supportsTemplateMode,
10517 availableTemplates
10518 } = select(store_store).getEditorSettings();
10519 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
10520 return availableTemplates[templateSlug];
10521 }
10522 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates') && select(store_store).getCurrentTemplateId();
10523 return template?.title || template?.slug || availableTemplates?.[templateSlug];
10524 }, []);
10525 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10526 __next40pxDefaultSize: true,
10527 variant: "tertiary",
10528 "aria-expanded": isOpen,
10529 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'),
10530 onClick: onClick,
10531 children: templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')
10532 });
10533 }
10534
10535 /**
10536 * Renders the dropdown content for selecting a post template.
10537 *
10538 * @param {Object} props The component props.
10539 * @param {Function} props.onClose The function to close the dropdown.
10540 *
10541 * @return {JSX.Element} The rendered dropdown content.
10542 */
10543 function PostTemplateDropdownContent({
10544 onClose
10545 }) {
10546 var _options$find, _selectedOption$value;
10547 const allowSwitchingTemplate = useAllowSwitchingTemplates();
10548 const {
10549 availableTemplates,
10550 fetchedTemplates,
10551 selectedTemplateSlug,
10552 canCreate,
10553 canEdit,
10554 currentTemplateId,
10555 onNavigateToEntityRecord,
10556 getEditorSettings
10557 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10558 const {
10559 canUser,
10560 getEntityRecords
10561 } = select(external_wp_coreData_namespaceObject.store);
10562 const editorSettings = select(store_store).getEditorSettings();
10563 const canCreateTemplates = canUser('create', 'templates');
10564 const _currentTemplateId = select(store_store).getCurrentTemplateId();
10565 return {
10566 availableTemplates: editorSettings.availableTemplates,
10567 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
10568 post_type: select(store_store).getCurrentPostType(),
10569 per_page: -1
10570 }) : undefined,
10571 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'),
10572 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
10573 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
10574 currentTemplateId: _currentTemplateId,
10575 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
10576 getEditorSettings: select(store_store).getEditorSettings
10577 };
10578 }, [allowSwitchingTemplate]);
10579 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({
10580 ...availableTemplates,
10581 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
10582 slug,
10583 title
10584 }) => [slug, title.rendered]))
10585 }).map(([slug, title]) => ({
10586 value: slug,
10587 label: title
10588 })), [availableTemplates, fetchedTemplates]);
10589 const selectedOption = (_options$find = options.find(option => option.value === selectedTemplateSlug)) !== null && _options$find !== void 0 ? _options$find : options.find(option => !option.value); // The default option has '' value.
10590
10591 const {
10592 editPost
10593 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10594 const {
10595 createSuccessNotice
10596 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
10597 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
10598 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10599 className: "editor-post-template__classic-theme-dropdown",
10600 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
10601 title: (0,external_wp_i18n_namespaceObject.__)('Template'),
10602 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'),
10603 actions: canCreate ? [{
10604 icon: add_template,
10605 label: (0,external_wp_i18n_namespaceObject.__)('Add template'),
10606 onClick: () => setIsCreateModalOpen(true)
10607 }] : [],
10608 onClose: onClose
10609 }), !allowSwitchingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
10610 status: "warning",
10611 isDismissible: false,
10612 children: (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')
10613 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
10614 __next40pxDefaultSize: true,
10615 __nextHasNoMarginBottom: true,
10616 hideLabelFromVision: true,
10617 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
10618 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
10619 options: options,
10620 onChange: slug => editPost({
10621 template: slug || ''
10622 })
10623 }), canEdit && onNavigateToEntityRecord && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
10624 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10625 variant: "link",
10626 onClick: () => {
10627 onNavigateToEntityRecord({
10628 postId: currentTemplateId,
10629 postType: 'wp_template'
10630 });
10631 onClose();
10632 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
10633 type: 'snackbar',
10634 actions: [{
10635 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
10636 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
10637 }]
10638 });
10639 },
10640 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
10641 })
10642 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
10643 onClose: () => setIsCreateModalOpen(false)
10644 })]
10645 });
10646 }
10647 function ClassicThemeControl() {
10648 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10649 popoverProps: POPOVER_PROPS,
10650 focusOnMount: true,
10651 renderToggle: ({
10652 isOpen,
10653 onToggle
10654 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateToggle, {
10655 isOpen: isOpen,
10656 onClick: onToggle
10657 }),
10658 renderContent: ({
10659 onClose
10660 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateDropdownContent, {
10661 onClose: onClose
10662 })
10663 });
10664 }
10665
10666 /**
10667 * Provides a dropdown menu for selecting and managing post templates.
10668 *
10669 * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
10670 *
10671 * @return {JSX.Element} The rendered ClassicThemeControl component.
10672 */
10673 /* harmony default export */ const classic_theme = (ClassicThemeControl);
10674
10675 ;// CONCATENATED MODULE: external ["wp","warning"]
10676 const external_wp_warning_namespaceObject = window["wp"]["warning"];
10677 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-panel.js
10678 /**
10679 * WordPress dependencies
10680 */
10681
10682
10683
10684
10685 /**
10686 * Internal dependencies
10687 */
10688
10689
10690 const {
10691 PreferenceBaseOption
10692 } = unlock(external_wp_preferences_namespaceObject.privateApis);
10693 /* harmony default export */ const enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
10694 panelName
10695 }) => {
10696 const {
10697 isEditorPanelEnabled,
10698 isEditorPanelRemoved
10699 } = select(store_store);
10700 return {
10701 isRemoved: isEditorPanelRemoved(panelName),
10702 isChecked: isEditorPanelEnabled(panelName)
10703 };
10704 }), (0,external_wp_compose_namespaceObject.ifCondition)(({
10705 isRemoved
10706 }) => !isRemoved), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
10707 panelName
10708 }) => ({
10709 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName)
10710 })))(PreferenceBaseOption));
10711
10712 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js
10713 /**
10714 * WordPress dependencies
10715 */
10716
10717
10718 /**
10719 * Internal dependencies
10720 */
10721
10722
10723 const {
10724 Fill,
10725 Slot
10726 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
10727 const EnablePluginDocumentSettingPanelOption = ({
10728 label,
10729 panelName
10730 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Fill, {
10731 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
10732 label: label,
10733 panelName: panelName
10734 })
10735 });
10736 EnablePluginDocumentSettingPanelOption.Slot = Slot;
10737 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
10738
10739 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-document-setting-panel/index.js
10740 /**
10741 * WordPress dependencies
10742 */
10743
10744
10745
10746
10747
10748 /**
10749 * Internal dependencies
10750 */
10751
10752
10753
10754
10755
10756 const {
10757 Fill: plugin_document_setting_panel_Fill,
10758 Slot: plugin_document_setting_panel_Slot
10759 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
10760
10761 /**
10762 * Renders items below the Status & Availability panel in the Document Sidebar.
10763 *
10764 * @param {Object} props Component properties.
10765 * @param {string} props.name Required. A machine-friendly name for the panel.
10766 * @param {string} [props.className] An optional class name added to the row.
10767 * @param {string} [props.title] The title of the panel
10768 * @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.
10769 * @param {Element} props.children Children to be rendered
10770 *
10771 * @example
10772 * ```js
10773 * // Using ES5 syntax
10774 * var el = React.createElement;
10775 * var __ = wp.i18n.__;
10776 * var registerPlugin = wp.plugins.registerPlugin;
10777 * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
10778 *
10779 * function MyDocumentSettingPlugin() {
10780 * return el(
10781 * PluginDocumentSettingPanel,
10782 * {
10783 * className: 'my-document-setting-plugin',
10784 * title: 'My Panel',
10785 * name: 'my-panel',
10786 * },
10787 * __( 'My Document Setting Panel' )
10788 * );
10789 * }
10790 *
10791 * registerPlugin( 'my-document-setting-plugin', {
10792 * render: MyDocumentSettingPlugin
10793 * } );
10794 * ```
10795 *
10796 * @example
10797 * ```jsx
10798 * // Using ESNext syntax
10799 * import { registerPlugin } from '@wordpress/plugins';
10800 * import { PluginDocumentSettingPanel } from '@wordpress/editor';
10801 *
10802 * const MyDocumentSettingTest = () => (
10803 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
10804 * <p>My Document Setting Panel</p>
10805 * </PluginDocumentSettingPanel>
10806 * );
10807 *
10808 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
10809 * ```
10810 *
10811 * @return {Component} The component to be rendered.
10812 */
10813 const PluginDocumentSettingPanel = ({
10814 name,
10815 className,
10816 title,
10817 icon,
10818 children
10819 }) => {
10820 const {
10821 name: pluginName
10822 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10823 const panelName = `${pluginName}/${name}`;
10824 const {
10825 opened,
10826 isEnabled
10827 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10828 const {
10829 isEditorPanelOpened,
10830 isEditorPanelEnabled
10831 } = select(store_store);
10832 return {
10833 opened: isEditorPanelOpened(panelName),
10834 isEnabled: isEditorPanelEnabled(panelName)
10835 };
10836 }, [panelName]);
10837 const {
10838 toggleEditorPanelOpened
10839 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10840 if (undefined === name) {
10841 false ? 0 : void 0;
10842 }
10843 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10844 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel, {
10845 label: title,
10846 panelName: panelName
10847 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel_Fill, {
10848 children: isEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10849 className: className,
10850 title: title,
10851 icon: icon,
10852 opened: opened,
10853 onToggle: () => toggleEditorPanelOpened(panelName),
10854 children: children
10855 })
10856 })]
10857 });
10858 };
10859 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
10860 /* harmony default export */ const plugin_document_setting_panel = (PluginDocumentSettingPanel);
10861
10862 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
10863 /**
10864 * WordPress dependencies
10865 */
10866
10867
10868
10869
10870 const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
10871
10872 /**
10873 * Plugins may want to add an item to the menu either for every block
10874 * or only for the specific ones provided in the `allowedBlocks` component property.
10875 *
10876 * If there are multiple blocks selected the item will be rendered if every block
10877 * is of one allowed type (not necessarily the same).
10878 *
10879 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
10880 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
10881 * @return {boolean} Whether the item will be rendered or not.
10882 */
10883 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
10884
10885 /**
10886 * Renders a new item in the block settings menu.
10887 *
10888 * @param {Object} props Component props.
10889 * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
10890 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
10891 * @param {string} props.label The menu item text.
10892 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
10893 * @param {boolean} [props.small] Whether to render the label or not.
10894 * @param {string} [props.role] The ARIA role for the menu item.
10895 *
10896 * @example
10897 * ```js
10898 * // Using ES5 syntax
10899 * var __ = wp.i18n.__;
10900 * var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
10901 *
10902 * function doOnClick(){
10903 * // To be called when the user clicks the menu item.
10904 * }
10905 *
10906 * function MyPluginBlockSettingsMenuItem() {
10907 * return React.createElement(
10908 * PluginBlockSettingsMenuItem,
10909 * {
10910 * allowedBlocks: [ 'core/paragraph' ],
10911 * icon: 'dashicon-name',
10912 * label: __( 'Menu item text' ),
10913 * onClick: doOnClick,
10914 * }
10915 * );
10916 * }
10917 * ```
10918 *
10919 * @example
10920 * ```jsx
10921 * // Using ESNext syntax
10922 * import { __ } from '@wordpress/i18n';
10923 * import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
10924 *
10925 * const doOnClick = ( ) => {
10926 * // To be called when the user clicks the menu item.
10927 * };
10928 *
10929 * const MyPluginBlockSettingsMenuItem = () => (
10930 * <PluginBlockSettingsMenuItem
10931 * allowedBlocks={ [ 'core/paragraph' ] }
10932 * icon='dashicon-name'
10933 * label={ __( 'Menu item text' ) }
10934 * onClick={ doOnClick } />
10935 * );
10936 * ```
10937 *
10938 * @return {Component} The component to be rendered.
10939 */
10940 const PluginBlockSettingsMenuItem = ({
10941 allowedBlocks,
10942 icon,
10943 label,
10944 onClick,
10945 small,
10946 role
10947 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
10948 children: ({
10949 selectedBlocks,
10950 onClose
10951 }) => {
10952 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
10953 return null;
10954 }
10955 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10956 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
10957 icon: icon,
10958 label: small ? label : undefined,
10959 role: role,
10960 children: !small && label
10961 });
10962 }
10963 });
10964 /* harmony default export */ const plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
10965
10966 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-more-menu-item/index.js
10967 /**
10968 * WordPress dependencies
10969 */
10970
10971
10972
10973
10974
10975 /**
10976 * 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.
10977 * The text within the component appears as the menu item label.
10978 *
10979 * @param {Object} props Component properties.
10980 * @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.
10981 * @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.
10982 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
10983 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
10984 *
10985 * @example
10986 * ```js
10987 * // Using ES5 syntax
10988 * var __ = wp.i18n.__;
10989 * var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
10990 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
10991 *
10992 * function onButtonClick() {
10993 * alert( 'Button clicked.' );
10994 * }
10995 *
10996 * function MyButtonMoreMenuItem() {
10997 * return wp.element.createElement(
10998 * PluginMoreMenuItem,
10999 * {
11000 * icon: moreIcon,
11001 * onClick: onButtonClick,
11002 * },
11003 * __( 'My button title' )
11004 * );
11005 * }
11006 * ```
11007 *
11008 * @example
11009 * ```jsx
11010 * // Using ESNext syntax
11011 * import { __ } from '@wordpress/i18n';
11012 * import { PluginMoreMenuItem } from '@wordpress/editor';
11013 * import { more } from '@wordpress/icons';
11014 *
11015 * function onButtonClick() {
11016 * alert( 'Button clicked.' );
11017 * }
11018 *
11019 * const MyButtonMoreMenuItem = () => (
11020 * <PluginMoreMenuItem
11021 * icon={ more }
11022 * onClick={ onButtonClick }
11023 * >
11024 * { __( 'My button title' ) }
11025 * </PluginMoreMenuItem>
11026 * );
11027 * ```
11028 *
11029 * @return {Component} The component to be rendered.
11030 */
11031 /* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
11032 var _ownProps$as;
11033 return {
11034 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
11035 icon: ownProps.icon || context.icon,
11036 name: 'core/plugin-more-menu'
11037 };
11038 }))(action_item));
11039
11040 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-publish-panel/index.js
11041 /**
11042 * WordPress dependencies
11043 */
11044
11045
11046
11047 const {
11048 Fill: plugin_post_publish_panel_Fill,
11049 Slot: plugin_post_publish_panel_Slot
11050 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
11051
11052 /**
11053 * Renders provided content to the post-publish panel in the publish flow
11054 * (side panel that opens after a user publishes the post).
11055 *
11056 * @param {Object} props Component properties.
11057 * @param {string} [props.className] An optional class name added to the panel.
11058 * @param {string} [props.title] Title displayed at the top of the panel.
11059 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
11060 * @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.
11061 * @param {Element} props.children Children to be rendered
11062 *
11063 * @example
11064 * ```jsx
11065 * // Using ESNext syntax
11066 * import { __ } from '@wordpress/i18n';
11067 * import { PluginPostPublishPanel } from '@wordpress/editor';
11068 *
11069 * const MyPluginPostPublishPanel = () => (
11070 * <PluginPostPublishPanel
11071 * className="my-plugin-post-publish-panel"
11072 * title={ __( 'My panel title' ) }
11073 * initialOpen={ true }
11074 * >
11075 * { __( 'My panel content' ) }
11076 * </PluginPostPublishPanel>
11077 * );
11078 * ```
11079 *
11080 * @return {Component} The component to be rendered.
11081 */
11082 const PluginPostPublishPanel = ({
11083 children,
11084 className,
11085 title,
11086 initialOpen = false,
11087 icon
11088 }) => {
11089 const {
11090 icon: pluginIcon
11091 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
11092 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_publish_panel_Fill, {
11093 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
11094 className: className,
11095 initialOpen: initialOpen || !title,
11096 title: title,
11097 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
11098 children: children
11099 })
11100 });
11101 };
11102 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
11103 /* harmony default export */ const plugin_post_publish_panel = (PluginPostPublishPanel);
11104
11105 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-status-info/index.js
11106 /**
11107 * Defines as extensibility slot for the Summary panel.
11108 */
11109
11110 /**
11111 * WordPress dependencies
11112 */
11113
11114
11115 const {
11116 Fill: plugin_post_status_info_Fill,
11117 Slot: plugin_post_status_info_Slot
11118 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
11119
11120 /**
11121 * Renders a row in the Summary panel of the Document sidebar.
11122 * It should be noted that this is named and implemented around the function it serves
11123 * and not its location, which may change in future iterations.
11124 *
11125 * @param {Object} props Component properties.
11126 * @param {string} [props.className] An optional class name added to the row.
11127 * @param {Element} props.children Children to be rendered.
11128 *
11129 * @example
11130 * ```js
11131 * // Using ES5 syntax
11132 * var __ = wp.i18n.__;
11133 * var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;
11134 *
11135 * function MyPluginPostStatusInfo() {
11136 * return React.createElement(
11137 * PluginPostStatusInfo,
11138 * {
11139 * className: 'my-plugin-post-status-info',
11140 * },
11141 * __( 'My post status info' )
11142 * )
11143 * }
11144 * ```
11145 *
11146 * @example
11147 * ```jsx
11148 * // Using ESNext syntax
11149 * import { __ } from '@wordpress/i18n';
11150 * import { PluginPostStatusInfo } from '@wordpress/editor';
11151 *
11152 * const MyPluginPostStatusInfo = () => (
11153 * <PluginPostStatusInfo
11154 * className="my-plugin-post-status-info"
11155 * >
11156 * { __( 'My post status info' ) }
11157 * </PluginPostStatusInfo>
11158 * );
11159 * ```
11160 *
11161 * @return {Component} The component to be rendered.
11162 */
11163 const PluginPostStatusInfo = ({
11164 children,
11165 className
11166 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info_Fill, {
11167 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
11168 className: className,
11169 children: children
11170 })
11171 });
11172 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
11173 /* harmony default export */ const plugin_post_status_info = (PluginPostStatusInfo);
11174
11175 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-pre-publish-panel/index.js
11176 /**
11177 * WordPress dependencies
11178 */
11179
11180
11181
11182 const {
11183 Fill: plugin_pre_publish_panel_Fill,
11184 Slot: plugin_pre_publish_panel_Slot
11185 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
11186
11187 /**
11188 * Renders provided content to the pre-publish side panel in the publish flow
11189 * (side panel that opens when a user first pushes "Publish" from the main editor).
11190 *
11191 * @param {Object} props Component props.
11192 * @param {string} [props.className] An optional class name added to the panel.
11193 * @param {string} [props.title] Title displayed at the top of the panel.
11194 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
11195 * When no title is provided it is always opened.
11196 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
11197 * icon slug string, or an SVG WP element, to be rendered when
11198 * the sidebar is pinned to toolbar.
11199 * @param {Element} props.children Children to be rendered
11200 *
11201 * @example
11202 * ```jsx
11203 * // Using ESNext syntax
11204 * import { __ } from '@wordpress/i18n';
11205 * import { PluginPrePublishPanel } from '@wordpress/editor';
11206 *
11207 * const MyPluginPrePublishPanel = () => (
11208 * <PluginPrePublishPanel
11209 * className="my-plugin-pre-publish-panel"
11210 * title={ __( 'My panel title' ) }
11211 * initialOpen={ true }
11212 * >
11213 * { __( 'My panel content' ) }
11214 * </PluginPrePublishPanel>
11215 * );
11216 * ```
11217 *
11218 * @return {Component} The component to be rendered.
11219 */
11220 const PluginPrePublishPanel = ({
11221 children,
11222 className,
11223 title,
11224 initialOpen = false,
11225 icon
11226 }) => {
11227 const {
11228 icon: pluginIcon
11229 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
11230 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_pre_publish_panel_Fill, {
11231 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
11232 className: className,
11233 initialOpen: initialOpen || !title,
11234 title: title,
11235 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
11236 children: children
11237 })
11238 });
11239 };
11240 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
11241 /* harmony default export */ const plugin_pre_publish_panel = (PluginPrePublishPanel);
11242
11243 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar/index.js
11244 /**
11245 * WordPress dependencies
11246 */
11247
11248
11249
11250
11251
11252 /**
11253 * Internal dependencies
11254 */
11255
11256
11257 /**
11258 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
11259 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
11260 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
11261 *
11262 * ```js
11263 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
11264 * ```
11265 *
11266 * @see PluginSidebarMoreMenuItem
11267 *
11268 * @param {Object} props Element props.
11269 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
11270 * @param {string} [props.className] An optional class name added to the sidebar body.
11271 * @param {string} props.title Title displayed at the top of the sidebar.
11272 * @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.
11273 * @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.
11274 *
11275 * @example
11276 * ```js
11277 * // Using ES5 syntax
11278 * var __ = wp.i18n.__;
11279 * var el = React.createElement;
11280 * var PanelBody = wp.components.PanelBody;
11281 * var PluginSidebar = wp.editor.PluginSidebar;
11282 * var moreIcon = React.createElement( 'svg' ); //... svg element.
11283 *
11284 * function MyPluginSidebar() {
11285 * return el(
11286 * PluginSidebar,
11287 * {
11288 * name: 'my-sidebar',
11289 * title: 'My sidebar title',
11290 * icon: moreIcon,
11291 * },
11292 * el(
11293 * PanelBody,
11294 * {},
11295 * __( 'My sidebar content' )
11296 * )
11297 * );
11298 * }
11299 * ```
11300 *
11301 * @example
11302 * ```jsx
11303 * // Using ESNext syntax
11304 * import { __ } from '@wordpress/i18n';
11305 * import { PanelBody } from '@wordpress/components';
11306 * import { PluginSidebar } from '@wordpress/editor';
11307 * import { more } from '@wordpress/icons';
11308 *
11309 * const MyPluginSidebar = () => (
11310 * <PluginSidebar
11311 * name="my-sidebar"
11312 * title="My sidebar title"
11313 * icon={ more }
11314 * >
11315 * <PanelBody>
11316 * { __( 'My sidebar content' ) }
11317 * </PanelBody>
11318 * </PluginSidebar>
11319 * );
11320 * ```
11321 */
11322
11323 function PluginSidebar({
11324 className,
11325 ...props
11326 }) {
11327 const {
11328 postTitle,
11329 shortcut
11330 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11331 return {
11332 postTitle: select(store_store).getEditedPostAttribute('title'),
11333 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar')
11334 };
11335 }, []);
11336 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area, {
11337 panelClassName: className,
11338 className: "editor-sidebar",
11339 smallScreenTitle: postTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
11340 scope: "core",
11341 toggleShortcut: shortcut,
11342 ...props
11343 });
11344 }
11345
11346 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js
11347 /**
11348 * WordPress dependencies
11349 */
11350
11351
11352 /**
11353 * Renders a menu item in `Plugins` group in `More Menu` drop down,
11354 * and can be used to activate the corresponding `PluginSidebar` component.
11355 * The text within the component appears as the menu item label.
11356 *
11357 * @param {Object} props Component props.
11358 * @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.
11359 * @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.
11360 *
11361 * @example
11362 * ```js
11363 * // Using ES5 syntax
11364 * var __ = wp.i18n.__;
11365 * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
11366 * var moreIcon = React.createElement( 'svg' ); //... svg element.
11367 *
11368 * function MySidebarMoreMenuItem() {
11369 * return React.createElement(
11370 * PluginSidebarMoreMenuItem,
11371 * {
11372 * target: 'my-sidebar',
11373 * icon: moreIcon,
11374 * },
11375 * __( 'My sidebar title' )
11376 * )
11377 * }
11378 * ```
11379 *
11380 * @example
11381 * ```jsx
11382 * // Using ESNext syntax
11383 * import { __ } from '@wordpress/i18n';
11384 * import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
11385 * import { more } from '@wordpress/icons';
11386 *
11387 * const MySidebarMoreMenuItem = () => (
11388 * <PluginSidebarMoreMenuItem
11389 * target="my-sidebar"
11390 * icon={ more }
11391 * >
11392 * { __( 'My sidebar title' ) }
11393 * </PluginSidebarMoreMenuItem>
11394 * );
11395 * ```
11396 *
11397 * @return {Component} The component to be rendered.
11398 */
11399
11400 function PluginSidebarMoreMenuItem(props) {
11401 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem
11402 // Menu item is marked with unstable prop for backward compatibility.
11403 // @see https://github.com/WordPress/gutenberg/issues/14457
11404 , {
11405 __unstableExplicitMenuItem: true,
11406 scope: "core",
11407 ...props
11408 });
11409 }
11410
11411 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/swap-template-button.js
11412 /**
11413 * WordPress dependencies
11414 */
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425 /**
11426 * Internal dependencies
11427 */
11428
11429
11430
11431
11432 function SwapTemplateButton({
11433 onClick
11434 }) {
11435 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
11436 const {
11437 postType,
11438 postId
11439 } = useEditedPostContext();
11440 const availableTemplates = useAvailableTemplates(postType);
11441 const {
11442 editEntityRecord
11443 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11444 if (!availableTemplates?.length) {
11445 return null;
11446 }
11447 const onTemplateSelect = async template => {
11448 editEntityRecord('postType', postType, postId, {
11449 template: template.name
11450 }, {
11451 undoIgnore: true
11452 });
11453 setShowModal(false); // Close the template suggestions modal first.
11454 onClick();
11455 };
11456 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11457 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11458 onClick: () => setShowModal(true),
11459 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
11460 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
11461 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
11462 onRequestClose: () => setShowModal(false),
11463 overlayClassName: "editor-post-template__swap-template-modal",
11464 isFullScreen: true,
11465 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
11466 className: "editor-post-template__swap-template-modal-content",
11467 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatesList, {
11468 postType: postType,
11469 onSelect: onTemplateSelect
11470 })
11471 })
11472 })]
11473 });
11474 }
11475 function TemplatesList({
11476 postType,
11477 onSelect
11478 }) {
11479 const availableTemplates = useAvailableTemplates(postType);
11480 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
11481 name: template.slug,
11482 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
11483 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
11484 id: template.id
11485 })), [availableTemplates]);
11486 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns);
11487 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
11488 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
11489 blockPatterns: templatesAsPatterns,
11490 shownPatterns: shownTemplates,
11491 onClickPattern: onSelect
11492 });
11493 }
11494
11495 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/reset-default-template.js
11496 /**
11497 * WordPress dependencies
11498 */
11499
11500
11501
11502
11503
11504 /**
11505 * Internal dependencies
11506 */
11507
11508
11509 function ResetDefaultTemplate({
11510 onClick
11511 }) {
11512 const currentTemplateSlug = useCurrentTemplateSlug();
11513 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11514 const {
11515 postType,
11516 postId
11517 } = useEditedPostContext();
11518 const {
11519 editEntityRecord
11520 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11521 // The default template in a post is indicated by an empty string.
11522 if (!currentTemplateSlug || !allowSwitchingTemplate) {
11523 return null;
11524 }
11525 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11526 onClick: () => {
11527 editEntityRecord('postType', postType, postId, {
11528 template: ''
11529 }, {
11530 undoIgnore: true
11531 });
11532 onClick();
11533 },
11534 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
11535 });
11536 }
11537
11538 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template.js
11539 /**
11540 * WordPress dependencies
11541 */
11542
11543
11544
11545
11546
11547
11548 /**
11549 * Internal dependencies
11550 */
11551
11552
11553
11554
11555
11556 function CreateNewTemplate({
11557 onClick
11558 }) {
11559 const {
11560 canCreateTemplates
11561 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11562 const {
11563 canUser
11564 } = select(external_wp_coreData_namespaceObject.store);
11565 return {
11566 canCreateTemplates: canUser('create', 'templates')
11567 };
11568 }, []);
11569 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11570 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11571
11572 // The default template in a post is indicated by an empty string.
11573 if (!canCreateTemplates || !allowSwitchingTemplate) {
11574 return null;
11575 }
11576 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11577 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11578 onClick: () => {
11579 setIsCreateModalOpen(true);
11580 },
11581 children: (0,external_wp_i18n_namespaceObject.__)('Create new template')
11582 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
11583 onClose: () => {
11584 setIsCreateModalOpen(false);
11585 onClick();
11586 }
11587 })]
11588 });
11589 }
11590
11591 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/block-theme.js
11592 /**
11593 * WordPress dependencies
11594 */
11595
11596
11597
11598
11599
11600
11601
11602
11603 /**
11604 * Internal dependencies
11605 */
11606
11607
11608
11609
11610
11611
11612
11613
11614 const block_theme_POPOVER_PROPS = {
11615 className: 'editor-post-template__dropdown',
11616 placement: 'bottom-start'
11617 };
11618 function BlockThemeControl({
11619 id
11620 }) {
11621 const {
11622 isTemplateHidden,
11623 onNavigateToEntityRecord,
11624 getEditorSettings,
11625 hasGoBack
11626 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11627 const {
11628 getRenderingMode,
11629 getEditorSettings: _getEditorSettings
11630 } = unlock(select(store_store));
11631 const editorSettings = _getEditorSettings();
11632 return {
11633 isTemplateHidden: getRenderingMode() === 'post-only',
11634 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
11635 getEditorSettings: _getEditorSettings,
11636 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
11637 };
11638 }, []);
11639 const {
11640 editedRecord: template,
11641 hasResolved
11642 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id);
11643 const {
11644 createSuccessNotice
11645 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11646 const {
11647 setRenderingMode
11648 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11649 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
11650 var _select$canUser;
11651 return (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
11652 });
11653 if (!hasResolved) {
11654 return null;
11655 }
11656
11657 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
11658 // and assigns its own backlink to focusMode pages.
11659 const notificationAction = hasGoBack ? [{
11660 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
11661 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
11662 }] : undefined;
11663 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
11664 popoverProps: block_theme_POPOVER_PROPS,
11665 focusOnMount: true,
11666 toggleProps: {
11667 size: 'compact',
11668 variant: 'tertiary',
11669 tooltipPosition: 'middle left'
11670 },
11671 label: (0,external_wp_i18n_namespaceObject.__)('Template options'),
11672 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title),
11673 icon: null,
11674 children: ({
11675 onClose
11676 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11677 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
11678 children: [canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11679 onClick: () => {
11680 onNavigateToEntityRecord({
11681 postId: template.id,
11682 postType: 'wp_template'
11683 });
11684 onClose();
11685 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
11686 type: 'snackbar',
11687 actions: notificationAction
11688 });
11689 },
11690 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
11691 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SwapTemplateButton, {
11692 onClick: onClose
11693 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetDefaultTemplate, {
11694 onClick: onClose
11695 }), canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplate, {
11696 onClick: onClose
11697 })]
11698 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
11699 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11700 icon: !isTemplateHidden ? library_check : undefined,
11701 isSelected: !isTemplateHidden,
11702 role: "menuitemcheckbox",
11703 onClick: () => {
11704 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
11705 },
11706 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
11707 })
11708 })]
11709 })
11710 });
11711 }
11712
11713 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/panel.js
11714 /**
11715 * WordPress dependencies
11716 */
11717
11718
11719
11720
11721 /**
11722 * Internal dependencies
11723 */
11724
11725
11726
11727
11728
11729 /**
11730 * Displays the template controls based on the current editor settings and user permissions.
11731 *
11732 * @return {JSX.Element|null} The rendered PostTemplatePanel component.
11733 */
11734
11735 function PostTemplatePanel() {
11736 const {
11737 templateId,
11738 isBlockTheme
11739 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11740 const {
11741 getCurrentTemplateId,
11742 getEditorSettings
11743 } = select(store_store);
11744 return {
11745 templateId: getCurrentTemplateId(),
11746 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
11747 };
11748 }, []);
11749 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
11750 var _select$canUser;
11751 const postTypeSlug = select(store_store).getCurrentPostType();
11752 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
11753 if (!postType?.viewable) {
11754 return false;
11755 }
11756 const settings = select(store_store).getEditorSettings();
11757 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
11758 if (hasTemplates) {
11759 return true;
11760 }
11761 if (!settings.supportsTemplateMode) {
11762 return false;
11763 }
11764 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
11765 return canCreateTemplates;
11766 }, []);
11767 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => {
11768 var _select$canUser2;
11769 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', 'templates')) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
11770 }, []);
11771 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
11772 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11773 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11774 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(classic_theme, {})
11775 });
11776 }
11777 if (isBlockTheme && !!templateId) {
11778 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11779 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11780 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockThemeControl, {
11781 id: templateId
11782 })
11783 });
11784 }
11785 return null;
11786 }
11787
11788 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/constants.js
11789 const BASE_QUERY = {
11790 _fields: 'id,name',
11791 context: 'view' // Allows non-admins to perform requests.
11792 };
11793 const AUTHORS_QUERY = {
11794 who: 'authors',
11795 per_page: 50,
11796 ...BASE_QUERY
11797 };
11798
11799 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/hook.js
11800 /**
11801 * WordPress dependencies
11802 */
11803
11804
11805
11806
11807
11808 /**
11809 * Internal dependencies
11810 */
11811
11812
11813 function useAuthorsQuery(search) {
11814 const {
11815 authorId,
11816 authors,
11817 postAuthor
11818 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11819 const {
11820 getUser,
11821 getUsers
11822 } = select(external_wp_coreData_namespaceObject.store);
11823 const {
11824 getEditedPostAttribute
11825 } = select(store_store);
11826 const _authorId = getEditedPostAttribute('author');
11827 const query = {
11828 ...AUTHORS_QUERY
11829 };
11830 if (search) {
11831 query.search = search;
11832 }
11833 return {
11834 authorId: _authorId,
11835 authors: getUsers(query),
11836 postAuthor: getUser(_authorId, BASE_QUERY)
11837 };
11838 }, [search]);
11839 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
11840 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
11841 return {
11842 value: author.id,
11843 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
11844 };
11845 });
11846
11847 // Ensure the current author is included in the dropdown list.
11848 const foundAuthor = fetchedAuthors.findIndex(({
11849 value
11850 }) => postAuthor?.id === value);
11851 if (foundAuthor < 0 && postAuthor) {
11852 return [{
11853 value: postAuthor.id,
11854 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
11855 }, ...fetchedAuthors];
11856 }
11857 return fetchedAuthors;
11858 }, [authors, postAuthor]);
11859 return {
11860 authorId,
11861 authorOptions,
11862 postAuthor
11863 };
11864 }
11865
11866 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/combobox.js
11867 /**
11868 * WordPress dependencies
11869 */
11870
11871
11872
11873
11874
11875
11876 /**
11877 * Internal dependencies
11878 */
11879
11880
11881
11882 function PostAuthorCombobox() {
11883 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
11884 const {
11885 editPost
11886 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11887 const {
11888 authorId,
11889 authorOptions
11890 } = useAuthorsQuery(fieldValue);
11891
11892 /**
11893 * Handle author selection.
11894 *
11895 * @param {number} postAuthorId The selected Author.
11896 */
11897 const handleSelect = postAuthorId => {
11898 if (!postAuthorId) {
11899 return;
11900 }
11901 editPost({
11902 author: postAuthorId
11903 });
11904 };
11905
11906 /**
11907 * Handle user input.
11908 *
11909 * @param {string} inputValue The current value of the input field.
11910 */
11911 const handleKeydown = inputValue => {
11912 setFieldValue(inputValue);
11913 };
11914 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
11915 __nextHasNoMarginBottom: true,
11916 __next40pxDefaultSize: true,
11917 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11918 options: authorOptions,
11919 value: authorId,
11920 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
11921 onChange: handleSelect,
11922 allowReset: false,
11923 hideLabelFromVision: true
11924 });
11925 }
11926
11927 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/select.js
11928 /**
11929 * WordPress dependencies
11930 */
11931
11932
11933
11934
11935 /**
11936 * Internal dependencies
11937 */
11938
11939
11940
11941 function PostAuthorSelect() {
11942 const {
11943 editPost
11944 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11945 const {
11946 authorId,
11947 authorOptions
11948 } = useAuthorsQuery();
11949 const setAuthorId = value => {
11950 const author = Number(value);
11951 editPost({
11952 author
11953 });
11954 };
11955 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
11956 __next40pxDefaultSize: true,
11957 __nextHasNoMarginBottom: true,
11958 className: "post-author-selector",
11959 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11960 options: authorOptions,
11961 onChange: setAuthorId,
11962 value: authorId,
11963 hideLabelFromVision: true
11964 });
11965 }
11966
11967 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/index.js
11968 /**
11969 * WordPress dependencies
11970 */
11971
11972
11973
11974 /**
11975 * Internal dependencies
11976 */
11977
11978
11979
11980
11981 const minimumUsersForCombobox = 25;
11982
11983 /**
11984 * Renders the component for selecting the post author.
11985 *
11986 * @return {Component} The component to be rendered.
11987 */
11988 function PostAuthor() {
11989 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
11990 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
11991 return authors?.length >= minimumUsersForCombobox;
11992 }, []);
11993 if (showCombobox) {
11994 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCombobox, {});
11995 }
11996 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorSelect, {});
11997 }
11998 /* harmony default export */ const post_author = (PostAuthor);
11999
12000 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/check.js
12001 /**
12002 * WordPress dependencies
12003 */
12004
12005
12006
12007 /**
12008 * Internal dependencies
12009 */
12010
12011
12012
12013
12014 /**
12015 * Wrapper component that renders its children only if the post type supports the author.
12016 *
12017 * @param {Object} props The component props.
12018 * @param {Element} props.children Children to be rendered.
12019 *
12020 * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't
12021 * supports the author or if there are no authors available.
12022 */
12023
12024 function PostAuthorCheck({
12025 children
12026 }) {
12027 const {
12028 hasAssignAuthorAction,
12029 hasAuthors
12030 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12031 var _post$_links$wpActio;
12032 const post = select(store_store).getCurrentPost();
12033 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
12034 return {
12035 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
12036 hasAuthors: authors?.length >= 1
12037 };
12038 }, []);
12039 if (!hasAssignAuthorAction || !hasAuthors) {
12040 return null;
12041 }
12042 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12043 supportKeys: "author",
12044 children: children
12045 });
12046 }
12047
12048 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/panel.js
12049 /**
12050 * WordPress dependencies
12051 */
12052
12053
12054
12055
12056
12057 /**
12058 * Internal dependencies
12059 */
12060
12061
12062
12063
12064
12065
12066 function PostAuthorToggle({
12067 isOpen,
12068 onClick
12069 }) {
12070 const {
12071 postAuthor
12072 } = useAuthorsQuery();
12073 const authorName = postAuthor?.name || '';
12074 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12075 size: "compact",
12076 className: "editor-post-author__panel-toggle",
12077 variant: "tertiary",
12078 "aria-expanded": isOpen
12079 // translators: %s: Current post link.
12080 ,
12081 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change author: %s'), authorName),
12082 onClick: onClick,
12083 children: authorName
12084 });
12085 }
12086
12087 /**
12088 * Renders the Post Author Panel component.
12089 *
12090 * @return {Component} The component to be rendered.
12091 */
12092 function panel_PostAuthor() {
12093 // Use internal state instead of a ref to make sure that the component
12094 // re-renders when the popover's anchor updates.
12095 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12096 // Memoize popoverProps to avoid returning a new object every time.
12097 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12098 // Anchor the popover to the middle of the entire row so that it doesn't
12099 // move around when the label changes.
12100 anchor: popoverAnchor,
12101 placement: 'left-start',
12102 offset: 36,
12103 shift: true
12104 }), [popoverAnchor]);
12105 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCheck, {
12106 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
12107 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
12108 ref: setPopoverAnchor,
12109 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12110 popoverProps: popoverProps,
12111 contentClassName: "editor-post-author__panel-dialog",
12112 focusOnMount: true,
12113 renderToggle: ({
12114 isOpen,
12115 onToggle
12116 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorToggle, {
12117 isOpen: isOpen,
12118 onClick: onToggle
12119 }),
12120 renderContent: ({
12121 onClose
12122 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12123 className: "editor-post-author",
12124 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12125 title: (0,external_wp_i18n_namespaceObject.__)('Author'),
12126 onClose: onClose
12127 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_author, {
12128 onClose: onClose
12129 })]
12130 })
12131 })
12132 })
12133 });
12134 }
12135 /* harmony default export */ const panel = (panel_PostAuthor);
12136
12137 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-comments/index.js
12138 /**
12139 * WordPress dependencies
12140 */
12141
12142
12143
12144
12145 /**
12146 * Internal dependencies
12147 */
12148
12149
12150
12151
12152 const COMMENT_OPTIONS = [{
12153 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12154 children: [(0,external_wp_i18n_namespaceObject.__)('Open'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12155 variant: "muted",
12156 size: 12,
12157 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
12158 })]
12159 }),
12160 value: 'open'
12161 }, {
12162 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12163 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12164 variant: "muted",
12165 size: 12,
12166 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
12167 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12168 variant: "muted",
12169 size: 12,
12170 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
12171 })]
12172 }),
12173 value: 'closed'
12174 }];
12175 function PostComments() {
12176 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
12177 var _select$getEditedPost;
12178 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
12179 }, []);
12180 const {
12181 editPost
12182 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12183 const handleStatus = newCommentStatus => editPost({
12184 comment_status: newCommentStatus
12185 });
12186 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
12187 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
12188 spacing: 4,
12189 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
12190 className: "editor-change-status__options",
12191 hideLabelFromVision: true,
12192 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
12193 options: COMMENT_OPTIONS,
12194 onChange: handleStatus,
12195 selected: commentStatus
12196 })
12197 })
12198 });
12199 }
12200
12201 /**
12202 * A form for managing comment status.
12203 *
12204 * @return {JSX.Element} The rendered PostComments component.
12205 */
12206 /* harmony default export */ const post_comments = (PostComments);
12207
12208 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pingbacks/index.js
12209 /**
12210 * WordPress dependencies
12211 */
12212
12213
12214
12215
12216 /**
12217 * Internal dependencies
12218 */
12219
12220
12221 function PostPingbacks() {
12222 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
12223 var _select$getEditedPost;
12224 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
12225 }, []);
12226 const {
12227 editPost
12228 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12229 const onTogglePingback = () => editPost({
12230 ping_status: pingStatus === 'open' ? 'closed' : 'open'
12231 });
12232 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
12233 __nextHasNoMarginBottom: true,
12234 label: (0,external_wp_i18n_namespaceObject.__)('Enable pingbacks & trackbacks'),
12235 checked: pingStatus === 'open',
12236 onChange: onTogglePingback,
12237 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
12238 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/trackbacks-and-pingbacks/'),
12239 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about pingbacks & trackbacks')
12240 })
12241 });
12242 }
12243
12244 /**
12245 * Renders a control for enabling or disabling pingbacks and trackbacks
12246 * in a WordPress post.
12247 *
12248 * @module PostPingbacks
12249 */
12250 /* harmony default export */ const post_pingbacks = (PostPingbacks);
12251
12252 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-discussion/panel.js
12253 /**
12254 * WordPress dependencies
12255 */
12256
12257
12258
12259
12260
12261
12262
12263 /**
12264 * Internal dependencies
12265 */
12266
12267
12268
12269
12270
12271
12272
12273 const panel_PANEL_NAME = 'discussion-panel';
12274 function ModalContents({
12275 onClose
12276 }) {
12277 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12278 className: "editor-post-discussion",
12279 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12280 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
12281 onClose: onClose
12282 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
12283 spacing: 4,
12284 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12285 supportKeys: "comments",
12286 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_comments, {})
12287 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12288 supportKeys: "trackbacks",
12289 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pingbacks, {})
12290 })]
12291 })]
12292 });
12293 }
12294 function PostDiscussionToggle({
12295 isOpen,
12296 onClick
12297 }) {
12298 const {
12299 commentStatus,
12300 pingStatus,
12301 commentsSupported,
12302 trackbacksSupported
12303 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12304 var _getEditedPostAttribu, _getEditedPostAttribu2;
12305 const {
12306 getEditedPostAttribute
12307 } = select(store_store);
12308 const {
12309 getPostType
12310 } = select(external_wp_coreData_namespaceObject.store);
12311 const postType = getPostType(getEditedPostAttribute('type'));
12312 return {
12313 commentStatus: (_getEditedPostAttribu = getEditedPostAttribute('comment_status')) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : 'open',
12314 pingStatus: (_getEditedPostAttribu2 = getEditedPostAttribute('ping_status')) !== null && _getEditedPostAttribu2 !== void 0 ? _getEditedPostAttribu2 : 'open',
12315 commentsSupported: !!postType.supports.comments,
12316 trackbacksSupported: !!postType.supports.trackbacks
12317 };
12318 }, []);
12319 let label;
12320 if (commentStatus === 'open') {
12321 if (pingStatus === 'open') {
12322 label = (0,external_wp_i18n_namespaceObject.__)('Open');
12323 } else {
12324 label = trackbacksSupported ? (0,external_wp_i18n_namespaceObject.__)('Comments only') : (0,external_wp_i18n_namespaceObject.__)('Open');
12325 }
12326 } else if (pingStatus === 'open') {
12327 label = commentsSupported ? (0,external_wp_i18n_namespaceObject.__)('Pings only') : (0,external_wp_i18n_namespaceObject.__)('Pings enabled');
12328 } else {
12329 label = (0,external_wp_i18n_namespaceObject.__)('Closed');
12330 }
12331 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12332 size: "compact",
12333 className: "editor-post-discussion__panel-toggle",
12334 variant: "tertiary",
12335 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion options'),
12336 "aria-expanded": isOpen,
12337 onClick: onClick,
12338 children: label
12339 });
12340 }
12341
12342 /**
12343 * This component allows to update comment and pingback
12344 * settings for the current post. Internally there are
12345 * checks whether the current post has support for the
12346 * above and if the `discussion-panel` panel is enabled.
12347 *
12348 * @return {JSX.Element|null} The rendered PostDiscussionPanel component.
12349 */
12350 function PostDiscussionPanel() {
12351 const {
12352 isEnabled
12353 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12354 const {
12355 isEditorPanelEnabled
12356 } = select(store_store);
12357 return {
12358 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME)
12359 };
12360 }, []);
12361
12362 // Use internal state instead of a ref to make sure that the component
12363 // re-renders when the popover's anchor updates.
12364 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12365 // Memoize popoverProps to avoid returning a new object every time.
12366 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12367 // Anchor the popover to the middle of the entire row so that it doesn't
12368 // move around when the label changes.
12369 anchor: popoverAnchor,
12370 placement: 'left-start',
12371 offset: 36,
12372 shift: true
12373 }), [popoverAnchor]);
12374 if (!isEnabled) {
12375 return null;
12376 }
12377 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12378 supportKeys: ['comments', 'trackbacks'],
12379 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
12380 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
12381 ref: setPopoverAnchor,
12382 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12383 popoverProps: popoverProps,
12384 className: "editor-post-discussion__panel-dropdown",
12385 contentClassName: "editor-post-discussion__panel-dialog",
12386 focusOnMount: true,
12387 renderToggle: ({
12388 isOpen,
12389 onToggle
12390 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionToggle, {
12391 isOpen: isOpen,
12392 onClick: onToggle
12393 }),
12394 renderContent: ({
12395 onClose
12396 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ModalContents, {
12397 onClose: onClose
12398 })
12399 })
12400 })
12401 });
12402 }
12403
12404 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/index.js
12405 /**
12406 * WordPress dependencies
12407 */
12408
12409
12410
12411
12412
12413 /**
12414 * Internal dependencies
12415 */
12416
12417
12418 /**
12419 * Renders an editable textarea for the post excerpt.
12420 * Templates, template parts and patterns use the `excerpt` field as a description semantically.
12421 * Additionally templates and template parts override the `excerpt` field as `description` in
12422 * REST API. So this component handles proper labeling and updating the edited entity.
12423 *
12424 * @param {Object} props - Component props.
12425 * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
12426 * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
12427 */
12428
12429 function PostExcerpt({
12430 hideLabelFromVision = false,
12431 updateOnBlur = false
12432 }) {
12433 const {
12434 excerpt,
12435 shouldUseDescriptionLabel,
12436 usedAttribute
12437 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12438 const {
12439 getCurrentPostType,
12440 getEditedPostAttribute
12441 } = select(store_store);
12442 const postType = getCurrentPostType();
12443 // This special case is unfortunate, but the REST API of wp_template and wp_template_part
12444 // support the excerpt field throught the "description" field rather than "excerpt".
12445 const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
12446 return {
12447 excerpt: getEditedPostAttribute(_usedAttribute),
12448 // There are special cases where we want to label the excerpt as a description.
12449 shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
12450 usedAttribute: _usedAttribute
12451 };
12452 }, []);
12453 const {
12454 editPost
12455 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12456 const [localExcerpt, setLocalExcerpt] = (0,external_wp_element_namespaceObject.useState)(excerpt);
12457 const updatePost = value => {
12458 editPost({
12459 [usedAttribute]: value
12460 });
12461 };
12462 const label = shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Write a description (optional)') : (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)');
12463 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12464 className: "editor-post-excerpt",
12465 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
12466 __nextHasNoMarginBottom: true,
12467 label: label,
12468 hideLabelFromVision: hideLabelFromVision,
12469 className: "editor-post-excerpt__textarea",
12470 onChange: updateOnBlur ? setLocalExcerpt : updatePost,
12471 onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
12472 value: updateOnBlur ? localExcerpt : excerpt,
12473 help: !shouldUseDescriptionLabel ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
12474 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'),
12475 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')
12476 }) : (0,external_wp_i18n_namespaceObject.__)('Write a description')
12477 })
12478 });
12479 }
12480
12481 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/check.js
12482 /**
12483 * Internal dependencies
12484 */
12485
12486
12487 /**
12488 * Component for checking if the post type supports the excerpt field.
12489 *
12490 * @param {Object} props Props.
12491 * @param {Element} props.children Children to be rendered.
12492 *
12493 * @return {Component} The component to be rendered.
12494 */
12495
12496 function PostExcerptCheck({
12497 children
12498 }) {
12499 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12500 supportKeys: "excerpt",
12501 children: children
12502 });
12503 }
12504 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
12505
12506 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/plugin.js
12507 /**
12508 * Defines as extensibility slot for the Excerpt panel.
12509 */
12510
12511 /**
12512 * WordPress dependencies
12513 */
12514
12515
12516 const {
12517 Fill: plugin_Fill,
12518 Slot: plugin_Slot
12519 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt');
12520
12521 /**
12522 * Renders a post excerpt panel in the post sidebar.
12523 *
12524 * @param {Object} props Component properties.
12525 * @param {string} [props.className] An optional class name added to the row.
12526 * @param {Element} props.children Children to be rendered.
12527 *
12528 * @example
12529 * ```js
12530 * // Using ES5 syntax
12531 * var __ = wp.i18n.__;
12532 * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
12533 *
12534 * function MyPluginPostExcerpt() {
12535 * return React.createElement(
12536 * PluginPostExcerpt,
12537 * {
12538 * className: 'my-plugin-post-excerpt',
12539 * },
12540 * __( 'Post excerpt custom content' )
12541 * )
12542 * }
12543 * ```
12544 *
12545 * @example
12546 * ```jsx
12547 * // Using ESNext syntax
12548 * import { __ } from '@wordpress/i18n';
12549 * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
12550 *
12551 * const MyPluginPostExcerpt = () => (
12552 * <PluginPostExcerpt className="my-plugin-post-excerpt">
12553 * { __( 'Post excerpt custom content' ) }
12554 * </PluginPostExcerpt>
12555 * );
12556 * ```
12557 *
12558 * @return {Component} The component to be rendered.
12559 */
12560 const PluginPostExcerpt = ({
12561 children,
12562 className
12563 }) => {
12564 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_Fill, {
12565 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
12566 className: className,
12567 children: children
12568 })
12569 });
12570 };
12571 PluginPostExcerpt.Slot = plugin_Slot;
12572 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt);
12573
12574 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/panel.js
12575 /**
12576 * WordPress dependencies
12577 */
12578
12579
12580
12581
12582
12583
12584
12585 /**
12586 * Internal dependencies
12587 */
12588
12589
12590
12591
12592
12593
12594 /**
12595 * Module Constants
12596 */
12597
12598
12599
12600 const post_excerpt_panel_PANEL_NAME = 'post-excerpt';
12601 function ExcerptPanel() {
12602 const {
12603 isOpened,
12604 isEnabled,
12605 postType
12606 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12607 const {
12608 isEditorPanelOpened,
12609 isEditorPanelEnabled,
12610 getCurrentPostType
12611 } = select(store_store);
12612 return {
12613 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME),
12614 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME),
12615 postType: getCurrentPostType()
12616 };
12617 }, []);
12618 const {
12619 toggleEditorPanelOpened
12620 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12621 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME);
12622 if (!isEnabled) {
12623 return null;
12624 }
12625
12626 // There are special cases where we want to label the excerpt as a description.
12627 const shouldUseDescriptionLabel = ['wp_template', 'wp_template_part', 'wp_block'].includes(postType);
12628 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
12629 title: shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
12630 opened: isOpened,
12631 onToggle: toggleExcerptPanel,
12632 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12633 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12634 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {}), fills]
12635 })
12636 })
12637 });
12638 }
12639
12640 /**
12641 * Is rendered if the post type supports excerpts and allows editing the excerpt.
12642 *
12643 * @return {JSX.Element} The rendered PostExcerptPanel component.
12644 */
12645 function PostExcerptPanel() {
12646 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12647 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExcerptPanel, {})
12648 });
12649 }
12650 function PrivatePostExcerptPanel() {
12651 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12652 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateExcerpt, {})
12653 });
12654 }
12655 function PrivateExcerpt() {
12656 const {
12657 shouldRender,
12658 excerpt,
12659 shouldBeUsedAsDescription,
12660 allowEditing
12661 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12662 const {
12663 getCurrentPostType,
12664 getCurrentPostId,
12665 getEditedPostAttribute,
12666 isEditorPanelEnabled
12667 } = select(store_store);
12668 const postType = getCurrentPostType();
12669 const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
12670 const isPattern = postType === 'wp_block';
12671 // These post types use the `excerpt` field as a description semantically, so we need to
12672 // handle proper labeling and some flows where we should always render them as text.
12673 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart || isPattern;
12674 const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
12675 // We need to fetch the entity in this case to check if we'll allow editing.
12676 const template = isTemplateOrTemplatePart && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, getCurrentPostId());
12677 // For post types that use excerpt as description, we do not abide
12678 // by the `isEnabled` panel flag in order to render them as text.
12679 const _shouldRender = isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) || _shouldBeUsedAsDescription;
12680 return {
12681 excerpt: getEditedPostAttribute(_usedAttribute),
12682 shouldRender: _shouldRender,
12683 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
12684 // If we should render, allow editing for all post types that are not used as description.
12685 // For the rest allow editing only for user generated entities.
12686 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template && template.source === TEMPLATE_ORIGINS.custom && !template.has_theme_file)
12687 };
12688 }, []);
12689 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12690 const label = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt');
12691 // Memoize popoverProps to avoid returning a new object every time.
12692 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12693 // Anchor the popover to the middle of the entire row so that it doesn't
12694 // move around when the label changes.
12695 anchor: popoverAnchor,
12696 'aria-label': label,
12697 headerTitle: label,
12698 placement: 'left-start',
12699 offset: 36,
12700 shift: true
12701 }), [popoverAnchor, label]);
12702 if (!shouldRender) {
12703 return false;
12704 }
12705 const excerptText = !!excerpt && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12706 align: "left",
12707 numberOfLines: 4,
12708 truncate: true,
12709 children: excerpt
12710 });
12711 if (!allowEditing) {
12712 return excerptText;
12713 }
12714 const excerptPlaceholder = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Add a description…') : (0,external_wp_i18n_namespaceObject.__)('Add an excerpt…');
12715 const triggerEditLabel = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Edit description') : (0,external_wp_i18n_namespaceObject.__)('Edit excerpt');
12716 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
12717 children: [excerptText, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12718 className: "editor-post-excerpt__dropdown",
12719 contentClassName: "editor-post-excerpt__dropdown__content",
12720 popoverProps: popoverProps,
12721 focusOnMount: true,
12722 ref: setPopoverAnchor,
12723 renderToggle: ({
12724 onToggle
12725 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12726 className: "editor-post-excerpt__dropdown__trigger",
12727 onClick: onToggle,
12728 variant: "link",
12729 children: excerptText ? triggerEditLabel : excerptPlaceholder
12730 }),
12731 renderContent: ({
12732 onClose
12733 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12734 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12735 title: label,
12736 onClose: onClose
12737 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
12738 spacing: 4,
12739 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12740 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12741 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {
12742 hideLabelFromVision: true,
12743 updateOnBlur: true
12744 }), fills]
12745 })
12746 })
12747 })]
12748 })
12749 })]
12750 });
12751 }
12752
12753 ;// CONCATENATED MODULE: external ["wp","blob"]
12754 const external_wp_blob_namespaceObject = window["wp"]["blob"];
12755 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/theme-support-check/index.js
12756 /**
12757 * WordPress dependencies
12758 */
12759
12760
12761
12762 /**
12763 * Internal dependencies
12764 */
12765
12766
12767 /**
12768 * Checks if the current theme supports specific features and renders the children if supported.
12769 *
12770 * @param {Object} props The component props.
12771 * @param {Element} props.children The children to render if the theme supports the specified features.
12772 * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
12773 *
12774 * @return {JSX.Element|null} The rendered children if the theme supports the specified features, otherwise null.
12775 */
12776 function ThemeSupportCheck({
12777 children,
12778 supportKeys
12779 }) {
12780 const {
12781 postType,
12782 themeSupports
12783 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12784 return {
12785 postType: select(store_store).getEditedPostAttribute('type'),
12786 themeSupports: select(external_wp_coreData_namespaceObject.store).getThemeSupports()
12787 };
12788 }, []);
12789 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
12790 var _themeSupports$key;
12791 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false;
12792 // 'post-thumbnails' can be boolean or an array of post types.
12793 // In the latter case, we need to verify `postType` exists
12794 // within `supported`. If `postType` isn't passed, then the check
12795 // should fail.
12796 if ('post-thumbnails' === key && Array.isArray(supported)) {
12797 return supported.includes(postType);
12798 }
12799 return supported;
12800 });
12801 if (!isSupported) {
12802 return null;
12803 }
12804 return children;
12805 }
12806
12807 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/check.js
12808 /**
12809 * Internal dependencies
12810 */
12811
12812
12813
12814 /**
12815 * Wrapper component that renders its children only if the post type supports a featured image
12816 * and the theme supports post thumbnails.
12817 *
12818 * @param {Object} props Props.
12819 * @param {Element} props.children Children to be rendered.
12820 *
12821 * @return {Component} The component to be rendered.
12822 */
12823
12824 function PostFeaturedImageCheck({
12825 children
12826 }) {
12827 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ThemeSupportCheck, {
12828 supportKeys: "post-thumbnails",
12829 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12830 supportKeys: "thumbnail",
12831 children: children
12832 })
12833 });
12834 }
12835 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
12836
12837 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/index.js
12838 /**
12839 * WordPress dependencies
12840 */
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851 /**
12852 * Internal dependencies
12853 */
12854
12855
12856
12857
12858 const ALLOWED_MEDIA_TYPES = ['image'];
12859
12860 // Used when labels from post type were not yet loaded or when they are not present.
12861 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
12862 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Add a featured image');
12863 const instructions = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
12864 children: (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')
12865 });
12866 function getMediaDetails(media, postId) {
12867 var _media$media_details$, _media$media_details$2;
12868 if (!media) {
12869 return {};
12870 }
12871 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
12872 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) {
12873 return {
12874 mediaWidth: media.media_details.sizes[defaultSize].width,
12875 mediaHeight: media.media_details.sizes[defaultSize].height,
12876 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
12877 };
12878 }
12879
12880 // Use fallbackSize when defaultSize is not available.
12881 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
12882 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) {
12883 return {
12884 mediaWidth: media.media_details.sizes[fallbackSize].width,
12885 mediaHeight: media.media_details.sizes[fallbackSize].height,
12886 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
12887 };
12888 }
12889
12890 // Use full image size when fallbackSize and defaultSize are not available.
12891 return {
12892 mediaWidth: media.media_details.width,
12893 mediaHeight: media.media_details.height,
12894 mediaSourceUrl: media.source_url
12895 };
12896 }
12897 function PostFeaturedImage({
12898 currentPostId,
12899 featuredImageId,
12900 onUpdateImage,
12901 onRemoveImage,
12902 media,
12903 postType,
12904 noticeUI,
12905 noticeOperations
12906 }) {
12907 const toggleRef = (0,external_wp_element_namespaceObject.useRef)();
12908 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
12909 const {
12910 getSettings
12911 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
12912 const {
12913 mediaSourceUrl
12914 } = getMediaDetails(media, currentPostId);
12915 function onDropFiles(filesList) {
12916 getSettings().mediaUpload({
12917 allowedTypes: ALLOWED_MEDIA_TYPES,
12918 filesList,
12919 onFileChange([image]) {
12920 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
12921 setIsLoading(true);
12922 return;
12923 }
12924 if (image) {
12925 onUpdateImage(image);
12926 }
12927 setIsLoading(false);
12928 },
12929 onError(message) {
12930 noticeOperations.removeAllNotices();
12931 noticeOperations.createErrorNotice(message);
12932 }
12933 });
12934 }
12935 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_featured_image_check, {
12936 children: [noticeUI, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12937 className: "editor-post-featured-image",
12938 children: [media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12939 id: `editor-post-featured-image-${featuredImageId}-describedby`,
12940 className: "hidden",
12941 children: [media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12942 // Translators: %s: The selected image alt text.
12943 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12944 // Translators: %s: The selected image filename.
12945 (0,external_wp_i18n_namespaceObject.__)('The current image has no alternative text. The file name is: %s'), media.media_details.sizes?.full?.file || media.slug)]
12946 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
12947 fallback: instructions,
12948 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, {
12949 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
12950 onSelect: onUpdateImage,
12951 unstableFeaturedImageFlow: true,
12952 allowedTypes: ALLOWED_MEDIA_TYPES,
12953 modalClass: "editor-post-featured-image__media-modal",
12954 render: ({
12955 open
12956 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12957 className: "editor-post-featured-image__container",
12958 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
12959 ref: toggleRef,
12960 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
12961 onClick: open,
12962 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the image'),
12963 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
12964 children: [!!featuredImageId && media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
12965 className: "editor-post-featured-image__preview-image",
12966 src: mediaSourceUrl,
12967 alt: ""
12968 }), isLoading && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)]
12969 }), !!featuredImageId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
12970 className: "editor-post-featured-image__actions",
12971 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12972 className: "editor-post-featured-image__action",
12973 onClick: open,
12974 children: (0,external_wp_i18n_namespaceObject.__)('Replace')
12975 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12976 className: "editor-post-featured-image__action",
12977 onClick: () => {
12978 onRemoveImage();
12979 toggleRef.current.focus();
12980 },
12981 children: (0,external_wp_i18n_namespaceObject.__)('Remove')
12982 })]
12983 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
12984 onFilesDrop: onDropFiles
12985 })]
12986 }),
12987 value: featuredImageId
12988 })
12989 })]
12990 })]
12991 });
12992 }
12993 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
12994 const {
12995 getMedia,
12996 getPostType
12997 } = select(external_wp_coreData_namespaceObject.store);
12998 const {
12999 getCurrentPostId,
13000 getEditedPostAttribute
13001 } = select(store_store);
13002 const featuredImageId = getEditedPostAttribute('featured_media');
13003 return {
13004 media: featuredImageId ? getMedia(featuredImageId, {
13005 context: 'view'
13006 }) : null,
13007 currentPostId: getCurrentPostId(),
13008 postType: getPostType(getEditedPostAttribute('type')),
13009 featuredImageId
13010 };
13011 });
13012 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
13013 noticeOperations
13014 }, {
13015 select
13016 }) => {
13017 const {
13018 editPost
13019 } = dispatch(store_store);
13020 return {
13021 onUpdateImage(image) {
13022 editPost({
13023 featured_media: image.id
13024 });
13025 },
13026 onDropImage(filesList) {
13027 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
13028 allowedTypes: ['image'],
13029 filesList,
13030 onFileChange([image]) {
13031 editPost({
13032 featured_media: image.id
13033 });
13034 },
13035 onError(message) {
13036 noticeOperations.removeAllNotices();
13037 noticeOperations.createErrorNotice(message);
13038 }
13039 });
13040 },
13041 onRemoveImage() {
13042 editPost({
13043 featured_media: 0
13044 });
13045 }
13046 };
13047 });
13048
13049 /**
13050 * Renders the component for managing the featured image of a post.
13051 *
13052 * @param {Object} props Props.
13053 * @param {number} props.currentPostId ID of the current post.
13054 * @param {number} props.featuredImageId ID of the featured image.
13055 * @param {Function} props.onUpdateImage Function to call when the image is updated.
13056 * @param {Function} props.onRemoveImage Function to call when the image is removed.
13057 * @param {Object} props.media The media object representing the featured image.
13058 * @param {string} props.postType Post type.
13059 * @param {Element} props.noticeUI UI for displaying notices.
13060 * @param {Object} props.noticeOperations Operations for managing notices.
13061 *
13062 * @return {Element} Component to be rendered .
13063 */
13064 /* harmony default export */ const post_featured_image = ((0,external_wp_compose_namespaceObject.compose)(external_wp_components_namespaceObject.withNotices, applyWithSelect, applyWithDispatch, (0,external_wp_components_namespaceObject.withFilters)('editor.PostFeaturedImage'))(PostFeaturedImage));
13065
13066 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/panel.js
13067 /**
13068 * WordPress dependencies
13069 */
13070
13071
13072
13073
13074
13075 /**
13076 * Internal dependencies
13077 */
13078
13079
13080
13081
13082 const post_featured_image_panel_PANEL_NAME = 'featured-image';
13083
13084 /**
13085 * Renders the panel for the post featured image.
13086 *
13087 * @param {Object} props Props.
13088 * @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
13089 *
13090 * @return {Component|null} The component to be rendered.
13091 * Return Null if the editor panel is disabled for featured image.
13092 */
13093 function PostFeaturedImagePanel({
13094 withPanelBody = true
13095 }) {
13096 var _postType$labels$feat;
13097 const {
13098 postType,
13099 isEnabled,
13100 isOpened
13101 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13102 const {
13103 getEditedPostAttribute,
13104 isEditorPanelEnabled,
13105 isEditorPanelOpened
13106 } = select(store_store);
13107 const {
13108 getPostType
13109 } = select(external_wp_coreData_namespaceObject.store);
13110 return {
13111 postType: getPostType(getEditedPostAttribute('type')),
13112 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME),
13113 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME)
13114 };
13115 }, []);
13116 const {
13117 toggleEditorPanelOpened
13118 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13119 if (!isEnabled) {
13120 return null;
13121 }
13122 if (!withPanelBody) {
13123 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
13124 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
13125 });
13126 }
13127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
13128 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13129 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'),
13130 opened: isOpened,
13131 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME),
13132 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
13133 })
13134 });
13135 }
13136
13137 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/check.js
13138 /**
13139 * WordPress dependencies
13140 */
13141
13142
13143 /**
13144 * Internal dependencies
13145 */
13146
13147
13148
13149 function PostFormatCheck({
13150 children
13151 }) {
13152 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []);
13153 if (disablePostFormats) {
13154 return null;
13155 }
13156 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
13157 supportKeys: "post-formats",
13158 children: children
13159 });
13160 }
13161
13162 /**
13163 * Component check if there are any post formats.
13164 *
13165 * @param {Object} props The component props.
13166 * @param {Element} props.children The child elements to render.
13167 *
13168 * @return {Component|null} The rendered component or null if post formats are disabled.
13169 */
13170 /* harmony default export */ const post_format_check = (PostFormatCheck);
13171
13172 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/index.js
13173 /**
13174 * WordPress dependencies
13175 */
13176
13177
13178
13179
13180
13181
13182 /**
13183 * Internal dependencies
13184 */
13185
13186
13187
13188 // All WP post formats, sorted alphabetically by translated name.
13189
13190
13191 const POST_FORMATS = [{
13192 id: 'aside',
13193 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
13194 }, {
13195 id: 'audio',
13196 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
13197 }, {
13198 id: 'chat',
13199 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
13200 }, {
13201 id: 'gallery',
13202 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
13203 }, {
13204 id: 'image',
13205 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
13206 }, {
13207 id: 'link',
13208 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
13209 }, {
13210 id: 'quote',
13211 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
13212 }, {
13213 id: 'standard',
13214 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
13215 }, {
13216 id: 'status',
13217 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
13218 }, {
13219 id: 'video',
13220 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
13221 }].sort((a, b) => {
13222 const normalizedA = a.caption.toUpperCase();
13223 const normalizedB = b.caption.toUpperCase();
13224 if (normalizedA < normalizedB) {
13225 return -1;
13226 }
13227 if (normalizedA > normalizedB) {
13228 return 1;
13229 }
13230 return 0;
13231 });
13232
13233 /**
13234 * `PostFormat` a component that allows changing the post format while also providing a suggestion for the current post.
13235 *
13236 * @example
13237 * ```jsx
13238 * <PostFormat />
13239 * ```
13240 *
13241 * @return {JSX.Element} The rendered PostFormat component.
13242 */
13243 function PostFormat() {
13244 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
13245 const postFormatSelectorId = `post-format-selector-${instanceId}`;
13246 const {
13247 postFormat,
13248 suggestedFormat,
13249 supportedFormats
13250 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13251 const {
13252 getEditedPostAttribute,
13253 getSuggestedPostFormat
13254 } = select(store_store);
13255 const _postFormat = getEditedPostAttribute('format');
13256 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
13257 return {
13258 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
13259 suggestedFormat: getSuggestedPostFormat(),
13260 supportedFormats: themeSupports.formats
13261 };
13262 }, []);
13263 const formats = POST_FORMATS.filter(format => {
13264 // Ensure current format is always in the set.
13265 // The current format may not be a format supported by the theme.
13266 return supportedFormats?.includes(format.id) || postFormat === format.id;
13267 });
13268 const suggestion = formats.find(format => format.id === suggestedFormat);
13269 const {
13270 editPost
13271 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13272 const onUpdatePostFormat = format => editPost({
13273 format
13274 });
13275 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
13276 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13277 className: "editor-post-format",
13278 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
13279 className: "editor-post-format__options",
13280 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'),
13281 selected: postFormat,
13282 onChange: format => onUpdatePostFormat(format),
13283 id: postFormatSelectorId,
13284 options: formats.map(format => ({
13285 label: format.caption,
13286 value: format.id
13287 })),
13288 hideLabelFromVision: true
13289 }), suggestion && suggestion.id !== postFormat && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13290 className: "editor-post-format__suggestion",
13291 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13292 variant: "link",
13293 onClick: () => onUpdatePostFormat(suggestion.id),
13294 children: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
13295 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption)
13296 })
13297 })]
13298 })
13299 });
13300 }
13301
13302 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/backup.js
13303 /**
13304 * WordPress dependencies
13305 */
13306
13307
13308 const backup = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13309 xmlns: "http://www.w3.org/2000/svg",
13310 viewBox: "0 0 24 24",
13311 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13312 d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z"
13313 })
13314 });
13315 /* harmony default export */ const library_backup = (backup);
13316
13317 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/check.js
13318 /**
13319 * WordPress dependencies
13320 */
13321
13322
13323 /**
13324 * Internal dependencies
13325 */
13326
13327
13328
13329 /**
13330 * Wrapper component that renders its children if the post has more than one revision.
13331 *
13332 * @param {Object} props Props.
13333 * @param {Element} props.children Children to be rendered.
13334 *
13335 * @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
13336 */
13337
13338 function PostLastRevisionCheck({
13339 children
13340 }) {
13341 const {
13342 lastRevisionId,
13343 revisionsCount
13344 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13345 const {
13346 getCurrentPostLastRevisionId,
13347 getCurrentPostRevisionsCount
13348 } = select(store_store);
13349 return {
13350 lastRevisionId: getCurrentPostLastRevisionId(),
13351 revisionsCount: getCurrentPostRevisionsCount()
13352 };
13353 }, []);
13354 if (!lastRevisionId || revisionsCount < 2) {
13355 return null;
13356 }
13357 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
13358 supportKeys: "revisions",
13359 children: children
13360 });
13361 }
13362 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck);
13363
13364 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/index.js
13365 /**
13366 * WordPress dependencies
13367 */
13368
13369
13370
13371
13372
13373
13374 /**
13375 * Internal dependencies
13376 */
13377
13378
13379
13380
13381 function usePostLastRevisionInfo() {
13382 return (0,external_wp_data_namespaceObject.useSelect)(select => {
13383 const {
13384 getCurrentPostLastRevisionId,
13385 getCurrentPostRevisionsCount
13386 } = select(store_store);
13387 return {
13388 lastRevisionId: getCurrentPostLastRevisionId(),
13389 revisionsCount: getCurrentPostRevisionsCount()
13390 };
13391 }, []);
13392 }
13393
13394 /**
13395 * Renders the component for displaying the last revision of a post.
13396 *
13397 * @return {Component} The component to be rendered.
13398 */
13399 function PostLastRevision() {
13400 const {
13401 lastRevisionId,
13402 revisionsCount
13403 } = usePostLastRevisionInfo();
13404 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
13405 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13406 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
13407 revision: lastRevisionId
13408 }),
13409 className: "editor-post-last-revision__title",
13410 icon: library_backup,
13411 iconPosition: "right",
13412 text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
13413 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount)
13414 })
13415 });
13416 }
13417 function PrivatePostLastRevision() {
13418 const {
13419 lastRevisionId,
13420 revisionsCount
13421 } = usePostLastRevisionInfo();
13422 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
13423 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
13424 label: (0,external_wp_i18n_namespaceObject.__)('Revisions'),
13425 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13426 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
13427 revision: lastRevisionId
13428 }),
13429 className: "editor-private-post-last-revision__button",
13430 text: revisionsCount,
13431 variant: "tertiary"
13432 })
13433 })
13434 });
13435 }
13436 /* harmony default export */ const post_last_revision = (PostLastRevision);
13437
13438 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/panel.js
13439 /**
13440 * WordPress dependencies
13441 */
13442
13443
13444 /**
13445 * Internal dependencies
13446 */
13447
13448
13449
13450 /**
13451 * Renders the panel for displaying the last revision of a post.
13452 *
13453 * @return {Component} The component to be rendered.
13454 */
13455
13456 function PostLastRevisionPanel() {
13457 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
13458 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13459 className: "editor-post-last-revision__panel",
13460 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision, {})
13461 })
13462 });
13463 }
13464 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel);
13465
13466 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-locked-modal/index.js
13467 /**
13468 * WordPress dependencies
13469 */
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479 /**
13480 * Internal dependencies
13481 */
13482
13483
13484 /**
13485 * A modal component that is displayed when a post is locked for editing by another user.
13486 * The modal provides information about the lock status and options to take over or exit the editor.
13487 *
13488 * @return {JSX.Element|null} The rendered PostLockedModal component.
13489 */
13490
13491
13492
13493 function PostLockedModal() {
13494 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
13495 const hookName = 'core/editor/post-locked-modal-' + instanceId;
13496 const {
13497 autosave,
13498 updatePostLock
13499 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13500 const {
13501 isLocked,
13502 isTakeover,
13503 user,
13504 postId,
13505 postLockUtils,
13506 activePostLock,
13507 postType,
13508 previewLink
13509 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13510 const {
13511 isPostLocked,
13512 isPostLockTakeover,
13513 getPostLockUser,
13514 getCurrentPostId,
13515 getActivePostLock,
13516 getEditedPostAttribute,
13517 getEditedPostPreviewLink,
13518 getEditorSettings
13519 } = select(store_store);
13520 const {
13521 getPostType
13522 } = select(external_wp_coreData_namespaceObject.store);
13523 return {
13524 isLocked: isPostLocked(),
13525 isTakeover: isPostLockTakeover(),
13526 user: getPostLockUser(),
13527 postId: getCurrentPostId(),
13528 postLockUtils: getEditorSettings().postLockUtils,
13529 activePostLock: getActivePostLock(),
13530 postType: getPostType(getEditedPostAttribute('type')),
13531 previewLink: getEditedPostPreviewLink()
13532 };
13533 }, []);
13534 (0,external_wp_element_namespaceObject.useEffect)(() => {
13535 /**
13536 * Keep the lock refreshed.
13537 *
13538 * When the user does not send a heartbeat in a heartbeat-tick
13539 * the user is no longer editing and another user can start editing.
13540 *
13541 * @param {Object} data Data to send in the heartbeat request.
13542 */
13543 function sendPostLock(data) {
13544 if (isLocked) {
13545 return;
13546 }
13547 data['wp-refresh-post-lock'] = {
13548 lock: activePostLock,
13549 post_id: postId
13550 };
13551 }
13552
13553 /**
13554 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
13555 *
13556 * @param {Object} data Data received in the heartbeat request
13557 */
13558 function receivePostLock(data) {
13559 if (!data['wp-refresh-post-lock']) {
13560 return;
13561 }
13562 const received = data['wp-refresh-post-lock'];
13563 if (received.lock_error) {
13564 // Auto save and display the takeover modal.
13565 autosave();
13566 updatePostLock({
13567 isLocked: true,
13568 isTakeover: true,
13569 user: {
13570 name: received.lock_error.name,
13571 avatar: received.lock_error.avatar_src_2x
13572 }
13573 });
13574 } else if (received.new_lock) {
13575 updatePostLock({
13576 isLocked: false,
13577 activePostLock: received.new_lock
13578 });
13579 }
13580 }
13581
13582 /**
13583 * Unlock the post before the window is exited.
13584 */
13585 function releasePostLock() {
13586 if (isLocked || !activePostLock) {
13587 return;
13588 }
13589 const data = new window.FormData();
13590 data.append('action', 'wp-remove-post-lock');
13591 data.append('_wpnonce', postLockUtils.unlockNonce);
13592 data.append('post_ID', postId);
13593 data.append('active_post_lock', activePostLock);
13594 if (window.navigator.sendBeacon) {
13595 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
13596 } else {
13597 const xhr = new window.XMLHttpRequest();
13598 xhr.open('POST', postLockUtils.ajaxUrl, false);
13599 xhr.send(data);
13600 }
13601 }
13602
13603 // Details on these events on the Heartbeat API docs
13604 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
13605 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
13606 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
13607 window.addEventListener('beforeunload', releasePostLock);
13608 return () => {
13609 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
13610 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
13611 window.removeEventListener('beforeunload', releasePostLock);
13612 };
13613 }, []);
13614 if (!isLocked) {
13615 return null;
13616 }
13617 const userDisplayName = user.name;
13618 const userAvatar = user.avatar;
13619 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
13620 'get-post-lock': '1',
13621 lockKey: true,
13622 post: postId,
13623 action: 'edit',
13624 _wpnonce: postLockUtils.nonce
13625 });
13626 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
13627 post_type: postType?.slug
13628 });
13629 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
13630 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
13631 title: isTakeover ? (0,external_wp_i18n_namespaceObject.__)('Someone else has taken over this post') : (0,external_wp_i18n_namespaceObject.__)('This post is already being edited'),
13632 focusOnMount: true,
13633 shouldCloseOnClickOutside: false,
13634 shouldCloseOnEsc: false,
13635 isDismissible: false,
13636 size: "medium",
13637 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13638 alignment: "top",
13639 spacing: 6,
13640 children: [!!userAvatar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
13641 src: userAvatar,
13642 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
13643 className: "editor-post-locked-modal__avatar",
13644 width: 64,
13645 height: 64
13646 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13647 children: [!!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13648 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13649 (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), {
13650 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13651 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13652 href: previewLink,
13653 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13654 })
13655 })
13656 }), !isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13657 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13658 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13659 (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), {
13660 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13661 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13662 href: previewLink,
13663 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13664 })
13665 })
13666 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13667 children: (0,external_wp_i18n_namespaceObject.__)('If you take over, the other user will lose editing control to the post, but their changes will be saved.')
13668 })]
13669 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13670 className: "editor-post-locked-modal__buttons",
13671 justify: "flex-end",
13672 children: [!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13673 variant: "tertiary",
13674 href: unlockUrl,
13675 children: (0,external_wp_i18n_namespaceObject.__)('Take over')
13676 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13677 variant: "primary",
13678 href: allPostsUrl,
13679 children: allPostsLabel
13680 })]
13681 })]
13682 })]
13683 })
13684 });
13685 }
13686
13687 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/check.js
13688 /**
13689 * WordPress dependencies
13690 */
13691
13692
13693 /**
13694 * Internal dependencies
13695 */
13696
13697
13698 /**
13699 * This component checks the publishing status of the current post.
13700 * If the post is already published or the user doesn't have the
13701 * capability to publish, it returns null.
13702 *
13703 * @param {Object} props Component properties.
13704 * @param {Element} props.children Children to be rendered.
13705 *
13706 * @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
13707 */
13708 function PostPendingStatusCheck({
13709 children
13710 }) {
13711 const {
13712 hasPublishAction,
13713 isPublished
13714 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13715 var _getCurrentPost$_link;
13716 const {
13717 isCurrentPostPublished,
13718 getCurrentPost
13719 } = select(store_store);
13720 return {
13721 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13722 isPublished: isCurrentPostPublished()
13723 };
13724 }, []);
13725 if (isPublished || !hasPublishAction) {
13726 return null;
13727 }
13728 return children;
13729 }
13730 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck);
13731
13732 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/index.js
13733 /**
13734 * WordPress dependencies
13735 */
13736
13737
13738
13739
13740 /**
13741 * Internal dependencies
13742 */
13743
13744
13745
13746 /**
13747 * A component for displaying and toggling the pending status of a post.
13748 *
13749 * @return {JSX.Element} The rendered component.
13750 */
13751
13752 function PostPendingStatus() {
13753 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []);
13754 const {
13755 editPost
13756 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13757 const togglePendingStatus = () => {
13758 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
13759 editPost({
13760 status: updatedStatus
13761 });
13762 };
13763 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pending_status_check, {
13764 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
13765 __nextHasNoMarginBottom: true,
13766 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
13767 checked: status === 'pending',
13768 onChange: togglePendingStatus
13769 })
13770 });
13771 }
13772 /* harmony default export */ const post_pending_status = (PostPendingStatus);
13773
13774 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-preview-button/index.js
13775 /**
13776 * WordPress dependencies
13777 */
13778
13779
13780
13781
13782
13783
13784
13785 /**
13786 * Internal dependencies
13787 */
13788
13789
13790
13791
13792 function writeInterstitialMessage(targetDocument) {
13793 let markup = (0,external_wp_element_namespaceObject.renderToString)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13794 className: "editor-post-preview-button__interstitial-message",
13795 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
13796 xmlns: "http://www.w3.org/2000/svg",
13797 viewBox: "0 0 96 96",
13798 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13799 className: "outer",
13800 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
13801 fill: "none"
13802 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13803 className: "inner",
13804 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z",
13805 fill: "none"
13806 })]
13807 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13808 children: (0,external_wp_i18n_namespaceObject.__)('Generating preview…')
13809 })]
13810 }));
13811 markup += `
13812 <style>
13813 body {
13814 margin: 0;
13815 }
13816 .editor-post-preview-button__interstitial-message {
13817 display: flex;
13818 flex-direction: column;
13819 align-items: center;
13820 justify-content: center;
13821 height: 100vh;
13822 width: 100vw;
13823 }
13824 @-webkit-keyframes paint {
13825 0% {
13826 stroke-dashoffset: 0;
13827 }
13828 }
13829 @-moz-keyframes paint {
13830 0% {
13831 stroke-dashoffset: 0;
13832 }
13833 }
13834 @-o-keyframes paint {
13835 0% {
13836 stroke-dashoffset: 0;
13837 }
13838 }
13839 @keyframes paint {
13840 0% {
13841 stroke-dashoffset: 0;
13842 }
13843 }
13844 .editor-post-preview-button__interstitial-message svg {
13845 width: 192px;
13846 height: 192px;
13847 stroke: #555d66;
13848 stroke-width: 0.75;
13849 }
13850 .editor-post-preview-button__interstitial-message svg .outer,
13851 .editor-post-preview-button__interstitial-message svg .inner {
13852 stroke-dasharray: 280;
13853 stroke-dashoffset: 280;
13854 -webkit-animation: paint 1.5s ease infinite alternate;
13855 -moz-animation: paint 1.5s ease infinite alternate;
13856 -o-animation: paint 1.5s ease infinite alternate;
13857 animation: paint 1.5s ease infinite alternate;
13858 }
13859 p {
13860 text-align: center;
13861 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13862 }
13863 </style>
13864 `;
13865
13866 /**
13867 * Filters the interstitial message shown when generating previews.
13868 *
13869 * @param {string} markup The preview interstitial markup.
13870 */
13871 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
13872 targetDocument.write(markup);
13873 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
13874 targetDocument.close();
13875 }
13876
13877 /**
13878 * Renders a button that opens a new window or tab for the preview,
13879 * writes the interstitial message to this window, and then navigates
13880 * to the actual preview link. The button is not rendered if the post
13881 * is not viewable and disabled if the post is not saveable.
13882 *
13883 * @param {Object} props The component props.
13884 * @param {string} props.className The class name for the button.
13885 * @param {string} props.textContent The text content for the button.
13886 * @param {boolean} props.forceIsAutosaveable Whether to force autosave.
13887 * @param {string} props.role The role attribute for the button.
13888 * @param {Function} props.onPreview The callback function for preview event.
13889 *
13890 * @return {JSX.Element|null} The rendered button component.
13891 */
13892 function PostPreviewButton({
13893 className,
13894 textContent,
13895 forceIsAutosaveable,
13896 role,
13897 onPreview
13898 }) {
13899 const {
13900 postId,
13901 currentPostLink,
13902 previewLink,
13903 isSaveable,
13904 isViewable
13905 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13906 var _postType$viewable;
13907 const editor = select(store_store);
13908 const core = select(external_wp_coreData_namespaceObject.store);
13909 const postType = core.getPostType(editor.getCurrentPostType('type'));
13910 return {
13911 postId: editor.getCurrentPostId(),
13912 currentPostLink: editor.getCurrentPostAttribute('link'),
13913 previewLink: editor.getEditedPostPreviewLink(),
13914 isSaveable: editor.isEditedPostSaveable(),
13915 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
13916 };
13917 }, []);
13918 const {
13919 __unstableSaveForPreview
13920 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13921 if (!isViewable) {
13922 return null;
13923 }
13924 const targetId = `wp-preview-${postId}`;
13925 const openPreviewWindow = async event => {
13926 // Our Preview button has its 'href' and 'target' set correctly for a11y
13927 // purposes. Unfortunately, though, we can't rely on the default 'click'
13928 // handler since sometimes it incorrectly opens a new tab instead of reusing
13929 // the existing one.
13930 // https://github.com/WordPress/gutenberg/pull/8330
13931 event.preventDefault();
13932
13933 // Open up a Preview tab if needed. This is where we'll show the preview.
13934 const previewWindow = window.open('', targetId);
13935
13936 // Focus the Preview tab. This might not do anything, depending on the browser's
13937 // and user's preferences.
13938 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
13939 previewWindow.focus();
13940 writeInterstitialMessage(previewWindow.document);
13941 const link = await __unstableSaveForPreview({
13942 forceIsAutosaveable
13943 });
13944 previewWindow.location = link;
13945 onPreview?.();
13946 };
13947
13948 // Link to the `?preview=true` URL if we have it, since this lets us see
13949 // changes that were autosaved since the post was last published. Otherwise,
13950 // just link to the post's URL.
13951 const href = previewLink || currentPostLink;
13952 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13953 variant: !className ? 'tertiary' : undefined,
13954 className: className || 'editor-post-preview',
13955 href: href,
13956 target: targetId,
13957 __experimentalIsFocusable: true,
13958 disabled: !isSaveable,
13959 onClick: openPreviewWindow,
13960 role: role,
13961 size: "compact",
13962 children: textContent || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13963 children: [(0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
13964 as: "span",
13965 children: /* translators: accessibility text */
13966 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
13967 })]
13968 })
13969 });
13970 }
13971
13972 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/label.js
13973 /**
13974 * WordPress dependencies
13975 */
13976
13977
13978
13979
13980 /**
13981 * Internal dependencies
13982 */
13983
13984
13985 /**
13986 * Renders the label for the publish button.
13987 *
13988 * @return {string} The label for the publish button.
13989 */
13990 function PublishButtonLabel() {
13991 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
13992 const {
13993 isPublished,
13994 isBeingScheduled,
13995 isSaving,
13996 isPublishing,
13997 hasPublishAction,
13998 isAutosaving,
13999 hasNonPostEntityChanges,
14000 postStatusHasChanged,
14001 postStatus
14002 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14003 var _getCurrentPost$_link;
14004 const {
14005 isCurrentPostPublished,
14006 isEditedPostBeingScheduled,
14007 isSavingPost,
14008 isPublishingPost,
14009 getCurrentPost,
14010 getCurrentPostType,
14011 isAutosavingPost,
14012 getPostEdits,
14013 getEditedPostAttribute
14014 } = select(store_store);
14015 return {
14016 isPublished: isCurrentPostPublished(),
14017 isBeingScheduled: isEditedPostBeingScheduled(),
14018 isSaving: isSavingPost(),
14019 isPublishing: isPublishingPost(),
14020 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
14021 postType: getCurrentPostType(),
14022 isAutosaving: isAutosavingPost(),
14023 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
14024 postStatusHasChanged: !!getPostEdits()?.status,
14025 postStatus: getEditedPostAttribute('status')
14026 };
14027 }, []);
14028 if (isPublishing) {
14029 /* translators: button label text should, if possible, be under 16 characters. */
14030 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
14031 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
14032 /* translators: button label text should, if possible, be under 16 characters. */
14033 return (0,external_wp_i18n_namespaceObject.__)('Saving…');
14034 }
14035 if (!hasPublishAction) {
14036 // TODO: this is because "Submit for review" string is too long in some languages.
14037 // @see https://github.com/WordPress/gutenberg/issues/10475
14038 return isSmallerThanMediumViewport ? (0,external_wp_i18n_namespaceObject.__)('Publish') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
14039 }
14040 if (hasNonPostEntityChanges || isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || !postStatusHasChanged && postStatus === 'future') {
14041 return (0,external_wp_i18n_namespaceObject.__)('Save');
14042 }
14043 if (isBeingScheduled) {
14044 return (0,external_wp_i18n_namespaceObject.__)('Schedule');
14045 }
14046 return (0,external_wp_i18n_namespaceObject.__)('Publish');
14047 }
14048
14049 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/index.js
14050 /**
14051 * WordPress dependencies
14052 */
14053
14054
14055
14056
14057
14058 /**
14059 * Internal dependencies
14060 */
14061
14062
14063
14064
14065
14066 const post_publish_button_noop = () => {};
14067 class PostPublishButton extends external_wp_element_namespaceObject.Component {
14068 constructor(props) {
14069 super(props);
14070 this.buttonNode = (0,external_wp_element_namespaceObject.createRef)();
14071 this.createOnClick = this.createOnClick.bind(this);
14072 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
14073 this.state = {
14074 entitiesSavedStatesCallback: false
14075 };
14076 }
14077 componentDidMount() {
14078 if (this.props.focusOnMount) {
14079 // This timeout is necessary to make sure the `useEffect` hook of
14080 // `useFocusReturn` gets the correct element (the button that opens the
14081 // PostPublishPanel) otherwise it will get this button.
14082 this.timeoutID = setTimeout(() => {
14083 this.buttonNode.current.focus();
14084 }, 0);
14085 }
14086 }
14087 componentWillUnmount() {
14088 clearTimeout(this.timeoutID);
14089 }
14090 createOnClick(callback) {
14091 return (...args) => {
14092 const {
14093 hasNonPostEntityChanges,
14094 hasPostMetaChanges,
14095 setEntitiesSavedStatesCallback,
14096 isPublished
14097 } = this.props;
14098 // If a post with non-post entities is published, but the user
14099 // elects to not save changes to the non-post entities, those
14100 // entities will still be dirty when the Publish button is clicked.
14101 // We also need to check that the `setEntitiesSavedStatesCallback`
14102 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
14103 //
14104 // TODO: Explore how to manage `hasPostMetaChanges` and pre-publish workflow properly.
14105 if ((hasNonPostEntityChanges || hasPostMetaChanges && isPublished) && setEntitiesSavedStatesCallback) {
14106 // The modal for multiple entity saving will open,
14107 // hold the callback for saving/publishing the post
14108 // so that we can call it if the post entity is checked.
14109 this.setState({
14110 entitiesSavedStatesCallback: () => callback(...args)
14111 });
14112
14113 // Open the save panel by setting its callback.
14114 // To set a function on the useState hook, we must set it
14115 // with another function (() => myFunction). Passing the
14116 // function on its own will cause an error when called.
14117 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates);
14118 return post_publish_button_noop;
14119 }
14120 return callback(...args);
14121 };
14122 }
14123 closeEntitiesSavedStates(savedEntities) {
14124 const {
14125 postType,
14126 postId
14127 } = this.props;
14128 const {
14129 entitiesSavedStatesCallback
14130 } = this.state;
14131 this.setState({
14132 entitiesSavedStatesCallback: false
14133 }, () => {
14134 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
14135 // The post entity was checked, call the held callback from `createOnClick`.
14136 entitiesSavedStatesCallback();
14137 }
14138 });
14139 }
14140 render() {
14141 const {
14142 forceIsDirty,
14143 hasPublishAction,
14144 isBeingScheduled,
14145 isOpen,
14146 isPostSavingLocked,
14147 isPublishable,
14148 isPublished,
14149 isSaveable,
14150 isSaving,
14151 isAutoSaving,
14152 isToggle,
14153 savePostStatus,
14154 onSubmit = post_publish_button_noop,
14155 onToggle,
14156 visibility,
14157 hasNonPostEntityChanges,
14158 isSavingNonPostEntityChanges,
14159 postStatus,
14160 postStatusHasChanged
14161 } = this.props;
14162 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
14163 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
14164
14165 // If the new status has not changed explicitely, we derive it from
14166 // other factors, like having a publish action, etc.. We need to preserve
14167 // this because it affects when to show the pre and post publish panels.
14168 // If it has changed though explicitely, we need to respect that.
14169 let publishStatus = 'publish';
14170 if (postStatusHasChanged) {
14171 publishStatus = postStatus;
14172 } else if (!hasPublishAction) {
14173 publishStatus = 'pending';
14174 } else if (visibility === 'private') {
14175 publishStatus = 'private';
14176 } else if (isBeingScheduled) {
14177 publishStatus = 'future';
14178 }
14179 const onClickButton = () => {
14180 if (isButtonDisabled) {
14181 return;
14182 }
14183 onSubmit();
14184 savePostStatus(publishStatus);
14185 };
14186
14187 // Callback to open the publish panel.
14188 const onClickToggle = () => {
14189 if (isToggleDisabled) {
14190 return;
14191 }
14192 onToggle();
14193 };
14194 const buttonProps = {
14195 'aria-disabled': isButtonDisabled,
14196 className: 'editor-post-publish-button',
14197 isBusy: !isAutoSaving && isSaving,
14198 variant: 'primary',
14199 onClick: this.createOnClick(onClickButton)
14200 };
14201 const toggleProps = {
14202 'aria-disabled': isToggleDisabled,
14203 'aria-expanded': isOpen,
14204 className: 'editor-post-publish-panel__toggle',
14205 isBusy: isSaving && isPublished,
14206 variant: 'primary',
14207 size: 'compact',
14208 onClick: this.createOnClick(onClickToggle)
14209 };
14210 const componentProps = isToggle ? toggleProps : buttonProps;
14211 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14212 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
14213 ref: this.buttonNode,
14214 ...componentProps,
14215 className: `${componentProps.className} editor-post-publish-button__button`,
14216 size: "compact",
14217 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PublishButtonLabel, {})
14218 })
14219 });
14220 }
14221 }
14222
14223 /**
14224 * Renders the publish button.
14225 */
14226 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
14227 var _getCurrentPost$_link;
14228 const {
14229 isSavingPost,
14230 isAutosavingPost,
14231 isEditedPostBeingScheduled,
14232 getEditedPostVisibility,
14233 isCurrentPostPublished,
14234 isEditedPostSaveable,
14235 isEditedPostPublishable,
14236 isPostSavingLocked,
14237 getCurrentPost,
14238 getCurrentPostType,
14239 getCurrentPostId,
14240 hasNonPostEntityChanges,
14241 isSavingNonPostEntityChanges,
14242 getEditedPostAttribute,
14243 getPostEdits,
14244 hasPostMetaChanges
14245 } = unlock(select(store_store));
14246 return {
14247 isSaving: isSavingPost(),
14248 isAutoSaving: isAutosavingPost(),
14249 isBeingScheduled: isEditedPostBeingScheduled(),
14250 visibility: getEditedPostVisibility(),
14251 isSaveable: isEditedPostSaveable(),
14252 isPostSavingLocked: isPostSavingLocked(),
14253 isPublishable: isEditedPostPublishable(),
14254 isPublished: isCurrentPostPublished(),
14255 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
14256 postType: getCurrentPostType(),
14257 postId: getCurrentPostId(),
14258 postStatus: getEditedPostAttribute('status'),
14259 postStatusHasChanged: getPostEdits()?.status,
14260 hasNonPostEntityChanges: hasNonPostEntityChanges(),
14261 hasPostMetaChanges: hasPostMetaChanges(),
14262 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
14263 };
14264 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
14265 const {
14266 editPost,
14267 savePost
14268 } = dispatch(store_store);
14269 return {
14270 savePostStatus: status => {
14271 editPost({
14272 status
14273 }, {
14274 undoIgnore: true
14275 });
14276 savePost();
14277 }
14278 };
14279 })])(PostPublishButton));
14280
14281 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
14282 /**
14283 * WordPress dependencies
14284 */
14285
14286
14287 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
14288 xmlns: "http://www.w3.org/2000/svg",
14289 viewBox: "-2 -2 24 24",
14290 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
14291 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"
14292 })
14293 });
14294 /* harmony default export */ const library_wordpress = (wordpress);
14295
14296 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/utils.js
14297 /**
14298 * WordPress dependencies
14299 */
14300
14301 const visibilityOptions = {
14302 public: {
14303 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
14304 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
14305 },
14306 private: {
14307 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
14308 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
14309 },
14310 password: {
14311 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
14312 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
14313 }
14314 };
14315
14316 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/index.js
14317 /**
14318 * WordPress dependencies
14319 */
14320
14321
14322
14323
14324
14325
14326
14327 /**
14328 * Internal dependencies
14329 */
14330
14331
14332
14333 /**
14334 * Allows users to set the visibility of a post.
14335 *
14336 * @param {Object} props The component props.
14337 * @param {Function} props.onClose Function to call when the popover is closed.
14338 * @return {JSX.Element} The rendered component.
14339 */
14340
14341
14342 function PostVisibility({
14343 onClose
14344 }) {
14345 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
14346 const {
14347 status,
14348 visibility,
14349 password
14350 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14351 status: select(store_store).getEditedPostAttribute('status'),
14352 visibility: select(store_store).getEditedPostVisibility(),
14353 password: select(store_store).getEditedPostAttribute('password')
14354 }));
14355 const {
14356 editPost,
14357 savePost
14358 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14359 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
14360 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
14361 const setPublic = () => {
14362 editPost({
14363 status: visibility === 'private' ? 'draft' : status,
14364 password: ''
14365 });
14366 setHasPassword(false);
14367 };
14368 const setPrivate = () => {
14369 setShowPrivateConfirmDialog(true);
14370 };
14371 const confirmPrivate = () => {
14372 editPost({
14373 status: 'private',
14374 password: ''
14375 });
14376 setHasPassword(false);
14377 setShowPrivateConfirmDialog(false);
14378 savePost();
14379 };
14380 const handleDialogCancel = () => {
14381 setShowPrivateConfirmDialog(false);
14382 };
14383 const setPasswordProtected = () => {
14384 editPost({
14385 status: visibility === 'private' ? 'draft' : status,
14386 password: password || ''
14387 });
14388 setHasPassword(true);
14389 };
14390 const updatePassword = event => {
14391 editPost({
14392 password: event.target.value
14393 });
14394 };
14395 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14396 className: "editor-post-visibility",
14397 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
14398 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
14399 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
14400 onClose: onClose
14401 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
14402 className: "editor-post-visibility__fieldset",
14403 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
14404 as: "legend",
14405 children: (0,external_wp_i18n_namespaceObject.__)('Visibility')
14406 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14407 instanceId: instanceId,
14408 value: "public",
14409 label: visibilityOptions.public.label,
14410 info: visibilityOptions.public.info,
14411 checked: visibility === 'public' && !hasPassword,
14412 onChange: setPublic
14413 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14414 instanceId: instanceId,
14415 value: "private",
14416 label: visibilityOptions.private.label,
14417 info: visibilityOptions.private.info,
14418 checked: visibility === 'private',
14419 onChange: setPrivate
14420 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14421 instanceId: instanceId,
14422 value: "password",
14423 label: visibilityOptions.password.label,
14424 info: visibilityOptions.password.info,
14425 checked: hasPassword,
14426 onChange: setPasswordProtected
14427 }), hasPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14428 className: "editor-post-visibility__password",
14429 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
14430 as: "label",
14431 htmlFor: `editor-post-visibility__password-input-${instanceId}`,
14432 children: (0,external_wp_i18n_namespaceObject.__)('Create password')
14433 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
14434 className: "editor-post-visibility__password-input",
14435 id: `editor-post-visibility__password-input-${instanceId}`,
14436 type: "text",
14437 onChange: updatePassword,
14438 value: password,
14439 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
14440 })]
14441 })]
14442 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
14443 isOpen: showPrivateConfirmDialog,
14444 onConfirm: confirmPrivate,
14445 onCancel: handleDialogCancel,
14446 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Publish'),
14447 size: "medium",
14448 children: (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')
14449 })]
14450 });
14451 }
14452 function PostVisibilityChoice({
14453 instanceId,
14454 value,
14455 label,
14456 info,
14457 ...props
14458 }) {
14459 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14460 className: "editor-post-visibility__choice",
14461 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
14462 type: "radio",
14463 name: `editor-post-visibility__setting-${instanceId}`,
14464 value: value,
14465 id: `editor-post-${value}-${instanceId}`,
14466 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
14467 className: "editor-post-visibility__radio",
14468 ...props
14469 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
14470 htmlFor: `editor-post-${value}-${instanceId}`,
14471 className: "editor-post-visibility__label",
14472 children: label
14473 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
14474 id: `editor-post-${value}-${instanceId}-description`,
14475 className: "editor-post-visibility__info",
14476 children: info
14477 })]
14478 });
14479 }
14480
14481 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/label.js
14482 /**
14483 * WordPress dependencies
14484 */
14485
14486
14487 /**
14488 * Internal dependencies
14489 */
14490
14491
14492
14493 /**
14494 * Returns the label for the current post visibility setting.
14495 *
14496 * @return {string} Post visibility label.
14497 */
14498 function PostVisibilityLabel() {
14499 return usePostVisibilityLabel();
14500 }
14501
14502 /**
14503 * Get the label for the current post visibility setting.
14504 *
14505 * @return {string} Post visibility label.
14506 */
14507 function usePostVisibilityLabel() {
14508 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
14509 return visibilityOptions[visibility]?.label;
14510 }
14511
14512 ;// CONCATENATED MODULE: ./node_modules/date-fns/toDate.mjs
14513 /**
14514 * @name toDate
14515 * @category Common Helpers
14516 * @summary Convert the given argument to an instance of Date.
14517 *
14518 * @description
14519 * Convert the given argument to an instance of Date.
14520 *
14521 * If the argument is an instance of Date, the function returns its clone.
14522 *
14523 * If the argument is a number, it is treated as a timestamp.
14524 *
14525 * If the argument is none of the above, the function returns Invalid Date.
14526 *
14527 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
14528 *
14529 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14530 *
14531 * @param argument - The value to convert
14532 *
14533 * @returns The parsed date in the local time zone
14534 *
14535 * @example
14536 * // Clone the date:
14537 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
14538 * //=> Tue Feb 11 2014 11:30:30
14539 *
14540 * @example
14541 * // Convert the timestamp to date:
14542 * const result = toDate(1392098430000)
14543 * //=> Tue Feb 11 2014 11:30:30
14544 */
14545 function toDate(argument) {
14546 const argStr = Object.prototype.toString.call(argument);
14547
14548 // Clone the date
14549 if (
14550 argument instanceof Date ||
14551 (typeof argument === "object" && argStr === "[object Date]")
14552 ) {
14553 // Prevent the date to lose the milliseconds when passed to new Date() in IE10
14554 return new argument.constructor(+argument);
14555 } else if (
14556 typeof argument === "number" ||
14557 argStr === "[object Number]" ||
14558 typeof argument === "string" ||
14559 argStr === "[object String]"
14560 ) {
14561 // TODO: Can we get rid of as?
14562 return new Date(argument);
14563 } else {
14564 // TODO: Can we get rid of as?
14565 return new Date(NaN);
14566 }
14567 }
14568
14569 // Fallback for modularized imports:
14570 /* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate)));
14571
14572 ;// CONCATENATED MODULE: ./node_modules/date-fns/startOfMonth.mjs
14573
14574
14575 /**
14576 * @name startOfMonth
14577 * @category Month Helpers
14578 * @summary Return the start of a month for the given date.
14579 *
14580 * @description
14581 * Return the start of a month for the given date.
14582 * The result will be in the local timezone.
14583 *
14584 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14585 *
14586 * @param date - The original date
14587 *
14588 * @returns The start of a month
14589 *
14590 * @example
14591 * // The start of a month for 2 September 2014 11:55:00:
14592 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14593 * //=> Mon Sep 01 2014 00:00:00
14594 */
14595 function startOfMonth(date) {
14596 const _date = toDate(date);
14597 _date.setDate(1);
14598 _date.setHours(0, 0, 0, 0);
14599 return _date;
14600 }
14601
14602 // Fallback for modularized imports:
14603 /* harmony default export */ const date_fns_startOfMonth = ((/* unused pure expression or super */ null && (startOfMonth)));
14604
14605 ;// CONCATENATED MODULE: ./node_modules/date-fns/endOfMonth.mjs
14606
14607
14608 /**
14609 * @name endOfMonth
14610 * @category Month Helpers
14611 * @summary Return the end of a month for the given date.
14612 *
14613 * @description
14614 * Return the end of a month for the given date.
14615 * The result will be in the local timezone.
14616 *
14617 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14618 *
14619 * @param date - The original date
14620 *
14621 * @returns The end of a month
14622 *
14623 * @example
14624 * // The end of a month for 2 September 2014 11:55:00:
14625 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14626 * //=> Tue Sep 30 2014 23:59:59.999
14627 */
14628 function endOfMonth(date) {
14629 const _date = toDate(date);
14630 const month = _date.getMonth();
14631 _date.setFullYear(_date.getFullYear(), month + 1, 0);
14632 _date.setHours(23, 59, 59, 999);
14633 return _date;
14634 }
14635
14636 // Fallback for modularized imports:
14637 /* harmony default export */ const date_fns_endOfMonth = ((/* unused pure expression or super */ null && (endOfMonth)));
14638
14639 ;// CONCATENATED MODULE: ./node_modules/date-fns/constants.mjs
14640 /**
14641 * @module constants
14642 * @summary Useful constants
14643 * @description
14644 * Collection of useful date constants.
14645 *
14646 * The constants could be imported from `date-fns/constants`:
14647 *
14648 * ```ts
14649 * import { maxTime, minTime } from "./constants/date-fns/constants";
14650 *
14651 * function isAllowedTime(time) {
14652 * return time <= maxTime && time >= minTime;
14653 * }
14654 * ```
14655 */
14656
14657 /**
14658 * @constant
14659 * @name daysInWeek
14660 * @summary Days in 1 week.
14661 */
14662 const daysInWeek = 7;
14663
14664 /**
14665 * @constant
14666 * @name daysInYear
14667 * @summary Days in 1 year.
14668 *
14669 * @description
14670 * How many days in a year.
14671 *
14672 * One years equals 365.2425 days according to the formula:
14673 *
14674 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
14675 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
14676 */
14677 const daysInYear = 365.2425;
14678
14679 /**
14680 * @constant
14681 * @name maxTime
14682 * @summary Maximum allowed time.
14683 *
14684 * @example
14685 * import { maxTime } from "./constants/date-fns/constants";
14686 *
14687 * const isValid = 8640000000000001 <= maxTime;
14688 * //=> false
14689 *
14690 * new Date(8640000000000001);
14691 * //=> Invalid Date
14692 */
14693 const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
14694
14695 /**
14696 * @constant
14697 * @name minTime
14698 * @summary Minimum allowed time.
14699 *
14700 * @example
14701 * import { minTime } from "./constants/date-fns/constants";
14702 *
14703 * const isValid = -8640000000000001 >= minTime;
14704 * //=> false
14705 *
14706 * new Date(-8640000000000001)
14707 * //=> Invalid Date
14708 */
14709 const minTime = -maxTime;
14710
14711 /**
14712 * @constant
14713 * @name millisecondsInWeek
14714 * @summary Milliseconds in 1 week.
14715 */
14716 const millisecondsInWeek = 604800000;
14717
14718 /**
14719 * @constant
14720 * @name millisecondsInDay
14721 * @summary Milliseconds in 1 day.
14722 */
14723 const millisecondsInDay = 86400000;
14724
14725 /**
14726 * @constant
14727 * @name millisecondsInMinute
14728 * @summary Milliseconds in 1 minute
14729 */
14730 const millisecondsInMinute = 60000;
14731
14732 /**
14733 * @constant
14734 * @name millisecondsInHour
14735 * @summary Milliseconds in 1 hour
14736 */
14737 const millisecondsInHour = 3600000;
14738
14739 /**
14740 * @constant
14741 * @name millisecondsInSecond
14742 * @summary Milliseconds in 1 second
14743 */
14744 const millisecondsInSecond = 1000;
14745
14746 /**
14747 * @constant
14748 * @name minutesInYear
14749 * @summary Minutes in 1 year.
14750 */
14751 const minutesInYear = 525600;
14752
14753 /**
14754 * @constant
14755 * @name minutesInMonth
14756 * @summary Minutes in 1 month.
14757 */
14758 const minutesInMonth = 43200;
14759
14760 /**
14761 * @constant
14762 * @name minutesInDay
14763 * @summary Minutes in 1 day.
14764 */
14765 const minutesInDay = 1440;
14766
14767 /**
14768 * @constant
14769 * @name minutesInHour
14770 * @summary Minutes in 1 hour.
14771 */
14772 const minutesInHour = 60;
14773
14774 /**
14775 * @constant
14776 * @name monthsInQuarter
14777 * @summary Months in 1 quarter.
14778 */
14779 const monthsInQuarter = 3;
14780
14781 /**
14782 * @constant
14783 * @name monthsInYear
14784 * @summary Months in 1 year.
14785 */
14786 const monthsInYear = 12;
14787
14788 /**
14789 * @constant
14790 * @name quartersInYear
14791 * @summary Quarters in 1 year
14792 */
14793 const quartersInYear = 4;
14794
14795 /**
14796 * @constant
14797 * @name secondsInHour
14798 * @summary Seconds in 1 hour.
14799 */
14800 const secondsInHour = 3600;
14801
14802 /**
14803 * @constant
14804 * @name secondsInMinute
14805 * @summary Seconds in 1 minute.
14806 */
14807 const secondsInMinute = 60;
14808
14809 /**
14810 * @constant
14811 * @name secondsInDay
14812 * @summary Seconds in 1 day.
14813 */
14814 const secondsInDay = secondsInHour * 24;
14815
14816 /**
14817 * @constant
14818 * @name secondsInWeek
14819 * @summary Seconds in 1 week.
14820 */
14821 const secondsInWeek = secondsInDay * 7;
14822
14823 /**
14824 * @constant
14825 * @name secondsInYear
14826 * @summary Seconds in 1 year.
14827 */
14828 const secondsInYear = secondsInDay * daysInYear;
14829
14830 /**
14831 * @constant
14832 * @name secondsInMonth
14833 * @summary Seconds in 1 month
14834 */
14835 const secondsInMonth = secondsInYear / 12;
14836
14837 /**
14838 * @constant
14839 * @name secondsInQuarter
14840 * @summary Seconds in 1 quarter.
14841 */
14842 const secondsInQuarter = secondsInMonth * 3;
14843
14844 ;// CONCATENATED MODULE: ./node_modules/date-fns/parseISO.mjs
14845
14846
14847 /**
14848 * The {@link parseISO} function options.
14849 */
14850
14851 /**
14852 * @name parseISO
14853 * @category Common Helpers
14854 * @summary Parse ISO string
14855 *
14856 * @description
14857 * Parse the given string in ISO 8601 format and return an instance of Date.
14858 *
14859 * Function accepts complete ISO 8601 formats as well as partial implementations.
14860 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
14861 *
14862 * If the argument isn't a string, the function cannot parse the string or
14863 * the values are invalid, it returns Invalid Date.
14864 *
14865 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14866 *
14867 * @param argument - The value to convert
14868 * @param options - An object with options
14869 *
14870 * @returns The parsed date in the local time zone
14871 *
14872 * @example
14873 * // Convert string '2014-02-11T11:30:30' to date:
14874 * const result = parseISO('2014-02-11T11:30:30')
14875 * //=> Tue Feb 11 2014 11:30:30
14876 *
14877 * @example
14878 * // Convert string '+02014101' to date,
14879 * // if the additional number of digits in the extended year format is 1:
14880 * const result = parseISO('+02014101', { additionalDigits: 1 })
14881 * //=> Fri Apr 11 2014 00:00:00
14882 */
14883 function parseISO(argument, options) {
14884 const additionalDigits = options?.additionalDigits ?? 2;
14885 const dateStrings = splitDateString(argument);
14886
14887 let date;
14888 if (dateStrings.date) {
14889 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
14890 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
14891 }
14892
14893 if (!date || isNaN(date.getTime())) {
14894 return new Date(NaN);
14895 }
14896
14897 const timestamp = date.getTime();
14898 let time = 0;
14899 let offset;
14900
14901 if (dateStrings.time) {
14902 time = parseTime(dateStrings.time);
14903 if (isNaN(time)) {
14904 return new Date(NaN);
14905 }
14906 }
14907
14908 if (dateStrings.timezone) {
14909 offset = parseTimezone(dateStrings.timezone);
14910 if (isNaN(offset)) {
14911 return new Date(NaN);
14912 }
14913 } else {
14914 const dirtyDate = new Date(timestamp + time);
14915 // JS parsed string assuming it's in UTC timezone
14916 // but we need it to be parsed in our timezone
14917 // so we use utc values to build date in our timezone.
14918 // Year values from 0 to 99 map to the years 1900 to 1999
14919 // so set year explicitly with setFullYear.
14920 const result = new Date(0);
14921 result.setFullYear(
14922 dirtyDate.getUTCFullYear(),
14923 dirtyDate.getUTCMonth(),
14924 dirtyDate.getUTCDate(),
14925 );
14926 result.setHours(
14927 dirtyDate.getUTCHours(),
14928 dirtyDate.getUTCMinutes(),
14929 dirtyDate.getUTCSeconds(),
14930 dirtyDate.getUTCMilliseconds(),
14931 );
14932 return result;
14933 }
14934
14935 return new Date(timestamp + time + offset);
14936 }
14937
14938 const patterns = {
14939 dateTimeDelimiter: /[T ]/,
14940 timeZoneDelimiter: /[Z ]/i,
14941 timezone: /([Z+-].*)$/,
14942 };
14943
14944 const dateRegex =
14945 /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
14946 const timeRegex =
14947 /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
14948 const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
14949
14950 function splitDateString(dateString) {
14951 const dateStrings = {};
14952 const array = dateString.split(patterns.dateTimeDelimiter);
14953 let timeString;
14954
14955 // The regex match should only return at maximum two array elements.
14956 // [date], [time], or [date, time].
14957 if (array.length > 2) {
14958 return dateStrings;
14959 }
14960
14961 if (/:/.test(array[0])) {
14962 timeString = array[0];
14963 } else {
14964 dateStrings.date = array[0];
14965 timeString = array[1];
14966 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
14967 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
14968 timeString = dateString.substr(
14969 dateStrings.date.length,
14970 dateString.length,
14971 );
14972 }
14973 }
14974
14975 if (timeString) {
14976 const token = patterns.timezone.exec(timeString);
14977 if (token) {
14978 dateStrings.time = timeString.replace(token[1], "");
14979 dateStrings.timezone = token[1];
14980 } else {
14981 dateStrings.time = timeString;
14982 }
14983 }
14984
14985 return dateStrings;
14986 }
14987
14988 function parseYear(dateString, additionalDigits) {
14989 const regex = new RegExp(
14990 "^(?:(\\d{4}|[+-]\\d{" +
14991 (4 + additionalDigits) +
14992 "})|(\\d{2}|[+-]\\d{" +
14993 (2 + additionalDigits) +
14994 "})$)",
14995 );
14996
14997 const captures = dateString.match(regex);
14998 // Invalid ISO-formatted year
14999 if (!captures) return { year: NaN, restDateString: "" };
15000
15001 const year = captures[1] ? parseInt(captures[1]) : null;
15002 const century = captures[2] ? parseInt(captures[2]) : null;
15003
15004 // either year or century is null, not both
15005 return {
15006 year: century === null ? year : century * 100,
15007 restDateString: dateString.slice((captures[1] || captures[2]).length),
15008 };
15009 }
15010
15011 function parseDate(dateString, year) {
15012 // Invalid ISO-formatted year
15013 if (year === null) return new Date(NaN);
15014
15015 const captures = dateString.match(dateRegex);
15016 // Invalid ISO-formatted string
15017 if (!captures) return new Date(NaN);
15018
15019 const isWeekDate = !!captures[4];
15020 const dayOfYear = parseDateUnit(captures[1]);
15021 const month = parseDateUnit(captures[2]) - 1;
15022 const day = parseDateUnit(captures[3]);
15023 const week = parseDateUnit(captures[4]);
15024 const dayOfWeek = parseDateUnit(captures[5]) - 1;
15025
15026 if (isWeekDate) {
15027 if (!validateWeekDate(year, week, dayOfWeek)) {
15028 return new Date(NaN);
15029 }
15030 return dayOfISOWeekYear(year, week, dayOfWeek);
15031 } else {
15032 const date = new Date(0);
15033 if (
15034 !validateDate(year, month, day) ||
15035 !validateDayOfYearDate(year, dayOfYear)
15036 ) {
15037 return new Date(NaN);
15038 }
15039 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
15040 return date;
15041 }
15042 }
15043
15044 function parseDateUnit(value) {
15045 return value ? parseInt(value) : 1;
15046 }
15047
15048 function parseTime(timeString) {
15049 const captures = timeString.match(timeRegex);
15050 if (!captures) return NaN; // Invalid ISO-formatted time
15051
15052 const hours = parseTimeUnit(captures[1]);
15053 const minutes = parseTimeUnit(captures[2]);
15054 const seconds = parseTimeUnit(captures[3]);
15055
15056 if (!validateTime(hours, minutes, seconds)) {
15057 return NaN;
15058 }
15059
15060 return (
15061 hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000
15062 );
15063 }
15064
15065 function parseTimeUnit(value) {
15066 return (value && parseFloat(value.replace(",", "."))) || 0;
15067 }
15068
15069 function parseTimezone(timezoneString) {
15070 if (timezoneString === "Z") return 0;
15071
15072 const captures = timezoneString.match(timezoneRegex);
15073 if (!captures) return 0;
15074
15075 const sign = captures[1] === "+" ? -1 : 1;
15076 const hours = parseInt(captures[2]);
15077 const minutes = (captures[3] && parseInt(captures[3])) || 0;
15078
15079 if (!validateTimezone(hours, minutes)) {
15080 return NaN;
15081 }
15082
15083 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
15084 }
15085
15086 function dayOfISOWeekYear(isoWeekYear, week, day) {
15087 const date = new Date(0);
15088 date.setUTCFullYear(isoWeekYear, 0, 4);
15089 const fourthOfJanuaryDay = date.getUTCDay() || 7;
15090 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
15091 date.setUTCDate(date.getUTCDate() + diff);
15092 return date;
15093 }
15094
15095 // Validation functions
15096
15097 // February is null to handle the leap year (using ||)
15098 const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
15099
15100 function isLeapYearIndex(year) {
15101 return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
15102 }
15103
15104 function validateDate(year, month, date) {
15105 return (
15106 month >= 0 &&
15107 month <= 11 &&
15108 date >= 1 &&
15109 date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28))
15110 );
15111 }
15112
15113 function validateDayOfYearDate(year, dayOfYear) {
15114 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
15115 }
15116
15117 function validateWeekDate(_year, week, day) {
15118 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
15119 }
15120
15121 function validateTime(hours, minutes, seconds) {
15122 if (hours === 24) {
15123 return minutes === 0 && seconds === 0;
15124 }
15125
15126 return (
15127 seconds >= 0 &&
15128 seconds < 60 &&
15129 minutes >= 0 &&
15130 minutes < 60 &&
15131 hours >= 0 &&
15132 hours < 25
15133 );
15134 }
15135
15136 function validateTimezone(_hours, minutes) {
15137 return minutes >= 0 && minutes <= 59;
15138 }
15139
15140 // Fallback for modularized imports:
15141 /* harmony default export */ const date_fns_parseISO = ((/* unused pure expression or super */ null && (parseISO)));
15142
15143 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/index.js
15144 /**
15145 * External dependencies
15146 */
15147
15148
15149 /**
15150 * WordPress dependencies
15151 */
15152
15153
15154
15155
15156
15157
15158 /**
15159 * Internal dependencies
15160 */
15161
15162
15163
15164 const {
15165 PrivatePublishDateTimePicker
15166 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
15167
15168 /**
15169 * Renders the PostSchedule component. It allows the user to schedule a post.
15170 *
15171 * @param {Object} props Props.
15172 * @param {Function} props.onClose Function to close the component.
15173 *
15174 * @return {Component} The component to be rendered.
15175 */
15176 function PostSchedule(props) {
15177 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
15178 ...props,
15179 showPopoverHeaderActions: true,
15180 isCompact: false
15181 });
15182 }
15183 function PrivatePostSchedule({
15184 onClose,
15185 showPopoverHeaderActions,
15186 isCompact
15187 }) {
15188 const {
15189 postDate,
15190 postType
15191 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
15192 postDate: select(store_store).getEditedPostAttribute('date'),
15193 postType: select(store_store).getCurrentPostType()
15194 }), []);
15195 const {
15196 editPost
15197 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15198 const onUpdateDate = date => editPost({
15199 date
15200 });
15201 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate)));
15202
15203 // Pick up published and schduled site posts.
15204 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
15205 status: 'publish,future',
15206 after: startOfMonth(previewedMonth).toISOString(),
15207 before: endOfMonth(previewedMonth).toISOString(),
15208 exclude: [select(store_store).getCurrentPostId()],
15209 per_page: 100,
15210 _fields: 'id,date'
15211 }), [previewedMonth, postType]);
15212 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({
15213 date: eventDate
15214 }) => ({
15215 date: new Date(eventDate)
15216 })), [eventsByPostType]);
15217 const settings = (0,external_wp_date_namespaceObject.getSettings)();
15218
15219 // To know if the current timezone is a 12 hour time with look for "a" in the time format
15220 // We also make sure this a is not escaped by a "/"
15221 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
15222 .replace(/\\\\/g, '') // Replace "//" with empty strings.
15223 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
15224 );
15225 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePublishDateTimePicker, {
15226 currentDate: postDate,
15227 onChange: onUpdateDate,
15228 is12Hour: is12HourTime,
15229 events: events,
15230 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)),
15231 onClose: onClose,
15232 isCompact: isCompact,
15233 showPopoverHeaderActions: showPopoverHeaderActions
15234 });
15235 }
15236
15237 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/label.js
15238 /**
15239 * WordPress dependencies
15240 */
15241
15242
15243
15244
15245 /**
15246 * Internal dependencies
15247 */
15248
15249
15250 /**
15251 * Renders the PostScheduleLabel component.
15252 *
15253 * @param {Object} props Props.
15254 *
15255 * @return {Component} The component to be rendered.
15256 */
15257 function PostScheduleLabel(props) {
15258 return usePostScheduleLabel(props);
15259 }
15260
15261 /**
15262 * Custom hook to get the label for post schedule.
15263 *
15264 * @param {Object} options Options for the hook.
15265 * @param {boolean} options.full Whether to get the full label or not. Default is false.
15266 *
15267 * @return {string} The label for post schedule.
15268 */
15269 function usePostScheduleLabel({
15270 full = false
15271 } = {}) {
15272 const {
15273 date,
15274 isFloating
15275 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
15276 date: select(store_store).getEditedPostAttribute('date'),
15277 isFloating: select(store_store).isEditedPostDateFloating()
15278 }), []);
15279 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, {
15280 isFloating
15281 });
15282 }
15283 function getFullPostScheduleLabel(dateAttribute) {
15284 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
15285 const timezoneAbbreviation = getTimezoneAbbreviation();
15286 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(
15287 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15288 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
15289 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
15290 }
15291 function getPostScheduleLabel(dateAttribute, {
15292 isFloating = false,
15293 now = new Date()
15294 } = {}) {
15295 if (!dateAttribute || isFloating) {
15296 return (0,external_wp_i18n_namespaceObject.__)('Immediately');
15297 }
15298
15299 // If the user timezone does not equal the site timezone then using words
15300 // like 'tomorrow' is confusing, so show the full date.
15301 if (!isTimezoneSameAsSiteTimezone(now)) {
15302 return getFullPostScheduleLabel(dateAttribute);
15303 }
15304 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
15305 if (isSameDay(date, now)) {
15306 return (0,external_wp_i18n_namespaceObject.sprintf)(
15307 // translators: %s: Time of day the post is scheduled for.
15308 (0,external_wp_i18n_namespaceObject.__)('Today at %s'),
15309 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15310 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
15311 }
15312 const tomorrow = new Date(now);
15313 tomorrow.setDate(tomorrow.getDate() + 1);
15314 if (isSameDay(date, tomorrow)) {
15315 return (0,external_wp_i18n_namespaceObject.sprintf)(
15316 // translators: %s: Time of day the post is scheduled for.
15317 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'),
15318 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15319 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
15320 }
15321 if (date.getFullYear() === now.getFullYear()) {
15322 return (0,external_wp_date_namespaceObject.dateI18n)(
15323 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15324 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date);
15325 }
15326 return (0,external_wp_date_namespaceObject.dateI18n)(
15327 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
15328 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
15329 }
15330 function getTimezoneAbbreviation() {
15331 const {
15332 timezone
15333 } = (0,external_wp_date_namespaceObject.getSettings)();
15334 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
15335 return timezone.abbr;
15336 }
15337 const symbol = timezone.offset < 0 ? '' : '+';
15338 return `UTC${symbol}${timezone.offsetFormatted}`;
15339 }
15340 function isTimezoneSameAsSiteTimezone(date) {
15341 const {
15342 timezone
15343 } = (0,external_wp_date_namespaceObject.getSettings)();
15344 const siteOffset = Number(timezone.offset);
15345 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
15346 return siteOffset === dateOffset;
15347 }
15348 function isSameDay(left, right) {
15349 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
15350 }
15351
15352 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
15353 /**
15354 * WordPress dependencies
15355 */
15356
15357
15358
15359
15360 /**
15361 * Internal dependencies
15362 */
15363
15364
15365
15366 const MIN_MOST_USED_TERMS = 3;
15367 const DEFAULT_QUERY = {
15368 per_page: 10,
15369 orderby: 'count',
15370 order: 'desc',
15371 hide_empty: true,
15372 _fields: 'id,name,count',
15373 context: 'view'
15374 };
15375 function MostUsedTerms({
15376 onSelect,
15377 taxonomy
15378 }) {
15379 const {
15380 _terms,
15381 showTerms
15382 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15383 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
15384 return {
15385 _terms: mostUsedTerms,
15386 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
15387 };
15388 }, [taxonomy.slug]);
15389 if (!showTerms) {
15390 return null;
15391 }
15392 const terms = unescapeTerms(_terms);
15393 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15394 className: "editor-post-taxonomies__flat-term-most-used",
15395 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
15396 as: "h3",
15397 className: "editor-post-taxonomies__flat-term-most-used-label",
15398 children: taxonomy.labels.most_used
15399 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
15400 role: "list",
15401 className: "editor-post-taxonomies__flat-term-most-used-list",
15402 children: terms.map(term => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
15403 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15404 variant: "link",
15405 onClick: () => onSelect(term),
15406 children: term.name
15407 })
15408 }, term.id))
15409 })]
15410 });
15411 }
15412
15413 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
15414 /**
15415 * WordPress dependencies
15416 */
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426 /**
15427 * Internal dependencies
15428 */
15429
15430
15431
15432
15433 /**
15434 * Shared reference to an empty array for cases where it is important to avoid
15435 * returning a new array reference on every invocation.
15436 *
15437 * @type {Array<any>}
15438 */
15439
15440
15441
15442 const flat_term_selector_EMPTY_ARRAY = [];
15443
15444 /**
15445 * How the max suggestions limit was chosen:
15446 * - Matches the `per_page` range set by the REST API.
15447 * - Can't use "unbound" query. The `FormTokenField` needs a fixed number.
15448 * - Matches default for `FormTokenField`.
15449 */
15450 const MAX_TERMS_SUGGESTIONS = 100;
15451 const flat_term_selector_DEFAULT_QUERY = {
15452 per_page: MAX_TERMS_SUGGESTIONS,
15453 _fields: 'id,name',
15454 context: 'view'
15455 };
15456 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
15457 const termNamesToIds = (names, terms) => {
15458 return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
15459 };
15460
15461 /**
15462 * Renders a flat term selector component.
15463 *
15464 * @param {Object} props The component props.
15465 * @param {string} props.slug The slug of the taxonomy.
15466 *
15467 * @return {JSX.Element} The rendered flat term selector component.
15468 */
15469 function FlatTermSelector({
15470 slug
15471 }) {
15472 var _taxonomy$labels$add_, _taxonomy$labels$sing2;
15473 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
15474 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
15475 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
15476 const {
15477 terms,
15478 termIds,
15479 taxonomy,
15480 hasAssignAction,
15481 hasCreateAction,
15482 hasResolvedTerms
15483 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15484 var _post$_links, _post$_links2;
15485 const {
15486 getCurrentPost,
15487 getEditedPostAttribute
15488 } = select(store_store);
15489 const {
15490 getEntityRecords,
15491 getTaxonomy,
15492 hasFinishedResolution
15493 } = select(external_wp_coreData_namespaceObject.store);
15494 const post = getCurrentPost();
15495 const _taxonomy = getTaxonomy(slug);
15496 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
15497 const query = {
15498 ...flat_term_selector_DEFAULT_QUERY,
15499 include: _termIds.join(','),
15500 per_page: -1
15501 };
15502 return {
15503 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15504 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15505 taxonomy: _taxonomy,
15506 termIds: _termIds,
15507 terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
15508 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
15509 };
15510 }, [slug]);
15511 const {
15512 searchResults
15513 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15514 const {
15515 getEntityRecords
15516 } = select(external_wp_coreData_namespaceObject.store);
15517 return {
15518 searchResults: !!search ? getEntityRecords('taxonomy', slug, {
15519 ...flat_term_selector_DEFAULT_QUERY,
15520 search
15521 }) : flat_term_selector_EMPTY_ARRAY
15522 };
15523 }, [search, slug]);
15524
15525 // Update terms state only after the selectors are resolved.
15526 // We're using this to avoid terms temporarily disappearing on slow networks
15527 // while core data makes REST API requests.
15528 (0,external_wp_element_namespaceObject.useEffect)(() => {
15529 if (hasResolvedTerms) {
15530 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
15531 setValues(newValues);
15532 }
15533 }, [terms, hasResolvedTerms]);
15534 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
15535 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
15536 }, [searchResults]);
15537 const {
15538 editPost
15539 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15540 const {
15541 saveEntityRecord
15542 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15543 const {
15544 createErrorNotice
15545 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15546 if (!hasAssignAction) {
15547 return null;
15548 }
15549 async function findOrCreateTerm(term) {
15550 try {
15551 const newTerm = await saveEntityRecord('taxonomy', slug, term, {
15552 throwOnError: true
15553 });
15554 return unescapeTerm(newTerm);
15555 } catch (error) {
15556 if (error.code !== 'term_exists') {
15557 throw error;
15558 }
15559 return {
15560 id: error.data.term_id,
15561 name: term.name
15562 };
15563 }
15564 }
15565 function onUpdateTerms(newTermIds) {
15566 editPost({
15567 [taxonomy.rest_base]: newTermIds
15568 });
15569 }
15570 function onChange(termNames) {
15571 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
15572 const uniqueTerms = termNames.reduce((acc, name) => {
15573 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
15574 acc.push(name);
15575 }
15576 return acc;
15577 }, []);
15578 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
15579
15580 // Optimistically update term values.
15581 // The selector will always re-fetch terms later.
15582 setValues(uniqueTerms);
15583 if (newTermNames.length === 0) {
15584 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15585 return;
15586 }
15587 if (!hasCreateAction) {
15588 return;
15589 }
15590 Promise.all(newTermNames.map(termName => findOrCreateTerm({
15591 name: termName
15592 }))).then(newTerms => {
15593 const newAvailableTerms = availableTerms.concat(newTerms);
15594 onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
15595 }).catch(error => {
15596 createErrorNotice(error.message, {
15597 type: 'snackbar'
15598 });
15599 // In case of a failure, try assigning available terms.
15600 // This will invalidate the optimistic update.
15601 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15602 });
15603 }
15604 function appendTerm(newTerm) {
15605 var _taxonomy$labels$sing;
15606 if (termIds.includes(newTerm.id)) {
15607 return;
15608 }
15609 const newTermIds = [...termIds, newTerm.id];
15610 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
15611 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15612 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : defaultName);
15613 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
15614 onUpdateTerms(newTermIds);
15615 }
15616 const newTermLabel = (_taxonomy$labels$add_ = taxonomy?.labels?.add_new_item) !== null && _taxonomy$labels$add_ !== void 0 ? _taxonomy$labels$add_ : slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Add new tag') : (0,external_wp_i18n_namespaceObject.__)('Add new Term');
15617 const singularName = (_taxonomy$labels$sing2 = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing2 !== void 0 ? _taxonomy$labels$sing2 : slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
15618 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15619 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
15620 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15621 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
15622 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15623 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
15624 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15625 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
15626 __next40pxDefaultSize: true,
15627 value: values,
15628 suggestions: suggestions,
15629 onChange: onChange,
15630 onInputChange: debouncedSearch,
15631 maxSuggestions: MAX_TERMS_SUGGESTIONS,
15632 label: newTermLabel,
15633 messages: {
15634 added: termAddedLabel,
15635 removed: termRemovedLabel,
15636 remove: removeTermLabel
15637 }
15638 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MostUsedTerms, {
15639 taxonomy: taxonomy,
15640 onSelect: appendTerm
15641 })]
15642 });
15643 }
15644 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
15645
15646 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
15647 /**
15648 * WordPress dependencies
15649 */
15650
15651
15652
15653
15654
15655
15656 /**
15657 * Internal dependencies
15658 */
15659
15660
15661
15662
15663 const TagsPanel = () => {
15664 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15665 className: "editor-post-publish-panel__link",
15666 children: (0,external_wp_i18n_namespaceObject.__)('Add tags')
15667 }, "label")];
15668 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15669 initialOpen: false,
15670 title: panelBodyTitle,
15671 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15672 children: (0,external_wp_i18n_namespaceObject.__)('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')
15673 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flat_term_selector, {
15674 slug: "post_tag"
15675 })]
15676 });
15677 };
15678 const MaybeTagsPanel = () => {
15679 const {
15680 hasTags,
15681 isPostTypeSupported
15682 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15683 const postType = select(store_store).getCurrentPostType();
15684 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
15685 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
15686 const areTagsFetched = tagsTaxonomy !== undefined;
15687 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
15688 return {
15689 hasTags: !!tags?.length,
15690 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
15691 };
15692 }, []);
15693 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags);
15694 if (!isPostTypeSupported) {
15695 return null;
15696 }
15697
15698 /*
15699 * We only want to show the tag panel if the post didn't have
15700 * any tags when the user hit the Publish button.
15701 *
15702 * We can't use the prop.hasTags because it'll change to true
15703 * if the user adds a new tag within the pre-publish panel.
15704 * This would force a re-render and a new prop.hasTags check,
15705 * hiding this panel and keeping the user from adding
15706 * more than one tag.
15707 */
15708 if (!hadTagsWhenOpeningThePanel) {
15709 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TagsPanel, {});
15710 }
15711 return null;
15712 };
15713 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel);
15714
15715 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
15716 /**
15717 * WordPress dependencies
15718 */
15719
15720
15721
15722
15723
15724 /**
15725 * Internal dependencies
15726 */
15727
15728
15729
15730
15731 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
15732 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id));
15733 return formats.find(format => format.id === suggestedPostFormat);
15734 };
15735 const PostFormatSuggestion = ({
15736 suggestedPostFormat,
15737 suggestionText,
15738 onUpdatePostFormat
15739 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15740 variant: "link",
15741 onClick: () => onUpdatePostFormat(suggestedPostFormat),
15742 children: suggestionText
15743 });
15744 function PostFormatPanel() {
15745 const {
15746 currentPostFormat,
15747 suggestion
15748 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15749 var _select$getThemeSuppo;
15750 const {
15751 getEditedPostAttribute,
15752 getSuggestedPostFormat
15753 } = select(store_store);
15754 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
15755 return {
15756 currentPostFormat: getEditedPostAttribute('format'),
15757 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
15758 };
15759 }, []);
15760 const {
15761 editPost
15762 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15763 const onUpdatePostFormat = format => editPost({
15764 format
15765 });
15766 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15767 className: "editor-post-publish-panel__link",
15768 children: (0,external_wp_i18n_namespaceObject.__)('Use a post format')
15769 }, "label")];
15770 if (!suggestion || suggestion.id === currentPostFormat) {
15771 return null;
15772 }
15773 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15774 initialOpen: false,
15775 title: panelBodyTitle,
15776 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15777 children: (0,external_wp_i18n_namespaceObject.__)('Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.')
15778 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15779 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatSuggestion, {
15780 onUpdatePostFormat: onUpdatePostFormat,
15781 suggestedPostFormat: suggestion.id,
15782 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
15783 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
15784 })
15785 })]
15786 });
15787 }
15788
15789 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
15790 /**
15791 * WordPress dependencies
15792 */
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803 /**
15804 * Internal dependencies
15805 */
15806
15807
15808
15809 /**
15810 * Module Constants
15811 */
15812
15813
15814 const hierarchical_term_selector_DEFAULT_QUERY = {
15815 per_page: -1,
15816 orderby: 'name',
15817 order: 'asc',
15818 _fields: 'id,name,parent',
15819 context: 'view'
15820 };
15821 const MIN_TERMS_COUNT_FOR_FILTER = 8;
15822 const hierarchical_term_selector_EMPTY_ARRAY = [];
15823
15824 /**
15825 * Sort Terms by Selected.
15826 *
15827 * @param {Object[]} termsTree Array of terms in tree format.
15828 * @param {number[]} terms Selected terms.
15829 *
15830 * @return {Object[]} Sorted array of terms.
15831 */
15832 function sortBySelected(termsTree, terms) {
15833 const treeHasSelection = termTree => {
15834 if (terms.indexOf(termTree.id) !== -1) {
15835 return true;
15836 }
15837 if (undefined === termTree.children) {
15838 return false;
15839 }
15840 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
15841 };
15842 const termOrChildIsSelected = (termA, termB) => {
15843 const termASelected = treeHasSelection(termA);
15844 const termBSelected = treeHasSelection(termB);
15845 if (termASelected === termBSelected) {
15846 return 0;
15847 }
15848 if (termASelected && !termBSelected) {
15849 return -1;
15850 }
15851 if (!termASelected && termBSelected) {
15852 return 1;
15853 }
15854 return 0;
15855 };
15856 const newTermTree = [...termsTree];
15857 newTermTree.sort(termOrChildIsSelected);
15858 return newTermTree;
15859 }
15860
15861 /**
15862 * Find term by parent id or name.
15863 *
15864 * @param {Object[]} terms Array of Terms.
15865 * @param {number|string} parent id.
15866 * @param {string} name Term name.
15867 * @return {Object} Term object.
15868 */
15869 function findTerm(terms, parent, name) {
15870 return terms.find(term => {
15871 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
15872 });
15873 }
15874
15875 /**
15876 * Get filter matcher function.
15877 *
15878 * @param {string} filterValue Filter value.
15879 * @return {(function(Object): (Object|boolean))} Matcher function.
15880 */
15881 function getFilterMatcher(filterValue) {
15882 const matchTermsForFilter = originalTerm => {
15883 if ('' === filterValue) {
15884 return originalTerm;
15885 }
15886
15887 // Shallow clone, because we'll be filtering the term's children and
15888 // don't want to modify the original term.
15889 const term = {
15890 ...originalTerm
15891 };
15892
15893 // Map and filter the children, recursive so we deal with grandchildren
15894 // and any deeper levels.
15895 if (term.children.length > 0) {
15896 term.children = term.children.map(matchTermsForFilter).filter(child => child);
15897 }
15898
15899 // If the term's name contains the filterValue, or it has children
15900 // (i.e. some child matched at some point in the tree) then return it.
15901 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
15902 return term;
15903 }
15904
15905 // Otherwise, return false. After mapping, the list of terms will need
15906 // to have false values filtered out.
15907 return false;
15908 };
15909 return matchTermsForFilter;
15910 }
15911
15912 /**
15913 * Hierarchical term selector.
15914 *
15915 * @param {Object} props Component props.
15916 * @param {string} props.slug Taxonomy slug.
15917 * @return {Element} Hierarchical term selector component.
15918 */
15919 function HierarchicalTermSelector({
15920 slug
15921 }) {
15922 var _taxonomy$labels$sear, _taxonomy$name;
15923 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
15924 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
15925 /**
15926 * @type {[number|'', Function]}
15927 */
15928 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
15929 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
15930 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
15931 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
15932 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
15933 const {
15934 hasCreateAction,
15935 hasAssignAction,
15936 terms,
15937 loading,
15938 availableTerms,
15939 taxonomy
15940 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15941 var _post$_links, _post$_links2;
15942 const {
15943 getCurrentPost,
15944 getEditedPostAttribute
15945 } = select(store_store);
15946 const {
15947 getTaxonomy,
15948 getEntityRecords,
15949 isResolving
15950 } = select(external_wp_coreData_namespaceObject.store);
15951 const _taxonomy = getTaxonomy(slug);
15952 const post = getCurrentPost();
15953 return {
15954 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15955 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15956 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
15957 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
15958 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
15959 taxonomy: _taxonomy
15960 };
15961 }, [slug]);
15962 const {
15963 editPost
15964 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15965 const {
15966 saveEntityRecord
15967 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15968 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms),
15969 // Remove `terms` from the dependency list to avoid reordering every time
15970 // checking or unchecking a term.
15971 [availableTerms]);
15972 const {
15973 createErrorNotice
15974 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15975 if (!hasAssignAction) {
15976 return null;
15977 }
15978
15979 /**
15980 * Append new term.
15981 *
15982 * @param {Object} term Term object.
15983 * @return {Promise} A promise that resolves to save term object.
15984 */
15985 const addTerm = term => {
15986 return saveEntityRecord('taxonomy', slug, term, {
15987 throwOnError: true
15988 });
15989 };
15990
15991 /**
15992 * Update terms for post.
15993 *
15994 * @param {number[]} termIds Term ids.
15995 */
15996 const onUpdateTerms = termIds => {
15997 editPost({
15998 [taxonomy.rest_base]: termIds
15999 });
16000 };
16001
16002 /**
16003 * Handler for checking term.
16004 *
16005 * @param {number} termId
16006 */
16007 const onChange = termId => {
16008 const hasTerm = terms.includes(termId);
16009 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
16010 onUpdateTerms(newTerms);
16011 };
16012 const onChangeFormName = value => {
16013 setFormName(value);
16014 };
16015
16016 /**
16017 * Handler for changing form parent.
16018 *
16019 * @param {number|''} parentId Parent post id.
16020 */
16021 const onChangeFormParent = parentId => {
16022 setFormParent(parentId);
16023 };
16024 const onToggleForm = () => {
16025 setShowForm(!showForm);
16026 };
16027 const onAddTerm = async event => {
16028 var _taxonomy$labels$sing;
16029 event.preventDefault();
16030 if (formName === '' || adding) {
16031 return;
16032 }
16033
16034 // Check if the term we are adding already exists.
16035 const existingTerm = findTerm(availableTerms, formParent, formName);
16036 if (existingTerm) {
16037 // If the term we are adding exists but is not selected select it.
16038 if (!terms.some(term => term === existingTerm.id)) {
16039 onUpdateTerms([...terms, existingTerm.id]);
16040 }
16041 setFormName('');
16042 setFormParent('');
16043 return;
16044 }
16045 setAdding(true);
16046 let newTerm;
16047 try {
16048 newTerm = await addTerm({
16049 name: formName,
16050 parent: formParent ? formParent : undefined
16051 });
16052 } catch (error) {
16053 createErrorNotice(error.message, {
16054 type: 'snackbar'
16055 });
16056 return;
16057 }
16058 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term');
16059 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: taxonomy name */
16060 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : defaultName);
16061 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
16062 setAdding(false);
16063 setFormName('');
16064 setFormParent('');
16065 onUpdateTerms([...terms, newTerm.id]);
16066 };
16067 const setFilter = value => {
16068 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
16069 const getResultCount = termsTree => {
16070 let count = 0;
16071 for (let i = 0; i < termsTree.length; i++) {
16072 count++;
16073 if (undefined !== termsTree[i].children) {
16074 count += getResultCount(termsTree[i].children);
16075 }
16076 }
16077 return count;
16078 };
16079 setFilterValue(value);
16080 setFilteredTermsTree(newFilteredTermsTree);
16081 const resultCount = getResultCount(newFilteredTermsTree);
16082 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results */
16083 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
16084 debouncedSpeak(resultsFoundMessage, 'assertive');
16085 };
16086 const renderTerms = renderedTerms => {
16087 return renderedTerms.map(term => {
16088 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16089 className: "editor-post-taxonomies__hierarchical-terms-choice",
16090 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16091 __nextHasNoMarginBottom: true,
16092 checked: terms.indexOf(term.id) !== -1,
16093 onChange: () => {
16094 const termId = parseInt(term.id, 10);
16095 onChange(termId);
16096 },
16097 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name)
16098 }), !!term.children.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16099 className: "editor-post-taxonomies__hierarchical-terms-subchoices",
16100 children: renderTerms(term.children)
16101 })]
16102 }, term.id);
16103 });
16104 };
16105 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
16106 var _taxonomy$labels$labe;
16107 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
16108 };
16109 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
16110 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
16111 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
16112 const noParentOption = `— ${parentSelectLabel} —`;
16113 const newTermSubmitLabel = newTermButtonLabel;
16114 const filterLabel = (_taxonomy$labels$sear = taxonomy?.labels?.search_items) !== null && _taxonomy$labels$sear !== void 0 ? _taxonomy$labels$sear : (0,external_wp_i18n_namespaceObject.__)('Search Terms');
16115 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms');
16116 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
16117 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
16118 direction: "column",
16119 gap: "4",
16120 children: [showFilter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16121 __nextHasNoMarginBottom: true,
16122 label: filterLabel,
16123 value: filterValue,
16124 onChange: setFilter
16125 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16126 className: "editor-post-taxonomies__hierarchical-terms-list",
16127 tabIndex: "0",
16128 role: "group",
16129 "aria-label": groupLabel,
16130 children: renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)
16131 }), !loading && hasCreateAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
16132 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16133 onClick: onToggleForm,
16134 className: "editor-post-taxonomies__hierarchical-terms-add",
16135 "aria-expanded": showForm,
16136 variant: "link",
16137 children: newTermButtonLabel
16138 })
16139 }), showForm && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
16140 onSubmit: onAddTerm,
16141 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
16142 direction: "column",
16143 gap: "4",
16144 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16145 __next40pxDefaultSize: true,
16146 __nextHasNoMarginBottom: true,
16147 className: "editor-post-taxonomies__hierarchical-terms-input",
16148 label: newTermLabel,
16149 value: formName,
16150 onChange: onChangeFormName,
16151 required: true
16152 }), !!availableTerms.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TreeSelect, {
16153 __next40pxDefaultSize: true,
16154 __nextHasNoMarginBottom: true,
16155 label: parentSelectLabel,
16156 noOptionLabel: noParentOption,
16157 onChange: onChangeFormParent,
16158 selectedId: formParent,
16159 tree: availableTermsTree
16160 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
16161 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16162 __next40pxDefaultSize: true,
16163 variant: "secondary",
16164 type: "submit",
16165 className: "editor-post-taxonomies__hierarchical-terms-submit",
16166 children: newTermSubmitLabel
16167 })
16168 })]
16169 })
16170 })]
16171 });
16172 }
16173 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
16174
16175 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
16176 /**
16177 * WordPress dependencies
16178 */
16179
16180
16181
16182
16183
16184
16185 /**
16186 * Internal dependencies
16187 */
16188
16189
16190
16191
16192 function MaybeCategoryPanel() {
16193 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
16194 const postType = select(store_store).getCurrentPostType();
16195 const {
16196 canUser,
16197 getEntityRecord,
16198 getTaxonomy
16199 } = select(external_wp_coreData_namespaceObject.store);
16200 const categoriesTaxonomy = getTaxonomy('category');
16201 const defaultCategoryId = canUser('read', 'settings') ? getEntityRecord('root', 'site')?.default_category : undefined;
16202 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
16203 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
16204 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
16205
16206 // This boolean should return true if everything is loaded
16207 // ( categoriesTaxonomy, defaultCategory )
16208 // and the post has not been assigned a category different than "uncategorized".
16209 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
16210 }, []);
16211 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
16212 (0,external_wp_element_namespaceObject.useEffect)(() => {
16213 // We use state to avoid hiding the panel if the user edits the categories
16214 // and adds one within the panel itself (while visible).
16215 if (hasNoCategory) {
16216 setShouldShowPanel(true);
16217 }
16218 }, [hasNoCategory]);
16219 if (!shouldShowPanel) {
16220 return null;
16221 }
16222 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16223 className: "editor-post-publish-panel__link",
16224 children: (0,external_wp_i18n_namespaceObject.__)('Assign a category')
16225 }, "label")];
16226 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16227 initialOpen: false,
16228 title: panelBodyTitle,
16229 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16230 children: (0,external_wp_i18n_namespaceObject.__)('Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.')
16231 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(hierarchical_term_selector, {
16232 slug: "category"
16233 })]
16234 });
16235 }
16236 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
16237
16238 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js
16239 /**
16240 * WordPress dependencies
16241 */
16242
16243
16244
16245
16246
16247
16248
16249 /**
16250 * Internal dependencies
16251 */
16252
16253
16254
16255 function flattenBlocks(blocks) {
16256 const result = [];
16257 blocks.forEach(block => {
16258 result.push(block);
16259 result.push(...flattenBlocks(block.innerBlocks));
16260 });
16261 return result;
16262 }
16263 function Image(block) {
16264 const {
16265 selectBlock
16266 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
16267 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
16268 tabIndex: 0,
16269 role: "button",
16270 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'),
16271 onClick: () => {
16272 selectBlock(block.clientId);
16273 },
16274 onKeyDown: event => {
16275 if (event.key === 'Enter' || event.key === ' ') {
16276 selectBlock(block.clientId);
16277 event.preventDefault();
16278 }
16279 },
16280 alt: block.attributes.alt,
16281 src: block.attributes.url,
16282 animate: {
16283 opacity: 1
16284 },
16285 exit: {
16286 opacity: 0,
16287 scale: 0
16288 },
16289 style: {
16290 width: '36px',
16291 height: '36px',
16292 objectFit: 'cover',
16293 borderRadius: '2px',
16294 cursor: 'pointer'
16295 },
16296 whileHover: {
16297 scale: 1.08
16298 }
16299 }, block.clientId);
16300 }
16301 function maybe_upload_media_PostFormatPanel() {
16302 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false);
16303 const {
16304 editorBlocks,
16305 mediaUpload
16306 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
16307 editorBlocks: select(store_store).getEditorBlocks(),
16308 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload
16309 }), []);
16310 const externalImages = flattenBlocks(editorBlocks).filter(block => block.name === 'core/image' && block.attributes.url && !block.attributes.id);
16311 const {
16312 updateBlockAttributes
16313 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
16314 if (!mediaUpload || !externalImages.length) {
16315 return null;
16316 }
16317 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16318 className: "editor-post-publish-panel__link",
16319 children: (0,external_wp_i18n_namespaceObject.__)('External media')
16320 }, "label")];
16321 function uploadImages() {
16322 setIsUploading(true);
16323 Promise.all(externalImages.map(image => window.fetch(image.attributes.url.includes('?') ? image.attributes.url : image.attributes.url + '?').then(response => response.blob()).then(blob => new Promise((resolve, reject) => {
16324 mediaUpload({
16325 filesList: [blob],
16326 onFileChange: ([media]) => {
16327 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
16328 return;
16329 }
16330 updateBlockAttributes(image.clientId, {
16331 id: media.id,
16332 url: media.url
16333 });
16334 resolve();
16335 },
16336 onError() {
16337 reject();
16338 }
16339 });
16340 })))).finally(() => {
16341 setIsUploading(false);
16342 });
16343 }
16344 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16345 initialOpen: true,
16346 title: panelBodyTitle,
16347 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16348 children: (0,external_wp_i18n_namespaceObject.__)('Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.')
16349 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16350 style: {
16351 display: 'inline-flex',
16352 flexWrap: 'wrap',
16353 gap: '8px'
16354 },
16355 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
16356 children: externalImages.map(image => {
16357 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Image, {
16358 ...image
16359 }, image.clientId);
16360 })
16361 }), isUploading ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16362 variant: "primary",
16363 onClick: uploadImages,
16364 children: (0,external_wp_i18n_namespaceObject.__)('Upload')
16365 })]
16366 })]
16367 });
16368 }
16369
16370 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/prepublish.js
16371 /**
16372 * WordPress dependencies
16373 */
16374
16375
16376
16377
16378
16379
16380
16381
16382 /**
16383 * Internal dependencies
16384 */
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397 function PostPublishPanelPrepublish({
16398 children
16399 }) {
16400 const {
16401 isBeingScheduled,
16402 isRequestingSiteIcon,
16403 hasPublishAction,
16404 siteIconUrl,
16405 siteTitle,
16406 siteHome
16407 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16408 var _getCurrentPost$_link;
16409 const {
16410 getCurrentPost,
16411 isEditedPostBeingScheduled
16412 } = select(store_store);
16413 const {
16414 getEntityRecord,
16415 isResolving
16416 } = select(external_wp_coreData_namespaceObject.store);
16417 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
16418 return {
16419 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16420 isBeingScheduled: isEditedPostBeingScheduled(),
16421 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
16422 siteIconUrl: siteData.site_icon_url,
16423 siteTitle: siteData.name,
16424 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
16425 };
16426 }, []);
16427 let siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
16428 className: "components-site-icon",
16429 size: "36px",
16430 icon: library_wordpress
16431 });
16432 if (siteIconUrl) {
16433 siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
16434 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
16435 className: "components-site-icon",
16436 src: siteIconUrl
16437 });
16438 }
16439 if (isRequestingSiteIcon) {
16440 siteIcon = null;
16441 }
16442 let prePublishTitle, prePublishBodyText;
16443 if (!hasPublishAction) {
16444 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
16445 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.');
16446 } else if (isBeingScheduled) {
16447 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
16448 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
16449 } else {
16450 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
16451 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
16452 }
16453 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16454 className: "editor-post-publish-panel__prepublish",
16455 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16456 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16457 children: prePublishTitle
16458 })
16459 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16460 children: prePublishBodyText
16461 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16462 className: "components-site-card",
16463 children: [siteIcon, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16464 className: "components-site-info",
16465 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16466 className: "components-site-name",
16467 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')
16468 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16469 className: "components-site-home",
16470 children: siteHome
16471 })]
16472 })]
16473 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_upload_media_PostFormatPanel, {}), hasPublishAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16474 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16475 initialOpen: false,
16476 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16477 className: "editor-post-publish-panel__link",
16478 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityLabel, {})
16479 }, "label")],
16480 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibility, {})
16481 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16482 initialOpen: false,
16483 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16484 className: "editor-post-publish-panel__link",
16485 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {})
16486 }, "label")],
16487 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {})
16488 })]
16489 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_tags_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_category_panel, {}), children]
16490 });
16491 }
16492 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
16493
16494 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/postpublish.js
16495 /**
16496 * WordPress dependencies
16497 */
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507 /**
16508 * Internal dependencies
16509 */
16510
16511
16512
16513
16514
16515 const POSTNAME = '%postname%';
16516 const PAGENAME = '%pagename%';
16517
16518 /**
16519 * Returns URL for a future post.
16520 *
16521 * @param {Object} post Post object.
16522 *
16523 * @return {string} PostPublish URL.
16524 */
16525
16526 const getFuturePostUrl = post => {
16527 const {
16528 slug
16529 } = post;
16530 if (post.permalink_template.includes(POSTNAME)) {
16531 return post.permalink_template.replace(POSTNAME, slug);
16532 }
16533 if (post.permalink_template.includes(PAGENAME)) {
16534 return post.permalink_template.replace(PAGENAME, slug);
16535 }
16536 return post.permalink_template;
16537 };
16538 function postpublish_CopyButton({
16539 text,
16540 onCopy,
16541 children
16542 }) {
16543 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
16544 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16545 variant: "secondary",
16546 ref: ref,
16547 children: children
16548 });
16549 }
16550 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
16551 constructor() {
16552 super(...arguments);
16553 this.state = {
16554 showCopyConfirmation: false
16555 };
16556 this.onCopy = this.onCopy.bind(this);
16557 this.onSelectInput = this.onSelectInput.bind(this);
16558 this.postLink = (0,external_wp_element_namespaceObject.createRef)();
16559 }
16560 componentDidMount() {
16561 if (this.props.focusOnMount) {
16562 this.postLink.current.focus();
16563 }
16564 }
16565 componentWillUnmount() {
16566 clearTimeout(this.dismissCopyConfirmation);
16567 }
16568 onCopy() {
16569 this.setState({
16570 showCopyConfirmation: true
16571 });
16572 clearTimeout(this.dismissCopyConfirmation);
16573 this.dismissCopyConfirmation = setTimeout(() => {
16574 this.setState({
16575 showCopyConfirmation: false
16576 });
16577 }, 4000);
16578 }
16579 onSelectInput(event) {
16580 event.target.select();
16581 }
16582 render() {
16583 const {
16584 children,
16585 isScheduled,
16586 post,
16587 postType
16588 } = this.props;
16589 const postLabel = postType?.labels?.singular_name;
16590 const viewPostLabel = postType?.labels?.view_item;
16591 const addNewPostLabel = postType?.labels?.add_new_item;
16592 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
16593 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
16594 post_type: post.type
16595 });
16596 const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16597 children: [(0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {}), "."]
16598 }) : (0,external_wp_i18n_namespaceObject.__)('is now live.');
16599 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16600 className: "post-publish-panel__postpublish",
16601 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16602 className: "post-publish-panel__postpublish-header",
16603 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
16604 ref: this.postLink,
16605 href: link,
16606 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')
16607 }), ' ', postPublishNonLinkHeader]
16608 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16609 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16610 className: "post-publish-panel__postpublish-subheader",
16611 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16612 children: (0,external_wp_i18n_namespaceObject.__)('What’s next?')
16613 })
16614 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16615 className: "post-publish-panel__postpublish-post-address-container",
16616 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16617 __nextHasNoMarginBottom: true,
16618 className: "post-publish-panel__postpublish-post-address",
16619 readOnly: true,
16620 label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post type singular name */
16621 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
16622 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
16623 onFocus: this.onSelectInput
16624 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16625 className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
16626 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish_CopyButton, {
16627 text: link,
16628 onCopy: this.onCopy,
16629 children: this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')
16630 })
16631 })]
16632 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16633 className: "post-publish-panel__postpublish-buttons",
16634 children: [!isScheduled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16635 variant: "primary",
16636 href: link,
16637 children: viewPostLabel
16638 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16639 variant: isScheduled ? 'primary' : 'secondary',
16640 href: addLink,
16641 children: addNewPostLabel
16642 })]
16643 })]
16644 }), children]
16645 });
16646 }
16647 }
16648 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
16649 const {
16650 getEditedPostAttribute,
16651 getCurrentPost,
16652 isCurrentPostScheduled
16653 } = select(store_store);
16654 const {
16655 getPostType
16656 } = select(external_wp_coreData_namespaceObject.store);
16657 return {
16658 post: getCurrentPost(),
16659 postType: getPostType(getEditedPostAttribute('type')),
16660 isScheduled: isCurrentPostScheduled()
16661 };
16662 })(PostPublishPanelPostpublish));
16663
16664 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/index.js
16665 /**
16666 * WordPress dependencies
16667 */
16668
16669
16670
16671
16672
16673
16674
16675
16676 /**
16677 * Internal dependencies
16678 */
16679
16680
16681
16682
16683
16684
16685
16686 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
16687 constructor() {
16688 super(...arguments);
16689 this.onSubmit = this.onSubmit.bind(this);
16690 }
16691 componentDidUpdate(prevProps) {
16692 // Automatically collapse the publish sidebar when a post
16693 // is published and the user makes an edit.
16694 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
16695 this.props.onClose();
16696 }
16697 }
16698 onSubmit() {
16699 const {
16700 onClose,
16701 hasPublishAction,
16702 isPostTypeViewable
16703 } = this.props;
16704 if (!hasPublishAction || !isPostTypeViewable) {
16705 onClose();
16706 }
16707 }
16708 render() {
16709 const {
16710 forceIsDirty,
16711 isBeingScheduled,
16712 isPublished,
16713 isPublishSidebarEnabled,
16714 isScheduled,
16715 isSaving,
16716 isSavingNonPostEntityChanges,
16717 onClose,
16718 onTogglePublishSidebar,
16719 PostPublishExtension,
16720 PrePublishExtension,
16721 ...additionalProps
16722 } = this.props;
16723 const {
16724 hasPublishAction,
16725 isDirty,
16726 isPostTypeViewable,
16727 ...propsForPanel
16728 } = additionalProps;
16729 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
16730 const isPrePublish = !isPublishedOrScheduled && !isSaving;
16731 const isPostPublish = isPublishedOrScheduled && !isSaving;
16732 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16733 className: "editor-post-publish-panel",
16734 ...propsForPanel,
16735 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16736 className: "editor-post-publish-panel__header",
16737 children: isPostPublish ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16738 onClick: onClose,
16739 icon: close_small,
16740 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
16741 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16742 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16743 className: "editor-post-publish-panel__header-publish-button",
16744 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
16745 focusOnMount: true,
16746 onSubmit: this.onSubmit,
16747 forceIsDirty: forceIsDirty
16748 })
16749 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16750 className: "editor-post-publish-panel__header-cancel-button",
16751 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16752 __experimentalIsFocusable: true,
16753 disabled: isSavingNonPostEntityChanges,
16754 onClick: onClose,
16755 variant: "secondary",
16756 size: "compact",
16757 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
16758 })
16759 })]
16760 })
16761 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16762 className: "editor-post-publish-panel__content",
16763 children: [isPrePublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(prepublish, {
16764 children: PrePublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrePublishExtension, {})
16765 }), isPostPublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish, {
16766 focusOnMount: true,
16767 children: PostPublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishExtension, {})
16768 }), isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {})]
16769 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16770 className: "editor-post-publish-panel__footer",
16771 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16772 __nextHasNoMarginBottom: true,
16773 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
16774 checked: isPublishSidebarEnabled,
16775 onChange: onTogglePublishSidebar
16776 })
16777 })]
16778 });
16779 }
16780 }
16781
16782 /**
16783 * Renders a panel for publishing a post.
16784 */
16785 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
16786 var _getCurrentPost$_link;
16787 const {
16788 getPostType
16789 } = select(external_wp_coreData_namespaceObject.store);
16790 const {
16791 getCurrentPost,
16792 getEditedPostAttribute,
16793 isCurrentPostPublished,
16794 isCurrentPostScheduled,
16795 isEditedPostBeingScheduled,
16796 isEditedPostDirty,
16797 isAutosavingPost,
16798 isSavingPost,
16799 isSavingNonPostEntityChanges
16800 } = select(store_store);
16801 const {
16802 isPublishSidebarEnabled
16803 } = select(store_store);
16804 const postType = getPostType(getEditedPostAttribute('type'));
16805 return {
16806 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16807 isPostTypeViewable: postType?.viewable,
16808 isBeingScheduled: isEditedPostBeingScheduled(),
16809 isDirty: isEditedPostDirty(),
16810 isPublished: isCurrentPostPublished(),
16811 isPublishSidebarEnabled: isPublishSidebarEnabled(),
16812 isSaving: isSavingPost() && !isAutosavingPost(),
16813 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
16814 isScheduled: isCurrentPostScheduled()
16815 };
16816 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
16817 isPublishSidebarEnabled
16818 }) => {
16819 const {
16820 disablePublishSidebar,
16821 enablePublishSidebar
16822 } = dispatch(store_store);
16823 return {
16824 onTogglePublishSidebar: () => {
16825 if (isPublishSidebarEnabled) {
16826 disablePublishSidebar();
16827 } else {
16828 enablePublishSidebar();
16829 }
16830 }
16831 };
16832 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
16833
16834 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud-upload.js
16835 /**
16836 * WordPress dependencies
16837 */
16838
16839
16840 const cloudUpload = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16841 xmlns: "http://www.w3.org/2000/svg",
16842 viewBox: "0 0 24 24",
16843 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16844 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z"
16845 })
16846 });
16847 /* harmony default export */ const cloud_upload = (cloudUpload);
16848
16849 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
16850 /**
16851 * WordPress dependencies
16852 */
16853
16854
16855 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
16856
16857 /**
16858 * Return an SVG icon.
16859 *
16860 * @param {IconProps} props icon is the SVG component to render
16861 * size is a number specifiying the icon size in pixels
16862 * Other props will be passed to wrapped SVG component
16863 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
16864 *
16865 * @return {JSX.Element} Icon component
16866 */
16867 function Icon({
16868 icon,
16869 size = 24,
16870 ...props
16871 }, ref) {
16872 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
16873 width: size,
16874 height: size,
16875 ...props,
16876 ref
16877 });
16878 }
16879 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
16880
16881 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud.js
16882 /**
16883 * WordPress dependencies
16884 */
16885
16886
16887 const cloud = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16888 xmlns: "http://www.w3.org/2000/svg",
16889 viewBox: "0 0 24 24",
16890 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16891 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z"
16892 })
16893 });
16894 /* harmony default export */ const library_cloud = (cloud);
16895
16896 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-saved-state/index.js
16897 /**
16898 * External dependencies
16899 */
16900
16901
16902 /**
16903 * WordPress dependencies
16904 */
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914 /**
16915 * Internal dependencies
16916 */
16917
16918
16919 /**
16920 * Component showing whether the post is saved or not and providing save
16921 * buttons.
16922 *
16923 * @param {Object} props Component props.
16924 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
16925 * as dirty.
16926 * @return {import('react').ComponentType} The component.
16927 */
16928
16929
16930 function PostSavedState({
16931 forceIsDirty
16932 }) {
16933 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
16934 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
16935 const {
16936 isAutosaving,
16937 isDirty,
16938 isNew,
16939 isPublished,
16940 isSaveable,
16941 isSaving,
16942 isScheduled,
16943 hasPublishAction,
16944 showIconLabels,
16945 postStatus,
16946 postStatusHasChanged
16947 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16948 var _getCurrentPost$_link;
16949 const {
16950 isEditedPostNew,
16951 isCurrentPostPublished,
16952 isCurrentPostScheduled,
16953 isEditedPostDirty,
16954 isSavingPost,
16955 isEditedPostSaveable,
16956 getCurrentPost,
16957 isAutosavingPost,
16958 getEditedPostAttribute,
16959 getPostEdits
16960 } = select(store_store);
16961 const {
16962 get
16963 } = select(external_wp_preferences_namespaceObject.store);
16964 return {
16965 isAutosaving: isAutosavingPost(),
16966 isDirty: forceIsDirty || isEditedPostDirty(),
16967 isNew: isEditedPostNew(),
16968 isPublished: isCurrentPostPublished(),
16969 isSaving: isSavingPost(),
16970 isSaveable: isEditedPostSaveable(),
16971 isScheduled: isCurrentPostScheduled(),
16972 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16973 showIconLabels: get('core', 'showIconLabels'),
16974 postStatus: getEditedPostAttribute('status'),
16975 postStatusHasChanged: !!getPostEdits()?.status
16976 };
16977 }, [forceIsDirty]);
16978 const isPending = postStatus === 'pending';
16979 const {
16980 savePost
16981 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16982 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
16983 (0,external_wp_element_namespaceObject.useEffect)(() => {
16984 let timeoutId;
16985 if (wasSaving && !isSaving) {
16986 setForceSavedMessage(true);
16987 timeoutId = setTimeout(() => {
16988 setForceSavedMessage(false);
16989 }, 1000);
16990 }
16991 return () => clearTimeout(timeoutId);
16992 }, [isSaving]);
16993
16994 // Once the post has been submitted for review this button
16995 // is not needed for the contributor role.
16996 if (!hasPublishAction && isPending) {
16997 return null;
16998 }
16999 if (isPublished || isScheduled || !['pending', 'draft', 'auto-draft'].includes(postStatus) || postStatusHasChanged && ['pending', 'draft'].includes(postStatus)) {
17000 return null;
17001 }
17002
17003 /* translators: button label text should, if possible, be under 16 characters. */
17004 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
17005
17006 /* translators: button label text should, if possible, be under 16 characters. */
17007 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
17008 const isSaved = forceSavedMessage || !isNew && !isDirty;
17009 const isSavedState = isSaving || isSaved;
17010 const isDisabled = isSaving || isSaved || !isSaveable;
17011 let text;
17012 if (isSaving) {
17013 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
17014 } else if (isSaved) {
17015 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
17016 } else if (isLargeViewport) {
17017 text = label;
17018 } else if (showIconLabels) {
17019 text = shortLabel;
17020 }
17021
17022 // Use common Button instance for all saved states so that focus is not
17023 // lost.
17024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
17025 className: isSaveable || isSaving ? dist_clsx({
17026 'editor-post-save-draft': !isSavedState,
17027 'editor-post-saved-state': isSavedState,
17028 'is-saving': isSaving,
17029 'is-autosaving': isAutosaving,
17030 'is-saved': isSaved,
17031 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
17032 type: 'loading'
17033 })]: isSaving
17034 }) : undefined,
17035 onClick: isDisabled ? undefined : () => savePost()
17036 /*
17037 * We want the tooltip to show the keyboard shortcut only when the
17038 * button does something, i.e. when it's not disabled.
17039 */,
17040 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
17041 variant: "tertiary",
17042 size: "compact",
17043 icon: isLargeViewport ? undefined : cloud_upload,
17044 label: text || label,
17045 "aria-disabled": isDisabled,
17046 children: [isSavedState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
17047 icon: isSaved ? library_check : library_cloud
17048 }), text]
17049 });
17050 }
17051
17052 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/check.js
17053 /**
17054 * WordPress dependencies
17055 */
17056
17057
17058 /**
17059 * Internal dependencies
17060 */
17061
17062
17063 /**
17064 * Wrapper component that renders its children only if post has a publish action.
17065 *
17066 * @param {Object} props Props.
17067 * @param {Element} props.children Children to be rendered.
17068 *
17069 * @return {Component} - The component to be rendered or null if there is no publish action.
17070 */
17071 function PostScheduleCheck({
17072 children
17073 }) {
17074 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => {
17075 var _select$getCurrentPos;
17076 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
17077 }, []);
17078 if (!hasPublishAction) {
17079 return null;
17080 }
17081 return children;
17082 }
17083
17084 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/panel.js
17085 /**
17086 * WordPress dependencies
17087 */
17088
17089
17090
17091
17092
17093 /**
17094 * Internal dependencies
17095 */
17096
17097
17098
17099
17100
17101
17102
17103 const DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
17104
17105 /**
17106 * Renders the Post Schedule Panel component.
17107 *
17108 * @return {Component} The component to be rendered.
17109 */
17110 function PostSchedulePanel() {
17111 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
17112 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
17113 // Memoize popoverProps to avoid returning a new object every time.
17114 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
17115 // Anchor the popover to the middle of the entire row so that it doesn't
17116 // move around when the label changes.
17117 anchor: popoverAnchor,
17118 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'),
17119 placement: 'left-start',
17120 offset: 36,
17121 shift: true
17122 }), [popoverAnchor]);
17123 const label = usePostScheduleLabel();
17124 const fullLabel = usePostScheduleLabel({
17125 full: true
17126 });
17127 if (DESIGN_POST_TYPES.includes(postType)) {
17128 return null;
17129 }
17130 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleCheck, {
17131 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17132 label: (0,external_wp_i18n_namespaceObject.__)('Publish'),
17133 ref: setPopoverAnchor,
17134 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
17135 popoverProps: popoverProps,
17136 focusOnMount: true,
17137 className: "editor-post-schedule__panel-dropdown",
17138 contentClassName: "editor-post-schedule__dialog",
17139 renderToggle: ({
17140 onToggle,
17141 isOpen
17142 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17143 size: "compact",
17144 className: "editor-post-schedule__dialog-toggle",
17145 variant: "tertiary",
17146 tooltipPosition: "middle left",
17147 onClick: onToggle,
17148 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
17149 // translators: %s: Current post date.
17150 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label),
17151 label: fullLabel,
17152 showTooltip: label !== fullLabel,
17153 "aria-expanded": isOpen,
17154 children: label
17155 }),
17156 renderContent: ({
17157 onClose
17158 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {
17159 onClose: onClose
17160 })
17161 })
17162 })
17163 });
17164 }
17165
17166 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/check.js
17167 /**
17168 * Internal dependencies
17169 */
17170
17171
17172 function PostSlugCheck({
17173 children
17174 }) {
17175 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17176 supportKeys: "slug",
17177 children: children
17178 });
17179 }
17180
17181 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/index.js
17182 /**
17183 * WordPress dependencies
17184 */
17185
17186
17187
17188
17189
17190
17191 /**
17192 * Internal dependencies
17193 */
17194
17195
17196
17197 function PostSlugControl() {
17198 const postSlug = (0,external_wp_data_namespaceObject.useSelect)(select => {
17199 return (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug());
17200 }, []);
17201 const {
17202 editPost
17203 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17204 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
17205 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
17206 __nextHasNoMarginBottom: true,
17207 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
17208 autoComplete: "off",
17209 spellCheck: "false",
17210 value: forceEmptyField ? '' : postSlug,
17211 onChange: newValue => {
17212 editPost({
17213 slug: newValue
17214 });
17215 // When we delete the field the permalink gets
17216 // reverted to the original value.
17217 // The forceEmptyField logic allows the user to have
17218 // the field temporarily empty while typing.
17219 if (!newValue) {
17220 if (!forceEmptyField) {
17221 setForceEmptyField(true);
17222 }
17223 return;
17224 }
17225 if (forceEmptyField) {
17226 setForceEmptyField(false);
17227 }
17228 },
17229 onBlur: event => {
17230 editPost({
17231 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
17232 });
17233 if (forceEmptyField) {
17234 setForceEmptyField(false);
17235 }
17236 },
17237 className: "editor-post-slug"
17238 });
17239 }
17240 function PostSlug() {
17241 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugCheck, {
17242 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugControl, {})
17243 });
17244 }
17245
17246 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/check.js
17247 /**
17248 * WordPress dependencies
17249 */
17250
17251
17252 /**
17253 * Internal dependencies
17254 */
17255
17256
17257 /**
17258 * Wrapper component that renders its children only if post has a sticky action.
17259 *
17260 * @param {Object} props Props.
17261 * @param {Element} props.children Children to be rendered.
17262 *
17263 * @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
17264 */
17265 function PostStickyCheck({
17266 children
17267 }) {
17268 const {
17269 hasStickyAction,
17270 postType
17271 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17272 var _post$_links$wpActio;
17273 const post = select(store_store).getCurrentPost();
17274 return {
17275 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
17276 postType: select(store_store).getCurrentPostType()
17277 };
17278 }, []);
17279 if (postType !== 'post' || !hasStickyAction) {
17280 return null;
17281 }
17282 return children;
17283 }
17284
17285 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/index.js
17286 /**
17287 * WordPress dependencies
17288 */
17289
17290
17291
17292
17293 /**
17294 * Internal dependencies
17295 */
17296
17297
17298
17299
17300 /**
17301 * Renders the PostSticky component. It provide toggle control for the sticky post feature.
17302 *
17303 * @return {Component} The component to be rendered.
17304 */
17305
17306 function PostSticky() {
17307 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => {
17308 var _select$getEditedPost;
17309 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false;
17310 }, []);
17311 const {
17312 editPost
17313 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17314 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStickyCheck, {
17315 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17316 label: (0,external_wp_i18n_namespaceObject.__)('Sticky'),
17317 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
17318 className: "editor-post-sticky__toggle-control",
17319 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17320 children: (0,external_wp_i18n_namespaceObject.__)('Sticky')
17321 }),
17322 checked: postSticky,
17323 onChange: () => editPost({
17324 sticky: !postSticky
17325 })
17326 })
17327 })
17328 });
17329 }
17330
17331 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
17332 /**
17333 * WordPress dependencies
17334 */
17335
17336
17337
17338
17339
17340
17341 /**
17342 * Internal dependencies
17343 */
17344
17345
17346 /**
17347 * Renders a button component that allows the user to switch a post to draft status.
17348 *
17349 * @return {JSX.Element} The rendered component.
17350 */
17351
17352
17353
17354 function PostSwitchToDraftButton() {
17355 external_wp_deprecated_default()('wp.editor.PostSwitchToDraftButton', {
17356 since: '6.7',
17357 version: '6.9'
17358 });
17359 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
17360 const {
17361 editPost,
17362 savePost
17363 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17364 const {
17365 isSaving,
17366 isPublished,
17367 isScheduled
17368 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17369 const {
17370 isSavingPost,
17371 isCurrentPostPublished,
17372 isCurrentPostScheduled
17373 } = select(store_store);
17374 return {
17375 isSaving: isSavingPost(),
17376 isPublished: isCurrentPostPublished(),
17377 isScheduled: isCurrentPostScheduled()
17378 };
17379 }, []);
17380 const isDisabled = isSaving || !isPublished && !isScheduled;
17381 let alertMessage;
17382 let confirmButtonText;
17383 if (isPublished) {
17384 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
17385 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unpublish');
17386 } else if (isScheduled) {
17387 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
17388 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unschedule');
17389 }
17390 const handleConfirm = () => {
17391 setShowConfirmDialog(false);
17392 editPost({
17393 status: 'draft'
17394 });
17395 savePost();
17396 };
17397 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17398 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17399 __next40pxDefaultSize: true,
17400 className: "editor-post-switch-to-draft",
17401 onClick: () => {
17402 if (!isDisabled) {
17403 setShowConfirmDialog(true);
17404 }
17405 },
17406 "aria-disabled": isDisabled,
17407 variant: "secondary",
17408 style: {
17409 flexGrow: '1',
17410 justifyContent: 'center'
17411 },
17412 children: (0,external_wp_i18n_namespaceObject.__)('Switch to draft')
17413 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
17414 isOpen: showConfirmDialog,
17415 onConfirm: handleConfirm,
17416 onCancel: () => setShowConfirmDialog(false),
17417 confirmButtonText: confirmButtonText,
17418 children: alertMessage
17419 })]
17420 });
17421 }
17422
17423 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sync-status/index.js
17424 /**
17425 * WordPress dependencies
17426 */
17427
17428
17429
17430 /**
17431 * Internal dependencies
17432 */
17433
17434
17435
17436 /**
17437 * Renders the sync status of a post.
17438 *
17439 * @return {JSX.Element|null} The rendered sync status component.
17440 */
17441
17442 function PostSyncStatus() {
17443 const {
17444 syncStatus,
17445 postType
17446 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17447 const {
17448 getEditedPostAttribute
17449 } = select(store_store);
17450 const meta = getEditedPostAttribute('meta');
17451
17452 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
17453 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
17454 return {
17455 syncStatus: currentSyncStatus,
17456 postType: getEditedPostAttribute('type')
17457 };
17458 });
17459 if (postType !== 'wp_block') {
17460 return null;
17461 }
17462 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17463 label: (0,external_wp_i18n_namespaceObject.__)('Sync status'),
17464 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
17465 className: "editor-post-sync-status__value",
17466 children: syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'pattern (singular)') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)')
17467 })
17468 });
17469 }
17470
17471 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/index.js
17472 /**
17473 * WordPress dependencies
17474 */
17475
17476
17477
17478
17479 /**
17480 * Internal dependencies
17481 */
17482
17483
17484
17485
17486 const post_taxonomies_identity = x => x;
17487 function PostTaxonomies({
17488 taxonomyWrapper = post_taxonomies_identity
17489 }) {
17490 const {
17491 postType,
17492 taxonomies
17493 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17494 return {
17495 postType: select(store_store).getCurrentPostType(),
17496 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17497 per_page: -1
17498 })
17499 };
17500 }, []);
17501 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
17502 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
17503 // https://github.com/WordPress/gutenberg/issues/40326
17504 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
17505 return visibleTaxonomies.map(taxonomy => {
17506 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
17507 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
17508 children: taxonomyWrapper( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyComponent, {
17509 slug: taxonomy.slug
17510 }), taxonomy)
17511 }, `taxonomy-${taxonomy.slug}`);
17512 });
17513 }
17514
17515 /**
17516 * Renders the taxonomies associated with a post.
17517 *
17518 * @param {Object} props The component props.
17519 * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
17520 *
17521 * @return {Array} An array of JSX elements representing the visible taxonomies.
17522 */
17523 /* harmony default export */ const post_taxonomies = (PostTaxonomies);
17524
17525 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/check.js
17526 /**
17527 * WordPress dependencies
17528 */
17529
17530
17531
17532 /**
17533 * Internal dependencies
17534 */
17535
17536
17537 /**
17538 * Renders the children components only if the current post type has taxonomies.
17539 *
17540 * @param {Object} props The component props.
17541 * @param {Element} props.children The children components to render.
17542 *
17543 * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
17544 */
17545 function PostTaxonomiesCheck({
17546 children
17547 }) {
17548 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => {
17549 const postType = select(store_store).getCurrentPostType();
17550 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17551 per_page: -1
17552 });
17553 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
17554 }, []);
17555 if (!hasTaxonomies) {
17556 return null;
17557 }
17558 return children;
17559 }
17560
17561 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/panel.js
17562 /**
17563 * WordPress dependencies
17564 */
17565
17566
17567
17568 /**
17569 * Internal dependencies
17570 */
17571
17572
17573
17574
17575 function TaxonomyPanel({
17576 taxonomy,
17577 children
17578 }) {
17579 const slug = taxonomy?.slug;
17580 const panelName = slug ? `taxonomy-panel-${slug}` : '';
17581 const {
17582 isEnabled,
17583 isOpened
17584 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17585 const {
17586 isEditorPanelEnabled,
17587 isEditorPanelOpened
17588 } = select(store_store);
17589 return {
17590 isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
17591 isOpened: slug ? isEditorPanelOpened(panelName) : false
17592 };
17593 }, [panelName, slug]);
17594 const {
17595 toggleEditorPanelOpened
17596 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17597 if (!isEnabled) {
17598 return null;
17599 }
17600 const taxonomyMenuName = taxonomy?.labels?.menu_name;
17601 if (!taxonomyMenuName) {
17602 return null;
17603 }
17604 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
17605 title: taxonomyMenuName,
17606 opened: isOpened,
17607 onToggle: () => toggleEditorPanelOpened(panelName),
17608 children: children
17609 });
17610 }
17611 function panel_PostTaxonomies() {
17612 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTaxonomiesCheck, {
17613 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
17614 taxonomyWrapper: (content, taxonomy) => {
17615 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyPanel, {
17616 taxonomy: taxonomy,
17617 children: content
17618 });
17619 }
17620 })
17621 });
17622 }
17623
17624 /**
17625 * Renders a panel for a specific taxonomy.
17626 *
17627 * @param {Object} props The component props.
17628 * @param {Object} props.taxonomy The taxonomy object.
17629 * @param {Element} props.children The child components.
17630 *
17631 * @return {Component} The rendered taxonomy panel.
17632 */
17633 /* harmony default export */ const post_taxonomies_panel = (panel_PostTaxonomies);
17634
17635 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
17636 var lib = __webpack_require__(773);
17637 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-text-editor/index.js
17638 /**
17639 * External dependencies
17640 */
17641
17642
17643 /**
17644 * WordPress dependencies
17645 */
17646
17647
17648
17649
17650
17651
17652
17653
17654 /**
17655 * Internal dependencies
17656 */
17657
17658
17659 /**
17660 * Displays the Post Text Editor along with content in Visual and Text mode.
17661 *
17662 * @return {JSX.Element|null} The rendered PostTextEditor component.
17663 */
17664
17665
17666
17667 function PostTextEditor() {
17668 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
17669 const {
17670 content,
17671 blocks,
17672 type,
17673 id
17674 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17675 const {
17676 getEditedEntityRecord
17677 } = select(external_wp_coreData_namespaceObject.store);
17678 const {
17679 getCurrentPostType,
17680 getCurrentPostId
17681 } = select(store_store);
17682 const _type = getCurrentPostType();
17683 const _id = getCurrentPostId();
17684 const editedRecord = getEditedEntityRecord('postType', _type, _id);
17685 return {
17686 content: editedRecord?.content,
17687 blocks: editedRecord?.blocks,
17688 type: _type,
17689 id: _id
17690 };
17691 }, []);
17692 const {
17693 editEntityRecord
17694 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
17695 // Replicates the logic found in getEditedPostContent().
17696 const value = (0,external_wp_element_namespaceObject.useMemo)(() => {
17697 if (content instanceof Function) {
17698 return content({
17699 blocks
17700 });
17701 } else if (blocks) {
17702 // If we have parsed blocks already, they should be our source of truth.
17703 // Parsing applies block deprecations and legacy block conversions that
17704 // unparsed content will not have.
17705 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
17706 }
17707 return content;
17708 }, [content, blocks]);
17709 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17710 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17711 as: "label",
17712 htmlFor: `post-content-${instanceId}`,
17713 children: (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')
17714 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(lib/* default */.Z, {
17715 autoComplete: "off",
17716 dir: "auto",
17717 value: value,
17718 onChange: event => {
17719 editEntityRecord('postType', type, id, {
17720 content: event.target.value,
17721 blocks: undefined,
17722 selection: undefined
17723 });
17724 },
17725 className: "editor-post-text-editor",
17726 id: `post-content-${instanceId}`,
17727 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
17728 })]
17729 });
17730 }
17731
17732 ;// CONCATENATED MODULE: external ["wp","dom"]
17733 const external_wp_dom_namespaceObject = window["wp"]["dom"];
17734 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/constants.js
17735 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text';
17736 const REGEXP_NEWLINES = /[\r\n]+/g;
17737
17738 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title-focus.js
17739 /**
17740 * WordPress dependencies
17741 */
17742
17743
17744
17745 /**
17746 * Internal dependencies
17747 */
17748
17749
17750 /**
17751 * Custom hook that manages the focus behavior of the post title input field.
17752 *
17753 * @param {Element} forwardedRef - The forwarded ref for the input field.
17754 *
17755 * @return {Object} - The ref object.
17756 */
17757 function usePostTitleFocus(forwardedRef) {
17758 const ref = (0,external_wp_element_namespaceObject.useRef)();
17759 const {
17760 isCleanNewPost
17761 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17762 const {
17763 isCleanNewPost: _isCleanNewPost
17764 } = select(store_store);
17765 return {
17766 isCleanNewPost: _isCleanNewPost()
17767 };
17768 }, []);
17769 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
17770 focus: () => {
17771 ref?.current?.focus();
17772 }
17773 }));
17774 (0,external_wp_element_namespaceObject.useEffect)(() => {
17775 if (!ref.current) {
17776 return;
17777 }
17778 const {
17779 defaultView
17780 } = ref.current.ownerDocument;
17781 const {
17782 name,
17783 parent
17784 } = defaultView;
17785 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
17786 const {
17787 activeElement,
17788 body
17789 } = ownerDocument;
17790
17791 // Only autofocus the title when the post is entirely empty. This should
17792 // only happen for a new post, which means we focus the title on new
17793 // post so the author can start typing right away, without needing to
17794 // click anything.
17795 if (isCleanNewPost && (!activeElement || body === activeElement)) {
17796 ref.current.focus();
17797 }
17798 }, [isCleanNewPost]);
17799 return {
17800 ref
17801 };
17802 }
17803
17804 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title.js
17805 /**
17806 * WordPress dependencies
17807 */
17808
17809 /**
17810 * Internal dependencies
17811 */
17812
17813
17814 /**
17815 * Custom hook for managing the post title in the editor.
17816 *
17817 * @return {Object} An object containing the current title and a function to update the title.
17818 */
17819 function usePostTitle() {
17820 const {
17821 editPost
17822 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17823 const {
17824 title
17825 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17826 const {
17827 getEditedPostAttribute
17828 } = select(store_store);
17829 return {
17830 title: getEditedPostAttribute('title')
17831 };
17832 }, []);
17833 function updateTitle(newTitle) {
17834 editPost({
17835 title: newTitle
17836 });
17837 }
17838 return {
17839 title,
17840 setTitle: updateTitle
17841 };
17842 }
17843
17844 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/index.js
17845 /**
17846 * External dependencies
17847 */
17848
17849 /**
17850 * WordPress dependencies
17851 */
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863 /**
17864 * Internal dependencies
17865 */
17866
17867
17868
17869
17870
17871 function PostTitle(_, forwardedRef) {
17872 const {
17873 placeholder
17874 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17875 const {
17876 getSettings
17877 } = select(external_wp_blockEditor_namespaceObject.store);
17878 const {
17879 titlePlaceholder
17880 } = getSettings();
17881 return {
17882 placeholder: titlePlaceholder
17883 };
17884 }, []);
17885 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
17886 const {
17887 ref: focusRef
17888 } = usePostTitleFocus(forwardedRef);
17889 const {
17890 title,
17891 setTitle: onUpdate
17892 } = usePostTitle();
17893 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
17894 const {
17895 clearSelectedBlock,
17896 insertBlocks,
17897 insertDefaultBlock
17898 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
17899 function onChange(value) {
17900 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
17901 }
17902 function onInsertBlockAfter(blocks) {
17903 insertBlocks(blocks, 0);
17904 }
17905 function onSelect() {
17906 setIsSelected(true);
17907 clearSelectedBlock();
17908 }
17909 function onUnselect() {
17910 setIsSelected(false);
17911 setSelection({});
17912 }
17913 function onEnterPress() {
17914 insertDefaultBlock(undefined, undefined, 0);
17915 }
17916 function onKeyDown(event) {
17917 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
17918 event.preventDefault();
17919 onEnterPress();
17920 }
17921 }
17922 function onPaste(event) {
17923 const clipboardData = event.clipboardData;
17924 let plainText = '';
17925 let html = '';
17926
17927 // IE11 only supports `Text` as an argument for `getData` and will
17928 // otherwise throw an invalid argument error, so we try the standard
17929 // arguments first, then fallback to `Text` if they fail.
17930 try {
17931 plainText = clipboardData.getData('text/plain');
17932 html = clipboardData.getData('text/html');
17933 } catch (error1) {
17934 try {
17935 html = clipboardData.getData('Text');
17936 } catch (error2) {
17937 // Some browsers like UC Browser paste plain text by default and
17938 // don't support clipboardData at all, so allow default
17939 // behaviour.
17940 return;
17941 }
17942 }
17943
17944 // Allows us to ask for this information when we get a report.
17945 window.console.log('Received HTML:\n\n', html);
17946 window.console.log('Received plain text:\n\n', plainText);
17947 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
17948 HTML: html,
17949 plainText
17950 });
17951 event.preventDefault();
17952 if (!content.length) {
17953 return;
17954 }
17955 if (typeof content !== 'string') {
17956 const [firstBlock] = content;
17957 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
17958 // Strip HTML to avoid unwanted HTML being added to the title.
17959 // In the majority of cases it is assumed that HTML in the title
17960 // is undesirable.
17961 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content);
17962 onUpdate(contentNoHTML);
17963 onInsertBlockAfter(content.slice(1));
17964 } else {
17965 onInsertBlockAfter(content);
17966 }
17967 } else {
17968 const value = {
17969 ...(0,external_wp_richText_namespaceObject.create)({
17970 html: title
17971 }),
17972 ...selection
17973 };
17974
17975 // Strip HTML to avoid unwanted HTML being added to the title.
17976 // In the majority of cases it is assumed that HTML in the title
17977 // is undesirable.
17978 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content);
17979 const newValue = (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
17980 html: contentNoHTML
17981 }));
17982 onUpdate((0,external_wp_richText_namespaceObject.toHTMLString)({
17983 value: newValue
17984 }));
17985 setSelection({
17986 start: newValue.start,
17987 end: newValue.end
17988 });
17989 }
17990 }
17991 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
17992 const {
17993 ref: richTextRef
17994 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
17995 value: title,
17996 onChange,
17997 placeholder: decodedPlaceholder,
17998 selectionStart: selection.start,
17999 selectionEnd: selection.end,
18000 onSelectionChange(newStart, newEnd) {
18001 setSelection(sel => {
18002 const {
18003 start,
18004 end
18005 } = sel;
18006 if (start === newStart && end === newEnd) {
18007 return sel;
18008 }
18009 return {
18010 start: newStart,
18011 end: newEnd
18012 };
18013 });
18014 },
18015 __unstableDisableFormats: false
18016 });
18017
18018 // The wp-block className is important for editor styles.
18019 // This same block is used in both the visual and the code editor.
18020 const className = dist_clsx(DEFAULT_CLASSNAMES, {
18021 'is-selected': isSelected
18022 });
18023 return (
18024 /*#__PURE__*/
18025 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
18026 (0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
18027 supportKeys: "title",
18028 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
18029 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]),
18030 contentEditable: true,
18031 className: className,
18032 "aria-label": decodedPlaceholder,
18033 role: "textbox",
18034 "aria-multiline": "true",
18035 onFocus: onSelect,
18036 onBlur: onUnselect,
18037 onKeyDown: onKeyDown,
18038 onKeyPress: onUnselect,
18039 onPaste: onPaste
18040 })
18041 })
18042 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
18043 );
18044 }
18045
18046 /**
18047 * Renders the `PostTitle` component.
18048 *
18049 * @param {Object} _ Unused parameter.
18050 * @param {Element} forwardedRef Forwarded ref for the component.
18051 *
18052 * @return {Component} The rendered PostTitle component.
18053 */
18054 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle));
18055
18056 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/post-title-raw.js
18057 /**
18058 * External dependencies
18059 */
18060
18061
18062 /**
18063 * WordPress dependencies
18064 */
18065
18066
18067
18068
18069
18070
18071
18072 /**
18073 * Internal dependencies
18074 */
18075
18076
18077
18078
18079 /**
18080 * Renders a raw post title input field.
18081 *
18082 * @param {Object} _ Unused parameter.
18083 * @param {Element} forwardedRef Reference to the component's DOM node.
18084 *
18085 * @return {Component} The rendered component.
18086 */
18087
18088 function PostTitleRaw(_, forwardedRef) {
18089 const {
18090 placeholder
18091 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18092 const {
18093 getSettings
18094 } = select(external_wp_blockEditor_namespaceObject.store);
18095 const {
18096 titlePlaceholder
18097 } = getSettings();
18098 return {
18099 placeholder: titlePlaceholder
18100 };
18101 }, []);
18102 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
18103 const {
18104 title,
18105 setTitle: onUpdate
18106 } = usePostTitle();
18107 const {
18108 ref: focusRef
18109 } = usePostTitleFocus(forwardedRef);
18110 function onChange(value) {
18111 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
18112 }
18113 function onSelect() {
18114 setIsSelected(true);
18115 }
18116 function onUnselect() {
18117 setIsSelected(false);
18118 }
18119
18120 // The wp-block className is important for editor styles.
18121 // This same block is used in both the visual and the code editor.
18122 const className = dist_clsx(DEFAULT_CLASSNAMES, {
18123 'is-selected': isSelected,
18124 'is-raw-text': true
18125 });
18126 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
18127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
18128 ref: focusRef,
18129 value: title,
18130 onChange: onChange,
18131 onFocus: onSelect,
18132 onBlur: onUnselect,
18133 label: placeholder,
18134 className: className,
18135 placeholder: decodedPlaceholder,
18136 hideLabelFromVision: true,
18137 autoComplete: "off",
18138 dir: "auto",
18139 rows: 1,
18140 __nextHasNoMarginBottom: true
18141 });
18142 }
18143 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw));
18144
18145 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/index.js
18146 /**
18147 * WordPress dependencies
18148 */
18149
18150
18151
18152
18153
18154 /**
18155 * Internal dependencies
18156 */
18157
18158
18159 /**
18160 * Displays the Post Trash Button and Confirm Dialog in the Editor.
18161 *
18162 * @return {JSX.Element|null} The rendered PostTrash component.
18163 */
18164
18165
18166
18167 function PostTrash() {
18168 const {
18169 isNew,
18170 isDeleting,
18171 postId
18172 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18173 const store = select(store_store);
18174 return {
18175 isNew: store.isEditedPostNew(),
18176 isDeleting: store.isDeletingPost(),
18177 postId: store.getCurrentPostId()
18178 };
18179 }, []);
18180 const {
18181 trashPost
18182 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18183 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
18184 if (isNew || !postId) {
18185 return null;
18186 }
18187 const handleConfirm = () => {
18188 setShowConfirmDialog(false);
18189 trashPost();
18190 };
18191 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18192 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18193 __next40pxDefaultSize: true,
18194 className: "editor-post-trash",
18195 isDestructive: true,
18196 variant: "secondary",
18197 isBusy: isDeleting,
18198 "aria-disabled": isDeleting,
18199 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true),
18200 children: (0,external_wp_i18n_namespaceObject.__)('Move to trash')
18201 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
18202 isOpen: showConfirmDialog,
18203 onConfirm: handleConfirm,
18204 onCancel: () => setShowConfirmDialog(false),
18205 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
18206 size: "medium",
18207 children: (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move this post to the trash?')
18208 })]
18209 });
18210 }
18211
18212 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/check.js
18213 /**
18214 * WordPress dependencies
18215 */
18216
18217
18218
18219 /**
18220 * Internal dependencies
18221 */
18222
18223
18224 /**
18225 * Wrapper component that renders its children only if the post can trashed.
18226 *
18227 * @param {Object} props - The component props.
18228 * @param {Element} props.children - The child components to render.
18229 *
18230 * @return {Component|null} The rendered child components or null if the post can not trashed.
18231 */
18232 function PostTrashCheck({
18233 children
18234 }) {
18235 const {
18236 canTrashPost
18237 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18238 const {
18239 isEditedPostNew,
18240 getCurrentPostId,
18241 getCurrentPostType
18242 } = select(store_store);
18243 const {
18244 getPostType,
18245 canUser
18246 } = select(external_wp_coreData_namespaceObject.store);
18247 const postType = getPostType(getCurrentPostType());
18248 const postId = getCurrentPostId();
18249 const isNew = isEditedPostNew();
18250 const resource = postType?.rest_base || ''; // eslint-disable-line camelcase
18251 const canUserDelete = postId && resource ? canUser('delete', resource, postId) : false;
18252 return {
18253 canTrashPost: (!isNew || postId) && canUserDelete
18254 };
18255 }, []);
18256 if (!canTrashPost) {
18257 return null;
18258 }
18259 return children;
18260 }
18261
18262 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/copy-small.js
18263 /**
18264 * WordPress dependencies
18265 */
18266
18267
18268 const copySmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18269 xmlns: "http://www.w3.org/2000/svg",
18270 viewBox: "0 0 24 24",
18271 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18272 fillRule: "evenodd",
18273 clipRule: "evenodd",
18274 d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z"
18275 })
18276 });
18277 /* harmony default export */ const copy_small = (copySmall);
18278
18279 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/index.js
18280 /**
18281 * WordPress dependencies
18282 */
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294 /**
18295 * Internal dependencies
18296 */
18297
18298
18299 /**
18300 * Renders the `PostURL` component.
18301 *
18302 * @example
18303 * ```jsx
18304 * <PostURL />
18305 * ```
18306 *
18307 * @param {Function} onClose Callback function to be executed when the popover is closed.
18308 *
18309 * @return {Component} The rendered PostURL component.
18310 */
18311
18312
18313 function PostURL({
18314 onClose
18315 }) {
18316 const {
18317 isEditable,
18318 postSlug,
18319 postLink,
18320 permalinkPrefix,
18321 permalinkSuffix,
18322 permalink
18323 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18324 var _post$_links$wpActio;
18325 const post = select(store_store).getCurrentPost();
18326 const postTypeSlug = select(store_store).getCurrentPostType();
18327 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18328 const permalinkParts = select(store_store).getPermalinkParts();
18329 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false;
18330 return {
18331 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction,
18332 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()),
18333 viewPostLabel: postType?.labels.view_item,
18334 postLink: post.link,
18335 permalinkPrefix: permalinkParts?.prefix,
18336 permalinkSuffix: permalinkParts?.suffix,
18337 permalink: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getPermalink())
18338 };
18339 }, []);
18340 const {
18341 editPost
18342 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18343 const {
18344 createNotice
18345 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
18346 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
18347 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
18348 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied URL to clipboard.'), {
18349 isDismissible: true,
18350 type: 'snackbar'
18351 });
18352 });
18353 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18354 className: "editor-post-url",
18355 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
18356 title: (0,external_wp_i18n_namespaceObject.__)('Link'),
18357 onClose: onClose
18358 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
18359 spacing: 3,
18360 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18361 children: [(0,external_wp_i18n_namespaceObject.__)('Customize the last part of the URL. '), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18362 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'),
18363 children: (0,external_wp_i18n_namespaceObject.__)('Learn more.')
18364 })]
18365 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18366 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
18367 __next40pxDefaultSize: true,
18368 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
18369 children: "/"
18370 }),
18371 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18372 icon: copy_small,
18373 ref: copyButtonRef,
18374 label: (0,external_wp_i18n_namespaceObject.__)('Copy')
18375 }),
18376 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18377 hideLabelFromVision: true,
18378 value: forceEmptyField ? '' : postSlug,
18379 autoComplete: "off",
18380 spellCheck: "false",
18381 type: "text",
18382 className: "editor-post-url__input",
18383 onChange: newValue => {
18384 editPost({
18385 slug: newValue
18386 });
18387 // When we delete the field the permalink gets
18388 // reverted to the original value.
18389 // The forceEmptyField logic allows the user to have
18390 // the field temporarily empty while typing.
18391 if (!newValue) {
18392 if (!forceEmptyField) {
18393 setForceEmptyField(true);
18394 }
18395 return;
18396 }
18397 if (forceEmptyField) {
18398 setForceEmptyField(false);
18399 }
18400 },
18401 onBlur: event => {
18402 editPost({
18403 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
18404 });
18405 if (forceEmptyField) {
18406 setForceEmptyField(false);
18407 }
18408 },
18409 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
18410 className: "editor-post-url__link",
18411 href: postLink,
18412 target: "_blank",
18413 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18414 className: "editor-post-url__link-prefix",
18415 children: permalinkPrefix
18416 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18417 className: "editor-post-url__link-slug",
18418 children: postSlug
18419 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18420 className: "editor-post-url__link-suffix",
18421 children: permalinkSuffix
18422 })]
18423 })
18424 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18425 className: "editor-post-url__link",
18426 href: postLink,
18427 target: "_blank",
18428 children: postLink
18429 })]
18430 })]
18431 })]
18432 });
18433 }
18434
18435 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/check.js
18436 /**
18437 * WordPress dependencies
18438 */
18439
18440
18441
18442 /**
18443 * Internal dependencies
18444 */
18445
18446
18447 /**
18448 * Check if the post URL is valid and visible.
18449 *
18450 * @param {Object} props The component props.
18451 * @param {Element} props.children The child components.
18452 *
18453 * @return {Component|null} The child components if the post URL is valid and visible, otherwise null.
18454 */
18455 function PostURLCheck({
18456 children
18457 }) {
18458 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
18459 const postTypeSlug = select(store_store).getCurrentPostType();
18460 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18461 if (!postType?.viewable) {
18462 return false;
18463 }
18464 const post = select(store_store).getCurrentPost();
18465 if (!post.link) {
18466 return false;
18467 }
18468 const permalinkParts = select(store_store).getPermalinkParts();
18469 if (!permalinkParts) {
18470 return false;
18471 }
18472 return true;
18473 }, []);
18474 if (!isVisible) {
18475 return null;
18476 }
18477 return children;
18478 }
18479
18480 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/label.js
18481 /**
18482 * WordPress dependencies
18483 */
18484
18485
18486
18487 /**
18488 * Internal dependencies
18489 */
18490
18491
18492 /**
18493 * Represents a label component for a post URL.
18494 *
18495 * @return {Component} The PostURLLabel component.
18496 */
18497 function PostURLLabel() {
18498 return usePostURLLabel();
18499 }
18500
18501 /**
18502 * Custom hook to get the label for the post URL.
18503 *
18504 * @return {string} The filtered and decoded post URL label.
18505 */
18506 function usePostURLLabel() {
18507 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []);
18508 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink));
18509 }
18510
18511 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/panel.js
18512 /**
18513 * WordPress dependencies
18514 */
18515
18516
18517
18518
18519
18520
18521
18522 /**
18523 * Internal dependencies
18524 */
18525
18526
18527
18528
18529
18530 /**
18531 * Renders the `PostURLPanel` component.
18532 *
18533 * @return {JSX.Element} The rendered PostURLPanel component.
18534 */
18535
18536
18537
18538 function PostURLPanel() {
18539 // Use internal state instead of a ref to make sure that the component
18540 // re-renders when the popover's anchor updates.
18541 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
18542 // Memoize popoverProps to avoid returning a new object every time.
18543 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
18544 // Anchor the popover to the middle of the entire row so that it doesn't
18545 // move around when the label changes.
18546 anchor: popoverAnchor,
18547 placement: 'left-start',
18548 offset: 36,
18549 shift: true
18550 }), [popoverAnchor]);
18551 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLCheck, {
18552 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
18553 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18554 ref: setPopoverAnchor,
18555 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18556 popoverProps: popoverProps,
18557 className: "editor-post-url__panel-dropdown",
18558 contentClassName: "editor-post-url__panel-dialog",
18559 focusOnMount: true,
18560 renderToggle: ({
18561 isOpen,
18562 onToggle
18563 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLToggle, {
18564 isOpen: isOpen,
18565 onClick: onToggle
18566 }),
18567 renderContent: ({
18568 onClose
18569 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURL, {
18570 onClose: onClose
18571 })
18572 })
18573 })
18574 });
18575 }
18576 function PostURLToggle({
18577 isOpen,
18578 onClick
18579 }) {
18580 const {
18581 slug,
18582 isFrontPage,
18583 postLink
18584 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18585 const {
18586 getCurrentPostId,
18587 getCurrentPost
18588 } = select(store_store);
18589 const {
18590 getEditedEntityRecord
18591 } = select(external_wp_coreData_namespaceObject.store);
18592 const siteSettings = getEditedEntityRecord('root', 'site');
18593 const _id = getCurrentPostId();
18594 return {
18595 slug: select(store_store).getEditedPostSlug(),
18596 isFrontPage: siteSettings?.page_on_front === _id,
18597 postLink: getCurrentPost()?.link
18598 };
18599 }, []);
18600 const decodedSlug = (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(slug);
18601 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18602 size: "compact",
18603 className: "editor-post-url__panel-toggle",
18604 variant: "tertiary",
18605 "aria-expanded": isOpen
18606 // translators: %s: Current post link.
18607 ,
18608 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change link: %s'), decodedSlug),
18609 onClick: onClick,
18610 children: isFrontPage ? postLink : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18611 children: ["/", decodedSlug]
18612 })
18613 });
18614 }
18615
18616 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/check.js
18617 /**
18618 * WordPress dependencies
18619 */
18620
18621
18622 /**
18623 * Internal dependencies
18624 */
18625
18626
18627 /**
18628 * Determines if the current post can be edited (published)
18629 * and passes this information to the provided render function.
18630 *
18631 * @param {Object} props The component props.
18632 * @param {Function} props.render Function to render the component.
18633 * Receives an object with a `canEdit` property.
18634 * @return {JSX.Element} The rendered component.
18635 */
18636 function PostVisibilityCheck({
18637 render
18638 }) {
18639 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => {
18640 var _select$getCurrentPos;
18641 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
18642 });
18643 return render({
18644 canEdit
18645 });
18646 }
18647
18648 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/info.js
18649 /**
18650 * WordPress dependencies
18651 */
18652
18653
18654 const info = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18655 xmlns: "http://www.w3.org/2000/svg",
18656 viewBox: "0 0 24 24",
18657 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18658 d: "M12 3.2c-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.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
18659 })
18660 });
18661 /* harmony default export */ const library_info = (info);
18662
18663 ;// CONCATENATED MODULE: external ["wp","wordcount"]
18664 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
18665 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/word-count/index.js
18666 /**
18667 * WordPress dependencies
18668 */
18669
18670
18671
18672
18673 /**
18674 * Internal dependencies
18675 */
18676
18677
18678 /**
18679 * Renders the word count of the post content.
18680 *
18681 * @return {JSX.Element|null} The rendered WordCount component.
18682 */
18683
18684 function WordCount() {
18685 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18686
18687 /*
18688 * translators: If your word count is based on single characters (e.g. East Asian characters),
18689 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18690 * Do not translate into your own language.
18691 */
18692 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18693 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18694 className: "word-count",
18695 children: (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)
18696 });
18697 }
18698
18699 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/time-to-read/index.js
18700 /**
18701 * WordPress dependencies
18702 */
18703
18704
18705
18706
18707
18708 /**
18709 * Internal dependencies
18710 */
18711
18712
18713 /**
18714 * Average reading rate - based on average taken from
18715 * https://irisreading.com/average-reading-speed-in-various-languages/
18716 * (Characters/minute used for Chinese rather than words).
18717 *
18718 * @type {number} A rough estimate of the average reading rate across multiple languages.
18719 */
18720
18721 const AVERAGE_READING_RATE = 189;
18722
18723 /**
18724 * Component for showing Time To Read in Content.
18725 *
18726 * @return {JSX.Element} The rendered TimeToRead component.
18727 */
18728 function TimeToRead() {
18729 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18730
18731 /*
18732 * translators: If your word count is based on single characters (e.g. East Asian characters),
18733 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18734 * Do not translate into your own language.
18735 */
18736 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18737 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE);
18738 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), {
18739 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18740 }) : (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s is the number of minutes the post will take to read. */
18741 (0,external_wp_i18n_namespaceObject._n)('<span>%d</span> minute', '<span>%d</span> minutes', minutesToRead), minutesToRead), {
18742 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18743 });
18744 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18745 className: "time-to-read",
18746 children: minutesToReadString
18747 });
18748 }
18749
18750 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/character-count/index.js
18751 /**
18752 * WordPress dependencies
18753 */
18754
18755
18756
18757 /**
18758 * Internal dependencies
18759 */
18760
18761
18762 /**
18763 * Renders the character count of the post content.
18764 *
18765 * @return {number} The character count.
18766 */
18767 function CharacterCount() {
18768 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18769 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
18770 }
18771
18772 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/panel.js
18773 /**
18774 * WordPress dependencies
18775 */
18776
18777
18778
18779
18780 /**
18781 * Internal dependencies
18782 */
18783
18784
18785
18786
18787
18788
18789
18790 function TableOfContentsPanel({
18791 hasOutlineItemsDisabled,
18792 onRequestClose
18793 }) {
18794 const {
18795 headingCount,
18796 paragraphCount,
18797 numberOfBlocks
18798 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18799 const {
18800 getGlobalBlockCount
18801 } = select(external_wp_blockEditor_namespaceObject.store);
18802 return {
18803 headingCount: getGlobalBlockCount('core/heading'),
18804 paragraphCount: getGlobalBlockCount('core/paragraph'),
18805 numberOfBlocks: getGlobalBlockCount()
18806 };
18807 }, []);
18808 return (
18809 /*#__PURE__*/
18810 /*
18811 * Disable reason: The `list` ARIA role is redundant but
18812 * Safari+VoiceOver won't announce the list otherwise.
18813 */
18814 /* eslint-disable jsx-a11y/no-redundant-roles */
18815 (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18816 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18817 className: "table-of-contents__wrapper",
18818 role: "note",
18819 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
18820 tabIndex: "0",
18821 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
18822 role: "list",
18823 className: "table-of-contents__counts",
18824 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18825 className: "table-of-contents__count",
18826 children: [(0,external_wp_i18n_namespaceObject.__)('Words'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
18827 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18828 className: "table-of-contents__count",
18829 children: [(0,external_wp_i18n_namespaceObject.__)('Characters'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18830 className: "table-of-contents__number",
18831 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
18832 })]
18833 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18834 className: "table-of-contents__count",
18835 children: [(0,external_wp_i18n_namespaceObject.__)('Time to read'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
18836 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18837 className: "table-of-contents__count",
18838 children: [(0,external_wp_i18n_namespaceObject.__)('Headings'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18839 className: "table-of-contents__number",
18840 children: headingCount
18841 })]
18842 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18843 className: "table-of-contents__count",
18844 children: [(0,external_wp_i18n_namespaceObject.__)('Paragraphs'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18845 className: "table-of-contents__number",
18846 children: paragraphCount
18847 })]
18848 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18849 className: "table-of-contents__count",
18850 children: [(0,external_wp_i18n_namespaceObject.__)('Blocks'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18851 className: "table-of-contents__number",
18852 children: numberOfBlocks
18853 })]
18854 })]
18855 })
18856 }), headingCount > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18857 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
18858 className: "table-of-contents__title",
18859 children: (0,external_wp_i18n_namespaceObject.__)('Document Outline')
18860 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {
18861 onSelect: onRequestClose,
18862 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18863 })]
18864 })]
18865 })
18866 /* eslint-enable jsx-a11y/no-redundant-roles */
18867 );
18868 }
18869 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel);
18870
18871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/index.js
18872 /**
18873 * WordPress dependencies
18874 */
18875
18876
18877
18878
18879
18880
18881
18882 /**
18883 * Internal dependencies
18884 */
18885
18886
18887 function TableOfContents({
18888 hasOutlineItemsDisabled,
18889 repositionDropdown,
18890 ...props
18891 }, ref) {
18892 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
18893 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18894 popoverProps: {
18895 placement: repositionDropdown ? 'right' : 'bottom'
18896 },
18897 className: "table-of-contents",
18898 contentClassName: "table-of-contents__popover",
18899 renderToggle: ({
18900 isOpen,
18901 onToggle
18902 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18903 ...props,
18904 ref: ref,
18905 onClick: hasBlocks ? onToggle : undefined,
18906 icon: library_info,
18907 "aria-expanded": isOpen,
18908 "aria-haspopup": "true"
18909 /* translators: button label text should, if possible, be under 16 characters. */,
18910 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
18911 tooltipPosition: "bottom",
18912 "aria-disabled": !hasBlocks
18913 }),
18914 renderContent: ({
18915 onClose
18916 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(table_of_contents_panel, {
18917 onRequestClose: onClose,
18918 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18919 })
18920 });
18921 }
18922
18923 /**
18924 * Renders a table of contents component.
18925 *
18926 * @param {Object} props The component props.
18927 * @param {boolean} props.hasOutlineItemsDisabled Whether outline items are disabled.
18928 * @param {boolean} props.repositionDropdown Whether to reposition the dropdown.
18929 * @param {Element.ref} ref The component's ref.
18930 *
18931 * @return {JSX.Element} The rendered table of contents component.
18932 */
18933 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
18934
18935 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/unsaved-changes-warning/index.js
18936 /**
18937 * WordPress dependencies
18938 */
18939
18940
18941
18942
18943
18944 /**
18945 * Warns the user if there are unsaved changes before leaving the editor.
18946 * Compatible with Post Editor and Site Editor.
18947 *
18948 * @return {Component} The component.
18949 */
18950 function UnsavedChangesWarning() {
18951 const {
18952 __experimentalGetDirtyEntityRecords
18953 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
18954 (0,external_wp_element_namespaceObject.useEffect)(() => {
18955 /**
18956 * Warns the user if there are unsaved changes before leaving the editor.
18957 *
18958 * @param {Event} event `beforeunload` event.
18959 *
18960 * @return {string | undefined} Warning prompt message, if unsaved changes exist.
18961 */
18962 const warnIfUnsavedChanges = event => {
18963 // We need to call the selector directly in the listener to avoid race
18964 // conditions with `BrowserURL` where `componentDidUpdate` gets the
18965 // new value of `isEditedPostDirty` before this component does,
18966 // causing this component to incorrectly think a trashed post is still dirty.
18967 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
18968 if (dirtyEntityRecords.length > 0) {
18969 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
18970 return event.returnValue;
18971 }
18972 };
18973 window.addEventListener('beforeunload', warnIfUnsavedChanges);
18974 return () => {
18975 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
18976 };
18977 }, [__experimentalGetDirtyEntityRecords]);
18978 return null;
18979 }
18980
18981 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/with-registry-provider.js
18982 /**
18983 * WordPress dependencies
18984 */
18985
18986
18987
18988
18989
18990 /**
18991 * Internal dependencies
18992 */
18993
18994
18995 function getSubRegistry(subRegistries, registry, useSubRegistry) {
18996 if (!useSubRegistry) {
18997 return registry;
18998 }
18999 let subRegistry = subRegistries.get(registry);
19000 if (!subRegistry) {
19001 subRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
19002 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
19003 }, registry);
19004 // Todo: The interface store should also be created per instance.
19005 subRegistry.registerStore('core/editor', storeConfig);
19006 subRegistries.set(registry, subRegistry);
19007 }
19008 return subRegistry;
19009 }
19010 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ({
19011 useSubRegistry = true,
19012 ...props
19013 }) => {
19014 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
19015 const [subRegistries] = (0,external_wp_element_namespaceObject.useState)(() => new WeakMap());
19016 const subRegistry = getSubRegistry(subRegistries, registry, useSubRegistry);
19017 if (subRegistry === registry) {
19018 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
19019 registry: registry,
19020 ...props
19021 });
19022 }
19023 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_data_namespaceObject.RegistryProvider, {
19024 value: subRegistry,
19025 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
19026 registry: subRegistry,
19027 ...props
19028 })
19029 });
19030 }, 'withRegistryProvider');
19031 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
19032
19033 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/media-categories/index.js
19034 /**
19035 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
19036 * See `packages/editor/src/components/media-categories/index.js`.
19037 *
19038 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
19039 * The rest of the settings would still need to be in sync though.
19040 */
19041
19042 /**
19043 * WordPress dependencies
19044 */
19045
19046
19047
19048
19049 /**
19050 * Internal dependencies
19051 */
19052
19053
19054 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
19055 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
19056 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
19057
19058 const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
19059 const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
19060 const getOpenverseLicense = (license, licenseVersion) => {
19061 let licenseName = license.trim();
19062 // PDM has no abbreviation
19063 if (license !== 'pdm') {
19064 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
19065 }
19066 // If version is known, append version to the name.
19067 // The license has to have a version to be valid. Only
19068 // PDM (public domain mark) doesn't have a version.
19069 if (licenseVersion) {
19070 licenseName += ` ${licenseVersion}`;
19071 }
19072 // For licenses other than public-domain marks, prepend 'CC' to the name.
19073 if (!['pdm', 'cc0'].includes(license)) {
19074 licenseName = `CC ${licenseName}`;
19075 }
19076 return licenseName;
19077 };
19078 const getOpenverseCaption = item => {
19079 const {
19080 title,
19081 foreign_landing_url: foreignLandingUrl,
19082 creator,
19083 creator_url: creatorUrl,
19084 license,
19085 license_version: licenseVersion,
19086 license_url: licenseUrl
19087 } = item;
19088 const fullLicense = getOpenverseLicense(license, licenseVersion);
19089 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator);
19090 let _caption;
19091 if (_creator) {
19092 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
19093 // translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
19094 (0,external_wp_i18n_namespaceObject._x)('"%1$s" by %2$s/ %3$s', 'caption'), getExternalLink(foreignLandingUrl, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0,external_wp_i18n_namespaceObject.sprintf)(
19095 // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
19096 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a> by %2$s/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
19097 } else {
19098 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
19099 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
19100 (0,external_wp_i18n_namespaceObject._x)('"%1$s"/ %2$s', 'caption'), getExternalLink(foreignLandingUrl, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0,external_wp_i18n_namespaceObject.sprintf)(
19101 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
19102 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
19103 }
19104 return _caption.replace(/\s{2}/g, ' ');
19105 };
19106 const coreMediaFetch = async (query = {}) => {
19107 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({
19108 ...query,
19109 orderBy: !!query?.search ? 'relevance' : 'date'
19110 });
19111 return mediaItems.map(mediaItem => ({
19112 ...mediaItem,
19113 alt: mediaItem.alt_text,
19114 url: mediaItem.source_url,
19115 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
19116 caption: mediaItem.caption?.raw
19117 }));
19118 };
19119
19120 /** @type {InserterMediaCategory[]} */
19121 const inserterMediaCategories = [{
19122 name: 'images',
19123 labels: {
19124 name: (0,external_wp_i18n_namespaceObject.__)('Images'),
19125 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images')
19126 },
19127 mediaType: 'image',
19128 async fetch(query = {}) {
19129 return coreMediaFetch({
19130 ...query,
19131 media_type: 'image'
19132 });
19133 }
19134 }, {
19135 name: 'videos',
19136 labels: {
19137 name: (0,external_wp_i18n_namespaceObject.__)('Videos'),
19138 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos')
19139 },
19140 mediaType: 'video',
19141 async fetch(query = {}) {
19142 return coreMediaFetch({
19143 ...query,
19144 media_type: 'video'
19145 });
19146 }
19147 }, {
19148 name: 'audio',
19149 labels: {
19150 name: (0,external_wp_i18n_namespaceObject.__)('Audio'),
19151 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio')
19152 },
19153 mediaType: 'audio',
19154 async fetch(query = {}) {
19155 return coreMediaFetch({
19156 ...query,
19157 media_type: 'audio'
19158 });
19159 }
19160 }, {
19161 name: 'openverse',
19162 labels: {
19163 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'),
19164 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse')
19165 },
19166 mediaType: 'image',
19167 async fetch(query = {}) {
19168 const defaultArgs = {
19169 mature: false,
19170 excluded_source: 'flickr,inaturalist,wikimedia',
19171 license: 'pdm,cc0'
19172 };
19173 const finalQuery = {
19174 ...query,
19175 ...defaultArgs
19176 };
19177 const mapFromInserterMediaRequest = {
19178 per_page: 'page_size',
19179 search: 'q'
19180 };
19181 const url = new URL('https://api.openverse.org/v1/images/');
19182 Object.entries(finalQuery).forEach(([key, value]) => {
19183 const queryKey = mapFromInserterMediaRequest[key] || key;
19184 url.searchParams.set(queryKey, value);
19185 });
19186 const response = await window.fetch(url, {
19187 headers: {
19188 'User-Agent': 'WordPress/inserter-media-fetch'
19189 }
19190 });
19191 const jsonResponse = await response.json();
19192 const results = jsonResponse.results;
19193 return results.map(result => ({
19194 ...result,
19195 // This is a temp solution for better titles, until Openverse API
19196 // completes the cleaning up of some titles of their upstream data.
19197 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
19198 sourceId: result.id,
19199 id: undefined,
19200 caption: getOpenverseCaption(result),
19201 previewUrl: result.thumbnail
19202 }));
19203 },
19204 getReportUrl: ({
19205 sourceId
19206 }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
19207 isExternalResource: true
19208 }];
19209 /* harmony default export */ const media_categories = (inserterMediaCategories);
19210
19211 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/media-upload/index.js
19212 /**
19213 * WordPress dependencies
19214 */
19215
19216
19217
19218 /**
19219 * Internal dependencies
19220 */
19221
19222 const media_upload_noop = () => {};
19223
19224 /**
19225 * Upload a media file when the file upload button is activated.
19226 * Wrapper around mediaUpload() that injects the current post ID.
19227 *
19228 * @param {Object} $0 Parameters object passed to the function.
19229 * @param {?Object} $0.additionalData Additional data to include in the request.
19230 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
19231 * @param {Array} $0.filesList List of files.
19232 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
19233 * @param {Function} $0.onError Function called when an error happens.
19234 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
19235 */
19236 function mediaUpload({
19237 additionalData = {},
19238 allowedTypes,
19239 filesList,
19240 maxUploadFileSize,
19241 onError = media_upload_noop,
19242 onFileChange
19243 }) {
19244 const {
19245 getCurrentPost,
19246 getEditorSettings
19247 } = (0,external_wp_data_namespaceObject.select)(store_store);
19248 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
19249 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
19250 const currentPost = getCurrentPost();
19251 // Templates and template parts' numerical ID is stored in `wp_id`.
19252 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
19253 const postData = currentPostId ? {
19254 post: currentPostId
19255 } : {};
19256 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
19257 allowedTypes,
19258 filesList,
19259 onFileChange,
19260 additionalData: {
19261 ...postData,
19262 ...additionalData
19263 },
19264 maxUploadFileSize,
19265 onError: ({
19266 message
19267 }) => onError(message),
19268 wpAllowedMimeTypes
19269 });
19270 }
19271
19272 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
19273 var cjs = __webpack_require__(1919);
19274 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
19275 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
19276 /*!
19277 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
19278 *
19279 * Copyright (c) 2014-2017, Jon Schlinkert.
19280 * Released under the MIT License.
19281 */
19282
19283 function isObject(o) {
19284 return Object.prototype.toString.call(o) === '[object Object]';
19285 }
19286
19287 function isPlainObject(o) {
19288 var ctor,prot;
19289
19290 if (isObject(o) === false) return false;
19291
19292 // If has modified constructor
19293 ctor = o.constructor;
19294 if (ctor === undefined) return true;
19295
19296 // If has modified prototype
19297 prot = ctor.prototype;
19298 if (isObject(prot) === false) return false;
19299
19300 // If constructor does not have an Object-specific method
19301 if (prot.hasOwnProperty('isPrototypeOf') === false) {
19302 return false;
19303 }
19304
19305 // Most likely a plain Object
19306 return true;
19307 }
19308
19309
19310
19311 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/set-nested-value.js
19312 /**
19313 * Sets the value at path of object.
19314 * If a portion of path doesn’t exist, it’s created.
19315 * Arrays are created for missing index properties while objects are created
19316 * for all other missing properties.
19317 *
19318 * This function intentionally mutates the input object.
19319 *
19320 * Inspired by _.set().
19321 *
19322 * @see https://lodash.com/docs/4.17.15#set
19323 *
19324 * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
19325 *
19326 * @param {Object} object Object to modify
19327 * @param {Array} path Path of the property to set.
19328 * @param {*} value Value to set.
19329 */
19330 function setNestedValue(object, path, value) {
19331 if (!object || typeof object !== 'object') {
19332 return object;
19333 }
19334 path.reduce((acc, key, idx) => {
19335 if (acc[key] === undefined) {
19336 if (Number.isInteger(path[idx + 1])) {
19337 acc[key] = [];
19338 } else {
19339 acc[key] = {};
19340 }
19341 }
19342 if (idx === path.length - 1) {
19343 acc[key] = value;
19344 }
19345 return acc[key];
19346 }, object);
19347 return object;
19348 }
19349
19350 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-styles-provider/index.js
19351 /**
19352 * External dependencies
19353 */
19354
19355
19356
19357 /**
19358 * WordPress dependencies
19359 */
19360
19361
19362
19363
19364
19365
19366 /**
19367 * Internal dependencies
19368 */
19369
19370
19371
19372 const {
19373 GlobalStylesContext: global_styles_provider_GlobalStylesContext,
19374 cleanEmptyObject
19375 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19376 function mergeBaseAndUserConfigs(base, user) {
19377 return cjs_default()(base, user, {
19378 // We only pass as arrays the presets,
19379 // in which case we want the new array of values
19380 // to override the old array (no merging).
19381 isMergeableObject: isPlainObject
19382 });
19383 }
19384
19385 /**
19386 * Resolves shared block style variation definitions from the user origin
19387 * under their respective block types and registers the block style if required.
19388 *
19389 * @param {Object} userConfig Current user origin global styles data.
19390 * @return {Object} Updated global styles data.
19391 */
19392 function useResolvedBlockStyleVariationsConfig(userConfig) {
19393 const {
19394 getBlockStyles
19395 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
19396 const sharedVariations = userConfig?.styles?.blocks?.variations;
19397
19398 // Collect block style variation definitions to merge and unregistered
19399 // block styles for automatic registration.
19400 const [userConfigToMerge, unregisteredStyles] = (0,external_wp_element_namespaceObject.useMemo)(() => {
19401 if (!sharedVariations) {
19402 return [];
19403 }
19404 const variationsConfigToMerge = {};
19405 const unregisteredBlockStyles = [];
19406 Object.entries(sharedVariations).forEach(([variationName, variation]) => {
19407 if (!variation?.blockTypes?.length) {
19408 return;
19409 }
19410 variation.blockTypes.forEach(blockName => {
19411 const blockStyles = getBlockStyles(blockName);
19412 const registeredBlockStyle = blockStyles.find(({
19413 name
19414 }) => name === variationName);
19415 if (!registeredBlockStyle) {
19416 unregisteredBlockStyles.push([blockName, {
19417 name: variationName,
19418 label: variationName
19419 }]);
19420 }
19421 const path = ['styles', 'blocks', blockName, 'variations', variationName];
19422 setNestedValue(variationsConfigToMerge, path, variation);
19423 });
19424 });
19425 return [variationsConfigToMerge, unregisteredBlockStyles];
19426 }, [sharedVariations, getBlockStyles]);
19427
19428 // Automatically register missing block styles from variations.
19429 (0,external_wp_element_namespaceObject.useEffect)(() => unregisteredStyles?.forEach(unregisteredStyle => (0,external_wp_blocks_namespaceObject.registerBlockStyle)(...unregisteredStyle)), [unregisteredStyles]);
19430
19431 // Merge shared block style variation definitions into overall user config.
19432 const updatedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
19433 if (!userConfigToMerge) {
19434 return userConfig;
19435 }
19436 return cjs_default()(userConfigToMerge, userConfig);
19437 }, [userConfigToMerge, userConfig]);
19438 return updatedConfig;
19439 }
19440 function useGlobalStylesUserConfig() {
19441 const {
19442 globalStylesId,
19443 isReady,
19444 settings,
19445 styles,
19446 _links
19447 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19448 const {
19449 getEditedEntityRecord,
19450 hasFinishedResolution
19451 } = select(external_wp_coreData_namespaceObject.store);
19452 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
19453 const record = _globalStylesId ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
19454 let hasResolved = false;
19455 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
19456 hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true;
19457 }
19458 return {
19459 globalStylesId: _globalStylesId,
19460 isReady: hasResolved,
19461 settings: record?.settings,
19462 styles: record?.styles,
19463 _links: record?._links
19464 };
19465 }, []);
19466 const {
19467 getEditedEntityRecord
19468 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
19469 const {
19470 editEntityRecord
19471 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19472 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
19473 return {
19474 settings: settings !== null && settings !== void 0 ? settings : {},
19475 styles: styles !== null && styles !== void 0 ? styles : {},
19476 _links: _links !== null && _links !== void 0 ? _links : {}
19477 };
19478 }, [settings, styles, _links]);
19479 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(
19480 /**
19481 * Set the global styles config.
19482 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
19483 * Otherwise, overwrite the current config with the incoming object.
19484 * @param {Object} options Options for editEntityRecord Core selector.
19485 */
19486 (callbackOrObject, options = {}) => {
19487 var _record$styles, _record$settings, _record$_links;
19488 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
19489 const currentConfig = {
19490 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
19491 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {},
19492 _links: (_record$_links = record?._links) !== null && _record$_links !== void 0 ? _record$_links : {}
19493 };
19494 const updatedConfig = typeof callbackOrObject === 'function' ? callbackOrObject(currentConfig) : callbackOrObject;
19495 editEntityRecord('root', 'globalStyles', globalStylesId, {
19496 styles: cleanEmptyObject(updatedConfig.styles) || {},
19497 settings: cleanEmptyObject(updatedConfig.settings) || {},
19498 _links: cleanEmptyObject(updatedConfig._links) || {}
19499 }, options);
19500 }, [globalStylesId]);
19501 return [isReady, config, setConfig];
19502 }
19503 function useGlobalStylesBaseConfig() {
19504 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
19505 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles();
19506 }, []);
19507 return [!!baseConfig, baseConfig];
19508 }
19509 function useGlobalStylesContext() {
19510 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
19511 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
19512 const userConfigWithVariations = useResolvedBlockStyleVariationsConfig(userConfig);
19513 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
19514 if (!baseConfig || !userConfigWithVariations) {
19515 return {};
19516 }
19517 return mergeBaseAndUserConfigs(baseConfig, userConfigWithVariations);
19518 }, [userConfigWithVariations, baseConfig]);
19519 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
19520 return {
19521 isReady: isUserConfigReady && isBaseConfigReady,
19522 user: userConfigWithVariations,
19523 base: baseConfig,
19524 merged: mergedConfig,
19525 setUserConfig
19526 };
19527 }, [mergedConfig, userConfigWithVariations, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
19528 return context;
19529 }
19530 function GlobalStylesProvider({
19531 children
19532 }) {
19533 const context = useGlobalStylesContext();
19534 if (!context.isReady) {
19535 return null;
19536 }
19537 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(global_styles_provider_GlobalStylesContext.Provider, {
19538 value: context,
19539 children: children
19540 });
19541 }
19542
19543 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-block-editor-settings.js
19544 /**
19545 * WordPress dependencies
19546 */
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556 /**
19557 * Internal dependencies
19558 */
19559
19560
19561
19562
19563
19564 const EMPTY_BLOCKS_LIST = [];
19565 const DEFAULT_STYLES = {};
19566 function __experimentalReusableBlocksSelect(select) {
19567 var _select$getEntityReco;
19568 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
19569 per_page: -1
19570 })) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : EMPTY_BLOCKS_LIST;
19571 }
19572 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__unstableGalleryWithImageBlocks', 'alignWide', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'onNavigateToEntityRecord', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'locale', 'maxWidth', 'postContentAttributes', 'postsPerPage', 'readOnly', 'sectionRootClientId', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', '__experimentalArchiveTitleTypeLabel', '__experimentalArchiveTitleNameLabel'];
19573 const {
19574 globalStylesDataKey,
19575 selectBlockPatternsKey,
19576 reusableBlocksSelectKey
19577 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19578
19579 /**
19580 * React hook used to compute the block editor settings to use for the post editor.
19581 *
19582 * @param {Object} settings EditorProvider settings prop.
19583 * @param {string} postType Editor root level post type.
19584 * @param {string} postId Editor root level post ID.
19585 * @param {string} renderingMode Editor rendering mode.
19586 *
19587 * @return {Object} Block Editor Settings.
19588 */
19589 function useBlockEditorSettings(settings, postType, postId, renderingMode) {
19590 var _mergedGlobalStyles$s, _settings$__experimen, _settings$__experimen2;
19591 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
19592 const {
19593 allowRightClickOverrides,
19594 blockTypes,
19595 focusMode,
19596 hasFixedToolbar,
19597 isDistractionFree,
19598 keepCaretInsideBlock,
19599 hasUploadPermissions,
19600 hiddenBlockTypes,
19601 canUseUnfilteredHTML,
19602 userCanCreatePages,
19603 pageOnFront,
19604 pageForPosts,
19605 userPatternCategories,
19606 restBlockPatternCategories,
19607 sectionRootClientId
19608 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19609 var _canUser;
19610 const {
19611 canUser,
19612 getRawEntityRecord,
19613 getEntityRecord,
19614 getUserPatternCategories,
19615 getBlockPatternCategories
19616 } = select(external_wp_coreData_namespaceObject.store);
19617 const {
19618 get
19619 } = select(external_wp_preferences_namespaceObject.store);
19620 const {
19621 getBlockTypes
19622 } = select(external_wp_blocks_namespaceObject.store);
19623 const {
19624 getBlocksByName,
19625 getBlockAttributes
19626 } = select(external_wp_blockEditor_namespaceObject.store);
19627 const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined;
19628 function getSectionRootBlock() {
19629 var _getBlocksByName$find;
19630 if (renderingMode === 'template-locked') {
19631 var _getBlocksByName$;
19632 return (_getBlocksByName$ = getBlocksByName('core/post-content')?.[0]) !== null && _getBlocksByName$ !== void 0 ? _getBlocksByName$ : '';
19633 }
19634 return (_getBlocksByName$find = getBlocksByName('core/group').find(clientId => getBlockAttributes(clientId)?.tagName === 'main')) !== null && _getBlocksByName$find !== void 0 ? _getBlocksByName$find : '';
19635 }
19636 return {
19637 allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
19638 blockTypes: getBlockTypes(),
19639 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
19640 focusMode: get('core', 'focusMode'),
19641 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
19642 hiddenBlockTypes: get('core', 'hiddenBlockTypes'),
19643 isDistractionFree: get('core', 'distractionFree'),
19644 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
19645 hasUploadPermissions: (_canUser = canUser('create', 'media')) !== null && _canUser !== void 0 ? _canUser : true,
19646 userCanCreatePages: canUser('create', 'pages'),
19647 pageOnFront: siteSettings?.page_on_front,
19648 pageForPosts: siteSettings?.page_for_posts,
19649 userPatternCategories: getUserPatternCategories(),
19650 restBlockPatternCategories: getBlockPatternCategories(),
19651 sectionRootClientId: getSectionRootBlock()
19652 };
19653 }, [postType, postId, isLargeViewport, renderingMode]);
19654 const {
19655 merged: mergedGlobalStyles
19656 } = useGlobalStylesContext();
19657 const globalStylesData = (_mergedGlobalStyles$s = mergedGlobalStyles.styles) !== null && _mergedGlobalStyles$s !== void 0 ? _mergedGlobalStyles$s : DEFAULT_STYLES;
19658 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
19659 // WP 6.0
19660 settings.__experimentalBlockPatterns; // WP 5.9
19661 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 :
19662 // WP 6.0
19663 settings.__experimentalBlockPatternCategories; // WP 5.9
19664
19665 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({
19666 postTypes
19667 }) => {
19668 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType);
19669 }), [settingsBlockPatterns, postType]);
19670 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
19671 const {
19672 undo,
19673 setIsInserterOpened
19674 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
19675 const {
19676 saveEntityRecord
19677 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19678
19679 /**
19680 * Creates a Post entity.
19681 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
19682 *
19683 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
19684 * @return {Object} the post type object that was created.
19685 */
19686 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => {
19687 if (!userCanCreatePages) {
19688 return Promise.reject({
19689 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
19690 });
19691 }
19692 return saveEntityRecord('postType', 'page', options);
19693 }, [saveEntityRecord, userCanCreatePages]);
19694 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
19695 // Omit hidden block types if exists and non-empty.
19696 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
19697 // Defer to passed setting for `allowedBlockTypes` if provided as
19698 // anything other than `true` (where `true` is equivalent to allow
19699 // all block types).
19700 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({
19701 name
19702 }) => name) : settings.allowedBlockTypes || [];
19703 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
19704 }
19705 return settings.allowedBlockTypes;
19706 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
19707 const forceDisableFocusMode = settings.focusMode === false;
19708 return (0,external_wp_element_namespaceObject.useMemo)(() => {
19709 const blockEditorSettings = {
19710 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
19711 [globalStylesDataKey]: globalStylesData,
19712 allowedBlockTypes,
19713 allowRightClickOverrides,
19714 focusMode: focusMode && !forceDisableFocusMode,
19715 hasFixedToolbar,
19716 isDistractionFree,
19717 keepCaretInsideBlock,
19718 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
19719 __experimentalBlockPatterns: blockPatterns,
19720 [selectBlockPatternsKey]: select => {
19721 const {
19722 hasFinishedResolution,
19723 getBlockPatternsForPostType
19724 } = unlock(select(external_wp_coreData_namespaceObject.store));
19725 const patterns = getBlockPatternsForPostType(postType);
19726 return hasFinishedResolution('getBlockPatterns') ? patterns : undefined;
19727 },
19728 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
19729 __experimentalBlockPatternCategories: blockPatternCategories,
19730 __experimentalUserPatternCategories: userPatternCategories,
19731 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
19732 inserterMediaCategories: media_categories,
19733 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
19734 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
19735 // This might be better as a generic "canUser" selector.
19736 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
19737 //Todo: this is only needed for native and should probably be removed.
19738 __experimentalUndo: undo,
19739 // Check whether we want all site editor frames to have outlines
19740 // including the navigation / pattern / parts editors.
19741 outlineMode: postType === 'wp_template',
19742 // Check these two properties: they were not present in the site editor.
19743 __experimentalCreatePageEntity: createPageEntity,
19744 __experimentalUserCanCreatePages: userCanCreatePages,
19745 pageOnFront,
19746 pageForPosts,
19747 __experimentalPreferPatternsOnRoot: postType === 'wp_template',
19748 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
19749 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
19750 __experimentalSetIsInserterOpened: setIsInserterOpened
19751 };
19752 lock(blockEditorSettings, {
19753 sectionRootClientId
19754 });
19755 return blockEditorSettings;
19756 }, [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened, sectionRootClientId, globalStylesData]);
19757 }
19758 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
19759
19760 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/disable-non-page-content-blocks.js
19761 /**
19762 * WordPress dependencies
19763 */
19764
19765
19766
19767
19768 const DEFAULT_CONTENT_ONLY_BLOCKS = ['core/post-title', 'core/post-featured-image', 'core/post-content', 'core/template-part'];
19769
19770 /**
19771 * Component that when rendered, makes it so that the site editor allows only
19772 * page content to be edited.
19773 */
19774 function DisableNonPageContentBlocks() {
19775 const contentOnlyBlocks = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', DEFAULT_CONTENT_ONLY_BLOCKS);
19776
19777 // Note that there are two separate subscription because the result for each
19778 // returns a new array.
19779 const contentOnlyIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19780 const {
19781 getBlocksByName,
19782 getBlockParents,
19783 getBlockName
19784 } = select(external_wp_blockEditor_namespaceObject.store);
19785 return getBlocksByName(contentOnlyBlocks).filter(clientId => getBlockParents(clientId).every(parentClientId => {
19786 const parentBlockName = getBlockName(parentClientId);
19787 return (
19788 // Ignore descendents of the query block.
19789 parentBlockName !== 'core/query' &&
19790 // Enable only the top-most block.
19791 !contentOnlyBlocks.includes(parentBlockName)
19792 );
19793 }));
19794 }, []);
19795 const disabledIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19796 const {
19797 getBlocksByName,
19798 getBlockOrder
19799 } = select(external_wp_blockEditor_namespaceObject.store);
19800 return getBlocksByName(['core/template-part']).flatMap(clientId => getBlockOrder(clientId));
19801 }, []);
19802 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
19803 (0,external_wp_element_namespaceObject.useEffect)(() => {
19804 const {
19805 setBlockEditingMode,
19806 unsetBlockEditingMode
19807 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
19808 registry.batch(() => {
19809 setBlockEditingMode('', 'disabled');
19810 for (const clientId of contentOnlyIds) {
19811 setBlockEditingMode(clientId, 'contentOnly');
19812 }
19813 for (const clientId of disabledIds) {
19814 setBlockEditingMode(clientId, 'disabled');
19815 }
19816 });
19817 return () => {
19818 registry.batch(() => {
19819 unsetBlockEditingMode('');
19820 for (const clientId of contentOnlyIds) {
19821 unsetBlockEditingMode(clientId);
19822 }
19823 for (const clientId of disabledIds) {
19824 unsetBlockEditingMode(clientId);
19825 }
19826 });
19827 };
19828 }, [contentOnlyIds, disabledIds, registry]);
19829 return null;
19830 }
19831
19832 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/navigation-block-editing-mode.js
19833 /**
19834 * WordPress dependencies
19835 */
19836
19837
19838
19839
19840 /**
19841 * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
19842 *
19843 * Set block editing mode to contentOnly when entering Navigation focus mode.
19844 * this ensures that non-content controls on the block will be hidden and thus
19845 * the user can focus on editing the Navigation Menu content only.
19846 */
19847
19848 function NavigationBlockEditingMode() {
19849 // In the navigation block editor,
19850 // the navigation block is the only root block.
19851 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []);
19852 const {
19853 setBlockEditingMode,
19854 unsetBlockEditingMode
19855 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
19856 (0,external_wp_element_namespaceObject.useEffect)(() => {
19857 if (!blockClientId) {
19858 return;
19859 }
19860 setBlockEditingMode(blockClientId, 'contentOnly');
19861 return () => {
19862 unsetBlockEditingMode(blockClientId);
19863 };
19864 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
19865 }
19866
19867 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js
19868 /**
19869 * WordPress dependencies
19870 */
19871
19872
19873
19874 // These post types are "structural" block lists.
19875 // We should be allowed to use
19876 // the post content and template parts blocks within them.
19877 const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template', 'wp_template_part'];
19878
19879 /**
19880 * In some specific contexts,
19881 * the template part and post content blocks need to be hidden.
19882 *
19883 * @param {string} postType Post Type
19884 * @param {string} mode Rendering mode
19885 */
19886 function useHideBlocksFromInserter(postType, mode) {
19887 (0,external_wp_element_namespaceObject.useEffect)(() => {
19888 /*
19889 * Prevent adding template part in the editor.
19890 */
19891 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
19892 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
19893 return false;
19894 }
19895 return canInsert;
19896 });
19897
19898 /*
19899 * Prevent adding post content block (except in query block) in the editor.
19900 */
19901 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
19902 getBlockParentsByBlockName
19903 }) => {
19904 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/post-content') {
19905 return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
19906 }
19907 return canInsert;
19908 });
19909 return () => {
19910 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
19911 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
19912 };
19913 }, [postType, mode]);
19914 }
19915
19916 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/keyboard.js
19917 /**
19918 * WordPress dependencies
19919 */
19920
19921
19922
19923 const keyboard = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
19924 xmlns: "http://www.w3.org/2000/svg",
19925 viewBox: "0 0 24 24",
19926 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19927 d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z"
19928 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19929 d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z"
19930 })]
19931 });
19932 /* harmony default export */ const library_keyboard = (keyboard);
19933
19934 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
19935 /**
19936 * WordPress dependencies
19937 */
19938
19939
19940 const listView = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19941 viewBox: "0 0 24 24",
19942 xmlns: "http://www.w3.org/2000/svg",
19943 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19944 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"
19945 })
19946 });
19947 /* harmony default export */ const list_view = (listView);
19948
19949 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/code.js
19950 /**
19951 * WordPress dependencies
19952 */
19953
19954
19955 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19956 viewBox: "0 0 24 24",
19957 xmlns: "http://www.w3.org/2000/svg",
19958 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19959 d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z"
19960 })
19961 });
19962 /* harmony default export */ const library_code = (code);
19963
19964 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-left.js
19965 /**
19966 * WordPress dependencies
19967 */
19968
19969
19970 const drawerLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19971 width: "24",
19972 height: "24",
19973 xmlns: "http://www.w3.org/2000/svg",
19974 viewBox: "0 0 24 24",
19975 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19976 fillRule: "evenodd",
19977 clipRule: "evenodd",
19978 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z"
19979 })
19980 });
19981 /* harmony default export */ const drawer_left = (drawerLeft);
19982
19983 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-right.js
19984 /**
19985 * WordPress dependencies
19986 */
19987
19988
19989 const drawerRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19990 width: "24",
19991 height: "24",
19992 xmlns: "http://www.w3.org/2000/svg",
19993 viewBox: "0 0 24 24",
19994 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19995 fillRule: "evenodd",
19996 clipRule: "evenodd",
19997 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z"
19998 })
19999 });
20000 /* harmony default export */ const drawer_right = (drawerRight);
20001
20002 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js
20003 /**
20004 * WordPress dependencies
20005 */
20006
20007
20008 const blockDefault = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20009 xmlns: "http://www.w3.org/2000/svg",
20010 viewBox: "0 0 24 24",
20011 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20012 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
20013 })
20014 });
20015 /* harmony default export */ const block_default = (blockDefault);
20016
20017 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/format-list-bullets.js
20018 /**
20019 * WordPress dependencies
20020 */
20021
20022
20023 const formatListBullets = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20024 xmlns: "http://www.w3.org/2000/svg",
20025 viewBox: "0 0 24 24",
20026 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20027 d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
20028 })
20029 });
20030 /* harmony default export */ const format_list_bullets = (formatListBullets);
20031
20032 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
20033 /**
20034 * WordPress dependencies
20035 */
20036
20037
20038 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20039 xmlns: "http://www.w3.org/2000/svg",
20040 viewBox: "0 0 24 24",
20041 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20042 d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"
20043 })
20044 });
20045 /* harmony default export */ const library_external = (external);
20046
20047 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
20048 /**
20049 * WordPress dependencies
20050 */
20051
20052
20053 const pencil = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20054 xmlns: "http://www.w3.org/2000/svg",
20055 viewBox: "0 0 24 24",
20056 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20057 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"
20058 })
20059 });
20060 /* harmony default export */ const library_pencil = (pencil);
20061
20062 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
20063 /**
20064 * Internal dependencies
20065 */
20066
20067
20068 /* harmony default export */ const edit = (library_pencil);
20069
20070 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-rename-modal/index.js
20071 /**
20072 * WordPress dependencies
20073 */
20074
20075
20076
20077
20078
20079 /**
20080 * Internal dependencies
20081 */
20082
20083
20084
20085
20086 const {
20087 RenamePatternModal
20088 } = unlock(external_wp_patterns_namespaceObject.privateApis);
20089 const modalName = 'editor/pattern-rename';
20090 function PatternRenameModal() {
20091 const {
20092 record,
20093 postType
20094 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20095 const {
20096 getCurrentPostType,
20097 getCurrentPostId
20098 } = select(store_store);
20099 const {
20100 getEditedEntityRecord
20101 } = select(external_wp_coreData_namespaceObject.store);
20102 const _postType = getCurrentPostType();
20103 return {
20104 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
20105 postType: _postType
20106 };
20107 }, []);
20108 const {
20109 closeModal
20110 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20111 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(modalName));
20112 if (!isActive || postType !== PATTERN_POST_TYPE) {
20113 return null;
20114 }
20115 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenamePatternModal, {
20116 onClose: closeModal,
20117 pattern: record
20118 });
20119 }
20120
20121 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-duplicate-modal/index.js
20122 /**
20123 * WordPress dependencies
20124 */
20125
20126
20127
20128
20129
20130 /**
20131 * Internal dependencies
20132 */
20133
20134
20135
20136
20137 const {
20138 DuplicatePatternModal
20139 } = unlock(external_wp_patterns_namespaceObject.privateApis);
20140 const pattern_duplicate_modal_modalName = 'editor/pattern-duplicate';
20141 function PatternDuplicateModal() {
20142 const {
20143 record,
20144 postType
20145 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20146 const {
20147 getCurrentPostType,
20148 getCurrentPostId
20149 } = select(store_store);
20150 const {
20151 getEditedEntityRecord
20152 } = select(external_wp_coreData_namespaceObject.store);
20153 const _postType = getCurrentPostType();
20154 return {
20155 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
20156 postType: _postType
20157 };
20158 }, []);
20159 const {
20160 closeModal
20161 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20162 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(pattern_duplicate_modal_modalName));
20163 if (!isActive || postType !== PATTERN_POST_TYPE) {
20164 return null;
20165 }
20166 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DuplicatePatternModal, {
20167 onClose: closeModal,
20168 onSuccess: () => closeModal(),
20169 pattern: record
20170 });
20171 }
20172
20173 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/commands/index.js
20174 /**
20175 * WordPress dependencies
20176 */
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187 /**
20188 * Internal dependencies
20189 */
20190
20191
20192
20193
20194 function useEditorCommandLoader() {
20195 const {
20196 editorMode,
20197 isListViewOpen,
20198 showBlockBreadcrumbs,
20199 isDistractionFree,
20200 isTopToolbar,
20201 isFocusMode,
20202 isPreviewMode,
20203 isViewable,
20204 isCodeEditingEnabled,
20205 isRichEditingEnabled,
20206 isPublishSidebarEnabled
20207 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20208 var _get, _getPostType$viewable;
20209 const {
20210 get
20211 } = select(external_wp_preferences_namespaceObject.store);
20212 const {
20213 isListViewOpened,
20214 getCurrentPostType,
20215 getEditorSettings
20216 } = select(store_store);
20217 const {
20218 getSettings
20219 } = select(external_wp_blockEditor_namespaceObject.store);
20220 const {
20221 getPostType
20222 } = select(external_wp_coreData_namespaceObject.store);
20223 return {
20224 editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
20225 isListViewOpen: isListViewOpened(),
20226 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
20227 isDistractionFree: get('core', 'distractionFree'),
20228 isFocusMode: get('core', 'focusMode'),
20229 isTopToolbar: get('core', 'fixedToolbar'),
20230 isPreviewMode: getSettings().__unstableIsPreviewMode,
20231 isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
20232 isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
20233 isRichEditingEnabled: getEditorSettings().richEditingEnabled,
20234 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled()
20235 };
20236 }, []);
20237 const {
20238 getActiveComplementaryArea
20239 } = (0,external_wp_data_namespaceObject.useSelect)(store);
20240 const {
20241 toggle
20242 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
20243 const {
20244 createInfoNotice
20245 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
20246 const {
20247 __unstableSaveForPreview,
20248 setIsListViewOpened,
20249 switchEditorMode,
20250 toggleDistractionFree
20251 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20252 const {
20253 openModal,
20254 enableComplementaryArea,
20255 disableComplementaryArea
20256 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20257 const {
20258 getCurrentPostId
20259 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
20260 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
20261 if (isPreviewMode) {
20262 return {
20263 commands: [],
20264 isLoading: false
20265 };
20266 }
20267 const commands = [];
20268 commands.push({
20269 name: 'core/open-shortcut-help',
20270 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
20271 icon: library_keyboard,
20272 callback: () => {
20273 openModal('editor/keyboard-shortcut-help');
20274 }
20275 });
20276 commands.push({
20277 name: 'core/toggle-distraction-free',
20278 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction Free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction Free'),
20279 callback: ({
20280 close
20281 }) => {
20282 toggleDistractionFree();
20283 close();
20284 }
20285 });
20286 commands.push({
20287 name: 'core/open-preferences',
20288 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'),
20289 callback: () => {
20290 openModal('editor/preferences');
20291 }
20292 });
20293 commands.push({
20294 name: 'core/toggle-spotlight-mode',
20295 label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight'),
20296 callback: ({
20297 close
20298 }) => {
20299 toggle('core', 'focusMode');
20300 close();
20301 createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), {
20302 id: 'core/editor/toggle-spotlight-mode/notice',
20303 type: 'snackbar',
20304 actions: [{
20305 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20306 onClick: () => {
20307 toggle('core', 'focusMode');
20308 }
20309 }]
20310 });
20311 }
20312 });
20313 commands.push({
20314 name: 'core/toggle-list-view',
20315 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'),
20316 icon: list_view,
20317 callback: ({
20318 close
20319 }) => {
20320 setIsListViewOpened(!isListViewOpen);
20321 close();
20322 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), {
20323 id: 'core/editor/toggle-list-view/notice',
20324 type: 'snackbar'
20325 });
20326 }
20327 });
20328 commands.push({
20329 name: 'core/toggle-top-toolbar',
20330 label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'),
20331 callback: ({
20332 close
20333 }) => {
20334 toggle('core', 'fixedToolbar');
20335 if (isDistractionFree) {
20336 toggleDistractionFree();
20337 }
20338 close();
20339 createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), {
20340 id: 'core/editor/toggle-top-toolbar/notice',
20341 type: 'snackbar',
20342 actions: [{
20343 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20344 onClick: () => {
20345 toggle('core', 'fixedToolbar');
20346 }
20347 }]
20348 });
20349 }
20350 });
20351 if (allowSwitchEditorMode) {
20352 commands.push({
20353 name: 'core/toggle-code-editor',
20354 label: editorMode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Open code editor') : (0,external_wp_i18n_namespaceObject.__)('Exit code editor'),
20355 icon: library_code,
20356 callback: ({
20357 close
20358 }) => {
20359 switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
20360 close();
20361 }
20362 });
20363 }
20364 commands.push({
20365 name: 'core/toggle-breadcrumbs',
20366 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'),
20367 callback: ({
20368 close
20369 }) => {
20370 toggle('core', 'showBlockBreadcrumbs');
20371 close();
20372 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), {
20373 id: 'core/editor/toggle-breadcrumbs/notice',
20374 type: 'snackbar'
20375 });
20376 }
20377 });
20378 commands.push({
20379 name: 'core/open-settings-sidebar',
20380 label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'),
20381 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
20382 callback: ({
20383 close
20384 }) => {
20385 const activeSidebar = getActiveComplementaryArea('core');
20386 close();
20387 if (activeSidebar === 'edit-post/document') {
20388 disableComplementaryArea('core');
20389 } else {
20390 enableComplementaryArea('core', 'edit-post/document');
20391 }
20392 }
20393 });
20394 commands.push({
20395 name: 'core/open-block-inspector',
20396 label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'),
20397 icon: block_default,
20398 callback: ({
20399 close
20400 }) => {
20401 const activeSidebar = getActiveComplementaryArea('core');
20402 close();
20403 if (activeSidebar === 'edit-post/block') {
20404 disableComplementaryArea('core');
20405 } else {
20406 enableComplementaryArea('core', 'edit-post/block');
20407 }
20408 }
20409 });
20410 commands.push({
20411 name: 'core/toggle-publish-sidebar',
20412 label: isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Disable pre-publish checks') : (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks'),
20413 icon: format_list_bullets,
20414 callback: ({
20415 close
20416 }) => {
20417 close();
20418 toggle('core', 'isPublishSidebarEnabled');
20419 createInfoNotice(isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks disabled.') : (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks enabled.'), {
20420 id: 'core/editor/publish-sidebar/notice',
20421 type: 'snackbar'
20422 });
20423 }
20424 });
20425 if (isViewable) {
20426 commands.push({
20427 name: 'core/preview-link',
20428 label: (0,external_wp_i18n_namespaceObject.__)('Preview in a new tab'),
20429 icon: library_external,
20430 callback: async ({
20431 close
20432 }) => {
20433 close();
20434 const postId = getCurrentPostId();
20435 const link = await __unstableSaveForPreview();
20436 window.open(link, `wp-preview-${postId}`);
20437 }
20438 });
20439 }
20440 return {
20441 commands,
20442 isLoading: false
20443 };
20444 }
20445 function useEditedEntityContextualCommands() {
20446 const {
20447 postType
20448 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20449 const {
20450 getCurrentPostType
20451 } = select(store_store);
20452 return {
20453 postType: getCurrentPostType()
20454 };
20455 }, []);
20456 const {
20457 openModal
20458 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20459 const commands = [];
20460 if (postType === PATTERN_POST_TYPE) {
20461 commands.push({
20462 name: 'core/rename-pattern',
20463 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'),
20464 icon: edit,
20465 callback: ({
20466 close
20467 }) => {
20468 openModal(modalName);
20469 close();
20470 }
20471 });
20472 commands.push({
20473 name: 'core/duplicate-pattern',
20474 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'),
20475 icon: library_symbol,
20476 callback: ({
20477 close
20478 }) => {
20479 openModal(pattern_duplicate_modal_modalName);
20480 close();
20481 }
20482 });
20483 }
20484 return {
20485 isLoading: false,
20486 commands
20487 };
20488 }
20489 function useCommands() {
20490 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20491 name: 'core/editor/edit-ui',
20492 hook: useEditorCommandLoader
20493 });
20494 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20495 name: 'core/editor/contextual-commands',
20496 hook: useEditedEntityContextualCommands,
20497 context: 'entity-edit'
20498 });
20499 }
20500
20501 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-removal-warnings/index.js
20502 /**
20503 * WordPress dependencies
20504 */
20505
20506
20507
20508
20509
20510
20511 /**
20512 * Internal dependencies
20513 */
20514
20515
20516
20517 const {
20518 BlockRemovalWarningModal
20519 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
20520
20521 // Prevent accidental removal of certain blocks, asking the user for confirmation first.
20522 const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
20523 const BLOCK_REMOVAL_RULES = [{
20524 // Template blocks.
20525 // The warning is only shown when a user manipulates templates or template parts.
20526 postTypes: ['wp_template', 'wp_template_part'],
20527 callback(removedBlocks) {
20528 const removedTemplateBlocks = removedBlocks.filter(({
20529 name
20530 }) => TEMPLATE_BLOCKS.includes(name));
20531 if (removedTemplateBlocks.length) {
20532 return (0,external_wp_i18n_namespaceObject._n)('Deleting this block will stop your post or page content from displaying on this template. It is not recommended.', 'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.', removedBlocks.length);
20533 }
20534 }
20535 }, {
20536 // Pattern overrides.
20537 // The warning is only shown when the user edits a pattern.
20538 postTypes: ['wp_block'],
20539 callback(removedBlocks) {
20540 const removedBlocksWithOverrides = removedBlocks.filter(({
20541 attributes
20542 }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
20543 if (removedBlocksWithOverrides.length) {
20544 return (0,external_wp_i18n_namespaceObject._n)('The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?', 'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?', removedBlocks.length);
20545 }
20546 }
20547 }];
20548 function BlockRemovalWarnings() {
20549 const currentPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
20550 const removalRulesForPostType = (0,external_wp_element_namespaceObject.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
20551
20552 // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
20553 // across react native and web. However, `BlockRemovalWarningModal` is web only.
20554 // Check it exists before trying to render it.
20555 if (!BlockRemovalWarningModal) {
20556 return null;
20557 }
20558 if (!removalRulesForPostType) {
20559 return null;
20560 }
20561 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarningModal, {
20562 rules: removalRulesForPostType
20563 });
20564 }
20565
20566 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-page-options/index.js
20567 /**
20568 * WordPress dependencies
20569 */
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579 /**
20580 * Internal dependencies
20581 */
20582
20583
20584
20585 function useStartPatterns() {
20586 // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
20587 // and it has no postTypes declared and the current post type is page or if
20588 // the current post type is part of the postTypes declared.
20589 const {
20590 blockPatternsWithPostContentBlockType,
20591 postType
20592 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20593 const {
20594 getPatternsByBlockTypes,
20595 getBlocksByName
20596 } = select(external_wp_blockEditor_namespaceObject.store);
20597 const {
20598 getCurrentPostType,
20599 getRenderingMode
20600 } = select(store_store);
20601 const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
20602 return {
20603 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
20604 postType: getCurrentPostType()
20605 };
20606 }, []);
20607 return (0,external_wp_element_namespaceObject.useMemo)(() => {
20608 // filter patterns without postTypes declared if the current postType is page
20609 // or patterns that declare the current postType in its post type array.
20610 return blockPatternsWithPostContentBlockType.filter(pattern => {
20611 return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
20612 });
20613 }, [postType, blockPatternsWithPostContentBlockType]);
20614 }
20615 function PatternSelection({
20616 blockPatterns,
20617 onChoosePattern
20618 }) {
20619 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
20620 const {
20621 editEntityRecord
20622 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
20623 const {
20624 postType,
20625 postId
20626 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20627 const {
20628 getCurrentPostType,
20629 getCurrentPostId
20630 } = select(store_store);
20631 return {
20632 postType: getCurrentPostType(),
20633 postId: getCurrentPostId()
20634 };
20635 }, []);
20636 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
20637 blockPatterns: blockPatterns,
20638 shownPatterns: shownBlockPatterns,
20639 onClickPattern: (_pattern, blocks) => {
20640 editEntityRecord('postType', postType, postId, {
20641 blocks,
20642 content: ({
20643 blocks: blocksForSerialization = []
20644 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization)
20645 });
20646 onChoosePattern();
20647 }
20648 });
20649 }
20650 function StartPageOptionsModal({
20651 onClose
20652 }) {
20653 const startPatterns = useStartPatterns();
20654 const hasStartPattern = startPatterns.length > 0;
20655 if (!hasStartPattern) {
20656 return null;
20657 }
20658 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
20659 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
20660 isFullScreen: true,
20661 onRequestClose: onClose,
20662 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20663 className: "editor-start-page-options__modal-content",
20664 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternSelection, {
20665 blockPatterns: startPatterns,
20666 onChoosePattern: onClose
20667 })
20668 })
20669 });
20670 }
20671 function StartPageOptions() {
20672 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
20673 const {
20674 shouldEnableModal,
20675 postType,
20676 postId
20677 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20678 const {
20679 isEditedPostDirty,
20680 isEditedPostEmpty,
20681 getCurrentPostType,
20682 getCurrentPostId
20683 } = select(store_store);
20684 const _postType = getCurrentPostType();
20685 return {
20686 shouldEnableModal: !isEditedPostDirty() && isEditedPostEmpty() && TEMPLATE_POST_TYPE !== _postType,
20687 postType: _postType,
20688 postId: getCurrentPostId()
20689 };
20690 }, []);
20691 (0,external_wp_element_namespaceObject.useEffect)(() => {
20692 // Should reset the modal state when navigating to a new page/post.
20693 setIsClosed(false);
20694 }, [postType, postId]);
20695 if (!shouldEnableModal || isClosed) {
20696 return null;
20697 }
20698 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptionsModal, {
20699 onClose: () => setIsClosed(true)
20700 });
20701 }
20702
20703 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js
20704 /**
20705 * WordPress dependencies
20706 */
20707
20708 const textFormattingShortcuts = [{
20709 keyCombination: {
20710 modifier: 'primary',
20711 character: 'b'
20712 },
20713 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
20714 }, {
20715 keyCombination: {
20716 modifier: 'primary',
20717 character: 'i'
20718 },
20719 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
20720 }, {
20721 keyCombination: {
20722 modifier: 'primary',
20723 character: 'k'
20724 },
20725 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
20726 }, {
20727 keyCombination: {
20728 modifier: 'primaryShift',
20729 character: 'k'
20730 },
20731 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
20732 }, {
20733 keyCombination: {
20734 character: '[['
20735 },
20736 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.')
20737 }, {
20738 keyCombination: {
20739 modifier: 'primary',
20740 character: 'u'
20741 },
20742 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
20743 }, {
20744 keyCombination: {
20745 modifier: 'access',
20746 character: 'd'
20747 },
20748 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
20749 }, {
20750 keyCombination: {
20751 modifier: 'access',
20752 character: 'x'
20753 },
20754 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
20755 }, {
20756 keyCombination: {
20757 modifier: 'access',
20758 character: '0'
20759 },
20760 aliases: [{
20761 modifier: 'access',
20762 character: '7'
20763 }],
20764 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.')
20765 }, {
20766 keyCombination: {
20767 modifier: 'access',
20768 character: '1-6'
20769 },
20770 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.')
20771 }, {
20772 keyCombination: {
20773 modifier: 'primaryShift',
20774 character: 'SPACE'
20775 },
20776 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.')
20777 }];
20778
20779 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js
20780 /**
20781 * WordPress dependencies
20782 */
20783
20784
20785
20786
20787
20788 function KeyCombination({
20789 keyCombination,
20790 forceAriaLabel
20791 }) {
20792 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20793 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20794 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20795 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
20796 "aria-label": forceAriaLabel || ariaLabel,
20797 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
20798 if (character === '+') {
20799 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
20800 children: character
20801 }, index);
20802 }
20803 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20804 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
20805 children: character
20806 }, index);
20807 })
20808 });
20809 }
20810 function Shortcut({
20811 description,
20812 keyCombination,
20813 aliases = [],
20814 ariaLabel
20815 }) {
20816 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20817 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20818 className: "editor-keyboard-shortcut-help-modal__shortcut-description",
20819 children: description
20820 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
20821 className: "editor-keyboard-shortcut-help-modal__shortcut-term",
20822 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20823 keyCombination: keyCombination,
20824 forceAriaLabel: ariaLabel
20825 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20826 keyCombination: alias,
20827 forceAriaLabel: ariaLabel
20828 }, index))]
20829 })]
20830 });
20831 }
20832 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut);
20833
20834 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
20835 /**
20836 * WordPress dependencies
20837 */
20838
20839
20840
20841 /**
20842 * Internal dependencies
20843 */
20844
20845
20846 function DynamicShortcut({
20847 name
20848 }) {
20849 const {
20850 keyCombination,
20851 description,
20852 aliases
20853 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20854 const {
20855 getShortcutKeyCombination,
20856 getShortcutDescription,
20857 getShortcutAliases
20858 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
20859 return {
20860 keyCombination: getShortcutKeyCombination(name),
20861 aliases: getShortcutAliases(name),
20862 description: getShortcutDescription(name)
20863 };
20864 }, [name]);
20865 if (!keyCombination) {
20866 return null;
20867 }
20868 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20869 keyCombination: keyCombination,
20870 description: description,
20871 aliases: aliases
20872 });
20873 }
20874 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut);
20875
20876 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js
20877 /**
20878 * External dependencies
20879 */
20880
20881
20882 /**
20883 * WordPress dependencies
20884 */
20885
20886
20887
20888
20889
20890
20891 /**
20892 * Internal dependencies
20893 */
20894
20895
20896
20897
20898
20899 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';
20900 const ShortcutList = ({
20901 shortcuts
20902 }) =>
20903 /*#__PURE__*/
20904 /*
20905 * Disable reason: The `list` ARIA role is redundant but
20906 * Safari+VoiceOver won't announce the list otherwise.
20907 */
20908 /* eslint-disable jsx-a11y/no-redundant-roles */
20909 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
20910 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
20911 role: "list",
20912 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
20913 className: "editor-keyboard-shortcut-help-modal__shortcut",
20914 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, {
20915 name: shortcut
20916 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20917 ...shortcut
20918 })
20919 }, index))
20920 })
20921 /* eslint-enable jsx-a11y/no-redundant-roles */;
20922 const ShortcutSection = ({
20923 title,
20924 shortcuts,
20925 className
20926 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
20927 className: dist_clsx('editor-keyboard-shortcut-help-modal__section', className),
20928 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
20929 className: "editor-keyboard-shortcut-help-modal__section-title",
20930 children: title
20931 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, {
20932 shortcuts: shortcuts
20933 })]
20934 });
20935 const ShortcutCategorySection = ({
20936 title,
20937 categoryName,
20938 additionalShortcuts = []
20939 }) => {
20940 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
20941 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
20942 }, [categoryName]);
20943 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20944 title: title,
20945 shortcuts: categoryShortcuts.concat(additionalShortcuts)
20946 });
20947 };
20948 function KeyboardShortcutHelpModal() {
20949 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), []);
20950 const {
20951 openModal,
20952 closeModal
20953 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20954 const toggleModal = () => {
20955 if (isModalActive) {
20956 closeModal();
20957 } else {
20958 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
20959 }
20960 };
20961 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/keyboard-shortcuts', toggleModal);
20962 if (!isModalActive) {
20963 return null;
20964 }
20965 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
20966 className: "editor-keyboard-shortcut-help-modal",
20967 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
20968 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
20969 onRequestClose: toggleModal,
20970 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20971 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
20972 shortcuts: ['core/editor/keyboard-shortcuts']
20973 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20974 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
20975 categoryName: "global"
20976 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20977 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
20978 categoryName: "selection"
20979 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20980 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
20981 categoryName: "block",
20982 additionalShortcuts: [{
20983 keyCombination: {
20984 character: '/'
20985 },
20986 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
20987 /* translators: The forward-slash character. e.g. '/'. */
20988 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
20989 }]
20990 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20991 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
20992 shortcuts: textFormattingShortcuts
20993 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20994 title: (0,external_wp_i18n_namespaceObject.__)('List View shortcuts'),
20995 categoryName: "list-view"
20996 })]
20997 });
20998 }
20999 /* harmony default export */ const keyboard_shortcut_help_modal = (KeyboardShortcutHelpModal);
21000
21001 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/content-only-settings-menu.js
21002 /**
21003 * WordPress dependencies
21004 */
21005
21006
21007
21008
21009
21010
21011 /**
21012 * Internal dependencies
21013 */
21014
21015
21016
21017
21018
21019 function ContentOnlySettingsMenuItems({
21020 clientId,
21021 onClose
21022 }) {
21023 const {
21024 entity,
21025 onNavigateToEntityRecord,
21026 canEditTemplates
21027 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21028 const {
21029 getBlockEditingMode,
21030 getBlockParentsByBlockName,
21031 getSettings,
21032 getBlockAttributes
21033 } = select(external_wp_blockEditor_namespaceObject.store);
21034 const contentOnly = getBlockEditingMode(clientId) === 'contentOnly';
21035 if (!contentOnly) {
21036 return {};
21037 }
21038 const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
21039 let record;
21040 if (patternParent) {
21041 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
21042 } else {
21043 const {
21044 getCurrentTemplateId
21045 } = select(store_store);
21046 const templateId = getCurrentTemplateId();
21047 const {
21048 getContentLockingParent
21049 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
21050 if (!getContentLockingParent(clientId) && templateId) {
21051 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
21052 }
21053 }
21054 const _canEditTemplates = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates');
21055 return {
21056 canEditTemplates: _canEditTemplates,
21057 entity: record,
21058 onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
21059 };
21060 }, [clientId]);
21061 if (!entity) {
21062 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateLockContentOnlyMenuItems, {
21063 clientId: clientId,
21064 onClose: onClose
21065 });
21066 }
21067 const isPattern = entity.type === 'wp_block';
21068 let helpText = isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit the pattern to move, delete, or make further changes to this block.') : (0,external_wp_i18n_namespaceObject.__)('Edit the template to move, delete, or make further changes to this block.');
21069 if (!canEditTemplates) {
21070 helpText = (0,external_wp_i18n_namespaceObject.__)('Only users with permissions to edit the template can move or delete this block');
21071 }
21072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21073 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
21074 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21075 onClick: () => {
21076 onNavigateToEntityRecord({
21077 postId: entity.id,
21078 postType: entity.type
21079 });
21080 },
21081 disabled: !canEditTemplates,
21082 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit pattern') : (0,external_wp_i18n_namespaceObject.__)('Edit template')
21083 })
21084 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
21085 variant: "muted",
21086 as: "p",
21087 className: "editor-content-only-settings-menu__description",
21088 children: helpText
21089 })]
21090 });
21091 }
21092 function TemplateLockContentOnlyMenuItems({
21093 clientId,
21094 onClose
21095 }) {
21096 const {
21097 contentLockingParent
21098 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21099 const {
21100 getContentLockingParent
21101 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
21102 return {
21103 contentLockingParent: getContentLockingParent(clientId)
21104 };
21105 }, [clientId]);
21106 const blockDisplayInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(contentLockingParent);
21107 // Disable reason: We're using a hook here so it has to be on top-level.
21108 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
21109 const {
21110 modifyContentLockBlock,
21111 selectBlock
21112 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
21113 if (!blockDisplayInformation?.title) {
21114 return null;
21115 }
21116 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21117 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
21118 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21119 onClick: () => {
21120 selectBlock(contentLockingParent);
21121 modifyContentLockBlock(contentLockingParent);
21122 onClose();
21123 },
21124 children: (0,external_wp_i18n_namespaceObject.__)('Unlock')
21125 })
21126 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
21127 variant: "muted",
21128 as: "p",
21129 className: "editor-content-only-settings-menu__description",
21130 children: (0,external_wp_i18n_namespaceObject.__)('Temporarily unlock the parent block to edit, delete or make further changes to this block.')
21131 })]
21132 });
21133 }
21134 function ContentOnlySettingsMenu() {
21135 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
21136 children: ({
21137 selectedClientIds,
21138 onClose
21139 }) => selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenuItems, {
21140 clientId: selectedClientIds[0],
21141 onClose: onClose
21142 })
21143 });
21144 }
21145
21146 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-template-options/index.js
21147 /**
21148 * WordPress dependencies
21149 */
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159 /**
21160 * Internal dependencies
21161 */
21162
21163
21164
21165
21166 function useFallbackTemplateContent(slug, isCustom = false) {
21167 return (0,external_wp_data_namespaceObject.useSelect)(select => {
21168 const {
21169 getEntityRecord,
21170 getDefaultTemplateId
21171 } = select(external_wp_coreData_namespaceObject.store);
21172 const templateId = getDefaultTemplateId({
21173 slug,
21174 is_custom: isCustom,
21175 ignore_empty: true
21176 });
21177 return templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
21178 }, [slug, isCustom]);
21179 }
21180 function start_template_options_useStartPatterns(fallbackContent) {
21181 const {
21182 slug,
21183 patterns
21184 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21185 const {
21186 getCurrentPostType,
21187 getCurrentPostId
21188 } = select(store_store);
21189 const {
21190 getEntityRecord,
21191 getBlockPatterns
21192 } = select(external_wp_coreData_namespaceObject.store);
21193 const postId = getCurrentPostId();
21194 const postType = getCurrentPostType();
21195 const record = getEntityRecord('postType', postType, postId);
21196 return {
21197 slug: record.slug,
21198 patterns: getBlockPatterns()
21199 };
21200 }, []);
21201 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet);
21202
21203 // Duplicated from packages/block-library/src/pattern/edit.js.
21204 function injectThemeAttributeInBlockTemplateContent(block) {
21205 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
21206 block.innerBlocks = block.innerBlocks.map(innerBlock => {
21207 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
21208 innerBlock.attributes.theme = currentThemeStylesheet;
21209 }
21210 return innerBlock;
21211 });
21212 }
21213 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
21214 block.attributes.theme = currentThemeStylesheet;
21215 }
21216 return block;
21217 }
21218 return (0,external_wp_element_namespaceObject.useMemo)(() => {
21219 // filter patterns that are supposed to be used in the current template being edited.
21220 return [{
21221 name: 'fallback',
21222 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent),
21223 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content')
21224 }, ...patterns.filter(pattern => {
21225 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
21226 }).map(pattern => {
21227 return {
21228 ...pattern,
21229 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
21230 };
21231 })];
21232 }, [fallbackContent, slug, patterns]);
21233 }
21234 function start_template_options_PatternSelection({
21235 fallbackContent,
21236 onChoosePattern,
21237 postType
21238 }) {
21239 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType);
21240 const blockPatterns = start_template_options_useStartPatterns(fallbackContent);
21241 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
21242 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
21243 blockPatterns: blockPatterns,
21244 shownPatterns: shownBlockPatterns,
21245 onClickPattern: (pattern, blocks) => {
21246 onChange(blocks, {
21247 selection: undefined
21248 });
21249 onChoosePattern();
21250 }
21251 });
21252 }
21253 function StartModal({
21254 slug,
21255 isCustom,
21256 onClose,
21257 postType
21258 }) {
21259 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
21260 if (!fallbackContent) {
21261 return null;
21262 }
21263 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
21264 className: "editor-start-template-options__modal",
21265 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
21266 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
21267 focusOnMount: "firstElement",
21268 onRequestClose: onClose,
21269 isFullScreen: true,
21270 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21271 className: "editor-start-template-options__modal-content",
21272 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(start_template_options_PatternSelection, {
21273 fallbackContent: fallbackContent,
21274 slug: slug,
21275 isCustom: isCustom,
21276 postType: postType,
21277 onChoosePattern: () => {
21278 onClose();
21279 }
21280 })
21281 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
21282 className: "editor-start-template-options__modal__actions",
21283 justify: "flex-end",
21284 expanded: false,
21285 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21286 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21287 variant: "tertiary",
21288 onClick: onClose,
21289 children: (0,external_wp_i18n_namespaceObject.__)('Skip')
21290 })
21291 })
21292 })]
21293 });
21294 }
21295 function StartTemplateOptions() {
21296 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
21297 const {
21298 shouldOpenModal,
21299 slug,
21300 isCustom,
21301 postType,
21302 postId
21303 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21304 const {
21305 getCurrentPostType,
21306 getCurrentPostId
21307 } = select(store_store);
21308 const _postType = getCurrentPostType();
21309 const _postId = getCurrentPostId();
21310 const {
21311 getEditedEntityRecord,
21312 hasEditsForEntityRecord
21313 } = select(external_wp_coreData_namespaceObject.store);
21314 const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
21315 const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
21316 return {
21317 shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
21318 slug: templateRecord.slug,
21319 isCustom: templateRecord.is_custom,
21320 postType: _postType,
21321 postId: _postId
21322 };
21323 }, []);
21324 (0,external_wp_element_namespaceObject.useEffect)(() => {
21325 // Should reset the modal state when navigating to a new page/post.
21326 setIsClosed(false);
21327 }, [postType, postId]);
21328 if (!shouldOpenModal || isClosed) {
21329 return null;
21330 }
21331 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartModal, {
21332 slug: slug,
21333 isCustom: isCustom,
21334 postType: postType,
21335 onClose: () => setIsClosed(true)
21336 });
21337 }
21338
21339 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/convert-to-regular.js
21340 /**
21341 * WordPress dependencies
21342 */
21343
21344
21345
21346
21347
21348 function ConvertToRegularBlocks({
21349 clientId,
21350 onClose
21351 }) {
21352 const {
21353 getBlocks
21354 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
21355 const {
21356 replaceBlocks
21357 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
21358 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
21359 if (!canRemove) {
21360 return null;
21361 }
21362 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21363 onClick: () => {
21364 replaceBlocks(clientId, getBlocks(clientId));
21365 onClose();
21366 },
21367 children: (0,external_wp_i18n_namespaceObject.__)('Detach')
21368 });
21369 }
21370
21371 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
21372 /******************************************************************************
21373 Copyright (c) Microsoft Corporation.
21374
21375 Permission to use, copy, modify, and/or distribute this software for any
21376 purpose with or without fee is hereby granted.
21377
21378 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21379 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21380 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21381 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21382 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21383 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21384 PERFORMANCE OF THIS SOFTWARE.
21385 ***************************************************************************** */
21386 /* global Reflect, Promise, SuppressedError, Symbol */
21387
21388 var extendStatics = function(d, b) {
21389 extendStatics = Object.setPrototypeOf ||
21390 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21391 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21392 return extendStatics(d, b);
21393 };
21394
21395 function __extends(d, b) {
21396 if (typeof b !== "function" && b !== null)
21397 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
21398 extendStatics(d, b);
21399 function __() { this.constructor = d; }
21400 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21401 }
21402
21403 var __assign = function() {
21404 __assign = Object.assign || function __assign(t) {
21405 for (var s, i = 1, n = arguments.length; i < n; i++) {
21406 s = arguments[i];
21407 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21408 }
21409 return t;
21410 }
21411 return __assign.apply(this, arguments);
21412 }
21413
21414 function __rest(s, e) {
21415 var t = {};
21416 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
21417 t[p] = s[p];
21418 if (s != null && typeof Object.getOwnPropertySymbols === "function")
21419 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21420 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
21421 t[p[i]] = s[p[i]];
21422 }
21423 return t;
21424 }
21425
21426 function __decorate(decorators, target, key, desc) {
21427 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21428 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21429 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21430 return c > 3 && r && Object.defineProperty(target, key, r), r;
21431 }
21432
21433 function __param(paramIndex, decorator) {
21434 return function (target, key) { decorator(target, key, paramIndex); }
21435 }
21436
21437 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
21438 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
21439 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
21440 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
21441 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
21442 var _, done = false;
21443 for (var i = decorators.length - 1; i >= 0; i--) {
21444 var context = {};
21445 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
21446 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
21447 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
21448 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21449 if (kind === "accessor") {
21450 if (result === void 0) continue;
21451 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
21452 if (_ = accept(result.get)) descriptor.get = _;
21453 if (_ = accept(result.set)) descriptor.set = _;
21454 if (_ = accept(result.init)) initializers.unshift(_);
21455 }
21456 else if (_ = accept(result)) {
21457 if (kind === "field") initializers.unshift(_);
21458 else descriptor[key] = _;
21459 }
21460 }
21461 if (target) Object.defineProperty(target, contextIn.name, descriptor);
21462 done = true;
21463 };
21464
21465 function __runInitializers(thisArg, initializers, value) {
21466 var useValue = arguments.length > 2;
21467 for (var i = 0; i < initializers.length; i++) {
21468 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
21469 }
21470 return useValue ? value : void 0;
21471 };
21472
21473 function __propKey(x) {
21474 return typeof x === "symbol" ? x : "".concat(x);
21475 };
21476
21477 function __setFunctionName(f, name, prefix) {
21478 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
21479 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
21480 };
21481
21482 function __metadata(metadataKey, metadataValue) {
21483 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
21484 }
21485
21486 function __awaiter(thisArg, _arguments, P, generator) {
21487 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21488 return new (P || (P = Promise))(function (resolve, reject) {
21489 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21490 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21491 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21492 step((generator = generator.apply(thisArg, _arguments || [])).next());
21493 });
21494 }
21495
21496 function __generator(thisArg, body) {
21497 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
21498 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
21499 function verb(n) { return function (v) { return step([n, v]); }; }
21500 function step(op) {
21501 if (f) throw new TypeError("Generator is already executing.");
21502 while (g && (g = 0, op[0] && (_ = 0)), _) try {
21503 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
21504 if (y = 0, t) op = [op[0] & 2, t.value];
21505 switch (op[0]) {
21506 case 0: case 1: t = op; break;
21507 case 4: _.label++; return { value: op[1], done: false };
21508 case 5: _.label++; y = op[1]; op = [0]; continue;
21509 case 7: op = _.ops.pop(); _.trys.pop(); continue;
21510 default:
21511 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
21512 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
21513 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
21514 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
21515 if (t[2]) _.ops.pop();
21516 _.trys.pop(); continue;
21517 }
21518 op = body.call(thisArg, _);
21519 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
21520 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
21521 }
21522 }
21523
21524 var __createBinding = Object.create ? (function(o, m, k, k2) {
21525 if (k2 === undefined) k2 = k;
21526 var desc = Object.getOwnPropertyDescriptor(m, k);
21527 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21528 desc = { enumerable: true, get: function() { return m[k]; } };
21529 }
21530 Object.defineProperty(o, k2, desc);
21531 }) : (function(o, m, k, k2) {
21532 if (k2 === undefined) k2 = k;
21533 o[k2] = m[k];
21534 });
21535
21536 function __exportStar(m, o) {
21537 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
21538 }
21539
21540 function __values(o) {
21541 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21542 if (m) return m.call(o);
21543 if (o && typeof o.length === "number") return {
21544 next: function () {
21545 if (o && i >= o.length) o = void 0;
21546 return { value: o && o[i++], done: !o };
21547 }
21548 };
21549 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
21550 }
21551
21552 function __read(o, n) {
21553 var m = typeof Symbol === "function" && o[Symbol.iterator];
21554 if (!m) return o;
21555 var i = m.call(o), r, ar = [], e;
21556 try {
21557 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21558 }
21559 catch (error) { e = { error: error }; }
21560 finally {
21561 try {
21562 if (r && !r.done && (m = i["return"])) m.call(i);
21563 }
21564 finally { if (e) throw e.error; }
21565 }
21566 return ar;
21567 }
21568
21569 /** @deprecated */
21570 function __spread() {
21571 for (var ar = [], i = 0; i < arguments.length; i++)
21572 ar = ar.concat(__read(arguments[i]));
21573 return ar;
21574 }
21575
21576 /** @deprecated */
21577 function __spreadArrays() {
21578 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
21579 for (var r = Array(s), k = 0, i = 0; i < il; i++)
21580 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
21581 r[k] = a[j];
21582 return r;
21583 }
21584
21585 function __spreadArray(to, from, pack) {
21586 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21587 if (ar || !(i in from)) {
21588 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21589 ar[i] = from[i];
21590 }
21591 }
21592 return to.concat(ar || Array.prototype.slice.call(from));
21593 }
21594
21595 function __await(v) {
21596 return this instanceof __await ? (this.v = v, this) : new __await(v);
21597 }
21598
21599 function __asyncGenerator(thisArg, _arguments, generator) {
21600 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21601 var g = generator.apply(thisArg, _arguments || []), i, q = [];
21602 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
21603 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
21604 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
21605 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
21606 function fulfill(value) { resume("next", value); }
21607 function reject(value) { resume("throw", value); }
21608 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
21609 }
21610
21611 function __asyncDelegator(o) {
21612 var i, p;
21613 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
21614 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
21615 }
21616
21617 function __asyncValues(o) {
21618 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21619 var m = o[Symbol.asyncIterator], i;
21620 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
21621 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
21622 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
21623 }
21624
21625 function __makeTemplateObject(cooked, raw) {
21626 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
21627 return cooked;
21628 };
21629
21630 var __setModuleDefault = Object.create ? (function(o, v) {
21631 Object.defineProperty(o, "default", { enumerable: true, value: v });
21632 }) : function(o, v) {
21633 o["default"] = v;
21634 };
21635
21636 function __importStar(mod) {
21637 if (mod && mod.__esModule) return mod;
21638 var result = {};
21639 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21640 __setModuleDefault(result, mod);
21641 return result;
21642 }
21643
21644 function __importDefault(mod) {
21645 return (mod && mod.__esModule) ? mod : { default: mod };
21646 }
21647
21648 function __classPrivateFieldGet(receiver, state, kind, f) {
21649 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21650 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21651 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21652 }
21653
21654 function __classPrivateFieldSet(receiver, state, value, kind, f) {
21655 if (kind === "m") throw new TypeError("Private method is not writable");
21656 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
21657 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
21658 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21659 }
21660
21661 function __classPrivateFieldIn(state, receiver) {
21662 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
21663 return typeof state === "function" ? receiver === state : state.has(receiver);
21664 }
21665
21666 function __addDisposableResource(env, value, async) {
21667 if (value !== null && value !== void 0) {
21668 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
21669 var dispose;
21670 if (async) {
21671 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
21672 dispose = value[Symbol.asyncDispose];
21673 }
21674 if (dispose === void 0) {
21675 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
21676 dispose = value[Symbol.dispose];
21677 }
21678 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
21679 env.stack.push({ value: value, dispose: dispose, async: async });
21680 }
21681 else if (async) {
21682 env.stack.push({ async: true });
21683 }
21684 return value;
21685 }
21686
21687 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
21688 var e = new Error(message);
21689 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21690 };
21691
21692 function __disposeResources(env) {
21693 function fail(e) {
21694 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
21695 env.hasError = true;
21696 }
21697 function next() {
21698 while (env.stack.length) {
21699 var rec = env.stack.pop();
21700 try {
21701 var result = rec.dispose && rec.dispose.call(rec.value);
21702 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
21703 }
21704 catch (e) {
21705 fail(e);
21706 }
21707 }
21708 if (env.hasError) throw env.error;
21709 }
21710 return next();
21711 }
21712
21713 /* harmony default export */ const tslib_es6 = ({
21714 __extends,
21715 __assign,
21716 __rest,
21717 __decorate,
21718 __param,
21719 __metadata,
21720 __awaiter,
21721 __generator,
21722 __createBinding,
21723 __exportStar,
21724 __values,
21725 __read,
21726 __spread,
21727 __spreadArrays,
21728 __spreadArray,
21729 __await,
21730 __asyncGenerator,
21731 __asyncDelegator,
21732 __asyncValues,
21733 __makeTemplateObject,
21734 __importStar,
21735 __importDefault,
21736 __classPrivateFieldGet,
21737 __classPrivateFieldSet,
21738 __classPrivateFieldIn,
21739 __addDisposableResource,
21740 __disposeResources,
21741 });
21742
21743 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
21744 /**
21745 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
21746 */
21747 var SUPPORTED_LOCALE = {
21748 tr: {
21749 regexp: /\u0130|\u0049|\u0049\u0307/g,
21750 map: {
21751 İ: "\u0069",
21752 I: "\u0131",
21753 İ: "\u0069",
21754 },
21755 },
21756 az: {
21757 regexp: /\u0130/g,
21758 map: {
21759 İ: "\u0069",
21760 I: "\u0131",
21761 İ: "\u0069",
21762 },
21763 },
21764 lt: {
21765 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
21766 map: {
21767 I: "\u0069\u0307",
21768 J: "\u006A\u0307",
21769 Į: "\u012F\u0307",
21770 Ì: "\u0069\u0307\u0300",
21771 Í: "\u0069\u0307\u0301",
21772 Ĩ: "\u0069\u0307\u0303",
21773 },
21774 },
21775 };
21776 /**
21777 * Localized lower case.
21778 */
21779 function localeLowerCase(str, locale) {
21780 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
21781 if (lang)
21782 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
21783 return lowerCase(str);
21784 }
21785 /**
21786 * Lower case as a function.
21787 */
21788 function lowerCase(str) {
21789 return str.toLowerCase();
21790 }
21791
21792 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
21793
21794 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
21795 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
21796 // Remove all non-word characters.
21797 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
21798 /**
21799 * Normalize the string into something other libraries can manipulate easier.
21800 */
21801 function noCase(input, options) {
21802 if (options === void 0) { options = {}; }
21803 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
21804 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
21805 var start = 0;
21806 var end = result.length;
21807 // Trim the delimiter from around the output string.
21808 while (result.charAt(start) === "\0")
21809 start++;
21810 while (result.charAt(end - 1) === "\0")
21811 end--;
21812 // Transform each token independently.
21813 return result.slice(start, end).split("\0").map(transform).join(delimiter);
21814 }
21815 /**
21816 * Replace `re` in the input string with the replacement value.
21817 */
21818 function replace(input, re, value) {
21819 if (re instanceof RegExp)
21820 return input.replace(re, value);
21821 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
21822 }
21823
21824 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
21825
21826
21827 function dotCase(input, options) {
21828 if (options === void 0) { options = {}; }
21829 return noCase(input, __assign({ delimiter: "." }, options));
21830 }
21831
21832 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
21833
21834
21835 function paramCase(input, options) {
21836 if (options === void 0) { options = {}; }
21837 return dotCase(input, __assign({ delimiter: "-" }, options));
21838 }
21839
21840 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/utils.js
21841 /**
21842 * External dependencies
21843 */
21844
21845
21846 /**
21847 * WordPress dependencies
21848 */
21849
21850
21851
21852 /**
21853 * Internal dependencies
21854 */
21855
21856 const useExistingTemplateParts = () => {
21857 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
21858 per_page: -1
21859 }), []);
21860 };
21861
21862 /**
21863 * Return a unique template part title based on
21864 * the given title and existing template parts.
21865 *
21866 * @param {string} title The original template part title.
21867 * @param {Object} templateParts The array of template part entities.
21868 * @return {string} A unique template part title.
21869 */
21870 const getUniqueTemplatePartTitle = (title, templateParts) => {
21871 const lowercaseTitle = title.toLowerCase();
21872 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
21873 if (!existingTitles.includes(lowercaseTitle)) {
21874 return title;
21875 }
21876 let suffix = 2;
21877 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
21878 suffix++;
21879 }
21880 return `${title} ${suffix}`;
21881 };
21882
21883 /**
21884 * Get a valid slug for a template part.
21885 * Currently template parts only allow latin chars.
21886 * The fallback slug will receive suffix by default.
21887 *
21888 * @param {string} title The template part title.
21889 * @return {string} A valid template part slug.
21890 */
21891 const getCleanTemplatePartSlug = title => {
21892 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
21893 };
21894
21895 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/index.js
21896 /**
21897 * WordPress dependencies
21898 */
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909 /**
21910 * Internal dependencies
21911 */
21912
21913
21914
21915
21916
21917 function CreateTemplatePartModal({
21918 modalTitle,
21919 ...restProps
21920 }) {
21921 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, []);
21922 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
21923 title: modalTitle || defaultModalTitle,
21924 onRequestClose: restProps.closeModal,
21925 overlayClassName: "editor-create-template-part-modal",
21926 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
21927 ...restProps
21928 })
21929 });
21930 }
21931 function CreateTemplatePartModalContents({
21932 defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
21933 blocks = [],
21934 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Add'),
21935 closeModal,
21936 onCreate,
21937 onError,
21938 defaultTitle = ''
21939 }) {
21940 const {
21941 createErrorNotice
21942 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
21943 const {
21944 saveEntityRecord
21945 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
21946 const existingTemplateParts = useExistingTemplateParts();
21947 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle);
21948 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea);
21949 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
21950 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
21951 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetDefaultTemplatePartAreas(), []);
21952 async function createTemplatePart() {
21953 if (!title || isSubmitting) {
21954 return;
21955 }
21956 try {
21957 setIsSubmitting(true);
21958 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts);
21959 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
21960 const templatePart = await saveEntityRecord('postType', TEMPLATE_PART_POST_TYPE, {
21961 slug: cleanSlug,
21962 title: uniqueTitle,
21963 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
21964 area
21965 }, {
21966 throwOnError: true
21967 });
21968 await onCreate(templatePart);
21969
21970 // TODO: Add a success notice?
21971 } catch (error) {
21972 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
21973 createErrorNotice(errorMessage, {
21974 type: 'snackbar'
21975 });
21976 onError?.();
21977 } finally {
21978 setIsSubmitting(false);
21979 }
21980 }
21981 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
21982 onSubmit: async event => {
21983 event.preventDefault();
21984 await createTemplatePart();
21985 },
21986 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
21987 spacing: "4",
21988 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
21989 __next40pxDefaultSize: true,
21990 __nextHasNoMarginBottom: true,
21991 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
21992 value: title,
21993 onChange: setTitle,
21994 required: true
21995 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, {
21996 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
21997 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
21998 className: "editor-create-template-part-modal__area-base-control",
21999 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
22000 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
22001 className: "editor-create-template-part-modal__area-radio-group",
22002 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
22003 onChange: setArea,
22004 checked: area,
22005 children: templatePartAreas.map(({
22006 icon,
22007 label,
22008 area: value,
22009 description
22010 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadio, {
22011 value: value,
22012 className: "editor-create-template-part-modal__area-radio",
22013 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
22014 align: "start",
22015 justify: "start",
22016 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
22017 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
22018 icon: icon
22019 })
22020 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.FlexBlock, {
22021 className: "editor-create-template-part-modal__option-label",
22022 children: [label, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22023 children: description
22024 })]
22025 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
22026 className: "editor-create-template-part-modal__checkbox",
22027 children: area === value && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
22028 icon: library_check
22029 })
22030 })]
22031 })
22032 }, label))
22033 })
22034 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
22035 justify: "right",
22036 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22037 __next40pxDefaultSize: true,
22038 variant: "tertiary",
22039 onClick: () => {
22040 closeModal();
22041 },
22042 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
22043 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22044 __next40pxDefaultSize: true,
22045 variant: "primary",
22046 type: "submit",
22047 "aria-disabled": !title || isSubmitting,
22048 isBusy: isSubmitting,
22049 children: confirmLabel
22050 })]
22051 })]
22052 })
22053 });
22054 }
22055
22056 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.js
22057 /**
22058 * WordPress dependencies
22059 */
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069 /**
22070 * Internal dependencies
22071 */
22072
22073
22074
22075
22076 function ConvertToTemplatePart({
22077 clientIds,
22078 blocks
22079 }) {
22080 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
22081 const {
22082 replaceBlocks
22083 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
22084 const {
22085 createSuccessNotice
22086 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22087 const {
22088 canCreate
22089 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22090 return {
22091 canCreate: select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType('core/template-part')
22092 };
22093 }, []);
22094 if (!canCreate) {
22095 return null;
22096 }
22097 const onConvert = async templatePart => {
22098 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
22099 slug: templatePart.slug,
22100 theme: templatePart.theme
22101 }));
22102 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
22103 type: 'snackbar'
22104 });
22105
22106 // The modal and this component will be unmounted because of `replaceBlocks` above,
22107 // so no need to call `closeModal` or `onClose`.
22108 };
22109 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22110 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22111 icon: symbol_filled,
22112 onClick: () => {
22113 setIsModalOpen(true);
22114 },
22115 "aria-expanded": isModalOpen,
22116 "aria-haspopup": "dialog",
22117 children: (0,external_wp_i18n_namespaceObject.__)('Create template part')
22118 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModal, {
22119 closeModal: () => {
22120 setIsModalOpen(false);
22121 },
22122 blocks: blocks,
22123 onCreate: onConvert
22124 })]
22125 });
22126 }
22127
22128 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/index.js
22129 /**
22130 * WordPress dependencies
22131 */
22132
22133
22134
22135 /**
22136 * Internal dependencies
22137 */
22138
22139
22140
22141 function TemplatePartMenuItems() {
22142 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
22143 children: ({
22144 selectedClientIds,
22145 onClose
22146 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartConverterMenuItem, {
22147 clientIds: selectedClientIds,
22148 onClose: onClose
22149 })
22150 });
22151 }
22152 function TemplatePartConverterMenuItem({
22153 clientIds,
22154 onClose
22155 }) {
22156 const {
22157 isContentOnly,
22158 blocks
22159 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22160 const {
22161 getBlocksByClientId,
22162 getBlockEditingMode
22163 } = select(external_wp_blockEditor_namespaceObject.store);
22164 return {
22165 blocks: getBlocksByClientId(clientIds),
22166 isContentOnly: clientIds.length === 1 && getBlockEditingMode(clientIds[0]) === 'contentOnly'
22167 };
22168 }, [clientIds]);
22169
22170 // Do not show the convert button if the block is in content-only mode.
22171 if (isContentOnly) {
22172 return null;
22173 }
22174
22175 // Allow converting a single template part to standard blocks.
22176 if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') {
22177 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToRegularBlocks, {
22178 clientId: clientIds[0],
22179 onClose: onClose
22180 });
22181 }
22182 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToTemplatePart, {
22183 clientIds: clientIds,
22184 blocks: blocks
22185 });
22186 }
22187
22188 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/index.js
22189 /**
22190 * WordPress dependencies
22191 */
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201 /**
22202 * Internal dependencies
22203 */
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224 const {
22225 ExperimentalBlockEditorProvider
22226 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
22227 const {
22228 PatternsMenuItems
22229 } = unlock(external_wp_patterns_namespaceObject.privateApis);
22230 const provider_noop = () => {};
22231
22232 /**
22233 * These are global entities that are only there to split blocks into logical units
22234 * They don't provide a "context" for the current post/page being rendered.
22235 * So we should not use their ids as post context. This is important to allow post blocks
22236 * (post content, post title) to be used within them without issues.
22237 */
22238 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_template', 'wp_navigation', 'wp_template_part'];
22239
22240 /**
22241 * Depending on the post, template and template mode,
22242 * returns the appropriate blocks and change handlers for the block editor provider.
22243 *
22244 * @param {Array} post Block list.
22245 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
22246 * @param {string} mode Rendering mode.
22247 *
22248 * @example
22249 * ```jsx
22250 * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );
22251 * ```
22252 *
22253 * @return {Array} Block editor props.
22254 */
22255 function useBlockEditorProps(post, template, mode) {
22256 const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template';
22257 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, {
22258 id: post.id
22259 });
22260 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, {
22261 id: template?.id
22262 });
22263 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22264 if (post.type === 'wp_navigation') {
22265 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
22266 ref: post.id,
22267 // As the parent editor is locked with `templateLock`, the template locking
22268 // must be explicitly "unset" on the block itself to allow the user to modify
22269 // the block's content.
22270 templateLock: false
22271 })];
22272 }
22273 }, [post.type, post.id]);
22274
22275 // It is important that we don't create a new instance of blocks on every change
22276 // We should only create a new instance if the blocks them selves change, not a dependency of them.
22277 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22278 if (maybeNavigationBlocks) {
22279 return maybeNavigationBlocks;
22280 }
22281 if (rootLevelPost === 'template') {
22282 return templateBlocks;
22283 }
22284 return postBlocks;
22285 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
22286
22287 // Handle fallback to postBlocks outside of the above useMemo, to ensure
22288 // that constructed block templates that call `createBlock` are not generated
22289 // too frequently. This ensures that clientIds are stable.
22290 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
22291 if (disableRootLevelChanges) {
22292 return [blocks, provider_noop, provider_noop];
22293 }
22294 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
22295 }
22296
22297 /**
22298 * This component provides the editor context and manages the state of the block editor.
22299 *
22300 * @param {Object} props The component props.
22301 * @param {Object} props.post The post object.
22302 * @param {Object} props.settings The editor settings.
22303 * @param {boolean} props.recovery Indicates if the editor is in recovery mode.
22304 * @param {Array} props.initialEdits The initial edits for the editor.
22305 * @param {Object} props.children The child components.
22306 * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.
22307 * @param {Object} [props.__unstableTemplate] The template object.
22308 *
22309 * @example
22310 * ```jsx
22311 * <ExperimentalEditorProvider
22312 * post={ post }
22313 * settings={ settings }
22314 * recovery={ recovery }
22315 * initialEdits={ initialEdits }
22316 * __unstableTemplate={ template }
22317 * >
22318 * { children }
22319 * </ExperimentalEditorProvider>
22320 *
22321 * @return {Object} The rendered ExperimentalEditorProvider component.
22322 */
22323 const ExperimentalEditorProvider = with_registry_provider(({
22324 post,
22325 settings,
22326 recovery,
22327 initialEdits,
22328 children,
22329 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
22330 __unstableTemplate: template
22331 }) => {
22332 const {
22333 editorSettings,
22334 selection,
22335 isReady,
22336 mode
22337 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22338 const {
22339 getEditorSettings,
22340 getEditorSelection,
22341 getRenderingMode,
22342 __unstableIsEditorReady
22343 } = select(store_store);
22344 return {
22345 editorSettings: getEditorSettings(),
22346 isReady: __unstableIsEditorReady(),
22347 mode: getRenderingMode(),
22348 selection: getEditorSelection()
22349 };
22350 }, []);
22351 const shouldRenderTemplate = !!template && mode !== 'post-only';
22352 const rootLevelPost = shouldRenderTemplate ? template : post;
22353 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
22354 const postContext = !NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate ? {
22355 postId: post.id,
22356 postType: post.type
22357 } : {};
22358 return {
22359 ...postContext,
22360 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
22361 };
22362 }, [shouldRenderTemplate, post.id, post.type, rootLevelPost.type, rootLevelPost.slug]);
22363 const {
22364 id,
22365 type
22366 } = rootLevelPost;
22367 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id, mode);
22368 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
22369 const {
22370 updatePostLock,
22371 setupEditor,
22372 updateEditorSettings,
22373 setCurrentTemplateId,
22374 setEditedPost,
22375 setRenderingMode
22376 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
22377 const {
22378 createWarningNotice
22379 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22380
22381 // Ideally this should be synced on each change and not just something you do once.
22382 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
22383 // Assume that we don't need to initialize in the case of an error recovery.
22384 if (recovery) {
22385 return;
22386 }
22387 updatePostLock(settings.postLock);
22388 setupEditor(post, initialEdits, settings.template);
22389 if (settings.autosave) {
22390 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
22391 id: 'autosave-exists',
22392 actions: [{
22393 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
22394 url: settings.autosave.editLink
22395 }]
22396 });
22397 }
22398 }, []);
22399
22400 // Synchronizes the active post with the state
22401 (0,external_wp_element_namespaceObject.useEffect)(() => {
22402 setEditedPost(post.type, post.id);
22403 }, [post.type, post.id, setEditedPost]);
22404
22405 // Synchronize the editor settings as they change.
22406 (0,external_wp_element_namespaceObject.useEffect)(() => {
22407 updateEditorSettings(settings);
22408 }, [settings, updateEditorSettings]);
22409
22410 // Synchronizes the active template with the state.
22411 (0,external_wp_element_namespaceObject.useEffect)(() => {
22412 setCurrentTemplateId(template?.id);
22413 }, [template?.id, setCurrentTemplateId]);
22414
22415 // Sets the right rendering mode when loading the editor.
22416 (0,external_wp_element_namespaceObject.useEffect)(() => {
22417 var _settings$defaultRend;
22418 setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only');
22419 }, [settings.defaultRenderingMode, setRenderingMode]);
22420 useHideBlocksFromInserter(post.type, mode);
22421
22422 // Register the editor commands.
22423 useCommands();
22424 if (!isReady) {
22425 return null;
22426 }
22427 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
22428 kind: "root",
22429 type: "site",
22430 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
22431 kind: "postType",
22432 type: post.type,
22433 id: post.id,
22434 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
22435 value: defaultBlockContext,
22436 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockEditorProviderComponent, {
22437 value: blocks,
22438 onChange: onChange,
22439 onInput: onInput,
22440 selection: selection,
22441 settings: blockEditorSettings,
22442 useSubRegistry: false,
22443 children: [children, !settings.__unstableIsPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22444 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternsMenuItems, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartMenuItems, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenu, {}), mode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DisableNonPageContentBlocks, {}), type === 'wp_navigation' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigationBlockEditingMode, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorKeyboardShortcuts, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarnings, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptions, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartTemplateOptions, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternRenameModal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternDuplicateModal, {})]
22445 })]
22446 })
22447 })
22448 })
22449 });
22450 });
22451
22452 /**
22453 * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).
22454 *
22455 * It supports a large number of post types, including post, page, templates,
22456 * custom post types, patterns, template parts.
22457 *
22458 * All modification and changes are performed to the `@wordpress/core-data` store.
22459 *
22460 * @param {Object} props The component props.
22461 * @param {Object} [props.post] The post object to edit. This is required.
22462 * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.
22463 * This is optional and can only be used when the post type supports templates (like posts and pages).
22464 * @param {Object} [props.settings] The settings object to use for the editor.
22465 * This is optional and can be used to override the default settings.
22466 * @param {Element} [props.children] Children elements for which the BlockEditorProvider context should apply.
22467 * This is optional.
22468 *
22469 * @example
22470 * ```jsx
22471 * <EditorProvider
22472 * post={ post }
22473 * settings={ settings }
22474 * __unstableTemplate={ template }
22475 * >
22476 * { children }
22477 * </EditorProvider>
22478 * ```
22479 *
22480 * @return {JSX.Element} The rendered EditorProvider component.
22481 */
22482 function EditorProvider(props) {
22483 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalEditorProvider, {
22484 ...props,
22485 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider,
22486 children: props.children
22487 });
22488 }
22489 /* harmony default export */ const provider = (EditorProvider);
22490
22491 ;// CONCATENATED MODULE: external ["wp","serverSideRender"]
22492 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
22493 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
22494 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/deprecated.js
22495 // Block Creation Components.
22496 /**
22497 * WordPress dependencies
22498 */
22499
22500
22501
22502
22503
22504 function deprecateComponent(name, Wrapped, staticsToHoist = []) {
22505 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
22506 external_wp_deprecated_default()('wp.editor.' + name, {
22507 since: '5.3',
22508 alternative: 'wp.blockEditor.' + name,
22509 version: '6.2'
22510 });
22511 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapped, {
22512 ref: ref,
22513 ...props
22514 });
22515 });
22516 staticsToHoist.forEach(staticName => {
22517 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
22518 });
22519 return Component;
22520 }
22521 function deprecateFunction(name, func) {
22522 return (...args) => {
22523 external_wp_deprecated_default()('wp.editor.' + name, {
22524 since: '5.3',
22525 alternative: 'wp.blockEditor.' + name,
22526 version: '6.2'
22527 });
22528 return func(...args);
22529 };
22530 }
22531
22532 /**
22533 * @deprecated since 5.3, use `wp.blockEditor.RichText` instead.
22534 */
22535 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
22536 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
22537
22538
22539 /**
22540 * @deprecated since 5.3, use `wp.blockEditor.Autocomplete` instead.
22541 */
22542 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
22543 /**
22544 * @deprecated since 5.3, use `wp.blockEditor.AlignmentToolbar` instead.
22545 */
22546 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
22547 /**
22548 * @deprecated since 5.3, use `wp.blockEditor.BlockAlignmentToolbar` instead.
22549 */
22550 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
22551 /**
22552 * @deprecated since 5.3, use `wp.blockEditor.BlockControls` instead.
22553 */
22554 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
22555 /**
22556 * @deprecated since 5.3, use `wp.blockEditor.BlockEdit` instead.
22557 */
22558 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
22559 /**
22560 * @deprecated since 5.3, use `wp.blockEditor.BlockEditorKeyboardShortcuts` instead.
22561 */
22562 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
22563 /**
22564 * @deprecated since 5.3, use `wp.blockEditor.BlockFormatControls` instead.
22565 */
22566 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
22567 /**
22568 * @deprecated since 5.3, use `wp.blockEditor.BlockIcon` instead.
22569 */
22570 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
22571 /**
22572 * @deprecated since 5.3, use `wp.blockEditor.BlockInspector` instead.
22573 */
22574 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
22575 /**
22576 * @deprecated since 5.3, use `wp.blockEditor.BlockList` instead.
22577 */
22578 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
22579 /**
22580 * @deprecated since 5.3, use `wp.blockEditor.BlockMover` instead.
22581 */
22582 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
22583 /**
22584 * @deprecated since 5.3, use `wp.blockEditor.BlockNavigationDropdown` instead.
22585 */
22586 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
22587 /**
22588 * @deprecated since 5.3, use `wp.blockEditor.BlockSelectionClearer` instead.
22589 */
22590 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
22591 /**
22592 * @deprecated since 5.3, use `wp.blockEditor.BlockSettingsMenu` instead.
22593 */
22594 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
22595 /**
22596 * @deprecated since 5.3, use `wp.blockEditor.BlockTitle` instead.
22597 */
22598 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
22599 /**
22600 * @deprecated since 5.3, use `wp.blockEditor.BlockToolbar` instead.
22601 */
22602 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
22603 /**
22604 * @deprecated since 5.3, use `wp.blockEditor.ColorPalette` instead.
22605 */
22606 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
22607 /**
22608 * @deprecated since 5.3, use `wp.blockEditor.ContrastChecker` instead.
22609 */
22610 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
22611 /**
22612 * @deprecated since 5.3, use `wp.blockEditor.CopyHandler` instead.
22613 */
22614 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
22615 /**
22616 * @deprecated since 5.3, use `wp.blockEditor.DefaultBlockAppender` instead.
22617 */
22618 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
22619 /**
22620 * @deprecated since 5.3, use `wp.blockEditor.FontSizePicker` instead.
22621 */
22622 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
22623 /**
22624 * @deprecated since 5.3, use `wp.blockEditor.Inserter` instead.
22625 */
22626 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
22627 /**
22628 * @deprecated since 5.3, use `wp.blockEditor.InnerBlocks` instead.
22629 */
22630 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
22631 /**
22632 * @deprecated since 5.3, use `wp.blockEditor.InspectorAdvancedControls` instead.
22633 */
22634 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
22635 /**
22636 * @deprecated since 5.3, use `wp.blockEditor.InspectorControls` instead.
22637 */
22638 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
22639 /**
22640 * @deprecated since 5.3, use `wp.blockEditor.PanelColorSettings` instead.
22641 */
22642 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
22643 /**
22644 * @deprecated since 5.3, use `wp.blockEditor.PlainText` instead.
22645 */
22646 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
22647 /**
22648 * @deprecated since 5.3, use `wp.blockEditor.RichTextShortcut` instead.
22649 */
22650 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
22651 /**
22652 * @deprecated since 5.3, use `wp.blockEditor.RichTextToolbarButton` instead.
22653 */
22654 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
22655 /**
22656 * @deprecated since 5.3, use `wp.blockEditor.__unstableRichTextInputEvent` instead.
22657 */
22658 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
22659 /**
22660 * @deprecated since 5.3, use `wp.blockEditor.MediaPlaceholder` instead.
22661 */
22662 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
22663 /**
22664 * @deprecated since 5.3, use `wp.blockEditor.MediaUpload` instead.
22665 */
22666 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
22667 /**
22668 * @deprecated since 5.3, use `wp.blockEditor.MediaUploadCheck` instead.
22669 */
22670 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
22671 /**
22672 * @deprecated since 5.3, use `wp.blockEditor.MultiSelectScrollIntoView` instead.
22673 */
22674 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
22675 /**
22676 * @deprecated since 5.3, use `wp.blockEditor.NavigableToolbar` instead.
22677 */
22678 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
22679 /**
22680 * @deprecated since 5.3, use `wp.blockEditor.ObserveTyping` instead.
22681 */
22682 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
22683 /**
22684 * @deprecated since 5.3, use `wp.blockEditor.SkipToSelectedBlock` instead.
22685 */
22686 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
22687 /**
22688 * @deprecated since 5.3, use `wp.blockEditor.URLInput` instead.
22689 */
22690 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
22691 /**
22692 * @deprecated since 5.3, use `wp.blockEditor.URLInputButton` instead.
22693 */
22694 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
22695 /**
22696 * @deprecated since 5.3, use `wp.blockEditor.URLPopover` instead.
22697 */
22698 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
22699 /**
22700 * @deprecated since 5.3, use `wp.blockEditor.Warning` instead.
22701 */
22702 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
22703 /**
22704 * @deprecated since 5.3, use `wp.blockEditor.WritingFlow` instead.
22705 */
22706 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
22707
22708 /**
22709 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
22710 */
22711 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
22712 /**
22713 * @deprecated since 5.3, use `wp.blockEditor.getColorClassName` instead.
22714 */
22715 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
22716 /**
22717 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByAttributeValues` instead.
22718 */
22719 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
22720 /**
22721 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByColorValue` instead.
22722 */
22723 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
22724 /**
22725 * @deprecated since 5.3, use `wp.blockEditor.getFontSize` instead.
22726 */
22727 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
22728 /**
22729 * @deprecated since 5.3, use `wp.blockEditor.getFontSizeClass` instead.
22730 */
22731 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
22732 /**
22733 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
22734 */
22735 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
22736 /**
22737 * @deprecated since 5.3, use `wp.blockEditor.withColors` instead.
22738 */
22739 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
22740 /**
22741 * @deprecated since 5.3, use `wp.blockEditor.withFontSizes` instead.
22742 */
22743 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
22744
22745 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/index.js
22746 /**
22747 * Internal dependencies
22748 */
22749
22750
22751 // Block Creation Components.
22752
22753
22754 // Post Related Components.
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843 // State Related Components.
22844
22845
22846 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
22847
22848 /**
22849 * Component handles the global keyboard shortcuts for the Text editor.
22850 *
22851 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
22852 * toggling distraction-free mode, undo/redo.
22853 */
22854 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
22855
22856 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/url.js
22857 /**
22858 * WordPress dependencies
22859 */
22860
22861
22862
22863 /**
22864 * Performs some basic cleanup of a string for use as a post slug
22865 *
22866 * This replicates some of what sanitize_title() does in WordPress core, but
22867 * is only designed to approximate what the slug will be.
22868 *
22869 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
22870 * Removes combining diacritical marks. Converts whitespace, periods,
22871 * and forward slashes to hyphens. Removes any remaining non-word characters
22872 * except hyphens and underscores. Converts remaining string to lowercase.
22873 * It does not account for octets, HTML entities, or other encoded characters.
22874 *
22875 * @param {string} string Title or slug to be processed
22876 *
22877 * @return {string} Processed string
22878 */
22879 function cleanForSlug(string) {
22880 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
22881 since: '12.7',
22882 plugin: 'Gutenberg',
22883 alternative: 'wp.url.cleanForSlug'
22884 });
22885 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
22886 }
22887
22888 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/index.js
22889 /**
22890 * Internal dependencies
22891 */
22892
22893
22894
22895
22896
22897 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/content-slot-fill.js
22898 /**
22899 * WordPress dependencies
22900 */
22901
22902
22903 /**
22904 * Internal dependencies
22905 */
22906
22907 const {
22908 createPrivateSlotFill
22909 } = unlock(external_wp_components_namespaceObject.privateApis);
22910 const SLOT_FILL_NAME = 'EditCanvasContainerSlot';
22911 const EditorContentSlotFill = createPrivateSlotFill(SLOT_FILL_NAME);
22912 /* harmony default export */ const content_slot_fill = (EditorContentSlotFill);
22913
22914 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/back-button.js
22915 /**
22916 * WordPress dependencies
22917 */
22918
22919
22920 // Keeping an old name for backward compatibility.
22921
22922 const slotName = '__experimentalMainDashboardButton';
22923 const {
22924 Fill: back_button_Fill,
22925 Slot: back_button_Slot
22926 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
22927 const BackButton = back_button_Fill;
22928 const BackButtonSlot = ({
22929 children
22930 }) => {
22931 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
22932 const hasFills = Boolean(fills && fills.length);
22933 if (!hasFills) {
22934 return children;
22935 }
22936 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button_Slot, {
22937 bubblesVirtually: true,
22938 fillProps: {
22939 length: !fills ? 0 : fills.length
22940 }
22941 });
22942 };
22943 BackButton.Slot = BackButtonSlot;
22944 /* harmony default export */ const back_button = (BackButton);
22945
22946 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/next.js
22947 /**
22948 * WordPress dependencies
22949 */
22950
22951
22952 const next = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22953 xmlns: "http://www.w3.org/2000/svg",
22954 viewBox: "0 0 24 24",
22955 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22956 d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z"
22957 })
22958 });
22959 /* harmony default export */ const library_next = (next);
22960
22961 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/previous.js
22962 /**
22963 * WordPress dependencies
22964 */
22965
22966
22967 const previous = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22968 xmlns: "http://www.w3.org/2000/svg",
22969 viewBox: "0 0 24 24",
22970 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22971 d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z"
22972 })
22973 });
22974 /* harmony default export */ const library_previous = (previous);
22975
22976 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/collapsible-block-toolbar/index.js
22977 /**
22978 * External dependencies
22979 */
22980
22981
22982 /**
22983 * WordPress dependencies
22984 */
22985
22986
22987
22988
22989
22990
22991
22992 /**
22993 * Internal dependencies
22994 */
22995
22996
22997
22998
22999 const {
23000 useHasBlockToolbar
23001 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
23002 function CollapsableBlockToolbar({
23003 isCollapsed,
23004 onToggle
23005 }) {
23006 const {
23007 blockSelectionStart
23008 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23009 return {
23010 blockSelectionStart: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
23011 };
23012 }, []);
23013 const hasBlockToolbar = useHasBlockToolbar();
23014 const hasBlockSelection = !!blockSelectionStart;
23015 (0,external_wp_element_namespaceObject.useEffect)(() => {
23016 // If we have a new block selection, show the block tools
23017 if (blockSelectionStart) {
23018 onToggle(false);
23019 }
23020 }, [blockSelectionStart, onToggle]);
23021 if (!hasBlockToolbar) {
23022 return null;
23023 }
23024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23025 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23026 className: dist_clsx('editor-collapsible-block-toolbar', {
23027 'is-collapsed': isCollapsed || !hasBlockSelection
23028 }),
23029 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
23030 hideDragHandle: true
23031 })
23032 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {
23033 name: "block-toolbar"
23034 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23035 className: "editor-collapsible-block-toolbar__toggle",
23036 icon: isCollapsed ? library_next : library_previous,
23037 onClick: () => {
23038 onToggle(!isCollapsed);
23039 },
23040 label: isCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools'),
23041 size: "compact"
23042 })]
23043 });
23044 }
23045 /* harmony default export */ const collapsible_block_toolbar = (CollapsableBlockToolbar);
23046
23047 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
23048 /**
23049 * WordPress dependencies
23050 */
23051
23052
23053 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23054 xmlns: "http://www.w3.org/2000/svg",
23055 viewBox: "0 0 24 24",
23056 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23057 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
23058 })
23059 });
23060 /* harmony default export */ const library_plus = (plus);
23061
23062 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-tools/index.js
23063 /**
23064 * External dependencies
23065 */
23066
23067
23068 /**
23069 * WordPress dependencies
23070 */
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081 /**
23082 * Internal dependencies
23083 */
23084
23085
23086
23087
23088
23089
23090
23091 function DocumentTools({
23092 className,
23093 disableBlockTools = false
23094 }) {
23095 const {
23096 setIsInserterOpened,
23097 setIsListViewOpened
23098 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23099 const {
23100 isDistractionFree,
23101 isInserterOpened,
23102 isListViewOpen,
23103 listViewShortcut,
23104 inserterSidebarToggleRef,
23105 listViewToggleRef,
23106 hasFixedToolbar,
23107 showIconLabels
23108 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23109 const {
23110 getSettings
23111 } = select(external_wp_blockEditor_namespaceObject.store);
23112 const {
23113 get
23114 } = select(external_wp_preferences_namespaceObject.store);
23115 const {
23116 isListViewOpened,
23117 getEditorMode,
23118 getInserterSidebarToggleRef,
23119 getListViewToggleRef
23120 } = unlock(select(store_store));
23121 const {
23122 getShortcutRepresentation
23123 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
23124 const {
23125 __unstableGetEditorMode
23126 } = select(external_wp_blockEditor_namespaceObject.store);
23127 return {
23128 isInserterOpened: select(store_store).isInserterOpened(),
23129 isListViewOpen: isListViewOpened(),
23130 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
23131 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
23132 listViewToggleRef: getListViewToggleRef(),
23133 hasFixedToolbar: getSettings().hasFixedToolbar,
23134 showIconLabels: get('core', 'showIconLabels'),
23135 isDistractionFree: get('core', 'distractionFree'),
23136 isVisualMode: getEditorMode() === 'visual',
23137 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
23138 };
23139 }, []);
23140 const preventDefault = event => {
23141 // Because the inserter behaves like a dialog,
23142 // if the inserter is opened already then when we click on the toggle button
23143 // then the initial click event will close the inserter and then be propagated
23144 // to the inserter toggle and it will open it again.
23145 // To prevent this we need to stop the propagation of the event.
23146 // This won't be necessary when the inserter no longer behaves like a dialog.
23147
23148 if (isInserterOpened) {
23149 event.preventDefault();
23150 }
23151 };
23152 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
23153 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
23154
23155 /* translators: accessibility text for the editor toolbar */
23156 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
23157 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
23158 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => setIsInserterOpened(!isInserterOpened), [isInserterOpened, setIsInserterOpened]);
23159
23160 /* translators: button label text should, if possible, be under 16 characters. */
23161 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button');
23162 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
23163 return (
23164 /*#__PURE__*/
23165 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
23166 // find the toolbar and inject UI elements into it. This is not officially
23167 // supported, but we're keeping it in the list of class names for backwards
23168 // compatibility.
23169 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
23170 className: dist_clsx('editor-document-tools', 'edit-post-header-toolbar', className),
23171 "aria-label": toolbarAriaLabel,
23172 variant: "unstyled",
23173 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23174 className: "editor-document-tools__left",
23175 children: [!isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23176 ref: inserterSidebarToggleRef,
23177 as: external_wp_components_namespaceObject.Button,
23178 className: "editor-document-tools__inserter-toggle",
23179 variant: "primary",
23180 isPressed: isInserterOpened,
23181 onMouseDown: preventDefault,
23182 onClick: toggleInserter,
23183 disabled: disableBlockTools,
23184 icon: library_plus,
23185 label: showIconLabels ? shortLabel : longLabel,
23186 showTooltip: !showIconLabels,
23187 "aria-expanded": isInserterOpened
23188 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23189 children: [isLargeViewport && !hasFixedToolbar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23190 as: external_wp_blockEditor_namespaceObject.ToolSelector,
23191 showTooltip: !showIconLabels,
23192 variant: showIconLabels ? 'tertiary' : undefined,
23193 disabled: disableBlockTools,
23194 size: "compact"
23195 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23196 as: editor_history_undo,
23197 showTooltip: !showIconLabels,
23198 variant: showIconLabels ? 'tertiary' : undefined,
23199 size: "compact"
23200 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23201 as: editor_history_redo,
23202 showTooltip: !showIconLabels,
23203 variant: showIconLabels ? 'tertiary' : undefined,
23204 size: "compact"
23205 }), !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23206 as: external_wp_components_namespaceObject.Button,
23207 className: "editor-document-tools__document-overview-toggle",
23208 icon: list_view,
23209 disabled: disableBlockTools,
23210 isPressed: isListViewOpen
23211 /* translators: button label text should, if possible, be under 16 characters. */,
23212 label: (0,external_wp_i18n_namespaceObject.__)('Document Overview'),
23213 onClick: toggleListView,
23214 shortcut: listViewShortcut,
23215 showTooltip: !showIconLabels,
23216 variant: showIconLabels ? 'tertiary' : undefined,
23217 "aria-expanded": isListViewOpen,
23218 ref: listViewToggleRef,
23219 size: "compact"
23220 })]
23221 })]
23222 })
23223 })
23224 );
23225 }
23226 /* harmony default export */ const document_tools = (DocumentTools);
23227
23228 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
23229 /**
23230 * WordPress dependencies
23231 */
23232
23233
23234 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23235 xmlns: "http://www.w3.org/2000/svg",
23236 viewBox: "0 0 24 24",
23237 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23238 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
23239 })
23240 });
23241 /* harmony default export */ const more_vertical = (moreVertical);
23242
23243 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/copy-content-menu-item.js
23244 /**
23245 * WordPress dependencies
23246 */
23247
23248
23249
23250
23251
23252
23253
23254
23255 /**
23256 * Internal dependencies
23257 */
23258
23259
23260 function CopyContentMenuItem() {
23261 const {
23262 createNotice
23263 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
23264 const {
23265 getCurrentPostId,
23266 getCurrentPostType
23267 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
23268 const {
23269 getEditedEntityRecord
23270 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
23271 function getText() {
23272 const record = getEditedEntityRecord('postType', getCurrentPostType(), getCurrentPostId());
23273 if (!record) {
23274 return '';
23275 }
23276 if (typeof record.content === 'function') {
23277 return record.content(record);
23278 } else if (record.blocks) {
23279 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
23280 } else if (record.content) {
23281 return record.content;
23282 }
23283 }
23284 function onSuccess() {
23285 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
23286 isDismissible: true,
23287 type: 'snackbar'
23288 });
23289 }
23290 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
23291 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23292 ref: ref,
23293 children: (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')
23294 });
23295 }
23296
23297 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/mode-switcher/index.js
23298 /**
23299 * WordPress dependencies
23300 */
23301
23302
23303
23304
23305
23306 /**
23307 * Internal dependencies
23308 */
23309
23310
23311 /**
23312 * Set of available mode options.
23313 *
23314 * @type {Array}
23315 */
23316
23317 const MODES = [{
23318 value: 'visual',
23319 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
23320 }, {
23321 value: 'text',
23322 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
23323 }];
23324 function ModeSwitcher() {
23325 const {
23326 shortcut,
23327 isRichEditingEnabled,
23328 isCodeEditingEnabled,
23329 mode
23330 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
23331 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-mode'),
23332 isRichEditingEnabled: select(store_store).getEditorSettings().richEditingEnabled,
23333 isCodeEditingEnabled: select(store_store).getEditorSettings().codeEditingEnabled,
23334 mode: select(store_store).getEditorMode()
23335 }), []);
23336 const {
23337 switchEditorMode
23338 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23339 let selectedMode = mode;
23340 if (!isRichEditingEnabled && mode === 'visual') {
23341 selectedMode = 'text';
23342 }
23343 if (!isCodeEditingEnabled && mode === 'text') {
23344 selectedMode = 'visual';
23345 }
23346 const choices = MODES.map(choice => {
23347 if (!isCodeEditingEnabled && choice.value === 'text') {
23348 choice = {
23349 ...choice,
23350 disabled: true
23351 };
23352 }
23353 if (!isRichEditingEnabled && choice.value === 'visual') {
23354 choice = {
23355 ...choice,
23356 disabled: true,
23357 info: (0,external_wp_i18n_namespaceObject.__)('You can enable the visual editor in your profile settings.')
23358 };
23359 }
23360 if (choice.value !== selectedMode && !choice.disabled) {
23361 return {
23362 ...choice,
23363 shortcut
23364 };
23365 }
23366 return choice;
23367 });
23368 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23369 label: (0,external_wp_i18n_namespaceObject.__)('Editor'),
23370 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
23371 choices: choices,
23372 value: selectedMode,
23373 onSelect: switchEditorMode
23374 })
23375 });
23376 }
23377 /* harmony default export */ const mode_switcher = (ModeSwitcher);
23378
23379 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/tools-more-menu-group.js
23380 /**
23381 * WordPress dependencies
23382 */
23383
23384
23385 const {
23386 Fill: ToolsMoreMenuGroup,
23387 Slot: tools_more_menu_group_Slot
23388 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
23389 ToolsMoreMenuGroup.Slot = ({
23390 fillProps
23391 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group_Slot, {
23392 fillProps: fillProps
23393 });
23394 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
23395
23396 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/view-more-menu-group.js
23397 /**
23398 * WordPress dependencies
23399 */
23400
23401
23402
23403 const {
23404 Fill: ViewMoreMenuGroup,
23405 Slot: view_more_menu_group_Slot
23406 } = (0,external_wp_components_namespaceObject.createSlotFill)(external_wp_element_namespaceObject.Platform.OS === 'web' ? Symbol('ViewMoreMenuGroup') : 'ViewMoreMenuGroup');
23407 ViewMoreMenuGroup.Slot = ({
23408 fillProps
23409 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group_Slot, {
23410 fillProps: fillProps
23411 });
23412 /* harmony default export */ const view_more_menu_group = (ViewMoreMenuGroup);
23413
23414 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/index.js
23415 /**
23416 * WordPress dependencies
23417 */
23418
23419
23420
23421
23422
23423
23424
23425
23426 /**
23427 * Internal dependencies
23428 */
23429
23430
23431
23432
23433
23434
23435
23436
23437 function MoreMenu() {
23438 const {
23439 openModal
23440 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23441 const {
23442 set: setPreference
23443 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
23444 const {
23445 toggleDistractionFree
23446 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23447 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'), []);
23448 const turnOffDistractionFree = () => {
23449 setPreference('core', 'distractionFree', false);
23450 };
23451 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23452 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
23453 icon: more_vertical,
23454 label: (0,external_wp_i18n_namespaceObject.__)('Options'),
23455 popoverProps: {
23456 placement: 'bottom-end',
23457 className: 'more-menu-dropdown__content'
23458 },
23459 toggleProps: {
23460 showTooltip: !showIconLabels,
23461 ...(showIconLabels && {
23462 variant: 'tertiary'
23463 }),
23464 tooltipPosition: 'bottom',
23465 size: 'compact'
23466 },
23467 children: ({
23468 onClose
23469 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23470 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23471 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'),
23472 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23473 scope: "core",
23474 name: "fixedToolbar",
23475 onToggle: turnOffDistractionFree,
23476 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
23477 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
23478 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
23479 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
23480 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23481 scope: "core",
23482 name: "distractionFree",
23483 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'),
23484 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'),
23485 handleToggling: false,
23486 onToggle: toggleDistractionFree,
23487 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'),
23488 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'),
23489 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\')
23490 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23491 scope: "core",
23492 name: "focusMode",
23493 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
23494 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
23495 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
23496 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
23497 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group.Slot, {
23498 fillProps: {
23499 onClose
23500 }
23501 })]
23502 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(mode_switcher, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
23503 name: "core/plugin-more-menu",
23504 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
23505 as: external_wp_components_namespaceObject.MenuGroup,
23506 fillProps: {
23507 onClick: onClose
23508 }
23509 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23510 label: (0,external_wp_i18n_namespaceObject.__)('Tools'),
23511 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23512 onClick: () => openModal('editor/keyboard-shortcut-help'),
23513 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'),
23514 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')
23515 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyContentMenuItem, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
23516 icon: library_external,
23517 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'),
23518 target: "_blank",
23519 rel: "noopener noreferrer",
23520 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23521 as: "span",
23522 children: /* translators: accessibility text */
23523 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
23524 })]
23525 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group.Slot, {
23526 fillProps: {
23527 onClose
23528 }
23529 })]
23530 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23531 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23532 onClick: () => openModal('editor/preferences'),
23533 children: (0,external_wp_i18n_namespaceObject.__)('Preferences')
23534 })
23535 })]
23536 })
23537 })
23538 });
23539 }
23540
23541 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js
23542 /**
23543 * WordPress dependencies
23544 */
23545
23546
23547
23548 /**
23549 * Internal dependencies
23550 */
23551
23552
23553
23554 function PostPublishButtonOrToggle({
23555 forceIsDirty,
23556 hasPublishAction,
23557 isBeingScheduled,
23558 isPending,
23559 isPublished,
23560 isPublishSidebarEnabled,
23561 isPublishSidebarOpened,
23562 isScheduled,
23563 togglePublishSidebar,
23564 setEntitiesSavedStatesCallback,
23565 postStatusHasChanged,
23566 postStatus
23567 }) {
23568 const IS_TOGGLE = 'toggle';
23569 const IS_BUTTON = 'button';
23570 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
23571 let component;
23572
23573 /**
23574 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
23575 *
23576 * 1) We want to show a BUTTON when the post status is at the _final stage_
23577 * for a particular role (see https://wordpress.org/documentation/article/post-status/):
23578 *
23579 * - is published
23580 * - post status has changed explicitely to something different than 'future' or 'publish'
23581 * - is scheduled to be published
23582 * - is pending and can't be published (but only for viewports >= medium).
23583 * Originally, we considered showing a button for pending posts that couldn't be published
23584 * (for example, for an author with the contributor role). Some languages can have
23585 * long translations for "Submit for review", so given the lack of UI real estate available
23586 * we decided to take into account the viewport in that case.
23587 * See: https://github.com/WordPress/gutenberg/issues/10475
23588 *
23589 * 2) Then, in small viewports, we'll show a TOGGLE.
23590 *
23591 * 3) Finally, we'll use the publish sidebar status to decide:
23592 *
23593 * - if it is enabled, we show a TOGGLE
23594 * - if it is disabled, we show a BUTTON
23595 */
23596 if (isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
23597 component = IS_BUTTON;
23598 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled) {
23599 component = IS_TOGGLE;
23600 } else {
23601 component = IS_BUTTON;
23602 }
23603 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
23604 forceIsDirty: forceIsDirty,
23605 isOpen: isPublishSidebarOpened,
23606 isToggle: component === IS_TOGGLE,
23607 onToggle: togglePublishSidebar,
23608 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
23609 });
23610 }
23611 /* harmony default export */ const post_publish_button_or_toggle = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
23612 var _select$getCurrentPos;
23613 return {
23614 hasPublishAction: (_select$getCurrentPos = select(store_store).getCurrentPost()?._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false,
23615 isBeingScheduled: select(store_store).isEditedPostBeingScheduled(),
23616 isPending: select(store_store).isCurrentPostPending(),
23617 isPublished: select(store_store).isCurrentPostPublished(),
23618 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled(),
23619 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
23620 isScheduled: select(store_store).isCurrentPostScheduled(),
23621 postStatus: select(store_store).getEditedPostAttribute('status'),
23622 postStatusHasChanged: select(store_store).getPostEdits()?.status
23623 };
23624 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
23625 const {
23626 togglePublishSidebar
23627 } = dispatch(store_store);
23628 return {
23629 togglePublishSidebar
23630 };
23631 }))(PostPublishButtonOrToggle));
23632
23633 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-view-link/index.js
23634 /**
23635 * WordPress dependencies
23636 */
23637
23638
23639
23640
23641
23642
23643
23644 /**
23645 * Internal dependencies
23646 */
23647
23648
23649 function PostViewLink() {
23650 const {
23651 hasLoaded,
23652 permalink,
23653 isPublished,
23654 label,
23655 showIconLabels
23656 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23657 // Grab post type to retrieve the view_item label.
23658 const postTypeSlug = select(store_store).getCurrentPostType();
23659 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
23660 const {
23661 get
23662 } = select(external_wp_preferences_namespaceObject.store);
23663 return {
23664 permalink: select(store_store).getPermalink(),
23665 isPublished: select(store_store).isCurrentPostPublished(),
23666 label: postType?.labels.view_item,
23667 hasLoaded: !!postType,
23668 showIconLabels: get('core', 'showIconLabels')
23669 };
23670 }, []);
23671
23672 // Only render the view button if the post is published and has a permalink.
23673 if (!isPublished || !permalink || !hasLoaded) {
23674 return null;
23675 }
23676 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23677 icon: library_external,
23678 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'),
23679 href: permalink,
23680 target: "_blank",
23681 showTooltip: !showIconLabels,
23682 size: "compact"
23683 });
23684 }
23685
23686 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/mobile.js
23687 /**
23688 * WordPress dependencies
23689 */
23690
23691
23692 const mobile = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23693 xmlns: "http://www.w3.org/2000/svg",
23694 viewBox: "0 0 24 24",
23695 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23696 d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"
23697 })
23698 });
23699 /* harmony default export */ const library_mobile = (mobile);
23700
23701 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tablet.js
23702 /**
23703 * WordPress dependencies
23704 */
23705
23706
23707 const tablet = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23708 xmlns: "http://www.w3.org/2000/svg",
23709 viewBox: "0 0 24 24",
23710 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23711 d: "M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"
23712 })
23713 });
23714 /* harmony default export */ const library_tablet = (tablet);
23715
23716 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/desktop.js
23717 /**
23718 * WordPress dependencies
23719 */
23720
23721
23722 const desktop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23723 xmlns: "http://www.w3.org/2000/svg",
23724 viewBox: "0 0 24 24",
23725 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23726 d: "M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"
23727 })
23728 });
23729 /* harmony default export */ const library_desktop = (desktop);
23730
23731 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preview-dropdown/index.js
23732 /**
23733 * WordPress dependencies
23734 */
23735
23736
23737
23738
23739
23740
23741
23742
23743 /**
23744 * Internal dependencies
23745 */
23746
23747
23748
23749
23750
23751 function PreviewDropdown({
23752 forceIsAutosaveable,
23753 disabled
23754 }) {
23755 const {
23756 deviceType,
23757 homeUrl,
23758 isTemplate,
23759 isViewable,
23760 showIconLabels
23761 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23762 var _getPostType$viewable;
23763 const {
23764 getDeviceType,
23765 getCurrentPostType
23766 } = select(store_store);
23767 const {
23768 getUnstableBase,
23769 getPostType
23770 } = select(external_wp_coreData_namespaceObject.store);
23771 const {
23772 get
23773 } = select(external_wp_preferences_namespaceObject.store);
23774 const _currentPostType = getCurrentPostType();
23775 return {
23776 deviceType: getDeviceType(),
23777 homeUrl: getUnstableBase()?.home,
23778 isTemplate: _currentPostType === 'wp_template',
23779 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
23780 showIconLabels: get('core', 'showIconLabels')
23781 };
23782 }, []);
23783 const {
23784 setDeviceType
23785 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23786 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
23787 if (isMobile) {
23788 return null;
23789 }
23790 const popoverProps = {
23791 placement: 'bottom-end'
23792 };
23793 const toggleProps = {
23794 className: 'editor-preview-dropdown__toggle',
23795 size: 'compact',
23796 showTooltip: !showIconLabels,
23797 disabled,
23798 __experimentalIsFocusable: disabled
23799 };
23800 const menuProps = {
23801 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
23802 };
23803 const deviceIcons = {
23804 mobile: library_mobile,
23805 tablet: library_tablet,
23806 desktop: library_desktop
23807 };
23808 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
23809 className: "editor-preview-dropdown",
23810 popoverProps: popoverProps,
23811 toggleProps: toggleProps,
23812 menuProps: menuProps,
23813 icon: deviceIcons[deviceType.toLowerCase()],
23814 label: (0,external_wp_i18n_namespaceObject.__)('View'),
23815 disableOpenOnArrowDown: disabled,
23816 children: ({
23817 onClose
23818 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23819 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23820 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23821 onClick: () => setDeviceType('Desktop'),
23822 icon: deviceType === 'Desktop' && library_check,
23823 children: (0,external_wp_i18n_namespaceObject.__)('Desktop')
23824 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23825 onClick: () => setDeviceType('Tablet'),
23826 icon: deviceType === 'Tablet' && library_check,
23827 children: (0,external_wp_i18n_namespaceObject.__)('Tablet')
23828 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23829 onClick: () => setDeviceType('Mobile'),
23830 icon: deviceType === 'Mobile' && library_check,
23831 children: (0,external_wp_i18n_namespaceObject.__)('Mobile')
23832 })]
23833 }), isTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23834 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
23835 href: homeUrl,
23836 target: "_blank",
23837 icon: library_external,
23838 onClick: onClose,
23839 children: [(0,external_wp_i18n_namespaceObject.__)('View site'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23840 as: "span",
23841 children: /* translators: accessibility text */
23842 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
23843 })]
23844 })
23845 }), isViewable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23846 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
23847 className: "editor-preview-dropdown__button-external",
23848 role: "menuitem",
23849 forceIsAutosaveable: forceIsAutosaveable,
23850 textContent: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23851 children: [(0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
23852 icon: library_external
23853 })]
23854 }),
23855 onPreview: onClose
23856 })
23857 })]
23858 })
23859 });
23860 }
23861
23862 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/index.js
23863 /**
23864 * External dependencies
23865 */
23866
23867
23868 /**
23869 * WordPress dependencies
23870 */
23871
23872
23873
23874
23875
23876
23877
23878
23879 /**
23880 * Internal dependencies
23881 */
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895 const toolbarVariations = {
23896 distractionFreeDisabled: {
23897 y: '-50px'
23898 },
23899 distractionFreeHover: {
23900 y: 0
23901 },
23902 distractionFreeHidden: {
23903 y: '-50px'
23904 },
23905 visible: {
23906 y: 0
23907 },
23908 hidden: {
23909 y: 0
23910 }
23911 };
23912 const backButtonVariations = {
23913 distractionFreeDisabled: {
23914 x: '-100%'
23915 },
23916 distractionFreeHover: {
23917 x: 0
23918 },
23919 distractionFreeHidden: {
23920 x: '-100%'
23921 },
23922 visible: {
23923 x: 0
23924 },
23925 hidden: {
23926 x: 0
23927 }
23928 };
23929 function Header({
23930 customSaveButton,
23931 forceIsDirty,
23932 forceDisableBlockTools,
23933 setEntitiesSavedStatesCallback,
23934 title
23935 }) {
23936 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
23937 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
23938 const {
23939 isTextEditor,
23940 isPublishSidebarOpened,
23941 showIconLabels,
23942 hasFixedToolbar,
23943 isNestedEntity,
23944 isZoomedOutView
23945 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23946 const {
23947 get: getPreference
23948 } = select(external_wp_preferences_namespaceObject.store);
23949 const {
23950 getEditorMode,
23951 getEditorSettings,
23952 isPublishSidebarOpened: _isPublishSidebarOpened
23953 } = select(store_store);
23954 const {
23955 __unstableGetEditorMode
23956 } = select(external_wp_blockEditor_namespaceObject.store);
23957 return {
23958 isTextEditor: getEditorMode() === 'text',
23959 isPublishSidebarOpened: _isPublishSidebarOpened(),
23960 showIconLabels: getPreference('core', 'showIconLabels'),
23961 hasFixedToolbar: getPreference('core', 'fixedToolbar'),
23962 isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord,
23963 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
23964 };
23965 }, []);
23966 const hasTopToolbar = isLargeViewport && hasFixedToolbar;
23967 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true);
23968
23969 // The edit-post-header classname is only kept for backward compatibilty
23970 // as some plugins might be relying on its presence.
23971 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23972 className: "editor-header edit-post-header",
23973 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
23974 variants: backButtonVariations,
23975 transition: {
23976 type: 'tween'
23977 },
23978 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button.Slot, {})
23979 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
23980 variants: toolbarVariations,
23981 className: "editor-header__toolbar",
23982 transition: {
23983 type: 'tween'
23984 },
23985 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_tools, {
23986 disableBlockTools: forceDisableBlockTools || isTextEditor
23987 }), hasTopToolbar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(collapsible_block_toolbar, {
23988 isCollapsed: isBlockToolsCollapsed,
23989 onToggle: setIsBlockToolsCollapsed
23990 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23991 className: dist_clsx('editor-header__center', {
23992 'is-collapsed': !isBlockToolsCollapsed && hasTopToolbar
23993 }),
23994 children: !title ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentBar, {}) : title
23995 })]
23996 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
23997 variants: toolbarVariations,
23998 transition: {
23999 type: 'tween'
24000 },
24001 className: "editor-header__settings",
24002 children: [!customSaveButton && !isPublishSidebarOpened &&
24003 /*#__PURE__*/
24004 // This button isn't completely hidden by the publish sidebar.
24005 // We can't hide the whole toolbar when the publish sidebar is open because
24006 // we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
24007 // We track that DOM node to return focus to the PostPublishButtonOrToggle
24008 // when the publish sidebar has been closed.
24009 (0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSavedState, {
24010 forceIsDirty: forceIsDirty
24011 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewDropdown, {
24012 forceIsAutosaveable: forceIsDirty,
24013 disabled: isNestedEntity || isZoomedOutView
24014 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
24015 className: "editor-header__post-preview-button",
24016 forceIsAutosaveable: forceIsDirty
24017 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostViewLink, {}), !customSaveButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button_or_toggle, {
24018 forceIsDirty: forceIsDirty,
24019 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
24020 }), customSaveButton, (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items.Slot, {
24021 scope: "core"
24022 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})]
24023 })]
24024 });
24025 }
24026 /* harmony default export */ const components_header = (Header);
24027
24028 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/inserter-sidebar/index.js
24029 /**
24030 * WordPress dependencies
24031 */
24032
24033
24034
24035
24036
24037
24038
24039
24040 /**
24041 * Internal dependencies
24042 */
24043
24044
24045
24046 const {
24047 PrivateInserterLibrary
24048 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24049 function InserterSidebar() {
24050 const {
24051 blockSectionRootClientId,
24052 inserterSidebarToggleRef,
24053 insertionPoint,
24054 showMostUsedBlocks,
24055 sidebarIsOpened
24056 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24057 const {
24058 getInserterSidebarToggleRef,
24059 getInsertionPoint,
24060 isPublishSidebarOpened
24061 } = unlock(select(store_store));
24062 const {
24063 getBlockRootClientId,
24064 __unstableGetEditorMode,
24065 getSettings
24066 } = select(external_wp_blockEditor_namespaceObject.store);
24067 const {
24068 get
24069 } = select(external_wp_preferences_namespaceObject.store);
24070 const {
24071 getActiveComplementaryArea
24072 } = select(store);
24073 const getBlockSectionRootClientId = () => {
24074 if (__unstableGetEditorMode() === 'zoom-out') {
24075 const {
24076 sectionRootClientId
24077 } = unlock(getSettings());
24078 if (sectionRootClientId) {
24079 return sectionRootClientId;
24080 }
24081 }
24082 return getBlockRootClientId();
24083 };
24084 return {
24085 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
24086 insertionPoint: getInsertionPoint(),
24087 showMostUsedBlocks: get('core', 'mostUsedBlocks'),
24088 blockSectionRootClientId: getBlockSectionRootClientId(),
24089 sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
24090 };
24091 }, []);
24092 const {
24093 setIsInserterOpened
24094 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24095 const {
24096 disableComplementaryArea
24097 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24098 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
24099 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
24100 onClose: () => setIsInserterOpened(false),
24101 focusOnMount: true
24102 });
24103 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
24104
24105 // When closing the inserter, focus should return to the toggle button.
24106 const closeInserterSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
24107 setIsInserterOpened(false);
24108 inserterSidebarToggleRef.current?.focus();
24109 }, [inserterSidebarToggleRef, setIsInserterOpened]);
24110 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
24111 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
24112 event.preventDefault();
24113 closeInserterSidebar();
24114 }
24115 }, [closeInserterSidebar]);
24116 const inserterContents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24117 className: "editor-inserter-sidebar__content",
24118 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
24119 showMostUsedBlocks: showMostUsedBlocks,
24120 showInserterHelpPanel: true,
24121 shouldFocusBlock: isMobileViewport,
24122 rootClientId: blockSectionRootClientId !== null && blockSectionRootClientId !== void 0 ? blockSectionRootClientId : insertionPoint.rootClientId,
24123 __experimentalInsertionIndex: insertionPoint.insertionIndex,
24124 __experimentalInitialTab: insertionPoint.tab,
24125 __experimentalInitialCategory: insertionPoint.category,
24126 __experimentalFilterValue: insertionPoint.filterValue,
24127 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
24128 ref: libraryRef,
24129 onClose: closeInserterSidebar
24130 })
24131 });
24132 if (window.__experimentalEnableZoomedOutPatternsTab) {
24133 return (
24134 /*#__PURE__*/
24135 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
24136 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24137 onKeyDown: closeOnEscape,
24138 className: "editor-inserter-sidebar",
24139 children: inserterContents
24140 })
24141 );
24142 }
24143 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24144 ref: inserterDialogRef,
24145 ...inserterDialogProps,
24146 className: "editor-inserter-sidebar",
24147 children: inserterContents
24148 });
24149 }
24150
24151 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/list-view-outline.js
24152 /**
24153 * WordPress dependencies
24154 */
24155
24156
24157
24158 /**
24159 * Internal dependencies
24160 */
24161
24162
24163
24164
24165
24166
24167
24168 function ListViewOutline() {
24169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24170 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24171 className: "editor-list-view-sidebar__outline",
24172 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24173 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24174 children: (0,external_wp_i18n_namespaceObject.__)('Characters:')
24175 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24176 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
24177 })]
24178 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24179 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24180 children: (0,external_wp_i18n_namespaceObject.__)('Words:')
24181 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
24182 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24183 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24184 children: (0,external_wp_i18n_namespaceObject.__)('Time to read:')
24185 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
24186 })]
24187 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {})]
24188 });
24189 }
24190
24191 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/index.js
24192 /**
24193 * WordPress dependencies
24194 */
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206 /**
24207 * Internal dependencies
24208 */
24209
24210
24211
24212
24213
24214 const {
24215 Tabs
24216 } = unlock(external_wp_components_namespaceObject.privateApis);
24217 function ListViewSidebar() {
24218 const {
24219 setIsListViewOpened
24220 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24221 const {
24222 getListViewToggleRef
24223 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store));
24224
24225 // This hook handles focus when the sidebar first renders.
24226 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
24227
24228 // When closing the list view, focus should return to the toggle button.
24229 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => {
24230 setIsListViewOpened(false);
24231 getListViewToggleRef().current?.focus();
24232 }, [getListViewToggleRef, setIsListViewOpened]);
24233 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
24234 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
24235 event.preventDefault();
24236 closeListView();
24237 }
24238 }, [closeListView]);
24239
24240 // Use internal state instead of a ref to make sure that the component
24241 // re-renders when the dropZoneElement updates.
24242 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null);
24243 // Tracks our current tab.
24244 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view');
24245
24246 // This ref refers to the sidebar as a whole.
24247 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)();
24248 // This ref refers to the tab panel.
24249 const tabsRef = (0,external_wp_element_namespaceObject.useRef)();
24250 // This ref refers to the list view application area.
24251 const listViewRef = (0,external_wp_element_namespaceObject.useRef)();
24252
24253 // Must merge the refs together so focus can be handled properly in the next function.
24254 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]);
24255
24256 /*
24257 * Callback function to handle list view or outline focus.
24258 *
24259 * @param {string} currentTab The current tab. Either list view or outline.
24260 *
24261 * @return void
24262 */
24263 function handleSidebarFocus(currentTab) {
24264 // Tab panel focus.
24265 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0];
24266 // List view tab is selected.
24267 if (currentTab === 'list-view') {
24268 // Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
24269 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0];
24270 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus;
24271 listViewFocusArea.focus();
24272 // Outline tab is selected.
24273 } else {
24274 tabPanelFocus.focus();
24275 }
24276 }
24277 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => {
24278 // If the sidebar has focus, it is safe to close.
24279 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
24280 closeListView();
24281 } else {
24282 // If the list view or outline does not have focus, focus should be moved to it.
24283 handleSidebarFocus(tab);
24284 }
24285 }, [closeListView, tab]);
24286
24287 // This only fires when the sidebar is open because of the conditional rendering.
24288 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
24289 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut);
24290 return (
24291 /*#__PURE__*/
24292 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
24293 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24294 className: "editor-list-view-sidebar",
24295 onKeyDown: closeOnEscape,
24296 ref: sidebarRef,
24297 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, {
24298 onSelect: tabName => setTab(tabName),
24299 selectOnMove: false
24300 // The initial tab value is set explicitly to avoid an initial
24301 // render where no tab is selected. This ensures that the
24302 // tabpanel height is correct so the relevant scroll container
24303 // can be rendered internally.
24304 ,
24305 defaultTabId: "list-view",
24306 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24307 className: "editor-list-view-sidebar__header",
24308 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24309 className: "editor-list-view-sidebar__close-button",
24310 icon: close_small,
24311 label: (0,external_wp_i18n_namespaceObject.__)('Close'),
24312 onClick: closeListView,
24313 size: "small"
24314 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs.TabList, {
24315 className: "editor-list-view-sidebar__tabs-tablist",
24316 ref: tabsRef,
24317 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
24318 className: "editor-list-view-sidebar__tabs-tab",
24319 tabId: "list-view",
24320 children: (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview')
24321 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
24322 className: "editor-list-view-sidebar__tabs-tab",
24323 tabId: "outline",
24324 children: (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview')
24325 })]
24326 })]
24327 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
24328 ref: listViewContainerRef,
24329 className: "editor-list-view-sidebar__tabs-tabpanel",
24330 tabId: "list-view",
24331 focusable: false,
24332 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24333 className: "editor-list-view-sidebar__list-view-container",
24334 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24335 className: "editor-list-view-sidebar__list-view-panel-content",
24336 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
24337 dropZoneElement: dropZoneElement
24338 })
24339 })
24340 })
24341 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
24342 className: "editor-list-view-sidebar__tabs-tabpanel",
24343 tabId: "outline",
24344 focusable: false,
24345 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24346 className: "editor-list-view-sidebar__list-view-container",
24347 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewOutline, {})
24348 })
24349 })]
24350 })
24351 })
24352 );
24353 }
24354
24355 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/save-publish-panels/index.js
24356 /**
24357 * WordPress dependencies
24358 */
24359
24360
24361
24362
24363
24364 /**
24365 * Internal dependencies
24366 */
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376 const {
24377 Fill: save_publish_panels_Fill,
24378 Slot: save_publish_panels_Slot
24379 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
24380 const ActionsPanelFill = (/* unused pure expression or super */ null && (save_publish_panels_Fill));
24381 function SavePublishPanels({
24382 setEntitiesSavedStatesCallback,
24383 closeEntitiesSavedStates,
24384 isEntitiesSavedStatesOpen,
24385 forceIsDirtyPublishPanel
24386 }) {
24387 const {
24388 closePublishSidebar,
24389 togglePublishSidebar
24390 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24391 const {
24392 publishSidebarOpened,
24393 hasNonPostEntityChanges,
24394 hasPostMetaChanges
24395 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
24396 publishSidebarOpened: select(store_store).isPublishSidebarOpened(),
24397 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
24398 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges()
24399 }), []);
24400 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []);
24401
24402 // It is ok for these components to be unmounted when not in visual use.
24403 // We don't want more than one present at a time, decide which to render.
24404 let unmountableContent;
24405 if (publishSidebarOpened) {
24406 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_panel, {
24407 onClose: closePublishSidebar,
24408 forceIsDirty: forceIsDirtyPublishPanel,
24409 PrePublishExtension: plugin_pre_publish_panel.Slot,
24410 PostPublishExtension: plugin_post_publish_panel.Slot
24411 });
24412 } else if (hasNonPostEntityChanges || hasPostMetaChanges) {
24413 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24414 className: "editor-layout__toggle-entities-saved-states-panel",
24415 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24416 variant: "secondary",
24417 className: "editor-layout__toggle-entities-saved-states-panel-button",
24418 onClick: openEntitiesSavedStates,
24419 "aria-expanded": false,
24420 children: (0,external_wp_i18n_namespaceObject.__)('Open save panel')
24421 })
24422 });
24423 } else {
24424 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24425 className: "editor-layout__toggle-publish-panel",
24426 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24427 variant: "secondary",
24428 className: "editor-layout__toggle-publish-panel-button",
24429 onClick: togglePublishSidebar,
24430 "aria-expanded": false,
24431 children: (0,external_wp_i18n_namespaceObject.__)('Open publish panel')
24432 })
24433 });
24434 }
24435
24436 // Since EntitiesSavedStates controls its own panel, we can keep it
24437 // always mounted to retain its own component state (such as checkboxes).
24438 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24439 children: [isEntitiesSavedStatesOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStates, {
24440 close: closeEntitiesSavedStates
24441 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(save_publish_panels_Slot, {
24442 bubblesVirtually: true
24443 }), !isEntitiesSavedStatesOpen && unmountableContent]
24444 });
24445 }
24446
24447 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/text-editor/index.js
24448 /**
24449 * WordPress dependencies
24450 */
24451
24452
24453
24454
24455
24456
24457 /**
24458 * Internal dependencies
24459 */
24460
24461
24462
24463
24464
24465 function TextEditor({
24466 autoFocus = false
24467 }) {
24468 const {
24469 switchEditorMode
24470 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24471 const {
24472 shortcut,
24473 isRichEditingEnabled
24474 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24475 const {
24476 getEditorSettings
24477 } = select(store_store);
24478 const {
24479 getShortcutRepresentation
24480 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
24481 return {
24482 shortcut: getShortcutRepresentation('core/editor/toggle-mode'),
24483 isRichEditingEnabled: getEditorSettings().richEditingEnabled
24484 };
24485 }, []);
24486 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
24487 (0,external_wp_element_namespaceObject.useEffect)(() => {
24488 if (autoFocus) {
24489 return;
24490 }
24491 titleRef?.current?.focus();
24492 }, [autoFocus]);
24493 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24494 className: "editor-text-editor",
24495 children: [isRichEditingEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24496 className: "editor-text-editor__toolbar",
24497 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
24498 children: (0,external_wp_i18n_namespaceObject.__)('Editing code')
24499 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24500 variant: "tertiary",
24501 onClick: () => switchEditorMode('visual'),
24502 shortcut: shortcut,
24503 children: (0,external_wp_i18n_namespaceObject.__)('Exit code editor')
24504 })]
24505 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24506 className: "editor-text-editor__body",
24507 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title_raw, {
24508 ref: titleRef
24509 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTextEditor, {})]
24510 })]
24511 });
24512 }
24513
24514 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js
24515 /**
24516 * WordPress dependencies
24517 */
24518
24519
24520
24521
24522
24523
24524 /**
24525 * Internal dependencies
24526 */
24527
24528
24529 /**
24530 * Component that:
24531 *
24532 * - Displays a 'Edit your template to edit this block' notification when the
24533 * user is focusing on editing page content and clicks on a disabled template
24534 * block.
24535 * - Displays a 'Edit your template to edit this block' dialog when the user
24536 * is focusing on editing page conetnt and double clicks on a disabled
24537 * template block.
24538 *
24539 * @param {Object} props
24540 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
24541 * editor iframe canvas.
24542 */
24543
24544 function EditTemplateBlocksNotification({
24545 contentRef
24546 }) {
24547 const {
24548 onNavigateToEntityRecord,
24549 templateId
24550 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24551 const {
24552 getEditorSettings,
24553 getCurrentTemplateId
24554 } = select(store_store);
24555 return {
24556 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
24557 templateId: getCurrentTemplateId()
24558 };
24559 }, []);
24560 const canEditTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
24561 var _select$canUser;
24562 return (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
24563 });
24564 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
24565 (0,external_wp_element_namespaceObject.useEffect)(() => {
24566 const handleDblClick = event => {
24567 if (!canEditTemplate) {
24568 return;
24569 }
24570 if (!event.target.classList.contains('is-root-container')) {
24571 return;
24572 }
24573 setIsDialogOpen(true);
24574 };
24575 const canvas = contentRef.current;
24576 canvas?.addEventListener('dblclick', handleDblClick);
24577 return () => {
24578 canvas?.removeEventListener('dblclick', handleDblClick);
24579 };
24580 }, [contentRef, canEditTemplate]);
24581 if (!canEditTemplate) {
24582 return null;
24583 }
24584 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
24585 isOpen: isDialogOpen,
24586 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'),
24587 onConfirm: () => {
24588 setIsDialogOpen(false);
24589 onNavigateToEntityRecord({
24590 postId: templateId,
24591 postType: 'wp_template'
24592 });
24593 },
24594 onCancel: () => setIsDialogOpen(false),
24595 size: "medium",
24596 children: (0,external_wp_i18n_namespaceObject.__)('You’ve tried to select a block that is part of a template, which may be used on other posts and pages. Would you like to edit the template?')
24597 });
24598 }
24599
24600 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/resize-handle.js
24601 /**
24602 * WordPress dependencies
24603 */
24604
24605
24606
24607
24608
24609
24610 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
24611
24612 function ResizeHandle({
24613 direction,
24614 resizeWidthBy
24615 }) {
24616 function handleKeyDown(event) {
24617 const {
24618 keyCode
24619 } = event;
24620 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
24621 resizeWidthBy(DELTA_DISTANCE);
24622 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
24623 resizeWidthBy(-DELTA_DISTANCE);
24624 }
24625 }
24626 const resizeHandleVariants = {
24627 active: {
24628 opacity: 1,
24629 scaleY: 1.3
24630 }
24631 };
24632 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
24633 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24634 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
24635 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
24636 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.button, {
24637 className: `editor-resizable-editor__resize-handle is-${direction}`,
24638 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
24639 "aria-describedby": resizableHandleHelpId,
24640 onKeyDown: handleKeyDown,
24641 variants: resizeHandleVariants,
24642 whileFocus: "active",
24643 whileHover: "active",
24644 whileTap: "active",
24645 role: "separator",
24646 "aria-orientation": "vertical"
24647 }, "handle")
24648 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
24649 id: resizableHandleHelpId,
24650 children: (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')
24651 })]
24652 });
24653 }
24654
24655 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/index.js
24656 /**
24657 * External dependencies
24658 */
24659
24660
24661 /**
24662 * WordPress dependencies
24663 */
24664
24665
24666
24667 /**
24668 * Internal dependencies
24669 */
24670
24671
24672 // Removes the inline styles in the drag handles.
24673
24674 const HANDLE_STYLES_OVERRIDE = {
24675 position: undefined,
24676 userSelect: undefined,
24677 cursor: undefined,
24678 width: undefined,
24679 height: undefined,
24680 top: undefined,
24681 right: undefined,
24682 bottom: undefined,
24683 left: undefined
24684 };
24685 function ResizableEditor({
24686 className,
24687 enableResizing,
24688 height,
24689 children
24690 }) {
24691 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
24692 const resizableRef = (0,external_wp_element_namespaceObject.useRef)();
24693 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
24694 if (resizableRef.current) {
24695 setWidth(resizableRef.current.offsetWidth + deltaPixels);
24696 }
24697 }, []);
24698 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ResizableBox, {
24699 className: dist_clsx('editor-resizable-editor', className, {
24700 'is-resizable': enableResizing
24701 }),
24702 ref: api => {
24703 resizableRef.current = api?.resizable;
24704 },
24705 size: {
24706 width: enableResizing ? width : '100%',
24707 height: enableResizing && height ? height : '100%'
24708 },
24709 onResizeStop: (event, direction, element) => {
24710 setWidth(element.style.width);
24711 },
24712 minWidth: 300,
24713 maxWidth: "100%",
24714 maxHeight: "100%",
24715 enable: {
24716 left: enableResizing,
24717 right: enableResizing
24718 },
24719 showHandle: enableResizing
24720 // The editor is centered horizontally, resizing it only
24721 // moves half the distance. Hence double the ratio to correctly
24722 // align the cursor to the resizer handle.
24723 ,
24724 resizeRatio: 2,
24725 handleComponent: {
24726 left: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
24727 direction: "left",
24728 resizeWidthBy: resizeWidthBy
24729 }),
24730 right: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
24731 direction: "right",
24732 resizeWidthBy: resizeWidthBy
24733 })
24734 },
24735 handleClasses: undefined,
24736 handleStyles: {
24737 left: HANDLE_STYLES_OVERRIDE,
24738 right: HANDLE_STYLES_OVERRIDE
24739 },
24740 children: children
24741 });
24742 }
24743 /* harmony default export */ const resizable_editor = (ResizableEditor);
24744
24745 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/use-select-nearest-editable-block.js
24746 /**
24747 * WordPress dependencies
24748 */
24749
24750
24751
24752
24753 /**
24754 * Internal dependencies
24755 */
24756
24757 const DISTANCE_THRESHOLD = 500;
24758 function clamp(value, min, max) {
24759 return Math.min(Math.max(value, min), max);
24760 }
24761 function distanceFromRect(x, y, rect) {
24762 const dx = x - clamp(x, rect.left, rect.right);
24763 const dy = y - clamp(y, rect.top, rect.bottom);
24764 return Math.sqrt(dx * dx + dy * dy);
24765 }
24766 function useSelectNearestEditableBlock({
24767 isEnabled = true
24768 } = {}) {
24769 const {
24770 getEnabledClientIdsTree,
24771 getBlockName,
24772 getBlockOrder
24773 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
24774 const {
24775 selectBlock
24776 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
24777 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
24778 if (!isEnabled) {
24779 return;
24780 }
24781 const selectNearestEditableBlock = (x, y) => {
24782 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({
24783 clientId
24784 }) => {
24785 const blockName = getBlockName(clientId);
24786 if (blockName === 'core/template-part') {
24787 return [];
24788 }
24789 if (blockName === 'core/post-content') {
24790 const innerBlocks = getBlockOrder(clientId);
24791 if (innerBlocks.length) {
24792 return innerBlocks;
24793 }
24794 }
24795 return [clientId];
24796 });
24797 let nearestDistance = Infinity,
24798 nearestClientId = null;
24799 for (const clientId of editableBlockClientIds) {
24800 const block = element.querySelector(`[data-block="${clientId}"]`);
24801 if (!block) {
24802 continue;
24803 }
24804 const rect = block.getBoundingClientRect();
24805 const distance = distanceFromRect(x, y, rect);
24806 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
24807 nearestDistance = distance;
24808 nearestClientId = clientId;
24809 }
24810 }
24811 if (nearestClientId) {
24812 selectBlock(nearestClientId);
24813 }
24814 };
24815 const handleClick = event => {
24816 const shouldSelect = event.target === element || event.target.classList.contains('is-root-container');
24817 if (shouldSelect) {
24818 selectNearestEditableBlock(event.clientX, event.clientY);
24819 }
24820 };
24821 element.addEventListener('click', handleClick);
24822 return () => element.removeEventListener('click', handleClick);
24823 }, [isEnabled]);
24824 }
24825
24826 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/index.js
24827 /**
24828 * External dependencies
24829 */
24830
24831
24832 /**
24833 * WordPress dependencies
24834 */
24835
24836
24837
24838
24839
24840
24841
24842 /**
24843 * Internal dependencies
24844 */
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855 const {
24856 LayoutStyle,
24857 useLayoutClasses,
24858 useLayoutStyles,
24859 ExperimentalBlockCanvas: BlockCanvas,
24860 useFlashEditableBlocks
24861 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24862
24863 /**
24864 * These post types have a special editor where they don't allow you to fill the title
24865 * and they don't apply the layout styles.
24866 */
24867 const visual_editor_DESIGN_POST_TYPES = [PATTERN_POST_TYPE, TEMPLATE_POST_TYPE, NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE];
24868
24869 /**
24870 * Given an array of nested blocks, find the first Post Content
24871 * block inside it, recursing through any nesting levels,
24872 * and return its attributes.
24873 *
24874 * @param {Array} blocks A list of blocks.
24875 *
24876 * @return {Object | undefined} The Post Content block.
24877 */
24878 function getPostContentAttributes(blocks) {
24879 for (let i = 0; i < blocks.length; i++) {
24880 if (blocks[i].name === 'core/post-content') {
24881 return blocks[i].attributes;
24882 }
24883 if (blocks[i].innerBlocks.length) {
24884 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
24885 if (nestedPostContent) {
24886 return nestedPostContent;
24887 }
24888 }
24889 }
24890 }
24891 function checkForPostContentAtRootLevel(blocks) {
24892 for (let i = 0; i < blocks.length; i++) {
24893 if (blocks[i].name === 'core/post-content') {
24894 return true;
24895 }
24896 }
24897 return false;
24898 }
24899 function VisualEditor({
24900 // Ideally as we unify post and site editors, we won't need these props.
24901 autoFocus,
24902 styles,
24903 disableIframe = false,
24904 iframeProps,
24905 contentRef,
24906 className
24907 }) {
24908 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
24909 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
24910 const {
24911 renderingMode,
24912 postContentAttributes,
24913 editedPostTemplate = {},
24914 wrapperBlockName,
24915 wrapperUniqueId,
24916 deviceType,
24917 isFocusedEntity,
24918 isDesignPostType,
24919 postType,
24920 isPreview
24921 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24922 const {
24923 getCurrentPostId,
24924 getCurrentPostType,
24925 getCurrentTemplateId,
24926 getEditorSettings,
24927 getRenderingMode,
24928 getDeviceType
24929 } = select(store_store);
24930 const {
24931 getPostType,
24932 canUser,
24933 getEditedEntityRecord
24934 } = select(external_wp_coreData_namespaceObject.store);
24935 const postTypeSlug = getCurrentPostType();
24936 const _renderingMode = getRenderingMode();
24937 let _wrapperBlockName;
24938 if (postTypeSlug === PATTERN_POST_TYPE) {
24939 _wrapperBlockName = 'core/block';
24940 } else if (_renderingMode === 'post-only') {
24941 _wrapperBlockName = 'core/post-content';
24942 }
24943 const editorSettings = getEditorSettings();
24944 const supportsTemplateMode = editorSettings.supportsTemplateMode;
24945 const postTypeObject = getPostType(postTypeSlug);
24946 const canEditTemplate = canUser('create', 'templates');
24947 const currentTemplateId = getCurrentTemplateId();
24948 const template = currentTemplateId ? getEditedEntityRecord('postType', TEMPLATE_POST_TYPE, currentTemplateId) : undefined;
24949 return {
24950 renderingMode: _renderingMode,
24951 postContentAttributes: editorSettings.postContentAttributes,
24952 isDesignPostType: visual_editor_DESIGN_POST_TYPES.includes(postTypeSlug),
24953 // Post template fetch returns a 404 on classic themes, which
24954 // messes with e2e tests, so check it's a block theme first.
24955 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode && canEditTemplate ? template : undefined,
24956 wrapperBlockName: _wrapperBlockName,
24957 wrapperUniqueId: getCurrentPostId(),
24958 deviceType: getDeviceType(),
24959 isFocusedEntity: !!editorSettings.onNavigateToPreviousEntityRecord,
24960 postType: postTypeSlug,
24961 isPreview: editorSettings.__unstableIsPreviewMode
24962 };
24963 }, []);
24964 const {
24965 isCleanNewPost
24966 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
24967 const {
24968 hasRootPaddingAwareAlignments,
24969 themeHasDisabledLayoutStyles,
24970 themeSupportsLayout,
24971 isZoomOutMode
24972 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24973 const {
24974 getSettings,
24975 __unstableGetEditorMode
24976 } = select(external_wp_blockEditor_namespaceObject.store);
24977 const _settings = getSettings();
24978 return {
24979 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
24980 themeSupportsLayout: _settings.supportsLayout,
24981 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
24982 isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
24983 };
24984 }, []);
24985 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
24986 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout');
24987
24988 // fallbackLayout is used if there is no Post Content,
24989 // and for Post Title.
24990 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
24991 if (renderingMode !== 'post-only' || isDesignPostType) {
24992 return {
24993 type: 'default'
24994 };
24995 }
24996 if (themeSupportsLayout) {
24997 // We need to ensure support for wide and full alignments,
24998 // so we add the constrained type.
24999 return {
25000 ...globalLayoutSettings,
25001 type: 'constrained'
25002 };
25003 }
25004 // Set default layout for classic themes so all alignments are supported.
25005 return {
25006 type: 'default'
25007 };
25008 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]);
25009 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => {
25010 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
25011 return postContentAttributes;
25012 }
25013 // When in template editing mode, we can access the blocks directly.
25014 if (editedPostTemplate?.blocks) {
25015 return getPostContentAttributes(editedPostTemplate?.blocks);
25016 }
25017 // If there are no blocks, we have to parse the content string.
25018 // Best double-check it's a string otherwise the parse function gets unhappy.
25019 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
25020 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {};
25021 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
25022 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => {
25023 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
25024 return false;
25025 }
25026 // When in template editing mode, we can access the blocks directly.
25027 if (editedPostTemplate?.blocks) {
25028 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
25029 }
25030 // If there are no blocks, we have to parse the content string.
25031 // Best double-check it's a string otherwise the parse function gets unhappy.
25032 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
25033 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false;
25034 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
25035 const {
25036 layout = {},
25037 align = ''
25038 } = newestPostContentAttributes || {};
25039 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
25040 const blockListLayoutClass = dist_clsx({
25041 'is-layout-flow': !themeSupportsLayout
25042 }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
25043 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
25044
25045 // Update type for blocks using legacy layouts.
25046 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
25047 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
25048 ...globalLayoutSettings,
25049 ...layout,
25050 type: 'constrained'
25051 } : {
25052 ...globalLayoutSettings,
25053 ...layout,
25054 type: 'default'
25055 };
25056 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
25057
25058 // If there is a Post Content block we use its layout for the block list;
25059 // if not, this must be a classic theme, in which case we use the fallback layout.
25060 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
25061 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
25062 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)();
25063 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
25064 (0,external_wp_element_namespaceObject.useEffect)(() => {
25065 if (!autoFocus || !isCleanNewPost()) {
25066 return;
25067 }
25068 titleRef?.current?.focus();
25069 }, [autoFocus, isCleanNewPost]);
25070
25071 // Add some styles for alignwide/alignfull Post Content and its children.
25072 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
25073 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
25074 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
25075 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
25076 const localRef = (0,external_wp_element_namespaceObject.useRef)();
25077 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)();
25078 contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, contentRef, renderingMode === 'post-only' ? typewriterRef : null, useFlashEditableBlocks({
25079 isEnabled: renderingMode === 'template-locked'
25080 }), useSelectNearestEditableBlock({
25081 isEnabled: renderingMode === 'template-locked'
25082 })]);
25083 const zoomOutProps = isZoomOutMode ? {
25084 scale: 'default',
25085 frameSize: '20px'
25086 } : {};
25087 const forceFullHeight = postType === NAVIGATION_POST_TYPE;
25088 const enableResizing = [NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType) &&
25089 // Disable in previews / view mode.
25090 !isPreview &&
25091 // Disable resizing in mobile viewport.
25092 !isMobileViewport &&
25093 // Dsiable resizing in zoomed-out mode.
25094 !isZoomOutMode;
25095 const shouldIframe = !disableIframe || ['Tablet', 'Mobile'].includes(deviceType);
25096 const iframeStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
25097 return [...(styles !== null && styles !== void 0 ? styles : []), {
25098 css: `.is-root-container{display:flow-root;${
25099 // Some themes will have `min-height: 100vh` for the root container,
25100 // which isn't a requirement in auto resize mode.
25101 enableResizing ? 'min-height:0!important;' : ''}}`
25102 }];
25103 }, [styles, enableResizing]);
25104 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
25105 className: dist_clsx('editor-visual-editor',
25106 // this class is here for backward compatibility reasons.
25107 'edit-post-visual-editor', className, {
25108 'has-padding': isFocusedEntity || enableResizing,
25109 'is-resizable': enableResizing,
25110 'is-iframed': shouldIframe
25111 }),
25112 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(resizable_editor, {
25113 enableResizing: enableResizing,
25114 height: sizes.height && !forceFullHeight ? sizes.height : '100%',
25115 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockCanvas, {
25116 shouldIframe: shouldIframe,
25117 contentRef: contentRef,
25118 styles: iframeStyles,
25119 height: "100%",
25120 iframeProps: {
25121 ...iframeProps,
25122 ...zoomOutProps,
25123 style: {
25124 ...iframeProps?.style,
25125 ...deviceStyles
25126 }
25127 },
25128 children: [themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25129 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25130 selector: ".editor-visual-editor__post-title-wrapper",
25131 layout: fallbackLayout
25132 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25133 selector: ".block-editor-block-list__layout.is-root-container",
25134 layout: postEditorLayout
25135 }), align && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25136 css: alignCSS
25137 }), postContentLayoutStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25138 layout: postContentLayout,
25139 css: postContentLayoutStyles
25140 })]
25141 }), renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
25142 className: dist_clsx('editor-visual-editor__post-title-wrapper',
25143 // The following class is only here for backward comapatibility
25144 // some themes might be using it to style the post title.
25145 'edit-post-visual-editor__post-title-wrapper', {
25146 'has-global-padding': hasRootPaddingAwareAlignments
25147 }),
25148 contentEditable: false,
25149 ref: observeTypingRef,
25150 style: {
25151 // This is using inline styles
25152 // so it's applied for both iframed and non iframed editors.
25153 marginTop: '4rem'
25154 },
25155 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title, {
25156 ref: titleRef
25157 })
25158 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
25159 blockName: wrapperBlockName,
25160 uniqueId: wrapperUniqueId,
25161 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, {
25162 className: dist_clsx('is-' + deviceType.toLowerCase() + '-preview', renderingMode !== 'post-only' || isDesignPostType ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
25163 ),
25164 layout: blockListLayout,
25165 dropZoneElement:
25166 // When iframed, pass in the html element of the iframe to
25167 // ensure the drop zone extends to the edges of the iframe.
25168 disableIframe ? localRef.current : localRef.current?.parentNode,
25169 __unstableDisableDropZone:
25170 // In template preview mode, disable drop zones at the root of the template.
25171 renderingMode === 'template-locked' ? true : false
25172 }), renderingMode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditTemplateBlocksNotification, {
25173 contentRef: localRef
25174 })]
25175 }),
25176 // Avoid resize listeners when not needed,
25177 // these will trigger unnecessary re-renders
25178 // when animating the iframe width.
25179 enableResizing && resizeObserver]
25180 })
25181 })
25182 });
25183 }
25184 /* harmony default export */ const visual_editor = (VisualEditor);
25185
25186 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/index.js
25187 /**
25188 * External dependencies
25189 */
25190
25191
25192 /**
25193 * WordPress dependencies
25194 */
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204 /**
25205 * Internal dependencies
25206 */
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219 const interfaceLabels = {
25220 /* translators: accessibility text for the editor top bar landmark region. */
25221 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
25222 /* translators: accessibility text for the editor content landmark region. */
25223 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
25224 /* translators: accessibility text for the editor settings landmark region. */
25225 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
25226 /* translators: accessibility text for the editor publish landmark region. */
25227 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
25228 /* translators: accessibility text for the editor footer landmark region. */
25229 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
25230 };
25231 function EditorInterface({
25232 className,
25233 enableRegionNavigation,
25234 styles,
25235 children,
25236 forceIsDirty,
25237 contentRef,
25238 disableIframe,
25239 autoFocus,
25240 customSaveButton,
25241 forceDisableBlockTools,
25242 title,
25243 iframeProps
25244 }) {
25245 const {
25246 mode,
25247 isRichEditingEnabled,
25248 isInserterOpened,
25249 isListViewOpened,
25250 isDistractionFree,
25251 isPreviewMode,
25252 previousShortcut,
25253 nextShortcut,
25254 showBlockBreadcrumbs,
25255 documentLabel,
25256 blockEditorMode
25257 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25258 const {
25259 get
25260 } = select(external_wp_preferences_namespaceObject.store);
25261 const {
25262 getEditorSettings,
25263 getPostTypeLabel
25264 } = select(store_store);
25265 const editorSettings = getEditorSettings();
25266 const postTypeLabel = getPostTypeLabel();
25267 return {
25268 mode: select(store_store).getEditorMode(),
25269 isRichEditingEnabled: editorSettings.richEditingEnabled,
25270 isInserterOpened: select(store_store).isInserterOpened(),
25271 isListViewOpened: select(store_store).isListViewOpened(),
25272 isDistractionFree: get('core', 'distractionFree'),
25273 isPreviewMode: editorSettings.__unstableIsPreviewMode,
25274 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/previous-region'),
25275 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/next-region'),
25276 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
25277 // translators: Default label for the Document in the Block Breadcrumb.
25278 documentLabel: postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun'),
25279 blockEditorMode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode()
25280 };
25281 }, []);
25282 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
25283 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
25284 const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('Document Overview') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
25285
25286 // Local state for save panel.
25287 // Note 'truthy' callback implies an open panel.
25288 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
25289 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
25290 if (typeof entitiesSavedStatesCallback === 'function') {
25291 entitiesSavedStatesCallback(arg);
25292 }
25293 setEntitiesSavedStatesCallback(false);
25294 }, [entitiesSavedStatesCallback]);
25295 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(interface_skeleton, {
25296 enableRegionNavigation: enableRegionNavigation,
25297 isDistractionFree: isDistractionFree && isWideViewport,
25298 className: dist_clsx('editor-editor-interface', className, {
25299 'is-entity-save-view-open': !!entitiesSavedStatesCallback,
25300 'is-distraction-free': isDistractionFree && isWideViewport && !isPreviewMode
25301 }),
25302 labels: {
25303 ...interfaceLabels,
25304 secondarySidebar: secondarySidebarLabel
25305 },
25306 header: !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_header, {
25307 forceIsDirty: forceIsDirty,
25308 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
25309 customSaveButton: customSaveButton,
25310 forceDisableBlockTools: forceDisableBlockTools,
25311 title: title
25312 }),
25313 editorNotices: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}),
25314 secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InserterSidebar, {}) || isListViewOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewSidebar, {})),
25315 sidebar: !isPreviewMode && !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area.Slot, {
25316 scope: "core"
25317 }),
25318 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25319 children: [!isDistractionFree && !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(content_slot_fill.Slot, {
25320 children: ([editorCanvasView]) => editorCanvasView ? editorCanvasView : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25321 children: [!isPreviewMode && (mode === 'text' || !isRichEditingEnabled) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TextEditor
25322 // We should auto-focus the canvas (title) on load.
25323 // eslint-disable-next-line jsx-a11y/no-autofocus
25324 , {
25325 autoFocus: autoFocus
25326 }), !isPreviewMode && !isLargeViewport && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
25327 hideDragHandle: true
25328 }), (isPreviewMode || isRichEditingEnabled && mode === 'visual') && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(visual_editor, {
25329 styles: styles,
25330 contentRef: contentRef,
25331 disableIframe: disableIframe
25332 // We should auto-focus the canvas (title) on load.
25333 // eslint-disable-next-line jsx-a11y/no-autofocus
25334 ,
25335 autoFocus: autoFocus,
25336 iframeProps: iframeProps
25337 }), children]
25338 })
25339 })]
25340 }),
25341 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && isRichEditingEnabled && blockEditorMode !== 'zoom-out' && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
25342 rootLabelText: documentLabel
25343 }),
25344 actions: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SavePublishPanels, {
25345 closeEntitiesSavedStates: closeEntitiesSavedStates,
25346 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
25347 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
25348 forceIsDirtyPublishPanel: forceIsDirty
25349 }),
25350 shortcuts: {
25351 previous: previousShortcut,
25352 next: nextShortcut
25353 }
25354 });
25355 }
25356
25357 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-overrides-panel/index.js
25358 /**
25359 * WordPress dependencies
25360 */
25361
25362
25363
25364 /**
25365 * Internal dependencies
25366 */
25367
25368
25369
25370 const {
25371 OverridesPanel
25372 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25373 function PatternOverridesPanel() {
25374 const supportsPatternOverridesPanel = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === 'wp_block', []);
25375 if (!supportsPatternOverridesPanel) {
25376 return null;
25377 }
25378 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverridesPanel, {});
25379 }
25380
25381 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/trash.js
25382 /**
25383 * WordPress dependencies
25384 */
25385
25386
25387 const trash = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25388 xmlns: "http://www.w3.org/2000/svg",
25389 viewBox: "0 0 24 24",
25390 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25391 fillRule: "evenodd",
25392 clipRule: "evenodd",
25393 d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"
25394 })
25395 });
25396 /* harmony default export */ const library_trash = (trash);
25397
25398 ;// CONCATENATED MODULE: ./node_modules/client-zip/index.js
25399 "stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}}),"setBigUint64"in DataView.prototype||Object.defineProperty(DataView.prototype,"setBigUint64",{value(e,n,t){const i=Number(0xffffffffn&n),r=Number(n>>32n);this.setUint32(e+(t?0:4),i,t),this.setUint32(e+(t?4:0),r,t)}});var e=e=>new DataView(new ArrayBuffer(e)),n=e=>new Uint8Array(e.buffer||e),t=e=>(new TextEncoder).encode(String(e)),i=e=>Math.min(4294967295,Number(e)),client_zip_r=e=>Math.min(65535,Number(e));function f(e,i){if(void 0===i||i instanceof Date||(i=new Date(i)),e instanceof File)return{isFile:1,t:i||new Date(e.lastModified),i:e.stream()};if(e instanceof Response)return{isFile:1,t:i||new Date(e.headers.get("Last-Modified")||Date.now()),i:e.body};if(void 0===i)i=new Date;else if(isNaN(i))throw new Error("Invalid modification date.");if(void 0===e)return{isFile:0,t:i};if("string"==typeof e)return{isFile:1,t:i,i:t(e)};if(e instanceof Blob)return{isFile:1,t:i,i:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{isFile:1,t:i,i:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{isFile:1,t:i,i:n(e)};if(Symbol.asyncIterator in e)return{isFile:1,t:i,i:o(e[Symbol.asyncIterator]())};throw new TypeError("Unsupported input format.")}function o(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const i=await e.next();if(!i.value){n.close();break}{const e=a(i.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){n.throw?.(e)}})}function a(e){return"string"==typeof e?t(e):e instanceof Uint8Array?e:n(e)}function s(e,i,r){let[f,o]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[n(e),1]:[t(e),0]:[void 0,0]}(i);if(e instanceof File)return{o:d(f||t(e.name)),u:BigInt(e.size),l:o};if(e instanceof Response){const n=e.headers.get("content-disposition"),i=n&&n.match(/;\s*filename\*?=["']?(.*?)["']?$/i),a=i&&i[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),s=a&&decodeURIComponent(a),u=r||+e.headers.get("content-length");return{o:d(f||t(s)),u:BigInt(u),l:o}}return f=d(f,void 0!==e||void 0!==r),"string"==typeof e?{o:f,u:BigInt(t(e).length),l:o}:e instanceof Blob?{o:f,u:BigInt(e.size),l:o}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:f,u:BigInt(e.byteLength),l:o}:{o:f,u:u(e,r),l:o}}function u(e,n){return n>-1?BigInt(n):e?void 0:0n}function d(e,n=1){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");if(n)for(;47===e[e.length-1];)e=e.subarray(0,-1);else 47!==e[e.length-1]&&(e=new Uint8Array([...e,47]));return e}var l=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);l[e]=n}function y(e,n=0){n^=-1;for(var t=0,i=e.length;t<i;t++)n=n>>>8^l[255&n^e[t]];return(-1^n)>>>0}function w(e,n,t=0){const i=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,r=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,i,1),n.setUint16(t+2,r,1)}function B({o:e,l:n},t){return 8*(!n||(t??function(e){try{b.decode(e)}catch{return 0}return 1}(e)))}var b=new TextDecoder("utf8",{fatal:1});function p(t,i=0){const r=e(30);return r.setUint32(0,1347093252),r.setUint32(4,754976768|i),w(t.t,r,10),r.setUint16(26,t.o.length,1),n(r)}async function*g(e){let{i:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.m=y(n,0),e.u=BigInt(n.length);else{e.u=0n;const t=n.getReader();for(;;){const{value:n,done:i}=await t.read();if(i)break;e.m=y(n,e.m),e.u+=BigInt(n.length),yield n}}}function I(t,r){const f=e(16+(r?8:0));return f.setUint32(0,1347094280),f.setUint32(4,t.isFile?t.m:0,1),r?(f.setBigUint64(8,t.u,1),f.setBigUint64(16,t.u,1)):(f.setUint32(8,i(t.u),1),f.setUint32(12,i(t.u),1)),n(f)}function v(t,r,f=0,o=0){const a=e(46);return a.setUint32(0,1347092738),a.setUint32(4,755182848),a.setUint16(8,2048|f),w(t.t,a,12),a.setUint32(16,t.isFile?t.m:0,1),a.setUint32(20,i(t.u),1),a.setUint32(24,i(t.u),1),a.setUint16(28,t.o.length,1),a.setUint16(30,o,1),a.setUint16(40,t.isFile?33204:16893,1),a.setUint32(42,i(r),1),n(a)}function h(t,i,r){const f=e(r);return f.setUint16(0,1,1),f.setUint16(2,r-4,1),16&r&&(f.setBigUint64(4,t.u,1),f.setBigUint64(12,t.u,1)),f.setBigUint64(r-8,i,1),n(f)}function D(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}var S=e=>function(e){let n=BigInt(22),t=0n,i=0;for(const r of e){if(!r.o)throw new Error("Every file must have a non-empty name.");if(void 0===r.u)throw new Error(`Missing size for file "${(new TextDecoder).decode(r.o)}".`);const e=r.u>=0xffffffffn,f=t>=0xffffffffn;t+=BigInt(46+r.o.length+(e&&8))+r.u,n+=BigInt(r.o.length+46+(12*f|28*e)),i||(i=e)}return(i||t>=0xffffffffn)&&(n+=BigInt(76)),n+t}(function*(e){for(const n of e)yield s(...D(n)[0])}(e));function A(e,n={}){const t={"Content-Type":"application/zip","Content-Disposition":"attachment"};return("bigint"==typeof n.length||Number.isInteger(n.length))&&n.length>0&&(t["Content-Length"]=String(n.length)),n.metadata&&(t["Content-Length"]=String(S(n.metadata))),new Response(N(e,n),{headers:t})}function N(t,a={}){const u=function(e){const n=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await n.next();if(e.done)return e;const[t,i]=D(e.value);return{done:0,value:Object.assign(f(...i),s(...t))}},throw:n.throw?.bind(n),[Symbol.asyncIterator](){return this}}}(t);return o(async function*(t,f){const o=[];let a=0n,s=0n,u=0;for await(const e of t){const n=B(e,f.buffersAreUTF8);yield p(e,n),yield new Uint8Array(e.o),e.isFile&&(yield*g(e));const t=e.u>=0xffffffffn,i=12*(a>=0xffffffffn)|28*t;yield I(e,t),o.push(v(e,a,n,i)),o.push(e.o),i&&o.push(h(e,a,i)),t&&(a+=8n),s++,a+=BigInt(46+e.o.length)+e.u,u||(u=t)}let d=0n;for(const e of o)yield e,d+=BigInt(e.length);if(u||a>=0xffffffffn){const t=e(76);t.setUint32(0,1347094022),t.setBigUint64(4,BigInt(44),1),t.setUint32(12,755182848),t.setBigUint64(24,s,1),t.setBigUint64(32,s,1),t.setBigUint64(40,d,1),t.setBigUint64(48,a,1),t.setUint32(56,1347094023),t.setBigUint64(64,a+d,1),t.setUint32(72,1,1),yield n(t)}const l=e(22);l.setUint32(0,1347093766),l.setUint16(8,client_zip_r(s),1),l.setUint16(10,client_zip_r(s),1),l.setUint32(12,i(d),1),l.setUint32(16,i(a),1),yield n(l)}(u,a),u)}
25400 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/export-pattern-action.js
25401 /**
25402 * External dependencies
25403 */
25404
25405
25406
25407 /**
25408 * WordPress dependencies
25409 */
25410
25411
25412
25413
25414 /**
25415 * Internal dependencies
25416 */
25417
25418
25419 // Patterns.
25420 const {
25421 PATTERN_TYPES: export_pattern_action_PATTERN_TYPES
25422 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25423 function getJsonFromItem(item) {
25424 return JSON.stringify({
25425 __file: item.type,
25426 title: item.title || item.name,
25427 content: item.patternPost.content.raw,
25428 syncStatus: item.patternPost.wp_pattern_sync_status
25429 }, null, 2);
25430 }
25431 const exportPatternAsJSONAction = {
25432 id: 'export-pattern',
25433 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'),
25434 supportsBulk: true,
25435 isEligible: item => {
25436 if (!item.type) {
25437 return false;
25438 }
25439 return item.type === export_pattern_action_PATTERN_TYPES.user;
25440 },
25441 callback: async items => {
25442 if (items.length === 1) {
25443 return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(items[0].title || items[0].name)}.json`, getJsonFromItem(items[0]), 'application/json');
25444 }
25445 const nameCount = {};
25446 const filesToZip = items.map(item => {
25447 const name = paramCase(item.title || item.name);
25448 nameCount[name] = (nameCount[name] || 0) + 1;
25449 return {
25450 name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
25451 lastModified: new Date(),
25452 input: getJsonFromItem(item)
25453 };
25454 });
25455 return (0,external_wp_blob_namespaceObject.downloadBlob)((0,external_wp_i18n_namespaceObject.__)('patterns-export') + '.zip', await A(filesToZip).blob(), 'application/zip');
25456 }
25457 };
25458
25459 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/actions.js
25460 /**
25461 * WordPress dependencies
25462 */
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474 /**
25475 * Internal dependencies
25476 */
25477
25478
25479
25480
25481
25482
25483
25484 // Patterns.
25485
25486
25487 const {
25488 PATTERN_TYPES: actions_PATTERN_TYPES,
25489 CreatePatternModalContents,
25490 useDuplicatePatternProps
25491 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25492
25493 /**
25494 * Check if a template is removable.
25495 *
25496 * @param {Object} template The template entity to check.
25497 * @return {boolean} Whether the template is removable.
25498 */
25499 function isTemplateRemovable(template) {
25500 if (!template) {
25501 return false;
25502 }
25503 // In patterns list page we map the templates parts to a different object
25504 // than the one returned from the endpoint. This is why we need to check for
25505 // two props whether is custom or has a theme file.
25506 return [template.source, template.templatePart?.source].includes(TEMPLATE_ORIGINS.custom) && !template.has_theme_file && !template.templatePart?.has_theme_file;
25507 }
25508 const canDeleteOrReset = item => {
25509 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
25510 const isUserPattern = item.type === actions_PATTERN_TYPES.user;
25511 return isUserPattern || isTemplatePart && item.isCustom;
25512 };
25513 function getItemTitle(item) {
25514 if (typeof item.title === 'string') {
25515 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
25516 }
25517 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered || '');
25518 }
25519
25520 // This action is used for templates, patterns and template parts.
25521 // Every other post type uses the similar `trashPostAction` which
25522 // moves the post to trash.
25523 const deletePostAction = {
25524 id: 'delete-post',
25525 label: (0,external_wp_i18n_namespaceObject.__)('Delete'),
25526 isPrimary: true,
25527 icon: library_trash,
25528 isEligible(post) {
25529 if ([TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(post.type)) {
25530 return isTemplateRemovable(post);
25531 }
25532 // We can only remove user patterns.
25533 return post.type === actions_PATTERN_TYPES.user;
25534 },
25535 supportsBulk: true,
25536 hideModalHeader: true,
25537 RenderModal: ({
25538 items,
25539 closeModal,
25540 onActionStart,
25541 onActionPerformed
25542 }) => {
25543 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
25544 const {
25545 removeTemplates
25546 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
25547 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25548 spacing: "5",
25549 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
25550 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
25551 // translators: %d: number of items to delete.
25552 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
25553 // translators: %s: The template or template part's titles
25554 (0,external_wp_i18n_namespaceObject.__)('Delete "%s"?'), getItemTitle(items[0]))
25555 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25556 justify: "right",
25557 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25558 variant: "tertiary",
25559 onClick: closeModal,
25560 disabled: isBusy,
25561 __experimentalIsFocusable: true,
25562 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25563 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25564 variant: "primary",
25565 onClick: async () => {
25566 setIsBusy(true);
25567 if (onActionStart) {
25568 onActionStart(items);
25569 }
25570 await removeTemplates(items, {
25571 allowUndo: false
25572 });
25573 onActionPerformed?.(items);
25574 setIsBusy(false);
25575 closeModal();
25576 },
25577 isBusy: isBusy,
25578 disabled: isBusy,
25579 __experimentalIsFocusable: true,
25580 children: (0,external_wp_i18n_namespaceObject.__)('Delete')
25581 })]
25582 })]
25583 });
25584 }
25585 };
25586 const trashPostAction = {
25587 id: 'move-to-trash',
25588 label: (0,external_wp_i18n_namespaceObject.__)('Move to Trash'),
25589 isPrimary: true,
25590 icon: library_trash,
25591 isEligible(item) {
25592 return !['auto-draft', 'trash'].includes(item.status);
25593 },
25594 supportsBulk: true,
25595 hideModalHeader: true,
25596 RenderModal: ({
25597 items,
25598 closeModal,
25599 onActionStart,
25600 onActionPerformed
25601 }) => {
25602 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
25603 const {
25604 createSuccessNotice,
25605 createErrorNotice
25606 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25607 const {
25608 deleteEntityRecord
25609 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25610 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25611 spacing: "5",
25612 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
25613 children: items.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
25614 // translators: %s: The item's title.
25615 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move to trash "%s"?'), getItemTitle(items[0])) : (0,external_wp_i18n_namespaceObject.sprintf)(
25616 // translators: %d: The number of items (2 or more).
25617 (0,external_wp_i18n_namespaceObject._n)('Are you sure you want to move to trash %d item?', 'Are you sure you want to move to trash %d items?', items.length), items.length)
25618 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25619 justify: "right",
25620 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25621 variant: "tertiary",
25622 onClick: closeModal,
25623 disabled: isBusy,
25624 __experimentalIsFocusable: true,
25625 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25626 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25627 variant: "primary",
25628 onClick: async () => {
25629 setIsBusy(true);
25630 if (onActionStart) {
25631 onActionStart(items);
25632 }
25633 const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id, {}, {
25634 throwOnError: true
25635 })));
25636 // If all the promises were fulfilled with success.
25637 if (promiseResult.every(({
25638 status
25639 }) => status === 'fulfilled')) {
25640 let successMessage;
25641 if (promiseResult.length === 1) {
25642 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The item's title. */
25643 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to trash.'), getItemTitle(items[0]));
25644 } else if (items[0].type === 'page') {
25645 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
25646 (0,external_wp_i18n_namespaceObject.__)('%s items moved to trash.'), items.length);
25647 } else {
25648 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25649 (0,external_wp_i18n_namespaceObject.__)('%s items move to trash.'), items.length);
25650 }
25651 createSuccessNotice(successMessage, {
25652 type: 'snackbar',
25653 id: 'move-to-trash-action'
25654 });
25655 } else {
25656 // If there was at least one failure.
25657 let errorMessage;
25658 // If we were trying to delete a single item.
25659 if (promiseResult.length === 1) {
25660 if (promiseResult[0].reason?.message) {
25661 errorMessage = promiseResult[0].reason.message;
25662 } else {
25663 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item.');
25664 }
25665 // If we were trying to delete multiple items.
25666 } else {
25667 const errorMessages = new Set();
25668 const failedPromises = promiseResult.filter(({
25669 status
25670 }) => status === 'rejected');
25671 for (const failedPromise of failedPromises) {
25672 if (failedPromise.reason?.message) {
25673 errorMessages.add(failedPromise.reason.message);
25674 }
25675 }
25676 if (errorMessages.size === 0) {
25677 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the items.');
25678 } else if (errorMessages.size === 1) {
25679 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25680 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item: %s'), [...errorMessages][0]);
25681 } else {
25682 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25683 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving to trash the items: %s'), [...errorMessages].join(','));
25684 }
25685 }
25686 createErrorNotice(errorMessage, {
25687 type: 'snackbar'
25688 });
25689 }
25690 if (onActionPerformed) {
25691 onActionPerformed(items);
25692 }
25693 setIsBusy(false);
25694 closeModal();
25695 },
25696 isBusy: isBusy,
25697 disabled: isBusy,
25698 __experimentalIsFocusable: true,
25699 children: (0,external_wp_i18n_namespaceObject.__)('Trash')
25700 })]
25701 })]
25702 });
25703 }
25704 };
25705 function usePermanentlyDeletePostAction() {
25706 const {
25707 createSuccessNotice,
25708 createErrorNotice
25709 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25710 const {
25711 deleteEntityRecord
25712 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25713 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
25714 id: 'permanently-delete',
25715 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'),
25716 supportsBulk: true,
25717 isEligible({
25718 status
25719 }) {
25720 return status === 'trash';
25721 },
25722 async callback(posts, onActionPerformed) {
25723 const promiseResult = await Promise.allSettled(posts.map(post => {
25724 return deleteEntityRecord('postType', post.type, post.id, {
25725 force: true
25726 }, {
25727 throwOnError: true
25728 });
25729 }));
25730 // If all the promises were fulfilled with success.
25731 if (promiseResult.every(({
25732 status
25733 }) => status === 'fulfilled')) {
25734 let successMessage;
25735 if (promiseResult.length === 1) {
25736 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */
25737 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), getItemTitle(posts[0]));
25738 } else {
25739 successMessage = (0,external_wp_i18n_namespaceObject.__)('The posts were permanently deleted.');
25740 }
25741 createSuccessNotice(successMessage, {
25742 type: 'snackbar',
25743 id: 'permanently-delete-post-action'
25744 });
25745 if (onActionPerformed) {
25746 onActionPerformed(posts);
25747 }
25748 } else {
25749 // If there was at lease one failure.
25750 let errorMessage;
25751 // If we were trying to permanently delete a single post.
25752 if (promiseResult.length === 1) {
25753 if (promiseResult[0].reason?.message) {
25754 errorMessage = promiseResult[0].reason.message;
25755 } else {
25756 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the post.');
25757 }
25758 // If we were trying to permanently delete multiple posts
25759 } else {
25760 const errorMessages = new Set();
25761 const failedPromises = promiseResult.filter(({
25762 status
25763 }) => status === 'rejected');
25764 for (const failedPromise of failedPromises) {
25765 if (failedPromise.reason?.message) {
25766 errorMessages.add(failedPromise.reason.message);
25767 }
25768 }
25769 if (errorMessages.size === 0) {
25770 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.');
25771 } else if (errorMessages.size === 1) {
25772 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25773 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
25774 } else {
25775 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25776 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
25777 }
25778 }
25779 createErrorNotice(errorMessage, {
25780 type: 'snackbar'
25781 });
25782 }
25783 }
25784 }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]);
25785 }
25786 function useRestorePostAction() {
25787 const {
25788 createSuccessNotice,
25789 createErrorNotice
25790 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25791 const {
25792 editEntityRecord,
25793 saveEditedEntityRecord
25794 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25795 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
25796 id: 'restore',
25797 label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
25798 isPrimary: true,
25799 icon: library_backup,
25800 supportsBulk: true,
25801 isEligible({
25802 status
25803 }) {
25804 return status === 'trash';
25805 },
25806 async callback(posts, onActionPerformed) {
25807 await Promise.allSettled(posts.map(post => {
25808 return editEntityRecord('postType', post.type, post.id, {
25809 status: 'draft'
25810 });
25811 }));
25812 const promiseResult = await Promise.allSettled(posts.map(post => {
25813 return saveEditedEntityRecord('postType', post.type, post.id, {
25814 throwOnError: true
25815 });
25816 }));
25817 if (promiseResult.every(({
25818 status
25819 }) => status === 'fulfilled')) {
25820 let successMessage;
25821 if (posts.length === 1) {
25822 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25823 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
25824 } else if (posts[0].type === 'page') {
25825 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25826 (0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
25827 } else {
25828 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25829 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
25830 }
25831 createSuccessNotice(successMessage, {
25832 type: 'snackbar',
25833 id: 'restore-post-action'
25834 });
25835 if (onActionPerformed) {
25836 onActionPerformed(posts);
25837 }
25838 } else {
25839 // If there was at lease one failure.
25840 let errorMessage;
25841 // If we were trying to move a single post to the trash.
25842 if (promiseResult.length === 1) {
25843 if (promiseResult[0].reason?.message) {
25844 errorMessage = promiseResult[0].reason.message;
25845 } else {
25846 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
25847 }
25848 // If we were trying to move multiple posts to the trash
25849 } else {
25850 const errorMessages = new Set();
25851 const failedPromises = promiseResult.filter(({
25852 status
25853 }) => status === 'rejected');
25854 for (const failedPromise of failedPromises) {
25855 if (failedPromise.reason?.message) {
25856 errorMessages.add(failedPromise.reason.message);
25857 }
25858 }
25859 if (errorMessages.size === 0) {
25860 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
25861 } else if (errorMessages.size === 1) {
25862 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25863 (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
25864 } else {
25865 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25866 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
25867 }
25868 }
25869 createErrorNotice(errorMessage, {
25870 type: 'snackbar'
25871 });
25872 }
25873 }
25874 }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]);
25875 }
25876 const viewPostAction = {
25877 id: 'view-post',
25878 label: (0,external_wp_i18n_namespaceObject.__)('View'),
25879 isPrimary: true,
25880 icon: library_external,
25881 isEligible(post) {
25882 return post.status !== 'trash';
25883 },
25884 callback(posts, onActionPerformed) {
25885 const post = posts[0];
25886 window.open(post.link, '_blank');
25887 if (onActionPerformed) {
25888 onActionPerformed(posts);
25889 }
25890 }
25891 };
25892 const postRevisionsAction = {
25893 id: 'view-post-revisions',
25894 label(items) {
25895 var _items$0$_links$versi;
25896 const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
25897 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
25898 (0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
25899 },
25900 isEligible: post => {
25901 var _post$_links$predeces, _post$_links$version;
25902 if (post.status === 'trash') {
25903 return false;
25904 }
25905 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
25906 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
25907 return lastRevisionId && revisionsCount > 1;
25908 },
25909 callback(posts, onActionPerformed) {
25910 const post = posts[0];
25911 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
25912 revision: post?._links?.['predecessor-version']?.[0]?.id
25913 });
25914 document.location.href = href;
25915 if (onActionPerformed) {
25916 onActionPerformed(posts);
25917 }
25918 }
25919 };
25920 const renamePostAction = {
25921 id: 'rename-post',
25922 label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
25923 isEligible(post) {
25924 if (post.status === 'trash') {
25925 return false;
25926 }
25927 // Templates, template parts and patterns have special checks for renaming.
25928 if (![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, ...Object.values(actions_PATTERN_TYPES)].includes(post.type)) {
25929 return true;
25930 }
25931 // In the case of templates, we can only rename custom templates.
25932 if (post.type === TEMPLATE_POST_TYPE) {
25933 return isTemplateRemovable(post) && post.is_custom;
25934 }
25935 // Make necessary checks for template parts and patterns.
25936 const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
25937 const isUserPattern = post.type === actions_PATTERN_TYPES.user;
25938 // In patterns list page we map the templates parts to a different object
25939 // than the one returned from the endpoint. This is why we need to check for
25940 // two props whether is custom or has a theme file.
25941 const isCustomPattern = isUserPattern || isTemplatePart && (post.isCustom || post.source === TEMPLATE_ORIGINS.custom);
25942 const hasThemeFile = isTemplatePart && (post.templatePart?.has_theme_file || post.has_theme_file);
25943 return isCustomPattern && !hasThemeFile;
25944 },
25945 RenderModal: ({
25946 items,
25947 closeModal,
25948 onActionPerformed
25949 }) => {
25950 const [item] = items;
25951 const originalTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(typeof item.title === 'string' ? item.title : item.title.rendered);
25952 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => originalTitle);
25953 const {
25954 editEntityRecord,
25955 saveEditedEntityRecord
25956 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25957 const {
25958 createSuccessNotice,
25959 createErrorNotice
25960 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25961 async function onRename(event) {
25962 event.preventDefault();
25963 try {
25964 await editEntityRecord('postType', item.type, item.id, {
25965 title
25966 });
25967 // Update state before saving rerenders the list.
25968 setTitle('');
25969 closeModal();
25970 // Persist edited entity.
25971 await saveEditedEntityRecord('postType', item.type, item.id, {
25972 throwOnError: true
25973 });
25974 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
25975 type: 'snackbar'
25976 });
25977 onActionPerformed?.(items);
25978 } catch (error) {
25979 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
25980 createErrorNotice(errorMessage, {
25981 type: 'snackbar'
25982 });
25983 }
25984 }
25985 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
25986 onSubmit: onRename,
25987 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25988 spacing: "5",
25989 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
25990 __nextHasNoMarginBottom: true,
25991 __next40pxDefaultSize: true,
25992 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
25993 value: title,
25994 onChange: setTitle,
25995 required: true
25996 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25997 justify: "right",
25998 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25999 __next40pxDefaultSize: true,
26000 variant: "tertiary",
26001 onClick: () => {
26002 closeModal();
26003 },
26004 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26005 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26006 __next40pxDefaultSize: true,
26007 variant: "primary",
26008 type: "submit",
26009 children: (0,external_wp_i18n_namespaceObject.__)('Save')
26010 })]
26011 })]
26012 })
26013 });
26014 }
26015 };
26016 const duplicatePostAction = {
26017 id: 'duplicate-post',
26018 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26019 isEligible({
26020 status
26021 }) {
26022 return status !== 'trash';
26023 },
26024 RenderModal: ({
26025 items,
26026 closeModal,
26027 onActionPerformed
26028 }) => {
26029 const [item] = items;
26030 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
26031 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing item title */
26032 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), getItemTitle(item)));
26033 const {
26034 saveEntityRecord
26035 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26036 const {
26037 createSuccessNotice,
26038 createErrorNotice
26039 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26040 async function createPage(event) {
26041 event.preventDefault();
26042 if (isCreatingPage) {
26043 return;
26044 }
26045 setIsCreatingPage(true);
26046 try {
26047 const newItem = await saveEntityRecord('postType', item.type, {
26048 status: 'draft',
26049 title,
26050 slug: title || (0,external_wp_i18n_namespaceObject.__)('No title'),
26051 author: item.author,
26052 comment_status: item.comment_status,
26053 content: typeof item.content === 'string' ? item.content : item.content.raw,
26054 excerpt: item.excerpt.raw,
26055 meta: item.meta,
26056 parent: item.parent,
26057 password: item.password,
26058 template: item.template,
26059 format: item.format,
26060 featured_media: item.featured_media,
26061 menu_order: item.menu_order,
26062 ping_status: item.ping_status,
26063 categories: item.categories,
26064 tags: item.tags
26065 }, {
26066 throwOnError: true
26067 });
26068 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26069 // translators: %s: Title of the created template e.g: "Category".
26070 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newItem.title?.rendered || title)), {
26071 id: 'duplicate-post-action',
26072 type: 'snackbar'
26073 });
26074 if (onActionPerformed) {
26075 onActionPerformed([newItem]);
26076 }
26077 } catch (error) {
26078 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
26079 createErrorNotice(errorMessage, {
26080 type: 'snackbar'
26081 });
26082 } finally {
26083 setIsCreatingPage(false);
26084 closeModal();
26085 }
26086 }
26087 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26088 onSubmit: createPage,
26089 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26090 spacing: 3,
26091 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
26092 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
26093 onChange: setTitle,
26094 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
26095 value: title
26096 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26097 spacing: 2,
26098 justify: "end",
26099 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26100 variant: "tertiary",
26101 onClick: closeModal,
26102 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26103 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26104 variant: "primary",
26105 type: "submit",
26106 isBusy: isCreatingPage,
26107 "aria-disabled": isCreatingPage,
26108 children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26109 })]
26110 })]
26111 })
26112 });
26113 }
26114 };
26115 const isTemplatePartRevertable = item => {
26116 if (!item) {
26117 return false;
26118 }
26119 const hasThemeFile = item.templatePart?.has_theme_file;
26120 return canDeleteOrReset(item) && hasThemeFile;
26121 };
26122 const resetTemplateAction = {
26123 id: 'reset-template',
26124 label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
26125 isEligible: item => {
26126 return item.type === TEMPLATE_PART_POST_TYPE ? isTemplatePartRevertable(item) : isTemplateRevertable(item);
26127 },
26128 icon: library_backup,
26129 supportsBulk: true,
26130 hideModalHeader: true,
26131 RenderModal: ({
26132 items,
26133 closeModal,
26134 onActionStart,
26135 onActionPerformed
26136 }) => {
26137 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
26138 const {
26139 revertTemplate,
26140 removeTemplates
26141 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
26142 const {
26143 saveEditedEntityRecord
26144 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26145 const {
26146 createSuccessNotice,
26147 createErrorNotice
26148 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26149 const onConfirm = async () => {
26150 try {
26151 if (items[0].type === TEMPLATE_PART_POST_TYPE) {
26152 await removeTemplates(items);
26153 } else {
26154 for (const template of items) {
26155 if (template.type === TEMPLATE_POST_TYPE) {
26156 await revertTemplate(template, {
26157 allowUndo: false
26158 });
26159 await saveEditedEntityRecord('postType', template.type, template.id);
26160 }
26161 }
26162 createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
26163 (0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
26164 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(items[0]))), {
26165 type: 'snackbar',
26166 id: 'revert-template-action'
26167 });
26168 }
26169 } catch (error) {
26170 let fallbackErrorMessage;
26171 if (items[0].type === TEMPLATE_POST_TYPE) {
26172 fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the templates.');
26173 } else {
26174 fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template parts.');
26175 }
26176 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage;
26177 createErrorNotice(errorMessage, {
26178 type: 'snackbar'
26179 });
26180 }
26181 };
26182 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26183 spacing: "5",
26184 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26185 children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
26186 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26187 justify: "right",
26188 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26189 variant: "tertiary",
26190 onClick: closeModal,
26191 disabled: isBusy,
26192 __experimentalIsFocusable: true,
26193 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26194 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26195 variant: "primary",
26196 onClick: async () => {
26197 setIsBusy(true);
26198 if (onActionStart) {
26199 onActionStart(items);
26200 }
26201 await onConfirm(items);
26202 onActionPerformed?.(items);
26203 setIsBusy(false);
26204 closeModal();
26205 },
26206 isBusy: isBusy,
26207 disabled: isBusy,
26208 __experimentalIsFocusable: true,
26209 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
26210 })]
26211 })]
26212 });
26213 }
26214 };
26215 const duplicatePatternAction = {
26216 id: 'duplicate-pattern',
26217 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26218 isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE,
26219 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
26220 RenderModal: ({
26221 items,
26222 closeModal
26223 }) => {
26224 const [item] = items;
26225 const isThemePattern = item.type === actions_PATTERN_TYPES.theme;
26226 const duplicatedProps = useDuplicatePatternProps({
26227 pattern: isThemePattern || !item.patternPost ? item : item.patternPost,
26228 onSuccess: () => closeModal()
26229 });
26230 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
26231 onClose: closeModal,
26232 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26233 ...duplicatedProps
26234 });
26235 }
26236 };
26237 const duplicateTemplatePartAction = {
26238 id: 'duplicate-template-part',
26239 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26240 isEligible: item => item.type === TEMPLATE_PART_POST_TYPE,
26241 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
26242 RenderModal: ({
26243 items,
26244 closeModal
26245 }) => {
26246 const [item] = items;
26247 const {
26248 createSuccessNotice
26249 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26250 function onTemplatePartSuccess() {
26251 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26252 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
26253 (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title), {
26254 type: 'snackbar',
26255 id: 'edit-site-patterns-success'
26256 });
26257 closeModal();
26258 }
26259 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
26260 blocks: item.blocks,
26261 defaultArea: item.templatePart?.area || item.area,
26262 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */
26263 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title),
26264 onCreate: onTemplatePartSuccess,
26265 onError: closeModal,
26266 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26267 });
26268 }
26269 };
26270 function usePostActions(postType, onActionPerformed) {
26271 const {
26272 defaultActions,
26273 postTypeObject
26274 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26275 const {
26276 getPostType
26277 } = select(external_wp_coreData_namespaceObject.store);
26278 const {
26279 getEntityActions
26280 } = unlock(select(store_store));
26281 return {
26282 postTypeObject: getPostType(postType),
26283 defaultActions: getEntityActions('postType', postType)
26284 };
26285 }, [postType]);
26286 const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
26287 const restorePostAction = useRestorePostAction();
26288 const isTemplateOrTemplatePart = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26289 const isPattern = postType === PATTERN_POST_TYPE;
26290 const isLoaded = !!postTypeObject;
26291 const supportsRevisions = !!postTypeObject?.supports?.revisions;
26292 const supportsTitle = !!postTypeObject?.supports?.title;
26293 return (0,external_wp_element_namespaceObject.useMemo)(() => {
26294 if (!isLoaded) {
26295 return [];
26296 }
26297 const actions = [postTypeObject?.viewable && viewPostAction, supportsRevisions && postRevisionsAction, true ? !isTemplateOrTemplatePart && !isPattern && duplicatePostAction : 0, isTemplateOrTemplatePart && duplicateTemplatePartAction, isPattern && duplicatePatternAction, supportsTitle && renamePostAction, isPattern && exportPatternAsJSONAction, isTemplateOrTemplatePart ? resetTemplateAction : restorePostAction, isTemplateOrTemplatePart || isPattern ? deletePostAction : trashPostAction, !isTemplateOrTemplatePart && permanentlyDeletePostAction, ...defaultActions].filter(Boolean);
26298 if (onActionPerformed) {
26299 for (let i = 0; i < actions.length; ++i) {
26300 if (actions[i].callback) {
26301 const existingCallback = actions[i].callback;
26302 actions[i] = {
26303 ...actions[i],
26304 callback: (items, _onActionPerformed) => {
26305 existingCallback(items, _items => {
26306 if (_onActionPerformed) {
26307 _onActionPerformed(_items);
26308 }
26309 onActionPerformed(actions[i].id, _items);
26310 });
26311 }
26312 };
26313 }
26314 if (actions[i].RenderModal) {
26315 const ExistingRenderModal = actions[i].RenderModal;
26316 actions[i] = {
26317 ...actions[i],
26318 RenderModal: props => {
26319 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExistingRenderModal, {
26320 ...props,
26321 onActionPerformed: _items => {
26322 if (props.onActionPerformed) {
26323 props.onActionPerformed(_items);
26324 }
26325 onActionPerformed(actions[i].id, _items);
26326 }
26327 });
26328 }
26329 };
26330 }
26331 }
26332 }
26333 return actions;
26334 }, [defaultActions, isTemplateOrTemplatePart, isPattern, postTypeObject?.viewable, permanentlyDeletePostAction, restorePostAction, onActionPerformed, isLoaded, supportsRevisions, supportsTitle]);
26335 }
26336
26337 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/index.js
26338 /**
26339 * WordPress dependencies
26340 */
26341
26342
26343
26344
26345
26346
26347
26348 /**
26349 * Internal dependencies
26350 */
26351
26352
26353
26354
26355
26356
26357 const {
26358 DropdownMenuV2: DropdownMenu,
26359 DropdownMenuGroupV2: DropdownMenuGroup,
26360 DropdownMenuItemV2: DropdownMenuItem,
26361 DropdownMenuItemLabelV2: DropdownMenuItemLabel,
26362 kebabCase
26363 } = unlock(external_wp_components_namespaceObject.privateApis);
26364 function PostActions({
26365 onActionPerformed,
26366 buttonProps
26367 }) {
26368 const [isActionsMenuOpen, setIsActionsMenuOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26369 const {
26370 item,
26371 postType
26372 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26373 const {
26374 getCurrentPostType,
26375 getCurrentPostId
26376 } = select(store_store);
26377 const {
26378 getEditedEntityRecord
26379 } = select(external_wp_coreData_namespaceObject.store);
26380 const _postType = getCurrentPostType();
26381 return {
26382 item: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
26383 postType: _postType
26384 };
26385 }, []);
26386 const allActions = usePostActions(postType, onActionPerformed);
26387 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => {
26388 return allActions.filter(action => {
26389 return !action.isEligible || action.isEligible(item);
26390 });
26391 }, [allActions, item]);
26392 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenu, {
26393 open: isActionsMenuOpen,
26394 trigger: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26395 size: "small",
26396 icon: more_vertical,
26397 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
26398 disabled: !actions.length,
26399 __experimentalIsFocusable: true,
26400 className: "editor-all-actions-button",
26401 onClick: () => setIsActionsMenuOpen(!isActionsMenuOpen),
26402 ...buttonProps
26403 }),
26404 onOpenChange: setIsActionsMenuOpen,
26405 placement: "bottom-end",
26406 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionsDropdownMenuGroup, {
26407 actions: actions,
26408 item: item,
26409 onClose: () => {
26410 setIsActionsMenuOpen(false);
26411 }
26412 })
26413 });
26414 }
26415
26416 // From now on all the functions on this file are copied as from the dataviews packages,
26417 // The editor packages should not be using the dataviews packages directly,
26418 // and the dataviews package should not be using the editor packages directly,
26419 // so duplicating the code here seems like the least bad option.
26420
26421 // Copied as is from packages/dataviews/src/item-actions.js
26422 function DropdownMenuItemTrigger({
26423 action,
26424 onClick,
26425 items
26426 }) {
26427 const label = typeof action.label === 'string' ? action.label : action.label(items);
26428 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItem, {
26429 onClick: onClick,
26430 hideOnClick: !action.RenderModal,
26431 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemLabel, {
26432 children: label
26433 })
26434 });
26435 }
26436
26437 // Copied as is from packages/dataviews/src/item-actions.js
26438 // With an added onClose prop.
26439 function ActionWithModal({
26440 action,
26441 item,
26442 ActionTrigger,
26443 onClose
26444 }) {
26445 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26446 const actionTriggerProps = {
26447 action,
26448 onClick: () => setIsModalOpen(true),
26449 items: [item]
26450 };
26451 const {
26452 RenderModal,
26453 hideModalHeader
26454 } = action;
26455 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26456 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionTrigger, {
26457 ...actionTriggerProps
26458 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
26459 title: action.modalHeader || action.label,
26460 __experimentalHideHeader: !!hideModalHeader,
26461 onRequestClose: () => {
26462 setIsModalOpen(false);
26463 },
26464 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
26465 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenderModal, {
26466 items: [item],
26467 closeModal: () => {
26468 setIsModalOpen(false);
26469 onClose();
26470 }
26471 })
26472 })]
26473 });
26474 }
26475
26476 // Copied as is from packages/dataviews/src/item-actions.js
26477 // With an added onClose prop.
26478 function ActionsDropdownMenuGroup({
26479 actions,
26480 item,
26481 onClose
26482 }) {
26483 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuGroup, {
26484 children: actions.map(action => {
26485 if (action.RenderModal) {
26486 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionWithModal, {
26487 action: action,
26488 item: item,
26489 ActionTrigger: DropdownMenuItemTrigger,
26490 onClose: onClose
26491 }, action.id);
26492 }
26493 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemTrigger, {
26494 action: action,
26495 onClick: () => action.callback([item]),
26496 items: [item]
26497 }, action.id);
26498 })
26499 });
26500 }
26501
26502 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-card-panel/index.js
26503 /**
26504 * External dependencies
26505 */
26506
26507 /**
26508 * WordPress dependencies
26509 */
26510
26511
26512
26513
26514
26515
26516 /**
26517 * Internal dependencies
26518 */
26519
26520
26521
26522
26523
26524 function PostCardPanel({
26525 actions
26526 }) {
26527 const {
26528 isFrontPage,
26529 isPostsPage,
26530 title,
26531 icon,
26532 isSync
26533 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26534 const {
26535 getEditedPostAttribute,
26536 getCurrentPostType,
26537 getCurrentPostId,
26538 __experimentalGetTemplateInfo
26539 } = select(store_store);
26540 const {
26541 getEditedEntityRecord
26542 } = select(external_wp_coreData_namespaceObject.store);
26543 const siteSettings = getEditedEntityRecord('root', 'site');
26544 const _type = getCurrentPostType();
26545 const _id = getCurrentPostId();
26546 const _record = getEditedEntityRecord('postType', _type, _id);
26547 const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(_type) && __experimentalGetTemplateInfo(_record);
26548 let _isSync = false;
26549 if (GLOBAL_POST_TYPES.includes(_type)) {
26550 if (PATTERN_POST_TYPE === _type) {
26551 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
26552 const currentSyncStatus = getEditedPostAttribute('meta')?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
26553 _isSync = currentSyncStatus !== 'unsynced';
26554 } else {
26555 _isSync = true;
26556 }
26557 }
26558 return {
26559 title: _templateInfo?.title || getEditedPostAttribute('title'),
26560 icon: unlock(select(store_store)).getPostIcon(_type, {
26561 area: _record?.area
26562 }),
26563 isSync: _isSync,
26564 isFrontPage: siteSettings?.page_on_front === _id,
26565 isPostsPage: siteSettings?.page_for_posts === _id
26566 };
26567 }, []);
26568 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26569 className: "editor-post-card-panel",
26570 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26571 spacing: 2,
26572 className: "editor-post-card-panel__header",
26573 align: "flex-start",
26574 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
26575 className: dist_clsx('editor-post-card-panel__icon', {
26576 'is-sync': isSync
26577 }),
26578 icon: icon
26579 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
26580 numberOfLines: 2,
26581 truncate: true,
26582 className: "editor-post-card-panel__title",
26583 weight: 500,
26584 as: "h2",
26585 lineHeight: "20px",
26586 children: [title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title'), isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26587 className: "editor-post-card-panel__title-badge",
26588 children: (0,external_wp_i18n_namespaceObject.__)('Front Page')
26589 }), isPostsPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26590 className: "editor-post-card-panel__title-badge",
26591 children: (0,external_wp_i18n_namespaceObject.__)('Posts Page')
26592 })]
26593 }), actions]
26594 })
26595 });
26596 }
26597
26598 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-content-information/index.js
26599 /**
26600 * WordPress dependencies
26601 */
26602
26603
26604
26605
26606
26607
26608
26609 /**
26610 * Internal dependencies
26611 */
26612
26613
26614
26615 // Taken from packages/editor/src/components/time-to-read/index.js.
26616
26617 const post_content_information_AVERAGE_READING_RATE = 189;
26618
26619 // This component renders the wordcount and reading time for the post.
26620 function PostContentInformation() {
26621 const {
26622 postContent
26623 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26624 const {
26625 getEditedPostAttribute,
26626 getCurrentPostType,
26627 getCurrentPostId
26628 } = select(store_store);
26629 const {
26630 getEntityRecord
26631 } = select(external_wp_coreData_namespaceObject.store);
26632 const siteSettings = getEntityRecord('root', 'site');
26633 const postType = getCurrentPostType();
26634 const _id = getCurrentPostId();
26635 const isPostsPage = +_id === siteSettings?.page_for_posts;
26636 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26637 return {
26638 postContent: showPostContentInfo && getEditedPostAttribute('content')
26639 };
26640 }, []);
26641
26642 /*
26643 * translators: If your word count is based on single characters (e.g. East Asian characters),
26644 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
26645 * Do not translate into your own language.
26646 */
26647 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
26648 const wordsCounted = (0,external_wp_element_namespaceObject.useMemo)(() => postContent ? (0,external_wp_wordcount_namespaceObject.count)(postContent, wordCountType) : 0, [postContent, wordCountType]);
26649 if (!wordsCounted) {
26650 return null;
26651 }
26652 const readingTime = Math.round(wordsCounted / post_content_information_AVERAGE_READING_RATE);
26653 const wordsCountText = (0,external_wp_i18n_namespaceObject.sprintf)(
26654 // translators: %s: the number of words in the post.
26655 (0,external_wp_i18n_namespaceObject._n)('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
26656 const minutesText = readingTime <= 1 ? (0,external_wp_i18n_namespaceObject.__)('1 minute') : (0,external_wp_i18n_namespaceObject.sprintf)(
26657 // translators: %s: the number of minutes to read the post.
26658 (0,external_wp_i18n_namespaceObject._n)('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
26659 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26660 className: "editor-post-content-information",
26661 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26662 children: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
26663 (0,external_wp_i18n_namespaceObject.__)('%1$s, %2$s read time.'), wordsCountText, minutesText)
26664 })
26665 });
26666 }
26667
26668 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/panel.js
26669 /**
26670 * WordPress dependencies
26671 */
26672
26673
26674
26675
26676
26677
26678 /**
26679 * Internal dependencies
26680 */
26681
26682
26683
26684
26685
26686 /**
26687 * Renders the Post Author Panel component.
26688 *
26689 * @return {Component} The component to be rendered.
26690 */
26691
26692
26693 function panel_PostFormat() {
26694 const {
26695 postFormat
26696 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26697 const {
26698 getEditedPostAttribute
26699 } = select(store_store);
26700 const _postFormat = getEditedPostAttribute('format');
26701 return {
26702 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard'
26703 };
26704 }, []);
26705 const activeFormat = POST_FORMATS.find(format => format.id === postFormat);
26706
26707 // Use internal state instead of a ref to make sure that the component
26708 // re-renders when the popover's anchor updates.
26709 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26710 // Memoize popoverProps to avoid returning a new object every time.
26711 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26712 // Anchor the popover to the middle of the entire row so that it doesn't
26713 // move around when the label changes.
26714 anchor: popoverAnchor,
26715 placement: 'left-start',
26716 offset: 36,
26717 shift: true
26718 }), [popoverAnchor]);
26719 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
26720 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26721 label: (0,external_wp_i18n_namespaceObject.__)('Format'),
26722 ref: setPopoverAnchor,
26723 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26724 popoverProps: popoverProps,
26725 contentClassName: "editor-post-format__dialog",
26726 focusOnMount: true,
26727 renderToggle: ({
26728 isOpen,
26729 onToggle
26730 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26731 size: "compact",
26732 variant: "tertiary",
26733 "aria-expanded": isOpen,
26734 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26735 // translators: %s: Current post format.
26736 (0,external_wp_i18n_namespaceObject.__)('Change format: %s'), activeFormat?.caption),
26737 onClick: onToggle,
26738 children: activeFormat?.caption
26739 }),
26740 renderContent: ({
26741 onClose
26742 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26743 className: "editor-post-format__dialog-content",
26744 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26745 title: (0,external_wp_i18n_namespaceObject.__)('Format'),
26746 onClose: onClose
26747 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormat, {})]
26748 })
26749 })
26750 })
26751 });
26752 }
26753 /* harmony default export */ const post_format_panel = (panel_PostFormat);
26754
26755 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-edited-panel/index.js
26756 /**
26757 * WordPress dependencies
26758 */
26759
26760
26761
26762
26763
26764 /**
26765 * Internal dependencies
26766 */
26767
26768
26769 function PostLastEditedPanel() {
26770 const modified = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('modified'), []);
26771 const lastEditedText = modified && (0,external_wp_i18n_namespaceObject.sprintf)(
26772 // translators: %s: Human-readable time difference, e.g. "2 days ago".
26773 (0,external_wp_i18n_namespaceObject.__)('Last edited %s.'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified));
26774 if (!lastEditedText) {
26775 return null;
26776 }
26777 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26778 className: "editor-post-last-edited-panel",
26779 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26780 children: lastEditedText
26781 })
26782 });
26783 }
26784
26785 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-section/index.js
26786 /**
26787 * External dependencies
26788 */
26789
26790
26791 /**
26792 * WordPress dependencies
26793 */
26794
26795
26796 function PostPanelSection({
26797 className,
26798 children
26799 }) {
26800 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26801 className: dist_clsx('editor-post-panel__section', className),
26802 children: children
26803 });
26804 }
26805 /* harmony default export */ const post_panel_section = (PostPanelSection);
26806
26807 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-status/index.js
26808 /**
26809 * WordPress dependencies
26810 */
26811
26812
26813
26814
26815
26816
26817
26818
26819 /**
26820 * Internal dependencies
26821 */
26822
26823
26824
26825
26826
26827
26828
26829 const labels = {
26830 'auto-draft': (0,external_wp_i18n_namespaceObject.__)('Draft'),
26831 draft: (0,external_wp_i18n_namespaceObject.__)('Draft'),
26832 pending: (0,external_wp_i18n_namespaceObject.__)('Pending'),
26833 private: (0,external_wp_i18n_namespaceObject.__)('Private'),
26834 future: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
26835 publish: (0,external_wp_i18n_namespaceObject.__)('Published')
26836 };
26837 const STATUS_OPTIONS = [{
26838 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26839 children: [(0,external_wp_i18n_namespaceObject.__)('Draft'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26840 variant: "muted",
26841 size: 12,
26842 children: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
26843 })]
26844 }),
26845 value: 'draft'
26846 }, {
26847 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26848 children: [(0,external_wp_i18n_namespaceObject.__)('Pending'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26849 variant: "muted",
26850 size: 12,
26851 children: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
26852 })]
26853 }),
26854 value: 'pending'
26855 }, {
26856 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26857 children: [(0,external_wp_i18n_namespaceObject.__)('Private'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26858 variant: "muted",
26859 size: 12,
26860 children: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
26861 })]
26862 }),
26863 value: 'private'
26864 }, {
26865 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26866 children: [(0,external_wp_i18n_namespaceObject.__)('Scheduled'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26867 variant: "muted",
26868 size: 12,
26869 children: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
26870 })]
26871 }),
26872 value: 'future'
26873 }, {
26874 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26875 children: [(0,external_wp_i18n_namespaceObject.__)('Published'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26876 variant: "muted",
26877 size: 12,
26878 children: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
26879 })]
26880 }),
26881 value: 'publish'
26882 }];
26883 const post_status_DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
26884 function PostStatus() {
26885 const {
26886 status,
26887 date,
26888 password,
26889 postId,
26890 postType,
26891 canEdit
26892 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26893 var _getCurrentPost$_link;
26894 const {
26895 getEditedPostAttribute,
26896 getCurrentPostId,
26897 getCurrentPostType,
26898 getCurrentPost
26899 } = select(store_store);
26900 return {
26901 status: getEditedPostAttribute('status'),
26902 date: getEditedPostAttribute('date'),
26903 password: getEditedPostAttribute('password'),
26904 postId: getCurrentPostId(),
26905 postType: getCurrentPostType(),
26906 canEdit: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
26907 };
26908 }, []);
26909 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
26910 const passwordInputId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostStatus, 'editor-change-status__password-input');
26911 const {
26912 editEntityRecord
26913 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26914 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26915 // Memoize popoverProps to avoid returning a new object every time.
26916 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26917 // Anchor the popover to the middle of the entire row so that it doesn't
26918 // move around when the label changes.
26919 anchor: popoverAnchor,
26920 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26921 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26922 placement: 'left-start',
26923 offset: 36,
26924 shift: true
26925 }), [popoverAnchor]);
26926 if (post_status_DESIGN_POST_TYPES.includes(postType)) {
26927 return null;
26928 }
26929 const updatePost = ({
26930 status: newStatus = status,
26931 password: newPassword = password,
26932 date: newDate = date
26933 }) => {
26934 editEntityRecord('postType', postType, postId, {
26935 status: newStatus,
26936 date: newDate,
26937 password: newPassword
26938 });
26939 };
26940 const handleTogglePassword = value => {
26941 setShowPassword(value);
26942 if (!value) {
26943 updatePost({
26944 password: ''
26945 });
26946 }
26947 };
26948 const handleStatus = value => {
26949 let newDate = date;
26950 let newPassword = password;
26951 if (status === 'future' && new Date(date) > new Date()) {
26952 newDate = null;
26953 }
26954 if (value === 'private' && password) {
26955 newPassword = '';
26956 }
26957 updatePost({
26958 status: value,
26959 date: newDate,
26960 password: newPassword
26961 });
26962 };
26963 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26964 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
26965 ref: setPopoverAnchor,
26966 children: canEdit ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26967 className: "editor-post-status",
26968 contentClassName: "editor-change-status__content",
26969 popoverProps: popoverProps,
26970 focusOnMount: true,
26971 renderToggle: ({
26972 onToggle
26973 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26974 variant: "tertiary",
26975 size: "compact",
26976 onClick: onToggle,
26977 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26978 // translators: %s: Current post status.
26979 (0,external_wp_i18n_namespaceObject.__)('Change post status: %s'), labels[status]),
26980 children: labels[status]
26981 }),
26982 renderContent: ({
26983 onClose
26984 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26985 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26986 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26987 onClose: onClose
26988 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26989 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26990 spacing: 4,
26991 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
26992 className: "editor-change-status__options",
26993 hideLabelFromVision: true,
26994 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
26995 options: STATUS_OPTIONS,
26996 onChange: handleStatus,
26997 selected: status === 'auto-draft' ? 'draft' : status
26998 }), status === 'future' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26999 className: "editor-change-status__publish-date-wrapper",
27000 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
27001 showPopoverHeaderActions: false,
27002 isCompact: true
27003 })
27004 }), status !== 'private' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27005 as: "fieldset",
27006 spacing: 4,
27007 className: "editor-change-status__password-fieldset",
27008 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
27009 __nextHasNoMarginBottom: true,
27010 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
27011 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
27012 checked: showPassword,
27013 onChange: handleTogglePassword
27014 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27015 className: "editor-change-status__password-input",
27016 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
27017 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
27018 onChange: value => updatePost({
27019 password: value
27020 }),
27021 value: password,
27022 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
27023 type: "text",
27024 id: passwordInputId,
27025 __next40pxDefaultSize: true,
27026 __nextHasNoMarginBottom: true
27027 })
27028 })]
27029 })]
27030 })
27031 })]
27032 })
27033 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27034 className: "editor-post-status is-read-only",
27035 children: labels[status]
27036 })
27037 });
27038 }
27039
27040 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/blog-title/index.js
27041 /**
27042 * WordPress dependencies
27043 */
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053 /**
27054 * Internal dependencies
27055 */
27056
27057
27058
27059
27060
27061
27062 const blog_title_EMPTY_OBJECT = {};
27063 function BlogTitle() {
27064 const {
27065 editEntityRecord
27066 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27067 const {
27068 postsPageTitle,
27069 postsPageId,
27070 isTemplate,
27071 postSlug
27072 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27073 const {
27074 getEntityRecord,
27075 getEditedEntityRecord
27076 } = select(external_wp_coreData_namespaceObject.store);
27077 const siteSettings = getEntityRecord('root', 'site');
27078 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : blog_title_EMPTY_OBJECT;
27079 const {
27080 getEditedPostAttribute,
27081 getCurrentPostType
27082 } = select(store_store);
27083 return {
27084 postsPageId: _postsPageRecord?.id,
27085 postsPageTitle: _postsPageRecord?.title,
27086 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27087 postSlug: getEditedPostAttribute('slug')
27088 };
27089 }, []);
27090 // Use internal state instead of a ref to make sure that the component
27091 // re-renders when the popover's anchor updates.
27092 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27093 // Memoize popoverProps to avoid returning a new object every time.
27094 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27095 // Anchor the popover to the middle of the entire row so that it doesn't
27096 // move around when the label changes.
27097 anchor: popoverAnchor,
27098 placement: 'left-start',
27099 offset: 36,
27100 shift: true
27101 }), [popoverAnchor]);
27102 if (!isTemplate || !['home', 'index'].includes(postSlug) || !postsPageId) {
27103 return null;
27104 }
27105 const setPostsPageTitle = newValue => {
27106 editEntityRecord('postType', 'page', postsPageId, {
27107 title: newValue
27108 });
27109 };
27110 const decodedTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postsPageTitle);
27111 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27112 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27113 ref: setPopoverAnchor,
27114 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27115 popoverProps: popoverProps,
27116 contentClassName: "editor-blog-title-dropdown__content",
27117 focusOnMount: true,
27118 renderToggle: ({
27119 isOpen,
27120 onToggle
27121 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27122 size: "compact",
27123 variant: "tertiary",
27124 "aria-expanded": isOpen,
27125 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
27126 // translators: %s: Current post link.
27127 (0,external_wp_i18n_namespaceObject.__)('Change blog title: %s'), decodedTitle),
27128 onClick: onToggle,
27129 children: decodedTitle
27130 }),
27131 renderContent: ({
27132 onClose
27133 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27134 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27135 title: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27136 onClose: onClose
27137 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
27138 placeholder: (0,external_wp_i18n_namespaceObject.__)('No Title'),
27139 size: "__unstable-large",
27140 value: postsPageTitle,
27141 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300),
27142 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27143 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.'),
27144 hideLabelFromVision: true
27145 })]
27146 })
27147 })
27148 });
27149 }
27150
27151 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/posts-per-page/index.js
27152 /**
27153 * WordPress dependencies
27154 */
27155
27156
27157
27158
27159
27160
27161
27162 /**
27163 * Internal dependencies
27164 */
27165
27166
27167
27168
27169
27170
27171 function PostsPerPage() {
27172 const {
27173 editEntityRecord
27174 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27175 const {
27176 postsPerPage,
27177 isTemplate,
27178 postSlug
27179 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27180 const {
27181 getEditedPostAttribute,
27182 getCurrentPostType
27183 } = select(store_store);
27184 const {
27185 getEditedEntityRecord
27186 } = select(external_wp_coreData_namespaceObject.store);
27187 const siteSettings = getEditedEntityRecord('root', 'site');
27188 return {
27189 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27190 postSlug: getEditedPostAttribute('slug'),
27191 postsPerPage: siteSettings?.posts_per_page || 1
27192 };
27193 }, []);
27194 // Use internal state instead of a ref to make sure that the component
27195 // re-renders when the popover's anchor updates.
27196 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27197 // Memoize popoverProps to avoid returning a new object every time.
27198 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27199 // Anchor the popover to the middle of the entire row so that it doesn't
27200 // move around when the label changes.
27201 anchor: popoverAnchor,
27202 placement: 'left-start',
27203 offset: 36,
27204 shift: true
27205 }), [popoverAnchor]);
27206 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27207 return null;
27208 }
27209 const setPostsPerPage = newValue => {
27210 editEntityRecord('root', 'site', undefined, {
27211 posts_per_page: newValue
27212 });
27213 };
27214 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27215 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27216 ref: setPopoverAnchor,
27217 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27218 popoverProps: popoverProps,
27219 contentClassName: "editor-posts-per-page-dropdown__content",
27220 focusOnMount: true,
27221 renderToggle: ({
27222 isOpen,
27223 onToggle
27224 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27225 size: "compact",
27226 variant: "tertiary",
27227 "aria-expanded": isOpen,
27228 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change posts per page'),
27229 onClick: onToggle,
27230 children: postsPerPage
27231 }),
27232 renderContent: ({
27233 onClose
27234 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27235 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27236 title: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27237 onClose: onClose
27238 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
27239 placeholder: 0,
27240 value: postsPerPage,
27241 size: "__unstable-large",
27242 spinControls: "custom",
27243 step: "1",
27244 min: "1",
27245 onChange: setPostsPerPage,
27246 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27247 help: (0,external_wp_i18n_namespaceObject.__)('Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'),
27248 hideLabelFromVision: true
27249 })]
27250 })
27251 })
27252 });
27253 }
27254
27255 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/site-discussion/index.js
27256 /**
27257 * WordPress dependencies
27258 */
27259
27260
27261
27262
27263
27264
27265
27266 /**
27267 * Internal dependencies
27268 */
27269
27270
27271
27272
27273
27274
27275 const site_discussion_COMMENT_OPTIONS = [{
27276 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27277 children: [(0,external_wp_i18n_namespaceObject.__)('Open'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27278 variant: "muted",
27279 size: 12,
27280 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
27281 })]
27282 }),
27283 value: 'open'
27284 }, {
27285 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27286 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27287 variant: "muted",
27288 size: 12,
27289 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
27290 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27291 variant: "muted",
27292 size: 12,
27293 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
27294 })]
27295 }),
27296 value: ''
27297 }];
27298 function SiteDiscussion() {
27299 const {
27300 editEntityRecord
27301 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27302 const {
27303 allowCommentsOnNewPosts,
27304 isTemplate,
27305 postSlug
27306 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27307 const {
27308 getEditedPostAttribute,
27309 getCurrentPostType
27310 } = select(store_store);
27311 const {
27312 getEditedEntityRecord
27313 } = select(external_wp_coreData_namespaceObject.store);
27314 const siteSettings = getEditedEntityRecord('root', 'site');
27315 return {
27316 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27317 postSlug: getEditedPostAttribute('slug'),
27318 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ''
27319 };
27320 }, []);
27321 // Use internal state instead of a ref to make sure that the component
27322 // re-renders when the popover's anchor updates.
27323 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27324 // Memoize popoverProps to avoid returning a new object every time.
27325 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27326 // Anchor the popover to the middle of the entire row so that it doesn't
27327 // move around when the label changes.
27328 anchor: popoverAnchor,
27329 placement: 'left-start',
27330 offset: 36,
27331 shift: true
27332 }), [popoverAnchor]);
27333 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27334 return null;
27335 }
27336 const setAllowCommentsOnNewPosts = newValue => {
27337 editEntityRecord('root', 'site', undefined, {
27338 default_comment_status: newValue ? 'open' : null
27339 });
27340 };
27341 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27342 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27343 ref: setPopoverAnchor,
27344 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27345 popoverProps: popoverProps,
27346 contentClassName: "editor-site-discussion-dropdown__content",
27347 focusOnMount: true,
27348 renderToggle: ({
27349 isOpen,
27350 onToggle
27351 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27352 size: "compact",
27353 variant: "tertiary",
27354 "aria-expanded": isOpen,
27355 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion settings'),
27356 onClick: onToggle,
27357 children: allowCommentsOnNewPosts ? (0,external_wp_i18n_namespaceObject.__)('Comments open') : (0,external_wp_i18n_namespaceObject.__)('Comments closed')
27358 }),
27359 renderContent: ({
27360 onClose
27361 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27362 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27363 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27364 onClose: onClose
27365 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27366 spacing: 3,
27367 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27368 children: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.')
27369 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
27370 className: "editor-site-discussion__options",
27371 hideLabelFromVision: true,
27372 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
27373 options: site_discussion_COMMENT_OPTIONS,
27374 onChange: setAllowCommentsOnNewPosts,
27375 selected: allowCommentsOnNewPosts
27376 })]
27377 })]
27378 })
27379 })
27380 });
27381 }
27382
27383 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-areas/index.js
27384 /**
27385 * WordPress dependencies
27386 */
27387
27388
27389
27390
27391
27392 /**
27393 * Internal dependencies
27394 */
27395
27396
27397
27398
27399
27400 function TemplateAreaItem({
27401 area,
27402 clientId
27403 }) {
27404 const {
27405 selectBlock,
27406 toggleBlockHighlight
27407 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
27408 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
27409 const defaultAreas = select(store_store).__experimentalGetDefaultTemplatePartAreas();
27410 return defaultAreas.find(defaultArea => defaultArea.area === area);
27411 }, [area]);
27412 const highlightBlock = () => toggleBlockHighlight(clientId, true);
27413 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
27414 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27415 className: "editor-template-areas__item",
27416 icon: templatePartArea?.icon,
27417 onMouseOver: highlightBlock,
27418 onMouseLeave: cancelHighlightBlock,
27419 onFocus: highlightBlock,
27420 onBlur: cancelHighlightBlock,
27421 onClick: () => {
27422 selectBlock(clientId);
27423 },
27424 children: templatePartArea?.label
27425 });
27426 }
27427 function TemplateAreas() {
27428 const {
27429 isTemplate,
27430 templateParts
27431 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27432 const _isTemplate = select(store_store).getCurrentPostType() === TEMPLATE_POST_TYPE;
27433 return {
27434 isTemplate: _isTemplate,
27435 templateParts: _isTemplate && unlock(select(store_store)).getCurrentTemplateTemplateParts()
27436 };
27437 }, []);
27438 if (!isTemplate || !templateParts.length) {
27439 return null;
27440 }
27441 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
27442 className: "editor-template-areas",
27443 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
27444 level: 3,
27445 className: "editor-template-areas__title",
27446 children: (0,external_wp_i18n_namespaceObject.__)('Areas')
27447 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
27448 className: "editor-template-areas__list",
27449 children: templateParts.map(({
27450 templatePart,
27451 block
27452 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
27453 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateAreaItem, {
27454 area: templatePart.area,
27455 clientId: block.clientId
27456 })
27457 }, block.clientId))
27458 })]
27459 });
27460 }
27461
27462 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/post-summary.js
27463 /**
27464 * WordPress dependencies
27465 */
27466
27467
27468
27469 /**
27470 * Internal dependencies
27471 */
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497 /**
27498 * Module Constants
27499 */
27500
27501
27502
27503 const post_summary_PANEL_NAME = 'post-status';
27504 function PostSummary({
27505 onActionPerformed
27506 }) {
27507 const {
27508 isRemovedPostStatusPanel
27509 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27510 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
27511 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
27512 const {
27513 isEditorPanelRemoved,
27514 getCurrentPostType
27515 } = select(store_store);
27516 return {
27517 isRemovedPostStatusPanel: isEditorPanelRemoved(post_summary_PANEL_NAME),
27518 postType: getCurrentPostType()
27519 };
27520 }, []);
27521 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_section, {
27522 className: "editor-post-summary",
27523 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info.Slot, {
27524 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27525 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27526 spacing: 4,
27527 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostCardPanel, {
27528 actions: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostActions, {
27529 onActionPerformed: onActionPerformed
27530 })
27531 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFeaturedImagePanel, {
27532 withPanelBody: false
27533 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostExcerptPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27534 spacing: 1,
27535 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostContentInformation, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostLastEditedPanel, {})]
27536 }), !isRemovedPostStatusPanel && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27537 spacing: 4,
27538 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27539 spacing: 1,
27540 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStatus, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedulePanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplatePanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostLastRevision, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSyncStatus, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlogTitle, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostsPerPage, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SiteDiscussion, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSticky, {})]
27541 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateAreas, {}), fills]
27542 })]
27543 })
27544 })
27545 })
27546 });
27547 }
27548
27549 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/hooks.js
27550 /**
27551 * WordPress dependencies
27552 */
27553
27554
27555
27556
27557
27558
27559 /**
27560 * Internal dependencies
27561 */
27562
27563
27564 const {
27565 EXCLUDED_PATTERN_SOURCES,
27566 PATTERN_TYPES: hooks_PATTERN_TYPES
27567 } = unlock(external_wp_patterns_namespaceObject.privateApis);
27568 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
27569 block.innerBlocks = block.innerBlocks.map(innerBlock => {
27570 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet);
27571 });
27572 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
27573 block.attributes.theme = currentThemeStylesheet;
27574 }
27575 return block;
27576 }
27577
27578 /**
27579 * Filter all patterns and return only the ones that are compatible with the current template.
27580 *
27581 * @param {Array} patterns An array of patterns.
27582 * @param {Object} template The current template.
27583 * @return {Array} Array of patterns that are compatible with the current template.
27584 */
27585 function filterPatterns(patterns, template) {
27586 // Filter out duplicates.
27587 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name);
27588
27589 // Filter out core/directory patterns not included in theme.json.
27590 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
27591
27592 // Looks for patterns that have the same template type as the current template,
27593 // or have a block type that matches the current template area.
27594 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug) || pattern.blockTypes?.includes('core/template-part/' + template.area);
27595 return patterns.filter((pattern, index, items) => {
27596 return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
27597 });
27598 }
27599 function preparePatterns(patterns, currentThemeStylesheet) {
27600 return patterns.map(pattern => ({
27601 ...pattern,
27602 keywords: pattern.keywords || [],
27603 type: hooks_PATTERN_TYPES.theme,
27604 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
27605 __unstableSkipMigrationLogs: true
27606 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet))
27607 }));
27608 }
27609 function useAvailablePatterns(template) {
27610 const {
27611 blockPatterns,
27612 restBlockPatterns,
27613 currentThemeStylesheet
27614 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27615 var _settings$__experimen;
27616 const {
27617 getEditorSettings
27618 } = select(store_store);
27619 const settings = getEditorSettings();
27620 return {
27621 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns,
27622 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
27623 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet
27624 };
27625 }, []);
27626 return (0,external_wp_element_namespaceObject.useMemo)(() => {
27627 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])];
27628 const filteredPatterns = filterPatterns(mergedPatterns, template);
27629 return preparePatterns(filteredPatterns, template, currentThemeStylesheet);
27630 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]);
27631 }
27632
27633 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/index.js
27634 /**
27635 * WordPress dependencies
27636 */
27637
27638
27639
27640
27641
27642
27643
27644
27645 /**
27646 * Internal dependencies
27647 */
27648
27649
27650
27651
27652 function post_transform_panel_TemplatesList({
27653 availableTemplates,
27654 onSelect
27655 }) {
27656 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates);
27657 if (!availableTemplates || availableTemplates?.length === 0) {
27658 return null;
27659 }
27660 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
27661 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
27662 blockPatterns: availableTemplates,
27663 shownPatterns: shownTemplates,
27664 onClickPattern: onSelect,
27665 showTitlesAsTooltip: true
27666 });
27667 }
27668 function PostTransform() {
27669 const {
27670 record,
27671 postType,
27672 postId
27673 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27674 const {
27675 getCurrentPostType,
27676 getCurrentPostId
27677 } = select(store_store);
27678 const {
27679 getEditedEntityRecord
27680 } = select(external_wp_coreData_namespaceObject.store);
27681 const type = getCurrentPostType();
27682 const id = getCurrentPostId();
27683 return {
27684 postType: type,
27685 postId: id,
27686 record: getEditedEntityRecord('postType', type, id)
27687 };
27688 }, []);
27689 const {
27690 editEntityRecord
27691 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27692 const availablePatterns = useAvailablePatterns(record);
27693 const onTemplateSelect = async selectedTemplate => {
27694 await editEntityRecord('postType', postType, postId, {
27695 blocks: selectedTemplate.blocks,
27696 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks)
27697 });
27698 };
27699 if (!availablePatterns?.length) {
27700 return null;
27701 }
27702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27703 title: (0,external_wp_i18n_namespaceObject.__)('Design'),
27704 initialOpen: record.type === TEMPLATE_PART_POST_TYPE,
27705 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_transform_panel_TemplatesList, {
27706 availableTemplates: availablePatterns,
27707 onSelect: onTemplateSelect
27708 })
27709 });
27710 }
27711 function PostTransformPanel() {
27712 const {
27713 postType
27714 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27715 const {
27716 getCurrentPostType
27717 } = select(store_store);
27718 return {
27719 postType: getCurrentPostType()
27720 };
27721 }, []);
27722 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
27723 return null;
27724 }
27725 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransform, {});
27726 }
27727
27728 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/constants.js
27729 const sidebars = {
27730 document: 'edit-post/document',
27731 block: 'edit-post/block'
27732 };
27733
27734 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/header.js
27735 /**
27736 * WordPress dependencies
27737 */
27738
27739
27740
27741
27742
27743 /**
27744 * Internal dependencies
27745 */
27746
27747
27748
27749
27750
27751 const {
27752 Tabs: header_Tabs
27753 } = unlock(external_wp_components_namespaceObject.privateApis);
27754 const SidebarHeader = (_, ref) => {
27755 const {
27756 documentLabel
27757 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27758 const {
27759 getPostTypeLabel
27760 } = select(store_store);
27761 return {
27762 // translators: Default label for the Document sidebar tab, not selected.
27763 documentLabel: getPostTypeLabel() || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun')
27764 };
27765 }, []);
27766 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(header_Tabs.TabList, {
27767 ref: ref,
27768 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(header_Tabs.Tab, {
27769 tabId: sidebars.document
27770 // Used for focus management in the SettingsSidebar component.
27771 ,
27772 "data-tab-id": sidebars.document,
27773 children: documentLabel
27774 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(header_Tabs.Tab, {
27775 tabId: sidebars.block
27776 // Used for focus management in the SettingsSidebar component.
27777 ,
27778 "data-tab-id": sidebars.block,
27779 children: (0,external_wp_i18n_namespaceObject.__)('Block')
27780 })]
27781 });
27782 };
27783 /* harmony default export */ const sidebar_header = ((0,external_wp_element_namespaceObject.forwardRef)(SidebarHeader));
27784
27785 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-content-panel/index.js
27786 /**
27787 * WordPress dependencies
27788 */
27789
27790
27791
27792
27793
27794 /**
27795 * Internal dependencies
27796 */
27797
27798
27799 const {
27800 BlockQuickNavigation
27801 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27802 const PAGE_CONTENT_BLOCKS = ['core/post-content', 'core/post-featured-image', 'core/post-title'];
27803 function TemplateContentPanel() {
27804 const clientIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
27805 const {
27806 getBlocksByName
27807 } = select(external_wp_blockEditor_namespaceObject.store);
27808 return getBlocksByName(PAGE_CONTENT_BLOCKS);
27809 }, []);
27810 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27811 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
27812 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
27813 clientIds: clientIds
27814 })
27815 });
27816 }
27817
27818 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js
27819 /**
27820 * WordPress dependencies
27821 */
27822
27823
27824
27825
27826
27827
27828 /**
27829 * This listener hook monitors for block selection and triggers the appropriate
27830 * sidebar state.
27831 */
27832 function useAutoSwitchEditorSidebars() {
27833 const {
27834 hasBlockSelection
27835 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27836 return {
27837 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
27838 };
27839 }, []);
27840 const {
27841 getActiveComplementaryArea
27842 } = (0,external_wp_data_namespaceObject.useSelect)(store);
27843 const {
27844 enableComplementaryArea
27845 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27846 const {
27847 get: getPreference
27848 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
27849 (0,external_wp_element_namespaceObject.useEffect)(() => {
27850 const activeGeneralSidebar = getActiveComplementaryArea('core');
27851 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
27852 const isDistractionFree = getPreference('core', 'distractionFree');
27853 if (!isEditorSidebarOpened || isDistractionFree) {
27854 return;
27855 }
27856 if (hasBlockSelection) {
27857 enableComplementaryArea('core', 'edit-post/block');
27858 } else {
27859 enableComplementaryArea('core', 'edit-post/document');
27860 }
27861 }, [hasBlockSelection, getActiveComplementaryArea, enableComplementaryArea, getPreference]);
27862 }
27863 /* harmony default export */ const use_auto_switch_editor_sidebars = (useAutoSwitchEditorSidebars);
27864
27865 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/index.js
27866 /**
27867 * WordPress dependencies
27868 */
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878 /**
27879 * Internal dependencies
27880 */
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896 const {
27897 Tabs: sidebar_Tabs
27898 } = unlock(external_wp_components_namespaceObject.privateApis);
27899 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
27900 web: true,
27901 native: false
27902 });
27903 const SidebarContent = ({
27904 tabName,
27905 keyboardShortcut,
27906 renderingMode,
27907 onActionPerformed,
27908 extraPanels
27909 }) => {
27910 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null);
27911 // Because `PluginSidebar` renders a `ComplementaryArea`, we
27912 // need to forward the `Tabs` context so it can be passed through the
27913 // underlying slot/fill.
27914 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_Tabs.Context);
27915
27916 // This effect addresses a race condition caused by tabbing from the last
27917 // block in the editor into the settings sidebar. Without this effect, the
27918 // selected tab and browser focus can become separated in an unexpected way
27919 // (e.g the "block" tab is focused, but the "post" tab is selected).
27920 (0,external_wp_element_namespaceObject.useEffect)(() => {
27921 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
27922 const selectedTabElement = tabsElements.find(
27923 // We are purposefully using a custom `data-tab-id` attribute here
27924 // because we don't want rely on any assumptions about `Tabs`
27925 // component internals.
27926 element => element.getAttribute('data-tab-id') === tabName);
27927 const activeElement = selectedTabElement?.ownerDocument.activeElement;
27928 const tabsHasFocus = tabsElements.some(element => {
27929 return activeElement && activeElement.id === element.id;
27930 });
27931 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
27932 selectedTabElement?.focus();
27933 }
27934 }, [tabName]);
27935 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
27936 identifier: tabName,
27937 header: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.Context.Provider, {
27938 value: tabsContextValue,
27939 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_header, {
27940 ref: tabListRef
27941 })
27942 }),
27943 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings')
27944 // This classname is added so we can apply a corrective negative
27945 // margin to the panel.
27946 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
27947 ,
27948 className: "editor-sidebar__panel",
27949 headerClassName: "editor-sidebar__panel-tabs"
27950 /* translators: button label text should, if possible, be under 16 characters. */,
27951 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
27952 toggleShortcut: keyboardShortcut,
27953 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
27954 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
27955 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.Context.Provider, {
27956 value: tabsContextValue,
27957 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.TabPanel, {
27958 tabId: sidebars.document,
27959 focusable: false,
27960 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSummary, {
27961 onActionPerformed: onActionPerformed
27962 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel.Slot, {}), renderingMode !== 'post-only' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransformPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesPanel, {}), extraPanels]
27963 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.TabPanel, {
27964 tabId: sidebars.block,
27965 focusable: false,
27966 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {})
27967 })]
27968 })
27969 });
27970 };
27971 const Sidebar = ({
27972 extraPanels,
27973 onActionPerformed
27974 }) => {
27975 use_auto_switch_editor_sidebars();
27976 const {
27977 tabName,
27978 keyboardShortcut,
27979 showSummary,
27980 renderingMode
27981 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27982 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar');
27983 const sidebar = select(store).getActiveComplementaryArea('core');
27984 const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
27985 let _tabName = sidebar;
27986 if (!_isEditorSidebarOpened) {
27987 _tabName = !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() ? sidebars.block : sidebars.document;
27988 }
27989 return {
27990 tabName: _tabName,
27991 keyboardShortcut: shortcut,
27992 showSummary: ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE].includes(select(store_store).getCurrentPostType()),
27993 renderingMode: select(store_store).getRenderingMode()
27994 };
27995 }, []);
27996 const {
27997 enableComplementaryArea
27998 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27999 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => {
28000 if (!!newSelectedTabId) {
28001 enableComplementaryArea('core', newSelectedTabId);
28002 }
28003 }, [enableComplementaryArea]);
28004 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs, {
28005 selectedTabId: tabName,
28006 onSelect: onTabSelect,
28007 selectOnMove: false,
28008 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarContent, {
28009 tabName: tabName,
28010 keyboardShortcut: keyboardShortcut,
28011 showSummary: showSummary,
28012 renderingMode: renderingMode,
28013 onActionPerformed: onActionPerformed,
28014 extraPanels: extraPanels
28015 })
28016 });
28017 };
28018 /* harmony default export */ const components_sidebar = (Sidebar);
28019
28020 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor/index.js
28021 /**
28022 * WordPress dependencies
28023 */
28024
28025
28026
28027
28028
28029 /**
28030 * Internal dependencies
28031 */
28032
28033
28034
28035
28036
28037
28038
28039 function Editor({
28040 postType,
28041 postId,
28042 templateId,
28043 settings,
28044 children,
28045 initialEdits,
28046 // This could be part of the settings.
28047 onActionPerformed,
28048 // The following abstractions are not ideal but necessary
28049 // to account for site editor and post editor differences for now.
28050 extraContent,
28051 extraSidebarPanels,
28052 ...props
28053 }) {
28054 const {
28055 post,
28056 template,
28057 hasLoadedPost
28058 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28059 const {
28060 getEntityRecord,
28061 hasFinishedResolution
28062 } = select(external_wp_coreData_namespaceObject.store);
28063 return {
28064 post: getEntityRecord('postType', postType, postId),
28065 template: templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId) : undefined,
28066 hasLoadedPost: hasFinishedResolution('getEntityRecord', ['postType', postType, postId])
28067 };
28068 }, [postType, postId, templateId]);
28069 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28070 children: [hasLoadedPost && !post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
28071 status: "warning",
28072 isDismissible: false,
28073 children: (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")
28074 }), !!post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ExperimentalEditorProvider, {
28075 post: post,
28076 __unstableTemplate: template,
28077 settings: settings,
28078 initialEdits: initialEdits,
28079 useSubRegistry: false,
28080 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorInterface, {
28081 ...props,
28082 children: extraContent
28083 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_sidebar, {
28084 onActionPerformed: onActionPerformed,
28085 extraPanels: extraSidebarPanels
28086 }), children]
28087 })]
28088 });
28089 }
28090 /* harmony default export */ const editor = (Editor);
28091
28092 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js
28093 /**
28094 * WordPress dependencies
28095 */
28096
28097
28098
28099
28100 /**
28101 * Internal dependencies
28102 */
28103
28104
28105 const {
28106 PreferenceBaseOption: enable_publish_sidebar_PreferenceBaseOption
28107 } = unlock(external_wp_preferences_namespaceObject.privateApis);
28108 /* harmony default export */ const enable_publish_sidebar = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
28109 isChecked: select(store_store).isPublishSidebarEnabled()
28110 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
28111 const {
28112 enablePublishSidebar,
28113 disablePublishSidebar
28114 } = dispatch(store_store);
28115 return {
28116 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar()
28117 };
28118 }))(enable_publish_sidebar_PreferenceBaseOption));
28119
28120 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/checklist.js
28121 /**
28122 * WordPress dependencies
28123 */
28124
28125
28126
28127
28128 function BlockTypesChecklist({
28129 blockTypes,
28130 value,
28131 onItemChange
28132 }) {
28133 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
28134 className: "editor-block-manager__checklist",
28135 children: blockTypes.map(blockType => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
28136 className: "editor-block-manager__checklist-item",
28137 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
28138 __nextHasNoMarginBottom: true,
28139 label: blockType.title,
28140 checked: value.includes(blockType.name),
28141 onChange: (...args) => onItemChange(blockType.name, ...args)
28142 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
28143 icon: blockType.icon
28144 })]
28145 }, blockType.name))
28146 });
28147 }
28148 /* harmony default export */ const checklist = (BlockTypesChecklist);
28149
28150 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/category.js
28151 /**
28152 * WordPress dependencies
28153 */
28154
28155
28156
28157
28158
28159
28160 /**
28161 * Internal dependencies
28162 */
28163
28164
28165
28166
28167
28168 function BlockManagerCategory({
28169 title,
28170 blockTypes
28171 }) {
28172 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory);
28173 const {
28174 allowedBlockTypes,
28175 hiddenBlockTypes
28176 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28177 const {
28178 getEditorSettings
28179 } = select(store_store);
28180 const {
28181 get
28182 } = select(external_wp_preferences_namespaceObject.store);
28183 return {
28184 allowedBlockTypes: getEditorSettings().allowedBlockTypes,
28185 hiddenBlockTypes: get('core', 'hiddenBlockTypes')
28186 };
28187 }, []);
28188 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
28189 if (allowedBlockTypes === true) {
28190 return blockTypes;
28191 }
28192 return blockTypes.filter(({
28193 name
28194 }) => {
28195 return allowedBlockTypes?.includes(name);
28196 });
28197 }, [allowedBlockTypes, blockTypes]);
28198 const {
28199 showBlockTypes,
28200 hideBlockTypes
28201 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
28202 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => {
28203 if (nextIsChecked) {
28204 showBlockTypes(blockName);
28205 } else {
28206 hideBlockTypes(blockName);
28207 }
28208 }, [showBlockTypes, hideBlockTypes]);
28209 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => {
28210 const blockNames = blockTypes.map(({
28211 name
28212 }) => name);
28213 if (nextIsChecked) {
28214 showBlockTypes(blockNames);
28215 } else {
28216 hideBlockTypes(blockNames);
28217 }
28218 }, [blockTypes, showBlockTypes, hideBlockTypes]);
28219 if (!filteredBlockTypes.length) {
28220 return null;
28221 }
28222 const checkedBlockNames = filteredBlockTypes.map(({
28223 name
28224 }) => name).filter(type => !(hiddenBlockTypes !== null && hiddenBlockTypes !== void 0 ? hiddenBlockTypes : []).includes(type));
28225 const titleId = 'editor-block-manager__category-title-' + instanceId;
28226 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
28227 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0;
28228 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28229 role: "group",
28230 "aria-labelledby": titleId,
28231 className: "editor-block-manager__category",
28232 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
28233 __nextHasNoMarginBottom: true,
28234 checked: isAllChecked,
28235 onChange: toggleAllVisible,
28236 className: "editor-block-manager__category-title",
28237 indeterminate: isIndeterminate,
28238 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
28239 id: titleId,
28240 children: title
28241 })
28242 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(checklist, {
28243 blockTypes: filteredBlockTypes,
28244 value: checkedBlockNames,
28245 onItemChange: toggleVisible
28246 })]
28247 });
28248 }
28249 /* harmony default export */ const block_manager_category = (BlockManagerCategory);
28250
28251 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/index.js
28252 /**
28253 * WordPress dependencies
28254 */
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264 /**
28265 * Internal dependencies
28266 */
28267
28268
28269
28270
28271
28272 function BlockManager({
28273 blockTypes,
28274 categories,
28275 hasBlockSupport,
28276 isMatchingSearchTerm,
28277 numberOfHiddenBlocks,
28278 enableAllBlockTypes
28279 }) {
28280 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
28281 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
28282
28283 // Filtering occurs here (as opposed to `withSelect`) to avoid
28284 // wasted renders by consequence of `Array#filter` producing
28285 // a new value reference on each call.
28286 blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
28287
28288 // Announce search results on change
28289 (0,external_wp_element_namespaceObject.useEffect)(() => {
28290 if (!search) {
28291 return;
28292 }
28293 const count = blockTypes.length;
28294 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */
28295 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
28296 debouncedSpeak(resultsFoundMessage);
28297 }, [blockTypes.length, search, debouncedSpeak]);
28298 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28299 className: "editor-block-manager__content",
28300 children: [!!numberOfHiddenBlocks && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28301 className: "editor-block-manager__disabled-blocks-count",
28302 children: [(0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of blocks. */
28303 (0,external_wp_i18n_namespaceObject._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28304 variant: "link",
28305 onClick: () => enableAllBlockTypes(blockTypes),
28306 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
28307 })]
28308 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
28309 __nextHasNoMarginBottom: true,
28310 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
28311 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
28312 value: search,
28313 onChange: nextSearch => setSearch(nextSearch),
28314 className: "editor-block-manager__search"
28315 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28316 tabIndex: "0",
28317 role: "region",
28318 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'),
28319 className: "editor-block-manager__results",
28320 children: [blockTypes.length === 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
28321 className: "editor-block-manager__no-results",
28322 children: (0,external_wp_i18n_namespaceObject.__)('No blocks found.')
28323 }), categories.map(category => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
28324 title: category.title,
28325 blockTypes: blockTypes.filter(blockType => blockType.category === category.slug)
28326 }, category.slug)), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
28327 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'),
28328 blockTypes: blockTypes.filter(({
28329 category
28330 }) => !category)
28331 })]
28332 })]
28333 });
28334 }
28335 /* harmony default export */ const block_manager = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
28336 var _get;
28337 const {
28338 getBlockTypes,
28339 getCategories,
28340 hasBlockSupport,
28341 isMatchingSearchTerm
28342 } = select(external_wp_blocks_namespaceObject.store);
28343 const {
28344 get
28345 } = select(external_wp_preferences_namespaceObject.store);
28346
28347 // Some hidden blocks become unregistered
28348 // by removing for instance the plugin that registered them, yet
28349 // they're still remain as hidden by the user's action.
28350 // We consider "hidden", blocks which were hidden and
28351 // are still registered.
28352 const blockTypes = getBlockTypes();
28353 const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => {
28354 return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
28355 });
28356 const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length;
28357 return {
28358 blockTypes,
28359 categories: getCategories(),
28360 hasBlockSupport,
28361 isMatchingSearchTerm,
28362 numberOfHiddenBlocks
28363 };
28364 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
28365 const {
28366 showBlockTypes
28367 } = unlock(dispatch(store_store));
28368 return {
28369 enableAllBlockTypes: blockTypes => {
28370 const blockNames = blockTypes.map(({
28371 name
28372 }) => name);
28373 showBlockTypes(blockNames);
28374 }
28375 };
28376 })])(BlockManager));
28377
28378 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/index.js
28379 /**
28380 * WordPress dependencies
28381 */
28382
28383
28384
28385
28386
28387
28388
28389
28390 /**
28391 * Internal dependencies
28392 */
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407 const {
28408 PreferencesModal,
28409 PreferencesModalTabs,
28410 PreferencesModalSection,
28411 PreferenceToggleControl
28412 } = unlock(external_wp_preferences_namespaceObject.privateApis);
28413 function EditorPreferencesModal({
28414 extraSections = {}
28415 }) {
28416 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
28417 const {
28418 isActive,
28419 showBlockBreadcrumbsOption
28420 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28421 const {
28422 getEditorSettings
28423 } = select(store_store);
28424 const {
28425 get
28426 } = select(external_wp_preferences_namespaceObject.store);
28427 const {
28428 isModalActive
28429 } = select(store);
28430 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
28431 const isDistractionFreeEnabled = get('core', 'distractionFree');
28432 return {
28433 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
28434 isActive: isModalActive('editor/preferences')
28435 };
28436 }, [isLargeViewport]);
28437 const {
28438 closeModal
28439 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28440 const {
28441 setIsListViewOpened,
28442 setIsInserterOpened
28443 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
28444 const {
28445 set: setPreference
28446 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
28447 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
28448 name: 'general',
28449 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
28450 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28451 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28452 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
28453 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28454 scope: "core",
28455 featureName: "showListViewByDefault",
28456 help: (0,external_wp_i18n_namespaceObject.__)('Opens the List View sidebar by default.'),
28457 label: (0,external_wp_i18n_namespaceObject.__)('Always open List View')
28458 }), showBlockBreadcrumbsOption && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28459 scope: "core",
28460 featureName: "showBlockBreadcrumbs",
28461 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'),
28462 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs')
28463 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28464 scope: "core",
28465 featureName: "allowRightClickOverrides",
28466 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual List View menus via right-click, overriding browser defaults.'),
28467 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus')
28468 })]
28469 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28470 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
28471 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.'),
28472 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
28473 taxonomyWrapper: (content, taxonomy) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28474 label: taxonomy.labels.menu_name,
28475 panelName: `taxonomy-panel-${taxonomy.slug}`
28476 })
28477 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
28478 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28479 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
28480 panelName: "featured-image"
28481 })
28482 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
28483 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28484 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
28485 panelName: "post-excerpt"
28486 })
28487 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
28488 supportKeys: ['comments', 'trackbacks'],
28489 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28490 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
28491 panelName: "discussion-panel"
28492 })
28493 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
28494 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28495 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
28496 panelName: "page-attributes"
28497 })
28498 })]
28499 }), isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28500 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
28501 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_publish_sidebar, {
28502 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
28503 label: (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks')
28504 })
28505 }), extraSections?.general]
28506 })
28507 }, {
28508 name: 'appearance',
28509 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
28510 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28511 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
28512 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.'),
28513 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28514 scope: "core",
28515 featureName: "fixedToolbar",
28516 onToggle: () => setPreference('core', 'distractionFree', false),
28517 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'),
28518 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar')
28519 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28520 scope: "core",
28521 featureName: "distractionFree",
28522 onToggle: () => {
28523 setPreference('core', 'fixedToolbar', true);
28524 setIsInserterOpened(false);
28525 setIsListViewOpened(false);
28526 },
28527 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'),
28528 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free')
28529 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28530 scope: "core",
28531 featureName: "focusMode",
28532 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
28533 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
28534 }), extraSections?.appearance]
28535 })
28536 }, {
28537 name: 'accessibility',
28538 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'),
28539 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28540 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28541 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
28542 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.'),
28543 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28544 scope: "core",
28545 featureName: "keepCaretInsideBlock",
28546 help: (0,external_wp_i18n_namespaceObject.__)('Keeps the text cursor within the block boundaries, aiding users with screen readers by preventing unintentional cursor movement outside the block.'),
28547 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
28548 })
28549 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28550 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
28551 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28552 scope: "core",
28553 featureName: "showIconLabels",
28554 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
28555 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.')
28556 })
28557 })]
28558 })
28559 }, {
28560 name: 'blocks',
28561 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
28562 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28563 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28564 title: (0,external_wp_i18n_namespaceObject.__)('Inserter'),
28565 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28566 scope: "core",
28567 featureName: "mostUsedBlocks",
28568 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'),
28569 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
28570 })
28571 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28572 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'),
28573 description: (0,external_wp_i18n_namespaceObject.__)("Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."),
28574 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager, {})
28575 })]
28576 })
28577 }], [showBlockBreadcrumbsOption, extraSections, setIsInserterOpened, setIsListViewOpened, setPreference, isLargeViewport]);
28578 if (!isActive) {
28579 return null;
28580 }
28581 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
28582 closeModal: closeModal,
28583 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalTabs, {
28584 sections: sections
28585 })
28586 });
28587 }
28588
28589 ;// CONCATENATED MODULE: ./packages/editor/build-module/private-apis.js
28590 /**
28591 * WordPress dependencies
28592 */
28593
28594
28595 /**
28596 * Internal dependencies
28597 */
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612 const {
28613 store: interfaceStore,
28614 ...remainingInterfaceApis
28615 } = build_module_namespaceObject;
28616 const privateApis = {};
28617 lock(privateApis, {
28618 CreateTemplatePartModal: CreateTemplatePartModal,
28619 BackButton: back_button,
28620 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible,
28621 Editor: editor,
28622 EditorContentSlotFill: content_slot_fill,
28623 GlobalStylesProvider: GlobalStylesProvider,
28624 mergeBaseAndUserConfigs: mergeBaseAndUserConfigs,
28625 PluginPostExcerpt: post_excerpt_plugin,
28626 PreferencesModal: EditorPreferencesModal,
28627 usePostActions: usePostActions,
28628 ToolsMoreMenuGroup: tools_more_menu_group,
28629 ViewMoreMenuGroup: view_more_menu_group,
28630 ResizableEditor: resizable_editor,
28631 // This is a temporary private API while we're updating the site editor to use EditorProvider.
28632 useBlockEditorSettings: use_block_editor_settings,
28633 interfaceStore,
28634 ...remainingInterfaceApis
28635 });
28636
28637 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/api.js
28638 /**
28639 * WordPress dependencies
28640 */
28641
28642
28643 /**
28644 * Internal dependencies
28645 */
28646
28647
28648
28649 /**
28650 * @typedef {import('@wordpress/dataviews').Action} Action
28651 */
28652
28653 /**
28654 * Registers a new DataViews action.
28655 *
28656 * This is an experimental API and is subject to change.
28657 * it's only available in the Gutenberg plugin for now.
28658 *
28659 * @param {string} kind Entity kind.
28660 * @param {string} name Entity name.
28661 * @param {Action} config Action configuration.
28662 */
28663
28664 function api_registerEntityAction(kind, name, config) {
28665 const {
28666 registerEntityAction: _registerEntityAction
28667 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
28668 if (true) {
28669 _registerEntityAction(kind, name, config);
28670 }
28671 }
28672
28673 /**
28674 * Unregisters a DataViews action.
28675 *
28676 * This is an experimental API and is subject to change.
28677 * it's only available in the Gutenberg plugin for now.
28678 *
28679 * @param {string} kind Entity kind.
28680 * @param {string} name Entity name.
28681 * @param {string} actionId Action ID.
28682 */
28683 function api_unregisterEntityAction(kind, name, actionId) {
28684 const {
28685 unregisterEntityAction: _unregisterEntityAction
28686 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
28687 if (true) {
28688 _unregisterEntityAction(kind, name, actionId);
28689 }
28690 }
28691
28692 ;// CONCATENATED MODULE: ./packages/editor/build-module/index.js
28693 /**
28694 * Internal dependencies
28695 */
28696
28697
28698
28699
28700
28701
28702
28703
28704 /*
28705 * Backward compatibility
28706 */
28707
28708
28709 })();
28710
28711 (window.wp = window.wp || {}).editor = __webpack_exports__;
28712 /******/ })()
28713 ;