PluginProbe
Gutenberg / 20.0.4
Gutenberg v20.0.4
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / editor / index.js

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

34,333 lines 1.1 MB
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 /***/ 4306:
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 /***/ 6109:
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 /***/ 66:
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 /***/ 5215:
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 /***/ 461:
523 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
524
525 // Load in dependencies
526 var computedStyle = __webpack_require__(6109);
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 /***/ 628:
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__(4067);
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 /***/ 5826:
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__(628)();
713 }
714
715
716 /***/ }),
717
718 /***/ 4067:
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 /***/ 4462:
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__(1609);
772 var PropTypes = __webpack_require__(5826);
773 var autosize = __webpack_require__(4306);
774 var _getLineHeight = __webpack_require__(461);
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 /***/ 4132:
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__(4462);
880 exports.A = TextareaAutosize_1.TextareaAutosize;
881
882
883 /***/ }),
884
885 /***/ 9681:
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 /***/ 1609:
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 needs to be wrapped in an IIFE because it needs 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 */ PluginMoreMenuItem),
1514 PluginPostPublishPanel: () => (/* reexport */ plugin_post_publish_panel),
1515 PluginPostStatusInfo: () => (/* reexport */ plugin_post_status_info),
1516 PluginPrePublishPanel: () => (/* reexport */ plugin_pre_publish_panel),
1517 PluginPreviewMenuItem: () => (/* reexport */ PluginPreviewMenuItem),
1518 PluginSidebar: () => (/* reexport */ PluginSidebar),
1519 PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem),
1520 PostAuthor: () => (/* reexport */ post_author),
1521 PostAuthorCheck: () => (/* reexport */ PostAuthorCheck),
1522 PostAuthorPanel: () => (/* reexport */ panel),
1523 PostComments: () => (/* reexport */ post_comments),
1524 PostDiscussionPanel: () => (/* reexport */ PostDiscussionPanel),
1525 PostExcerpt: () => (/* reexport */ PostExcerpt),
1526 PostExcerptCheck: () => (/* reexport */ post_excerpt_check),
1527 PostExcerptPanel: () => (/* reexport */ PostExcerptPanel),
1528 PostFeaturedImage: () => (/* reexport */ post_featured_image),
1529 PostFeaturedImageCheck: () => (/* reexport */ post_featured_image_check),
1530 PostFeaturedImagePanel: () => (/* reexport */ PostFeaturedImagePanel),
1531 PostFormat: () => (/* reexport */ PostFormat),
1532 PostFormatCheck: () => (/* reexport */ PostFormatCheck),
1533 PostLastRevision: () => (/* reexport */ post_last_revision),
1534 PostLastRevisionCheck: () => (/* reexport */ post_last_revision_check),
1535 PostLastRevisionPanel: () => (/* reexport */ post_last_revision_panel),
1536 PostLockedModal: () => (/* reexport */ PostLockedModal),
1537 PostPendingStatus: () => (/* reexport */ post_pending_status),
1538 PostPendingStatusCheck: () => (/* reexport */ post_pending_status_check),
1539 PostPingbacks: () => (/* reexport */ post_pingbacks),
1540 PostPreviewButton: () => (/* reexport */ PostPreviewButton),
1541 PostPublishButton: () => (/* reexport */ post_publish_button),
1542 PostPublishButtonLabel: () => (/* reexport */ PublishButtonLabel),
1543 PostPublishPanel: () => (/* reexport */ post_publish_panel),
1544 PostSavedState: () => (/* reexport */ PostSavedState),
1545 PostSchedule: () => (/* reexport */ PostSchedule),
1546 PostScheduleCheck: () => (/* reexport */ PostScheduleCheck),
1547 PostScheduleLabel: () => (/* reexport */ PostScheduleLabel),
1548 PostSchedulePanel: () => (/* reexport */ PostSchedulePanel),
1549 PostSticky: () => (/* reexport */ PostSticky),
1550 PostStickyCheck: () => (/* reexport */ PostStickyCheck),
1551 PostSwitchToDraftButton: () => (/* reexport */ PostSwitchToDraftButton),
1552 PostSyncStatus: () => (/* reexport */ PostSyncStatus),
1553 PostTaxonomies: () => (/* reexport */ post_taxonomies),
1554 PostTaxonomiesCheck: () => (/* reexport */ PostTaxonomiesCheck),
1555 PostTaxonomiesFlatTermSelector: () => (/* reexport */ FlatTermSelector),
1556 PostTaxonomiesHierarchicalTermSelector: () => (/* reexport */ HierarchicalTermSelector),
1557 PostTaxonomiesPanel: () => (/* reexport */ panel_PostTaxonomies),
1558 PostTemplatePanel: () => (/* reexport */ PostTemplatePanel),
1559 PostTextEditor: () => (/* reexport */ PostTextEditor),
1560 PostTitle: () => (/* reexport */ post_title),
1561 PostTitleRaw: () => (/* reexport */ post_title_raw),
1562 PostTrash: () => (/* reexport */ PostTrash),
1563 PostTrashCheck: () => (/* reexport */ PostTrashCheck),
1564 PostTypeSupportCheck: () => (/* reexport */ post_type_support_check),
1565 PostURL: () => (/* reexport */ PostURL),
1566 PostURLCheck: () => (/* reexport */ PostURLCheck),
1567 PostURLLabel: () => (/* reexport */ PostURLLabel),
1568 PostURLPanel: () => (/* reexport */ PostURLPanel),
1569 PostVisibility: () => (/* reexport */ PostVisibility),
1570 PostVisibilityCheck: () => (/* reexport */ PostVisibilityCheck),
1571 PostVisibilityLabel: () => (/* reexport */ PostVisibilityLabel),
1572 RichText: () => (/* reexport */ RichText),
1573 RichTextShortcut: () => (/* reexport */ RichTextShortcut),
1574 RichTextToolbarButton: () => (/* reexport */ RichTextToolbarButton),
1575 ServerSideRender: () => (/* reexport */ (external_wp_serverSideRender_default())),
1576 SkipToSelectedBlock: () => (/* reexport */ SkipToSelectedBlock),
1577 TableOfContents: () => (/* reexport */ table_of_contents),
1578 TextEditorGlobalKeyboardShortcuts: () => (/* reexport */ TextEditorGlobalKeyboardShortcuts),
1579 ThemeSupportCheck: () => (/* reexport */ ThemeSupportCheck),
1580 TimeToRead: () => (/* reexport */ TimeToRead),
1581 URLInput: () => (/* reexport */ URLInput),
1582 URLInputButton: () => (/* reexport */ URLInputButton),
1583 URLPopover: () => (/* reexport */ URLPopover),
1584 UnsavedChangesWarning: () => (/* reexport */ UnsavedChangesWarning),
1585 VisualEditorGlobalKeyboardShortcuts: () => (/* reexport */ VisualEditorGlobalKeyboardShortcuts),
1586 Warning: () => (/* reexport */ Warning),
1587 WordCount: () => (/* reexport */ WordCount),
1588 WritingFlow: () => (/* reexport */ WritingFlow),
1589 __unstableRichTextInputEvent: () => (/* reexport */ __unstableRichTextInputEvent),
1590 cleanForSlug: () => (/* reexport */ cleanForSlug),
1591 createCustomColorsHOC: () => (/* reexport */ createCustomColorsHOC),
1592 getColorClassName: () => (/* reexport */ getColorClassName),
1593 getColorObjectByAttributeValues: () => (/* reexport */ getColorObjectByAttributeValues),
1594 getColorObjectByColorValue: () => (/* reexport */ getColorObjectByColorValue),
1595 getFontSize: () => (/* reexport */ getFontSize),
1596 getFontSizeClass: () => (/* reexport */ getFontSizeClass),
1597 getTemplatePartIcon: () => (/* reexport */ getTemplatePartIcon),
1598 mediaUpload: () => (/* reexport */ mediaUpload),
1599 privateApis: () => (/* reexport */ privateApis),
1600 registerEntityAction: () => (/* reexport */ api_registerEntityAction),
1601 registerEntityField: () => (/* reexport */ api_registerEntityField),
1602 store: () => (/* reexport */ store_store),
1603 storeConfig: () => (/* reexport */ storeConfig),
1604 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
1605 unregisterEntityAction: () => (/* reexport */ api_unregisterEntityAction),
1606 unregisterEntityField: () => (/* reexport */ api_unregisterEntityField),
1607 useEntitiesSavedStatesIsDirty: () => (/* reexport */ useIsDirty),
1608 usePostScheduleLabel: () => (/* reexport */ usePostScheduleLabel),
1609 usePostURLLabel: () => (/* reexport */ usePostURLLabel),
1610 usePostVisibilityLabel: () => (/* reexport */ usePostVisibilityLabel),
1611 userAutocompleter: () => (/* reexport */ user),
1612 withColorContext: () => (/* reexport */ withColorContext),
1613 withColors: () => (/* reexport */ withColors),
1614 withFontSizes: () => (/* reexport */ withFontSizes)
1615 });
1616
1617 // NAMESPACE OBJECT: ./packages/editor/build-module/store/selectors.js
1618 var selectors_namespaceObject = {};
1619 __webpack_require__.r(selectors_namespaceObject);
1620 __webpack_require__.d(selectors_namespaceObject, {
1621 __experimentalGetDefaultTemplatePartAreas: () => (__experimentalGetDefaultTemplatePartAreas),
1622 __experimentalGetDefaultTemplateType: () => (__experimentalGetDefaultTemplateType),
1623 __experimentalGetDefaultTemplateTypes: () => (__experimentalGetDefaultTemplateTypes),
1624 __experimentalGetTemplateInfo: () => (__experimentalGetTemplateInfo),
1625 __unstableIsEditorReady: () => (__unstableIsEditorReady),
1626 canInsertBlockType: () => (canInsertBlockType),
1627 canUserUseUnfilteredHTML: () => (canUserUseUnfilteredHTML),
1628 didPostSaveRequestFail: () => (didPostSaveRequestFail),
1629 didPostSaveRequestSucceed: () => (didPostSaveRequestSucceed),
1630 getActivePostLock: () => (getActivePostLock),
1631 getAdjacentBlockClientId: () => (getAdjacentBlockClientId),
1632 getAutosaveAttribute: () => (getAutosaveAttribute),
1633 getBlock: () => (getBlock),
1634 getBlockAttributes: () => (getBlockAttributes),
1635 getBlockCount: () => (getBlockCount),
1636 getBlockHierarchyRootClientId: () => (getBlockHierarchyRootClientId),
1637 getBlockIndex: () => (getBlockIndex),
1638 getBlockInsertionPoint: () => (getBlockInsertionPoint),
1639 getBlockListSettings: () => (getBlockListSettings),
1640 getBlockMode: () => (getBlockMode),
1641 getBlockName: () => (getBlockName),
1642 getBlockOrder: () => (getBlockOrder),
1643 getBlockRootClientId: () => (getBlockRootClientId),
1644 getBlockSelectionEnd: () => (getBlockSelectionEnd),
1645 getBlockSelectionStart: () => (getBlockSelectionStart),
1646 getBlocks: () => (getBlocks),
1647 getBlocksByClientId: () => (getBlocksByClientId),
1648 getClientIdsOfDescendants: () => (getClientIdsOfDescendants),
1649 getClientIdsWithDescendants: () => (getClientIdsWithDescendants),
1650 getCurrentPost: () => (getCurrentPost),
1651 getCurrentPostAttribute: () => (getCurrentPostAttribute),
1652 getCurrentPostId: () => (getCurrentPostId),
1653 getCurrentPostLastRevisionId: () => (getCurrentPostLastRevisionId),
1654 getCurrentPostRevisionsCount: () => (getCurrentPostRevisionsCount),
1655 getCurrentPostType: () => (getCurrentPostType),
1656 getCurrentTemplateId: () => (getCurrentTemplateId),
1657 getDeviceType: () => (getDeviceType),
1658 getEditedPostAttribute: () => (getEditedPostAttribute),
1659 getEditedPostContent: () => (getEditedPostContent),
1660 getEditedPostPreviewLink: () => (getEditedPostPreviewLink),
1661 getEditedPostSlug: () => (getEditedPostSlug),
1662 getEditedPostVisibility: () => (getEditedPostVisibility),
1663 getEditorBlocks: () => (getEditorBlocks),
1664 getEditorMode: () => (getEditorMode),
1665 getEditorSelection: () => (getEditorSelection),
1666 getEditorSelectionEnd: () => (getEditorSelectionEnd),
1667 getEditorSelectionStart: () => (getEditorSelectionStart),
1668 getEditorSettings: () => (getEditorSettings),
1669 getFirstMultiSelectedBlockClientId: () => (getFirstMultiSelectedBlockClientId),
1670 getGlobalBlockCount: () => (getGlobalBlockCount),
1671 getInserterItems: () => (getInserterItems),
1672 getLastMultiSelectedBlockClientId: () => (getLastMultiSelectedBlockClientId),
1673 getMultiSelectedBlockClientIds: () => (getMultiSelectedBlockClientIds),
1674 getMultiSelectedBlocks: () => (getMultiSelectedBlocks),
1675 getMultiSelectedBlocksEndClientId: () => (getMultiSelectedBlocksEndClientId),
1676 getMultiSelectedBlocksStartClientId: () => (getMultiSelectedBlocksStartClientId),
1677 getNextBlockClientId: () => (getNextBlockClientId),
1678 getPermalink: () => (getPermalink),
1679 getPermalinkParts: () => (getPermalinkParts),
1680 getPostEdits: () => (getPostEdits),
1681 getPostLockUser: () => (getPostLockUser),
1682 getPostTypeLabel: () => (getPostTypeLabel),
1683 getPreviousBlockClientId: () => (getPreviousBlockClientId),
1684 getRenderingMode: () => (getRenderingMode),
1685 getSelectedBlock: () => (getSelectedBlock),
1686 getSelectedBlockClientId: () => (getSelectedBlockClientId),
1687 getSelectedBlockCount: () => (getSelectedBlockCount),
1688 getSelectedBlocksInitialCaretPosition: () => (getSelectedBlocksInitialCaretPosition),
1689 getStateBeforeOptimisticTransaction: () => (getStateBeforeOptimisticTransaction),
1690 getSuggestedPostFormat: () => (getSuggestedPostFormat),
1691 getTemplate: () => (getTemplate),
1692 getTemplateLock: () => (getTemplateLock),
1693 hasChangedContent: () => (hasChangedContent),
1694 hasEditorRedo: () => (hasEditorRedo),
1695 hasEditorUndo: () => (hasEditorUndo),
1696 hasInserterItems: () => (hasInserterItems),
1697 hasMultiSelection: () => (hasMultiSelection),
1698 hasNonPostEntityChanges: () => (hasNonPostEntityChanges),
1699 hasSelectedBlock: () => (hasSelectedBlock),
1700 hasSelectedInnerBlock: () => (hasSelectedInnerBlock),
1701 inSomeHistory: () => (inSomeHistory),
1702 isAncestorMultiSelected: () => (isAncestorMultiSelected),
1703 isAutosavingPost: () => (isAutosavingPost),
1704 isBlockInsertionPointVisible: () => (isBlockInsertionPointVisible),
1705 isBlockMultiSelected: () => (isBlockMultiSelected),
1706 isBlockSelected: () => (isBlockSelected),
1707 isBlockValid: () => (isBlockValid),
1708 isBlockWithinSelection: () => (isBlockWithinSelection),
1709 isCaretWithinFormattedText: () => (isCaretWithinFormattedText),
1710 isCleanNewPost: () => (isCleanNewPost),
1711 isCurrentPostPending: () => (isCurrentPostPending),
1712 isCurrentPostPublished: () => (isCurrentPostPublished),
1713 isCurrentPostScheduled: () => (isCurrentPostScheduled),
1714 isDeletingPost: () => (isDeletingPost),
1715 isEditedPostAutosaveable: () => (isEditedPostAutosaveable),
1716 isEditedPostBeingScheduled: () => (isEditedPostBeingScheduled),
1717 isEditedPostDateFloating: () => (isEditedPostDateFloating),
1718 isEditedPostDirty: () => (isEditedPostDirty),
1719 isEditedPostEmpty: () => (isEditedPostEmpty),
1720 isEditedPostNew: () => (isEditedPostNew),
1721 isEditedPostPublishable: () => (isEditedPostPublishable),
1722 isEditedPostSaveable: () => (isEditedPostSaveable),
1723 isEditorPanelEnabled: () => (isEditorPanelEnabled),
1724 isEditorPanelOpened: () => (isEditorPanelOpened),
1725 isEditorPanelRemoved: () => (isEditorPanelRemoved),
1726 isFirstMultiSelectedBlock: () => (isFirstMultiSelectedBlock),
1727 isInserterOpened: () => (isInserterOpened),
1728 isListViewOpened: () => (isListViewOpened),
1729 isMultiSelecting: () => (isMultiSelecting),
1730 isPermalinkEditable: () => (isPermalinkEditable),
1731 isPostAutosavingLocked: () => (isPostAutosavingLocked),
1732 isPostLockTakeover: () => (isPostLockTakeover),
1733 isPostLocked: () => (isPostLocked),
1734 isPostSavingLocked: () => (isPostSavingLocked),
1735 isPreviewingPost: () => (isPreviewingPost),
1736 isPublishSidebarEnabled: () => (isPublishSidebarEnabled),
1737 isPublishSidebarOpened: () => (isPublishSidebarOpened),
1738 isPublishingPost: () => (isPublishingPost),
1739 isSavingNonPostEntityChanges: () => (isSavingNonPostEntityChanges),
1740 isSavingPost: () => (isSavingPost),
1741 isSelectionEnabled: () => (isSelectionEnabled),
1742 isTyping: () => (isTyping),
1743 isValidTemplate: () => (isValidTemplate)
1744 });
1745
1746 // NAMESPACE OBJECT: ./packages/editor/build-module/store/actions.js
1747 var actions_namespaceObject = {};
1748 __webpack_require__.r(actions_namespaceObject);
1749 __webpack_require__.d(actions_namespaceObject, {
1750 __experimentalTearDownEditor: () => (__experimentalTearDownEditor),
1751 __unstableSaveForPreview: () => (__unstableSaveForPreview),
1752 autosave: () => (autosave),
1753 clearSelectedBlock: () => (clearSelectedBlock),
1754 closePublishSidebar: () => (closePublishSidebar),
1755 createUndoLevel: () => (createUndoLevel),
1756 disablePublishSidebar: () => (disablePublishSidebar),
1757 editPost: () => (editPost),
1758 enablePublishSidebar: () => (enablePublishSidebar),
1759 enterFormattedText: () => (enterFormattedText),
1760 exitFormattedText: () => (exitFormattedText),
1761 hideInsertionPoint: () => (hideInsertionPoint),
1762 insertBlock: () => (insertBlock),
1763 insertBlocks: () => (insertBlocks),
1764 insertDefaultBlock: () => (insertDefaultBlock),
1765 lockPostAutosaving: () => (lockPostAutosaving),
1766 lockPostSaving: () => (lockPostSaving),
1767 mergeBlocks: () => (mergeBlocks),
1768 moveBlockToPosition: () => (moveBlockToPosition),
1769 moveBlocksDown: () => (moveBlocksDown),
1770 moveBlocksUp: () => (moveBlocksUp),
1771 multiSelect: () => (multiSelect),
1772 openPublishSidebar: () => (openPublishSidebar),
1773 receiveBlocks: () => (receiveBlocks),
1774 redo: () => (redo),
1775 refreshPost: () => (refreshPost),
1776 removeBlock: () => (removeBlock),
1777 removeBlocks: () => (removeBlocks),
1778 removeEditorPanel: () => (removeEditorPanel),
1779 replaceBlock: () => (replaceBlock),
1780 replaceBlocks: () => (replaceBlocks),
1781 resetBlocks: () => (resetBlocks),
1782 resetEditorBlocks: () => (resetEditorBlocks),
1783 resetPost: () => (resetPost),
1784 savePost: () => (savePost),
1785 selectBlock: () => (selectBlock),
1786 setDeviceType: () => (setDeviceType),
1787 setEditedPost: () => (setEditedPost),
1788 setIsInserterOpened: () => (setIsInserterOpened),
1789 setIsListViewOpened: () => (setIsListViewOpened),
1790 setRenderingMode: () => (setRenderingMode),
1791 setTemplateValidity: () => (setTemplateValidity),
1792 setupEditor: () => (setupEditor),
1793 setupEditorState: () => (setupEditorState),
1794 showInsertionPoint: () => (showInsertionPoint),
1795 startMultiSelect: () => (startMultiSelect),
1796 startTyping: () => (startTyping),
1797 stopMultiSelect: () => (stopMultiSelect),
1798 stopTyping: () => (stopTyping),
1799 switchEditorMode: () => (switchEditorMode),
1800 synchronizeTemplate: () => (synchronizeTemplate),
1801 toggleBlockMode: () => (toggleBlockMode),
1802 toggleDistractionFree: () => (toggleDistractionFree),
1803 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled),
1804 toggleEditorPanelOpened: () => (toggleEditorPanelOpened),
1805 togglePublishSidebar: () => (togglePublishSidebar),
1806 toggleSelection: () => (toggleSelection),
1807 toggleSpotlightMode: () => (toggleSpotlightMode),
1808 toggleTopToolbar: () => (toggleTopToolbar),
1809 trashPost: () => (trashPost),
1810 undo: () => (undo),
1811 unlockPostAutosaving: () => (unlockPostAutosaving),
1812 unlockPostSaving: () => (unlockPostSaving),
1813 updateBlock: () => (updateBlock),
1814 updateBlockAttributes: () => (updateBlockAttributes),
1815 updateBlockListSettings: () => (updateBlockListSettings),
1816 updateEditorSettings: () => (updateEditorSettings),
1817 updatePost: () => (updatePost),
1818 updatePostLock: () => (updatePostLock)
1819 });
1820
1821 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-actions.js
1822 var store_private_actions_namespaceObject = {};
1823 __webpack_require__.r(store_private_actions_namespaceObject);
1824 __webpack_require__.d(store_private_actions_namespaceObject, {
1825 createTemplate: () => (createTemplate),
1826 hideBlockTypes: () => (hideBlockTypes),
1827 registerEntityAction: () => (registerEntityAction),
1828 registerEntityField: () => (registerEntityField),
1829 registerPostTypeSchema: () => (registerPostTypeSchema),
1830 removeTemplates: () => (removeTemplates),
1831 revertTemplate: () => (private_actions_revertTemplate),
1832 saveDirtyEntities: () => (saveDirtyEntities),
1833 setCurrentTemplateId: () => (setCurrentTemplateId),
1834 setIsReady: () => (setIsReady),
1835 showBlockTypes: () => (showBlockTypes),
1836 unregisterEntityAction: () => (unregisterEntityAction),
1837 unregisterEntityField: () => (unregisterEntityField)
1838 });
1839
1840 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-selectors.js
1841 var store_private_selectors_namespaceObject = {};
1842 __webpack_require__.r(store_private_selectors_namespaceObject);
1843 __webpack_require__.d(store_private_selectors_namespaceObject, {
1844 getEntityActions: () => (private_selectors_getEntityActions),
1845 getEntityFields: () => (private_selectors_getEntityFields),
1846 getInserter: () => (getInserter),
1847 getInserterSidebarToggleRef: () => (getInserterSidebarToggleRef),
1848 getListViewToggleRef: () => (getListViewToggleRef),
1849 getPostBlocksByName: () => (getPostBlocksByName),
1850 getPostIcon: () => (getPostIcon),
1851 hasPostMetaChanges: () => (hasPostMetaChanges),
1852 isEntityReady: () => (private_selectors_isEntityReady)
1853 });
1854
1855 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1856 var store_actions_namespaceObject = {};
1857 __webpack_require__.r(store_actions_namespaceObject);
1858 __webpack_require__.d(store_actions_namespaceObject, {
1859 closeModal: () => (closeModal),
1860 disableComplementaryArea: () => (disableComplementaryArea),
1861 enableComplementaryArea: () => (enableComplementaryArea),
1862 openModal: () => (openModal),
1863 pinItem: () => (pinItem),
1864 setDefaultComplementaryArea: () => (setDefaultComplementaryArea),
1865 setFeatureDefaults: () => (setFeatureDefaults),
1866 setFeatureValue: () => (setFeatureValue),
1867 toggleFeature: () => (toggleFeature),
1868 unpinItem: () => (unpinItem)
1869 });
1870
1871 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1872 var store_selectors_namespaceObject = {};
1873 __webpack_require__.r(store_selectors_namespaceObject);
1874 __webpack_require__.d(store_selectors_namespaceObject, {
1875 getActiveComplementaryArea: () => (getActiveComplementaryArea),
1876 isComplementaryAreaLoading: () => (isComplementaryAreaLoading),
1877 isFeatureActive: () => (isFeatureActive),
1878 isItemPinned: () => (isItemPinned),
1879 isModalActive: () => (isModalActive)
1880 });
1881
1882 // NAMESPACE OBJECT: ./packages/interface/build-module/index.js
1883 var build_module_namespaceObject = {};
1884 __webpack_require__.r(build_module_namespaceObject);
1885 __webpack_require__.d(build_module_namespaceObject, {
1886 ActionItem: () => (action_item),
1887 ComplementaryArea: () => (complementary_area),
1888 ComplementaryAreaMoreMenuItem: () => (ComplementaryAreaMoreMenuItem),
1889 FullscreenMode: () => (fullscreen_mode),
1890 InterfaceSkeleton: () => (interface_skeleton),
1891 NavigableRegion: () => (navigable_region),
1892 PinnedItems: () => (pinned_items),
1893 store: () => (store)
1894 });
1895
1896 ;// external ["wp","data"]
1897 const external_wp_data_namespaceObject = window["wp"]["data"];
1898 ;// external ["wp","coreData"]
1899 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1900 ;// external ["wp","element"]
1901 const external_wp_element_namespaceObject = window["wp"]["element"];
1902 ;// external ["wp","compose"]
1903 const external_wp_compose_namespaceObject = window["wp"]["compose"];
1904 ;// external ["wp","hooks"]
1905 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1906 ;// external ["wp","blockEditor"]
1907 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1908 ;// ./packages/editor/build-module/store/defaults.js
1909 /**
1910 * WordPress dependencies
1911 */
1912
1913
1914 /**
1915 * The default post editor settings.
1916 *
1917 * @property {boolean|Array} allowedBlockTypes Allowed block types
1918 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
1919 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
1920 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
1921 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
1922 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
1923 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
1924 * 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.
1925 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
1926 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
1927 * @property {Array?} availableTemplates The available post templates
1928 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
1929 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
1930 * @property {number} maxUploadFileSize Maximum upload file size
1931 * @property {boolean} supportsLayout Whether the editor supports layouts.
1932 */
1933 const EDITOR_SETTINGS_DEFAULTS = {
1934 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
1935 richEditingEnabled: true,
1936 codeEditingEnabled: true,
1937 fontLibraryEnabled: true,
1938 enableCustomFields: undefined,
1939 defaultRenderingMode: 'post-only'
1940 };
1941
1942 ;// ./packages/editor/build-module/dataviews/store/reducer.js
1943 /* wp:polyfill */
1944 /**
1945 * WordPress dependencies
1946 */
1947
1948 function isReady(state = {}, action) {
1949 switch (action.type) {
1950 case 'SET_IS_READY':
1951 return {
1952 ...state,
1953 [action.kind]: {
1954 ...state[action.kind],
1955 [action.name]: true
1956 }
1957 };
1958 }
1959 return state;
1960 }
1961 function actions(state = {}, action) {
1962 var _state$action$kind$ac;
1963 switch (action.type) {
1964 case 'REGISTER_ENTITY_ACTION':
1965 return {
1966 ...state,
1967 [action.kind]: {
1968 ...state[action.kind],
1969 [action.name]: [...((_state$action$kind$ac = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac !== void 0 ? _state$action$kind$ac : []).filter(_action => _action.id !== action.config.id), action.config]
1970 }
1971 };
1972 case 'UNREGISTER_ENTITY_ACTION':
1973 {
1974 var _state$action$kind$ac2;
1975 return {
1976 ...state,
1977 [action.kind]: {
1978 ...state[action.kind],
1979 [action.name]: ((_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)
1980 }
1981 };
1982 }
1983 }
1984 return state;
1985 }
1986 function fields(state = {}, action) {
1987 var _state$action$kind$ac3, _state$action$kind$ac4;
1988 switch (action.type) {
1989 case 'REGISTER_ENTITY_FIELD':
1990 return {
1991 ...state,
1992 [action.kind]: {
1993 ...state[action.kind],
1994 [action.name]: [...((_state$action$kind$ac3 = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac3 !== void 0 ? _state$action$kind$ac3 : []).filter(_field => _field.id !== action.config.id), action.config]
1995 }
1996 };
1997 case 'UNREGISTER_ENTITY_FIELD':
1998 return {
1999 ...state,
2000 [action.kind]: {
2001 ...state[action.kind],
2002 [action.name]: ((_state$action$kind$ac4 = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac4 !== void 0 ? _state$action$kind$ac4 : []).filter(_field => _field.id !== action.fieldId)
2003 }
2004 };
2005 }
2006 return state;
2007 }
2008 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2009 actions,
2010 fields,
2011 isReady
2012 }));
2013
2014 ;// ./packages/editor/build-module/store/reducer.js
2015 /* wp:polyfill */
2016 /**
2017 * WordPress dependencies
2018 */
2019
2020
2021 /**
2022 * Internal dependencies
2023 */
2024
2025
2026
2027 /**
2028 * Returns a post attribute value, flattening nested rendered content using its
2029 * raw value in place of its original object form.
2030 *
2031 * @param {*} value Original value.
2032 *
2033 * @return {*} Raw value.
2034 */
2035 function getPostRawValue(value) {
2036 if (value && 'object' === typeof value && 'raw' in value) {
2037 return value.raw;
2038 }
2039 return value;
2040 }
2041
2042 /**
2043 * Returns true if the two object arguments have the same keys, or false
2044 * otherwise.
2045 *
2046 * @param {Object} a First object.
2047 * @param {Object} b Second object.
2048 *
2049 * @return {boolean} Whether the two objects have the same keys.
2050 */
2051 function hasSameKeys(a, b) {
2052 const keysA = Object.keys(a).sort();
2053 const keysB = Object.keys(b).sort();
2054 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key);
2055 }
2056
2057 /**
2058 * Returns true if, given the currently dispatching action and the previously
2059 * dispatched action, the two actions are editing the same post property, or
2060 * false otherwise.
2061 *
2062 * @param {Object} action Currently dispatching action.
2063 * @param {Object} previousAction Previously dispatched action.
2064 *
2065 * @return {boolean} Whether actions are updating the same post property.
2066 */
2067 function isUpdatingSamePostProperty(action, previousAction) {
2068 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
2069 }
2070
2071 /**
2072 * Returns true if, given the currently dispatching action and the previously
2073 * dispatched action, the two actions are modifying the same property such that
2074 * undo history should be batched.
2075 *
2076 * @param {Object} action Currently dispatching action.
2077 * @param {Object} previousAction Previously dispatched action.
2078 *
2079 * @return {boolean} Whether to overwrite present state.
2080 */
2081 function shouldOverwriteState(action, previousAction) {
2082 if (action.type === 'RESET_EDITOR_BLOCKS') {
2083 return !action.shouldCreateUndoLevel;
2084 }
2085 if (!previousAction || action.type !== previousAction.type) {
2086 return false;
2087 }
2088 return isUpdatingSamePostProperty(action, previousAction);
2089 }
2090 function postId(state = null, action) {
2091 switch (action.type) {
2092 case 'SET_EDITED_POST':
2093 return action.postId;
2094 }
2095 return state;
2096 }
2097 function templateId(state = null, action) {
2098 switch (action.type) {
2099 case 'SET_CURRENT_TEMPLATE_ID':
2100 return action.id;
2101 }
2102 return state;
2103 }
2104 function postType(state = null, action) {
2105 switch (action.type) {
2106 case 'SET_EDITED_POST':
2107 return action.postType;
2108 }
2109 return state;
2110 }
2111
2112 /**
2113 * Reducer returning whether the post blocks match the defined template or not.
2114 *
2115 * @param {Object} state Current state.
2116 * @param {Object} action Dispatched action.
2117 *
2118 * @return {boolean} Updated state.
2119 */
2120 function template(state = {
2121 isValid: true
2122 }, action) {
2123 switch (action.type) {
2124 case 'SET_TEMPLATE_VALIDITY':
2125 return {
2126 ...state,
2127 isValid: action.isValid
2128 };
2129 }
2130 return state;
2131 }
2132
2133 /**
2134 * Reducer returning current network request state (whether a request to
2135 * the WP REST API is in progress, successful, or failed).
2136 *
2137 * @param {Object} state Current state.
2138 * @param {Object} action Dispatched action.
2139 *
2140 * @return {Object} Updated state.
2141 */
2142 function saving(state = {}, action) {
2143 switch (action.type) {
2144 case 'REQUEST_POST_UPDATE_START':
2145 case 'REQUEST_POST_UPDATE_FINISH':
2146 return {
2147 pending: action.type === 'REQUEST_POST_UPDATE_START',
2148 options: action.options || {}
2149 };
2150 }
2151 return state;
2152 }
2153
2154 /**
2155 * Reducer returning deleting post request state.
2156 *
2157 * @param {Object} state Current state.
2158 * @param {Object} action Dispatched action.
2159 *
2160 * @return {Object} Updated state.
2161 */
2162 function deleting(state = {}, action) {
2163 switch (action.type) {
2164 case 'REQUEST_POST_DELETE_START':
2165 case 'REQUEST_POST_DELETE_FINISH':
2166 return {
2167 pending: action.type === 'REQUEST_POST_DELETE_START'
2168 };
2169 }
2170 return state;
2171 }
2172
2173 /**
2174 * Post Lock State.
2175 *
2176 * @typedef {Object} PostLockState
2177 *
2178 * @property {boolean} isLocked Whether the post is locked.
2179 * @property {?boolean} isTakeover Whether the post editing has been taken over.
2180 * @property {?boolean} activePostLock Active post lock value.
2181 * @property {?Object} user User that took over the post.
2182 */
2183
2184 /**
2185 * Reducer returning the post lock status.
2186 *
2187 * @param {PostLockState} state Current state.
2188 * @param {Object} action Dispatched action.
2189 *
2190 * @return {PostLockState} Updated state.
2191 */
2192 function postLock(state = {
2193 isLocked: false
2194 }, action) {
2195 switch (action.type) {
2196 case 'UPDATE_POST_LOCK':
2197 return action.lock;
2198 }
2199 return state;
2200 }
2201
2202 /**
2203 * Post saving lock.
2204 *
2205 * When post saving is locked, the post cannot be published or updated.
2206 *
2207 * @param {PostLockState} state Current state.
2208 * @param {Object} action Dispatched action.
2209 *
2210 * @return {PostLockState} Updated state.
2211 */
2212 function postSavingLock(state = {}, action) {
2213 switch (action.type) {
2214 case 'LOCK_POST_SAVING':
2215 return {
2216 ...state,
2217 [action.lockName]: true
2218 };
2219 case 'UNLOCK_POST_SAVING':
2220 {
2221 const {
2222 [action.lockName]: removedLockName,
2223 ...restState
2224 } = state;
2225 return restState;
2226 }
2227 }
2228 return state;
2229 }
2230
2231 /**
2232 * Post autosaving lock.
2233 *
2234 * When post autosaving is locked, the post will not autosave.
2235 *
2236 * @param {PostLockState} state Current state.
2237 * @param {Object} action Dispatched action.
2238 *
2239 * @return {PostLockState} Updated state.
2240 */
2241 function postAutosavingLock(state = {}, action) {
2242 switch (action.type) {
2243 case 'LOCK_POST_AUTOSAVING':
2244 return {
2245 ...state,
2246 [action.lockName]: true
2247 };
2248 case 'UNLOCK_POST_AUTOSAVING':
2249 {
2250 const {
2251 [action.lockName]: removedLockName,
2252 ...restState
2253 } = state;
2254 return restState;
2255 }
2256 }
2257 return state;
2258 }
2259
2260 /**
2261 * Reducer returning the post editor setting.
2262 *
2263 * @param {Object} state Current state.
2264 * @param {Object} action Dispatched action.
2265 *
2266 * @return {Object} Updated state.
2267 */
2268 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2269 switch (action.type) {
2270 case 'UPDATE_EDITOR_SETTINGS':
2271 return {
2272 ...state,
2273 ...action.settings
2274 };
2275 }
2276 return state;
2277 }
2278 function renderingMode(state = 'post-only', action) {
2279 switch (action.type) {
2280 case 'SET_RENDERING_MODE':
2281 return action.mode;
2282 }
2283 return state;
2284 }
2285
2286 /**
2287 * Reducer returning the editing canvas device type.
2288 *
2289 * @param {Object} state Current state.
2290 * @param {Object} action Dispatched action.
2291 *
2292 * @return {Object} Updated state.
2293 */
2294 function deviceType(state = 'Desktop', action) {
2295 switch (action.type) {
2296 case 'SET_DEVICE_TYPE':
2297 return action.deviceType;
2298 }
2299 return state;
2300 }
2301
2302 /**
2303 * Reducer storing the list of all programmatically removed panels.
2304 *
2305 * @param {Array} state Current state.
2306 * @param {Object} action Action object.
2307 *
2308 * @return {Array} Updated state.
2309 */
2310 function removedPanels(state = [], action) {
2311 switch (action.type) {
2312 case 'REMOVE_PANEL':
2313 if (!state.includes(action.panelName)) {
2314 return [...state, action.panelName];
2315 }
2316 }
2317 return state;
2318 }
2319
2320 /**
2321 * Reducer to set the block inserter panel open or closed.
2322 *
2323 * Note: this reducer interacts with the list view panel reducer
2324 * to make sure that only one of the two panels is open at the same time.
2325 *
2326 * @param {Object} state Current state.
2327 * @param {Object} action Dispatched action.
2328 */
2329 function blockInserterPanel(state = false, action) {
2330 switch (action.type) {
2331 case 'SET_IS_LIST_VIEW_OPENED':
2332 return action.isOpen ? false : state;
2333 case 'SET_IS_INSERTER_OPENED':
2334 return action.value;
2335 }
2336 return state;
2337 }
2338
2339 /**
2340 * Reducer to set the list view panel open or closed.
2341 *
2342 * Note: this reducer interacts with the inserter panel reducer
2343 * to make sure that only one of the two panels is open at the same time.
2344 *
2345 * @param {Object} state Current state.
2346 * @param {Object} action Dispatched action.
2347 */
2348 function listViewPanel(state = false, action) {
2349 switch (action.type) {
2350 case 'SET_IS_INSERTER_OPENED':
2351 return action.value ? false : state;
2352 case 'SET_IS_LIST_VIEW_OPENED':
2353 return action.isOpen;
2354 }
2355 return state;
2356 }
2357
2358 /**
2359 * This reducer does nothing aside initializing a ref to the list view toggle.
2360 * We will have a unique ref per "editor" instance.
2361 *
2362 * @param {Object} state
2363 * @return {Object} Reference to the list view toggle button.
2364 */
2365 function listViewToggleRef(state = {
2366 current: null
2367 }) {
2368 return state;
2369 }
2370
2371 /**
2372 * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
2373 * We will have a unique ref per "editor" instance.
2374 *
2375 * @param {Object} state
2376 * @return {Object} Reference to the inserter sidebar toggle button.
2377 */
2378 function inserterSidebarToggleRef(state = {
2379 current: null
2380 }) {
2381 return state;
2382 }
2383 function publishSidebarActive(state = false, action) {
2384 switch (action.type) {
2385 case 'OPEN_PUBLISH_SIDEBAR':
2386 return true;
2387 case 'CLOSE_PUBLISH_SIDEBAR':
2388 return false;
2389 case 'TOGGLE_PUBLISH_SIDEBAR':
2390 return !state;
2391 }
2392 return state;
2393 }
2394 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2395 postId,
2396 postType,
2397 templateId,
2398 saving,
2399 deleting,
2400 postLock,
2401 template,
2402 postSavingLock,
2403 editorSettings,
2404 postAutosavingLock,
2405 renderingMode,
2406 deviceType,
2407 removedPanels,
2408 blockInserterPanel,
2409 inserterSidebarToggleRef,
2410 listViewPanel,
2411 listViewToggleRef,
2412 publishSidebarActive,
2413 dataviews: reducer
2414 }));
2415
2416 ;// external ["wp","blocks"]
2417 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
2418 ;// external ["wp","date"]
2419 const external_wp_date_namespaceObject = window["wp"]["date"];
2420 ;// external ["wp","url"]
2421 const external_wp_url_namespaceObject = window["wp"]["url"];
2422 ;// external ["wp","deprecated"]
2423 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2424 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2425 ;// external ["wp","preferences"]
2426 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
2427 ;// ./packages/editor/build-module/store/constants.js
2428 /**
2429 * Set of post properties for which edits should assume a merging behavior,
2430 * assuming an object value.
2431 *
2432 * @type {Set}
2433 */
2434 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
2435
2436 /**
2437 * Constant for the store module (or reducer) key.
2438 */
2439 const STORE_NAME = 'core/editor';
2440 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
2441 const ONE_MINUTE_IN_MS = 60 * 1000;
2442 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
2443 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';
2444 const TEMPLATE_POST_TYPE = 'wp_template';
2445 const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
2446 const PATTERN_POST_TYPE = 'wp_block';
2447 const NAVIGATION_POST_TYPE = 'wp_navigation';
2448 const TEMPLATE_ORIGINS = {
2449 custom: 'custom',
2450 theme: 'theme',
2451 plugin: 'plugin'
2452 };
2453 const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
2454 const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
2455
2456 ;// external ["wp","primitives"]
2457 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
2458 ;// external "ReactJSXRuntime"
2459 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
2460 ;// ./packages/icons/build-module/library/header.js
2461 /**
2462 * WordPress dependencies
2463 */
2464
2465
2466 const header = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2467 xmlns: "http://www.w3.org/2000/svg",
2468 viewBox: "0 0 24 24",
2469 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2470 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"
2471 })
2472 });
2473 /* harmony default export */ const library_header = (header);
2474
2475 ;// ./packages/icons/build-module/library/footer.js
2476 /**
2477 * WordPress dependencies
2478 */
2479
2480
2481 const footer = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2482 xmlns: "http://www.w3.org/2000/svg",
2483 viewBox: "0 0 24 24",
2484 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2485 fillRule: "evenodd",
2486 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"
2487 })
2488 });
2489 /* harmony default export */ const library_footer = (footer);
2490
2491 ;// ./packages/icons/build-module/library/sidebar.js
2492 /**
2493 * WordPress dependencies
2494 */
2495
2496
2497 const sidebar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2498 xmlns: "http://www.w3.org/2000/svg",
2499 viewBox: "0 0 24 24",
2500 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2501 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"
2502 })
2503 });
2504 /* harmony default export */ const library_sidebar = (sidebar);
2505
2506 ;// ./packages/icons/build-module/library/symbol-filled.js
2507 /**
2508 * WordPress dependencies
2509 */
2510
2511
2512 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2513 xmlns: "http://www.w3.org/2000/svg",
2514 viewBox: "0 0 24 24",
2515 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2516 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"
2517 })
2518 });
2519 /* harmony default export */ const symbol_filled = (symbolFilled);
2520
2521 ;// ./packages/editor/build-module/utils/get-template-part-icon.js
2522 /**
2523 * WordPress dependencies
2524 */
2525
2526 /**
2527 * Helper function to retrieve the corresponding icon by name.
2528 *
2529 * @param {string} iconName The name of the icon.
2530 *
2531 * @return {Object} The corresponding icon.
2532 */
2533 function getTemplatePartIcon(iconName) {
2534 if ('header' === iconName) {
2535 return library_header;
2536 } else if ('footer' === iconName) {
2537 return library_footer;
2538 } else if ('sidebar' === iconName) {
2539 return library_sidebar;
2540 }
2541 return symbol_filled;
2542 }
2543
2544 ;// external ["wp","privateApis"]
2545 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
2546 ;// ./packages/editor/build-module/lock-unlock.js
2547 /**
2548 * WordPress dependencies
2549 */
2550
2551 const {
2552 lock,
2553 unlock
2554 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/editor');
2555
2556 ;// ./packages/icons/build-module/library/layout.js
2557 /**
2558 * WordPress dependencies
2559 */
2560
2561
2562 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2563 xmlns: "http://www.w3.org/2000/svg",
2564 viewBox: "0 0 24 24",
2565 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2566 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"
2567 })
2568 });
2569 /* harmony default export */ const library_layout = (layout);
2570
2571 ;// ./packages/editor/build-module/utils/get-template-info.js
2572 /* wp:polyfill */
2573 /**
2574 * WordPress dependencies
2575 */
2576
2577 /**
2578 * Internal dependencies
2579 */
2580
2581 const EMPTY_OBJECT = {};
2582
2583 /**
2584 * Helper function to retrieve the corresponding template info for a given template.
2585 * @param {Object} params
2586 * @param {Array} params.templateTypes
2587 * @param {Array} [params.templateAreas]
2588 * @param {Object} params.template
2589 */
2590 const getTemplateInfo = params => {
2591 var _Object$values$find;
2592 if (!params) {
2593 return EMPTY_OBJECT;
2594 }
2595 const {
2596 templateTypes,
2597 templateAreas,
2598 template
2599 } = params;
2600 const {
2601 description,
2602 slug,
2603 title,
2604 area
2605 } = template;
2606 const {
2607 title: defaultTitle,
2608 description: defaultDescription
2609 } = (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT;
2610 const templateTitle = typeof title === 'string' ? title : title?.rendered;
2611 const templateDescription = typeof description === 'string' ? description : description?.raw;
2612 const templateAreasWithIcon = templateAreas?.map(item => ({
2613 ...item,
2614 icon: getTemplatePartIcon(item.icon)
2615 }));
2616 const templateIcon = templateAreasWithIcon?.find(item => area === item.area)?.icon || library_layout;
2617 return {
2618 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
2619 description: templateDescription || defaultDescription,
2620 icon: templateIcon
2621 };
2622 };
2623
2624 ;// ./packages/editor/build-module/store/selectors.js
2625 /* wp:polyfill */
2626 /**
2627 * WordPress dependencies
2628 */
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639 /**
2640 * Internal dependencies
2641 */
2642
2643
2644
2645
2646
2647
2648 /**
2649 * Shared reference to an empty object for cases where it is important to avoid
2650 * returning a new object reference on every invocation, as in a connected or
2651 * other pure component which performs `shouldComponentUpdate` check on props.
2652 * This should be used as a last resort, since the normalized data should be
2653 * maintained by the reducer result in state.
2654 */
2655 const selectors_EMPTY_OBJECT = {};
2656
2657 /**
2658 * Returns true if any past editor history snapshots exist, or false otherwise.
2659 *
2660 * @param {Object} state Global application state.
2661 *
2662 * @return {boolean} Whether undo history exists.
2663 */
2664 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2665 return select(external_wp_coreData_namespaceObject.store).hasUndo();
2666 });
2667
2668 /**
2669 * Returns true if any future editor history snapshots exist, or false
2670 * otherwise.
2671 *
2672 * @param {Object} state Global application state.
2673 *
2674 * @return {boolean} Whether redo history exists.
2675 */
2676 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2677 return select(external_wp_coreData_namespaceObject.store).hasRedo();
2678 });
2679
2680 /**
2681 * Returns true if the currently edited post is yet to be saved, or false if
2682 * the post has been saved.
2683 *
2684 * @param {Object} state Global application state.
2685 *
2686 * @return {boolean} Whether the post is new.
2687 */
2688 function isEditedPostNew(state) {
2689 return getCurrentPost(state).status === 'auto-draft';
2690 }
2691
2692 /**
2693 * Returns true if content includes unsaved changes, or false otherwise.
2694 *
2695 * @param {Object} state Editor state.
2696 *
2697 * @return {boolean} Whether content includes unsaved changes.
2698 */
2699 function hasChangedContent(state) {
2700 const edits = getPostEdits(state);
2701 return 'content' in edits;
2702 }
2703
2704 /**
2705 * Returns true if there are unsaved values for the current edit session, or
2706 * false if the editing state matches the saved or new post.
2707 *
2708 * @param {Object} state Global application state.
2709 *
2710 * @return {boolean} Whether unsaved values exist.
2711 */
2712 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2713 // Edits should contain only fields which differ from the saved post (reset
2714 // at initial load and save complete). Thus, a non-empty edits state can be
2715 // inferred to contain unsaved values.
2716 const postType = getCurrentPostType(state);
2717 const postId = getCurrentPostId(state);
2718 return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId);
2719 });
2720
2721 /**
2722 * Returns true if there are unsaved edits for entities other than
2723 * the editor's post, and false otherwise.
2724 *
2725 * @param {Object} state Global application state.
2726 *
2727 * @return {boolean} Whether there are edits or not.
2728 */
2729 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2730 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2731 const {
2732 type,
2733 id
2734 } = getCurrentPost(state);
2735 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2736 });
2737
2738 /**
2739 * Returns true if there are no unsaved values for the current edit session and
2740 * if the currently edited post is new (has never been saved before).
2741 *
2742 * @param {Object} state Global application state.
2743 *
2744 * @return {boolean} Whether new post and unsaved values exist.
2745 */
2746 function isCleanNewPost(state) {
2747 return !isEditedPostDirty(state) && isEditedPostNew(state);
2748 }
2749
2750 /**
2751 * Returns the post currently being edited in its last known saved state, not
2752 * including unsaved edits. Returns an object containing relevant default post
2753 * values if the post has not yet been saved.
2754 *
2755 * @param {Object} state Global application state.
2756 *
2757 * @return {Object} Post object.
2758 */
2759 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2760 const postId = getCurrentPostId(state);
2761 const postType = getCurrentPostType(state);
2762 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2763 if (post) {
2764 return post;
2765 }
2766
2767 // This exists for compatibility with the previous selector behavior
2768 // which would guarantee an object return based on the editor reducer's
2769 // default empty object state.
2770 return selectors_EMPTY_OBJECT;
2771 });
2772
2773 /**
2774 * Returns the post type of the post currently being edited.
2775 *
2776 * @param {Object} state Global application state.
2777 *
2778 * @example
2779 *
2780 *```js
2781 * const currentPostType = wp.data.select( 'core/editor' ).getCurrentPostType();
2782 *```
2783 * @return {string} Post type.
2784 */
2785 function getCurrentPostType(state) {
2786 return state.postType;
2787 }
2788
2789 /**
2790 * Returns the ID of the post currently being edited, or null if the post has
2791 * not yet been saved.
2792 *
2793 * @param {Object} state Global application state.
2794 *
2795 * @return {?number} ID of current post.
2796 */
2797 function getCurrentPostId(state) {
2798 return state.postId;
2799 }
2800
2801 /**
2802 * Returns the template ID currently being rendered/edited
2803 *
2804 * @param {Object} state Global application state.
2805 *
2806 * @return {?string} Template ID.
2807 */
2808 function getCurrentTemplateId(state) {
2809 return state.templateId;
2810 }
2811
2812 /**
2813 * Returns the number of revisions of the post currently being edited.
2814 *
2815 * @param {Object} state Global application state.
2816 *
2817 * @return {number} Number of revisions.
2818 */
2819 function getCurrentPostRevisionsCount(state) {
2820 var _getCurrentPost$_link;
2821 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0;
2822 }
2823
2824 /**
2825 * Returns the last revision ID of the post currently being edited,
2826 * or null if the post has no revisions.
2827 *
2828 * @param {Object} state Global application state.
2829 *
2830 * @return {?number} ID of the last revision.
2831 */
2832 function getCurrentPostLastRevisionId(state) {
2833 var _getCurrentPost$_link2;
2834 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null;
2835 }
2836
2837 /**
2838 * Returns any post values which have been changed in the editor but not yet
2839 * been saved.
2840 *
2841 * @param {Object} state Global application state.
2842 *
2843 * @return {Object} Object of key value pairs comprising unsaved edits.
2844 */
2845 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2846 const postType = getCurrentPostType(state);
2847 const postId = getCurrentPostId(state);
2848 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || selectors_EMPTY_OBJECT;
2849 });
2850
2851 /**
2852 * Returns an attribute value of the saved post.
2853 *
2854 * @param {Object} state Global application state.
2855 * @param {string} attributeName Post attribute name.
2856 *
2857 * @return {*} Post attribute value.
2858 */
2859 function getCurrentPostAttribute(state, attributeName) {
2860 switch (attributeName) {
2861 case 'type':
2862 return getCurrentPostType(state);
2863 case 'id':
2864 return getCurrentPostId(state);
2865 default:
2866 const post = getCurrentPost(state);
2867 if (!post.hasOwnProperty(attributeName)) {
2868 break;
2869 }
2870 return getPostRawValue(post[attributeName]);
2871 }
2872 }
2873
2874 /**
2875 * Returns a single attribute of the post being edited, preferring the unsaved
2876 * edit if one exists, but merging with the attribute value for the last known
2877 * saved state of the post (this is needed for some nested attributes like meta).
2878 *
2879 * @param {Object} state Global application state.
2880 * @param {string} attributeName Post attribute name.
2881 *
2882 * @return {*} Post attribute value.
2883 */
2884 const getNestedEditedPostProperty = (0,external_wp_data_namespaceObject.createSelector)((state, attributeName) => {
2885 const edits = getPostEdits(state);
2886 if (!edits.hasOwnProperty(attributeName)) {
2887 return getCurrentPostAttribute(state, attributeName);
2888 }
2889 return {
2890 ...getCurrentPostAttribute(state, attributeName),
2891 ...edits[attributeName]
2892 };
2893 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]);
2894
2895 /**
2896 * Returns a single attribute of the post being edited, preferring the unsaved
2897 * edit if one exists, but falling back to the attribute for the last known
2898 * saved state of the post.
2899 *
2900 * @param {Object} state Global application state.
2901 * @param {string} attributeName Post attribute name.
2902 *
2903 * @example
2904 *
2905 *```js
2906 * // Get specific media size based on the featured media ID
2907 * // Note: change sizes?.large for any registered size
2908 * const getFeaturedMediaUrl = useSelect( ( select ) => {
2909 * const getFeaturedMediaId =
2910 * select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
2911 * const getMedia = select( 'core' ).getMedia( getFeaturedMediaId );
2912 *
2913 * return (
2914 * getMedia?.media_details?.sizes?.large?.source_url || getMedia?.source_url || ''
2915 * );
2916 * }, [] );
2917 *```
2918 *
2919 * @return {*} Post attribute value.
2920 */
2921 function getEditedPostAttribute(state, attributeName) {
2922 // Special cases.
2923 switch (attributeName) {
2924 case 'content':
2925 return getEditedPostContent(state);
2926 }
2927
2928 // Fall back to saved post value if not edited.
2929 const edits = getPostEdits(state);
2930 if (!edits.hasOwnProperty(attributeName)) {
2931 return getCurrentPostAttribute(state, attributeName);
2932 }
2933
2934 // Merge properties are objects which contain only the patch edit in state,
2935 // and thus must be merged with the current post attribute.
2936 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2937 return getNestedEditedPostProperty(state, attributeName);
2938 }
2939 return edits[attributeName];
2940 }
2941
2942 /**
2943 * Returns an attribute value of the current autosave revision for a post, or
2944 * null if there is no autosave for the post.
2945 *
2946 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2947 * from the '@wordpress/core-data' package and access properties on the returned
2948 * autosave object using getPostRawValue.
2949 *
2950 * @param {Object} state Global application state.
2951 * @param {string} attributeName Autosave attribute name.
2952 *
2953 * @return {*} Autosave attribute value.
2954 */
2955 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2956 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') {
2957 return;
2958 }
2959 const postType = getCurrentPostType(state);
2960
2961 // Currently template autosaving is not supported.
2962 if (postType === 'wp_template') {
2963 return false;
2964 }
2965 const postId = getCurrentPostId(state);
2966 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
2967 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2968 if (autosave) {
2969 return getPostRawValue(autosave[attributeName]);
2970 }
2971 });
2972
2973 /**
2974 * Returns the current visibility of the post being edited, preferring the
2975 * unsaved value if different than the saved post. The return value is one of
2976 * "private", "password", or "public".
2977 *
2978 * @param {Object} state Global application state.
2979 *
2980 * @return {string} Post visibility.
2981 */
2982 function getEditedPostVisibility(state) {
2983 const status = getEditedPostAttribute(state, 'status');
2984 if (status === 'private') {
2985 return 'private';
2986 }
2987 const password = getEditedPostAttribute(state, 'password');
2988 if (password) {
2989 return 'password';
2990 }
2991 return 'public';
2992 }
2993
2994 /**
2995 * Returns true if post is pending review.
2996 *
2997 * @param {Object} state Global application state.
2998 *
2999 * @return {boolean} Whether current post is pending review.
3000 */
3001 function isCurrentPostPending(state) {
3002 return getCurrentPost(state).status === 'pending';
3003 }
3004
3005 /**
3006 * Return true if the current post has already been published.
3007 *
3008 * @param {Object} state Global application state.
3009 * @param {Object} [currentPost] Explicit current post for bypassing registry selector.
3010 *
3011 * @return {boolean} Whether the post has been published.
3012 */
3013 function isCurrentPostPublished(state, currentPost) {
3014 const post = currentPost || getCurrentPost(state);
3015 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));
3016 }
3017
3018 /**
3019 * Returns true if post is already scheduled.
3020 *
3021 * @param {Object} state Global application state.
3022 *
3023 * @return {boolean} Whether current post is scheduled to be posted.
3024 */
3025 function isCurrentPostScheduled(state) {
3026 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
3027 }
3028
3029 /**
3030 * Return true if the post being edited can be published.
3031 *
3032 * @param {Object} state Global application state.
3033 *
3034 * @return {boolean} Whether the post can been published.
3035 */
3036 function isEditedPostPublishable(state) {
3037 const post = getCurrentPost(state);
3038
3039 // TODO: Post being publishable should be superset of condition of post
3040 // being saveable. Currently this restriction is imposed at UI.
3041 //
3042 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
3043
3044 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
3045 }
3046
3047 /**
3048 * Returns true if the post can be saved, or false otherwise. A post must
3049 * contain a title, an excerpt, or non-empty content to be valid for save.
3050 *
3051 * @param {Object} state Global application state.
3052 *
3053 * @return {boolean} Whether the post can be saved.
3054 */
3055 function isEditedPostSaveable(state) {
3056 if (isSavingPost(state)) {
3057 return false;
3058 }
3059
3060 // TODO: Post should not be saveable if not dirty. Cannot be added here at
3061 // this time since posts where meta boxes are present can be saved even if
3062 // the post is not dirty. Currently this restriction is imposed at UI, but
3063 // should be moved here.
3064 //
3065 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
3066 // See: <PostSavedState /> (`forceIsDirty` prop)
3067 // See: <PostPublishButton /> (`forceIsDirty` prop)
3068 // See: https://github.com/WordPress/gutenberg/pull/4184.
3069
3070 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
3071 }
3072
3073 /**
3074 * Returns true if the edited post has content. A post has content if it has at
3075 * least one saveable block or otherwise has a non-empty content property
3076 * assigned.
3077 *
3078 * @param {Object} state Global application state.
3079 *
3080 * @return {boolean} Whether post has content.
3081 */
3082 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3083 // While the condition of truthy content string is sufficient to determine
3084 // emptiness, testing saveable blocks length is a trivial operation. Since
3085 // this function can be called frequently, optimize for the fast case as a
3086 // condition of the mere existence of blocks. Note that the value of edited
3087 // content takes precedent over block content, and must fall through to the
3088 // default logic.
3089 const postId = getCurrentPostId(state);
3090 const postType = getCurrentPostType(state);
3091 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3092 if (typeof record.content !== 'function') {
3093 return !record.content;
3094 }
3095 const blocks = getEditedPostAttribute(state, 'blocks');
3096 if (blocks.length === 0) {
3097 return true;
3098 }
3099
3100 // Pierce the abstraction of the serializer in knowing that blocks are
3101 // joined with newlines such that even if every individual block
3102 // produces an empty save result, the serialized content is non-empty.
3103 if (blocks.length > 1) {
3104 return false;
3105 }
3106
3107 // There are two conditions under which the optimization cannot be
3108 // assumed, and a fallthrough to getEditedPostContent must occur:
3109 //
3110 // 1. getBlocksForSerialization has special treatment in omitting a
3111 // single unmodified default block.
3112 // 2. Comment delimiters are omitted for a freeform or unregistered
3113 // block in its serialization. The freeform block specifically may
3114 // produce an empty string in its saved output.
3115 //
3116 // For all other content, the single block is assumed to make a post
3117 // non-empty, if only by virtue of its own comment delimiters.
3118 const blockName = blocks[0].name;
3119 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
3120 return false;
3121 }
3122 return !getEditedPostContent(state);
3123 });
3124
3125 /**
3126 * Returns true if the post can be autosaved, or false otherwise.
3127 *
3128 * @param {Object} state Global application state.
3129 * @param {Object} autosave A raw autosave object from the REST API.
3130 *
3131 * @return {boolean} Whether the post can be autosaved.
3132 */
3133 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3134 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
3135 if (!isEditedPostSaveable(state)) {
3136 return false;
3137 }
3138
3139 // A post is not autosavable when there is a post autosave lock.
3140 if (isPostAutosavingLocked(state)) {
3141 return false;
3142 }
3143 const postType = getCurrentPostType(state);
3144
3145 // Currently template autosaving is not supported.
3146 if (postType === 'wp_template') {
3147 return false;
3148 }
3149 const postId = getCurrentPostId(state);
3150 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
3151 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
3152
3153 // Disable reason - this line causes the side-effect of fetching the autosave
3154 // via a resolver, moving below the return would result in the autosave never
3155 // being fetched.
3156 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
3157 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
3158
3159 // If any existing autosaves have not yet been fetched, this function is
3160 // unable to determine if the post is autosaveable, so return false.
3161 if (!hasFetchedAutosave) {
3162 return false;
3163 }
3164
3165 // If we don't already have an autosave, the post is autosaveable.
3166 if (!autosave) {
3167 return true;
3168 }
3169
3170 // To avoid an expensive content serialization, use the content dirtiness
3171 // flag in place of content field comparison against the known autosave.
3172 // This is not strictly accurate, and relies on a tolerance toward autosave
3173 // request failures for unnecessary saves.
3174 if (hasChangedContent(state)) {
3175 return true;
3176 }
3177
3178 // If title, excerpt, or meta have changed, the post is autosaveable.
3179 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
3180 });
3181
3182 /**
3183 * Return true if the post being edited is being scheduled. Preferring the
3184 * unsaved status values.
3185 *
3186 * @param {Object} state Global application state.
3187 *
3188 * @return {boolean} Whether the post has been published.
3189 */
3190 function isEditedPostBeingScheduled(state) {
3191 const date = getEditedPostAttribute(state, 'date');
3192 // Offset the date by one minute (network latency).
3193 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
3194 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
3195 }
3196
3197 /**
3198 * Returns whether the current post should be considered to have a "floating"
3199 * date (i.e. that it would publish "Immediately" rather than at a set time).
3200 *
3201 * Unlike in the PHP backend, the REST API returns a full date string for posts
3202 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
3203 * infer that a post is set to publish "Immediately" we check whether the date
3204 * and modified date are the same.
3205 *
3206 * @param {Object} state Editor state.
3207 *
3208 * @return {boolean} Whether the edited post has a floating date value.
3209 */
3210 function isEditedPostDateFloating(state) {
3211 const date = getEditedPostAttribute(state, 'date');
3212 const modified = getEditedPostAttribute(state, 'modified');
3213
3214 // This should be the status of the persisted post
3215 // It shouldn't use the "edited" status otherwise it breaks the
3216 // inferred post data floating status
3217 // See https://github.com/WordPress/gutenberg/issues/28083.
3218 const status = getCurrentPost(state).status;
3219 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
3220 return date === modified || date === null;
3221 }
3222 return false;
3223 }
3224
3225 /**
3226 * Returns true if the post is currently being deleted, or false otherwise.
3227 *
3228 * @param {Object} state Editor state.
3229 *
3230 * @return {boolean} Whether post is being deleted.
3231 */
3232 function isDeletingPost(state) {
3233 return !!state.deleting.pending;
3234 }
3235
3236 /**
3237 * Returns true if the post is currently being saved, or false otherwise.
3238 *
3239 * @param {Object} state Global application state.
3240 *
3241 * @return {boolean} Whether post is being saved.
3242 */
3243 function isSavingPost(state) {
3244 return !!state.saving.pending;
3245 }
3246
3247 /**
3248 * Returns true if non-post entities are currently being saved, or false otherwise.
3249 *
3250 * @param {Object} state Global application state.
3251 *
3252 * @return {boolean} Whether non-post entities are being saved.
3253 */
3254 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3255 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
3256 const {
3257 type,
3258 id
3259 } = getCurrentPost(state);
3260 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
3261 });
3262
3263 /**
3264 * Returns true if a previous post save was attempted successfully, or false
3265 * otherwise.
3266 *
3267 * @param {Object} state Global application state.
3268 *
3269 * @return {boolean} Whether the post was saved successfully.
3270 */
3271 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3272 const postType = getCurrentPostType(state);
3273 const postId = getCurrentPostId(state);
3274 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3275 });
3276
3277 /**
3278 * Returns true if a previous post save was attempted but failed, or false
3279 * otherwise.
3280 *
3281 * @param {Object} state Global application state.
3282 *
3283 * @return {boolean} Whether the post save failed.
3284 */
3285 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3286 const postType = getCurrentPostType(state);
3287 const postId = getCurrentPostId(state);
3288 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3289 });
3290
3291 /**
3292 * Returns true if the post is autosaving, or false otherwise.
3293 *
3294 * @param {Object} state Global application state.
3295 *
3296 * @return {boolean} Whether the post is autosaving.
3297 */
3298 function isAutosavingPost(state) {
3299 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3300 }
3301
3302 /**
3303 * Returns true if the post is being previewed, or false otherwise.
3304 *
3305 * @param {Object} state Global application state.
3306 *
3307 * @return {boolean} Whether the post is being previewed.
3308 */
3309 function isPreviewingPost(state) {
3310 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3311 }
3312
3313 /**
3314 * Returns the post preview link
3315 *
3316 * @param {Object} state Global application state.
3317 *
3318 * @return {string | undefined} Preview Link.
3319 */
3320 function getEditedPostPreviewLink(state) {
3321 if (state.saving.pending || isSavingPost(state)) {
3322 return;
3323 }
3324 let previewLink = getAutosaveAttribute(state, 'preview_link');
3325 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
3326 // If the post is draft, ignore the preview link from the autosave record,
3327 // because the preview could be a stale autosave if the post was switched from
3328 // published to draft.
3329 // See: https://github.com/WordPress/gutenberg/pull/37952.
3330 if (!previewLink || 'draft' === getCurrentPost(state).status) {
3331 previewLink = getEditedPostAttribute(state, 'link');
3332 if (previewLink) {
3333 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3334 preview: true
3335 });
3336 }
3337 }
3338 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
3339 if (previewLink && featuredImageId) {
3340 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3341 _thumbnail_id: featuredImageId
3342 });
3343 }
3344 return previewLink;
3345 }
3346
3347 /**
3348 * Returns a suggested post format for the current post, inferred only if there
3349 * is a single block within the post and it is of a type known to match a
3350 * default post format. Returns null if the format cannot be determined.
3351 *
3352 * @return {?string} Suggested post format.
3353 */
3354 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3355 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
3356 if (blocks.length > 2) {
3357 return null;
3358 }
3359 let name;
3360 // If there is only one block in the content of the post grab its name
3361 // so we can derive a suitable post format from it.
3362 if (blocks.length === 1) {
3363 name = blocks[0].name;
3364 // Check for core/embed `video` and `audio` eligible suggestions.
3365 if (name === 'core/embed') {
3366 const provider = blocks[0].attributes?.providerNameSlug;
3367 if (['youtube', 'vimeo'].includes(provider)) {
3368 name = 'core/video';
3369 } else if (['spotify', 'soundcloud'].includes(provider)) {
3370 name = 'core/audio';
3371 }
3372 }
3373 }
3374
3375 // If there are two blocks in the content and the last one is a text blocks
3376 // grab the name of the first one to also suggest a post format from it.
3377 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
3378 name = blocks[0].name;
3379 }
3380
3381 // We only convert to default post formats in core.
3382 switch (name) {
3383 case 'core/image':
3384 return 'image';
3385 case 'core/quote':
3386 case 'core/pullquote':
3387 return 'quote';
3388 case 'core/gallery':
3389 return 'gallery';
3390 case 'core/video':
3391 return 'video';
3392 case 'core/audio':
3393 return 'audio';
3394 default:
3395 return null;
3396 }
3397 });
3398
3399 /**
3400 * Returns the content of the post being edited.
3401 *
3402 * @param {Object} state Global application state.
3403 *
3404 * @return {string} Post content.
3405 */
3406 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3407 const postId = getCurrentPostId(state);
3408 const postType = getCurrentPostType(state);
3409 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3410 if (record) {
3411 if (typeof record.content === 'function') {
3412 return record.content(record);
3413 } else if (record.blocks) {
3414 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
3415 } else if (record.content) {
3416 return record.content;
3417 }
3418 }
3419 return '';
3420 });
3421
3422 /**
3423 * Returns true if the post is being published, or false otherwise.
3424 *
3425 * @param {Object} state Global application state.
3426 *
3427 * @return {boolean} Whether post is being published.
3428 */
3429 function isPublishingPost(state) {
3430 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
3431 }
3432
3433 /**
3434 * Returns whether the permalink is editable or not.
3435 *
3436 * @param {Object} state Editor state.
3437 *
3438 * @return {boolean} Whether or not the permalink is editable.
3439 */
3440 function isPermalinkEditable(state) {
3441 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3442 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
3443 }
3444
3445 /**
3446 * Returns the permalink for the post.
3447 *
3448 * @param {Object} state Editor state.
3449 *
3450 * @return {?string} The permalink, or null if the post is not viewable.
3451 */
3452 function getPermalink(state) {
3453 const permalinkParts = getPermalinkParts(state);
3454 if (!permalinkParts) {
3455 return null;
3456 }
3457 const {
3458 prefix,
3459 postName,
3460 suffix
3461 } = permalinkParts;
3462 if (isPermalinkEditable(state)) {
3463 return prefix + postName + suffix;
3464 }
3465 return prefix;
3466 }
3467
3468 /**
3469 * Returns the slug for the post being edited, preferring a manually edited
3470 * value if one exists, then a sanitized version of the current post title, and
3471 * finally the post ID.
3472 *
3473 * @param {Object} state Editor state.
3474 *
3475 * @return {string} The current slug to be displayed in the editor
3476 */
3477 function getEditedPostSlug(state) {
3478 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
3479 }
3480
3481 /**
3482 * Returns the permalink for a post, split into its three parts: the prefix,
3483 * the postName, and the suffix.
3484 *
3485 * @param {Object} state Editor state.
3486 *
3487 * @return {Object} An object containing the prefix, postName, and suffix for
3488 * the permalink, or null if the post is not viewable.
3489 */
3490 function getPermalinkParts(state) {
3491 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3492 if (!permalinkTemplate) {
3493 return null;
3494 }
3495 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
3496 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
3497 return {
3498 prefix,
3499 postName,
3500 suffix
3501 };
3502 }
3503
3504 /**
3505 * Returns whether the post is locked.
3506 *
3507 * @param {Object} state Global application state.
3508 *
3509 * @return {boolean} Is locked.
3510 */
3511 function isPostLocked(state) {
3512 return state.postLock.isLocked;
3513 }
3514
3515 /**
3516 * Returns whether post saving is locked.
3517 *
3518 * @param {Object} state Global application state.
3519 *
3520 * @return {boolean} Is locked.
3521 */
3522 function isPostSavingLocked(state) {
3523 return Object.keys(state.postSavingLock).length > 0;
3524 }
3525
3526 /**
3527 * Returns whether post autosaving is locked.
3528 *
3529 * @param {Object} state Global application state.
3530 *
3531 * @return {boolean} Is locked.
3532 */
3533 function isPostAutosavingLocked(state) {
3534 return Object.keys(state.postAutosavingLock).length > 0;
3535 }
3536
3537 /**
3538 * Returns whether the edition of the post has been taken over.
3539 *
3540 * @param {Object} state Global application state.
3541 *
3542 * @return {boolean} Is post lock takeover.
3543 */
3544 function isPostLockTakeover(state) {
3545 return state.postLock.isTakeover;
3546 }
3547
3548 /**
3549 * Returns details about the post lock user.
3550 *
3551 * @param {Object} state Global application state.
3552 *
3553 * @return {Object} A user object.
3554 */
3555 function getPostLockUser(state) {
3556 return state.postLock.user;
3557 }
3558
3559 /**
3560 * Returns the active post lock.
3561 *
3562 * @param {Object} state Global application state.
3563 *
3564 * @return {Object} The lock object.
3565 */
3566 function getActivePostLock(state) {
3567 return state.postLock.activePostLock;
3568 }
3569
3570 /**
3571 * Returns whether or not the user has the unfiltered_html capability.
3572 *
3573 * @param {Object} state Editor state.
3574 *
3575 * @return {boolean} Whether the user can or can't post unfiltered HTML.
3576 */
3577 function canUserUseUnfilteredHTML(state) {
3578 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
3579 }
3580
3581 /**
3582 * Returns whether the pre-publish panel should be shown
3583 * or skipped when the user clicks the "publish" button.
3584 *
3585 * @return {boolean} Whether the pre-publish panel should be shown or not.
3586 */
3587 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core', 'isPublishSidebarEnabled'));
3588
3589 /**
3590 * Return the current block list.
3591 *
3592 * @param {Object} state
3593 * @return {Array} Block list.
3594 */
3595 const getEditorBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
3596 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state));
3597 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]);
3598
3599 /**
3600 * Returns true if the given panel was programmatically removed, or false otherwise.
3601 * All panels are not removed by default.
3602 *
3603 * @param {Object} state Global application state.
3604 * @param {string} panelName A string that identifies the panel.
3605 *
3606 * @return {boolean} Whether or not the panel is removed.
3607 */
3608 function isEditorPanelRemoved(state, panelName) {
3609 return state.removedPanels.includes(panelName);
3610 }
3611
3612 /**
3613 * Returns true if the given panel is enabled, or false otherwise. Panels are
3614 * enabled by default.
3615 *
3616 * @param {Object} state Global application state.
3617 * @param {string} panelName A string that identifies the panel.
3618 *
3619 * @return {boolean} Whether or not the panel is enabled.
3620 */
3621 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3622 // For backward compatibility, we check edit-post
3623 // even though now this is in "editor" package.
3624 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
3625 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
3626 });
3627
3628 /**
3629 * Returns true if the given panel is open, or false otherwise. Panels are
3630 * closed by default.
3631 *
3632 * @param {Object} state Global application state.
3633 * @param {string} panelName A string that identifies the panel.
3634 *
3635 * @return {boolean} Whether or not the panel is open.
3636 */
3637 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3638 // For backward compatibility, we check edit-post
3639 // even though now this is in "editor" package.
3640 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
3641 return !!openPanels?.includes(panelName);
3642 });
3643
3644 /**
3645 * A block selection object.
3646 *
3647 * @typedef {Object} WPBlockSelection
3648 *
3649 * @property {string} clientId A block client ID.
3650 * @property {string} attributeKey A block attribute key.
3651 * @property {number} offset An attribute value offset, based on the rich
3652 * text value. See `wp.richText.create`.
3653 */
3654
3655 /**
3656 * Returns the current selection start.
3657 *
3658 * @param {Object} state
3659 * @return {WPBlockSelection} The selection start.
3660 *
3661 * @deprecated since Gutenberg 10.0.0.
3662 */
3663 function getEditorSelectionStart(state) {
3664 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3665 since: '5.8',
3666 alternative: "select('core/editor').getEditorSelection"
3667 });
3668 return getEditedPostAttribute(state, 'selection')?.selectionStart;
3669 }
3670
3671 /**
3672 * Returns the current selection end.
3673 *
3674 * @param {Object} state
3675 * @return {WPBlockSelection} The selection end.
3676 *
3677 * @deprecated since Gutenberg 10.0.0.
3678 */
3679 function getEditorSelectionEnd(state) {
3680 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3681 since: '5.8',
3682 alternative: "select('core/editor').getEditorSelection"
3683 });
3684 return getEditedPostAttribute(state, 'selection')?.selectionEnd;
3685 }
3686
3687 /**
3688 * Returns the current selection.
3689 *
3690 * @param {Object} state
3691 * @return {WPBlockSelection} The selection end.
3692 */
3693 function getEditorSelection(state) {
3694 return getEditedPostAttribute(state, 'selection');
3695 }
3696
3697 /**
3698 * Is the editor ready
3699 *
3700 * @param {Object} state
3701 * @return {boolean} is Ready.
3702 */
3703 function __unstableIsEditorReady(state) {
3704 return !!state.postId;
3705 }
3706
3707 /**
3708 * Returns the post editor settings.
3709 *
3710 * @param {Object} state Editor state.
3711 *
3712 * @return {Object} The editor settings object.
3713 */
3714 function getEditorSettings(state) {
3715 return state.editorSettings;
3716 }
3717
3718 /**
3719 * Returns the post editor's rendering mode.
3720 *
3721 * @param {Object} state Editor state.
3722 *
3723 * @return {string} Rendering mode.
3724 */
3725 function getRenderingMode(state) {
3726 return state.renderingMode;
3727 }
3728
3729 /**
3730 * Returns the current editing canvas device type.
3731 *
3732 * @param {Object} state Global application state.
3733 *
3734 * @return {string} Device type.
3735 */
3736 const getDeviceType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3737 const isZoomOut = unlock(select(external_wp_blockEditor_namespaceObject.store)).isZoomOut();
3738 if (isZoomOut) {
3739 return 'Desktop';
3740 }
3741 return state.deviceType;
3742 });
3743
3744 /**
3745 * Returns true if the list view is opened.
3746 *
3747 * @param {Object} state Global application state.
3748 *
3749 * @return {boolean} Whether the list view is opened.
3750 */
3751 function isListViewOpened(state) {
3752 return state.listViewPanel;
3753 }
3754
3755 /**
3756 * Returns true if the inserter is opened.
3757 *
3758 * @param {Object} state Global application state.
3759 *
3760 * @return {boolean} Whether the inserter is opened.
3761 */
3762 function isInserterOpened(state) {
3763 return !!state.blockInserterPanel;
3764 }
3765
3766 /**
3767 * Returns the current editing mode.
3768 *
3769 * @param {Object} state Global application state.
3770 *
3771 * @return {string} Editing mode.
3772 */
3773 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3774 var _select$get;
3775 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
3776 });
3777
3778 /*
3779 * Backward compatibility
3780 */
3781
3782 /**
3783 * Returns state object prior to a specified optimist transaction ID, or `null`
3784 * if the transaction corresponding to the given ID cannot be found.
3785 *
3786 * @deprecated since Gutenberg 9.7.0.
3787 */
3788 function getStateBeforeOptimisticTransaction() {
3789 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3790 since: '5.7',
3791 hint: 'No state history is kept on this store anymore'
3792 });
3793 return null;
3794 }
3795 /**
3796 * Returns true if an optimistic transaction is pending commit, for which the
3797 * before state satisfies the given predicate function.
3798 *
3799 * @deprecated since Gutenberg 9.7.0.
3800 */
3801 function inSomeHistory() {
3802 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3803 since: '5.7',
3804 hint: 'No state history is kept on this store anymore'
3805 });
3806 return false;
3807 }
3808 function getBlockEditorSelector(name) {
3809 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => {
3810 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3811 since: '5.3',
3812 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3813 version: '6.2'
3814 });
3815 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3816 });
3817 }
3818
3819 /**
3820 * @see getBlockName in core/block-editor store.
3821 */
3822 const getBlockName = getBlockEditorSelector('getBlockName');
3823
3824 /**
3825 * @see isBlockValid in core/block-editor store.
3826 */
3827 const isBlockValid = getBlockEditorSelector('isBlockValid');
3828
3829 /**
3830 * @see getBlockAttributes in core/block-editor store.
3831 */
3832 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3833
3834 /**
3835 * @see getBlock in core/block-editor store.
3836 */
3837 const getBlock = getBlockEditorSelector('getBlock');
3838
3839 /**
3840 * @see getBlocks in core/block-editor store.
3841 */
3842 const getBlocks = getBlockEditorSelector('getBlocks');
3843
3844 /**
3845 * @see getClientIdsOfDescendants in core/block-editor store.
3846 */
3847 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3848
3849 /**
3850 * @see getClientIdsWithDescendants in core/block-editor store.
3851 */
3852 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3853
3854 /**
3855 * @see getGlobalBlockCount in core/block-editor store.
3856 */
3857 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3858
3859 /**
3860 * @see getBlocksByClientId in core/block-editor store.
3861 */
3862 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3863
3864 /**
3865 * @see getBlockCount in core/block-editor store.
3866 */
3867 const getBlockCount = getBlockEditorSelector('getBlockCount');
3868
3869 /**
3870 * @see getBlockSelectionStart in core/block-editor store.
3871 */
3872 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3873
3874 /**
3875 * @see getBlockSelectionEnd in core/block-editor store.
3876 */
3877 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3878
3879 /**
3880 * @see getSelectedBlockCount in core/block-editor store.
3881 */
3882 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3883
3884 /**
3885 * @see hasSelectedBlock in core/block-editor store.
3886 */
3887 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3888
3889 /**
3890 * @see getSelectedBlockClientId in core/block-editor store.
3891 */
3892 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3893
3894 /**
3895 * @see getSelectedBlock in core/block-editor store.
3896 */
3897 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3898
3899 /**
3900 * @see getBlockRootClientId in core/block-editor store.
3901 */
3902 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3903
3904 /**
3905 * @see getBlockHierarchyRootClientId in core/block-editor store.
3906 */
3907 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3908
3909 /**
3910 * @see getAdjacentBlockClientId in core/block-editor store.
3911 */
3912 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3913
3914 /**
3915 * @see getPreviousBlockClientId in core/block-editor store.
3916 */
3917 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3918
3919 /**
3920 * @see getNextBlockClientId in core/block-editor store.
3921 */
3922 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3923
3924 /**
3925 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3926 */
3927 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3928
3929 /**
3930 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3931 */
3932 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3933
3934 /**
3935 * @see getMultiSelectedBlocks in core/block-editor store.
3936 */
3937 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3938
3939 /**
3940 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3941 */
3942 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3943
3944 /**
3945 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3946 */
3947 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3948
3949 /**
3950 * @see isFirstMultiSelectedBlock in core/block-editor store.
3951 */
3952 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3953
3954 /**
3955 * @see isBlockMultiSelected in core/block-editor store.
3956 */
3957 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3958
3959 /**
3960 * @see isAncestorMultiSelected in core/block-editor store.
3961 */
3962 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3963
3964 /**
3965 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3966 */
3967 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3968
3969 /**
3970 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3971 */
3972 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3973
3974 /**
3975 * @see getBlockOrder in core/block-editor store.
3976 */
3977 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3978
3979 /**
3980 * @see getBlockIndex in core/block-editor store.
3981 */
3982 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3983
3984 /**
3985 * @see isBlockSelected in core/block-editor store.
3986 */
3987 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3988
3989 /**
3990 * @see hasSelectedInnerBlock in core/block-editor store.
3991 */
3992 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3993
3994 /**
3995 * @see isBlockWithinSelection in core/block-editor store.
3996 */
3997 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3998
3999 /**
4000 * @see hasMultiSelection in core/block-editor store.
4001 */
4002 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
4003
4004 /**
4005 * @see isMultiSelecting in core/block-editor store.
4006 */
4007 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
4008
4009 /**
4010 * @see isSelectionEnabled in core/block-editor store.
4011 */
4012 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
4013
4014 /**
4015 * @see getBlockMode in core/block-editor store.
4016 */
4017 const getBlockMode = getBlockEditorSelector('getBlockMode');
4018
4019 /**
4020 * @see isTyping in core/block-editor store.
4021 */
4022 const isTyping = getBlockEditorSelector('isTyping');
4023
4024 /**
4025 * @see isCaretWithinFormattedText in core/block-editor store.
4026 */
4027 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
4028
4029 /**
4030 * @see getBlockInsertionPoint in core/block-editor store.
4031 */
4032 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
4033
4034 /**
4035 * @see isBlockInsertionPointVisible in core/block-editor store.
4036 */
4037 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
4038
4039 /**
4040 * @see isValidTemplate in core/block-editor store.
4041 */
4042 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
4043
4044 /**
4045 * @see getTemplate in core/block-editor store.
4046 */
4047 const getTemplate = getBlockEditorSelector('getTemplate');
4048
4049 /**
4050 * @see getTemplateLock in core/block-editor store.
4051 */
4052 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
4053
4054 /**
4055 * @see canInsertBlockType in core/block-editor store.
4056 */
4057 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
4058
4059 /**
4060 * @see getInserterItems in core/block-editor store.
4061 */
4062 const getInserterItems = getBlockEditorSelector('getInserterItems');
4063
4064 /**
4065 * @see hasInserterItems in core/block-editor store.
4066 */
4067 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
4068
4069 /**
4070 * @see getBlockListSettings in core/block-editor store.
4071 */
4072 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
4073 const __experimentalGetDefaultTemplateTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
4074 external_wp_deprecated_default()("select('core/editor').__experimentalGetDefaultTemplateTypes", {
4075 since: '6.8',
4076 alternative: "select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.default_template_types"
4077 });
4078 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_types;
4079 });
4080
4081 /**
4082 * Returns the default template part areas.
4083 *
4084 * @param {Object} state Global application state.
4085 *
4086 * @return {Array} The template part areas.
4087 */
4088 const __experimentalGetDefaultTemplatePartAreas = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(() => {
4089 external_wp_deprecated_default()("select('core/editor').__experimentalGetDefaultTemplatePartAreas", {
4090 since: '6.8',
4091 alternative: "select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.default_template_part_areas"
4092 });
4093 const areas = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas || [];
4094 return areas.map(item => {
4095 return {
4096 ...item,
4097 icon: getTemplatePartIcon(item.icon)
4098 };
4099 });
4100 }));
4101
4102 /**
4103 * Returns a default template type searched by slug.
4104 *
4105 * @param {Object} state Global application state.
4106 * @param {string} slug The template type slug.
4107 *
4108 * @return {Object} The template type.
4109 */
4110 const __experimentalGetDefaultTemplateType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, slug) => {
4111 var _Object$values$find;
4112 external_wp_deprecated_default()("select('core/editor').__experimentalGetDefaultTemplateType", {
4113 since: '6.8'
4114 });
4115 const templateTypes = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_types;
4116 if (!templateTypes) {
4117 return selectors_EMPTY_OBJECT;
4118 }
4119 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : selectors_EMPTY_OBJECT;
4120 }));
4121
4122 /**
4123 * Given a template entity, return information about it which is ready to be
4124 * rendered, such as the title, description, and icon.
4125 *
4126 * @param {Object} state Global application state.
4127 * @param {Object} template The template for which we need information.
4128 * @return {Object} Information about the template, including title, description, and icon.
4129 */
4130 const __experimentalGetTemplateInfo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, template) => {
4131 external_wp_deprecated_default()("select('core/editor').__experimentalGetTemplateInfo", {
4132 since: '6.8'
4133 });
4134 if (!template) {
4135 return selectors_EMPTY_OBJECT;
4136 }
4137 const templateTypes = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_types || [];
4138 const templateAreas = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas || [];
4139 return getTemplateInfo({
4140 template,
4141 templateAreas,
4142 templateTypes
4143 });
4144 }));
4145
4146 /**
4147 * Returns a post type label depending on the current post.
4148 *
4149 * @param {Object} state Global application state.
4150 *
4151 * @return {string|undefined} The post type label if available, otherwise undefined.
4152 */
4153 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4154 const currentPostType = getCurrentPostType(state);
4155 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType);
4156 // Disable reason: Post type labels object is shaped like this.
4157 // eslint-disable-next-line camelcase
4158 return postType?.labels?.singular_name;
4159 });
4160
4161 /**
4162 * Returns true if the publish sidebar is opened.
4163 *
4164 * @param {Object} state Global application state
4165 *
4166 * @return {boolean} Whether the publish sidebar is open.
4167 */
4168 function isPublishSidebarOpened(state) {
4169 return state.publishSidebarActive;
4170 }
4171
4172 ;// external ["wp","a11y"]
4173 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
4174 ;// external ["wp","apiFetch"]
4175 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
4176 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
4177 ;// external ["wp","notices"]
4178 const external_wp_notices_namespaceObject = window["wp"]["notices"];
4179 ;// external ["wp","i18n"]
4180 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
4181 ;// ./packages/editor/build-module/store/local-autosave.js
4182 /**
4183 * Function returning a sessionStorage key to set or retrieve a given post's
4184 * automatic session backup.
4185 *
4186 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
4187 * `loggedout` handler can clear sessionStorage of any user-private content.
4188 *
4189 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
4190 *
4191 * @param {string} postId Post ID.
4192 * @param {boolean} isPostNew Whether post new.
4193 *
4194 * @return {string} sessionStorage key
4195 */
4196 function postKey(postId, isPostNew) {
4197 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
4198 }
4199 function localAutosaveGet(postId, isPostNew) {
4200 return window.sessionStorage.getItem(postKey(postId, isPostNew));
4201 }
4202 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
4203 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
4204 post_title: title,
4205 content,
4206 excerpt
4207 }));
4208 }
4209 function localAutosaveClear(postId, isPostNew) {
4210 window.sessionStorage.removeItem(postKey(postId, isPostNew));
4211 }
4212
4213 ;// ./packages/editor/build-module/store/utils/notice-builder.js
4214 /**
4215 * WordPress dependencies
4216 */
4217
4218
4219 /**
4220 * Builds the arguments for a success notification dispatch.
4221 *
4222 * @param {Object} data Incoming data to build the arguments from.
4223 *
4224 * @return {Array} Arguments for dispatch. An empty array signals no
4225 * notification should be sent.
4226 */
4227 function getNotificationArgumentsForSaveSuccess(data) {
4228 var _postType$viewable;
4229 const {
4230 previousPost,
4231 post,
4232 postType
4233 } = data;
4234 // Autosaves are neither shown a notice nor redirected.
4235 if (data.options?.isAutosave) {
4236 return [];
4237 }
4238 const publishStatus = ['publish', 'private', 'future'];
4239 const isPublished = publishStatus.includes(previousPost.status);
4240 const willPublish = publishStatus.includes(post.status);
4241 const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
4242 let noticeMessage;
4243 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
4244 let isDraft;
4245
4246 // Always should a notice, which will be spoken for accessibility.
4247 if (willTrash) {
4248 noticeMessage = postType.labels.item_trashed;
4249 shouldShowLink = false;
4250 } else if (!isPublished && !willPublish) {
4251 // If saving a non-published post, don't show notice.
4252 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
4253 isDraft = true;
4254 } else if (isPublished && !willPublish) {
4255 // If undoing publish status, show specific notice.
4256 noticeMessage = postType.labels.item_reverted_to_draft;
4257 shouldShowLink = false;
4258 } else if (!isPublished && willPublish) {
4259 // If publishing or scheduling a post, show the corresponding
4260 // publish message.
4261 noticeMessage = {
4262 publish: postType.labels.item_published,
4263 private: postType.labels.item_published_privately,
4264 future: postType.labels.item_scheduled
4265 }[post.status];
4266 } else {
4267 // Generic fallback notice.
4268 noticeMessage = postType.labels.item_updated;
4269 }
4270 const actions = [];
4271 if (shouldShowLink) {
4272 actions.push({
4273 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
4274 url: post.link
4275 });
4276 }
4277 return [noticeMessage, {
4278 id: 'editor-save',
4279 type: 'snackbar',
4280 actions
4281 }];
4282 }
4283
4284 /**
4285 * Builds the fail notification arguments for dispatch.
4286 *
4287 * @param {Object} data Incoming data to build the arguments with.
4288 *
4289 * @return {Array} Arguments for dispatch. An empty array signals no
4290 * notification should be sent.
4291 */
4292 function getNotificationArgumentsForSaveFail(data) {
4293 const {
4294 post,
4295 edits,
4296 error
4297 } = data;
4298 if (error && 'rest_autosave_no_changes' === error.code) {
4299 // Autosave requested a new autosave, but there were no changes. This shouldn't
4300 // result in an error notice for the user.
4301 return [];
4302 }
4303 const publishStatus = ['publish', 'private', 'future'];
4304 const isPublished = publishStatus.indexOf(post.status) !== -1;
4305 // If the post was being published, we show the corresponding publish error message
4306 // Unless we publish an "updating failed" message.
4307 const messages = {
4308 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4309 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4310 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
4311 };
4312 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.');
4313
4314 // Check if message string contains HTML. Notice text is currently only
4315 // supported as plaintext, and stripping the tags may muddle the meaning.
4316 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4317 noticeMessage = [noticeMessage, error.message].join(' ');
4318 }
4319 return [noticeMessage, {
4320 id: 'editor-save'
4321 }];
4322 }
4323
4324 /**
4325 * Builds the trash fail notification arguments for dispatch.
4326 *
4327 * @param {Object} data
4328 *
4329 * @return {Array} Arguments for dispatch.
4330 */
4331 function getNotificationArgumentsForTrashFail(data) {
4332 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
4333 id: 'editor-trash-fail'
4334 }];
4335 }
4336
4337 ;// ./packages/editor/build-module/store/actions.js
4338 /* wp:polyfill */
4339 /**
4340 * WordPress dependencies
4341 */
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353 /**
4354 * Internal dependencies
4355 */
4356
4357
4358
4359 /**
4360 * Returns an action generator used in signalling that editor has initialized with
4361 * the specified post object and editor settings.
4362 *
4363 * @param {Object} post Post object.
4364 * @param {Object} edits Initial edited attributes object.
4365 * @param {Array} [template] Block Template.
4366 */
4367 const setupEditor = (post, edits, template) => ({
4368 dispatch
4369 }) => {
4370 dispatch.setEditedPost(post.type, post.id);
4371 // Apply a template for new posts only, if exists.
4372 const isNewPost = post.status === 'auto-draft';
4373 if (isNewPost && template) {
4374 // In order to ensure maximum of a single parse during setup, edits are
4375 // included as part of editor setup action. Assume edited content as
4376 // canonical if provided, falling back to post.
4377 let content;
4378 if ('content' in edits) {
4379 content = edits.content;
4380 } else {
4381 content = post.content.raw;
4382 }
4383 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
4384 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
4385 dispatch.resetEditorBlocks(blocks, {
4386 __unstableShouldCreateUndoLevel: false
4387 });
4388 }
4389 if (edits && Object.values(edits).some(([key, edit]) => {
4390 var _post$key$raw;
4391 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
4392 })) {
4393 dispatch.editPost(edits);
4394 }
4395 };
4396
4397 /**
4398 * Returns an action object signalling that the editor is being destroyed and
4399 * that any necessary state or side-effect cleanup should occur.
4400 *
4401 * @deprecated
4402 *
4403 * @return {Object} Action object.
4404 */
4405 function __experimentalTearDownEditor() {
4406 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
4407 since: '6.5'
4408 });
4409 return {
4410 type: 'DO_NOTHING'
4411 };
4412 }
4413
4414 /**
4415 * Returns an action object used in signalling that the latest version of the
4416 * post has been received, either by initialization or save.
4417 *
4418 * @deprecated Since WordPress 6.0.
4419 */
4420 function resetPost() {
4421 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
4422 since: '6.0',
4423 version: '6.3',
4424 alternative: 'Initialize the editor with the setupEditorState action'
4425 });
4426 return {
4427 type: 'DO_NOTHING'
4428 };
4429 }
4430
4431 /**
4432 * Returns an action object used in signalling that a patch of updates for the
4433 * latest version of the post have been received.
4434 *
4435 * @return {Object} Action object.
4436 * @deprecated since Gutenberg 9.7.0.
4437 */
4438 function updatePost() {
4439 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
4440 since: '5.7',
4441 alternative: 'Use the core entities store instead'
4442 });
4443 return {
4444 type: 'DO_NOTHING'
4445 };
4446 }
4447
4448 /**
4449 * Setup the editor state.
4450 *
4451 * @deprecated
4452 *
4453 * @param {Object} post Post object.
4454 */
4455 function setupEditorState(post) {
4456 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4457 since: '6.5',
4458 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4459 });
4460 return setEditedPost(post.type, post.id);
4461 }
4462
4463 /**
4464 * Returns an action that sets the current post Type and post ID.
4465 *
4466 * @param {string} postType Post Type.
4467 * @param {string} postId Post ID.
4468 *
4469 * @return {Object} Action object.
4470 */
4471 function setEditedPost(postType, postId) {
4472 return {
4473 type: 'SET_EDITED_POST',
4474 postType,
4475 postId
4476 };
4477 }
4478
4479 /**
4480 * Returns an action object used in signalling that attributes of the post have
4481 * been edited.
4482 *
4483 * @param {Object} edits Post attributes to edit.
4484 * @param {Object} [options] Options for the edit.
4485 *
4486 * @example
4487 * ```js
4488 * // Update the post title
4489 * wp.data.dispatch( 'core/editor' ).editPost( { title: `${ newTitle }` } );
4490 * ```
4491 *
4492 * @example
4493 *```js
4494 * // Get specific media size based on the featured media ID
4495 * // Note: change sizes?.large for any registered size
4496 * const getFeaturedMediaUrl = useSelect( ( select ) => {
4497 * const getFeaturedMediaId =
4498 * select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
4499 * const getMedia = select( 'core' ).getMedia( getFeaturedMediaId );
4500 *
4501 * return (
4502 * getMedia?.media_details?.sizes?.large?.source_url || getMedia?.source_url || ''
4503 * );
4504 * }, [] );
4505 * ```
4506 *
4507 * @return {Object} Action object
4508 */
4509 const editPost = (edits, options) => ({
4510 select,
4511 registry
4512 }) => {
4513 const {
4514 id,
4515 type
4516 } = select.getCurrentPost();
4517 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
4518 };
4519
4520 /**
4521 * Action for saving the current post in the editor.
4522 *
4523 * @param {Object} [options]
4524 */
4525 const savePost = (options = {}) => async ({
4526 select,
4527 dispatch,
4528 registry
4529 }) => {
4530 if (!select.isEditedPostSaveable()) {
4531 return;
4532 }
4533 const content = select.getEditedPostContent();
4534 if (!options.isAutosave) {
4535 dispatch.editPost({
4536 content
4537 }, {
4538 undoIgnore: true
4539 });
4540 }
4541 const previousRecord = select.getCurrentPost();
4542 let edits = {
4543 id: previousRecord.id,
4544 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
4545 content
4546 };
4547 dispatch({
4548 type: 'REQUEST_POST_UPDATE_START',
4549 options
4550 });
4551 let error = false;
4552 try {
4553 edits = await (0,external_wp_hooks_namespaceObject.applyFiltersAsync)('editor.preSavePost', edits, options);
4554 } catch (err) {
4555 error = err;
4556 }
4557 if (!error) {
4558 try {
4559 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
4560 } catch (err) {
4561 error = err.message && err.code !== 'unknown_error' ? err.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating.');
4562 }
4563 }
4564 if (!error) {
4565 error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
4566 }
4567
4568 // Run the hook with legacy unstable name for backward compatibility
4569 if (!error) {
4570 try {
4571 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options);
4572 } catch (err) {
4573 error = err;
4574 }
4575 }
4576 if (!error) {
4577 try {
4578 await (0,external_wp_hooks_namespaceObject.doActionAsync)('editor.savePost', {
4579 id: previousRecord.id
4580 }, options);
4581 } catch (err) {
4582 error = err;
4583 }
4584 }
4585 dispatch({
4586 type: 'REQUEST_POST_UPDATE_FINISH',
4587 options
4588 });
4589 if (error) {
4590 const args = getNotificationArgumentsForSaveFail({
4591 post: previousRecord,
4592 edits,
4593 error
4594 });
4595 if (args.length) {
4596 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
4597 }
4598 } else {
4599 const updatedRecord = select.getCurrentPost();
4600 const args = getNotificationArgumentsForSaveSuccess({
4601 previousPost: previousRecord,
4602 post: updatedRecord,
4603 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
4604 options
4605 });
4606 if (args.length) {
4607 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
4608 }
4609 // Make sure that any edits after saving create an undo level and are
4610 // considered for change detection.
4611 if (!options.isAutosave) {
4612 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
4613 }
4614 }
4615 };
4616
4617 /**
4618 * Action for refreshing the current post.
4619 *
4620 * @deprecated Since WordPress 6.0.
4621 */
4622 function refreshPost() {
4623 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
4624 since: '6.0',
4625 version: '6.3',
4626 alternative: 'Use the core entities store instead'
4627 });
4628 return {
4629 type: 'DO_NOTHING'
4630 };
4631 }
4632
4633 /**
4634 * Action for trashing the current post in the editor.
4635 */
4636 const trashPost = () => async ({
4637 select,
4638 dispatch,
4639 registry
4640 }) => {
4641 const postTypeSlug = select.getCurrentPostType();
4642 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
4643 const {
4644 rest_base: restBase,
4645 rest_namespace: restNamespace = 'wp/v2'
4646 } = postType;
4647 dispatch({
4648 type: 'REQUEST_POST_DELETE_START'
4649 });
4650 try {
4651 const post = select.getCurrentPost();
4652 await external_wp_apiFetch_default()({
4653 path: `/${restNamespace}/${restBase}/${post.id}`,
4654 method: 'DELETE'
4655 });
4656 await dispatch.savePost();
4657 } catch (error) {
4658 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
4659 error
4660 }));
4661 }
4662 dispatch({
4663 type: 'REQUEST_POST_DELETE_FINISH'
4664 });
4665 };
4666
4667 /**
4668 * Action that autosaves the current post. This
4669 * includes server-side autosaving (default) and client-side (a.k.a. local)
4670 * autosaving (e.g. on the Web, the post might be committed to Session
4671 * Storage).
4672 *
4673 * @param {Object} [options] Extra flags to identify the autosave.
4674 * @param {boolean} [options.local] Whether to perform a local autosave.
4675 */
4676 const autosave = ({
4677 local = false,
4678 ...options
4679 } = {}) => async ({
4680 select,
4681 dispatch
4682 }) => {
4683 const post = select.getCurrentPost();
4684
4685 // Currently template autosaving is not supported.
4686 if (post.type === 'wp_template') {
4687 return;
4688 }
4689 if (local) {
4690 const isPostNew = select.isEditedPostNew();
4691 const title = select.getEditedPostAttribute('title');
4692 const content = select.getEditedPostAttribute('content');
4693 const excerpt = select.getEditedPostAttribute('excerpt');
4694 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
4695 } else {
4696 await dispatch.savePost({
4697 isAutosave: true,
4698 ...options
4699 });
4700 }
4701 };
4702 const __unstableSaveForPreview = ({
4703 forceIsAutosaveable
4704 } = {}) => async ({
4705 select,
4706 dispatch
4707 }) => {
4708 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
4709 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
4710 if (isDraft) {
4711 await dispatch.savePost({
4712 isPreview: true
4713 });
4714 } else {
4715 await dispatch.autosave({
4716 isPreview: true
4717 });
4718 }
4719 }
4720 return select.getEditedPostPreviewLink();
4721 };
4722
4723 /**
4724 * Action that restores last popped state in undo history.
4725 */
4726 const redo = () => ({
4727 registry
4728 }) => {
4729 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
4730 };
4731
4732 /**
4733 * Action that pops a record from undo history and undoes the edit.
4734 */
4735 const undo = () => ({
4736 registry
4737 }) => {
4738 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
4739 };
4740
4741 /**
4742 * Action that creates an undo history record.
4743 *
4744 * @deprecated Since WordPress 6.0
4745 */
4746 function createUndoLevel() {
4747 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4748 since: '6.0',
4749 version: '6.3',
4750 alternative: 'Use the core entities store instead'
4751 });
4752 return {
4753 type: 'DO_NOTHING'
4754 };
4755 }
4756
4757 /**
4758 * Action that locks the editor.
4759 *
4760 * @param {Object} lock Details about the post lock status, user, and nonce.
4761 * @return {Object} Action object.
4762 */
4763 function updatePostLock(lock) {
4764 return {
4765 type: 'UPDATE_POST_LOCK',
4766 lock
4767 };
4768 }
4769
4770 /**
4771 * Enable the publish sidebar.
4772 */
4773 const enablePublishSidebar = () => ({
4774 registry
4775 }) => {
4776 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
4777 };
4778
4779 /**
4780 * Disables the publish sidebar.
4781 */
4782 const disablePublishSidebar = () => ({
4783 registry
4784 }) => {
4785 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
4786 };
4787
4788 /**
4789 * Action that locks post saving.
4790 *
4791 * @param {string} lockName The lock name.
4792 *
4793 * @example
4794 * ```
4795 * const { subscribe } = wp.data;
4796 *
4797 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4798 *
4799 * // Only allow publishing posts that are set to a future date.
4800 * if ( 'publish' !== initialPostStatus ) {
4801 *
4802 * // Track locking.
4803 * let locked = false;
4804 *
4805 * // Watch for the publish event.
4806 * let unssubscribe = subscribe( () => {
4807 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4808 * if ( 'publish' !== currentPostStatus ) {
4809 *
4810 * // Compare the post date to the current date, lock the post if the date isn't in the future.
4811 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
4812 * const currentDate = new Date();
4813 * if ( postDate.getTime() <= currentDate.getTime() ) {
4814 * if ( ! locked ) {
4815 * locked = true;
4816 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
4817 * }
4818 * } else {
4819 * if ( locked ) {
4820 * locked = false;
4821 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
4822 * }
4823 * }
4824 * }
4825 * } );
4826 * }
4827 * ```
4828 *
4829 * @return {Object} Action object
4830 */
4831 function lockPostSaving(lockName) {
4832 return {
4833 type: 'LOCK_POST_SAVING',
4834 lockName
4835 };
4836 }
4837
4838 /**
4839 * Action that unlocks post saving.
4840 *
4841 * @param {string} lockName The lock name.
4842 *
4843 * @example
4844 * ```
4845 * // Unlock post saving with the lock key `mylock`:
4846 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4847 * ```
4848 *
4849 * @return {Object} Action object
4850 */
4851 function unlockPostSaving(lockName) {
4852 return {
4853 type: 'UNLOCK_POST_SAVING',
4854 lockName
4855 };
4856 }
4857
4858 /**
4859 * Action that locks post autosaving.
4860 *
4861 * @param {string} lockName The lock name.
4862 *
4863 * @example
4864 * ```
4865 * // Lock post autosaving with the lock key `mylock`:
4866 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4867 * ```
4868 *
4869 * @return {Object} Action object
4870 */
4871 function lockPostAutosaving(lockName) {
4872 return {
4873 type: 'LOCK_POST_AUTOSAVING',
4874 lockName
4875 };
4876 }
4877
4878 /**
4879 * Action that unlocks post autosaving.
4880 *
4881 * @param {string} lockName The lock name.
4882 *
4883 * @example
4884 * ```
4885 * // Unlock post saving with the lock key `mylock`:
4886 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4887 * ```
4888 *
4889 * @return {Object} Action object
4890 */
4891 function unlockPostAutosaving(lockName) {
4892 return {
4893 type: 'UNLOCK_POST_AUTOSAVING',
4894 lockName
4895 };
4896 }
4897
4898 /**
4899 * Returns an action object used to signal that the blocks have been updated.
4900 *
4901 * @param {Array} blocks Block Array.
4902 * @param {Object} [options] Optional options.
4903 */
4904 const resetEditorBlocks = (blocks, options = {}) => ({
4905 select,
4906 dispatch,
4907 registry
4908 }) => {
4909 const {
4910 __unstableShouldCreateUndoLevel,
4911 selection
4912 } = options;
4913 const edits = {
4914 blocks,
4915 selection
4916 };
4917 if (__unstableShouldCreateUndoLevel !== false) {
4918 const {
4919 id,
4920 type
4921 } = select.getCurrentPost();
4922 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4923 if (noChange) {
4924 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4925 return;
4926 }
4927
4928 // We create a new function here on every persistent edit
4929 // to make sure the edit makes the post dirty and creates
4930 // a new undo level.
4931 edits.content = ({
4932 blocks: blocksForSerialization = []
4933 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4934 }
4935 dispatch.editPost(edits);
4936 };
4937
4938 /*
4939 * Returns an action object used in signalling that the post editor settings have been updated.
4940 *
4941 * @param {Object} settings Updated settings
4942 *
4943 * @return {Object} Action object
4944 */
4945 function updateEditorSettings(settings) {
4946 return {
4947 type: 'UPDATE_EDITOR_SETTINGS',
4948 settings
4949 };
4950 }
4951
4952 /**
4953 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
4954 *
4955 * - `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.
4956 * - `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.
4957 *
4958 * @param {string} mode Mode (one of 'post-only' or 'template-locked').
4959 */
4960 const setRenderingMode = mode => ({
4961 dispatch,
4962 registry,
4963 select
4964 }) => {
4965 if (select.__unstableIsEditorReady()) {
4966 // We clear the block selection but we also need to clear the selection from the core store.
4967 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4968 dispatch.editPost({
4969 selection: undefined
4970 }, {
4971 undoIgnore: true
4972 });
4973 }
4974 dispatch({
4975 type: 'SET_RENDERING_MODE',
4976 mode
4977 });
4978 };
4979
4980 /**
4981 * Action that changes the width of the editing canvas.
4982 *
4983 * @param {string} deviceType
4984 *
4985 * @return {Object} Action object.
4986 */
4987 function setDeviceType(deviceType) {
4988 return {
4989 type: 'SET_DEVICE_TYPE',
4990 deviceType
4991 };
4992 }
4993
4994 /**
4995 * Returns an action object used to enable or disable a panel in the editor.
4996 *
4997 * @param {string} panelName A string that identifies the panel to enable or disable.
4998 *
4999 * @return {Object} Action object.
5000 */
5001 const toggleEditorPanelEnabled = panelName => ({
5002 registry
5003 }) => {
5004 var _registry$select$get;
5005 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
5006 const isPanelInactive = !!inactivePanels?.includes(panelName);
5007
5008 // If the panel is inactive, remove it to enable it, else add it to
5009 // make it inactive.
5010 let updatedInactivePanels;
5011 if (isPanelInactive) {
5012 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
5013 } else {
5014 updatedInactivePanels = [...inactivePanels, panelName];
5015 }
5016 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
5017 };
5018
5019 /**
5020 * Opens a closed panel and closes an open panel.
5021 *
5022 * @param {string} panelName A string that identifies the panel to open or close.
5023 */
5024 const toggleEditorPanelOpened = panelName => ({
5025 registry
5026 }) => {
5027 var _registry$select$get2;
5028 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
5029 const isPanelOpen = !!openPanels?.includes(panelName);
5030
5031 // If the panel is open, remove it to close it, else add it to
5032 // make it open.
5033 let updatedOpenPanels;
5034 if (isPanelOpen) {
5035 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
5036 } else {
5037 updatedOpenPanels = [...openPanels, panelName];
5038 }
5039 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
5040 };
5041
5042 /**
5043 * Returns an action object used to remove a panel from the editor.
5044 *
5045 * @param {string} panelName A string that identifies the panel to remove.
5046 *
5047 * @return {Object} Action object.
5048 */
5049 function removeEditorPanel(panelName) {
5050 return {
5051 type: 'REMOVE_PANEL',
5052 panelName
5053 };
5054 }
5055
5056 /**
5057 * Returns an action object used to open/close the inserter.
5058 *
5059 * @param {boolean|Object} value Whether the inserter should be
5060 * opened (true) or closed (false).
5061 * To specify an insertion point,
5062 * use an object.
5063 * @param {string} value.rootClientId The root client ID to insert at.
5064 * @param {number} value.insertionIndex The index to insert at.
5065 * @param {string} value.filterValue A query to filter the inserter results.
5066 * @param {Function} value.onSelect A callback when an item is selected.
5067 * @param {string} value.tab The tab to open in the inserter.
5068 * @param {string} value.category The category to initialize in the inserter.
5069 *
5070 * @return {Object} Action object.
5071 */
5072 const setIsInserterOpened = value => ({
5073 dispatch,
5074 registry
5075 }) => {
5076 if (typeof value === 'object' && value.hasOwnProperty('rootClientId') && value.hasOwnProperty('insertionIndex')) {
5077 unlock(registry.dispatch(external_wp_blockEditor_namespaceObject.store)).setInsertionPoint({
5078 rootClientId: value.rootClientId,
5079 index: value.insertionIndex
5080 });
5081 }
5082 dispatch({
5083 type: 'SET_IS_INSERTER_OPENED',
5084 value
5085 });
5086 };
5087
5088 /**
5089 * Returns an action object used to open/close the list view.
5090 *
5091 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
5092 * @return {Object} Action object.
5093 */
5094 function setIsListViewOpened(isOpen) {
5095 return {
5096 type: 'SET_IS_LIST_VIEW_OPENED',
5097 isOpen
5098 };
5099 }
5100
5101 /**
5102 * Action that toggles Distraction free mode.
5103 * Distraction free mode expects there are no sidebars, as due to the
5104 * z-index values set, you can't close sidebars.
5105 *
5106 * @param {Object} [options={}] Optional configuration object
5107 * @param {boolean} [options.createNotice=true] Whether to create a notice
5108 */
5109 const toggleDistractionFree = ({
5110 createNotice = true
5111 } = {}) => ({
5112 dispatch,
5113 registry
5114 }) => {
5115 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5116 if (isDistractionFree) {
5117 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
5118 }
5119 if (!isDistractionFree) {
5120 registry.batch(() => {
5121 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
5122 dispatch.setIsInserterOpened(false);
5123 dispatch.setIsListViewOpened(false);
5124 unlock(registry.dispatch(external_wp_blockEditor_namespaceObject.store)).resetZoomLevel();
5125 });
5126 }
5127 registry.batch(() => {
5128 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
5129 if (createNotice) {
5130 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated.'), {
5131 id: 'core/editor/distraction-free-mode/notice',
5132 type: 'snackbar',
5133 actions: [{
5134 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5135 onClick: () => {
5136 registry.batch(() => {
5137 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree);
5138 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');
5139 });
5140 }
5141 }]
5142 });
5143 }
5144 });
5145 };
5146
5147 /**
5148 * Action that toggles the Spotlight Mode view option.
5149 */
5150 const toggleSpotlightMode = () => ({
5151 registry
5152 }) => {
5153 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'focusMode');
5154 const isFocusMode = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'focusMode');
5155 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated.'), {
5156 id: 'core/editor/toggle-spotlight-mode/notice',
5157 type: 'snackbar',
5158 actions: [{
5159 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5160 onClick: () => {
5161 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'focusMode');
5162 }
5163 }]
5164 });
5165 };
5166
5167 /**
5168 * Action that toggles the Top Toolbar view option.
5169 */
5170 const toggleTopToolbar = () => ({
5171 registry
5172 }) => {
5173 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'fixedToolbar');
5174 const isTopToolbar = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'fixedToolbar');
5175 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated.'), {
5176 id: 'core/editor/toggle-top-toolbar/notice',
5177 type: 'snackbar',
5178 actions: [{
5179 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5180 onClick: () => {
5181 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'fixedToolbar');
5182 }
5183 }]
5184 });
5185 };
5186
5187 /**
5188 * Triggers an action used to switch editor mode.
5189 *
5190 * @param {string} mode The editor mode.
5191 */
5192 const switchEditorMode = mode => ({
5193 dispatch,
5194 registry
5195 }) => {
5196 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
5197 if (mode !== 'visual') {
5198 // Unselect blocks when we switch to a non visual mode.
5199 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
5200 // Exit zoom out state when switching to a non visual mode.
5201 unlock(registry.dispatch(external_wp_blockEditor_namespaceObject.store)).resetZoomLevel();
5202 }
5203 if (mode === 'visual') {
5204 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
5205 } else if (mode === 'text') {
5206 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5207 if (isDistractionFree) {
5208 dispatch.toggleDistractionFree();
5209 }
5210 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
5211 }
5212 };
5213
5214 /**
5215 * Returns an action object used in signalling that the user opened the publish
5216 * sidebar.
5217 *
5218 * @return {Object} Action object
5219 */
5220 function openPublishSidebar() {
5221 return {
5222 type: 'OPEN_PUBLISH_SIDEBAR'
5223 };
5224 }
5225
5226 /**
5227 * Returns an action object used in signalling that the user closed the
5228 * publish sidebar.
5229 *
5230 * @return {Object} Action object.
5231 */
5232 function closePublishSidebar() {
5233 return {
5234 type: 'CLOSE_PUBLISH_SIDEBAR'
5235 };
5236 }
5237
5238 /**
5239 * Returns an action object used in signalling that the user toggles the publish sidebar.
5240 *
5241 * @return {Object} Action object
5242 */
5243 function togglePublishSidebar() {
5244 return {
5245 type: 'TOGGLE_PUBLISH_SIDEBAR'
5246 };
5247 }
5248
5249 /**
5250 * Backward compatibility
5251 */
5252
5253 const getBlockEditorAction = name => (...args) => ({
5254 registry
5255 }) => {
5256 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
5257 since: '5.3',
5258 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
5259 version: '6.2'
5260 });
5261 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
5262 };
5263
5264 /**
5265 * @see resetBlocks in core/block-editor store.
5266 */
5267 const resetBlocks = getBlockEditorAction('resetBlocks');
5268
5269 /**
5270 * @see receiveBlocks in core/block-editor store.
5271 */
5272 const receiveBlocks = getBlockEditorAction('receiveBlocks');
5273
5274 /**
5275 * @see updateBlock in core/block-editor store.
5276 */
5277 const updateBlock = getBlockEditorAction('updateBlock');
5278
5279 /**
5280 * @see updateBlockAttributes in core/block-editor store.
5281 */
5282 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
5283
5284 /**
5285 * @see selectBlock in core/block-editor store.
5286 */
5287 const selectBlock = getBlockEditorAction('selectBlock');
5288
5289 /**
5290 * @see startMultiSelect in core/block-editor store.
5291 */
5292 const startMultiSelect = getBlockEditorAction('startMultiSelect');
5293
5294 /**
5295 * @see stopMultiSelect in core/block-editor store.
5296 */
5297 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
5298
5299 /**
5300 * @see multiSelect in core/block-editor store.
5301 */
5302 const multiSelect = getBlockEditorAction('multiSelect');
5303
5304 /**
5305 * @see clearSelectedBlock in core/block-editor store.
5306 */
5307 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
5308
5309 /**
5310 * @see toggleSelection in core/block-editor store.
5311 */
5312 const toggleSelection = getBlockEditorAction('toggleSelection');
5313
5314 /**
5315 * @see replaceBlocks in core/block-editor store.
5316 */
5317 const replaceBlocks = getBlockEditorAction('replaceBlocks');
5318
5319 /**
5320 * @see replaceBlock in core/block-editor store.
5321 */
5322 const replaceBlock = getBlockEditorAction('replaceBlock');
5323
5324 /**
5325 * @see moveBlocksDown in core/block-editor store.
5326 */
5327 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
5328
5329 /**
5330 * @see moveBlocksUp in core/block-editor store.
5331 */
5332 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
5333
5334 /**
5335 * @see moveBlockToPosition in core/block-editor store.
5336 */
5337 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
5338
5339 /**
5340 * @see insertBlock in core/block-editor store.
5341 */
5342 const insertBlock = getBlockEditorAction('insertBlock');
5343
5344 /**
5345 * @see insertBlocks in core/block-editor store.
5346 */
5347 const insertBlocks = getBlockEditorAction('insertBlocks');
5348
5349 /**
5350 * @see showInsertionPoint in core/block-editor store.
5351 */
5352 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
5353
5354 /**
5355 * @see hideInsertionPoint in core/block-editor store.
5356 */
5357 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
5358
5359 /**
5360 * @see setTemplateValidity in core/block-editor store.
5361 */
5362 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
5363
5364 /**
5365 * @see synchronizeTemplate in core/block-editor store.
5366 */
5367 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
5368
5369 /**
5370 * @see mergeBlocks in core/block-editor store.
5371 */
5372 const mergeBlocks = getBlockEditorAction('mergeBlocks');
5373
5374 /**
5375 * @see removeBlocks in core/block-editor store.
5376 */
5377 const removeBlocks = getBlockEditorAction('removeBlocks');
5378
5379 /**
5380 * @see removeBlock in core/block-editor store.
5381 */
5382 const removeBlock = getBlockEditorAction('removeBlock');
5383
5384 /**
5385 * @see toggleBlockMode in core/block-editor store.
5386 */
5387 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
5388
5389 /**
5390 * @see startTyping in core/block-editor store.
5391 */
5392 const startTyping = getBlockEditorAction('startTyping');
5393
5394 /**
5395 * @see stopTyping in core/block-editor store.
5396 */
5397 const stopTyping = getBlockEditorAction('stopTyping');
5398
5399 /**
5400 * @see enterFormattedText in core/block-editor store.
5401 */
5402 const enterFormattedText = getBlockEditorAction('enterFormattedText');
5403
5404 /**
5405 * @see exitFormattedText in core/block-editor store.
5406 */
5407 const exitFormattedText = getBlockEditorAction('exitFormattedText');
5408
5409 /**
5410 * @see insertDefaultBlock in core/block-editor store.
5411 */
5412 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
5413
5414 /**
5415 * @see updateBlockListSettings in core/block-editor store.
5416 */
5417 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
5418
5419 ;// external ["wp","htmlEntities"]
5420 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5421 ;// ./packages/editor/build-module/store/utils/is-template-revertable.js
5422 /**
5423 * Internal dependencies
5424 */
5425
5426
5427 // Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
5428
5429 /**
5430 * Check if a template or template part is revertable to its original theme-provided file.
5431 *
5432 * @param {Object} templateOrTemplatePart The entity to check.
5433 * @return {boolean} Whether the entity is revertable.
5434 */
5435 function isTemplateRevertable(templateOrTemplatePart) {
5436 if (!templateOrTemplatePart) {
5437 return false;
5438 }
5439 return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
5440 }
5441
5442 ;// ./packages/icons/build-module/library/external.js
5443 /**
5444 * WordPress dependencies
5445 */
5446
5447
5448 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5449 xmlns: "http://www.w3.org/2000/svg",
5450 viewBox: "0 0 24 24",
5451 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5452 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"
5453 })
5454 });
5455 /* harmony default export */ const library_external = (external);
5456
5457 ;// ./packages/fields/build-module/actions/view-post.js
5458 /**
5459 * WordPress dependencies
5460 */
5461
5462
5463
5464 /**
5465 * Internal dependencies
5466 */
5467
5468 const viewPost = {
5469 id: 'view-post',
5470 label: (0,external_wp_i18n_namespaceObject._x)('View', 'verb'),
5471 isPrimary: true,
5472 icon: library_external,
5473 isEligible(post) {
5474 return post.status !== 'trash';
5475 },
5476 callback(posts, {
5477 onActionPerformed
5478 }) {
5479 const post = posts[0];
5480 window.open(post?.link, '_blank');
5481 if (onActionPerformed) {
5482 onActionPerformed(posts);
5483 }
5484 }
5485 };
5486
5487 /**
5488 * View post action for BasePost.
5489 */
5490 /* harmony default export */ const view_post = (viewPost);
5491
5492 ;// ./packages/fields/build-module/actions/view-post-revisions.js
5493 /**
5494 * WordPress dependencies
5495 */
5496
5497
5498
5499 /**
5500 * Internal dependencies
5501 */
5502
5503 const viewPostRevisions = {
5504 id: 'view-post-revisions',
5505 context: 'list',
5506 label(items) {
5507 var _items$0$_links$versi;
5508 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;
5509 return (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: number of revisions. */
5510 (0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
5511 },
5512 isEligible(post) {
5513 var _post$_links$predeces, _post$_links$version;
5514 if (post.status === 'trash') {
5515 return false;
5516 }
5517 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
5518 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
5519 return !!lastRevisionId && revisionsCount > 1;
5520 },
5521 callback(posts, {
5522 onActionPerformed
5523 }) {
5524 const post = posts[0];
5525 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
5526 revision: post?._links?.['predecessor-version']?.[0]?.id
5527 });
5528 document.location.href = href;
5529 if (onActionPerformed) {
5530 onActionPerformed(posts);
5531 }
5532 }
5533 };
5534
5535 /**
5536 * View post revisions action for Post.
5537 */
5538 /* harmony default export */ const view_post_revisions = (viewPostRevisions);
5539
5540 ;// ./packages/dataviews/build-module/components/dataform-context/index.js
5541 /**
5542 * WordPress dependencies
5543 */
5544
5545
5546 /**
5547 * Internal dependencies
5548 */
5549
5550 const DataFormContext = (0,external_wp_element_namespaceObject.createContext)({
5551 fields: []
5552 });
5553 function DataFormProvider({
5554 fields,
5555 children
5556 }) {
5557 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormContext.Provider, {
5558 value: {
5559 fields
5560 },
5561 children: children
5562 });
5563 }
5564 /* harmony default export */ const dataform_context = (DataFormContext);
5565
5566 ;// ./packages/dataviews/build-module/field-types/integer.js
5567 /**
5568 * Internal dependencies
5569 */
5570
5571 function sort(a, b, direction) {
5572 return direction === 'asc' ? a - b : b - a;
5573 }
5574 function isValid(value, context) {
5575 // TODO: this implicitely means the value is required.
5576 if (value === '') {
5577 return false;
5578 }
5579 if (!Number.isInteger(Number(value))) {
5580 return false;
5581 }
5582 if (context?.elements) {
5583 const validValues = context?.elements.map(f => f.value);
5584 if (!validValues.includes(Number(value))) {
5585 return false;
5586 }
5587 }
5588 return true;
5589 }
5590 /* harmony default export */ const integer = ({
5591 sort,
5592 isValid,
5593 Edit: 'integer'
5594 });
5595
5596 ;// ./packages/dataviews/build-module/field-types/text.js
5597 /**
5598 * Internal dependencies
5599 */
5600
5601 function text_sort(valueA, valueB, direction) {
5602 return direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
5603 }
5604 function text_isValid(value, context) {
5605 if (context?.elements) {
5606 const validValues = context?.elements?.map(f => f.value);
5607 if (!validValues.includes(value)) {
5608 return false;
5609 }
5610 }
5611 return true;
5612 }
5613 /* harmony default export */ const field_types_text = ({
5614 sort: text_sort,
5615 isValid: text_isValid,
5616 Edit: 'text'
5617 });
5618
5619 ;// ./packages/dataviews/build-module/field-types/datetime.js
5620 /**
5621 * Internal dependencies
5622 */
5623
5624 function datetime_sort(a, b, direction) {
5625 const timeA = new Date(a).getTime();
5626 const timeB = new Date(b).getTime();
5627 return direction === 'asc' ? timeA - timeB : timeB - timeA;
5628 }
5629 function datetime_isValid(value, context) {
5630 if (context?.elements) {
5631 const validValues = context?.elements.map(f => f.value);
5632 if (!validValues.includes(value)) {
5633 return false;
5634 }
5635 }
5636 return true;
5637 }
5638 /* harmony default export */ const datetime = ({
5639 sort: datetime_sort,
5640 isValid: datetime_isValid,
5641 Edit: 'datetime'
5642 });
5643
5644 ;// ./packages/dataviews/build-module/field-types/index.js
5645 /**
5646 * Internal dependencies
5647 */
5648
5649
5650
5651
5652
5653 /**
5654 *
5655 * @param {FieldType} type The field type definition to get.
5656 *
5657 * @return A field type definition.
5658 */
5659 function getFieldTypeDefinition(type) {
5660 if ('integer' === type) {
5661 return integer;
5662 }
5663 if ('text' === type) {
5664 return field_types_text;
5665 }
5666 if ('datetime' === type) {
5667 return datetime;
5668 }
5669 return {
5670 sort: (a, b, direction) => {
5671 if (typeof a === 'number' && typeof b === 'number') {
5672 return direction === 'asc' ? a - b : b - a;
5673 }
5674 return direction === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
5675 },
5676 isValid: (value, context) => {
5677 if (context?.elements) {
5678 const validValues = context?.elements?.map(f => f.value);
5679 if (!validValues.includes(value)) {
5680 return false;
5681 }
5682 }
5683 return true;
5684 },
5685 Edit: () => null
5686 };
5687 }
5688
5689 ;// external ["wp","components"]
5690 const external_wp_components_namespaceObject = window["wp"]["components"];
5691 ;// ./packages/dataviews/build-module/dataform-controls/datetime.js
5692 /**
5693 * WordPress dependencies
5694 */
5695
5696
5697
5698 /**
5699 * Internal dependencies
5700 */
5701
5702 function DateTime({
5703 data,
5704 field,
5705 onChange,
5706 hideLabelFromVision
5707 }) {
5708 const {
5709 id,
5710 label
5711 } = field;
5712 const value = field.getValue({
5713 item: data
5714 });
5715 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5716 [id]: newValue
5717 }), [id, onChange]);
5718 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
5719 className: "dataviews-controls__datetime",
5720 children: [!hideLabelFromVision && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
5721 as: "legend",
5722 children: label
5723 }), hideLabelFromVision && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
5724 as: "legend",
5725 children: label
5726 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TimePicker, {
5727 currentTime: value,
5728 onChange: onChangeControl,
5729 hideLabelFromVision: true
5730 })]
5731 });
5732 }
5733
5734 ;// ./packages/dataviews/build-module/dataform-controls/integer.js
5735 /**
5736 * WordPress dependencies
5737 */
5738
5739
5740
5741 /**
5742 * Internal dependencies
5743 */
5744
5745 function Integer({
5746 data,
5747 field,
5748 onChange,
5749 hideLabelFromVision
5750 }) {
5751 var _field$getValue;
5752 const {
5753 id,
5754 label,
5755 description
5756 } = field;
5757 const value = (_field$getValue = field.getValue({
5758 item: data
5759 })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
5760 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5761 [id]: Number(newValue)
5762 }), [id, onChange]);
5763 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
5764 label: label,
5765 help: description,
5766 value: value,
5767 onChange: onChangeControl,
5768 __next40pxDefaultSize: true,
5769 hideLabelFromVision: hideLabelFromVision
5770 });
5771 }
5772
5773 ;// ./packages/dataviews/build-module/dataform-controls/radio.js
5774 /**
5775 * WordPress dependencies
5776 */
5777
5778
5779
5780 /**
5781 * Internal dependencies
5782 */
5783
5784 function Radio({
5785 data,
5786 field,
5787 onChange,
5788 hideLabelFromVision
5789 }) {
5790 const {
5791 id,
5792 label
5793 } = field;
5794 const value = field.getValue({
5795 item: data
5796 });
5797 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5798 [id]: newValue
5799 }), [id, onChange]);
5800 if (field.elements) {
5801 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
5802 label: label,
5803 onChange: onChangeControl,
5804 options: field.elements,
5805 selected: value,
5806 hideLabelFromVision: hideLabelFromVision
5807 });
5808 }
5809 return null;
5810 }
5811
5812 ;// ./packages/dataviews/build-module/dataform-controls/select.js
5813 /**
5814 * WordPress dependencies
5815 */
5816
5817
5818
5819
5820 /**
5821 * Internal dependencies
5822 */
5823
5824 function Select({
5825 data,
5826 field,
5827 onChange,
5828 hideLabelFromVision
5829 }) {
5830 var _field$getValue, _field$elements;
5831 const {
5832 id,
5833 label
5834 } = field;
5835 const value = (_field$getValue = field.getValue({
5836 item: data
5837 })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
5838 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5839 [id]: newValue
5840 }), [id, onChange]);
5841 const elements = [
5842 /*
5843 * Value can be undefined when:
5844 *
5845 * - the field is not required
5846 * - in bulk editing
5847 *
5848 */
5849 {
5850 label: (0,external_wp_i18n_namespaceObject.__)('Select item'),
5851 value: ''
5852 }, ...((_field$elements = field?.elements) !== null && _field$elements !== void 0 ? _field$elements : [])];
5853 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
5854 label: label,
5855 value: value,
5856 options: elements,
5857 onChange: onChangeControl,
5858 __next40pxDefaultSize: true,
5859 __nextHasNoMarginBottom: true,
5860 hideLabelFromVision: hideLabelFromVision
5861 });
5862 }
5863
5864 ;// ./packages/dataviews/build-module/dataform-controls/text.js
5865 /**
5866 * WordPress dependencies
5867 */
5868
5869
5870
5871 /**
5872 * Internal dependencies
5873 */
5874
5875 function Text({
5876 data,
5877 field,
5878 onChange,
5879 hideLabelFromVision
5880 }) {
5881 const {
5882 id,
5883 label,
5884 placeholder
5885 } = field;
5886 const value = field.getValue({
5887 item: data
5888 });
5889 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
5890 [id]: newValue
5891 }), [id, onChange]);
5892 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
5893 label: label,
5894 placeholder: placeholder,
5895 value: value !== null && value !== void 0 ? value : '',
5896 onChange: onChangeControl,
5897 __next40pxDefaultSize: true,
5898 __nextHasNoMarginBottom: true,
5899 hideLabelFromVision: hideLabelFromVision
5900 });
5901 }
5902
5903 ;// ./packages/dataviews/build-module/dataform-controls/index.js
5904 /**
5905 * External dependencies
5906 */
5907
5908 /**
5909 * Internal dependencies
5910 */
5911
5912
5913
5914
5915
5916
5917 const FORM_CONTROLS = {
5918 datetime: DateTime,
5919 integer: Integer,
5920 radio: Radio,
5921 select: Select,
5922 text: Text
5923 };
5924 function getControl(field, fieldTypeDefinition) {
5925 if (typeof field.Edit === 'function') {
5926 return field.Edit;
5927 }
5928 if (typeof field.Edit === 'string') {
5929 return getControlByType(field.Edit);
5930 }
5931 if (field.elements) {
5932 return getControlByType('select');
5933 }
5934 if (typeof fieldTypeDefinition.Edit === 'string') {
5935 return getControlByType(fieldTypeDefinition.Edit);
5936 }
5937 return fieldTypeDefinition.Edit;
5938 }
5939 function getControlByType(type) {
5940 if (Object.keys(FORM_CONTROLS).includes(type)) {
5941 return FORM_CONTROLS[type];
5942 }
5943 throw 'Control ' + type + ' not found';
5944 }
5945
5946 ;// ./packages/dataviews/build-module/normalize-fields.js
5947 /* wp:polyfill */
5948 /**
5949 * Internal dependencies
5950 */
5951
5952
5953 const getValueFromId = id => ({
5954 item
5955 }) => {
5956 const path = id.split('.');
5957 let value = item;
5958 for (const segment of path) {
5959 if (value.hasOwnProperty(segment)) {
5960 value = value[segment];
5961 } else {
5962 value = undefined;
5963 }
5964 }
5965 return value;
5966 };
5967
5968 /**
5969 * Apply default values and normalize the fields config.
5970 *
5971 * @param fields Fields config.
5972 * @return Normalized fields config.
5973 */
5974 function normalizeFields(fields) {
5975 return fields.map(field => {
5976 var _field$sort, _field$isValid, _field$enableHiding, _field$enableSorting;
5977 const fieldTypeDefinition = getFieldTypeDefinition(field.type);
5978 const getValue = field.getValue || getValueFromId(field.id);
5979 const sort = (_field$sort = field.sort) !== null && _field$sort !== void 0 ? _field$sort : function sort(a, b, direction) {
5980 return fieldTypeDefinition.sort(getValue({
5981 item: a
5982 }), getValue({
5983 item: b
5984 }), direction);
5985 };
5986 const isValid = (_field$isValid = field.isValid) !== null && _field$isValid !== void 0 ? _field$isValid : function isValid(item, context) {
5987 return fieldTypeDefinition.isValid(getValue({
5988 item
5989 }), context);
5990 };
5991 const Edit = getControl(field, fieldTypeDefinition);
5992 const renderFromElements = ({
5993 item
5994 }) => {
5995 const value = getValue({
5996 item
5997 });
5998 return field?.elements?.find(element => element.value === value)?.label || getValue({
5999 item
6000 });
6001 };
6002 const render = field.render || (field.elements ? renderFromElements : getValue);
6003 return {
6004 ...field,
6005 label: field.label || field.id,
6006 header: field.header || field.label || field.id,
6007 getValue,
6008 render,
6009 sort,
6010 isValid,
6011 Edit,
6012 enableHiding: (_field$enableHiding = field.enableHiding) !== null && _field$enableHiding !== void 0 ? _field$enableHiding : true,
6013 enableSorting: (_field$enableSorting = field.enableSorting) !== null && _field$enableSorting !== void 0 ? _field$enableSorting : true
6014 };
6015 });
6016 }
6017
6018 ;// ./packages/dataviews/build-module/dataforms-layouts/is-combined-field.js
6019 /**
6020 * Internal dependencies
6021 */
6022
6023 function isCombinedField(field) {
6024 return field.children !== undefined;
6025 }
6026
6027 ;// ./packages/dataviews/build-module/dataforms-layouts/regular/index.js
6028 /* wp:polyfill */
6029 /**
6030 * WordPress dependencies
6031 */
6032
6033
6034
6035 /**
6036 * Internal dependencies
6037 */
6038
6039
6040
6041
6042
6043 function Header({
6044 title
6045 }) {
6046 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
6047 className: "dataforms-layouts-regular__header",
6048 spacing: 4,
6049 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6050 alignment: "center",
6051 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
6052 level: 2,
6053 size: 13,
6054 children: title
6055 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalSpacer, {})]
6056 })
6057 });
6058 }
6059 function FormRegularField({
6060 data,
6061 field,
6062 onChange,
6063 hideLabelFromVision
6064 }) {
6065 var _field$labelPosition;
6066 const {
6067 fields
6068 } = (0,external_wp_element_namespaceObject.useContext)(dataform_context);
6069 const form = (0,external_wp_element_namespaceObject.useMemo)(() => {
6070 if (isCombinedField(field)) {
6071 return {
6072 fields: field.children.map(child => {
6073 if (typeof child === 'string') {
6074 return {
6075 id: child
6076 };
6077 }
6078 return child;
6079 }),
6080 type: 'regular'
6081 };
6082 }
6083 return {
6084 type: 'regular',
6085 fields: []
6086 };
6087 }, [field]);
6088 if (isCombinedField(field)) {
6089 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6090 children: [!hideLabelFromVision && field.label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Header, {
6091 title: field.label
6092 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormLayout, {
6093 data: data,
6094 form: form,
6095 onChange: onChange
6096 })]
6097 });
6098 }
6099 const labelPosition = (_field$labelPosition = field.labelPosition) !== null && _field$labelPosition !== void 0 ? _field$labelPosition : 'top';
6100 const fieldDefinition = fields.find(fieldDef => fieldDef.id === field.id);
6101 if (!fieldDefinition) {
6102 return null;
6103 }
6104 if (labelPosition === 'side') {
6105 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6106 className: "dataforms-layouts-regular__field",
6107 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6108 className: "dataforms-layouts-regular__field-label",
6109 children: fieldDefinition.label
6110 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6111 className: "dataforms-layouts-regular__field-control",
6112 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(fieldDefinition.Edit, {
6113 data: data,
6114 field: fieldDefinition,
6115 onChange: onChange,
6116 hideLabelFromVision: true
6117 }, fieldDefinition.id)
6118 })]
6119 });
6120 }
6121 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6122 className: "dataforms-layouts-regular__field",
6123 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(fieldDefinition.Edit, {
6124 data: data,
6125 field: fieldDefinition,
6126 onChange: onChange,
6127 hideLabelFromVision: labelPosition === 'none' ? true : hideLabelFromVision
6128 })
6129 });
6130 }
6131
6132 ;// ./packages/icons/build-module/library/close-small.js
6133 /**
6134 * WordPress dependencies
6135 */
6136
6137
6138 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6139 xmlns: "http://www.w3.org/2000/svg",
6140 viewBox: "0 0 24 24",
6141 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6142 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"
6143 })
6144 });
6145 /* harmony default export */ const close_small = (closeSmall);
6146
6147 ;// ./packages/dataviews/build-module/dataforms-layouts/panel/index.js
6148 /* wp:polyfill */
6149 /**
6150 * WordPress dependencies
6151 */
6152
6153
6154
6155
6156
6157 /**
6158 * Internal dependencies
6159 */
6160
6161
6162
6163
6164
6165 function DropdownHeader({
6166 title,
6167 onClose
6168 }) {
6169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
6170 className: "dataforms-layouts-panel__dropdown-header",
6171 spacing: 4,
6172 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6173 alignment: "center",
6174 children: [title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
6175 level: 2,
6176 size: 13,
6177 children: title
6178 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalSpacer, {}), onClose && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6179 label: (0,external_wp_i18n_namespaceObject.__)('Close'),
6180 icon: close_small,
6181 onClick: onClose,
6182 size: "small"
6183 })]
6184 })
6185 });
6186 }
6187 function PanelDropdown({
6188 fieldDefinition,
6189 popoverAnchor,
6190 labelPosition = 'side',
6191 data,
6192 onChange,
6193 field
6194 }) {
6195 const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
6196 const form = (0,external_wp_element_namespaceObject.useMemo)(() => {
6197 if (isCombinedField(field)) {
6198 return {
6199 type: 'regular',
6200 fields: field.children.map(child => {
6201 if (typeof child === 'string') {
6202 return {
6203 id: child
6204 };
6205 }
6206 return child;
6207 })
6208 };
6209 }
6210 // If not explicit children return the field id itself.
6211 return {
6212 type: 'regular',
6213 fields: [{
6214 id: field.id
6215 }]
6216 };
6217 }, [field]);
6218
6219 // Memoize popoverProps to avoid returning a new object every time.
6220 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
6221 // Anchor the popover to the middle of the entire row so that it doesn't
6222 // move around when the label changes.
6223 anchor: popoverAnchor,
6224 placement: 'left-start',
6225 offset: 36,
6226 shift: true
6227 }), [popoverAnchor]);
6228 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
6229 contentClassName: "dataforms-layouts-panel__field-dropdown",
6230 popoverProps: popoverProps,
6231 focusOnMount: true,
6232 toggleProps: {
6233 size: 'compact',
6234 variant: 'tertiary',
6235 tooltipPosition: 'middle left'
6236 },
6237 renderToggle: ({
6238 isOpen,
6239 onToggle
6240 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6241 className: "dataforms-layouts-panel__field-control",
6242 size: "compact",
6243 variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
6244 "aria-expanded": isOpen,
6245 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
6246 // translators: %s: Field name.
6247 (0,external_wp_i18n_namespaceObject._x)('Edit %s', 'field'), fieldLabel),
6248 onClick: onToggle,
6249 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(fieldDefinition.render, {
6250 item: data
6251 })
6252 }),
6253 renderContent: ({
6254 onClose
6255 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6256 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownHeader, {
6257 title: fieldLabel,
6258 onClose: onClose
6259 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormLayout, {
6260 data: data,
6261 form: form,
6262 onChange: onChange,
6263 children: (FieldLayout, nestedField) => {
6264 var _form$fields;
6265 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FieldLayout, {
6266 data: data,
6267 field: nestedField,
6268 onChange: onChange,
6269 hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
6270 }, nestedField.id);
6271 }
6272 })]
6273 })
6274 });
6275 }
6276 function FormPanelField({
6277 data,
6278 field,
6279 onChange
6280 }) {
6281 var _field$labelPosition;
6282 const {
6283 fields
6284 } = (0,external_wp_element_namespaceObject.useContext)(dataform_context);
6285 const fieldDefinition = fields.find(fieldDef => {
6286 // Default to the first child if it is a combined field.
6287 if (isCombinedField(field)) {
6288 const children = field.children.filter(child => typeof child === 'string' || !isCombinedField(child));
6289 const firstChildFieldId = typeof children[0] === 'string' ? children[0] : children[0].id;
6290 return fieldDef.id === firstChildFieldId;
6291 }
6292 return fieldDef.id === field.id;
6293 });
6294 const labelPosition = (_field$labelPosition = field.labelPosition) !== null && _field$labelPosition !== void 0 ? _field$labelPosition : 'side';
6295
6296 // Use internal state instead of a ref to make sure that the component
6297 // re-renders when the popover's anchor updates.
6298 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
6299 if (!fieldDefinition) {
6300 return null;
6301 }
6302 const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
6303 if (labelPosition === 'top') {
6304 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
6305 className: "dataforms-layouts-panel__field",
6306 spacing: 0,
6307 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6308 className: "dataforms-layouts-panel__field-label",
6309 style: {
6310 paddingBottom: 0
6311 },
6312 children: fieldLabel
6313 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6314 className: "dataforms-layouts-panel__field-control",
6315 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PanelDropdown, {
6316 field: field,
6317 popoverAnchor: popoverAnchor,
6318 fieldDefinition: fieldDefinition,
6319 data: data,
6320 onChange: onChange,
6321 labelPosition: labelPosition
6322 })
6323 })]
6324 });
6325 }
6326 if (labelPosition === 'none') {
6327 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6328 className: "dataforms-layouts-panel__field",
6329 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PanelDropdown, {
6330 field: field,
6331 popoverAnchor: popoverAnchor,
6332 fieldDefinition: fieldDefinition,
6333 data: data,
6334 onChange: onChange,
6335 labelPosition: labelPosition
6336 })
6337 });
6338 }
6339
6340 // Defaults to label position side.
6341 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6342 ref: setPopoverAnchor,
6343 className: "dataforms-layouts-panel__field",
6344 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6345 className: "dataforms-layouts-panel__field-label",
6346 children: fieldLabel
6347 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6348 className: "dataforms-layouts-panel__field-control",
6349 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PanelDropdown, {
6350 field: field,
6351 popoverAnchor: popoverAnchor,
6352 fieldDefinition: fieldDefinition,
6353 data: data,
6354 onChange: onChange,
6355 labelPosition: labelPosition
6356 })
6357 })]
6358 });
6359 }
6360
6361 ;// ./packages/dataviews/build-module/dataforms-layouts/index.js
6362 /* wp:polyfill */
6363 /**
6364 * Internal dependencies
6365 */
6366
6367
6368 const FORM_FIELD_LAYOUTS = [{
6369 type: 'regular',
6370 component: FormRegularField
6371 }, {
6372 type: 'panel',
6373 component: FormPanelField
6374 }];
6375 function getFormFieldLayout(type) {
6376 return FORM_FIELD_LAYOUTS.find(layout => layout.type === type);
6377 }
6378
6379 ;// ./packages/dataviews/build-module/normalize-form-fields.js
6380 /* wp:polyfill */
6381 /**
6382 * Internal dependencies
6383 */
6384
6385 function normalizeFormFields(form) {
6386 var _form$type, _form$labelPosition, _form$fields;
6387 let layout = 'regular';
6388 if (['regular', 'panel'].includes((_form$type = form.type) !== null && _form$type !== void 0 ? _form$type : '')) {
6389 layout = form.type;
6390 }
6391 const labelPosition = (_form$labelPosition = form.labelPosition) !== null && _form$labelPosition !== void 0 ? _form$labelPosition : layout === 'regular' ? 'top' : 'side';
6392 return ((_form$fields = form.fields) !== null && _form$fields !== void 0 ? _form$fields : []).map(field => {
6393 var _field$layout, _field$labelPosition;
6394 if (typeof field === 'string') {
6395 return {
6396 id: field,
6397 layout,
6398 labelPosition
6399 };
6400 }
6401 const fieldLayout = (_field$layout = field.layout) !== null && _field$layout !== void 0 ? _field$layout : layout;
6402 const fieldLabelPosition = (_field$labelPosition = field.labelPosition) !== null && _field$labelPosition !== void 0 ? _field$labelPosition : fieldLayout === 'regular' ? 'top' : 'side';
6403 return {
6404 ...field,
6405 layout: fieldLayout,
6406 labelPosition: fieldLabelPosition
6407 };
6408 });
6409 }
6410
6411 ;// ./packages/dataviews/build-module/dataforms-layouts/data-form-layout.js
6412 /* wp:polyfill */
6413 /**
6414 * WordPress dependencies
6415 */
6416
6417
6418
6419 /**
6420 * Internal dependencies
6421 */
6422
6423
6424
6425
6426
6427
6428 function DataFormLayout({
6429 data,
6430 form,
6431 onChange,
6432 children
6433 }) {
6434 const {
6435 fields: fieldDefinitions
6436 } = (0,external_wp_element_namespaceObject.useContext)(dataform_context);
6437 function getFieldDefinition(field) {
6438 const fieldId = typeof field === 'string' ? field : field.id;
6439 return fieldDefinitions.find(fieldDefinition => fieldDefinition.id === fieldId);
6440 }
6441 const normalizedFormFields = (0,external_wp_element_namespaceObject.useMemo)(() => normalizeFormFields(form), [form]);
6442 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
6443 spacing: 2,
6444 children: normalizedFormFields.map(formField => {
6445 const FieldLayout = getFormFieldLayout(formField.layout)?.component;
6446 if (!FieldLayout) {
6447 return null;
6448 }
6449 const fieldDefinition = !isCombinedField(formField) ? getFieldDefinition(formField) : undefined;
6450 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
6451 return null;
6452 }
6453 if (children) {
6454 return children(FieldLayout, formField);
6455 }
6456 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FieldLayout, {
6457 data: data,
6458 field: formField,
6459 onChange: onChange
6460 }, formField.id);
6461 })
6462 });
6463 }
6464
6465 ;// ./packages/dataviews/build-module/components/dataform/index.js
6466 /**
6467 * WordPress dependencies
6468 */
6469
6470
6471 /**
6472 * Internal dependencies
6473 */
6474
6475
6476
6477
6478
6479 function DataForm({
6480 data,
6481 form,
6482 fields,
6483 onChange
6484 }) {
6485 const normalizedFields = (0,external_wp_element_namespaceObject.useMemo)(() => normalizeFields(fields), [fields]);
6486 if (!form.fields) {
6487 return null;
6488 }
6489 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormProvider, {
6490 fields: normalizedFields,
6491 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormLayout, {
6492 data: data,
6493 form: form,
6494 onChange: onChange
6495 })
6496 });
6497 }
6498
6499 ;// ./packages/fields/build-module/actions/utils.js
6500 /**
6501 * WordPress dependencies
6502 */
6503
6504
6505 /**
6506 * Internal dependencies
6507 */
6508
6509 function isTemplate(post) {
6510 return post.type === 'wp_template';
6511 }
6512 function isTemplatePart(post) {
6513 return post.type === 'wp_template_part';
6514 }
6515 function isTemplateOrTemplatePart(p) {
6516 return p.type === 'wp_template' || p.type === 'wp_template_part';
6517 }
6518 function getItemTitle(item) {
6519 if (typeof item.title === 'string') {
6520 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
6521 }
6522 if (item.title && 'rendered' in item.title) {
6523 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.rendered);
6524 }
6525 if (item.title && 'raw' in item.title) {
6526 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.raw);
6527 }
6528 return '';
6529 }
6530
6531 /**
6532 * Check if a template is removable.
6533 *
6534 * @param template The template entity to check.
6535 * @return Whether the template is removable.
6536 */
6537 function isTemplateRemovable(template) {
6538 if (!template) {
6539 return false;
6540 }
6541 // In patterns list page we map the templates parts to a different object
6542 // than the one returned from the endpoint. This is why we need to check for
6543 // two props whether is custom or has a theme file.
6544 return [template.source, template.source].includes('custom') && !Boolean(template.type === 'wp_template' && template?.plugin) && !template.has_theme_file;
6545 }
6546
6547 ;// ./node_modules/clsx/dist/clsx.mjs
6548 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);
6549 ;// ./packages/fields/build-module/fields/title/view.js
6550 /**
6551 * External dependencies
6552 */
6553
6554 /**
6555 * WordPress dependencies
6556 */
6557
6558
6559
6560 /**
6561 * Internal dependencies
6562 */
6563
6564
6565
6566 function BaseTitleView({
6567 item,
6568 className,
6569 children
6570 }) {
6571 const renderedTitle = getItemTitle(item);
6572 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6573 className: dist_clsx('fields-field__title', className),
6574 alignment: "center",
6575 justify: "flex-start",
6576 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6577 children: renderedTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)')
6578 }), children]
6579 });
6580 }
6581 function TitleView({
6582 item
6583 }) {
6584 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BaseTitleView, {
6585 item: item
6586 });
6587 }
6588
6589 ;// ./packages/fields/build-module/fields/title/index.js
6590 /**
6591 * WordPress dependencies
6592 */
6593
6594
6595
6596 /**
6597 * Internal dependencies
6598 */
6599
6600
6601
6602 const titleField = {
6603 type: 'text',
6604 id: 'title',
6605 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
6606 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
6607 getValue: ({
6608 item
6609 }) => getItemTitle(item),
6610 render: TitleView,
6611 enableHiding: false,
6612 enableGlobalSearch: true
6613 };
6614
6615 /**
6616 * Title for the any entity with a `title` property.
6617 * For patterns, pages or templates you should use the respective field
6618 * because there are some differences in the rendering, labels, etc.
6619 */
6620 /* harmony default export */ const title = (titleField);
6621
6622 ;// ./packages/fields/build-module/actions/duplicate-post.js
6623 /* wp:polyfill */
6624 /**
6625 * WordPress dependencies
6626 */
6627
6628
6629
6630
6631
6632
6633
6634
6635 /**
6636 * Internal dependencies
6637 */
6638
6639
6640
6641 const duplicate_post_fields = [title];
6642 const formDuplicateAction = {
6643 fields: ['title']
6644 };
6645 const duplicatePost = {
6646 id: 'duplicate-post',
6647 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
6648 isEligible({
6649 status
6650 }) {
6651 return status !== 'trash';
6652 },
6653 RenderModal: ({
6654 items,
6655 closeModal,
6656 onActionPerformed
6657 }) => {
6658 const [item, setItem] = (0,external_wp_element_namespaceObject.useState)({
6659 ...items[0],
6660 title: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: Existing post title */
6661 (0,external_wp_i18n_namespaceObject._x)('%s (Copy)', 'post'), getItemTitle(items[0]))
6662 });
6663 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
6664 const {
6665 saveEntityRecord
6666 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
6667 const {
6668 createSuccessNotice,
6669 createErrorNotice
6670 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
6671 async function createPage(event) {
6672 event.preventDefault();
6673 if (isCreatingPage) {
6674 return;
6675 }
6676 const newItemOject = {
6677 status: 'draft',
6678 title: item.title,
6679 slug: item.title || (0,external_wp_i18n_namespaceObject.__)('No title'),
6680 comment_status: item.comment_status,
6681 content: typeof item.content === 'string' ? item.content : item.content.raw,
6682 excerpt: typeof item.excerpt === 'string' ? item.excerpt : item.excerpt?.raw,
6683 meta: item.meta,
6684 parent: item.parent,
6685 password: item.password,
6686 template: item.template,
6687 format: item.format,
6688 featured_media: item.featured_media,
6689 menu_order: item.menu_order,
6690 ping_status: item.ping_status
6691 };
6692 const assignablePropertiesPrefix = 'wp:action-assign-';
6693 // Get all the properties that the current user is able to assign normally author, categories, tags,
6694 // and custom taxonomies.
6695 const assignableProperties = Object.keys(item?._links || {}).filter(property => property.startsWith(assignablePropertiesPrefix)).map(property => property.slice(assignablePropertiesPrefix.length));
6696 assignableProperties.forEach(property => {
6697 if (item.hasOwnProperty(property)) {
6698 // @ts-ignore
6699 newItemOject[property] = item[property];
6700 }
6701 });
6702 setIsCreatingPage(true);
6703 try {
6704 const newItem = await saveEntityRecord('postType', item.type, newItemOject, {
6705 throwOnError: true
6706 });
6707 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
6708 // translators: %s: Title of the created post, e.g: "Hello world".
6709 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newItem.title?.rendered || item.title)), {
6710 id: 'duplicate-post-action',
6711 type: 'snackbar'
6712 });
6713 if (onActionPerformed) {
6714 onActionPerformed([newItem]);
6715 }
6716 } catch (error) {
6717 const typedError = error;
6718 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
6719 createErrorNotice(errorMessage, {
6720 type: 'snackbar'
6721 });
6722 } finally {
6723 setIsCreatingPage(false);
6724 closeModal?.();
6725 }
6726 }
6727 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
6728 onSubmit: createPage,
6729 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
6730 spacing: 3,
6731 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataForm, {
6732 data: item,
6733 fields: duplicate_post_fields,
6734 form: formDuplicateAction,
6735 onChange: changes => setItem(prev => ({
6736 ...prev,
6737 ...changes
6738 }))
6739 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
6740 spacing: 2,
6741 justify: "end",
6742 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6743 variant: "tertiary",
6744 onClick: closeModal,
6745 __next40pxDefaultSize: true,
6746 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
6747 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
6748 variant: "primary",
6749 type: "submit",
6750 isBusy: isCreatingPage,
6751 "aria-disabled": isCreatingPage,
6752 __next40pxDefaultSize: true,
6753 children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
6754 })]
6755 })]
6756 })
6757 });
6758 }
6759 };
6760
6761 /**
6762 * Duplicate action for BasePost.
6763 */
6764 /* harmony default export */ const duplicate_post = (duplicatePost);
6765
6766 ;// ./packages/icons/build-module/library/check.js
6767 /**
6768 * WordPress dependencies
6769 */
6770
6771
6772 const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6773 xmlns: "http://www.w3.org/2000/svg",
6774 viewBox: "0 0 24 24",
6775 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6776 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
6777 })
6778 });
6779 /* harmony default export */ const library_check = (check);
6780
6781 ;// ./node_modules/tslib/tslib.es6.mjs
6782 /******************************************************************************
6783 Copyright (c) Microsoft Corporation.
6784
6785 Permission to use, copy, modify, and/or distribute this software for any
6786 purpose with or without fee is hereby granted.
6787
6788 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6789 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6790 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6791 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6792 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6793 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6794 PERFORMANCE OF THIS SOFTWARE.
6795 ***************************************************************************** */
6796 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
6797
6798 var extendStatics = function(d, b) {
6799 extendStatics = Object.setPrototypeOf ||
6800 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6801 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6802 return extendStatics(d, b);
6803 };
6804
6805 function __extends(d, b) {
6806 if (typeof b !== "function" && b !== null)
6807 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6808 extendStatics(d, b);
6809 function __() { this.constructor = d; }
6810 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6811 }
6812
6813 var __assign = function() {
6814 __assign = Object.assign || function __assign(t) {
6815 for (var s, i = 1, n = arguments.length; i < n; i++) {
6816 s = arguments[i];
6817 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6818 }
6819 return t;
6820 }
6821 return __assign.apply(this, arguments);
6822 }
6823
6824 function __rest(s, e) {
6825 var t = {};
6826 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6827 t[p] = s[p];
6828 if (s != null && typeof Object.getOwnPropertySymbols === "function")
6829 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
6830 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
6831 t[p[i]] = s[p[i]];
6832 }
6833 return t;
6834 }
6835
6836 function __decorate(decorators, target, key, desc) {
6837 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6838 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6839 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;
6840 return c > 3 && r && Object.defineProperty(target, key, r), r;
6841 }
6842
6843 function __param(paramIndex, decorator) {
6844 return function (target, key) { decorator(target, key, paramIndex); }
6845 }
6846
6847 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
6848 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
6849 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
6850 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6851 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6852 var _, done = false;
6853 for (var i = decorators.length - 1; i >= 0; i--) {
6854 var context = {};
6855 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
6856 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
6857 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
6858 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
6859 if (kind === "accessor") {
6860 if (result === void 0) continue;
6861 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
6862 if (_ = accept(result.get)) descriptor.get = _;
6863 if (_ = accept(result.set)) descriptor.set = _;
6864 if (_ = accept(result.init)) initializers.unshift(_);
6865 }
6866 else if (_ = accept(result)) {
6867 if (kind === "field") initializers.unshift(_);
6868 else descriptor[key] = _;
6869 }
6870 }
6871 if (target) Object.defineProperty(target, contextIn.name, descriptor);
6872 done = true;
6873 };
6874
6875 function __runInitializers(thisArg, initializers, value) {
6876 var useValue = arguments.length > 2;
6877 for (var i = 0; i < initializers.length; i++) {
6878 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6879 }
6880 return useValue ? value : void 0;
6881 };
6882
6883 function __propKey(x) {
6884 return typeof x === "symbol" ? x : "".concat(x);
6885 };
6886
6887 function __setFunctionName(f, name, prefix) {
6888 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
6889 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
6890 };
6891
6892 function __metadata(metadataKey, metadataValue) {
6893 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
6894 }
6895
6896 function __awaiter(thisArg, _arguments, P, generator) {
6897 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6898 return new (P || (P = Promise))(function (resolve, reject) {
6899 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6900 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6901 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6902 step((generator = generator.apply(thisArg, _arguments || [])).next());
6903 });
6904 }
6905
6906 function __generator(thisArg, body) {
6907 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
6908 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6909 function verb(n) { return function (v) { return step([n, v]); }; }
6910 function step(op) {
6911 if (f) throw new TypeError("Generator is already executing.");
6912 while (g && (g = 0, op[0] && (_ = 0)), _) try {
6913 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;
6914 if (y = 0, t) op = [op[0] & 2, t.value];
6915 switch (op[0]) {
6916 case 0: case 1: t = op; break;
6917 case 4: _.label++; return { value: op[1], done: false };
6918 case 5: _.label++; y = op[1]; op = [0]; continue;
6919 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6920 default:
6921 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6922 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6923 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6924 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6925 if (t[2]) _.ops.pop();
6926 _.trys.pop(); continue;
6927 }
6928 op = body.call(thisArg, _);
6929 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6930 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6931 }
6932 }
6933
6934 var __createBinding = Object.create ? (function(o, m, k, k2) {
6935 if (k2 === undefined) k2 = k;
6936 var desc = Object.getOwnPropertyDescriptor(m, k);
6937 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6938 desc = { enumerable: true, get: function() { return m[k]; } };
6939 }
6940 Object.defineProperty(o, k2, desc);
6941 }) : (function(o, m, k, k2) {
6942 if (k2 === undefined) k2 = k;
6943 o[k2] = m[k];
6944 });
6945
6946 function __exportStar(m, o) {
6947 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
6948 }
6949
6950 function __values(o) {
6951 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
6952 if (m) return m.call(o);
6953 if (o && typeof o.length === "number") return {
6954 next: function () {
6955 if (o && i >= o.length) o = void 0;
6956 return { value: o && o[i++], done: !o };
6957 }
6958 };
6959 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
6960 }
6961
6962 function __read(o, n) {
6963 var m = typeof Symbol === "function" && o[Symbol.iterator];
6964 if (!m) return o;
6965 var i = m.call(o), r, ar = [], e;
6966 try {
6967 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
6968 }
6969 catch (error) { e = { error: error }; }
6970 finally {
6971 try {
6972 if (r && !r.done && (m = i["return"])) m.call(i);
6973 }
6974 finally { if (e) throw e.error; }
6975 }
6976 return ar;
6977 }
6978
6979 /** @deprecated */
6980 function __spread() {
6981 for (var ar = [], i = 0; i < arguments.length; i++)
6982 ar = ar.concat(__read(arguments[i]));
6983 return ar;
6984 }
6985
6986 /** @deprecated */
6987 function __spreadArrays() {
6988 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
6989 for (var r = Array(s), k = 0, i = 0; i < il; i++)
6990 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6991 r[k] = a[j];
6992 return r;
6993 }
6994
6995 function __spreadArray(to, from, pack) {
6996 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
6997 if (ar || !(i in from)) {
6998 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6999 ar[i] = from[i];
7000 }
7001 }
7002 return to.concat(ar || Array.prototype.slice.call(from));
7003 }
7004
7005 function __await(v) {
7006 return this instanceof __await ? (this.v = v, this) : new __await(v);
7007 }
7008
7009 function __asyncGenerator(thisArg, _arguments, generator) {
7010 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
7011 var g = generator.apply(thisArg, _arguments || []), i, q = [];
7012 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
7013 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
7014 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
7015 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
7016 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
7017 function fulfill(value) { resume("next", value); }
7018 function reject(value) { resume("throw", value); }
7019 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
7020 }
7021
7022 function __asyncDelegator(o) {
7023 var i, p;
7024 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
7025 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; }
7026 }
7027
7028 function __asyncValues(o) {
7029 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
7030 var m = o[Symbol.asyncIterator], i;
7031 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);
7032 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); }); }; }
7033 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7034 }
7035
7036 function __makeTemplateObject(cooked, raw) {
7037 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
7038 return cooked;
7039 };
7040
7041 var __setModuleDefault = Object.create ? (function(o, v) {
7042 Object.defineProperty(o, "default", { enumerable: true, value: v });
7043 }) : function(o, v) {
7044 o["default"] = v;
7045 };
7046
7047 function __importStar(mod) {
7048 if (mod && mod.__esModule) return mod;
7049 var result = {};
7050 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
7051 __setModuleDefault(result, mod);
7052 return result;
7053 }
7054
7055 function __importDefault(mod) {
7056 return (mod && mod.__esModule) ? mod : { default: mod };
7057 }
7058
7059 function __classPrivateFieldGet(receiver, state, kind, f) {
7060 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
7061 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");
7062 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7063 }
7064
7065 function __classPrivateFieldSet(receiver, state, value, kind, f) {
7066 if (kind === "m") throw new TypeError("Private method is not writable");
7067 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7068 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");
7069 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7070 }
7071
7072 function __classPrivateFieldIn(state, receiver) {
7073 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
7074 return typeof state === "function" ? receiver === state : state.has(receiver);
7075 }
7076
7077 function __addDisposableResource(env, value, async) {
7078 if (value !== null && value !== void 0) {
7079 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
7080 var dispose, inner;
7081 if (async) {
7082 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7083 dispose = value[Symbol.asyncDispose];
7084 }
7085 if (dispose === void 0) {
7086 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
7087 dispose = value[Symbol.dispose];
7088 if (async) inner = dispose;
7089 }
7090 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
7091 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
7092 env.stack.push({ value: value, dispose: dispose, async: async });
7093 }
7094 else if (async) {
7095 env.stack.push({ async: true });
7096 }
7097 return value;
7098 }
7099
7100 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
7101 var e = new Error(message);
7102 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
7103 };
7104
7105 function __disposeResources(env) {
7106 function fail(e) {
7107 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
7108 env.hasError = true;
7109 }
7110 var r, s = 0;
7111 function next() {
7112 while (r = env.stack.pop()) {
7113 try {
7114 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
7115 if (r.dispose) {
7116 var result = r.dispose.call(r.value);
7117 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
7118 }
7119 else s |= 1;
7120 }
7121 catch (e) {
7122 fail(e);
7123 }
7124 }
7125 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
7126 if (env.hasError) throw env.error;
7127 }
7128 return next();
7129 }
7130
7131 function __rewriteRelativeImportExtension(path, preserveJsx) {
7132 if (typeof path === "string" && /^\.\.?\//.test(path)) {
7133 return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
7134 return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
7135 });
7136 }
7137 return path;
7138 }
7139
7140 /* harmony default export */ const tslib_es6 = ({
7141 __extends,
7142 __assign,
7143 __rest,
7144 __decorate,
7145 __param,
7146 __esDecorate,
7147 __runInitializers,
7148 __propKey,
7149 __setFunctionName,
7150 __metadata,
7151 __awaiter,
7152 __generator,
7153 __createBinding,
7154 __exportStar,
7155 __values,
7156 __read,
7157 __spread,
7158 __spreadArrays,
7159 __spreadArray,
7160 __await,
7161 __asyncGenerator,
7162 __asyncDelegator,
7163 __asyncValues,
7164 __makeTemplateObject,
7165 __importStar,
7166 __importDefault,
7167 __classPrivateFieldGet,
7168 __classPrivateFieldSet,
7169 __classPrivateFieldIn,
7170 __addDisposableResource,
7171 __disposeResources,
7172 __rewriteRelativeImportExtension,
7173 });
7174
7175 ;// ./node_modules/lower-case/dist.es2015/index.js
7176 /**
7177 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
7178 */
7179 var SUPPORTED_LOCALE = {
7180 tr: {
7181 regexp: /\u0130|\u0049|\u0049\u0307/g,
7182 map: {
7183 İ: "\u0069",
7184 I: "\u0131",
7185 İ: "\u0069",
7186 },
7187 },
7188 az: {
7189 regexp: /\u0130/g,
7190 map: {
7191 İ: "\u0069",
7192 I: "\u0131",
7193 İ: "\u0069",
7194 },
7195 },
7196 lt: {
7197 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
7198 map: {
7199 I: "\u0069\u0307",
7200 J: "\u006A\u0307",
7201 Į: "\u012F\u0307",
7202 Ì: "\u0069\u0307\u0300",
7203 Í: "\u0069\u0307\u0301",
7204 Ĩ: "\u0069\u0307\u0303",
7205 },
7206 },
7207 };
7208 /**
7209 * Localized lower case.
7210 */
7211 function localeLowerCase(str, locale) {
7212 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
7213 if (lang)
7214 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
7215 return lowerCase(str);
7216 }
7217 /**
7218 * Lower case as a function.
7219 */
7220 function lowerCase(str) {
7221 return str.toLowerCase();
7222 }
7223
7224 ;// ./node_modules/no-case/dist.es2015/index.js
7225
7226 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
7227 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
7228 // Remove all non-word characters.
7229 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
7230 /**
7231 * Normalize the string into something other libraries can manipulate easier.
7232 */
7233 function noCase(input, options) {
7234 if (options === void 0) { options = {}; }
7235 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;
7236 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
7237 var start = 0;
7238 var end = result.length;
7239 // Trim the delimiter from around the output string.
7240 while (result.charAt(start) === "\0")
7241 start++;
7242 while (result.charAt(end - 1) === "\0")
7243 end--;
7244 // Transform each token independently.
7245 return result.slice(start, end).split("\0").map(transform).join(delimiter);
7246 }
7247 /**
7248 * Replace `re` in the input string with the replacement value.
7249 */
7250 function replace(input, re, value) {
7251 if (re instanceof RegExp)
7252 return input.replace(re, value);
7253 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
7254 }
7255
7256 ;// ./node_modules/dot-case/dist.es2015/index.js
7257
7258
7259 function dotCase(input, options) {
7260 if (options === void 0) { options = {}; }
7261 return noCase(input, __assign({ delimiter: "." }, options));
7262 }
7263
7264 ;// ./node_modules/param-case/dist.es2015/index.js
7265
7266
7267 function paramCase(input, options) {
7268 if (options === void 0) { options = {}; }
7269 return dotCase(input, __assign({ delimiter: "-" }, options));
7270 }
7271
7272 ;// ./packages/fields/build-module/components/create-template-part-modal/utils.js
7273 /* wp:polyfill */
7274 /**
7275 * External dependencies
7276 */
7277
7278
7279 /**
7280 * WordPress dependencies
7281 */
7282
7283
7284
7285 /**
7286 * Internal dependencies
7287 */
7288
7289 const useExistingTemplateParts = () => {
7290 var _useSelect;
7291 return (_useSelect = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template_part', {
7292 per_page: -1
7293 }), [])) !== null && _useSelect !== void 0 ? _useSelect : [];
7294 };
7295
7296 /**
7297 * Return a unique template part title based on
7298 * the given title and existing template parts.
7299 *
7300 * @param {string} title The original template part title.
7301 * @param {Object} templateParts The array of template part entities.
7302 * @return {string} A unique template part title.
7303 */
7304 const getUniqueTemplatePartTitle = (title, templateParts) => {
7305 const lowercaseTitle = title.toLowerCase();
7306 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
7307 if (!existingTitles.includes(lowercaseTitle)) {
7308 return title;
7309 }
7310 let suffix = 2;
7311 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
7312 suffix++;
7313 }
7314 return `${title} ${suffix}`;
7315 };
7316
7317 /**
7318 * Get a valid slug for a template part.
7319 * Currently template parts only allow latin chars.
7320 * The fallback slug will receive suffix by default.
7321 *
7322 * @param {string} title The template part title.
7323 * @return {string} A valid template part slug.
7324 */
7325 const getCleanTemplatePartSlug = title => {
7326 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
7327 };
7328
7329 ;// ./packages/fields/build-module/components/create-template-part-modal/index.js
7330 /* wp:polyfill */
7331 /**
7332 * WordPress dependencies
7333 */
7334
7335
7336
7337
7338
7339
7340
7341
7342 // @ts-expect-error serialize is not typed
7343
7344
7345 /**
7346 * Internal dependencies
7347 */
7348
7349
7350 function getAreaRadioId(value, instanceId) {
7351 return `fields-create-template-part-modal__area-option-${value}-${instanceId}`;
7352 }
7353 function getAreaRadioDescriptionId(value, instanceId) {
7354 return `fields-create-template-part-modal__area-option-description-${value}-${instanceId}`;
7355 }
7356 /**
7357 * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.
7358 * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
7359 * @param {Object} props The component props.
7360 * @param props.modalTitle
7361 */
7362 function CreateTemplatePartModal({
7363 modalTitle,
7364 ...restProps
7365 }) {
7366 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select =>
7367 // @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
7368 select(external_wp_coreData_namespaceObject.store).getPostType('wp_template_part')?.labels?.add_new_item, []);
7369 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
7370 title: modalTitle || defaultModalTitle,
7371 onRequestClose: restProps.closeModal,
7372 overlayClassName: "fields-create-template-part-modal",
7373 focusOnMount: "firstContentElement",
7374 size: "medium",
7375 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
7376 ...restProps
7377 })
7378 });
7379 }
7380 const create_template_part_modal_getTemplatePartIcon = iconName => {
7381 if ('header' === iconName) {
7382 return library_header;
7383 } else if ('footer' === iconName) {
7384 return library_footer;
7385 } else if ('sidebar' === iconName) {
7386 return library_sidebar;
7387 }
7388 return symbol_filled;
7389 };
7390
7391 /**
7392 * A React component that renders the content of a model for creating a template part.
7393 * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.
7394 *
7395 * @param {Object} props - The component props.
7396 * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.
7397 * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.
7398 * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.
7399 * @param {Function} props.closeModal - Function to close the modal.
7400 * @param {Function} props.onCreate - Function to call when the template part is successfully created.
7401 * @param {Function} [props.onError] - Function to call when there is an error creating the template part.
7402 * @param {string} [props.defaultTitle=''] - The default title for the template part.
7403 */
7404 function CreateTemplatePartModalContents({
7405 defaultArea = 'uncategorized',
7406 blocks = [],
7407 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Add'),
7408 closeModal,
7409 onCreate,
7410 onError,
7411 defaultTitle = ''
7412 }) {
7413 const {
7414 createErrorNotice
7415 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7416 const {
7417 saveEntityRecord
7418 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
7419 const existingTemplateParts = useExistingTemplateParts();
7420 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle);
7421 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea);
7422 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
7423 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
7424 const defaultTemplatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select =>
7425 // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
7426 select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas, []);
7427 async function createTemplatePart() {
7428 if (!title || isSubmitting) {
7429 return;
7430 }
7431 try {
7432 setIsSubmitting(true);
7433 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts);
7434 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
7435 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
7436 slug: cleanSlug,
7437 title: uniqueTitle,
7438 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
7439 area
7440 }, {
7441 throwOnError: true
7442 });
7443 await onCreate(templatePart);
7444
7445 // TODO: Add a success notice?
7446 } catch (error) {
7447 const errorMessage = error instanceof Error && 'code' in error && error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
7448 createErrorNotice(errorMessage, {
7449 type: 'snackbar'
7450 });
7451 onError?.();
7452 } finally {
7453 setIsSubmitting(false);
7454 }
7455 }
7456 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
7457 onSubmit: async event => {
7458 event.preventDefault();
7459 await createTemplatePart();
7460 },
7461 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7462 spacing: "4",
7463 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
7464 __next40pxDefaultSize: true,
7465 __nextHasNoMarginBottom: true,
7466 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
7467 value: title,
7468 onChange: setTitle,
7469 required: true
7470 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
7471 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
7472 as: "legend",
7473 children: (0,external_wp_i18n_namespaceObject.__)('Area')
7474 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7475 className: "fields-create-template-part-modal__area-radio-group",
7476 children: (defaultTemplatePartAreas !== null && defaultTemplatePartAreas !== void 0 ? defaultTemplatePartAreas : []).map(item => {
7477 const icon = create_template_part_modal_getTemplatePartIcon(item.icon);
7478 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7479 className: "fields-create-template-part-modal__area-radio-wrapper",
7480 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
7481 type: "radio",
7482 id: getAreaRadioId(item.area, instanceId),
7483 name: `fields-create-template-part-modal__area-${instanceId}`,
7484 value: item.area,
7485 checked: area === item.area,
7486 onChange: () => {
7487 setArea(item.area);
7488 },
7489 "aria-describedby": getAreaRadioDescriptionId(item.area, instanceId)
7490 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
7491 icon: icon,
7492 className: "fields-create-template-part-modal__area-radio-icon"
7493 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
7494 htmlFor: getAreaRadioId(item.area, instanceId),
7495 className: "fields-create-template-part-modal__area-radio-label",
7496 children: item.label
7497 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
7498 icon: library_check,
7499 className: "fields-create-template-part-modal__area-radio-checkmark"
7500 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
7501 className: "fields-create-template-part-modal__area-radio-description",
7502 id: getAreaRadioDescriptionId(item.area, instanceId),
7503 children: item.description
7504 })]
7505 }, item.area);
7506 })
7507 })]
7508 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7509 justify: "right",
7510 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7511 __next40pxDefaultSize: true,
7512 variant: "tertiary",
7513 onClick: () => {
7514 closeModal();
7515 },
7516 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7517 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7518 __next40pxDefaultSize: true,
7519 variant: "primary",
7520 type: "submit",
7521 "aria-disabled": !title || isSubmitting,
7522 isBusy: isSubmitting,
7523 children: confirmLabel
7524 })]
7525 })]
7526 })
7527 });
7528 }
7529
7530 ;// ./packages/fields/build-module/actions/duplicate-template-part.js
7531 /**
7532 * WordPress dependencies
7533 */
7534
7535
7536
7537
7538 // @ts-ignore
7539
7540
7541 /**
7542 * Internal dependencies
7543 */
7544
7545
7546
7547
7548 /**
7549 * This action is used to duplicate a template part.
7550 */
7551
7552 const duplicateTemplatePart = {
7553 id: 'duplicate-template-part',
7554 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
7555 isEligible: item => item.type === 'wp_template_part',
7556 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
7557 RenderModal: ({
7558 items,
7559 closeModal
7560 }) => {
7561 const [item] = items;
7562 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
7563 var _item$blocks;
7564 return (_item$blocks = item.blocks) !== null && _item$blocks !== void 0 ? _item$blocks : (0,external_wp_blocks_namespaceObject.parse)(typeof item.content === 'string' ? item.content : item.content.raw, {
7565 __unstableSkipMigrationLogs: true
7566 });
7567 }, [item.content, item.blocks]);
7568 const {
7569 createSuccessNotice
7570 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7571 function onTemplatePartSuccess(templatePart) {
7572 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
7573 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
7574 (0,external_wp_i18n_namespaceObject._x)('"%s" duplicated.', 'template part'), getItemTitle(templatePart)), {
7575 type: 'snackbar',
7576 id: 'edit-site-patterns-success'
7577 });
7578 closeModal?.();
7579 }
7580 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
7581 blocks: blocks,
7582 defaultArea: item.area,
7583 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: Existing template part title */
7584 (0,external_wp_i18n_namespaceObject._x)('%s (Copy)', 'template part'), getItemTitle(item)),
7585 onCreate: onTemplatePartSuccess,
7586 onError: closeModal,
7587 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
7588 closeModal: closeModal !== null && closeModal !== void 0 ? closeModal : () => {}
7589 });
7590 }
7591 };
7592 /**
7593 * Duplicate action for TemplatePart.
7594 */
7595 /* harmony default export */ const duplicate_template_part = (duplicateTemplatePart);
7596
7597 ;// external ["wp","patterns"]
7598 const external_wp_patterns_namespaceObject = window["wp"]["patterns"];
7599 ;// ./packages/fields/build-module/lock-unlock.js
7600 /**
7601 * WordPress dependencies
7602 */
7603
7604 const {
7605 lock: lock_unlock_lock,
7606 unlock: lock_unlock_unlock
7607 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/fields');
7608
7609 ;// ./packages/fields/build-module/actions/duplicate-pattern.js
7610 /**
7611 * WordPress dependencies
7612 */
7613
7614 // @ts-ignore
7615
7616 /**
7617 * Internal dependencies
7618 */
7619
7620
7621 // Patterns.
7622 const {
7623 CreatePatternModalContents,
7624 useDuplicatePatternProps
7625 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
7626 const duplicatePattern = {
7627 id: 'duplicate-pattern',
7628 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
7629 isEligible: item => item.type !== 'wp_template_part',
7630 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
7631 RenderModal: ({
7632 items,
7633 closeModal
7634 }) => {
7635 const [item] = items;
7636 const duplicatedProps = useDuplicatePatternProps({
7637 pattern: item,
7638 onSuccess: () => closeModal?.()
7639 });
7640 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
7641 onClose: closeModal,
7642 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
7643 ...duplicatedProps
7644 });
7645 }
7646 };
7647
7648 /**
7649 * Duplicate action for Pattern.
7650 */
7651 /* harmony default export */ const duplicate_pattern = (duplicatePattern);
7652
7653 ;// ./packages/fields/build-module/actions/rename-post.js
7654 /**
7655 * WordPress dependencies
7656 */
7657
7658
7659
7660
7661 // @ts-ignore
7662
7663
7664
7665
7666 /**
7667 * Internal dependencies
7668 */
7669
7670
7671
7672
7673 // Patterns.
7674 const {
7675 PATTERN_TYPES
7676 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
7677 const renamePost = {
7678 id: 'rename-post',
7679 label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
7680 isEligible(post) {
7681 if (post.status === 'trash') {
7682 return false;
7683 }
7684 // Templates, template parts and patterns have special checks for renaming.
7685 if (!['wp_template', 'wp_template_part', ...Object.values(PATTERN_TYPES)].includes(post.type)) {
7686 return post.permissions?.update;
7687 }
7688
7689 // In the case of templates, we can only rename custom templates.
7690 if (isTemplate(post)) {
7691 return isTemplateRemovable(post) && post.is_custom && post.permissions?.update;
7692 }
7693 if (isTemplatePart(post)) {
7694 return post.source === 'custom' && !post?.has_theme_file && post.permissions?.update;
7695 }
7696 return post.type === PATTERN_TYPES.user && post.permissions?.update;
7697 },
7698 RenderModal: ({
7699 items,
7700 closeModal,
7701 onActionPerformed
7702 }) => {
7703 const [item] = items;
7704 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => getItemTitle(item));
7705 const {
7706 editEntityRecord,
7707 saveEditedEntityRecord
7708 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
7709 const {
7710 createSuccessNotice,
7711 createErrorNotice
7712 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7713 async function onRename(event) {
7714 event.preventDefault();
7715 try {
7716 await editEntityRecord('postType', item.type, item.id, {
7717 title
7718 });
7719 // Update state before saving rerenders the list.
7720 setTitle('');
7721 closeModal?.();
7722 // Persist edited entity.
7723 await saveEditedEntityRecord('postType', item.type, item.id, {
7724 throwOnError: true
7725 });
7726 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
7727 type: 'snackbar'
7728 });
7729 onActionPerformed?.(items);
7730 } catch (error) {
7731 const typedError = error;
7732 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
7733 createErrorNotice(errorMessage, {
7734 type: 'snackbar'
7735 });
7736 }
7737 }
7738 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
7739 onSubmit: onRename,
7740 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7741 spacing: "5",
7742 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
7743 __nextHasNoMarginBottom: true,
7744 __next40pxDefaultSize: true,
7745 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
7746 value: title,
7747 onChange: setTitle,
7748 required: true
7749 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7750 justify: "right",
7751 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7752 __next40pxDefaultSize: true,
7753 variant: "tertiary",
7754 onClick: () => {
7755 closeModal?.();
7756 },
7757 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7758 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7759 __next40pxDefaultSize: true,
7760 variant: "primary",
7761 type: "submit",
7762 children: (0,external_wp_i18n_namespaceObject.__)('Save')
7763 })]
7764 })]
7765 })
7766 });
7767 }
7768 };
7769
7770 /**
7771 * Rename action for PostWithPermissions.
7772 */
7773 /* harmony default export */ const rename_post = (renamePost);
7774
7775 ;// ./packages/dataviews/build-module/validation.js
7776 /* wp:polyfill */
7777 /**
7778 * Internal dependencies
7779 */
7780
7781 /**
7782 * Whether or not the given item's value is valid according to the fields and form config.
7783 *
7784 * @param item The item to validate.
7785 * @param fields Fields config.
7786 * @param form Form config.
7787 *
7788 * @return A boolean indicating if the item is valid (true) or not (false).
7789 */
7790 function isItemValid(item, fields, form) {
7791 const _fields = normalizeFields(fields.filter(({
7792 id
7793 }) => !!form.fields?.includes(id)));
7794 return _fields.every(field => {
7795 return field.isValid(item, {
7796 elements: field.elements
7797 });
7798 });
7799 }
7800
7801 ;// ./packages/fields/build-module/fields/order/index.js
7802 /**
7803 * WordPress dependencies
7804 */
7805
7806
7807
7808 /**
7809 * Internal dependencies
7810 */
7811
7812 const orderField = {
7813 id: 'menu_order',
7814 type: 'integer',
7815 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
7816 description: (0,external_wp_i18n_namespaceObject.__)('Determines the order of pages.')
7817 };
7818
7819 /**
7820 * Order field for BasePost.
7821 */
7822 /* harmony default export */ const order = (orderField);
7823
7824 ;// ./packages/fields/build-module/actions/reorder-page.js
7825 /**
7826 * WordPress dependencies
7827 */
7828
7829
7830
7831
7832
7833
7834
7835
7836 /**
7837 * Internal dependencies
7838 */
7839
7840
7841
7842 const reorder_page_fields = [order];
7843 const formOrderAction = {
7844 fields: ['menu_order']
7845 };
7846 function ReorderModal({
7847 items,
7848 closeModal,
7849 onActionPerformed
7850 }) {
7851 const [item, setItem] = (0,external_wp_element_namespaceObject.useState)(items[0]);
7852 const orderInput = item.menu_order;
7853 const {
7854 editEntityRecord,
7855 saveEditedEntityRecord
7856 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
7857 const {
7858 createSuccessNotice,
7859 createErrorNotice
7860 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
7861 async function onOrder(event) {
7862 event.preventDefault();
7863 if (!isItemValid(item, reorder_page_fields, formOrderAction)) {
7864 return;
7865 }
7866 try {
7867 await editEntityRecord('postType', item.type, item.id, {
7868 menu_order: orderInput
7869 });
7870 closeModal?.();
7871 // Persist edited entity.
7872 await saveEditedEntityRecord('postType', item.type, item.id, {
7873 throwOnError: true
7874 });
7875 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Order updated.'), {
7876 type: 'snackbar'
7877 });
7878 onActionPerformed?.(items);
7879 } catch (error) {
7880 const typedError = error;
7881 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the order');
7882 createErrorNotice(errorMessage, {
7883 type: 'snackbar'
7884 });
7885 }
7886 }
7887 const isSaveDisabled = !isItemValid(item, reorder_page_fields, formOrderAction);
7888 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
7889 onSubmit: onOrder,
7890 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
7891 spacing: "5",
7892 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7893 children: (0,external_wp_i18n_namespaceObject.__)('Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.')
7894 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataForm, {
7895 data: item,
7896 fields: reorder_page_fields,
7897 form: formOrderAction,
7898 onChange: changes => setItem({
7899 ...item,
7900 ...changes
7901 })
7902 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
7903 justify: "right",
7904 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7905 __next40pxDefaultSize: true,
7906 variant: "tertiary",
7907 onClick: () => {
7908 closeModal?.();
7909 },
7910 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
7911 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7912 __next40pxDefaultSize: true,
7913 variant: "primary",
7914 type: "submit",
7915 accessibleWhenDisabled: true,
7916 disabled: isSaveDisabled,
7917 children: (0,external_wp_i18n_namespaceObject.__)('Save')
7918 })]
7919 })]
7920 })
7921 });
7922 }
7923 const reorderPage = {
7924 id: 'order-pages',
7925 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
7926 isEligible({
7927 status
7928 }) {
7929 return status !== 'trash';
7930 },
7931 RenderModal: ReorderModal
7932 };
7933
7934 /**
7935 * Reorder action for BasePost.
7936 */
7937 /* harmony default export */ const reorder_page = (reorderPage);
7938
7939 ;// ./node_modules/client-zip/index.js
7940 "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)}
7941 ;// external ["wp","blob"]
7942 const external_wp_blob_namespaceObject = window["wp"]["blob"];
7943 ;// ./packages/icons/build-module/library/download.js
7944 /**
7945 * WordPress dependencies
7946 */
7947
7948
7949 const download = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7950 xmlns: "http://www.w3.org/2000/svg",
7951 viewBox: "0 0 24 24",
7952 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7953 d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"
7954 })
7955 });
7956 /* harmony default export */ const library_download = (download);
7957
7958 ;// ./packages/fields/build-module/actions/export-pattern.js
7959 /* wp:polyfill */
7960 /**
7961 * External dependencies
7962 */
7963
7964
7965
7966 /**
7967 * WordPress dependencies
7968 */
7969
7970
7971
7972
7973 /**
7974 * Internal dependencies
7975 */
7976
7977
7978 function getJsonFromItem(item) {
7979 return JSON.stringify({
7980 __file: item.type,
7981 title: getItemTitle(item),
7982 content: typeof item.content === 'string' ? item.content : item.content?.raw,
7983 syncStatus: item.wp_pattern_sync_status
7984 }, null, 2);
7985 }
7986 const exportPattern = {
7987 id: 'export-pattern',
7988 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'),
7989 icon: library_download,
7990 supportsBulk: true,
7991 isEligible: item => item.type === 'wp_block',
7992 callback: async items => {
7993 if (items.length === 1) {
7994 return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(getItemTitle(items[0]) || items[0].slug)}.json`, getJsonFromItem(items[0]), 'application/json');
7995 }
7996 const nameCount = {};
7997 const filesToZip = items.map(item => {
7998 const name = paramCase(getItemTitle(item) || item.slug);
7999 nameCount[name] = (nameCount[name] || 0) + 1;
8000 return {
8001 name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
8002 lastModified: new Date(),
8003 input: getJsonFromItem(item)
8004 };
8005 });
8006 return (0,external_wp_blob_namespaceObject.downloadBlob)((0,external_wp_i18n_namespaceObject.__)('patterns-export') + '.zip', await A(filesToZip).blob(), 'application/zip');
8007 }
8008 };
8009
8010 /**
8011 * Export action as JSON for Pattern.
8012 */
8013 /* harmony default export */ const export_pattern = (exportPattern);
8014
8015 ;// ./packages/icons/build-module/library/backup.js
8016 /**
8017 * WordPress dependencies
8018 */
8019
8020
8021 const backup = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8022 xmlns: "http://www.w3.org/2000/svg",
8023 viewBox: "0 0 24 24",
8024 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8025 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"
8026 })
8027 });
8028 /* harmony default export */ const library_backup = (backup);
8029
8030 ;// ./packages/fields/build-module/actions/restore-post.js
8031 /* wp:polyfill */
8032 /**
8033 * WordPress dependencies
8034 */
8035
8036
8037
8038
8039 /**
8040 * Internal dependencies
8041 */
8042
8043 const restorePost = {
8044 id: 'restore',
8045 label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
8046 isPrimary: true,
8047 icon: library_backup,
8048 supportsBulk: true,
8049 isEligible(item) {
8050 return !isTemplateOrTemplatePart(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
8051 },
8052 async callback(posts, {
8053 registry,
8054 onActionPerformed
8055 }) {
8056 const {
8057 createSuccessNotice,
8058 createErrorNotice
8059 } = registry.dispatch(external_wp_notices_namespaceObject.store);
8060 const {
8061 editEntityRecord,
8062 saveEditedEntityRecord
8063 } = registry.dispatch(external_wp_coreData_namespaceObject.store);
8064 await Promise.allSettled(posts.map(post => {
8065 return editEntityRecord('postType', post.type, post.id, {
8066 status: 'draft'
8067 });
8068 }));
8069 const promiseResult = await Promise.allSettled(posts.map(post => {
8070 return saveEditedEntityRecord('postType', post.type, post.id, {
8071 throwOnError: true
8072 });
8073 }));
8074 if (promiseResult.every(({
8075 status
8076 }) => status === 'fulfilled')) {
8077 let successMessage;
8078 if (posts.length === 1) {
8079 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
8080 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
8081 } else if (posts[0].type === 'page') {
8082 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
8083 (0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
8084 } else {
8085 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of posts. */
8086 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
8087 }
8088 createSuccessNotice(successMessage, {
8089 type: 'snackbar',
8090 id: 'restore-post-action'
8091 });
8092 if (onActionPerformed) {
8093 onActionPerformed(posts);
8094 }
8095 } else {
8096 // If there was at lease one failure.
8097 let errorMessage;
8098 // If we were trying to move a single post to the trash.
8099 if (promiseResult.length === 1) {
8100 const typedError = promiseResult[0];
8101 if (typedError.reason?.message) {
8102 errorMessage = typedError.reason.message;
8103 } else {
8104 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
8105 }
8106 // If we were trying to move multiple posts to the trash
8107 } else {
8108 const errorMessages = new Set();
8109 const failedPromises = promiseResult.filter(({
8110 status
8111 }) => status === 'rejected');
8112 for (const failedPromise of failedPromises) {
8113 const typedError = failedPromise;
8114 if (typedError.reason?.message) {
8115 errorMessages.add(typedError.reason.message);
8116 }
8117 }
8118 if (errorMessages.size === 0) {
8119 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
8120 } else if (errorMessages.size === 1) {
8121 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8122 (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
8123 } else {
8124 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8125 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
8126 }
8127 }
8128 createErrorNotice(errorMessage, {
8129 type: 'snackbar'
8130 });
8131 }
8132 }
8133 };
8134
8135 /**
8136 * Restore action for PostWithPermissions.
8137 */
8138 /* harmony default export */ const restore_post = (restorePost);
8139
8140 ;// ./packages/fields/build-module/actions/reset-post.js
8141 /**
8142 * WordPress dependencies
8143 */
8144
8145
8146
8147
8148
8149
8150 // @ts-ignore
8151
8152
8153
8154
8155
8156 /**
8157 * Internal dependencies
8158 */
8159
8160
8161 const reset_post_isTemplateRevertable = templateOrTemplatePart => {
8162 if (!templateOrTemplatePart) {
8163 return false;
8164 }
8165 return templateOrTemplatePart.source === 'custom' && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
8166 };
8167
8168 /**
8169 * Copied - pasted from https://github.com/WordPress/gutenberg/blob/bf1462ad37d4637ebbf63270b9c244b23c69e2a8/packages/editor/src/store/private-actions.js#L233-L365
8170 *
8171 * @param {Object} template The template to revert.
8172 * @param {Object} [options]
8173 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
8174 * reverting the template. Default true.
8175 */
8176 const revertTemplate = async (template, {
8177 allowUndo = true
8178 } = {}) => {
8179 const noticeId = 'edit-site-template-reverted';
8180 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
8181 if (!reset_post_isTemplateRevertable(template)) {
8182 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
8183 type: 'snackbar'
8184 });
8185 return;
8186 }
8187 try {
8188 const templateEntityConfig = (0,external_wp_data_namespaceObject.select)(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
8189 if (!templateEntityConfig) {
8190 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
8191 type: 'snackbar'
8192 });
8193 return;
8194 }
8195 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
8196 context: 'edit',
8197 source: template.origin
8198 });
8199 const fileTemplate = await external_wp_apiFetch_default()({
8200 path: fileTemplatePath
8201 });
8202 if (!fileTemplate) {
8203 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
8204 type: 'snackbar'
8205 });
8206 return;
8207 }
8208 const serializeBlocks = ({
8209 blocks: blocksForSerialization = []
8210 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
8211 const edited = (0,external_wp_data_namespaceObject.select)(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
8212
8213 // We are fixing up the undo level here to make sure we can undo
8214 // the revert in the header toolbar correctly.
8215 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
8216 content: serializeBlocks,
8217 // Required to make the `undo` behave correctly.
8218 blocks: edited.blocks,
8219 // Required to revert the blocks in the editor.
8220 source: 'custom' // required to avoid turning the editor into a dirty state
8221 }, {
8222 undoIgnore: true // Required to merge this edit with the last undo level.
8223 });
8224 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
8225 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
8226 content: serializeBlocks,
8227 blocks,
8228 source: 'theme'
8229 });
8230 if (allowUndo) {
8231 const undoRevert = () => {
8232 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
8233 content: serializeBlocks,
8234 blocks: edited.blocks,
8235 source: 'custom'
8236 });
8237 };
8238 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
8239 type: 'snackbar',
8240 id: noticeId,
8241 actions: [{
8242 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
8243 onClick: undoRevert
8244 }]
8245 });
8246 }
8247 } catch (error) {
8248 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
8249 (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
8250 type: 'snackbar'
8251 });
8252 }
8253 };
8254 const resetPostAction = {
8255 id: 'reset-post',
8256 label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
8257 isEligible: item => {
8258 return isTemplateOrTemplatePart(item) && item?.source === 'custom' && (Boolean(item.type === 'wp_template' && item?.plugin) || item?.has_theme_file);
8259 },
8260 icon: library_backup,
8261 supportsBulk: true,
8262 hideModalHeader: true,
8263 RenderModal: ({
8264 items,
8265 closeModal,
8266 onActionPerformed
8267 }) => {
8268 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
8269 const {
8270 saveEditedEntityRecord
8271 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8272 const {
8273 createSuccessNotice,
8274 createErrorNotice
8275 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8276 const onConfirm = async () => {
8277 try {
8278 for (const template of items) {
8279 await revertTemplate(template, {
8280 allowUndo: false
8281 });
8282 await saveEditedEntityRecord('postType', template.type, template.id);
8283 }
8284 createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of items. */
8285 (0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
8286 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), getItemTitle(items[0])), {
8287 type: 'snackbar',
8288 id: 'revert-template-action'
8289 });
8290 } catch (error) {
8291 let fallbackErrorMessage;
8292 if (items[0].type === 'wp_template') {
8293 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.');
8294 } else {
8295 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.');
8296 }
8297 const typedError = error;
8298 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : fallbackErrorMessage;
8299 createErrorNotice(errorMessage, {
8300 type: 'snackbar'
8301 });
8302 }
8303 };
8304 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
8305 spacing: "5",
8306 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8307 children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
8308 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
8309 justify: "right",
8310 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8311 __next40pxDefaultSize: true,
8312 variant: "tertiary",
8313 onClick: closeModal,
8314 disabled: isBusy,
8315 accessibleWhenDisabled: true,
8316 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8317 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8318 __next40pxDefaultSize: true,
8319 variant: "primary",
8320 onClick: async () => {
8321 setIsBusy(true);
8322 await onConfirm();
8323 onActionPerformed?.(items);
8324 setIsBusy(false);
8325 closeModal?.();
8326 },
8327 isBusy: isBusy,
8328 disabled: isBusy,
8329 accessibleWhenDisabled: true,
8330 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
8331 })]
8332 })]
8333 });
8334 }
8335 };
8336
8337 /**
8338 * Reset action for Template and TemplatePart.
8339 */
8340 /* harmony default export */ const reset_post = (resetPostAction);
8341
8342 ;// ./packages/icons/build-module/library/trash.js
8343 /**
8344 * WordPress dependencies
8345 */
8346
8347
8348 const trash = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8349 xmlns: "http://www.w3.org/2000/svg",
8350 viewBox: "0 0 24 24",
8351 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8352 fillRule: "evenodd",
8353 clipRule: "evenodd",
8354 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"
8355 })
8356 });
8357 /* harmony default export */ const library_trash = (trash);
8358
8359 ;// ./packages/fields/build-module/mutation/index.js
8360 /* wp:polyfill */
8361 /**
8362 * WordPress dependencies
8363 */
8364
8365
8366
8367
8368 /**
8369 * Internal dependencies
8370 */
8371
8372 function getErrorMessagesFromPromises(allSettledResults) {
8373 const errorMessages = new Set();
8374 // If there was at lease one failure.
8375 if (allSettledResults.length === 1) {
8376 const typedError = allSettledResults[0];
8377 if (typedError.reason?.message) {
8378 errorMessages.add(typedError.reason.message);
8379 }
8380 } else {
8381 const failedPromises = allSettledResults.filter(({
8382 status
8383 }) => status === 'rejected');
8384 for (const failedPromise of failedPromises) {
8385 const typedError = failedPromise;
8386 if (typedError.reason?.message) {
8387 errorMessages.add(typedError.reason.message);
8388 }
8389 }
8390 }
8391 return errorMessages;
8392 }
8393 const deletePostWithNotices = async (posts, notice, callbacks) => {
8394 const {
8395 createSuccessNotice,
8396 createErrorNotice
8397 } = (0,external_wp_data_namespaceObject.dispatch)(external_wp_notices_namespaceObject.store);
8398 const {
8399 deleteEntityRecord
8400 } = (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store);
8401 const allSettledResults = await Promise.allSettled(posts.map(post => {
8402 return deleteEntityRecord('postType', post.type, post.id, {
8403 force: true
8404 }, {
8405 throwOnError: true
8406 });
8407 }));
8408 // If all the promises were fulfilled with success.
8409 if (allSettledResults.every(({
8410 status
8411 }) => status === 'fulfilled')) {
8412 var _notice$success$type;
8413 let successMessage;
8414 if (allSettledResults.length === 1) {
8415 successMessage = notice.success.messages.getMessage(posts[0]);
8416 } else {
8417 successMessage = notice.success.messages.getBatchMessage(posts);
8418 }
8419 createSuccessNotice(successMessage, {
8420 type: (_notice$success$type = notice.success.type) !== null && _notice$success$type !== void 0 ? _notice$success$type : 'snackbar',
8421 id: notice.success.id
8422 });
8423 callbacks.onActionPerformed?.(posts);
8424 } else {
8425 var _notice$error$type;
8426 const errorMessages = getErrorMessagesFromPromises(allSettledResults);
8427 let errorMessage = '';
8428 if (allSettledResults.length === 1) {
8429 errorMessage = notice.error.messages.getMessage(errorMessages);
8430 } else {
8431 errorMessage = notice.error.messages.getBatchMessage(errorMessages);
8432 }
8433 createErrorNotice(errorMessage, {
8434 type: (_notice$error$type = notice.error.type) !== null && _notice$error$type !== void 0 ? _notice$error$type : 'snackbar',
8435 id: notice.error.id
8436 });
8437 callbacks.onActionError?.();
8438 }
8439 };
8440 const editPostWithNotices = async (postsWithUpdates, notice, callbacks) => {
8441 const {
8442 createSuccessNotice,
8443 createErrorNotice
8444 } = dispatch(noticesStore);
8445 const {
8446 editEntityRecord,
8447 saveEditedEntityRecord
8448 } = dispatch(coreStore);
8449 await Promise.allSettled(postsWithUpdates.map(post => {
8450 return editEntityRecord('postType', post.originalPost.type, post.originalPost.id, {
8451 ...post.changes
8452 });
8453 }));
8454 const allSettledResults = await Promise.allSettled(postsWithUpdates.map(post => {
8455 return saveEditedEntityRecord('postType', post.originalPost.type, post.originalPost.id, {
8456 throwOnError: true
8457 });
8458 }));
8459 // If all the promises were fulfilled with success.
8460 if (allSettledResults.every(({
8461 status
8462 }) => status === 'fulfilled')) {
8463 var _notice$success$type2;
8464 let successMessage;
8465 if (allSettledResults.length === 1) {
8466 successMessage = notice.success.messages.getMessage(postsWithUpdates[0].originalPost);
8467 } else {
8468 successMessage = notice.success.messages.getBatchMessage(postsWithUpdates.map(post => post.originalPost));
8469 }
8470 createSuccessNotice(successMessage, {
8471 type: (_notice$success$type2 = notice.success.type) !== null && _notice$success$type2 !== void 0 ? _notice$success$type2 : 'snackbar',
8472 id: notice.success.id
8473 });
8474 callbacks.onActionPerformed?.(postsWithUpdates.map(post => post.originalPost));
8475 } else {
8476 var _notice$error$type2;
8477 const errorMessages = getErrorMessagesFromPromises(allSettledResults);
8478 let errorMessage = '';
8479 if (allSettledResults.length === 1) {
8480 errorMessage = notice.error.messages.getMessage(errorMessages);
8481 } else {
8482 errorMessage = notice.error.messages.getBatchMessage(errorMessages);
8483 }
8484 createErrorNotice(errorMessage, {
8485 type: (_notice$error$type2 = notice.error.type) !== null && _notice$error$type2 !== void 0 ? _notice$error$type2 : 'snackbar',
8486 id: notice.error.id
8487 });
8488 callbacks.onActionError?.();
8489 }
8490 };
8491
8492 ;// ./packages/fields/build-module/actions/delete-post.js
8493 /* wp:polyfill */
8494 /**
8495 * WordPress dependencies
8496 */
8497
8498
8499
8500
8501 // @ts-ignore
8502
8503
8504
8505 /**
8506 * Internal dependencies
8507 */
8508
8509
8510
8511
8512 const {
8513 PATTERN_TYPES: delete_post_PATTERN_TYPES
8514 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
8515
8516 // This action is used for templates, patterns and template parts.
8517 // Every other post type uses the similar `trashPostAction` which
8518 // moves the post to trash.
8519 const deletePostAction = {
8520 id: 'delete-post',
8521 label: (0,external_wp_i18n_namespaceObject.__)('Delete'),
8522 isPrimary: true,
8523 icon: library_trash,
8524 isEligible(post) {
8525 if (isTemplateOrTemplatePart(post)) {
8526 return isTemplateRemovable(post);
8527 }
8528 // We can only remove user patterns.
8529 return post.type === delete_post_PATTERN_TYPES.user;
8530 },
8531 supportsBulk: true,
8532 hideModalHeader: true,
8533 RenderModal: ({
8534 items,
8535 closeModal,
8536 onActionPerformed
8537 }) => {
8538 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
8539 const isResetting = items.every(item => isTemplateOrTemplatePart(item) && item?.has_theme_file);
8540 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
8541 spacing: "5",
8542 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8543 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
8544 // translators: %d: number of items to delete.
8545 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
8546 // translators: %s: The template or template part's title
8547 (0,external_wp_i18n_namespaceObject._x)('Delete "%s"?', 'template part'), getItemTitle(items[0]))
8548 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
8549 justify: "right",
8550 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8551 variant: "tertiary",
8552 onClick: closeModal,
8553 disabled: isBusy,
8554 accessibleWhenDisabled: true,
8555 __next40pxDefaultSize: true,
8556 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8557 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8558 variant: "primary",
8559 onClick: async () => {
8560 setIsBusy(true);
8561 const notice = {
8562 success: {
8563 messages: {
8564 getMessage: item => {
8565 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
8566 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(item))) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: The template/part's name. */
8567 (0,external_wp_i18n_namespaceObject._x)('"%s" deleted.', 'template part'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(item)));
8568 },
8569 getBatchMessage: () => {
8570 return isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
8571 }
8572 }
8573 },
8574 error: {
8575 messages: {
8576 getMessage: error => {
8577 if (error.size === 1) {
8578 return [...error][0];
8579 }
8580 return isResetting ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the item.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
8581 },
8582 getBatchMessage: errors => {
8583 if (errors.size === 0) {
8584 return isResetting ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the items.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
8585 }
8586 if (errors.size === 1) {
8587 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8588 (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the items: %s'), [...errors][0]) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8589 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errors][0]);
8590 }
8591 return isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8592 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while reverting the items: %s'), [...errors].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8593 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errors].join(','));
8594 }
8595 }
8596 }
8597 };
8598 await deletePostWithNotices(items, notice, {
8599 onActionPerformed
8600 });
8601 setIsBusy(false);
8602 closeModal?.();
8603 },
8604 isBusy: isBusy,
8605 disabled: isBusy,
8606 accessibleWhenDisabled: true,
8607 __next40pxDefaultSize: true,
8608 children: (0,external_wp_i18n_namespaceObject.__)('Delete')
8609 })]
8610 })]
8611 });
8612 }
8613 };
8614
8615 /**
8616 * Delete action for Templates, Patterns and Template Parts.
8617 */
8618 /* harmony default export */ const delete_post = (deletePostAction);
8619
8620 ;// ./packages/fields/build-module/actions/trash-post.js
8621 /* wp:polyfill */
8622 /**
8623 * WordPress dependencies
8624 */
8625
8626
8627
8628
8629
8630
8631
8632 /**
8633 * Internal dependencies
8634 */
8635
8636
8637 const trash_post_trashPost = {
8638 id: 'move-to-trash',
8639 label: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
8640 isPrimary: true,
8641 icon: library_trash,
8642 isEligible(item) {
8643 if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
8644 return false;
8645 }
8646 return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
8647 },
8648 supportsBulk: true,
8649 hideModalHeader: true,
8650 RenderModal: ({
8651 items,
8652 closeModal,
8653 onActionPerformed
8654 }) => {
8655 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
8656 const {
8657 createSuccessNotice,
8658 createErrorNotice
8659 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8660 const {
8661 deleteEntityRecord
8662 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8663 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
8664 spacing: "5",
8665 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8666 children: items.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
8667 // translators: %s: The item's title.
8668 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move "%s" to the trash?'), getItemTitle(items[0])) : (0,external_wp_i18n_namespaceObject.sprintf)(
8669 // translators: %d: The number of items (2 or more).
8670 (0,external_wp_i18n_namespaceObject._n)('Are you sure you want to move %d item to the trash ?', 'Are you sure you want to move %d items to the trash ?', items.length), items.length)
8671 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
8672 justify: "right",
8673 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8674 __next40pxDefaultSize: true,
8675 variant: "tertiary",
8676 onClick: closeModal,
8677 disabled: isBusy,
8678 accessibleWhenDisabled: true,
8679 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8680 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8681 __next40pxDefaultSize: true,
8682 variant: "primary",
8683 onClick: async () => {
8684 setIsBusy(true);
8685 const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
8686 throwOnError: true
8687 })));
8688 // If all the promises were fulfilled with success.
8689 if (promiseResult.every(({
8690 status
8691 }) => status === 'fulfilled')) {
8692 let successMessage;
8693 if (promiseResult.length === 1) {
8694 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The item's title. */
8695 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to the trash.'), getItemTitle(items[0]));
8696 } else {
8697 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The number of items. */
8698 (0,external_wp_i18n_namespaceObject._n)('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
8699 }
8700 createSuccessNotice(successMessage, {
8701 type: 'snackbar',
8702 id: 'move-to-trash-action'
8703 });
8704 } else {
8705 // If there was at least one failure.
8706 let errorMessage;
8707 // If we were trying to delete a single item.
8708 if (promiseResult.length === 1) {
8709 const typedError = promiseResult[0];
8710 if (typedError.reason?.message) {
8711 errorMessage = typedError.reason.message;
8712 } else {
8713 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the item to the trash.');
8714 }
8715 // If we were trying to delete multiple items.
8716 } else {
8717 const errorMessages = new Set();
8718 const failedPromises = promiseResult.filter(({
8719 status
8720 }) => status === 'rejected');
8721 for (const failedPromise of failedPromises) {
8722 const typedError = failedPromise;
8723 if (typedError.reason?.message) {
8724 errorMessages.add(typedError.reason.message);
8725 }
8726 }
8727 if (errorMessages.size === 0) {
8728 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the items to the trash.');
8729 } else if (errorMessages.size === 1) {
8730 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8731 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
8732 } else {
8733 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8734 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
8735 }
8736 }
8737 createErrorNotice(errorMessage, {
8738 type: 'snackbar'
8739 });
8740 }
8741 if (onActionPerformed) {
8742 onActionPerformed(items);
8743 }
8744 setIsBusy(false);
8745 closeModal?.();
8746 },
8747 isBusy: isBusy,
8748 disabled: isBusy,
8749 accessibleWhenDisabled: true,
8750 children: (0,external_wp_i18n_namespaceObject._x)('Trash', 'verb')
8751 })]
8752 })]
8753 });
8754 }
8755 };
8756
8757 /**
8758 * Trash action for PostWithPermissions.
8759 */
8760 /* harmony default export */ const trash_post = (trash_post_trashPost);
8761
8762 ;// ./packages/fields/build-module/actions/permanently-delete-post.js
8763 /* wp:polyfill */
8764 /**
8765 * WordPress dependencies
8766 */
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776 /**
8777 * Internal dependencies
8778 */
8779
8780
8781 const permanentlyDeletePost = {
8782 id: 'permanently-delete',
8783 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'),
8784 supportsBulk: true,
8785 icon: library_trash,
8786 isEligible(item) {
8787 if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
8788 return false;
8789 }
8790 const {
8791 status,
8792 permissions
8793 } = item;
8794 return status === 'trash' && permissions?.delete;
8795 },
8796 hideModalHeader: true,
8797 RenderModal: ({
8798 items,
8799 closeModal,
8800 onActionPerformed
8801 }) => {
8802 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
8803 const {
8804 createSuccessNotice,
8805 createErrorNotice
8806 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8807 const {
8808 deleteEntityRecord
8809 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8810 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
8811 spacing: "5",
8812 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8813 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
8814 // translators: %d: number of items to delete.
8815 (0,external_wp_i18n_namespaceObject._n)('Are you sure you want to permanently delete %d item?', 'Are you sure you want to permanently delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
8816 // translators: %s: The post's title
8817 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to permanently delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(items[0])))
8818 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
8819 justify: "right",
8820 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8821 variant: "tertiary",
8822 onClick: closeModal,
8823 disabled: isBusy,
8824 accessibleWhenDisabled: true,
8825 __next40pxDefaultSize: true,
8826 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8827 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8828 variant: "primary",
8829 onClick: async () => {
8830 setIsBusy(true);
8831 const promiseResult = await Promise.allSettled(items.map(post => deleteEntityRecord('postType', post.type, post.id, {
8832 force: true
8833 }, {
8834 throwOnError: true
8835 })));
8836
8837 // If all the promises were fulfilled with success.
8838 if (promiseResult.every(({
8839 status
8840 }) => status === 'fulfilled')) {
8841 let successMessage;
8842 if (promiseResult.length === 1) {
8843 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The posts's title. */
8844 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), getItemTitle(items[0]));
8845 } else {
8846 successMessage = (0,external_wp_i18n_namespaceObject.__)('The items were permanently deleted.');
8847 }
8848 createSuccessNotice(successMessage, {
8849 type: 'snackbar',
8850 id: 'permanently-delete-post-action'
8851 });
8852 onActionPerformed?.(items);
8853 } else {
8854 // If there was at lease one failure.
8855 let errorMessage;
8856 // If we were trying to permanently delete a single post.
8857 if (promiseResult.length === 1) {
8858 const typedError = promiseResult[0];
8859 if (typedError.reason?.message) {
8860 errorMessage = typedError.reason.message;
8861 } else {
8862 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the item.');
8863 }
8864 // If we were trying to permanently delete multiple posts
8865 } else {
8866 const errorMessages = new Set();
8867 const failedPromises = promiseResult.filter(({
8868 status
8869 }) => status === 'rejected');
8870 for (const failedPromise of failedPromises) {
8871 const typedError = failedPromise;
8872 if (typedError.reason?.message) {
8873 errorMessages.add(typedError.reason.message);
8874 }
8875 }
8876 if (errorMessages.size === 0) {
8877 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the items.');
8878 } else if (errorMessages.size === 1) {
8879 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
8880 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the items: %s'), [...errorMessages][0]);
8881 } else {
8882 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
8883 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the items: %s'), [...errorMessages].join(','));
8884 }
8885 }
8886 createErrorNotice(errorMessage, {
8887 type: 'snackbar'
8888 });
8889 }
8890 setIsBusy(false);
8891 closeModal?.();
8892 },
8893 isBusy: isBusy,
8894 disabled: isBusy,
8895 accessibleWhenDisabled: true,
8896 __next40pxDefaultSize: true,
8897 children: (0,external_wp_i18n_namespaceObject.__)('Delete permanently')
8898 })]
8899 })]
8900 });
8901 }
8902 };
8903
8904 /**
8905 * Delete action for PostWithPermissions.
8906 */
8907 /* harmony default export */ const permanently_delete_post = (permanentlyDeletePost);
8908
8909 ;// external ["wp","mediaUtils"]
8910 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
8911 ;// ./packages/icons/build-module/library/line-solid.js
8912 /**
8913 * WordPress dependencies
8914 */
8915
8916
8917 const lineSolid = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8918 xmlns: "http://www.w3.org/2000/svg",
8919 viewBox: "0 0 24 24",
8920 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8921 d: "M5 11.25h14v1.5H5z"
8922 })
8923 });
8924 /* harmony default export */ const line_solid = (lineSolid);
8925
8926 ;// ./packages/fields/build-module/fields/featured-image/featured-image-edit.js
8927 /**
8928 * WordPress dependencies
8929 */
8930
8931
8932
8933 // @ts-ignore
8934
8935
8936
8937
8938
8939 /**
8940 * Internal dependencies
8941 */
8942
8943 const FeaturedImageEdit = ({
8944 data,
8945 field,
8946 onChange
8947 }) => {
8948 const {
8949 id
8950 } = field;
8951 const value = field.getValue({
8952 item: data
8953 });
8954 const media = (0,external_wp_data_namespaceObject.useSelect)(select => {
8955 const {
8956 getEntityRecord
8957 } = select(external_wp_coreData_namespaceObject.store);
8958 return getEntityRecord('root', 'media', value);
8959 }, [value]);
8960 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
8961 [id]: newValue
8962 }), [id, onChange]);
8963 const url = media?.source_url;
8964 const title = media?.title?.rendered;
8965 const ref = (0,external_wp_element_namespaceObject.useRef)(null);
8966 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("fieldset", {
8967 className: "fields-controls__featured-image",
8968 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8969 className: "fields-controls__featured-image-container",
8970 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_mediaUtils_namespaceObject.MediaUpload, {
8971 onSelect: selectedMedia => {
8972 onChangeControl(selectedMedia.id);
8973 },
8974 allowedTypes: ['image'],
8975 render: ({
8976 open
8977 }) => {
8978 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8979 ref: ref,
8980 role: "button",
8981 tabIndex: -1,
8982 onClick: () => {
8983 open();
8984 },
8985 onKeyDown: open,
8986 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalGrid, {
8987 rowGap: 0,
8988 columnGap: 8,
8989 templateColumns: "24px 1fr 24px",
8990 children: [url && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8991 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
8992 className: "fields-controls__featured-image-image",
8993 alt: "",
8994 width: 24,
8995 height: 24,
8996 src: url
8997 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8998 className: "fields-controls__featured-image-title",
8999 children: title
9000 })]
9001 }), !url && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9002 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9003 className: "fields-controls__featured-image-placeholder",
9004 style: {
9005 width: '24px',
9006 height: '24px'
9007 }
9008 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9009 className: "fields-controls__featured-image-title",
9010 children: (0,external_wp_i18n_namespaceObject.__)('Choose an image…')
9011 })]
9012 }), url && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9013 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9014 size: "small",
9015 className: "fields-controls__featured-image-remove-button",
9016 icon: line_solid,
9017 onClick: event => {
9018 event.stopPropagation();
9019 onChangeControl(0);
9020 }
9021 })
9022 })]
9023 })
9024 });
9025 }
9026 })
9027 })
9028 });
9029 };
9030
9031 ;// ./packages/fields/build-module/fields/featured-image/featured-image-view.js
9032 /**
9033 * WordPress dependencies
9034 */
9035
9036
9037
9038 /**
9039 * Internal dependencies
9040 */
9041
9042 const FeaturedImageView = ({
9043 item
9044 }) => {
9045 const mediaId = item.featured_media;
9046 const media = (0,external_wp_data_namespaceObject.useSelect)(select => {
9047 const {
9048 getEntityRecord
9049 } = select(external_wp_coreData_namespaceObject.store);
9050 return mediaId ? getEntityRecord('root', 'media', mediaId) : null;
9051 }, [mediaId]);
9052 const url = media?.source_url;
9053 if (url) {
9054 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
9055 className: "fields-controls__featured-image-image",
9056 src: url,
9057 alt: ""
9058 });
9059 }
9060 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9061 className: "fields-controls__featured-image-placeholder"
9062 });
9063 };
9064
9065 ;// ./packages/fields/build-module/fields/featured-image/index.js
9066 /**
9067 * WordPress dependencies
9068 */
9069
9070
9071
9072 /**
9073 * Internal dependencies
9074 */
9075
9076
9077
9078 const featuredImageField = {
9079 id: 'featured_media',
9080 type: 'text',
9081 label: (0,external_wp_i18n_namespaceObject.__)('Featured Image'),
9082 Edit: FeaturedImageEdit,
9083 render: FeaturedImageView,
9084 enableSorting: false
9085 };
9086
9087 /**
9088 * Featured Image field for BasePost.
9089 */
9090 /* harmony default export */ const featured_image = (featuredImageField);
9091
9092 ;// ./packages/icons/build-module/library/comment-author-avatar.js
9093 /**
9094 * WordPress dependencies
9095 */
9096
9097
9098 const commentAuthorAvatar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9099 xmlns: "http://www.w3.org/2000/svg",
9100 viewBox: "0 0 24 24",
9101 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9102 fillRule: "evenodd",
9103 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",
9104 clipRule: "evenodd"
9105 })
9106 });
9107 /* harmony default export */ const comment_author_avatar = (commentAuthorAvatar);
9108
9109 ;// ./packages/fields/build-module/fields/author/author-view.js
9110 /**
9111 * External dependencies
9112 */
9113
9114
9115 /**
9116 * WordPress dependencies
9117 */
9118
9119
9120
9121
9122
9123
9124
9125 /**
9126 * Internal dependencies
9127 */
9128
9129 function AuthorView({
9130 item
9131 }) {
9132 const {
9133 text,
9134 imageUrl
9135 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9136 const {
9137 getEntityRecord
9138 } = select(external_wp_coreData_namespaceObject.store);
9139 let user;
9140 if (!!item.author) {
9141 user = getEntityRecord('root', 'user', item.author);
9142 }
9143 return {
9144 imageUrl: user?.avatar_urls?.[48],
9145 text: user?.name
9146 };
9147 }, [item]);
9148 const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false);
9149 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9150 alignment: "left",
9151 spacing: 0,
9152 children: [!!imageUrl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9153 className: dist_clsx('page-templates-author-field__avatar', {
9154 'is-loaded': isImageLoaded
9155 }),
9156 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
9157 onLoad: () => setIsImageLoaded(true),
9158 alt: (0,external_wp_i18n_namespaceObject.__)('Author avatar'),
9159 src: imageUrl
9160 })
9161 }), !imageUrl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9162 className: "page-templates-author-field__icon",
9163 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
9164 icon: comment_author_avatar
9165 })
9166 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9167 className: "page-templates-author-field__name",
9168 children: text
9169 })]
9170 });
9171 }
9172 /* harmony default export */ const author_view = (AuthorView);
9173
9174 ;// ./packages/fields/build-module/fields/author/index.js
9175 /**
9176 * WordPress dependencies
9177 */
9178
9179
9180
9181 /**
9182 * Internal dependencies
9183 */
9184
9185
9186 const authorField = {
9187 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
9188 id: 'author',
9189 type: 'integer',
9190 elements: [],
9191 render: author_view,
9192 sort: (a, b, direction) => {
9193 const nameA = a._embedded?.author?.[0]?.name || '';
9194 const nameB = b._embedded?.author?.[0]?.name || '';
9195 return direction === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
9196 }
9197 };
9198
9199 /**
9200 * Author field for BasePost.
9201 */
9202 /* harmony default export */ const author = (authorField);
9203
9204 ;// ./packages/icons/build-module/library/drafts.js
9205 /**
9206 * WordPress dependencies
9207 */
9208
9209
9210 const drafts = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9211 xmlns: "http://www.w3.org/2000/svg",
9212 viewBox: "0 0 24 24",
9213 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9214 fillRule: "evenodd",
9215 clipRule: "evenodd",
9216 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z"
9217 })
9218 });
9219 /* harmony default export */ const library_drafts = (drafts);
9220
9221 ;// ./packages/icons/build-module/library/scheduled.js
9222 /**
9223 * WordPress dependencies
9224 */
9225
9226
9227 const scheduled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9228 xmlns: "http://www.w3.org/2000/svg",
9229 viewBox: "0 0 24 24",
9230 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9231 fillRule: "evenodd",
9232 clipRule: "evenodd",
9233 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z"
9234 })
9235 });
9236 /* harmony default export */ const library_scheduled = (scheduled);
9237
9238 ;// ./packages/icons/build-module/library/pending.js
9239 /**
9240 * WordPress dependencies
9241 */
9242
9243
9244 const pending = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9245 xmlns: "http://www.w3.org/2000/svg",
9246 viewBox: "0 0 24 24",
9247 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9248 fillRule: "evenodd",
9249 clipRule: "evenodd",
9250 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 1-4-4h4V8a4 4 0 0 1 0 8Z"
9251 })
9252 });
9253 /* harmony default export */ const library_pending = (pending);
9254
9255 ;// ./packages/icons/build-module/library/not-allowed.js
9256 /**
9257 * WordPress dependencies
9258 */
9259
9260
9261 const notAllowed = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9262 xmlns: "http://www.w3.org/2000/svg",
9263 viewBox: "0 0 24 24",
9264 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9265 fillRule: "evenodd",
9266 clipRule: "evenodd",
9267 d: "M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z"
9268 })
9269 });
9270 /* harmony default export */ const not_allowed = (notAllowed);
9271
9272 ;// ./packages/icons/build-module/library/published.js
9273 /**
9274 * WordPress dependencies
9275 */
9276
9277
9278 const published = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9279 xmlns: "http://www.w3.org/2000/svg",
9280 viewBox: "0 0 24 24",
9281 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9282 fillRule: "evenodd",
9283 clipRule: "evenodd",
9284 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z"
9285 })
9286 });
9287 /* harmony default export */ const library_published = (published);
9288
9289 ;// ./packages/fields/build-module/fields/status/status-elements.js
9290 /**
9291 * WordPress dependencies
9292 */
9293
9294
9295
9296 // See https://github.com/WordPress/gutenberg/issues/55886
9297 // We do not support custom statutes at the moment.
9298 const STATUSES = [{
9299 value: 'draft',
9300 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
9301 icon: library_drafts,
9302 description: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
9303 }, {
9304 value: 'future',
9305 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
9306 icon: library_scheduled,
9307 description: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
9308 }, {
9309 value: 'pending',
9310 label: (0,external_wp_i18n_namespaceObject.__)('Pending Review'),
9311 icon: library_pending,
9312 description: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
9313 }, {
9314 value: 'private',
9315 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
9316 icon: not_allowed,
9317 description: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
9318 }, {
9319 value: 'publish',
9320 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
9321 icon: library_published,
9322 description: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
9323 }, {
9324 value: 'trash',
9325 label: (0,external_wp_i18n_namespaceObject.__)('Trash'),
9326 icon: library_trash
9327 }];
9328 /* harmony default export */ const status_elements = (STATUSES);
9329
9330 ;// ./packages/fields/build-module/fields/status/status-view.js
9331 /* wp:polyfill */
9332 /**
9333 * WordPress dependencies
9334 */
9335
9336
9337 /**
9338 * Internal dependencies
9339 */
9340
9341
9342
9343 function StatusView({
9344 item
9345 }) {
9346 const status = status_elements.find(({
9347 value
9348 }) => value === item.status);
9349 const label = status?.label || item.status;
9350 const icon = status?.icon;
9351 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9352 alignment: "left",
9353 spacing: 0,
9354 children: [icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9355 className: "edit-site-post-list__status-icon",
9356 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
9357 icon: icon
9358 })
9359 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9360 children: label
9361 })]
9362 });
9363 }
9364 /* harmony default export */ const status_view = (StatusView);
9365
9366 ;// ./packages/fields/build-module/fields/status/index.js
9367 /**
9368 * WordPress dependencies
9369 */
9370
9371
9372
9373 /**
9374 * Internal dependencies
9375 */
9376
9377
9378
9379 const OPERATOR_IS_ANY = 'isAny';
9380 const statusField = {
9381 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
9382 id: 'status',
9383 type: 'text',
9384 elements: status_elements,
9385 render: status_view,
9386 Edit: 'radio',
9387 enableSorting: false,
9388 filterBy: {
9389 operators: [OPERATOR_IS_ANY]
9390 }
9391 };
9392
9393 /**
9394 * Status field for BasePost.
9395 */
9396 /* harmony default export */ const fields_status = (statusField);
9397
9398 ;// ./packages/fields/build-module/fields/date/date-view.js
9399 /**
9400 * WordPress dependencies
9401 */
9402
9403
9404
9405
9406 /**
9407 * Internal dependencies
9408 */
9409
9410 const getFormattedDate = dateToDisplay => (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_date_namespaceObject.getSettings)().formats.datetimeAbbreviated, (0,external_wp_date_namespaceObject.getDate)(dateToDisplay));
9411 const DateView = ({
9412 item
9413 }) => {
9414 var _item$status, _item$modified, _item$date4, _item$date5;
9415 const isDraftOrPrivate = ['draft', 'private'].includes((_item$status = item.status) !== null && _item$status !== void 0 ? _item$status : '');
9416 if (isDraftOrPrivate) {
9417 var _item$date;
9418 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: page creation or modification date. */
9419 (0,external_wp_i18n_namespaceObject.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate((_item$date = item.date) !== null && _item$date !== void 0 ? _item$date : null)), {
9420 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {}),
9421 time: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {})
9422 });
9423 }
9424 const isScheduled = item.status === 'future';
9425 if (isScheduled) {
9426 var _item$date2;
9427 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: page creation date */
9428 (0,external_wp_i18n_namespaceObject.__)('<span>Scheduled: <time>%s</time></span>'), getFormattedDate((_item$date2 = item.date) !== null && _item$date2 !== void 0 ? _item$date2 : null)), {
9429 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {}),
9430 time: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {})
9431 });
9432 }
9433 const isPublished = item.status === 'publish';
9434 if (isPublished) {
9435 var _item$date3;
9436 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: page creation time */
9437 (0,external_wp_i18n_namespaceObject.__)('<span>Published: <time>%s</time></span>'), getFormattedDate((_item$date3 = item.date) !== null && _item$date3 !== void 0 ? _item$date3 : null)), {
9438 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {}),
9439 time: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {})
9440 });
9441 }
9442
9443 // Pending posts show the modified date if it's newer.
9444 const dateToDisplay = (0,external_wp_date_namespaceObject.getDate)((_item$modified = item.modified) !== null && _item$modified !== void 0 ? _item$modified : null) > (0,external_wp_date_namespaceObject.getDate)((_item$date4 = item.date) !== null && _item$date4 !== void 0 ? _item$date4 : null) ? item.modified : item.date;
9445 const isPending = item.status === 'pending';
9446 if (isPending) {
9447 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: page creation or modification date. */
9448 (0,external_wp_i18n_namespaceObject.__)('<span>Modified: <time>%s</time></span>'), getFormattedDate(dateToDisplay !== null && dateToDisplay !== void 0 ? dateToDisplay : null)), {
9449 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {}),
9450 time: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {})
9451 });
9452 }
9453
9454 // Unknow status.
9455 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {
9456 children: getFormattedDate((_item$date5 = item.date) !== null && _item$date5 !== void 0 ? _item$date5 : null)
9457 });
9458 };
9459 /* harmony default export */ const date_view = (DateView);
9460
9461 ;// ./packages/fields/build-module/fields/date/index.js
9462 /**
9463 * WordPress dependencies
9464 */
9465
9466
9467
9468 /**
9469 * Internal dependencies
9470 */
9471
9472
9473 const dateField = {
9474 id: 'date',
9475 type: 'datetime',
9476 label: (0,external_wp_i18n_namespaceObject.__)('Date'),
9477 render: date_view
9478 };
9479
9480 /**
9481 * Date field for BasePost.
9482 */
9483 /* harmony default export */ const date = (dateField);
9484
9485 ;// ./packages/icons/build-module/library/copy-small.js
9486 /**
9487 * WordPress dependencies
9488 */
9489
9490
9491 const copySmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9492 xmlns: "http://www.w3.org/2000/svg",
9493 viewBox: "0 0 24 24",
9494 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9495 fillRule: "evenodd",
9496 clipRule: "evenodd",
9497 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"
9498 })
9499 });
9500 /* harmony default export */ const copy_small = (copySmall);
9501
9502 ;// ./packages/fields/build-module/fields/slug/utils.js
9503 /**
9504 * WordPress dependencies
9505 */
9506
9507 /**
9508 * Internal dependencies
9509 */
9510
9511
9512 const getSlug = item => {
9513 if (typeof item !== 'object') {
9514 return '';
9515 }
9516 return item.slug || (0,external_wp_url_namespaceObject.cleanForSlug)(getItemTitle(item)) || item.id.toString();
9517 };
9518
9519 ;// ./packages/fields/build-module/fields/slug/slug-edit.js
9520 /**
9521 * WordPress dependencies
9522 */
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532 /**
9533 * Internal dependencies
9534 */
9535
9536
9537
9538 const SlugEdit = ({
9539 field,
9540 onChange,
9541 data
9542 }) => {
9543 const {
9544 id
9545 } = field;
9546 const slug = field.getValue({
9547 item: data
9548 }) || getSlug(data);
9549 const permalinkTemplate = data.permalink_template || '';
9550 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
9551 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
9552 const permalinkPrefix = prefix;
9553 const permalinkSuffix = suffix;
9554 const isEditable = PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
9555 const originalSlugRef = (0,external_wp_element_namespaceObject.useRef)(slug);
9556 const slugToDisplay = slug || originalSlugRef.current;
9557 const permalink = isEditable ? `${permalinkPrefix}${slugToDisplay}${permalinkSuffix}` : (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(data.link || '');
9558 (0,external_wp_element_namespaceObject.useEffect)(() => {
9559 if (slug && originalSlugRef.current === undefined) {
9560 originalSlugRef.current = slug;
9561 }
9562 }, [slug]);
9563 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
9564 [id]: newValue
9565 }), [id, onChange]);
9566 const {
9567 createNotice
9568 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
9569 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
9570 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied Permalink to clipboard.'), {
9571 isDismissible: true,
9572 type: 'snackbar'
9573 });
9574 });
9575 const postUrlSlugDescriptionId = 'editor-post-url__slug-description-' + (0,external_wp_compose_namespaceObject.useInstanceId)(SlugEdit);
9576 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
9577 className: "fields-controls__slug",
9578 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
9579 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
9580 spacing: "0px",
9581 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9582 children: (0,external_wp_i18n_namespaceObject.__)('Customize the last part of the Permalink.')
9583 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
9584 href: "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink",
9585 children: (0,external_wp_i18n_namespaceObject.__)('Learn more')
9586 })]
9587 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
9588 __next40pxDefaultSize: true,
9589 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
9590 children: "/"
9591 }),
9592 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9593 __next40pxDefaultSize: true,
9594 icon: copy_small,
9595 ref: copyButtonRef,
9596 label: (0,external_wp_i18n_namespaceObject.__)('Copy')
9597 }),
9598 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
9599 hideLabelFromVision: true,
9600 value: slug,
9601 autoComplete: "off",
9602 spellCheck: "false",
9603 type: "text",
9604 className: "fields-controls__slug-input",
9605 onChange: newValue => {
9606 onChangeControl(newValue);
9607 },
9608 onBlur: () => {
9609 if (slug === '') {
9610 onChangeControl(originalSlugRef.current);
9611 }
9612 },
9613 "aria-describedby": postUrlSlugDescriptionId
9614 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9615 className: "fields-controls__slug-help",
9616 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9617 className: "fields-controls__slug-help-visual-label",
9618 children: (0,external_wp_i18n_namespaceObject.__)('Permalink:')
9619 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
9620 className: "fields-controls__slug-help-link",
9621 href: permalink,
9622 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9623 className: "fields-controls__slug-help-prefix",
9624 children: permalinkPrefix
9625 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9626 className: "fields-controls__slug-help-slug",
9627 children: slugToDisplay
9628 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
9629 className: "fields-controls__slug-help-suffix",
9630 children: permalinkSuffix
9631 })]
9632 })]
9633 })]
9634 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
9635 className: "fields-controls__slug-help",
9636 href: permalink,
9637 children: permalink
9638 })]
9639 });
9640 };
9641 /* harmony default export */ const slug_edit = (SlugEdit);
9642
9643 ;// ./packages/fields/build-module/fields/slug/slug-view.js
9644 /**
9645 * WordPress dependencies
9646 */
9647
9648
9649 /**
9650 * Internal dependencies
9651 */
9652
9653
9654 const SlugView = ({
9655 item
9656 }) => {
9657 const slug = getSlug(item);
9658 const originalSlugRef = (0,external_wp_element_namespaceObject.useRef)(slug);
9659 (0,external_wp_element_namespaceObject.useEffect)(() => {
9660 if (slug && originalSlugRef.current === undefined) {
9661 originalSlugRef.current = slug;
9662 }
9663 }, [slug]);
9664 const slugToDisplay = slug || originalSlugRef.current;
9665 return `${slugToDisplay}`;
9666 };
9667 /* harmony default export */ const slug_view = (SlugView);
9668
9669 ;// ./packages/fields/build-module/fields/slug/index.js
9670 /**
9671 * WordPress dependencies
9672 */
9673
9674
9675
9676 /**
9677 * Internal dependencies
9678 */
9679
9680
9681
9682 const slugField = {
9683 id: 'slug',
9684 type: 'text',
9685 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
9686 Edit: slug_edit,
9687 render: slug_view
9688 };
9689
9690 /**
9691 * Slug field for BasePost.
9692 */
9693 /* harmony default export */ const slug = (slugField);
9694
9695 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
9696 var remove_accents = __webpack_require__(9681);
9697 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
9698 ;// ./packages/fields/build-module/fields/parent/utils.js
9699 /**
9700 * WordPress dependencies
9701 */
9702
9703
9704
9705 /**
9706 * Internal dependencies
9707 */
9708
9709 function getTitleWithFallbackName(post) {
9710 return typeof post.title === 'object' && 'rendered' in post.title && post.title.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post?.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
9711 }
9712
9713 ;// ./packages/fields/build-module/fields/parent/parent-edit.js
9714 /* wp:polyfill */
9715 /**
9716 * External dependencies
9717 */
9718
9719
9720 /**
9721 * WordPress dependencies
9722 */
9723
9724
9725
9726 // @ts-ignore
9727
9728
9729
9730
9731
9732
9733 /**
9734 * Internal dependencies
9735 */
9736
9737
9738
9739 function buildTermsTree(flatTerms) {
9740 const flatTermsWithParentAndChildren = flatTerms.map(term => {
9741 return {
9742 children: [],
9743 ...term
9744 };
9745 });
9746
9747 // All terms should have a `parent` because we're about to index them by it.
9748 if (flatTermsWithParentAndChildren.some(({
9749 parent
9750 }) => parent === null || parent === undefined)) {
9751 return flatTermsWithParentAndChildren;
9752 }
9753 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
9754 const {
9755 parent
9756 } = term;
9757 if (!acc[parent]) {
9758 acc[parent] = [];
9759 }
9760 acc[parent].push(term);
9761 return acc;
9762 }, {});
9763 const fillWithChildren = terms => {
9764 return terms.map(term => {
9765 const children = termsByParent[term.id];
9766 return {
9767 ...term,
9768 children: children && children.length ? fillWithChildren(children) : []
9769 };
9770 });
9771 };
9772 return fillWithChildren(termsByParent['0'] || []);
9773 }
9774 const getItemPriority = (name, searchValue) => {
9775 const normalizedName = remove_accents_default()(name || '').toLowerCase();
9776 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
9777 if (normalizedName === normalizedSearch) {
9778 return 0;
9779 }
9780 if (normalizedName.startsWith(normalizedSearch)) {
9781 return normalizedName.length;
9782 }
9783 return Infinity;
9784 };
9785 function PageAttributesParent({
9786 data,
9787 onChangeControl
9788 }) {
9789 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(null);
9790 const pageId = data.parent;
9791 const postId = data.id;
9792 const postTypeSlug = data.type;
9793 const {
9794 parentPostTitle,
9795 pageItems,
9796 isHierarchical
9797 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9798 // @ts-expect-error getPostType is not typed
9799 const {
9800 getEntityRecord,
9801 getEntityRecords,
9802 getPostType
9803 } = select(external_wp_coreData_namespaceObject.store);
9804 const postTypeInfo = getPostType(postTypeSlug);
9805 const postIsHierarchical = postTypeInfo?.hierarchical && postTypeInfo.viewable;
9806 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
9807 const query = {
9808 per_page: 100,
9809 exclude: postId,
9810 parent_exclude: postId,
9811 orderby: 'menu_order',
9812 order: 'asc',
9813 _fields: 'id,title,parent',
9814 ...(fieldValue !== null && {
9815 search: fieldValue
9816 })
9817 };
9818 return {
9819 isHierarchical: postIsHierarchical,
9820 parentPostTitle: parentPost ? getTitleWithFallbackName(parentPost) : '',
9821 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
9822 };
9823 }, [fieldValue, pageId, postId, postTypeSlug]);
9824
9825 /**
9826 * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.
9827 */
9828 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
9829 const getOptionsFromTree = (tree, level = 0) => {
9830 const mappedNodes = tree.map(treeNode => [{
9831 value: treeNode.id,
9832 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
9833 rawName: treeNode.name
9834 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
9835 const sortedNodes = mappedNodes.sort(([a], [b]) => {
9836 const priorityA = getItemPriority(a.rawName, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
9837 const priorityB = getItemPriority(b.rawName, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
9838 return priorityA >= priorityB ? 1 : -1;
9839 });
9840 return sortedNodes.flat();
9841 };
9842 if (!pageItems) {
9843 return [];
9844 }
9845 let tree = pageItems.map(item => {
9846 var _item$parent;
9847 return {
9848 id: item.id,
9849 parent: (_item$parent = item.parent) !== null && _item$parent !== void 0 ? _item$parent : null,
9850 name: getTitleWithFallbackName(item)
9851 };
9852 });
9853
9854 // Only build a hierarchical tree when not searching.
9855 if (!fieldValue) {
9856 tree = buildTermsTree(tree);
9857 }
9858 const opts = getOptionsFromTree(tree);
9859
9860 // Ensure the current parent is in the options list.
9861 const optsHasParent = opts.find(item => item.value === pageId);
9862 if (pageId && parentPostTitle && !optsHasParent) {
9863 opts.unshift({
9864 value: pageId,
9865 label: parentPostTitle,
9866 rawName: ''
9867 });
9868 }
9869 return opts.map(option => ({
9870 ...option,
9871 value: option.value.toString()
9872 }));
9873 }, [pageItems, fieldValue, parentPostTitle, pageId]);
9874 if (!isHierarchical) {
9875 return null;
9876 }
9877
9878 /**
9879 * Handle user input.
9880 *
9881 * @param {string} inputValue The current value of the input field.
9882 */
9883 const handleKeydown = inputValue => {
9884 setFieldValue(inputValue);
9885 };
9886
9887 /**
9888 * Handle author selection.
9889 *
9890 * @param {Object} selectedPostId The selected Author.
9891 */
9892 const handleChange = selectedPostId => {
9893 if (selectedPostId) {
9894 var _parseInt;
9895 return onChangeControl((_parseInt = parseInt(selectedPostId, 10)) !== null && _parseInt !== void 0 ? _parseInt : 0);
9896 }
9897 onChangeControl(0);
9898 };
9899 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
9900 __nextHasNoMarginBottom: true,
9901 __next40pxDefaultSize: true,
9902 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
9903 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
9904 value: pageId?.toString(),
9905 options: parentOptions,
9906 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(value => handleKeydown(value), 300),
9907 onChange: handleChange,
9908 hideLabelFromVision: true
9909 });
9910 }
9911 const ParentEdit = ({
9912 data,
9913 field,
9914 onChange
9915 }) => {
9916 const {
9917 id
9918 } = field;
9919 const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => {
9920 // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
9921 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.home;
9922 }, []);
9923 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
9924 [id]: newValue
9925 }), [id, onChange]);
9926 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("fieldset", {
9927 className: "fields-controls__parent",
9928 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9929 children: [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %1$s The home URL of the WordPress installation without the scheme. */
9930 (0,external_wp_i18n_namespaceObject.__)('Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %1$s<wbr />/services<wbr />/pricing.'), (0,external_wp_url_namespaceObject.filterURLForDisplay)(homeUrl).replace(/([/.])/g, '<wbr />$1')), {
9931 wbr: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("wbr", {})
9932 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
9933 children: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'), {
9934 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
9935 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'),
9936 children: undefined
9937 })
9938 })
9939 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesParent, {
9940 data: data,
9941 onChangeControl: onChangeControl
9942 })]
9943 })
9944 });
9945 };
9946
9947 ;// ./packages/fields/build-module/fields/parent/parent-view.js
9948 /**
9949 * WordPress dependencies
9950 */
9951
9952
9953
9954
9955 /**
9956 * Internal dependencies
9957 */
9958
9959
9960
9961 const ParentView = ({
9962 item
9963 }) => {
9964 const parent = (0,external_wp_data_namespaceObject.useSelect)(select => {
9965 const {
9966 getEntityRecord
9967 } = select(external_wp_coreData_namespaceObject.store);
9968 return item?.parent ? getEntityRecord('postType', item.type, item.parent) : null;
9969 }, [item.parent, item.type]);
9970 if (parent) {
9971 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9972 children: getTitleWithFallbackName(parent)
9973 });
9974 }
9975 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
9976 children: (0,external_wp_i18n_namespaceObject.__)('None')
9977 });
9978 };
9979
9980 ;// ./packages/fields/build-module/fields/parent/index.js
9981 /**
9982 * WordPress dependencies
9983 */
9984
9985
9986
9987 /**
9988 * Internal dependencies
9989 */
9990
9991
9992
9993 const parentField = {
9994 id: 'parent',
9995 type: 'text',
9996 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
9997 Edit: ParentEdit,
9998 render: ParentView,
9999 enableSorting: true
10000 };
10001
10002 /**
10003 * Parent field for BasePost.
10004 */
10005 /* harmony default export */ const fields_parent = (parentField);
10006
10007 ;// ./packages/fields/build-module/fields/comment-status/index.js
10008 /**
10009 * WordPress dependencies
10010 */
10011
10012
10013
10014 /**
10015 * Internal dependencies
10016 */
10017
10018 const commentStatusField = {
10019 id: 'comment_status',
10020 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
10021 type: 'text',
10022 Edit: 'radio',
10023 enableSorting: false,
10024 filterBy: {
10025 operators: []
10026 },
10027 elements: [{
10028 value: 'open',
10029 label: (0,external_wp_i18n_namespaceObject.__)('Open'),
10030 description: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
10031 }, {
10032 value: 'closed',
10033 label: (0,external_wp_i18n_namespaceObject.__)('Closed'),
10034 description: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies. Existing comments remain visible.')
10035 }]
10036 };
10037
10038 /**
10039 * Comment status field for BasePost.
10040 */
10041 /* harmony default export */ const comment_status = (commentStatusField);
10042
10043 ;// ./packages/fields/build-module/fields/template/template-edit.js
10044 /* wp:polyfill */
10045 /**
10046 * WordPress dependencies
10047 */
10048
10049 // @ts-ignore
10050
10051
10052 /**
10053 * Internal dependencies
10054 */
10055 // @ts-expect-error block-editor is not typed correctly.
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065 const TemplateEdit = ({
10066 data,
10067 field,
10068 onChange
10069 }) => {
10070 const {
10071 id
10072 } = field;
10073 const postType = data.type;
10074 const postId = typeof data.id === 'number' ? data.id : parseInt(data.id, 10);
10075 const slug = data.slug;
10076 const {
10077 availableTemplates,
10078 templates
10079 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10080 var _select$getEntityReco;
10081 const allTemplates = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
10082 per_page: -1,
10083 post_type: postType
10084 })) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : [];
10085 const {
10086 getHomePage,
10087 getPostsPageId
10088 } = lock_unlock_unlock(select(external_wp_coreData_namespaceObject.store));
10089 const isPostsPage = getPostsPageId() === +postId;
10090 const isFrontPage = postType === 'page' && getHomePage()?.postId === +postId;
10091 const allowSwitchingTemplate = !isPostsPage && !isFrontPage;
10092 return {
10093 templates: allTemplates,
10094 availableTemplates: allowSwitchingTemplate ? allTemplates.filter(template => template.is_custom && template.slug !== data.template && !!template.content.raw // Skip empty templates.
10095 ) : []
10096 };
10097 }, [data.template, postId, postType]);
10098 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
10099 name: template.slug,
10100 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
10101 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
10102 id: template.id
10103 })), [availableTemplates]);
10104 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns);
10105 const value = field.getValue({
10106 item: data
10107 });
10108 const currentTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
10109 const foundTemplate = templates?.find(template => template.slug === value);
10110 if (foundTemplate) {
10111 return foundTemplate;
10112 }
10113 let slugToCheck;
10114 // In `draft` status we might not have a slug available, so we use the `single`
10115 // post type templates slug(ex page, single-post, single-product etc..).
10116 // Pages do not need the `single` prefix in the slug to be prioritized
10117 // through template hierarchy.
10118 if (slug) {
10119 slugToCheck = postType === 'page' ? `${postType}-${slug}` : `single-${postType}-${slug}`;
10120 } else {
10121 slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
10122 }
10123 if (postType) {
10124 const templateId = select(external_wp_coreData_namespaceObject.store).getDefaultTemplateId({
10125 slug: slugToCheck
10126 });
10127 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
10128 }
10129 }, [postType, slug, templates, value]);
10130 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
10131 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange({
10132 [id]: newValue
10133 }), [id, onChange]);
10134 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
10135 className: "fields-controls__template",
10136 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10137 popoverProps: {
10138 placement: 'bottom-start'
10139 },
10140 renderToggle: ({
10141 onToggle
10142 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10143 __next40pxDefaultSize: true,
10144 variant: "tertiary",
10145 size: "compact",
10146 onClick: onToggle,
10147 children: currentTemplate ? getItemTitle(currentTemplate) : ''
10148 }),
10149 renderContent: ({
10150 onToggle
10151 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
10152 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10153 onClick: () => {
10154 setShowModal(true);
10155 onToggle();
10156 },
10157 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
10158 }),
10159 // The default template in a post is indicated by an empty string
10160 value !== '' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10161 onClick: () => {
10162 onChangeControl('');
10163 onToggle();
10164 },
10165 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
10166 })]
10167 })
10168 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
10169 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
10170 onRequestClose: () => setShowModal(false),
10171 overlayClassName: "fields-controls__template-modal",
10172 isFullScreen: true,
10173 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10174 className: "fields-controls__template-content",
10175 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
10176 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
10177 blockPatterns: templatesAsPatterns,
10178 shownPatterns: shownTemplates,
10179 onClickPattern: template => {
10180 onChangeControl(template.name);
10181 setShowModal(false);
10182 }
10183 })
10184 })
10185 })]
10186 });
10187 };
10188
10189 ;// ./packages/fields/build-module/fields/template/index.js
10190 /**
10191 * WordPress dependencies
10192 */
10193
10194 /**
10195 * Internal dependencies
10196 */
10197
10198
10199 const templateField = {
10200 id: 'template',
10201 type: 'text',
10202 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
10203 Edit: TemplateEdit,
10204 enableSorting: false
10205 };
10206
10207 /**
10208 * Template field for BasePost.
10209 */
10210 /* harmony default export */ const fields_template = (templateField);
10211
10212 ;// ./packages/fields/build-module/fields/password/edit.js
10213 /**
10214 * WordPress dependencies
10215 */
10216
10217
10218
10219
10220 /**
10221 * Internal dependencies
10222 */
10223
10224 function PasswordEdit({
10225 data,
10226 onChange,
10227 field
10228 }) {
10229 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!field.getValue({
10230 item: data
10231 }));
10232 const handleTogglePassword = value => {
10233 setShowPassword(value);
10234 if (!value) {
10235 onChange({
10236 password: ''
10237 });
10238 }
10239 };
10240 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
10241 as: "fieldset",
10242 spacing: 4,
10243 className: "fields-controls__password",
10244 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
10245 __nextHasNoMarginBottom: true,
10246 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
10247 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
10248 checked: showPassword,
10249 onChange: handleTogglePassword
10250 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10251 className: "fields-controls__password-input",
10252 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
10253 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
10254 onChange: value => onChange({
10255 password: value
10256 }),
10257 value: field.getValue({
10258 item: data
10259 }) || '',
10260 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
10261 type: "text",
10262 __next40pxDefaultSize: true,
10263 __nextHasNoMarginBottom: true,
10264 maxLength: 255
10265 })
10266 })]
10267 });
10268 }
10269 /* harmony default export */ const edit = (PasswordEdit);
10270
10271 ;// ./packages/fields/build-module/fields/password/index.js
10272 /**
10273 * WordPress dependencies
10274 */
10275
10276 /**
10277 * Internal dependencies
10278 */
10279
10280
10281 const passwordField = {
10282 id: 'password',
10283 type: 'text',
10284 Edit: edit,
10285 enableSorting: false,
10286 enableHiding: false,
10287 isVisible: item => item.status !== 'private'
10288 };
10289
10290 /**
10291 * Password field for BasePost.
10292 */
10293 /* harmony default export */ const fields_password = (passwordField);
10294
10295 ;// ./packages/fields/build-module/fields/page-title/view.js
10296 /**
10297 * WordPress dependencies
10298 */
10299
10300
10301
10302
10303
10304 /**
10305 * Internal dependencies
10306 */
10307
10308
10309
10310
10311 const {
10312 Badge
10313 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis);
10314 function PageTitleView({
10315 item
10316 }) {
10317 const {
10318 frontPageId,
10319 postsPageId
10320 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10321 const {
10322 getEntityRecord
10323 } = select(external_wp_coreData_namespaceObject.store);
10324 const siteSettings = getEntityRecord('root', 'site');
10325 return {
10326 frontPageId: siteSettings?.page_on_front,
10327 postsPageId: siteSettings?.page_for_posts
10328 };
10329 }, []);
10330 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BaseTitleView, {
10331 item: item,
10332 className: "fields-field__page-title",
10333 children: [frontPageId, postsPageId].includes(item.id) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Badge, {
10334 children: item.id === frontPageId ? (0,external_wp_i18n_namespaceObject.__)('Homepage') : (0,external_wp_i18n_namespaceObject.__)('Posts Page')
10335 })
10336 });
10337 }
10338
10339 ;// ./packages/fields/build-module/fields/page-title/index.js
10340 /**
10341 * WordPress dependencies
10342 */
10343
10344
10345
10346 /**
10347 * Internal dependencies
10348 */
10349
10350
10351
10352 const pageTitleField = {
10353 type: 'text',
10354 id: 'title',
10355 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
10356 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
10357 getValue: ({
10358 item
10359 }) => getItemTitle(item),
10360 render: PageTitleView,
10361 enableHiding: false,
10362 enableGlobalSearch: true
10363 };
10364
10365 /**
10366 * Title for the page entity.
10367 */
10368 /* harmony default export */ const page_title = (pageTitleField);
10369
10370 ;// ./packages/fields/build-module/fields/template-title/index.js
10371 /**
10372 * WordPress dependencies
10373 */
10374
10375
10376
10377 /**
10378 * Internal dependencies
10379 */
10380
10381
10382
10383 const templateTitleField = {
10384 type: 'text',
10385 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
10386 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
10387 id: 'title',
10388 getValue: ({
10389 item
10390 }) => getItemTitle(item),
10391 render: TitleView,
10392 enableHiding: false,
10393 enableGlobalSearch: true
10394 };
10395
10396 /**
10397 * Title for the template entity.
10398 */
10399 /* harmony default export */ const template_title = (templateTitleField);
10400
10401 ;// ./packages/icons/build-module/icon/index.js
10402 /**
10403 * WordPress dependencies
10404 */
10405
10406
10407 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
10408
10409 /**
10410 * Return an SVG icon.
10411 *
10412 * @param {IconProps} props icon is the SVG component to render
10413 * size is a number specifiying the icon size in pixels
10414 * Other props will be passed to wrapped SVG component
10415 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
10416 *
10417 * @return {JSX.Element} Icon component
10418 */
10419 function Icon({
10420 icon,
10421 size = 24,
10422 ...props
10423 }, ref) {
10424 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
10425 width: size,
10426 height: size,
10427 ...props,
10428 ref
10429 });
10430 }
10431 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
10432
10433 ;// ./packages/icons/build-module/library/lock-small.js
10434 /**
10435 * WordPress dependencies
10436 */
10437
10438
10439 const lockSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10440 viewBox: "0 0 24 24",
10441 xmlns: "http://www.w3.org/2000/svg",
10442 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10443 fillRule: "evenodd",
10444 clipRule: "evenodd",
10445 d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z"
10446 })
10447 });
10448 /* harmony default export */ const lock_small = (lockSmall);
10449
10450 ;// ./packages/fields/build-module/fields/pattern-title/view.js
10451 /**
10452 * WordPress dependencies
10453 */
10454
10455
10456
10457 // @ts-ignore
10458
10459
10460 /**
10461 * Internal dependencies
10462 */
10463
10464
10465
10466
10467 const {
10468 PATTERN_TYPES: view_PATTERN_TYPES
10469 } = lock_unlock_unlock(external_wp_patterns_namespaceObject.privateApis);
10470 function PatternTitleView({
10471 item
10472 }) {
10473 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BaseTitleView, {
10474 item: item,
10475 className: "fields-field__pattern-title",
10476 children: item.type === view_PATTERN_TYPES.theme && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
10477 placement: "top",
10478 text: (0,external_wp_i18n_namespaceObject.__)('This pattern cannot be edited.'),
10479 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
10480 icon: lock_small,
10481 size: 24
10482 })
10483 })
10484 });
10485 }
10486
10487 ;// ./packages/fields/build-module/fields/pattern-title/index.js
10488 /**
10489 * WordPress dependencies
10490 */
10491
10492
10493
10494 /**
10495 * Internal dependencies
10496 */
10497
10498
10499
10500 const patternTitleField = {
10501 type: 'text',
10502 id: 'title',
10503 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
10504 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
10505 getValue: ({
10506 item
10507 }) => getItemTitle(item),
10508 render: PatternTitleView,
10509 enableHiding: false,
10510 enableGlobalSearch: true
10511 };
10512
10513 /**
10514 * Title for the pattern entity.
10515 */
10516 /* harmony default export */ const pattern_title = (patternTitleField);
10517
10518 ;// ./packages/editor/build-module/dataviews/store/private-actions.js
10519 /* wp:polyfill */
10520 /**
10521 * WordPress dependencies
10522 */
10523
10524
10525
10526
10527 /**
10528 * Internal dependencies
10529 */
10530
10531
10532 function registerEntityAction(kind, name, config) {
10533 return {
10534 type: 'REGISTER_ENTITY_ACTION',
10535 kind,
10536 name,
10537 config
10538 };
10539 }
10540 function unregisterEntityAction(kind, name, actionId) {
10541 return {
10542 type: 'UNREGISTER_ENTITY_ACTION',
10543 kind,
10544 name,
10545 actionId
10546 };
10547 }
10548 function registerEntityField(kind, name, config) {
10549 return {
10550 type: 'REGISTER_ENTITY_FIELD',
10551 kind,
10552 name,
10553 config
10554 };
10555 }
10556 function unregisterEntityField(kind, name, fieldId) {
10557 return {
10558 type: 'UNREGISTER_ENTITY_FIELD',
10559 kind,
10560 name,
10561 fieldId
10562 };
10563 }
10564 function setIsReady(kind, name) {
10565 return {
10566 type: 'SET_IS_READY',
10567 kind,
10568 name
10569 };
10570 }
10571 const registerPostTypeSchema = postType => async ({
10572 registry
10573 }) => {
10574 const isReady = unlock(registry.select(store_store)).isEntityReady('postType', postType);
10575 if (isReady) {
10576 return;
10577 }
10578 unlock(registry.dispatch(store_store)).setIsReady('postType', postType);
10579 const postTypeConfig = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postType);
10580 const canCreate = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).canUser('create', {
10581 kind: 'postType',
10582 name: postType
10583 });
10584 const currentTheme = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getCurrentTheme();
10585 const actions = [postTypeConfig.viewable ? view_post : undefined, !!postTypeConfig.supports?.revisions ? view_post_revisions : undefined,
10586 // @ts-ignore
10587 true ? !['wp_template', 'wp_block', 'wp_template_part'].includes(postTypeConfig.slug) && canCreate && duplicate_post : 0, postTypeConfig.slug === 'wp_template_part' && canCreate && currentTheme?.is_block_theme ? duplicate_template_part : undefined, canCreate && postTypeConfig.slug === 'wp_block' ? duplicate_pattern : undefined, postTypeConfig.supports?.title ? rename_post : undefined, postTypeConfig.supports?.['page-attributes'] ? reorder_page : undefined, postTypeConfig.slug === 'wp_block' ? export_pattern : undefined, restore_post, reset_post, delete_post, trash_post, permanently_delete_post].filter(Boolean);
10588 const fields = [postTypeConfig.supports?.thumbnail && currentTheme?.theme_supports?.['post-thumbnails'] && featured_image, postTypeConfig.supports?.author && author, fields_status, date, slug, postTypeConfig.supports?.['page-attributes'] && fields_parent, postTypeConfig.supports?.comments && comment_status, fields_template, fields_password].filter(Boolean);
10589 if (postTypeConfig.supports?.title) {
10590 let _titleField;
10591 if (postType === 'page') {
10592 _titleField = page_title;
10593 } else if (postType === 'wp_template') {
10594 _titleField = template_title;
10595 } else if (postType === 'wp_block') {
10596 _titleField = pattern_title;
10597 } else {
10598 _titleField = title;
10599 }
10600 fields.push(_titleField);
10601 }
10602 registry.batch(() => {
10603 actions.forEach(action => {
10604 unlock(registry.dispatch(store_store)).registerEntityAction('postType', postType, action);
10605 });
10606 fields.forEach(field => {
10607 unlock(registry.dispatch(store_store)).registerEntityField('postType', postType, field);
10608 });
10609 });
10610 (0,external_wp_hooks_namespaceObject.doAction)('core.registerPostTypeSchema', postType);
10611 };
10612
10613 ;// ./packages/editor/build-module/store/private-actions.js
10614 /* wp:polyfill */
10615 /**
10616 * WordPress dependencies
10617 */
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628 /**
10629 * Internal dependencies
10630 */
10631
10632
10633
10634 /**
10635 * Returns an action object used to set which template is currently being used/edited.
10636 *
10637 * @param {string} id Template Id.
10638 *
10639 * @return {Object} Action object.
10640 */
10641 function setCurrentTemplateId(id) {
10642 return {
10643 type: 'SET_CURRENT_TEMPLATE_ID',
10644 id
10645 };
10646 }
10647
10648 /**
10649 * Create a block based template.
10650 *
10651 * @param {?Object} template Template to create and assign.
10652 */
10653 const createTemplate = template => async ({
10654 select,
10655 dispatch,
10656 registry
10657 }) => {
10658 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
10659 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
10660 template: savedTemplate.slug
10661 });
10662 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
10663 type: 'snackbar',
10664 actions: [{
10665 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
10666 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
10667 }]
10668 });
10669 return savedTemplate;
10670 };
10671
10672 /**
10673 * Update the provided block types to be visible.
10674 *
10675 * @param {string[]} blockNames Names of block types to show.
10676 */
10677 const showBlockTypes = blockNames => ({
10678 registry
10679 }) => {
10680 var _registry$select$get;
10681 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
10682 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
10683 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
10684 };
10685
10686 /**
10687 * Update the provided block types to be hidden.
10688 *
10689 * @param {string[]} blockNames Names of block types to hide.
10690 */
10691 const hideBlockTypes = blockNames => ({
10692 registry
10693 }) => {
10694 var _registry$select$get2;
10695 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
10696 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
10697 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
10698 };
10699
10700 /**
10701 * Save entity records marked as dirty.
10702 *
10703 * @param {Object} options Options for the action.
10704 * @param {Function} [options.onSave] Callback when saving happens.
10705 * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
10706 * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
10707 * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
10708 */
10709 const saveDirtyEntities = ({
10710 onSave,
10711 dirtyEntityRecords = [],
10712 entitiesToSkip = [],
10713 close
10714 } = {}) => ({
10715 registry
10716 }) => {
10717 const PUBLISH_ON_SAVE_ENTITIES = [{
10718 kind: 'postType',
10719 name: 'wp_navigation'
10720 }];
10721 const saveNoticeId = 'site-editor-save-success';
10722 const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.home;
10723 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
10724 const entitiesToSave = dirtyEntityRecords.filter(({
10725 kind,
10726 name,
10727 key,
10728 property
10729 }) => {
10730 return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
10731 });
10732 close?.(entitiesToSave);
10733 const siteItemsToSave = [];
10734 const pendingSavedRecords = [];
10735 entitiesToSave.forEach(({
10736 kind,
10737 name,
10738 key,
10739 property
10740 }) => {
10741 if ('root' === kind && 'site' === name) {
10742 siteItemsToSave.push(property);
10743 } else {
10744 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
10745 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
10746 status: 'publish'
10747 });
10748 }
10749 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
10750 }
10751 });
10752 if (siteItemsToSave.length) {
10753 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
10754 }
10755 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
10756 Promise.all(pendingSavedRecords).then(values => {
10757 return onSave ? onSave(values) : values;
10758 }).then(values => {
10759 if (values.some(value => typeof value === 'undefined')) {
10760 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
10761 } else {
10762 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
10763 type: 'snackbar',
10764 id: saveNoticeId,
10765 actions: [{
10766 label: (0,external_wp_i18n_namespaceObject.__)('View site'),
10767 url: homeUrl
10768 }]
10769 });
10770 }
10771 }).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
10772 };
10773
10774 /**
10775 * Reverts a template to its original theme-provided file.
10776 *
10777 * @param {Object} template The template to revert.
10778 * @param {Object} [options]
10779 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
10780 * reverting the template. Default true.
10781 */
10782 const private_actions_revertTemplate = (template, {
10783 allowUndo = true
10784 } = {}) => async ({
10785 registry
10786 }) => {
10787 const noticeId = 'edit-site-template-reverted';
10788 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
10789 if (!isTemplateRevertable(template)) {
10790 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
10791 type: 'snackbar'
10792 });
10793 return;
10794 }
10795 try {
10796 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
10797 if (!templateEntityConfig) {
10798 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
10799 type: 'snackbar'
10800 });
10801 return;
10802 }
10803 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
10804 context: 'edit',
10805 source: template.origin
10806 });
10807 const fileTemplate = await external_wp_apiFetch_default()({
10808 path: fileTemplatePath
10809 });
10810 if (!fileTemplate) {
10811 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
10812 type: 'snackbar'
10813 });
10814 return;
10815 }
10816 const serializeBlocks = ({
10817 blocks: blocksForSerialization = []
10818 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
10819 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
10820
10821 // We are fixing up the undo level here to make sure we can undo
10822 // the revert in the header toolbar correctly.
10823 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
10824 content: serializeBlocks,
10825 // Required to make the `undo` behave correctly.
10826 blocks: edited.blocks,
10827 // Required to revert the blocks in the editor.
10828 source: 'custom' // required to avoid turning the editor into a dirty state
10829 }, {
10830 undoIgnore: true // Required to merge this edit with the last undo level.
10831 });
10832 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
10833 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
10834 content: serializeBlocks,
10835 blocks,
10836 source: 'theme'
10837 });
10838 if (allowUndo) {
10839 const undoRevert = () => {
10840 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
10841 content: serializeBlocks,
10842 blocks: edited.blocks,
10843 source: 'custom'
10844 });
10845 };
10846 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
10847 type: 'snackbar',
10848 id: noticeId,
10849 actions: [{
10850 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
10851 onClick: undoRevert
10852 }]
10853 });
10854 }
10855 } catch (error) {
10856 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
10857 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
10858 type: 'snackbar'
10859 });
10860 }
10861 };
10862
10863 /**
10864 * Action that removes an array of templates, template parts or patterns.
10865 *
10866 * @param {Array} items An array of template,template part or pattern objects to remove.
10867 */
10868 const removeTemplates = items => async ({
10869 registry
10870 }) => {
10871 const isResetting = items.every(item => item?.has_theme_file);
10872 const promiseResult = await Promise.allSettled(items.map(item => {
10873 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
10874 force: true
10875 }, {
10876 throwOnError: true
10877 });
10878 }));
10879
10880 // If all the promises were fulfilled with sucess.
10881 if (promiseResult.every(({
10882 status
10883 }) => status === 'fulfilled')) {
10884 let successMessage;
10885 if (items.length === 1) {
10886 // Depending on how the entity was retrieved its title might be
10887 // an object or simple string.
10888 let title;
10889 if (typeof items[0].title === 'string') {
10890 title = items[0].title;
10891 } else if (typeof items[0].title?.rendered === 'string') {
10892 title = items[0].title?.rendered;
10893 } else if (typeof items[0].title?.raw === 'string') {
10894 title = items[0].title?.raw;
10895 }
10896 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: The template/part's name. */
10897 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: The template/part's name. */
10898 (0,external_wp_i18n_namespaceObject._x)('"%s" deleted.', 'template part'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
10899 } else {
10900 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
10901 }
10902 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
10903 type: 'snackbar',
10904 id: 'editor-template-deleted-success'
10905 });
10906 } else {
10907 // If there was at lease one failure.
10908 let errorMessage;
10909 // If we were trying to delete a single template.
10910 if (promiseResult.length === 1) {
10911 if (promiseResult[0].reason?.message) {
10912 errorMessage = promiseResult[0].reason.message;
10913 } else {
10914 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the item.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
10915 }
10916 // If we were trying to delete a multiple templates
10917 } else {
10918 const errorMessages = new Set();
10919 const failedPromises = promiseResult.filter(({
10920 status
10921 }) => status === 'rejected');
10922 for (const failedPromise of failedPromises) {
10923 if (failedPromise.reason?.message) {
10924 errorMessages.add(failedPromise.reason.message);
10925 }
10926 }
10927 if (errorMessages.size === 0) {
10928 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
10929 } else if (errorMessages.size === 1) {
10930 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
10931 (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the items: %s'), [...errorMessages][0]) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: an error message */
10932 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
10933 } else {
10934 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
10935 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while reverting the items: %s'), [...errorMessages].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: a list of comma separated error messages */
10936 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
10937 }
10938 }
10939 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
10940 type: 'snackbar'
10941 });
10942 }
10943 };
10944
10945 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
10946 var fast_deep_equal = __webpack_require__(5215);
10947 var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
10948 ;// ./packages/icons/build-module/library/symbol.js
10949 /**
10950 * WordPress dependencies
10951 */
10952
10953
10954 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10955 xmlns: "http://www.w3.org/2000/svg",
10956 viewBox: "0 0 24 24",
10957 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10958 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"
10959 })
10960 });
10961 /* harmony default export */ const library_symbol = (symbol);
10962
10963 ;// ./packages/icons/build-module/library/navigation.js
10964 /**
10965 * WordPress dependencies
10966 */
10967
10968
10969 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10970 viewBox: "0 0 24 24",
10971 xmlns: "http://www.w3.org/2000/svg",
10972 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10973 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"
10974 })
10975 });
10976 /* harmony default export */ const library_navigation = (navigation);
10977
10978 ;// ./packages/icons/build-module/library/page.js
10979 /**
10980 * WordPress dependencies
10981 */
10982
10983
10984 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
10985 xmlns: "http://www.w3.org/2000/svg",
10986 viewBox: "0 0 24 24",
10987 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10988 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
10989 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10990 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"
10991 })]
10992 });
10993 /* harmony default export */ const library_page = (page);
10994
10995 ;// ./packages/icons/build-module/library/verse.js
10996 /**
10997 * WordPress dependencies
10998 */
10999
11000
11001 const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
11002 viewBox: "0 0 24 24",
11003 xmlns: "http://www.w3.org/2000/svg",
11004 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
11005 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"
11006 })
11007 });
11008 /* harmony default export */ const library_verse = (verse);
11009
11010 ;// ./packages/editor/build-module/dataviews/store/private-selectors.js
11011 /**
11012 * Internal dependencies
11013 */
11014
11015 const EMPTY_ARRAY = [];
11016 function getEntityActions(state, kind, name) {
11017 var _state$actions$kind$n;
11018 return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : EMPTY_ARRAY;
11019 }
11020 function getEntityFields(state, kind, name) {
11021 var _state$fields$kind$na;
11022 return (_state$fields$kind$na = state.fields[kind]?.[name]) !== null && _state$fields$kind$na !== void 0 ? _state$fields$kind$na : EMPTY_ARRAY;
11023 }
11024 function isEntityReady(state, kind, name) {
11025 return state.isReady[kind]?.[name];
11026 }
11027
11028 ;// ./packages/editor/build-module/store/private-selectors.js
11029 /* wp:polyfill */
11030 /**
11031 * External dependencies
11032 */
11033
11034
11035 /**
11036 * WordPress dependencies
11037 */
11038
11039
11040
11041
11042
11043 /**
11044 * Internal dependencies
11045 */
11046
11047
11048 const EMPTY_INSERTION_POINT = {
11049 rootClientId: undefined,
11050 insertionIndex: undefined,
11051 filterValue: undefined
11052 };
11053
11054 /**
11055 * Get the inserter.
11056 *
11057 * @param {Object} state Global application state.
11058 *
11059 * @return {Object} The root client ID, index to insert at and starting filter value.
11060 */
11061 const getInserter = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
11062 if (typeof state.blockInserterPanel === 'object') {
11063 return state.blockInserterPanel;
11064 }
11065 if (getRenderingMode(state) === 'template-locked') {
11066 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
11067 if (postContentClientId) {
11068 return {
11069 rootClientId: postContentClientId,
11070 insertionIndex: undefined,
11071 filterValue: undefined
11072 };
11073 }
11074 }
11075 return EMPTY_INSERTION_POINT;
11076 }, state => {
11077 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
11078 return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
11079 }));
11080 function getListViewToggleRef(state) {
11081 return state.listViewToggleRef;
11082 }
11083 function getInserterSidebarToggleRef(state) {
11084 return state.inserterSidebarToggleRef;
11085 }
11086 const CARD_ICONS = {
11087 wp_block: library_symbol,
11088 wp_navigation: library_navigation,
11089 page: library_page,
11090 post: library_verse
11091 };
11092 const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
11093 {
11094 if (postType === 'wp_template_part' || postType === 'wp_template') {
11095 return (select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas || []).find(item => options.area === item.area)?.icon || library_layout;
11096 }
11097 if (CARD_ICONS[postType]) {
11098 return CARD_ICONS[postType];
11099 }
11100 const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
11101 // `icon` is the `menu_icon` property of a post type. We
11102 // only handle `dashicons` for now, even if the `menu_icon`
11103 // also supports urls and svg as values.
11104 if (typeof postTypeEntity?.icon === 'string' && postTypeEntity.icon.startsWith('dashicons-')) {
11105 return postTypeEntity.icon.slice(10);
11106 }
11107 return library_page;
11108 }
11109 });
11110
11111 /**
11112 * Returns true if there are unsaved changes to the
11113 * post's meta fields, and false otherwise.
11114 *
11115 * @param {Object} state Global application state.
11116 * @param {string} postType The post type of the post.
11117 * @param {number} postId The ID of the post.
11118 *
11119 * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
11120 */
11121 const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
11122 const {
11123 type: currentPostType,
11124 id: currentPostId
11125 } = getCurrentPost(state);
11126 // If no postType or postId is passed, use the current post.
11127 const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
11128 if (!edits?.meta) {
11129 return false;
11130 }
11131
11132 // Compare if anything apart from `footnotes` has changed.
11133 const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
11134 return !fast_deep_equal_default()({
11135 ...originalPostMeta,
11136 footnotes: undefined
11137 }, {
11138 ...edits.meta,
11139 footnotes: undefined
11140 });
11141 });
11142 function private_selectors_getEntityActions(state, ...args) {
11143 return getEntityActions(state.dataviews, ...args);
11144 }
11145 function private_selectors_isEntityReady(state, ...args) {
11146 return isEntityReady(state.dataviews, ...args);
11147 }
11148 function private_selectors_getEntityFields(state, ...args) {
11149 return getEntityFields(state.dataviews, ...args);
11150 }
11151
11152 /**
11153 * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most
11154 * blocks that aren't descendants of the query block.
11155 *
11156 * @param {Object} state Global application state.
11157 * @param {Array|string} blockNames Block names of the blocks to retrieve.
11158 *
11159 * @return {Array} Block client IDs.
11160 */
11161 const getPostBlocksByName = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, blockNames) => {
11162 blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
11163 const {
11164 getBlocksByName,
11165 getBlockParents,
11166 getBlockName
11167 } = select(external_wp_blockEditor_namespaceObject.store);
11168 return getBlocksByName(blockNames).filter(clientId => getBlockParents(clientId).every(parentClientId => {
11169 const parentBlockName = getBlockName(parentClientId);
11170 return (
11171 // Ignore descendents of the query block.
11172 parentBlockName !== 'core/query' &&
11173 // Enable only the top-most block.
11174 !blockNames.includes(parentBlockName)
11175 );
11176 }));
11177 }, () => [select(external_wp_blockEditor_namespaceObject.store).getBlocks()]));
11178
11179 ;// ./packages/editor/build-module/store/index.js
11180 /**
11181 * WordPress dependencies
11182 */
11183
11184
11185 /**
11186 * Internal dependencies
11187 */
11188
11189
11190
11191
11192
11193
11194
11195
11196 /**
11197 * Post editor data store configuration.
11198 *
11199 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
11200 */
11201 const storeConfig = {
11202 reducer: store_reducer,
11203 selectors: selectors_namespaceObject,
11204 actions: actions_namespaceObject
11205 };
11206
11207 /**
11208 * Store definition for the editor namespace.
11209 *
11210 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
11211 */
11212 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
11213 ...storeConfig
11214 });
11215 (0,external_wp_data_namespaceObject.register)(store_store);
11216 unlock(store_store).registerPrivateActions(store_private_actions_namespaceObject);
11217 unlock(store_store).registerPrivateSelectors(store_private_selectors_namespaceObject);
11218
11219 ;// ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
11220 /* wp:polyfill */
11221 /**
11222 * WordPress dependencies
11223 */
11224
11225
11226
11227
11228
11229
11230 /**
11231 * Internal dependencies
11232 */
11233
11234
11235 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
11236 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
11237
11238 /**
11239 * Object whose keys are the names of block attributes, where each value
11240 * represents the meta key to which the block attribute is intended to save.
11241 *
11242 * @see https://developer.wordpress.org/reference/functions/register_meta/
11243 *
11244 * @typedef {Object<string,string>} WPMetaAttributeMapping
11245 */
11246
11247 /**
11248 * Given a mapping of attribute names (meta source attributes) to their
11249 * associated meta key, returns a higher order component that overrides its
11250 * `attributes` and `setAttributes` props to sync any changes with the edited
11251 * post's meta keys.
11252 *
11253 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
11254 *
11255 * @return {WPHigherOrderComponent} Higher-order component.
11256 */
11257
11258 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({
11259 attributes,
11260 setAttributes,
11261 ...props
11262 }) => {
11263 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
11264 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
11265 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({
11266 ...attributes,
11267 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]]))
11268 }), [attributes, meta]);
11269 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
11270 attributes: mergedAttributes,
11271 setAttributes: nextAttributes => {
11272 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter(
11273 // Filter to intersection of keys between the updated
11274 // attributes and those with an associated meta key.
11275 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [
11276 // Rename the keys to the expected meta key name.
11277 metaAttributes[attributeKey], value]));
11278 if (Object.entries(nextMeta).length) {
11279 setMeta(nextMeta);
11280 }
11281 setAttributes(nextAttributes);
11282 },
11283 ...props
11284 });
11285 }, 'withMetaAttributeSource');
11286
11287 /**
11288 * Filters a registered block's settings to enhance a block's `edit` component
11289 * to upgrade meta-sourced attributes to use the post's meta entity property.
11290 *
11291 * @param {WPBlockSettings} settings Registered block settings.
11292 *
11293 * @return {WPBlockSettings} Filtered block settings.
11294 */
11295 function shimAttributeSource(settings) {
11296 var _settings$attributes;
11297 /** @type {WPMetaAttributeMapping} */
11298 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, {
11299 source
11300 }]) => source === 'meta').map(([attributeKey, {
11301 meta
11302 }]) => [attributeKey, meta]));
11303 if (Object.entries(metaAttributes).length) {
11304 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
11305 }
11306 return settings;
11307 }
11308 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
11309
11310 ;// ./packages/editor/build-module/components/autocompleters/user.js
11311 /* wp:polyfill */
11312 /**
11313 * WordPress dependencies
11314 */
11315
11316
11317
11318
11319 function getUserLabel(user) {
11320 const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
11321 className: "editor-autocompleters__user-avatar",
11322 alt: "",
11323 src: user.avatar_urls[24]
11324 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11325 className: "editor-autocompleters__no-avatar"
11326 });
11327 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11328 children: [avatar, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11329 className: "editor-autocompleters__user-name",
11330 children: user.name
11331 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
11332 className: "editor-autocompleters__user-slug",
11333 children: user.slug
11334 })]
11335 });
11336 }
11337
11338 /**
11339 * A user mentions completer.
11340 *
11341 * @type {Object}
11342 */
11343 /* harmony default export */ const user = ({
11344 name: 'users',
11345 className: 'editor-autocompleters__user',
11346 triggerPrefix: '@',
11347 useItems(filterValue) {
11348 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
11349 const {
11350 getUsers
11351 } = select(external_wp_coreData_namespaceObject.store);
11352 return getUsers({
11353 context: 'view',
11354 search: encodeURIComponent(filterValue)
11355 });
11356 }, [filterValue]);
11357 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
11358 key: `user-${user.slug}`,
11359 value: user,
11360 label: getUserLabel(user)
11361 })) : [], [users]);
11362 return [options];
11363 },
11364 getOptionCompletion(user) {
11365 return `@${user.slug}`;
11366 }
11367 });
11368
11369 ;// ./packages/editor/build-module/hooks/default-autocompleters.js
11370 /**
11371 * WordPress dependencies
11372 */
11373
11374
11375 /**
11376 * Internal dependencies
11377 */
11378
11379 function setDefaultCompleters(completers = []) {
11380 // Provide copies so filters may directly modify them.
11381 completers.push({
11382 ...user
11383 });
11384 return completers;
11385 }
11386 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
11387
11388 ;// ./packages/editor/build-module/hooks/media-upload.js
11389 /**
11390 * WordPress dependencies
11391 */
11392
11393
11394 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
11395
11396 ;// ./packages/editor/build-module/hooks/pattern-overrides.js
11397 /* wp:polyfill */
11398 /**
11399 * WordPress dependencies
11400 */
11401
11402
11403
11404
11405
11406
11407
11408 /**
11409 * Internal dependencies
11410 */
11411
11412
11413
11414 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
11415
11416 const {
11417 PatternOverridesControls,
11418 ResetOverridesControl,
11419 PatternOverridesBlockControls,
11420 PATTERN_TYPES: pattern_overrides_PATTERN_TYPES,
11421 PARTIAL_SYNCING_SUPPORTED_BLOCKS,
11422 PATTERN_SYNC_TYPES
11423 } = unlock(external_wp_patterns_namespaceObject.privateApis);
11424
11425 /**
11426 * Override the default edit UI to include a new block inspector control for
11427 * assigning a partial syncing controls to supported blocks in the pattern editor.
11428 * Currently, only the `core/paragraph` block is supported.
11429 *
11430 * @param {Component} BlockEdit Original component.
11431 *
11432 * @return {Component} Wrapped component.
11433 */
11434 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
11435 const isSupportedBlock = !!PARTIAL_SYNCING_SUPPORTED_BLOCKS[props.name];
11436 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11437 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
11438 ...props
11439 }, "edit"), props.isSelected && isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ControlsWithStoreSubscription, {
11440 ...props
11441 }), isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesBlockControls, {})]
11442 });
11443 }, 'withPatternOverrideControls');
11444
11445 // Split into a separate component to avoid a store subscription
11446 // on every block.
11447 function ControlsWithStoreSubscription(props) {
11448 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)();
11449 const {
11450 hasPatternOverridesSource,
11451 isEditingSyncedPattern
11452 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11453 const {
11454 getCurrentPostType,
11455 getEditedPostAttribute
11456 } = select(store_store);
11457 return {
11458 // For editing link to the site editor if the theme and user permissions support it.
11459 hasPatternOverridesSource: !!(0,external_wp_blocks_namespaceObject.getBlockBindingsSource)('core/pattern-overrides'),
11460 isEditingSyncedPattern: getCurrentPostType() === pattern_overrides_PATTERN_TYPES.user && getEditedPostAttribute('meta')?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute('wp_pattern_sync_status') !== PATTERN_SYNC_TYPES.unsynced
11461 };
11462 }, []);
11463 const bindings = props.attributes.metadata?.bindings;
11464 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
11465 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === 'default';
11466 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
11467 if (!hasPatternOverridesSource) {
11468 return null;
11469 }
11470 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11471 children: [shouldShowPatternOverridesControls && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesControls, {
11472 ...props
11473 }), shouldShowResetOverridesControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetOverridesControl, {
11474 ...props
11475 })]
11476 });
11477 }
11478 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
11479
11480 ;// ./packages/editor/build-module/hooks/index.js
11481 /**
11482 * Internal dependencies
11483 */
11484
11485
11486
11487
11488
11489 ;// external ["wp","keyboardShortcuts"]
11490 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
11491 ;// ./packages/icons/build-module/library/star-filled.js
11492 /**
11493 * WordPress dependencies
11494 */
11495
11496
11497 const starFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
11498 xmlns: "http://www.w3.org/2000/svg",
11499 viewBox: "0 0 24 24",
11500 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
11501 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"
11502 })
11503 });
11504 /* harmony default export */ const star_filled = (starFilled);
11505
11506 ;// ./packages/icons/build-module/library/star-empty.js
11507 /**
11508 * WordPress dependencies
11509 */
11510
11511
11512 const starEmpty = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
11513 xmlns: "http://www.w3.org/2000/svg",
11514 viewBox: "0 0 24 24",
11515 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
11516 fillRule: "evenodd",
11517 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",
11518 clipRule: "evenodd"
11519 })
11520 });
11521 /* harmony default export */ const star_empty = (starEmpty);
11522
11523 ;// external ["wp","viewport"]
11524 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
11525 ;// external ["wp","plugins"]
11526 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
11527 ;// ./packages/interface/build-module/store/deprecated.js
11528 /**
11529 * WordPress dependencies
11530 */
11531
11532 function normalizeComplementaryAreaScope(scope) {
11533 if (['core/edit-post', 'core/edit-site'].includes(scope)) {
11534 external_wp_deprecated_default()(`${scope} interface scope`, {
11535 alternative: 'core interface scope',
11536 hint: 'core/edit-post and core/edit-site are merging.',
11537 version: '6.6'
11538 });
11539 return 'core';
11540 }
11541 return scope;
11542 }
11543 function normalizeComplementaryAreaName(scope, name) {
11544 if (scope === 'core' && name === 'edit-site/template') {
11545 external_wp_deprecated_default()(`edit-site/template sidebar`, {
11546 alternative: 'edit-post/document',
11547 version: '6.6'
11548 });
11549 return 'edit-post/document';
11550 }
11551 if (scope === 'core' && name === 'edit-site/block-inspector') {
11552 external_wp_deprecated_default()(`edit-site/block-inspector sidebar`, {
11553 alternative: 'edit-post/block',
11554 version: '6.6'
11555 });
11556 return 'edit-post/block';
11557 }
11558 return name;
11559 }
11560
11561 ;// ./packages/interface/build-module/store/actions.js
11562 /**
11563 * WordPress dependencies
11564 */
11565
11566
11567
11568 /**
11569 * Internal dependencies
11570 */
11571
11572
11573 /**
11574 * Set a default complementary area.
11575 *
11576 * @param {string} scope Complementary area scope.
11577 * @param {string} area Area identifier.
11578 *
11579 * @return {Object} Action object.
11580 */
11581 const setDefaultComplementaryArea = (scope, area) => {
11582 scope = normalizeComplementaryAreaScope(scope);
11583 area = normalizeComplementaryAreaName(scope, area);
11584 return {
11585 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
11586 scope,
11587 area
11588 };
11589 };
11590
11591 /**
11592 * Enable the complementary area.
11593 *
11594 * @param {string} scope Complementary area scope.
11595 * @param {string} area Area identifier.
11596 */
11597 const enableComplementaryArea = (scope, area) => ({
11598 registry,
11599 dispatch
11600 }) => {
11601 // Return early if there's no area.
11602 if (!area) {
11603 return;
11604 }
11605 scope = normalizeComplementaryAreaScope(scope);
11606 area = normalizeComplementaryAreaName(scope, area);
11607 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
11608 if (!isComplementaryAreaVisible) {
11609 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
11610 }
11611 dispatch({
11612 type: 'ENABLE_COMPLEMENTARY_AREA',
11613 scope,
11614 area
11615 });
11616 };
11617
11618 /**
11619 * Disable the complementary area.
11620 *
11621 * @param {string} scope Complementary area scope.
11622 */
11623 const disableComplementaryArea = scope => ({
11624 registry
11625 }) => {
11626 scope = normalizeComplementaryAreaScope(scope);
11627 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
11628 if (isComplementaryAreaVisible) {
11629 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
11630 }
11631 };
11632
11633 /**
11634 * Pins an item.
11635 *
11636 * @param {string} scope Item scope.
11637 * @param {string} item Item identifier.
11638 *
11639 * @return {Object} Action object.
11640 */
11641 const pinItem = (scope, item) => ({
11642 registry
11643 }) => {
11644 // Return early if there's no item.
11645 if (!item) {
11646 return;
11647 }
11648 scope = normalizeComplementaryAreaScope(scope);
11649 item = normalizeComplementaryAreaName(scope, item);
11650 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
11651
11652 // The item is already pinned, there's nothing to do.
11653 if (pinnedItems?.[item] === true) {
11654 return;
11655 }
11656 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
11657 ...pinnedItems,
11658 [item]: true
11659 });
11660 };
11661
11662 /**
11663 * Unpins an item.
11664 *
11665 * @param {string} scope Item scope.
11666 * @param {string} item Item identifier.
11667 */
11668 const unpinItem = (scope, item) => ({
11669 registry
11670 }) => {
11671 // Return early if there's no item.
11672 if (!item) {
11673 return;
11674 }
11675 scope = normalizeComplementaryAreaScope(scope);
11676 item = normalizeComplementaryAreaName(scope, item);
11677 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
11678 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
11679 ...pinnedItems,
11680 [item]: false
11681 });
11682 };
11683
11684 /**
11685 * Returns an action object used in signalling that a feature should be toggled.
11686 *
11687 * @param {string} scope The feature scope (e.g. core/edit-post).
11688 * @param {string} featureName The feature name.
11689 */
11690 function toggleFeature(scope, featureName) {
11691 return function ({
11692 registry
11693 }) {
11694 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
11695 since: '6.0',
11696 alternative: `dispatch( 'core/preferences' ).toggle`
11697 });
11698 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
11699 };
11700 }
11701
11702 /**
11703 * Returns an action object used in signalling that a feature should be set to
11704 * a true or false value
11705 *
11706 * @param {string} scope The feature scope (e.g. core/edit-post).
11707 * @param {string} featureName The feature name.
11708 * @param {boolean} value The value to set.
11709 *
11710 * @return {Object} Action object.
11711 */
11712 function setFeatureValue(scope, featureName, value) {
11713 return function ({
11714 registry
11715 }) {
11716 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
11717 since: '6.0',
11718 alternative: `dispatch( 'core/preferences' ).set`
11719 });
11720 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
11721 };
11722 }
11723
11724 /**
11725 * Returns an action object used in signalling that defaults should be set for features.
11726 *
11727 * @param {string} scope The feature scope (e.g. core/edit-post).
11728 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
11729 *
11730 * @return {Object} Action object.
11731 */
11732 function setFeatureDefaults(scope, defaults) {
11733 return function ({
11734 registry
11735 }) {
11736 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
11737 since: '6.0',
11738 alternative: `dispatch( 'core/preferences' ).setDefaults`
11739 });
11740 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
11741 };
11742 }
11743
11744 /**
11745 * Returns an action object used in signalling that the user opened a modal.
11746 *
11747 * @param {string} name A string that uniquely identifies the modal.
11748 *
11749 * @return {Object} Action object.
11750 */
11751 function openModal(name) {
11752 return {
11753 type: 'OPEN_MODAL',
11754 name
11755 };
11756 }
11757
11758 /**
11759 * Returns an action object signalling that the user closed a modal.
11760 *
11761 * @return {Object} Action object.
11762 */
11763 function closeModal() {
11764 return {
11765 type: 'CLOSE_MODAL'
11766 };
11767 }
11768
11769 ;// ./packages/interface/build-module/store/selectors.js
11770 /**
11771 * WordPress dependencies
11772 */
11773
11774
11775
11776
11777 /**
11778 * Internal dependencies
11779 */
11780
11781
11782 /**
11783 * Returns the complementary area that is active in a given scope.
11784 *
11785 * @param {Object} state Global application state.
11786 * @param {string} scope Item scope.
11787 *
11788 * @return {string | null | undefined} The complementary area that is active in the given scope.
11789 */
11790 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
11791 scope = normalizeComplementaryAreaScope(scope);
11792 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
11793
11794 // Return `undefined` to indicate that the user has never toggled
11795 // visibility, this is the vanilla default. Other code relies on this
11796 // nuance in the return value.
11797 if (isComplementaryAreaVisible === undefined) {
11798 return undefined;
11799 }
11800
11801 // Return `null` to indicate the user hid the complementary area.
11802 if (isComplementaryAreaVisible === false) {
11803 return null;
11804 }
11805 return state?.complementaryAreas?.[scope];
11806 });
11807 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
11808 scope = normalizeComplementaryAreaScope(scope);
11809 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
11810 const identifier = state?.complementaryAreas?.[scope];
11811 return isVisible && identifier === undefined;
11812 });
11813
11814 /**
11815 * Returns a boolean indicating if an item is pinned or not.
11816 *
11817 * @param {Object} state Global application state.
11818 * @param {string} scope Scope.
11819 * @param {string} item Item to check.
11820 *
11821 * @return {boolean} True if the item is pinned and false otherwise.
11822 */
11823 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
11824 var _pinnedItems$item;
11825 scope = normalizeComplementaryAreaScope(scope);
11826 item = normalizeComplementaryAreaName(scope, item);
11827 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
11828 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
11829 });
11830
11831 /**
11832 * Returns a boolean indicating whether a feature is active for a particular
11833 * scope.
11834 *
11835 * @param {Object} state The store state.
11836 * @param {string} scope The scope of the feature (e.g. core/edit-post).
11837 * @param {string} featureName The name of the feature.
11838 *
11839 * @return {boolean} Is the feature enabled?
11840 */
11841 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
11842 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
11843 since: '6.0',
11844 alternative: `select( 'core/preferences' ).get( scope, featureName )`
11845 });
11846 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
11847 });
11848
11849 /**
11850 * Returns true if a modal is active, or false otherwise.
11851 *
11852 * @param {Object} state Global application state.
11853 * @param {string} modalName A string that uniquely identifies the modal.
11854 *
11855 * @return {boolean} Whether the modal is active.
11856 */
11857 function isModalActive(state, modalName) {
11858 return state.activeModal === modalName;
11859 }
11860
11861 ;// ./packages/interface/build-module/store/reducer.js
11862 /**
11863 * WordPress dependencies
11864 */
11865
11866 function complementaryAreas(state = {}, action) {
11867 switch (action.type) {
11868 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
11869 {
11870 const {
11871 scope,
11872 area
11873 } = action;
11874
11875 // If there's already an area, don't overwrite it.
11876 if (state[scope]) {
11877 return state;
11878 }
11879 return {
11880 ...state,
11881 [scope]: area
11882 };
11883 }
11884 case 'ENABLE_COMPLEMENTARY_AREA':
11885 {
11886 const {
11887 scope,
11888 area
11889 } = action;
11890 return {
11891 ...state,
11892 [scope]: area
11893 };
11894 }
11895 }
11896 return state;
11897 }
11898
11899 /**
11900 * Reducer for storing the name of the open modal, or null if no modal is open.
11901 *
11902 * @param {Object} state Previous state.
11903 * @param {Object} action Action object containing the `name` of the modal
11904 *
11905 * @return {Object} Updated state
11906 */
11907 function activeModal(state = null, action) {
11908 switch (action.type) {
11909 case 'OPEN_MODAL':
11910 return action.name;
11911 case 'CLOSE_MODAL':
11912 return null;
11913 }
11914 return state;
11915 }
11916 /* harmony default export */ const build_module_store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
11917 complementaryAreas,
11918 activeModal
11919 }));
11920
11921 ;// ./packages/interface/build-module/store/constants.js
11922 /**
11923 * The identifier for the data store.
11924 *
11925 * @type {string}
11926 */
11927 const constants_STORE_NAME = 'core/interface';
11928
11929 ;// ./packages/interface/build-module/store/index.js
11930 /**
11931 * WordPress dependencies
11932 */
11933
11934
11935 /**
11936 * Internal dependencies
11937 */
11938
11939
11940
11941
11942
11943 /**
11944 * Store definition for the interface namespace.
11945 *
11946 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
11947 *
11948 * @type {Object}
11949 */
11950 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
11951 reducer: build_module_store_reducer,
11952 actions: store_actions_namespaceObject,
11953 selectors: store_selectors_namespaceObject
11954 });
11955
11956 // Once we build a more generic persistence plugin that works across types of stores
11957 // we'd be able to replace this with a register call.
11958 (0,external_wp_data_namespaceObject.register)(store);
11959
11960 ;// ./packages/interface/build-module/components/complementary-area-toggle/index.js
11961 /**
11962 * WordPress dependencies
11963 */
11964
11965
11966
11967
11968 /**
11969 * Internal dependencies
11970 */
11971
11972
11973 /**
11974 * Whether the role supports checked state.
11975 *
11976 * @param {import('react').AriaRole} role Role.
11977 * @return {boolean} Whether the role supports checked state.
11978 * @see https://www.w3.org/TR/wai-aria-1.1/#aria-checked
11979 */
11980
11981 function roleSupportsCheckedState(role) {
11982 return ['checkbox', 'option', 'radio', 'switch', 'menuitemcheckbox', 'menuitemradio', 'treeitem'].includes(role);
11983 }
11984 function ComplementaryAreaToggle({
11985 as = external_wp_components_namespaceObject.Button,
11986 scope,
11987 identifier: identifierProp,
11988 icon: iconProp,
11989 selectedIcon,
11990 name,
11991 shortcut,
11992 ...props
11993 }) {
11994 const ComponentToUse = as;
11995 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
11996 const icon = iconProp || context.icon;
11997 const identifier = identifierProp || `${context.name}/${name}`;
11998 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]);
11999 const {
12000 enableComplementaryArea,
12001 disableComplementaryArea
12002 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12003 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComponentToUse, {
12004 icon: selectedIcon && isSelected ? selectedIcon : icon,
12005 "aria-controls": identifier.replace('/', ':')
12006 // Make sure aria-checked matches spec https://www.w3.org/TR/wai-aria-1.1/#aria-checked
12007 ,
12008 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : undefined,
12009 onClick: () => {
12010 if (isSelected) {
12011 disableComplementaryArea(scope);
12012 } else {
12013 enableComplementaryArea(scope, identifier);
12014 }
12015 },
12016 shortcut: shortcut,
12017 ...props
12018 });
12019 }
12020
12021 ;// ./packages/interface/build-module/components/complementary-area-header/index.js
12022 /**
12023 * External dependencies
12024 */
12025
12026
12027 /**
12028 * WordPress dependencies
12029 */
12030
12031
12032 /**
12033 * Internal dependencies
12034 */
12035
12036
12037 const ComplementaryAreaHeader = ({
12038 children,
12039 className,
12040 toggleButtonProps
12041 }) => {
12042 const toggleButton = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
12043 icon: close_small,
12044 ...toggleButtonProps
12045 });
12046 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12047 className: dist_clsx('components-panel__header', 'interface-complementary-area-header', className),
12048 tabIndex: -1,
12049 children: [children, toggleButton]
12050 });
12051 };
12052 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
12053
12054 ;// ./packages/interface/build-module/components/action-item/index.js
12055 /* wp:polyfill */
12056 /**
12057 * WordPress dependencies
12058 */
12059
12060
12061
12062 const noop = () => {};
12063 function ActionItemSlot({
12064 name,
12065 as: Component = external_wp_components_namespaceObject.MenuGroup,
12066 fillProps = {},
12067 bubblesVirtually,
12068 ...props
12069 }) {
12070 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
12071 name: name,
12072 bubblesVirtually: bubblesVirtually,
12073 fillProps: fillProps,
12074 children: fills => {
12075 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
12076 return null;
12077 }
12078
12079 // Special handling exists for backward compatibility.
12080 // It ensures that menu items created by plugin authors aren't
12081 // duplicated with automatically injected menu items coming
12082 // from pinnable plugin sidebars.
12083 // @see https://github.com/WordPress/gutenberg/issues/14457
12084 const initializedByPlugins = [];
12085 external_wp_element_namespaceObject.Children.forEach(fills, ({
12086 props: {
12087 __unstableExplicitMenuItem,
12088 __unstableTarget
12089 }
12090 }) => {
12091 if (__unstableTarget && __unstableExplicitMenuItem) {
12092 initializedByPlugins.push(__unstableTarget);
12093 }
12094 });
12095 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
12096 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
12097 return null;
12098 }
12099 return child;
12100 });
12101 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
12102 ...props,
12103 children: children
12104 });
12105 }
12106 });
12107 }
12108 function ActionItem({
12109 name,
12110 as: Component = external_wp_components_namespaceObject.Button,
12111 onClick,
12112 ...props
12113 }) {
12114 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
12115 name: name,
12116 children: ({
12117 onClick: fpOnClick
12118 }) => {
12119 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
12120 onClick: onClick || fpOnClick ? (...args) => {
12121 (onClick || noop)(...args);
12122 (fpOnClick || noop)(...args);
12123 } : undefined,
12124 ...props
12125 });
12126 }
12127 });
12128 }
12129 ActionItem.Slot = ActionItemSlot;
12130 /* harmony default export */ const action_item = (ActionItem);
12131
12132 ;// ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
12133 /**
12134 * WordPress dependencies
12135 */
12136
12137
12138
12139 /**
12140 * Internal dependencies
12141 */
12142
12143
12144
12145 const PluginsMenuItem = ({
12146 // Menu item is marked with unstable prop for backward compatibility.
12147 // They are removed so they don't leak to DOM elements.
12148 // @see https://github.com/WordPress/gutenberg/issues/14457
12149 __unstableExplicitMenuItem,
12150 __unstableTarget,
12151 ...restProps
12152 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
12153 ...restProps
12154 });
12155 function ComplementaryAreaMoreMenuItem({
12156 scope,
12157 target,
12158 __unstableExplicitMenuItem,
12159 ...props
12160 }) {
12161 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
12162 as: toggleProps => {
12163 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
12164 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
12165 __unstableTarget: `${scope}/${target}`,
12166 as: PluginsMenuItem,
12167 name: `${scope}/plugin-more-menu`,
12168 ...toggleProps
12169 });
12170 },
12171 role: "menuitemcheckbox",
12172 selectedIcon: library_check,
12173 name: target,
12174 scope: scope,
12175 ...props
12176 });
12177 }
12178
12179 ;// ./packages/interface/build-module/components/pinned-items/index.js
12180 /**
12181 * External dependencies
12182 */
12183
12184
12185 /**
12186 * WordPress dependencies
12187 */
12188
12189
12190 function PinnedItems({
12191 scope,
12192 ...props
12193 }) {
12194 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
12195 name: `PinnedItems/${scope}`,
12196 ...props
12197 });
12198 }
12199 function PinnedItemsSlot({
12200 scope,
12201 className,
12202 ...props
12203 }) {
12204 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
12205 name: `PinnedItems/${scope}`,
12206 ...props,
12207 children: fills => fills?.length > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12208 className: dist_clsx(className, 'interface-pinned-items'),
12209 children: fills
12210 })
12211 });
12212 }
12213 PinnedItems.Slot = PinnedItemsSlot;
12214 /* harmony default export */ const pinned_items = (PinnedItems);
12215
12216 ;// ./packages/interface/build-module/components/complementary-area/index.js
12217 /**
12218 * External dependencies
12219 */
12220
12221
12222 /**
12223 * WordPress dependencies
12224 */
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235 /**
12236 * Internal dependencies
12237 */
12238
12239
12240
12241
12242
12243
12244 const ANIMATION_DURATION = 0.3;
12245 function ComplementaryAreaSlot({
12246 scope,
12247 ...props
12248 }) {
12249 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
12250 name: `ComplementaryArea/${scope}`,
12251 ...props
12252 });
12253 }
12254 const SIDEBAR_WIDTH = 280;
12255 const variants = {
12256 open: {
12257 width: SIDEBAR_WIDTH
12258 },
12259 closed: {
12260 width: 0
12261 },
12262 mobileOpen: {
12263 width: '100vw'
12264 }
12265 };
12266 function ComplementaryAreaFill({
12267 activeArea,
12268 isActive,
12269 scope,
12270 children,
12271 className,
12272 id
12273 }) {
12274 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
12275 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
12276 // This is used to delay the exit animation to the next tick.
12277 // The reason this is done is to allow us to apply the right transition properties
12278 // When we switch from an open sidebar to another open sidebar.
12279 // we don't want to animate in this case.
12280 const previousActiveArea = (0,external_wp_compose_namespaceObject.usePrevious)(activeArea);
12281 const previousIsActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive);
12282 const [, setState] = (0,external_wp_element_namespaceObject.useState)({});
12283 (0,external_wp_element_namespaceObject.useEffect)(() => {
12284 setState({});
12285 }, [isActive]);
12286 const transition = {
12287 type: 'tween',
12288 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
12289 ease: [0.6, 0, 0.4, 1]
12290 };
12291 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
12292 name: `ComplementaryArea/${scope}`,
12293 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
12294 initial: false,
12295 children: (previousIsActive || isActive) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
12296 variants: variants,
12297 initial: "closed",
12298 animate: isMobileViewport ? 'mobileOpen' : 'open',
12299 exit: "closed",
12300 transition: transition,
12301 className: "interface-complementary-area__fill",
12302 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12303 id: id,
12304 className: className,
12305 style: {
12306 width: isMobileViewport ? '100vw' : SIDEBAR_WIDTH
12307 },
12308 children: children
12309 })
12310 })
12311 })
12312 });
12313 }
12314 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
12315 const previousIsSmallRef = (0,external_wp_element_namespaceObject.useRef)(false);
12316 const shouldOpenWhenNotSmallRef = (0,external_wp_element_namespaceObject.useRef)(false);
12317 const {
12318 enableComplementaryArea,
12319 disableComplementaryArea
12320 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12321 (0,external_wp_element_namespaceObject.useEffect)(() => {
12322 // If the complementary area is active and the editor is switching from
12323 // a big to a small window size.
12324 if (isActive && isSmall && !previousIsSmallRef.current) {
12325 disableComplementaryArea(scope);
12326 // Flag the complementary area to be reopened when the window size
12327 // goes from small to big.
12328 shouldOpenWhenNotSmallRef.current = true;
12329 } else if (
12330 // If there is a flag indicating the complementary area should be
12331 // enabled when we go from small to big window size and we are going
12332 // from a small to big window size.
12333 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current) {
12334 // Remove the flag indicating the complementary area should be
12335 // enabled.
12336 shouldOpenWhenNotSmallRef.current = false;
12337 enableComplementaryArea(scope, identifier);
12338 } else if (
12339 // If the flag is indicating the current complementary should be
12340 // reopened but another complementary area becomes active, remove
12341 // the flag.
12342 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier) {
12343 shouldOpenWhenNotSmallRef.current = false;
12344 }
12345 if (isSmall !== previousIsSmallRef.current) {
12346 previousIsSmallRef.current = isSmall;
12347 }
12348 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]);
12349 }
12350 function ComplementaryArea({
12351 children,
12352 className,
12353 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
12354 identifier: identifierProp,
12355 header,
12356 headerClassName,
12357 icon: iconProp,
12358 isPinnable = true,
12359 panelClassName,
12360 scope,
12361 name,
12362 title,
12363 toggleShortcut,
12364 isActiveByDefault
12365 }) {
12366 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
12367 const icon = iconProp || context.icon;
12368 const identifier = identifierProp || `${context.name}/${name}`;
12369
12370 // This state is used to delay the rendering of the Fill
12371 // until the initial effect runs.
12372 // This prevents the animation from running on mount if
12373 // the complementary area is active by default.
12374 const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
12375 const {
12376 isLoading,
12377 isActive,
12378 isPinned,
12379 activeArea,
12380 isSmall,
12381 isLarge,
12382 showIconLabels
12383 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12384 const {
12385 getActiveComplementaryArea,
12386 isComplementaryAreaLoading,
12387 isItemPinned
12388 } = select(store);
12389 const {
12390 get
12391 } = select(external_wp_preferences_namespaceObject.store);
12392 const _activeArea = getActiveComplementaryArea(scope);
12393 return {
12394 isLoading: isComplementaryAreaLoading(scope),
12395 isActive: _activeArea === identifier,
12396 isPinned: isItemPinned(scope, identifier),
12397 activeArea: _activeArea,
12398 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
12399 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'),
12400 showIconLabels: get('core', 'showIconLabels')
12401 };
12402 }, [identifier, scope]);
12403 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
12404 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
12405 const {
12406 enableComplementaryArea,
12407 disableComplementaryArea,
12408 pinItem,
12409 unpinItem
12410 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12411 (0,external_wp_element_namespaceObject.useEffect)(() => {
12412 // Set initial visibility: For large screens, enable if it's active by
12413 // default. For small screens, always initially disable.
12414 if (isActiveByDefault && activeArea === undefined && !isSmall) {
12415 enableComplementaryArea(scope, identifier);
12416 } else if (activeArea === undefined && isSmall) {
12417 disableComplementaryArea(scope, identifier);
12418 }
12419 setIsReady(true);
12420 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]);
12421 if (!isReady) {
12422 return;
12423 }
12424 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12425 children: [isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items, {
12426 scope: scope,
12427 children: isPinned && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaToggle, {
12428 scope: scope,
12429 identifier: identifier,
12430 isPressed: isActive && (!showIconLabels || isLarge),
12431 "aria-expanded": isActive,
12432 "aria-disabled": isLoading,
12433 label: title,
12434 icon: showIconLabels ? library_check : icon,
12435 showTooltip: !showIconLabels,
12436 variant: showIconLabels ? 'tertiary' : undefined,
12437 size: "compact",
12438 shortcut: toggleShortcut
12439 })
12440 }), name && isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem, {
12441 target: name,
12442 scope: scope,
12443 icon: icon,
12444 children: title
12445 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ComplementaryAreaFill, {
12446 activeArea: activeArea,
12447 isActive: isActive,
12448 className: dist_clsx('interface-complementary-area', className),
12449 scope: scope,
12450 id: identifier.replace('/', ':'),
12451 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_header, {
12452 className: headerClassName,
12453 closeLabel: closeLabel,
12454 onClose: () => disableComplementaryArea(scope),
12455 toggleButtonProps: {
12456 label: closeLabel,
12457 size: 'compact',
12458 shortcut: toggleShortcut,
12459 scope,
12460 identifier
12461 },
12462 children: header || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12463 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
12464 className: "interface-complementary-area-header__title",
12465 children: title
12466 }), isPinnable && !isMobileViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12467 className: "interface-complementary-area__pin-unpin-item",
12468 icon: isPinned ? star_filled : star_empty,
12469 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
12470 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
12471 isPressed: isPinned,
12472 "aria-expanded": isPinned,
12473 size: "compact"
12474 })]
12475 })
12476 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Panel, {
12477 className: panelClassName,
12478 children: children
12479 })]
12480 })]
12481 });
12482 }
12483 ComplementaryArea.Slot = ComplementaryAreaSlot;
12484 /* harmony default export */ const complementary_area = (ComplementaryArea);
12485
12486 ;// ./packages/interface/build-module/components/fullscreen-mode/index.js
12487 /**
12488 * WordPress dependencies
12489 */
12490
12491 const FullscreenMode = ({
12492 isActive
12493 }) => {
12494 (0,external_wp_element_namespaceObject.useEffect)(() => {
12495 let isSticky = false;
12496 // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
12497 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
12498 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
12499 // a consequence of the FullscreenMode setup.
12500 if (document.body.classList.contains('sticky-menu')) {
12501 isSticky = true;
12502 document.body.classList.remove('sticky-menu');
12503 }
12504 return () => {
12505 if (isSticky) {
12506 document.body.classList.add('sticky-menu');
12507 }
12508 };
12509 }, []);
12510 (0,external_wp_element_namespaceObject.useEffect)(() => {
12511 if (isActive) {
12512 document.body.classList.add('is-fullscreen-mode');
12513 } else {
12514 document.body.classList.remove('is-fullscreen-mode');
12515 }
12516 return () => {
12517 if (isActive) {
12518 document.body.classList.remove('is-fullscreen-mode');
12519 }
12520 };
12521 }, [isActive]);
12522 return null;
12523 };
12524 /* harmony default export */ const fullscreen_mode = (FullscreenMode);
12525
12526 ;// ./packages/interface/build-module/components/navigable-region/index.js
12527 /**
12528 * WordPress dependencies
12529 */
12530
12531
12532 /**
12533 * External dependencies
12534 */
12535
12536
12537 const NavigableRegion = (0,external_wp_element_namespaceObject.forwardRef)(({
12538 children,
12539 className,
12540 ariaLabel,
12541 as: Tag = 'div',
12542 ...props
12543 }, ref) => {
12544 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tag, {
12545 ref: ref,
12546 className: dist_clsx('interface-navigable-region', className),
12547 "aria-label": ariaLabel,
12548 role: "region",
12549 tabIndex: "-1",
12550 ...props,
12551 children: children
12552 });
12553 });
12554 NavigableRegion.displayName = 'NavigableRegion';
12555 /* harmony default export */ const navigable_region = (NavigableRegion);
12556
12557 ;// ./packages/interface/build-module/components/interface-skeleton/index.js
12558 /**
12559 * External dependencies
12560 */
12561
12562
12563 /**
12564 * WordPress dependencies
12565 */
12566
12567
12568
12569
12570
12571 /**
12572 * Internal dependencies
12573 */
12574
12575
12576 const interface_skeleton_ANIMATION_DURATION = 0.25;
12577 const commonTransition = {
12578 type: 'tween',
12579 duration: interface_skeleton_ANIMATION_DURATION,
12580 ease: [0.6, 0, 0.4, 1]
12581 };
12582 function useHTMLClass(className) {
12583 (0,external_wp_element_namespaceObject.useEffect)(() => {
12584 const element = document && document.querySelector(`html:not(.${className})`);
12585 if (!element) {
12586 return;
12587 }
12588 element.classList.toggle(className);
12589 return () => {
12590 element.classList.toggle(className);
12591 };
12592 }, [className]);
12593 }
12594 const headerVariants = {
12595 hidden: {
12596 opacity: 1,
12597 marginTop: -60
12598 },
12599 visible: {
12600 opacity: 1,
12601 marginTop: 0
12602 },
12603 distractionFreeHover: {
12604 opacity: 1,
12605 marginTop: 0,
12606 transition: {
12607 ...commonTransition,
12608 delay: 0.2,
12609 delayChildren: 0.2
12610 }
12611 },
12612 distractionFreeHidden: {
12613 opacity: 0,
12614 marginTop: -60
12615 },
12616 distractionFreeDisabled: {
12617 opacity: 0,
12618 marginTop: 0,
12619 transition: {
12620 ...commonTransition,
12621 delay: 0.8,
12622 delayChildren: 0.8
12623 }
12624 }
12625 };
12626 function InterfaceSkeleton({
12627 isDistractionFree,
12628 footer,
12629 header,
12630 editorNotices,
12631 sidebar,
12632 secondarySidebar,
12633 content,
12634 actions,
12635 labels,
12636 className
12637 }, ref) {
12638 const [secondarySidebarResizeListener, secondarySidebarSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
12639 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
12640 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
12641 const defaultTransition = {
12642 type: 'tween',
12643 duration: disableMotion ? 0 : interface_skeleton_ANIMATION_DURATION,
12644 ease: [0.6, 0, 0.4, 1]
12645 };
12646 useHTMLClass('interface-interface-skeleton__html-container');
12647 const defaultLabels = {
12648 /* translators: accessibility text for the top bar landmark region. */
12649 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'),
12650 /* translators: accessibility text for the content landmark region. */
12651 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
12652 /* translators: accessibility text for the secondary sidebar landmark region. */
12653 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
12654 /* translators: accessibility text for the settings landmark region. */
12655 sidebar: (0,external_wp_i18n_namespaceObject._x)('Settings', 'settings landmark area'),
12656 /* translators: accessibility text for the publish landmark region. */
12657 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
12658 /* translators: accessibility text for the footer landmark region. */
12659 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
12660 };
12661 const mergedLabels = {
12662 ...defaultLabels,
12663 ...labels
12664 };
12665 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12666 ref: ref,
12667 className: dist_clsx(className, 'interface-interface-skeleton', !!footer && 'has-footer'),
12668 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12669 className: "interface-interface-skeleton__editor",
12670 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
12671 initial: false,
12672 children: !!header && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12673 as: external_wp_components_namespaceObject.__unstableMotion.div,
12674 className: "interface-interface-skeleton__header",
12675 "aria-label": mergedLabels.header,
12676 initial: isDistractionFree && !isMobileViewport ? 'distractionFreeHidden' : 'hidden',
12677 whileHover: isDistractionFree && !isMobileViewport ? 'distractionFreeHover' : 'visible',
12678 animate: isDistractionFree && !isMobileViewport ? 'distractionFreeDisabled' : 'visible',
12679 exit: isDistractionFree && !isMobileViewport ? 'distractionFreeHidden' : 'hidden',
12680 variants: headerVariants,
12681 transition: defaultTransition,
12682 children: header
12683 })
12684 }), isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12685 className: "interface-interface-skeleton__header",
12686 children: editorNotices
12687 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12688 className: "interface-interface-skeleton__body",
12689 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
12690 initial: false,
12691 children: !!secondarySidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12692 className: "interface-interface-skeleton__secondary-sidebar",
12693 ariaLabel: mergedLabels.secondarySidebar,
12694 as: external_wp_components_namespaceObject.__unstableMotion.div,
12695 initial: "closed",
12696 animate: "open",
12697 exit: "closed",
12698 variants: {
12699 open: {
12700 width: secondarySidebarSize.width
12701 },
12702 closed: {
12703 width: 0
12704 }
12705 },
12706 transition: defaultTransition,
12707 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
12708 style: {
12709 position: 'absolute',
12710 width: isMobileViewport ? '100vw' : 'fit-content',
12711 height: '100%',
12712 left: 0
12713 },
12714 variants: {
12715 open: {
12716 x: 0
12717 },
12718 closed: {
12719 x: '-100%'
12720 }
12721 },
12722 transition: defaultTransition,
12723 children: [secondarySidebarResizeListener, secondarySidebar]
12724 })
12725 })
12726 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12727 className: "interface-interface-skeleton__content",
12728 ariaLabel: mergedLabels.body,
12729 children: content
12730 }), !!sidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12731 className: "interface-interface-skeleton__sidebar",
12732 ariaLabel: mergedLabels.sidebar,
12733 children: sidebar
12734 }), !!actions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12735 className: "interface-interface-skeleton__actions",
12736 ariaLabel: mergedLabels.actions,
12737 children: actions
12738 })]
12739 })]
12740 }), !!footer && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(navigable_region, {
12741 className: "interface-interface-skeleton__footer",
12742 ariaLabel: mergedLabels.footer,
12743 children: footer
12744 })]
12745 });
12746 }
12747 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
12748
12749 ;// ./packages/interface/build-module/components/index.js
12750
12751
12752
12753
12754
12755
12756
12757
12758 ;// ./packages/interface/build-module/index.js
12759
12760
12761
12762 ;// ./packages/editor/build-module/components/global-keyboard-shortcuts/index.js
12763 /**
12764 * WordPress dependencies
12765 */
12766
12767
12768
12769
12770
12771 /**
12772 * Internal dependencies
12773 */
12774
12775
12776 /**
12777 * Handles the keyboard shortcuts for the editor.
12778 *
12779 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
12780 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
12781 * and toggling the sidebar.
12782 */
12783 function EditorKeyboardShortcuts() {
12784 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
12785 const {
12786 richEditingEnabled,
12787 codeEditingEnabled
12788 } = select(store_store).getEditorSettings();
12789 return !richEditingEnabled || !codeEditingEnabled;
12790 }, []);
12791 const {
12792 getBlockSelectionStart
12793 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
12794 const {
12795 getActiveComplementaryArea
12796 } = (0,external_wp_data_namespaceObject.useSelect)(store);
12797 const {
12798 enableComplementaryArea,
12799 disableComplementaryArea
12800 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12801 const {
12802 redo,
12803 undo,
12804 savePost,
12805 setIsListViewOpened,
12806 switchEditorMode,
12807 toggleDistractionFree
12808 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12809 const {
12810 isEditedPostDirty,
12811 isPostSavingLocked,
12812 isListViewOpened,
12813 getEditorMode
12814 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
12815 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-mode', () => {
12816 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
12817 }, {
12818 isDisabled: isModeToggleDisabled
12819 });
12820 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-distraction-free', () => {
12821 toggleDistractionFree();
12822 });
12823 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
12824 undo();
12825 event.preventDefault();
12826 });
12827 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
12828 redo();
12829 event.preventDefault();
12830 });
12831 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
12832 event.preventDefault();
12833
12834 /**
12835 * Do not save the post if post saving is locked.
12836 */
12837 if (isPostSavingLocked()) {
12838 return;
12839 }
12840
12841 // TODO: This should be handled in the `savePost` effect in
12842 // considering `isSaveable`. See note on `isEditedPostSaveable`
12843 // selector about dirtiness and meta-boxes.
12844 //
12845 // See: `isEditedPostSaveable`
12846 if (!isEditedPostDirty()) {
12847 return;
12848 }
12849 savePost();
12850 });
12851
12852 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
12853 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => {
12854 if (!isListViewOpened()) {
12855 event.preventDefault();
12856 setIsListViewOpened(true);
12857 }
12858 });
12859 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-sidebar', event => {
12860 // This shortcut has no known clashes, but use preventDefault to prevent any
12861 // obscure shortcuts from triggering.
12862 event.preventDefault();
12863 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(getActiveComplementaryArea('core'));
12864 if (isEditorSidebarOpened) {
12865 disableComplementaryArea('core');
12866 } else {
12867 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
12868 enableComplementaryArea('core', sidebarToOpen);
12869 }
12870 });
12871 return null;
12872 }
12873
12874 ;// ./packages/editor/build-module/components/autocompleters/index.js
12875
12876
12877 ;// ./packages/editor/build-module/components/autosave-monitor/index.js
12878 /**
12879 * WordPress dependencies
12880 */
12881
12882
12883
12884
12885
12886 /**
12887 * Internal dependencies
12888 */
12889
12890 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
12891 constructor(props) {
12892 super(props);
12893 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
12894 }
12895 componentDidMount() {
12896 if (!this.props.disableIntervalChecks) {
12897 this.setAutosaveTimer();
12898 }
12899 }
12900 componentDidUpdate(prevProps) {
12901 if (this.props.disableIntervalChecks) {
12902 if (this.props.editsReference !== prevProps.editsReference) {
12903 this.props.autosave();
12904 }
12905 return;
12906 }
12907 if (this.props.interval !== prevProps.interval) {
12908 clearTimeout(this.timerId);
12909 this.setAutosaveTimer();
12910 }
12911 if (!this.props.isDirty) {
12912 this.needsAutosave = false;
12913 return;
12914 }
12915 if (this.props.isAutosaving && !prevProps.isAutosaving) {
12916 this.needsAutosave = false;
12917 return;
12918 }
12919 if (this.props.editsReference !== prevProps.editsReference) {
12920 this.needsAutosave = true;
12921 }
12922 }
12923 componentWillUnmount() {
12924 clearTimeout(this.timerId);
12925 }
12926 setAutosaveTimer(timeout = this.props.interval * 1000) {
12927 this.timerId = setTimeout(() => {
12928 this.autosaveTimerHandler();
12929 }, timeout);
12930 }
12931 autosaveTimerHandler() {
12932 if (!this.props.isAutosaveable) {
12933 this.setAutosaveTimer(1000);
12934 return;
12935 }
12936 if (this.needsAutosave) {
12937 this.needsAutosave = false;
12938 this.props.autosave();
12939 }
12940 this.setAutosaveTimer();
12941 }
12942 render() {
12943 return null;
12944 }
12945 }
12946
12947 /**
12948 * Monitors the changes made to the edited post and triggers autosave if necessary.
12949 *
12950 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
12951 * 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
12952 * the specific way of detecting changes.
12953 *
12954 * There are two caveats:
12955 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
12956 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
12957 *
12958 * @param {Object} props - The properties passed to the component.
12959 * @param {Function} props.autosave - The function to call when changes need to be saved.
12960 * @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
12961 * @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
12962 * @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
12963 * @param {boolean} props.isDirty - Indicates if there are unsaved changes.
12964 *
12965 * @example
12966 * ```jsx
12967 * <AutosaveMonitor interval={30000} />
12968 * ```
12969 */
12970 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
12971 const {
12972 getReferenceByDistinctEdits
12973 } = select(external_wp_coreData_namespaceObject.store);
12974 const {
12975 isEditedPostDirty,
12976 isEditedPostAutosaveable,
12977 isAutosavingPost,
12978 getEditorSettings
12979 } = select(store_store);
12980 const {
12981 interval = getEditorSettings().autosaveInterval
12982 } = ownProps;
12983 return {
12984 editsReference: getReferenceByDistinctEdits(),
12985 isDirty: isEditedPostDirty(),
12986 isAutosaveable: isEditedPostAutosaveable(),
12987 isAutosaving: isAutosavingPost(),
12988 interval
12989 };
12990 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
12991 autosave() {
12992 const {
12993 autosave = dispatch(store_store).autosave
12994 } = ownProps;
12995 autosave();
12996 }
12997 }))])(AutosaveMonitor));
12998
12999 ;// ./packages/icons/build-module/library/chevron-right-small.js
13000 /**
13001 * WordPress dependencies
13002 */
13003
13004
13005 const chevronRightSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13006 xmlns: "http://www.w3.org/2000/svg",
13007 viewBox: "0 0 24 24",
13008 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13009 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
13010 })
13011 });
13012 /* harmony default export */ const chevron_right_small = (chevronRightSmall);
13013
13014 ;// ./packages/icons/build-module/library/chevron-left-small.js
13015 /**
13016 * WordPress dependencies
13017 */
13018
13019
13020 const chevronLeftSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13021 xmlns: "http://www.w3.org/2000/svg",
13022 viewBox: "0 0 24 24",
13023 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13024 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
13025 })
13026 });
13027 /* harmony default export */ const chevron_left_small = (chevronLeftSmall);
13028
13029 ;// external ["wp","keycodes"]
13030 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
13031 ;// external ["wp","commands"]
13032 const external_wp_commands_namespaceObject = window["wp"]["commands"];
13033 ;// external ["wp","dom"]
13034 const external_wp_dom_namespaceObject = window["wp"]["dom"];
13035 ;// ./packages/editor/build-module/utils/pageTypeBadge.js
13036 /**
13037 * WordPress dependencies
13038 */
13039
13040
13041
13042
13043 /**
13044 * Custom hook to get the page type badge for the current post on edit site view.
13045 *
13046 * @param {number|string} postId postId of the current post being edited.
13047 */
13048 function usePageTypeBadge(postId) {
13049 const {
13050 isFrontPage,
13051 isPostsPage
13052 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13053 const {
13054 canUser,
13055 getEditedEntityRecord
13056 } = select(external_wp_coreData_namespaceObject.store);
13057 const siteSettings = canUser('read', {
13058 kind: 'root',
13059 name: 'site'
13060 }) ? getEditedEntityRecord('root', 'site') : undefined;
13061 const _postId = parseInt(postId, 10);
13062 return {
13063 isFrontPage: siteSettings?.page_on_front === _postId,
13064 isPostsPage: siteSettings?.page_for_posts === _postId
13065 };
13066 });
13067 if (isFrontPage) {
13068 return (0,external_wp_i18n_namespaceObject.__)('Homepage');
13069 } else if (isPostsPage) {
13070 return (0,external_wp_i18n_namespaceObject.__)('Posts Page');
13071 }
13072 return false;
13073 }
13074
13075 ;// ./packages/editor/build-module/components/document-bar/index.js
13076 /**
13077 * External dependencies
13078 */
13079
13080
13081 /**
13082 * WordPress dependencies
13083 */
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097 /**
13098 * Internal dependencies
13099 */
13100
13101
13102
13103
13104
13105 /** @typedef {import("@wordpress/components").IconType} IconType */
13106
13107 const MotionButton = (0,external_wp_components_namespaceObject.__unstableMotion)(external_wp_components_namespaceObject.Button);
13108
13109 /**
13110 * This component renders a navigation bar at the top of the editor. It displays the title of the current document,
13111 * a back button (if applicable), and a command center button. It also handles different states of the document,
13112 * such as "not found" or "unsynced".
13113 *
13114 * @example
13115 * ```jsx
13116 * <DocumentBar />
13117 * ```
13118 * @param {Object} props The component props.
13119 * @param {string} props.title A title for the document, defaulting to the document or
13120 * template title currently being edited.
13121 * @param {IconType} props.icon An icon for the document, no default.
13122 * (A default icon indicating the document post type is no longer used.)
13123 *
13124 * @return {React.ReactNode} The rendered DocumentBar component.
13125 */
13126 function DocumentBar(props) {
13127 const {
13128 postId,
13129 postType,
13130 postTypeLabel,
13131 documentTitle,
13132 isNotFound,
13133 templateTitle,
13134 onNavigateToPreviousEntityRecord,
13135 isTemplatePreview
13136 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13137 var _select$getEntityReco;
13138 const {
13139 getCurrentPostType,
13140 getCurrentPostId,
13141 getEditorSettings,
13142 getRenderingMode
13143 } = select(store_store);
13144 const {
13145 getEditedEntityRecord,
13146 getPostType,
13147 isResolving: isResolvingSelector
13148 } = select(external_wp_coreData_namespaceObject.store);
13149 const _postType = getCurrentPostType();
13150 const _postId = getCurrentPostId();
13151 const _document = getEditedEntityRecord('postType', _postType, _postId);
13152 const {
13153 default_template_types: templateTypes = []
13154 } = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : {};
13155 const _templateInfo = getTemplateInfo({
13156 templateTypes,
13157 template: _document
13158 });
13159 const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
13160 return {
13161 postId: _postId,
13162 postType: _postType,
13163 postTypeLabel: _postTypeLabel,
13164 documentTitle: _document.title,
13165 isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
13166 templateTitle: _templateInfo.title,
13167 onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord,
13168 isTemplatePreview: getRenderingMode() === 'template-locked'
13169 };
13170 }, []);
13171 const {
13172 open: openCommandCenter
13173 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store);
13174 const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
13175 const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
13176 const hasBackButton = !!onNavigateToPreviousEntityRecord;
13177 const entityTitle = isTemplate ? templateTitle : documentTitle;
13178 const title = props.title || entityTitle;
13179 const icon = props.icon;
13180 const pageTypeBadge = usePageTypeBadge(postId);
13181 const mountedRef = (0,external_wp_element_namespaceObject.useRef)(false);
13182 (0,external_wp_element_namespaceObject.useEffect)(() => {
13183 mountedRef.current = true;
13184 }, []);
13185 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13186 className: dist_clsx('editor-document-bar', {
13187 'has-back-button': hasBackButton
13188 }),
13189 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
13190 children: hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MotionButton, {
13191 className: "editor-document-bar__back",
13192 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small,
13193 onClick: event => {
13194 event.stopPropagation();
13195 onNavigateToPreviousEntityRecord();
13196 },
13197 size: "compact",
13198 initial: mountedRef.current ? {
13199 opacity: 0,
13200 transform: 'translateX(15%)'
13201 } : false // Don't show entry animation when DocumentBar mounts.
13202 ,
13203 animate: {
13204 opacity: 1,
13205 transform: 'translateX(0%)'
13206 },
13207 exit: {
13208 opacity: 0,
13209 transform: 'translateX(15%)'
13210 },
13211 transition: isReducedMotion ? {
13212 duration: 0
13213 } : undefined,
13214 children: (0,external_wp_i18n_namespaceObject.__)('Back')
13215 })
13216 }), !isTemplate && isTemplatePreview && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
13217 icon: library_layout,
13218 className: "editor-document-bar__icon-layout"
13219 }), isNotFound ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
13220 children: (0,external_wp_i18n_namespaceObject.__)('Document not found')
13221 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
13222 className: "editor-document-bar__command",
13223 onClick: () => openCommandCenter(),
13224 size: "compact",
13225 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
13226 className: "editor-document-bar__title"
13227 // Force entry animation when the back button is added or removed.
13228 ,
13229
13230 initial: mountedRef.current ? {
13231 opacity: 0,
13232 transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
13233 } : false // Don't show entry animation when DocumentBar mounts.
13234 ,
13235 animate: {
13236 opacity: 1,
13237 transform: 'translateX(0%)'
13238 },
13239 transition: isReducedMotion ? {
13240 duration: 0
13241 } : undefined,
13242 children: [icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
13243 icon: icon
13244 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
13245 size: "body",
13246 as: "h1",
13247 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13248 className: "editor-document-bar__post-title",
13249 children: title ? (0,external_wp_dom_namespaceObject.__unstableStripHTML)(title) : (0,external_wp_i18n_namespaceObject.__)('No title')
13250 }), pageTypeBadge && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13251 className: "editor-document-bar__post-type-label",
13252 children: `· ${pageTypeBadge}`
13253 }), postTypeLabel && !props.title && !pageTypeBadge && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13254 className: "editor-document-bar__post-type-label",
13255 children: `· ${(0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postTypeLabel)}`
13256 })]
13257 })]
13258 }, hasBackButton), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13259 className: "editor-document-bar__shortcut",
13260 children: external_wp_keycodes_namespaceObject.displayShortcut.primary('k')
13261 })]
13262 })]
13263 });
13264 }
13265
13266 ;// external ["wp","richText"]
13267 const external_wp_richText_namespaceObject = window["wp"]["richText"];
13268 ;// ./packages/editor/build-module/components/document-outline/item.js
13269 /**
13270 * External dependencies
13271 */
13272
13273
13274 const TableOfContentsItem = ({
13275 children,
13276 isValid,
13277 level,
13278 href,
13279 onSelect
13280 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
13281 className: dist_clsx('document-outline__item', `is-${level.toLowerCase()}`, {
13282 'is-invalid': !isValid
13283 }),
13284 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("a", {
13285 href: href,
13286 className: "document-outline__button",
13287 onClick: onSelect,
13288 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13289 className: "document-outline__emdash",
13290 "aria-hidden": "true"
13291 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
13292 className: "document-outline__level",
13293 children: level
13294 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
13295 className: "document-outline__item-content",
13296 children: children
13297 })]
13298 })
13299 });
13300 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
13301
13302 ;// ./packages/editor/build-module/components/document-outline/index.js
13303 /* wp:polyfill */
13304 /**
13305 * WordPress dependencies
13306 */
13307
13308
13309
13310
13311
13312
13313
13314
13315 /**
13316 * Internal dependencies
13317 */
13318
13319
13320
13321 /**
13322 * Module constants
13323 */
13324
13325 const emptyHeadingContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
13326 children: (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')
13327 });
13328 const incorrectLevelContent = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
13329 children: (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)')
13330 }, "incorrect-message")];
13331 const singleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
13332 children: (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)')
13333 }, "incorrect-message-h1")];
13334 const multipleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-multiple-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
13335 children: (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)')
13336 }, "incorrect-message-multiple-h1")];
13337 function EmptyOutlineIllustration() {
13338 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
13339 width: "138",
13340 height: "148",
13341 viewBox: "0 0 138 148",
13342 fill: "none",
13343 xmlns: "http://www.w3.org/2000/svg",
13344 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
13345 width: "138",
13346 height: "148",
13347 rx: "4",
13348 fill: "#F0F6FC"
13349 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
13350 x1: "44",
13351 y1: "28",
13352 x2: "24",
13353 y2: "28",
13354 stroke: "#DDDDDD"
13355 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
13356 x: "48",
13357 y: "16",
13358 width: "27",
13359 height: "23",
13360 rx: "4",
13361 fill: "#DDDDDD"
13362 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13363 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",
13364 fill: "black"
13365 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
13366 x1: "55",
13367 y1: "59",
13368 x2: "24",
13369 y2: "59",
13370 stroke: "#DDDDDD"
13371 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
13372 x: "59",
13373 y: "47",
13374 width: "29",
13375 height: "23",
13376 rx: "4",
13377 fill: "#DDDDDD"
13378 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13379 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",
13380 fill: "black"
13381 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
13382 x1: "80",
13383 y1: "90",
13384 x2: "24",
13385 y2: "90",
13386 stroke: "#DDDDDD"
13387 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
13388 x: "84",
13389 y: "78",
13390 width: "30",
13391 height: "23",
13392 rx: "4",
13393 fill: "#F0B849"
13394 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13395 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",
13396 fill: "black"
13397 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
13398 x1: "66",
13399 y1: "121",
13400 x2: "24",
13401 y2: "121",
13402 stroke: "#DDDDDD"
13403 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
13404 x: "70",
13405 y: "109",
13406 width: "29",
13407 height: "23",
13408 rx: "4",
13409 fill: "#DDDDDD"
13410 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13411 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",
13412 fill: "black"
13413 })]
13414 });
13415 }
13416
13417 /**
13418 * Returns an array of heading blocks enhanced with the following properties:
13419 * level - An integer with the heading level.
13420 * isEmpty - Flag indicating if the heading has no content.
13421 *
13422 * @param {?Array} blocks An array of blocks.
13423 *
13424 * @return {Array} An array of heading blocks enhanced with the properties described above.
13425 */
13426 const computeOutlineHeadings = (blocks = []) => {
13427 return blocks.flatMap((block = {}) => {
13428 if (block.name === 'core/heading') {
13429 return {
13430 ...block,
13431 level: block.attributes.level,
13432 isEmpty: isEmptyHeading(block)
13433 };
13434 }
13435 return computeOutlineHeadings(block.innerBlocks);
13436 });
13437 };
13438 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.trim().length === 0;
13439
13440 /**
13441 * Renders a document outline component.
13442 *
13443 * @param {Object} props Props.
13444 * @param {Function} props.onSelect Function to be called when an outline item is selected
13445 * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
13446 *
13447 * @return {React.ReactNode} The rendered component.
13448 */
13449 function DocumentOutline({
13450 onSelect,
13451 hasOutlineItemsDisabled
13452 }) {
13453 const {
13454 selectBlock
13455 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
13456 const {
13457 blocks,
13458 title,
13459 isTitleSupported
13460 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13461 var _postType$supports$ti;
13462 const {
13463 getBlocks
13464 } = select(external_wp_blockEditor_namespaceObject.store);
13465 const {
13466 getEditedPostAttribute
13467 } = select(store_store);
13468 const {
13469 getPostType
13470 } = select(external_wp_coreData_namespaceObject.store);
13471 const postType = getPostType(getEditedPostAttribute('type'));
13472 return {
13473 title: getEditedPostAttribute('title'),
13474 blocks: getBlocks(),
13475 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
13476 };
13477 });
13478 const prevHeadingLevelRef = (0,external_wp_element_namespaceObject.useRef)(1);
13479 const headings = computeOutlineHeadings(blocks);
13480 if (headings.length < 1) {
13481 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13482 className: "editor-document-outline has-no-headings",
13483 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyOutlineIllustration, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13484 children: (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.')
13485 })]
13486 });
13487 }
13488
13489 // Not great but it's the simplest way to locate the title right now.
13490 const titleNode = document.querySelector('.editor-post-title__input');
13491 const hasTitle = isTitleSupported && title && titleNode;
13492 const countByLevel = headings.reduce((acc, heading) => ({
13493 ...acc,
13494 [heading.level]: (acc[heading.level] || 0) + 1
13495 }), {});
13496 const hasMultipleH1 = countByLevel[1] > 1;
13497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
13498 className: "document-outline",
13499 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
13500 children: [hasTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_outline_item, {
13501 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
13502 isValid: true,
13503 onSelect: onSelect,
13504 href: `#${titleNode.id}`,
13505 isDisabled: hasOutlineItemsDisabled,
13506 children: title
13507 }), headings.map((item, index) => {
13508 // Headings remain the same, go up by one, or down by any amount.
13509 // Otherwise there are missing levels.
13510 const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1;
13511 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
13512 prevHeadingLevelRef.current = item.level;
13513 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(document_outline_item, {
13514 level: `H${item.level}`,
13515 isValid: isValid,
13516 isDisabled: hasOutlineItemsDisabled,
13517 href: `#block-${item.clientId}`,
13518 onSelect: () => {
13519 selectBlock(item.clientId);
13520 onSelect?.();
13521 },
13522 children: [item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
13523 html: item.attributes.content
13524 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
13525 }, index);
13526 })]
13527 })
13528 });
13529 }
13530
13531 ;// ./packages/editor/build-module/components/document-outline/check.js
13532 /**
13533 * WordPress dependencies
13534 */
13535
13536
13537
13538 /**
13539 * Component check if there are any headings (core/heading blocks) present in the document.
13540 *
13541 * @param {Object} props Props.
13542 * @param {React.ReactElement} props.children Children to be rendered.
13543 *
13544 * @return {React.ReactElement} The component to be rendered or null if there are headings.
13545 */
13546 function DocumentOutlineCheck({
13547 children
13548 }) {
13549 const hasHeadings = (0,external_wp_data_namespaceObject.useSelect)(select => {
13550 const {
13551 getGlobalBlockCount
13552 } = select(external_wp_blockEditor_namespaceObject.store);
13553 return getGlobalBlockCount('core/heading') > 0;
13554 });
13555 if (!hasHeadings) {
13556 return null;
13557 }
13558 return children;
13559 }
13560
13561 ;// ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
13562 /**
13563 * WordPress dependencies
13564 */
13565
13566
13567
13568
13569
13570
13571
13572 /**
13573 * Component for registering editor keyboard shortcuts.
13574 *
13575 * @return {Element} The component to be rendered.
13576 */
13577
13578 function EditorKeyboardShortcutsRegister() {
13579 // Registering the shortcuts.
13580 const {
13581 registerShortcut
13582 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
13583 (0,external_wp_element_namespaceObject.useEffect)(() => {
13584 registerShortcut({
13585 name: 'core/editor/toggle-mode',
13586 category: 'global',
13587 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
13588 keyCombination: {
13589 modifier: 'secondary',
13590 character: 'm'
13591 }
13592 });
13593 registerShortcut({
13594 name: 'core/editor/save',
13595 category: 'global',
13596 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
13597 keyCombination: {
13598 modifier: 'primary',
13599 character: 's'
13600 }
13601 });
13602 registerShortcut({
13603 name: 'core/editor/undo',
13604 category: 'global',
13605 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
13606 keyCombination: {
13607 modifier: 'primary',
13608 character: 'z'
13609 }
13610 });
13611 registerShortcut({
13612 name: 'core/editor/redo',
13613 category: 'global',
13614 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
13615 keyCombination: {
13616 modifier: 'primaryShift',
13617 character: 'z'
13618 },
13619 // Disable on Apple OS because it conflicts with the browser's
13620 // history shortcut. It's a fine alias for both Windows and Linux.
13621 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
13622 // Linux, we keep it as the default for consistency.
13623 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{
13624 modifier: 'primary',
13625 character: 'y'
13626 }]
13627 });
13628 registerShortcut({
13629 name: 'core/editor/toggle-list-view',
13630 category: 'global',
13631 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the List View.'),
13632 keyCombination: {
13633 modifier: 'access',
13634 character: 'o'
13635 }
13636 });
13637 registerShortcut({
13638 name: 'core/editor/toggle-distraction-free',
13639 category: 'global',
13640 description: (0,external_wp_i18n_namespaceObject.__)('Enter or exit distraction free mode.'),
13641 keyCombination: {
13642 modifier: 'primaryShift',
13643 character: '\\'
13644 }
13645 });
13646 registerShortcut({
13647 name: 'core/editor/toggle-sidebar',
13648 category: 'global',
13649 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings panel.'),
13650 keyCombination: {
13651 modifier: 'primaryShift',
13652 character: ','
13653 }
13654 });
13655 registerShortcut({
13656 name: 'core/editor/keyboard-shortcuts',
13657 category: 'main',
13658 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
13659 keyCombination: {
13660 modifier: 'access',
13661 character: 'h'
13662 }
13663 });
13664 registerShortcut({
13665 name: 'core/editor/next-region',
13666 category: 'global',
13667 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
13668 keyCombination: {
13669 modifier: 'ctrl',
13670 character: '`'
13671 },
13672 aliases: [{
13673 modifier: 'access',
13674 character: 'n'
13675 }]
13676 });
13677 registerShortcut({
13678 name: 'core/editor/previous-region',
13679 category: 'global',
13680 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
13681 keyCombination: {
13682 modifier: 'ctrlShift',
13683 character: '`'
13684 },
13685 aliases: [{
13686 modifier: 'access',
13687 character: 'p'
13688 }, {
13689 modifier: 'ctrlShift',
13690 character: '~'
13691 }]
13692 });
13693 }, [registerShortcut]);
13694 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, {});
13695 }
13696 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
13697
13698 ;// ./packages/icons/build-module/library/redo.js
13699 /**
13700 * WordPress dependencies
13701 */
13702
13703
13704 const redo_redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13705 xmlns: "http://www.w3.org/2000/svg",
13706 viewBox: "0 0 24 24",
13707 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13708 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"
13709 })
13710 });
13711 /* harmony default export */ const library_redo = (redo_redo);
13712
13713 ;// ./packages/icons/build-module/library/undo.js
13714 /**
13715 * WordPress dependencies
13716 */
13717
13718
13719 const undo_undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13720 xmlns: "http://www.w3.org/2000/svg",
13721 viewBox: "0 0 24 24",
13722 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13723 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"
13724 })
13725 });
13726 /* harmony default export */ const library_undo = (undo_undo);
13727
13728 ;// ./packages/editor/build-module/components/editor-history/redo.js
13729 /**
13730 * WordPress dependencies
13731 */
13732
13733
13734
13735
13736
13737
13738
13739 /**
13740 * Internal dependencies
13741 */
13742
13743
13744 function EditorHistoryRedo(props, ref) {
13745 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
13746 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
13747 const {
13748 redo
13749 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13750 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13751 __next40pxDefaultSize: true,
13752 ...props,
13753 ref: ref,
13754 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
13755 /* translators: button label text should, if possible, be under 16 characters. */,
13756 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
13757 shortcut: shortcut
13758 // If there are no redo levels we don't want to actually disable this
13759 // button, because it will remove focus for keyboard users.
13760 // See: https://github.com/WordPress/gutenberg/issues/3486
13761 ,
13762 "aria-disabled": !hasRedo,
13763 onClick: hasRedo ? redo : undefined,
13764 className: "editor-history__redo"
13765 });
13766 }
13767
13768 /** @typedef {import('react').Ref<HTMLElement>} Ref */
13769
13770 /**
13771 * Renders the redo button for the editor history.
13772 *
13773 * @param {Object} props - Props.
13774 * @param {Ref} ref - Forwarded ref.
13775 *
13776 * @return {React.ReactNode} The rendered component.
13777 */
13778 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
13779
13780 ;// ./packages/editor/build-module/components/editor-history/undo.js
13781 /**
13782 * WordPress dependencies
13783 */
13784
13785
13786
13787
13788
13789
13790
13791 /**
13792 * Internal dependencies
13793 */
13794
13795
13796 function EditorHistoryUndo(props, ref) {
13797 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
13798 const {
13799 undo
13800 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13801 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13802 __next40pxDefaultSize: true,
13803 ...props,
13804 ref: ref,
13805 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
13806 /* translators: button label text should, if possible, be under 16 characters. */,
13807 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
13808 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z')
13809 // If there are no undo levels we don't want to actually disable this
13810 // button, because it will remove focus for keyboard users.
13811 // See: https://github.com/WordPress/gutenberg/issues/3486
13812 ,
13813 "aria-disabled": !hasUndo,
13814 onClick: hasUndo ? undo : undefined,
13815 className: "editor-history__undo"
13816 });
13817 }
13818
13819 /** @typedef {import('react').Ref<HTMLElement>} Ref */
13820
13821 /**
13822 * Renders the undo button for the editor history.
13823 *
13824 * @param {Object} props - Props.
13825 * @param {Ref} ref - Forwarded ref.
13826 *
13827 * @return {React.ReactNode} The rendered component.
13828 */
13829 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
13830
13831 ;// ./packages/editor/build-module/components/template-validation-notice/index.js
13832 /**
13833 * WordPress dependencies
13834 */
13835
13836
13837
13838
13839
13840
13841 function TemplateValidationNotice() {
13842 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
13843 const isValid = (0,external_wp_data_namespaceObject.useSelect)(select => {
13844 return select(external_wp_blockEditor_namespaceObject.store).isValidTemplate();
13845 }, []);
13846 const {
13847 setTemplateValidity,
13848 synchronizeTemplate
13849 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
13850 if (isValid) {
13851 return null;
13852 }
13853 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13854 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
13855 className: "editor-template-validation-notice",
13856 isDismissible: false,
13857 status: "warning",
13858 actions: [{
13859 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
13860 onClick: () => setTemplateValidity(true)
13861 }, {
13862 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
13863 onClick: () => setShowConfirmDialog(true)
13864 }],
13865 children: (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')
13866 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
13867 isOpen: showConfirmDialog,
13868 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Reset'),
13869 onConfirm: () => {
13870 setShowConfirmDialog(false);
13871 synchronizeTemplate();
13872 },
13873 onCancel: () => setShowConfirmDialog(false),
13874 size: "medium",
13875 children: (0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?')
13876 })]
13877 });
13878 }
13879
13880 ;// ./packages/editor/build-module/components/editor-notices/index.js
13881 /* wp:polyfill */
13882 /**
13883 * WordPress dependencies
13884 */
13885
13886
13887
13888
13889 /**
13890 * Internal dependencies
13891 */
13892
13893
13894 /**
13895 * This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
13896 *
13897 * @example
13898 * ```jsx
13899 * <EditorNotices />
13900 * ```
13901 *
13902 * @return {React.ReactNode} The rendered EditorNotices component.
13903 */
13904
13905 function EditorNotices() {
13906 const {
13907 notices
13908 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
13909 notices: select(external_wp_notices_namespaceObject.store).getNotices()
13910 }), []);
13911 const {
13912 removeNotice
13913 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
13914 const dismissibleNotices = notices.filter(({
13915 isDismissible,
13916 type
13917 }) => isDismissible && type === 'default');
13918 const nonDismissibleNotices = notices.filter(({
13919 isDismissible,
13920 type
13921 }) => !isDismissible && type === 'default');
13922 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13923 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
13924 notices: nonDismissibleNotices,
13925 className: "components-editor-notices__pinned"
13926 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
13927 notices: dismissibleNotices,
13928 className: "components-editor-notices__dismissible",
13929 onRemove: removeNotice,
13930 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateValidationNotice, {})
13931 })]
13932 });
13933 }
13934 /* harmony default export */ const editor_notices = (EditorNotices);
13935
13936 ;// ./packages/editor/build-module/components/editor-snackbars/index.js
13937 /* wp:polyfill */
13938 /**
13939 * WordPress dependencies
13940 */
13941
13942
13943
13944
13945 // Last three notices. Slices from the tail end of the list.
13946
13947 const MAX_VISIBLE_NOTICES = -3;
13948
13949 /**
13950 * Renders the editor snackbars component.
13951 *
13952 * @return {React.ReactNode} The rendered component.
13953 */
13954 function EditorSnackbars() {
13955 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
13956 const {
13957 removeNotice
13958 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
13959 const snackbarNotices = notices.filter(({
13960 type
13961 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES);
13962 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SnackbarList, {
13963 notices: snackbarNotices,
13964 className: "components-editor-notices__snackbar",
13965 onRemove: removeNotice
13966 });
13967 }
13968
13969 ;// ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
13970 /**
13971 * WordPress dependencies
13972 */
13973
13974
13975
13976
13977
13978
13979 /**
13980 * Internal dependencies
13981 */
13982
13983
13984
13985
13986 function EntityRecordItem({
13987 record,
13988 checked,
13989 onChange
13990 }) {
13991 const {
13992 name,
13993 kind,
13994 title,
13995 key
13996 } = record;
13997
13998 // Handle templates that might use default descriptive titles.
13999 const {
14000 entityRecordTitle,
14001 hasPostMetaChanges
14002 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14003 var _select$getEntityReco;
14004 if ('postType' !== kind || 'wp_template' !== name) {
14005 return {
14006 entityRecordTitle: title,
14007 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
14008 };
14009 }
14010 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
14011 const {
14012 default_template_types: templateTypes = []
14013 } = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : {};
14014 return {
14015 entityRecordTitle: getTemplateInfo({
14016 template,
14017 templateTypes
14018 }).title,
14019 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
14020 };
14021 }, [name, kind, title, key]);
14022 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14023 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
14024 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
14025 __nextHasNoMarginBottom: true,
14026 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'),
14027 checked: checked,
14028 onChange: onChange
14029 })
14030 }), hasPostMetaChanges && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
14031 className: "entities-saved-states__changes",
14032 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
14033 children: (0,external_wp_i18n_namespaceObject.__)('Post Meta.')
14034 })
14035 })]
14036 });
14037 }
14038
14039 ;// ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
14040 /* wp:polyfill */
14041 /**
14042 * WordPress dependencies
14043 */
14044
14045
14046
14047
14048
14049
14050
14051 /**
14052 * Internal dependencies
14053 */
14054
14055
14056
14057 const {
14058 getGlobalStylesChanges,
14059 GlobalStylesContext
14060 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
14061 function getEntityDescription(entity, count) {
14062 switch (entity) {
14063 case 'site':
14064 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.');
14065 case 'wp_template':
14066 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
14067 case 'page':
14068 case 'post':
14069 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.');
14070 }
14071 }
14072 function GlobalStylesDescription({
14073 record
14074 }) {
14075 const {
14076 user: currentEditorGlobalStyles
14077 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
14078 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]);
14079 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, {
14080 maxResults: 10
14081 });
14082 return globalStylesChanges.length ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
14083 className: "entities-saved-states__changes",
14084 children: globalStylesChanges.map(change => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
14085 children: change
14086 }, change))
14087 }) : null;
14088 }
14089 function EntityDescription({
14090 record,
14091 count
14092 }) {
14093 if ('globalStyles' === record?.name) {
14094 return null;
14095 }
14096 const description = getEntityDescription(record?.name, count);
14097 return description ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
14098 children: description
14099 }) : null;
14100 }
14101 function EntityTypeList({
14102 list,
14103 unselectedEntities,
14104 setUnselectedEntities
14105 }) {
14106 const count = list.length;
14107 const firstRecord = list[0];
14108 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
14109 let entityLabel = entityConfig.label;
14110 if (firstRecord?.name === 'wp_template_part') {
14111 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
14112 }
14113 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
14114 title: entityLabel,
14115 initialOpen: true,
14116 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
14117 record: firstRecord,
14118 count: count
14119 }), list.map(record => {
14120 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
14121 record: record,
14122 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
14123 onChange: value => setUnselectedEntities(record, value)
14124 }, record.key || record.property);
14125 }), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
14126 record: firstRecord
14127 })]
14128 });
14129 }
14130
14131 ;// ./packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
14132 /* wp:polyfill */
14133 /**
14134 * WordPress dependencies
14135 */
14136
14137
14138
14139
14140 /**
14141 * Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
14142 *
14143 * @return {Object} An object containing the following properties:
14144 * - dirtyEntityRecords: An array of dirty entity records.
14145 * - isDirty: A boolean indicating if there are any dirty entity records.
14146 * - setUnselectedEntities: A function to set the unselected entities.
14147 * - unselectedEntities: An array of unselected entities.
14148 */
14149 const useIsDirty = () => {
14150 const {
14151 editedEntities,
14152 siteEdits,
14153 siteEntityConfig
14154 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14155 const {
14156 __experimentalGetDirtyEntityRecords,
14157 getEntityRecordEdits,
14158 getEntityConfig
14159 } = select(external_wp_coreData_namespaceObject.store);
14160 return {
14161 editedEntities: __experimentalGetDirtyEntityRecords(),
14162 siteEdits: getEntityRecordEdits('root', 'site'),
14163 siteEntityConfig: getEntityConfig('root', 'site')
14164 };
14165 }, []);
14166 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
14167 var _siteEntityConfig$met;
14168 // Remove site object and decouple into its edited pieces.
14169 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
14170 const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
14171 const editedSiteEntities = [];
14172 for (const property in siteEdits) {
14173 editedSiteEntities.push({
14174 kind: 'root',
14175 name: 'site',
14176 title: siteEntityLabels[property] || property,
14177 property
14178 });
14179 }
14180 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
14181 }, [editedEntities, siteEdits, siteEntityConfig]);
14182
14183 // Unchecked entities to be ignored by save function.
14184 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
14185 const setUnselectedEntities = ({
14186 kind,
14187 name,
14188 key,
14189 property
14190 }, checked) => {
14191 if (checked) {
14192 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
14193 } else {
14194 _setUnselectedEntities([...unselectedEntities, {
14195 kind,
14196 name,
14197 key,
14198 property
14199 }]);
14200 }
14201 };
14202 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
14203 return {
14204 dirtyEntityRecords,
14205 isDirty,
14206 setUnselectedEntities,
14207 unselectedEntities
14208 };
14209 };
14210
14211 ;// ./packages/editor/build-module/components/entities-saved-states/index.js
14212 /* wp:polyfill */
14213 /**
14214 * WordPress dependencies
14215 */
14216
14217
14218
14219
14220
14221
14222 /**
14223 * Internal dependencies
14224 */
14225
14226
14227
14228
14229
14230 function identity(values) {
14231 return values;
14232 }
14233
14234 /**
14235 * Renders the component for managing saved states of entities.
14236 *
14237 * @param {Object} props The component props.
14238 * @param {Function} props.close The function to close the dialog.
14239 * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.
14240 *
14241 * @return {React.ReactNode} The rendered component.
14242 */
14243 function EntitiesSavedStates({
14244 close,
14245 renderDialog
14246 }) {
14247 const isDirtyProps = useIsDirty();
14248 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
14249 close: close,
14250 renderDialog: renderDialog,
14251 ...isDirtyProps
14252 });
14253 }
14254
14255 /**
14256 * Renders a panel for saving entities with dirty records.
14257 *
14258 * @param {Object} props The component props.
14259 * @param {string} props.additionalPrompt Additional prompt to display.
14260 * @param {Function} props.close Function to close the panel.
14261 * @param {Function} props.onSave Function to call when saving entities.
14262 * @param {boolean} props.saveEnabled Flag indicating if save is enabled.
14263 * @param {string} props.saveLabel Label for the save button.
14264 * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.
14265 * @param {Array} props.dirtyEntityRecords Array of dirty entity records.
14266 * @param {boolean} props.isDirty Flag indicating if there are dirty entities.
14267 * @param {Function} props.setUnselectedEntities Function to set unselected entities.
14268 * @param {Array} props.unselectedEntities Array of unselected entities.
14269 *
14270 * @return {React.ReactNode} The rendered component.
14271 */
14272 function EntitiesSavedStatesExtensible({
14273 additionalPrompt = undefined,
14274 close,
14275 onSave = identity,
14276 saveEnabled: saveEnabledProp = undefined,
14277 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
14278 renderDialog,
14279 dirtyEntityRecords,
14280 isDirty,
14281 setUnselectedEntities,
14282 unselectedEntities
14283 }) {
14284 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
14285 const {
14286 saveDirtyEntities
14287 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
14288 // To group entities by type.
14289 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
14290 const {
14291 name
14292 } = record;
14293 if (!acc[name]) {
14294 acc[name] = [];
14295 }
14296 acc[name].push(record);
14297 return acc;
14298 }, {});
14299
14300 // Sort entity groups.
14301 const {
14302 site: siteSavables,
14303 wp_template: templateSavables,
14304 wp_template_part: templatePartSavables,
14305 ...contentSavables
14306 } = partitionedSavables;
14307 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
14308 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
14309 // Explicitly define this with no argument passed. Using `close` on
14310 // its own will use the event object in place of the expected saved entities.
14311 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
14312 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
14313 onClose: () => dismissPanel()
14314 });
14315 const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
14316 const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
14317 const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.') : undefined;
14318 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14319 ref: renderDialog ? saveDialogRef : undefined,
14320 ...(renderDialog && saveDialogProps),
14321 className: "entities-saved-states__panel",
14322 role: renderDialog ? 'dialog' : undefined,
14323 "aria-labelledby": renderDialog ? dialogLabel : undefined,
14324 "aria-describedby": renderDialog ? dialogDescription : undefined,
14325 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
14326 className: "entities-saved-states__panel-header",
14327 gap: 2,
14328 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
14329 isBlock: true,
14330 as: external_wp_components_namespaceObject.Button,
14331 variant: "secondary",
14332 size: "compact",
14333 onClick: dismissPanel,
14334 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
14335 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
14336 isBlock: true,
14337 as: external_wp_components_namespaceObject.Button,
14338 ref: saveButtonRef,
14339 variant: "primary",
14340 size: "compact",
14341 disabled: !saveEnabled,
14342 accessibleWhenDisabled: true,
14343 onClick: () => saveDirtyEntities({
14344 onSave,
14345 dirtyEntityRecords,
14346 entitiesToSkip: unselectedEntities,
14347 close
14348 }),
14349 className: "editor-entities-saved-states__save-button",
14350 children: saveLabel
14351 })]
14352 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14353 className: "entities-saved-states__text-prompt",
14354 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14355 className: "entities-saved-states__text-prompt--header-wrapper",
14356 id: renderDialog ? dialogLabel : undefined,
14357 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
14358 className: "entities-saved-states__text-prompt--header",
14359 children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
14360 }), additionalPrompt]
14361 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
14362 id: renderDialog ? dialogDescription : undefined,
14363 children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of site changes waiting to be saved. */
14364 (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.', dirtyEntityRecords.length), dirtyEntityRecords.length), {
14365 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
14366 }) : selectItemsToSaveDescription
14367 })]
14368 }), sortedPartitionedSavables.map(list => {
14369 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
14370 list: list,
14371 unselectedEntities: unselectedEntities,
14372 setUnselectedEntities: setUnselectedEntities
14373 }, list[0].name);
14374 })]
14375 });
14376 }
14377
14378 ;// ./packages/editor/build-module/components/error-boundary/index.js
14379 /**
14380 * WordPress dependencies
14381 */
14382
14383
14384
14385
14386
14387
14388
14389 /**
14390 * Internal dependencies
14391 */
14392
14393
14394 function getContent() {
14395 try {
14396 // While `select` in a component is generally discouraged, it is
14397 // used here because it (a) reduces the chance of data loss in the
14398 // case of additional errors by performing a direct retrieval and
14399 // (b) avoids the performance cost associated with unnecessary
14400 // content serialization throughout the lifetime of a non-erroring
14401 // application.
14402 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
14403 } catch (error) {}
14404 }
14405 function CopyButton({
14406 text,
14407 children,
14408 variant = 'secondary'
14409 }) {
14410 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
14411 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
14412 __next40pxDefaultSize: true,
14413 variant: variant,
14414 ref: ref,
14415 children: children
14416 });
14417 }
14418 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
14419 constructor() {
14420 super(...arguments);
14421 this.state = {
14422 error: null
14423 };
14424 }
14425 componentDidCatch(error) {
14426 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
14427 }
14428 static getDerivedStateFromError(error) {
14429 return {
14430 error
14431 };
14432 }
14433 render() {
14434 const {
14435 error
14436 } = this.state;
14437 const {
14438 canCopyContent = false
14439 } = this.props;
14440 if (!error) {
14441 return this.props.children;
14442 }
14443 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
14444 className: "editor-error-boundary",
14445 alignment: "baseline",
14446 spacing: 4,
14447 justify: "space-between",
14448 expanded: false,
14449 wrap: true,
14450 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
14451 as: "p",
14452 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
14453 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
14454 expanded: false,
14455 children: [canCopyContent && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
14456 text: getContent,
14457 children: (0,external_wp_i18n_namespaceObject.__)('Copy contents')
14458 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
14459 variant: "primary",
14460 text: error?.stack,
14461 children: (0,external_wp_i18n_namespaceObject.__)('Copy error')
14462 })]
14463 })]
14464 });
14465 }
14466 }
14467
14468 /**
14469 * ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
14470 *
14471 * It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
14472 *
14473 * getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
14474 *
14475 * @class ErrorBoundary
14476 * @augments Component
14477 */
14478 /* harmony default export */ const error_boundary = (ErrorBoundary);
14479
14480 ;// ./packages/editor/build-module/components/local-autosave-monitor/index.js
14481 /* wp:polyfill */
14482 /**
14483 * WordPress dependencies
14484 */
14485
14486
14487
14488
14489
14490
14491
14492 /**
14493 * Internal dependencies
14494 */
14495
14496
14497
14498
14499 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
14500 let hasStorageSupport;
14501
14502 /**
14503 * Function which returns true if the current environment supports browser
14504 * sessionStorage, or false otherwise. The result of this function is cached and
14505 * reused in subsequent invocations.
14506 */
14507 const hasSessionStorageSupport = () => {
14508 if (hasStorageSupport !== undefined) {
14509 return hasStorageSupport;
14510 }
14511 try {
14512 // Private Browsing in Safari 10 and earlier will throw an error when
14513 // attempting to set into sessionStorage. The test here is intentional in
14514 // causing a thrown error as condition bailing from local autosave.
14515 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
14516 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
14517 hasStorageSupport = true;
14518 } catch {
14519 hasStorageSupport = false;
14520 }
14521 return hasStorageSupport;
14522 };
14523
14524 /**
14525 * Custom hook which manages the creation of a notice prompting the user to
14526 * restore a local autosave, if one exists.
14527 */
14528 function useAutosaveNotice() {
14529 const {
14530 postId,
14531 isEditedPostNew,
14532 hasRemoteAutosave
14533 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14534 postId: select(store_store).getCurrentPostId(),
14535 isEditedPostNew: select(store_store).isEditedPostNew(),
14536 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
14537 }), []);
14538 const {
14539 getEditedPostAttribute
14540 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
14541 const {
14542 createWarningNotice,
14543 removeNotice
14544 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
14545 const {
14546 editPost,
14547 resetEditorBlocks
14548 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14549 (0,external_wp_element_namespaceObject.useEffect)(() => {
14550 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
14551 if (!localAutosave) {
14552 return;
14553 }
14554 try {
14555 localAutosave = JSON.parse(localAutosave);
14556 } catch {
14557 // Not usable if it can't be parsed.
14558 return;
14559 }
14560 const {
14561 post_title: title,
14562 content,
14563 excerpt
14564 } = localAutosave;
14565 const edits = {
14566 title,
14567 content,
14568 excerpt
14569 };
14570 {
14571 // Only display a notice if there is a difference between what has been
14572 // saved and that which is stored in sessionStorage.
14573 const hasDifference = Object.keys(edits).some(key => {
14574 return edits[key] !== getEditedPostAttribute(key);
14575 });
14576 if (!hasDifference) {
14577 // If there is no difference, it can be safely ejected from storage.
14578 localAutosaveClear(postId, isEditedPostNew);
14579 return;
14580 }
14581 }
14582 if (hasRemoteAutosave) {
14583 return;
14584 }
14585 const id = 'wpEditorAutosaveRestore';
14586 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
14587 id,
14588 actions: [{
14589 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
14590 onClick() {
14591 const {
14592 content: editsContent,
14593 ...editsWithoutContent
14594 } = edits;
14595 editPost(editsWithoutContent);
14596 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
14597 removeNotice(id);
14598 }
14599 }]
14600 });
14601 }, [isEditedPostNew, postId]);
14602 }
14603
14604 /**
14605 * Custom hook which ejects a local autosave after a successful save occurs.
14606 */
14607 function useAutosavePurge() {
14608 const {
14609 postId,
14610 isEditedPostNew,
14611 isDirty,
14612 isAutosaving,
14613 didError
14614 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14615 postId: select(store_store).getCurrentPostId(),
14616 isEditedPostNew: select(store_store).isEditedPostNew(),
14617 isDirty: select(store_store).isEditedPostDirty(),
14618 isAutosaving: select(store_store).isAutosavingPost(),
14619 didError: select(store_store).didPostSaveRequestFail()
14620 }), []);
14621 const lastIsDirtyRef = (0,external_wp_element_namespaceObject.useRef)(isDirty);
14622 const lastIsAutosavingRef = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
14623 (0,external_wp_element_namespaceObject.useEffect)(() => {
14624 if (!didError && (lastIsAutosavingRef.current && !isAutosaving || lastIsDirtyRef.current && !isDirty)) {
14625 localAutosaveClear(postId, isEditedPostNew);
14626 }
14627 lastIsDirtyRef.current = isDirty;
14628 lastIsAutosavingRef.current = isAutosaving;
14629 }, [isDirty, isAutosaving, didError]);
14630
14631 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
14632 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
14633 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
14634 (0,external_wp_element_namespaceObject.useEffect)(() => {
14635 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
14636 localAutosaveClear(postId, true);
14637 }
14638 }, [isEditedPostNew, postId]);
14639 }
14640 function LocalAutosaveMonitor() {
14641 const {
14642 autosave
14643 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14644 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
14645 requestIdleCallback(() => autosave({
14646 local: true
14647 }));
14648 }, []);
14649 useAutosaveNotice();
14650 useAutosavePurge();
14651 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
14652 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
14653 interval: localAutosaveInterval,
14654 autosave: deferredAutosave
14655 });
14656 }
14657
14658 /**
14659 * Monitors local autosaves of a post in the editor.
14660 * It uses several hooks and functions to manage autosave behavior:
14661 * - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
14662 * - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
14663 * - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
14664 * - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
14665 *
14666 * The module also checks for sessionStorage support and conditionally exports the `LocalAutosaveMonitor` component based on that.
14667 *
14668 * @module LocalAutosaveMonitor
14669 */
14670 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
14671
14672 ;// ./packages/editor/build-module/components/page-attributes/check.js
14673 /**
14674 * WordPress dependencies
14675 */
14676
14677
14678
14679 /**
14680 * Internal dependencies
14681 */
14682
14683
14684 /**
14685 * Wrapper component that renders its children only if the post type supports page attributes.
14686 *
14687 * @param {Object} props - The component props.
14688 * @param {React.ReactElement} props.children - The child components to render.
14689 *
14690 * @return {React.ReactElement} The rendered child components or null if page attributes are not supported.
14691 */
14692 function PageAttributesCheck({
14693 children
14694 }) {
14695 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
14696 const {
14697 getEditedPostAttribute
14698 } = select(store_store);
14699 const {
14700 getPostType
14701 } = select(external_wp_coreData_namespaceObject.store);
14702 const postType = getPostType(getEditedPostAttribute('type'));
14703 return !!postType?.supports?.['page-attributes'];
14704 }, []);
14705
14706 // Only render fields if post type supports page attributes or available templates exist.
14707 if (!supportsPageAttributes) {
14708 return null;
14709 }
14710 return children;
14711 }
14712 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
14713
14714 ;// ./packages/editor/build-module/components/post-type-support-check/index.js
14715 /* wp:polyfill */
14716 /**
14717 * WordPress dependencies
14718 */
14719
14720
14721
14722 /**
14723 * Internal dependencies
14724 */
14725
14726
14727 /**
14728 * A component which renders its own children only if the current editor post
14729 * type supports one of the given `supportKeys` prop.
14730 *
14731 * @param {Object} props Props.
14732 * @param {React.ReactElement} props.children Children to be rendered if post
14733 * type supports.
14734 * @param {(string|string[])} props.supportKeys String or string array of keys
14735 * to test.
14736 *
14737 * @return {React.ReactElement} The component to be rendered.
14738 */
14739 function PostTypeSupportCheck({
14740 children,
14741 supportKeys
14742 }) {
14743 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
14744 const {
14745 getEditedPostAttribute
14746 } = select(store_store);
14747 const {
14748 getPostType
14749 } = select(external_wp_coreData_namespaceObject.store);
14750 return getPostType(getEditedPostAttribute('type'));
14751 }, []);
14752 let isSupported = !!postType;
14753 if (postType) {
14754 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
14755 }
14756 if (!isSupported) {
14757 return null;
14758 }
14759 return children;
14760 }
14761 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck);
14762
14763 ;// ./packages/editor/build-module/components/page-attributes/order.js
14764 /**
14765 * WordPress dependencies
14766 */
14767
14768
14769
14770
14771
14772 /**
14773 * Internal dependencies
14774 */
14775
14776
14777
14778 function PageAttributesOrder() {
14779 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
14780 var _select$getEditedPost;
14781 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0;
14782 }, []);
14783 const {
14784 editPost
14785 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14786 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
14787 const setUpdatedOrder = value => {
14788 setOrderInput(value);
14789 const newOrder = Number(value);
14790 if (Number.isInteger(newOrder) && value.trim?.() !== '') {
14791 editPost({
14792 menu_order: newOrder
14793 });
14794 }
14795 };
14796 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order;
14797 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
14798 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, {
14799 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
14800 __next40pxDefaultSize: true,
14801 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
14802 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
14803 value: value,
14804 onChange: setUpdatedOrder,
14805 hideLabelFromVision: true,
14806 onBlur: () => {
14807 setOrderInput(null);
14808 }
14809 })
14810 })
14811 });
14812 }
14813
14814 /**
14815 * Renders the Page Attributes Order component. A number input in an editor interface
14816 * for setting the order of a given page.
14817 * The component is now not used in core but was kept for backward compatibility.
14818 *
14819 * @return {React.ReactNode} The rendered component.
14820 */
14821 function PageAttributesOrderWithChecks() {
14822 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
14823 supportKeys: "page-attributes",
14824 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})
14825 });
14826 }
14827
14828 ;// ./packages/editor/build-module/components/post-panel-row/index.js
14829 /**
14830 * External dependencies
14831 */
14832
14833
14834 /**
14835 * WordPress dependencies
14836 */
14837
14838
14839
14840 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({
14841 className,
14842 label,
14843 children
14844 }, ref) => {
14845 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
14846 className: dist_clsx('editor-post-panel__row', className),
14847 ref: ref,
14848 children: [label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
14849 className: "editor-post-panel__row-label",
14850 children: label
14851 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
14852 className: "editor-post-panel__row-control",
14853 children: children
14854 })]
14855 });
14856 });
14857 /* harmony default export */ const post_panel_row = (PostPanelRow);
14858
14859 ;// ./packages/editor/build-module/utils/terms.js
14860 /* wp:polyfill */
14861 /**
14862 * WordPress dependencies
14863 */
14864
14865
14866 /**
14867 * Returns terms in a tree form.
14868 *
14869 * @param {Array} flatTerms Array of terms in flat format.
14870 *
14871 * @return {Array} Array of terms in tree format.
14872 */
14873 function terms_buildTermsTree(flatTerms) {
14874 const flatTermsWithParentAndChildren = flatTerms.map(term => {
14875 return {
14876 children: [],
14877 parent: undefined,
14878 ...term
14879 };
14880 });
14881
14882 // All terms should have a `parent` because we're about to index them by it.
14883 if (flatTermsWithParentAndChildren.some(({
14884 parent
14885 }) => parent === undefined)) {
14886 return flatTermsWithParentAndChildren;
14887 }
14888 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
14889 const {
14890 parent
14891 } = term;
14892 if (!acc[parent]) {
14893 acc[parent] = [];
14894 }
14895 acc[parent].push(term);
14896 return acc;
14897 }, {});
14898 const fillWithChildren = terms => {
14899 return terms.map(term => {
14900 const children = termsByParent[term.id];
14901 return {
14902 ...term,
14903 children: children && children.length ? fillWithChildren(children) : []
14904 };
14905 });
14906 };
14907 return fillWithChildren(termsByParent['0'] || []);
14908 }
14909 const unescapeString = arg => {
14910 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
14911 };
14912
14913 /**
14914 * Returns a term object with name unescaped.
14915 *
14916 * @param {Object} term The term object to unescape.
14917 *
14918 * @return {Object} Term object with name property unescaped.
14919 */
14920 const unescapeTerm = term => {
14921 return {
14922 ...term,
14923 name: unescapeString(term.name)
14924 };
14925 };
14926
14927 /**
14928 * Returns an array of term objects with names unescaped.
14929 * The unescape of each term is performed using the unescapeTerm function.
14930 *
14931 * @param {Object[]} terms Array of term objects to unescape.
14932 *
14933 * @return {Object[]} Array of term objects unescaped.
14934 */
14935 const unescapeTerms = terms => {
14936 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm);
14937 };
14938
14939 ;// ./packages/editor/build-module/components/page-attributes/parent.js
14940 /* wp:polyfill */
14941 /**
14942 * External dependencies
14943 */
14944
14945
14946 /**
14947 * WordPress dependencies
14948 */
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959 /**
14960 * Internal dependencies
14961 */
14962
14963
14964
14965
14966 function getTitle(post) {
14967 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
14968 }
14969 const parent_getItemPriority = (name, searchValue) => {
14970 const normalizedName = remove_accents_default()(name || '').toLowerCase();
14971 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
14972 if (normalizedName === normalizedSearch) {
14973 return 0;
14974 }
14975 if (normalizedName.startsWith(normalizedSearch)) {
14976 return normalizedName.length;
14977 }
14978 return Infinity;
14979 };
14980
14981 /**
14982 * Renders the Page Attributes Parent component. A dropdown menu in an editor interface
14983 * for selecting the parent page of a given page.
14984 *
14985 * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.
14986 */
14987 function parent_PageAttributesParent() {
14988 const {
14989 editPost
14990 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14991 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
14992 const {
14993 isHierarchical,
14994 parentPostId,
14995 parentPostTitle,
14996 pageItems
14997 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14998 var _pType$hierarchical;
14999 const {
15000 getPostType,
15001 getEntityRecords,
15002 getEntityRecord
15003 } = select(external_wp_coreData_namespaceObject.store);
15004 const {
15005 getCurrentPostId,
15006 getEditedPostAttribute
15007 } = select(store_store);
15008 const postTypeSlug = getEditedPostAttribute('type');
15009 const pageId = getEditedPostAttribute('parent');
15010 const pType = getPostType(postTypeSlug);
15011 const postId = getCurrentPostId();
15012 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
15013 const query = {
15014 per_page: 100,
15015 exclude: postId,
15016 parent_exclude: postId,
15017 orderby: 'menu_order',
15018 order: 'asc',
15019 _fields: 'id,title,parent'
15020 };
15021
15022 // Perform a search when the field is changed.
15023 if (!!fieldValue) {
15024 query.search = fieldValue;
15025 }
15026 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
15027 return {
15028 isHierarchical: postIsHierarchical,
15029 parentPostId: pageId,
15030 parentPostTitle: parentPost ? getTitle(parentPost) : '',
15031 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
15032 };
15033 }, [fieldValue]);
15034 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
15035 const getOptionsFromTree = (tree, level = 0) => {
15036 const mappedNodes = tree.map(treeNode => [{
15037 value: treeNode.id,
15038 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
15039 rawName: treeNode.name
15040 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
15041 const sortedNodes = mappedNodes.sort(([a], [b]) => {
15042 const priorityA = parent_getItemPriority(a.rawName, fieldValue);
15043 const priorityB = parent_getItemPriority(b.rawName, fieldValue);
15044 return priorityA >= priorityB ? 1 : -1;
15045 });
15046 return sortedNodes.flat();
15047 };
15048 if (!pageItems) {
15049 return [];
15050 }
15051 let tree = pageItems.map(item => ({
15052 id: item.id,
15053 parent: item.parent,
15054 name: getTitle(item)
15055 }));
15056
15057 // Only build a hierarchical tree when not searching.
15058 if (!fieldValue) {
15059 tree = terms_buildTermsTree(tree);
15060 }
15061 const opts = getOptionsFromTree(tree);
15062
15063 // Ensure the current parent is in the options list.
15064 const optsHasParent = opts.find(item => item.value === parentPostId);
15065 if (parentPostTitle && !optsHasParent) {
15066 opts.unshift({
15067 value: parentPostId,
15068 label: parentPostTitle
15069 });
15070 }
15071 return opts;
15072 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
15073 if (!isHierarchical) {
15074 return null;
15075 }
15076 /**
15077 * Handle user input.
15078 *
15079 * @param {string} inputValue The current value of the input field.
15080 */
15081 const handleKeydown = inputValue => {
15082 setFieldValue(inputValue);
15083 };
15084
15085 /**
15086 * Handle author selection.
15087 *
15088 * @param {Object} selectedPostId The selected Author.
15089 */
15090 const handleChange = selectedPostId => {
15091 editPost({
15092 parent: selectedPostId
15093 });
15094 };
15095 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
15096 __nextHasNoMarginBottom: true,
15097 __next40pxDefaultSize: true,
15098 className: "editor-page-attributes__parent",
15099 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
15100 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
15101 value: parentPostId,
15102 options: parentOptions,
15103 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
15104 onChange: handleChange,
15105 hideLabelFromVision: true
15106 });
15107 }
15108 function PostParentToggle({
15109 isOpen,
15110 onClick
15111 }) {
15112 const parentPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
15113 const {
15114 getEditedPostAttribute
15115 } = select(store_store);
15116 const parentPostId = getEditedPostAttribute('parent');
15117 if (!parentPostId) {
15118 return null;
15119 }
15120 const {
15121 getEntityRecord
15122 } = select(external_wp_coreData_namespaceObject.store);
15123 const postTypeSlug = getEditedPostAttribute('type');
15124 return getEntityRecord('postType', postTypeSlug, parentPostId);
15125 }, []);
15126 const parentTitle = (0,external_wp_element_namespaceObject.useMemo)(() => !parentPost ? (0,external_wp_i18n_namespaceObject.__)('None') : getTitle(parentPost), [parentPost]);
15127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15128 size: "compact",
15129 className: "editor-post-parent__panel-toggle",
15130 variant: "tertiary",
15131 "aria-expanded": isOpen,
15132 "aria-label":
15133 // translators: %s: Current post parent.
15134 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change parent: %s'), parentTitle),
15135 onClick: onClick,
15136 children: parentTitle
15137 });
15138 }
15139 function ParentRow() {
15140 const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => {
15141 // Site index.
15142 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', '__unstableBase')?.home;
15143 }, []);
15144 // Use internal state instead of a ref to make sure that the component
15145 // re-renders when the popover's anchor updates.
15146 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
15147 // Memoize popoverProps to avoid returning a new object every time.
15148 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
15149 // Anchor the popover to the middle of the entire row so that it doesn't
15150 // move around when the label changes.
15151 anchor: popoverAnchor,
15152 placement: 'left-start',
15153 offset: 36,
15154 shift: true
15155 }), [popoverAnchor]);
15156 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
15157 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
15158 ref: setPopoverAnchor,
15159 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
15160 popoverProps: popoverProps,
15161 className: "editor-post-parent__panel-dropdown",
15162 contentClassName: "editor-post-parent__panel-dialog",
15163 focusOnMount: true,
15164 renderToggle: ({
15165 isOpen,
15166 onToggle
15167 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostParentToggle, {
15168 isOpen: isOpen,
15169 onClick: onToggle
15170 }),
15171 renderContent: ({
15172 onClose
15173 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15174 className: "editor-post-parent",
15175 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
15176 title: (0,external_wp_i18n_namespaceObject.__)('Parent'),
15177 onClose: onClose
15178 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15179 children: [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: The home URL of the WordPress installation without the scheme. */
15180 (0,external_wp_i18n_namespaceObject.__)('Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %s<wbr />/services<wbr />/pricing.'), (0,external_wp_url_namespaceObject.filterURLForDisplay)(homeUrl).replace(/([/.])/g, '<wbr />$1')), {
15181 wbr: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("wbr", {})
15182 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15183 children: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'), {
15184 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
15185 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes')
15186 })
15187 })
15188 })]
15189 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(parent_PageAttributesParent, {})]
15190 })
15191 })
15192 });
15193 }
15194 /* harmony default export */ const page_attributes_parent = (parent_PageAttributesParent);
15195
15196 ;// ./packages/editor/build-module/components/page-attributes/panel.js
15197 /**
15198 * WordPress dependencies
15199 */
15200
15201
15202 /**
15203 * Internal dependencies
15204 */
15205
15206
15207
15208
15209 const PANEL_NAME = 'page-attributes';
15210 function AttributesPanel() {
15211 const {
15212 isEnabled,
15213 postType
15214 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15215 const {
15216 getEditedPostAttribute,
15217 isEditorPanelEnabled
15218 } = select(store_store);
15219 const {
15220 getPostType
15221 } = select(external_wp_coreData_namespaceObject.store);
15222 return {
15223 isEnabled: isEditorPanelEnabled(PANEL_NAME),
15224 postType: getPostType(getEditedPostAttribute('type'))
15225 };
15226 }, []);
15227 if (!isEnabled || !postType) {
15228 return null;
15229 }
15230 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ParentRow, {});
15231 }
15232
15233 /**
15234 * Renders the Page Attributes Panel component.
15235 *
15236 * @return {React.ReactNode} The rendered component.
15237 */
15238 function PageAttributesPanel() {
15239 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
15240 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AttributesPanel, {})
15241 });
15242 }
15243
15244 ;// ./packages/icons/build-module/library/add-template.js
15245 /**
15246 * WordPress dependencies
15247 */
15248
15249
15250 const addTemplate = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
15251 viewBox: "0 0 24 24",
15252 xmlns: "http://www.w3.org/2000/svg",
15253 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
15254 fillRule: "evenodd",
15255 clipRule: "evenodd",
15256 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"
15257 })
15258 });
15259 /* harmony default export */ const add_template = (addTemplate);
15260
15261 ;// ./packages/editor/build-module/components/post-template/create-new-template-modal.js
15262 /**
15263 * WordPress dependencies
15264 */
15265
15266
15267
15268
15269
15270
15271
15272 /**
15273 * Internal dependencies
15274 */
15275
15276
15277
15278 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
15279 function CreateNewTemplateModal({
15280 onClose
15281 }) {
15282 const {
15283 defaultBlockTemplate,
15284 onNavigateToEntityRecord
15285 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15286 const {
15287 getEditorSettings,
15288 getCurrentTemplateId
15289 } = select(store_store);
15290 return {
15291 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
15292 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
15293 getTemplateId: getCurrentTemplateId
15294 };
15295 });
15296 const {
15297 createTemplate
15298 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
15299 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
15300 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
15301 const cancel = () => {
15302 setTitle('');
15303 onClose();
15304 };
15305 const submit = async event => {
15306 event.preventDefault();
15307 if (isBusy) {
15308 return;
15309 }
15310 setIsBusy(true);
15311 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
15312 tagName: 'header',
15313 layout: {
15314 inherit: true
15315 }
15316 }, [(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', {
15317 tagName: 'main'
15318 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
15319 layout: {
15320 inherit: true
15321 }
15322 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
15323 layout: {
15324 inherit: true
15325 }
15326 })])]);
15327 const newTemplate = await createTemplate({
15328 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE),
15329 content: newTemplateContent,
15330 title: title || DEFAULT_TITLE
15331 });
15332 setIsBusy(false);
15333 onNavigateToEntityRecord({
15334 postId: newTemplate.id,
15335 postType: 'wp_template'
15336 });
15337 cancel();
15338 };
15339 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
15340 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
15341 onRequestClose: cancel,
15342 focusOnMount: "firstContentElement",
15343 size: "small",
15344 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
15345 className: "editor-post-template__create-form",
15346 onSubmit: submit,
15347 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
15348 spacing: "3",
15349 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
15350 __next40pxDefaultSize: true,
15351 __nextHasNoMarginBottom: true,
15352 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
15353 value: title,
15354 onChange: setTitle,
15355 placeholder: DEFAULT_TITLE,
15356 disabled: isBusy,
15357 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.')
15358 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
15359 justify: "right",
15360 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15361 __next40pxDefaultSize: true,
15362 variant: "tertiary",
15363 onClick: cancel,
15364 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
15365 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15366 __next40pxDefaultSize: true,
15367 variant: "primary",
15368 type: "submit",
15369 isBusy: isBusy,
15370 "aria-disabled": isBusy,
15371 children: (0,external_wp_i18n_namespaceObject.__)('Create')
15372 })]
15373 })]
15374 })
15375 })
15376 });
15377 }
15378
15379 ;// ./packages/editor/build-module/components/post-template/hooks.js
15380 /**
15381 * WordPress dependencies
15382 */
15383
15384
15385
15386
15387 /**
15388 * Internal dependencies
15389 */
15390
15391 function useEditedPostContext() {
15392 return (0,external_wp_data_namespaceObject.useSelect)(select => {
15393 const {
15394 getCurrentPostId,
15395 getCurrentPostType
15396 } = select(store_store);
15397 return {
15398 postId: getCurrentPostId(),
15399 postType: getCurrentPostType()
15400 };
15401 }, []);
15402 }
15403 function useAllowSwitchingTemplates() {
15404 const {
15405 postType,
15406 postId
15407 } = useEditedPostContext();
15408 return (0,external_wp_data_namespaceObject.useSelect)(select => {
15409 const {
15410 canUser,
15411 getEntityRecord,
15412 getEntityRecords
15413 } = select(external_wp_coreData_namespaceObject.store);
15414 const siteSettings = canUser('read', {
15415 kind: 'root',
15416 name: 'site'
15417 }) ? getEntityRecord('root', 'site') : undefined;
15418 const templates = getEntityRecords('postType', 'wp_template', {
15419 per_page: -1
15420 });
15421 const isPostsPage = +postId === siteSettings?.page_for_posts;
15422 // If current page is set front page or posts page, we also need
15423 // to check if the current theme has a template for it. If not
15424 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
15425 slug
15426 }) => slug === 'front-page');
15427 return !isPostsPage && !isFrontPage;
15428 }, [postId, postType]);
15429 }
15430 function useTemplates(postType) {
15431 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
15432 per_page: -1,
15433 post_type: postType
15434 }), [postType]);
15435 }
15436 function useAvailableTemplates(postType) {
15437 const currentTemplateSlug = useCurrentTemplateSlug();
15438 const allowSwitchingTemplate = useAllowSwitchingTemplates();
15439 const templates = useTemplates(postType);
15440 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
15441 ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
15442 }
15443 function useCurrentTemplateSlug() {
15444 const {
15445 postType,
15446 postId
15447 } = useEditedPostContext();
15448 const templates = useTemplates(postType);
15449 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
15450 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
15451 return post?.template;
15452 }, [postType, postId]);
15453 if (!entityTemplate) {
15454 return;
15455 }
15456 // If a page has a `template` set and is not included in the list
15457 // of the theme's templates, do not return it, in order to resolve
15458 // to the current theme's default template.
15459 return templates?.find(template => template.slug === entityTemplate)?.slug;
15460 }
15461
15462 ;// ./packages/editor/build-module/components/post-template/classic-theme.js
15463 /* wp:polyfill */
15464 /**
15465 * WordPress dependencies
15466 */
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476 /**
15477 * Internal dependencies
15478 */
15479
15480
15481
15482
15483 const POPOVER_PROPS = {
15484 className: 'editor-post-template__dropdown',
15485 placement: 'bottom-start'
15486 };
15487 function PostTemplateToggle({
15488 isOpen,
15489 onClick
15490 }) {
15491 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
15492 const templateSlug = select(store_store).getEditedPostAttribute('template');
15493 const {
15494 supportsTemplateMode,
15495 availableTemplates
15496 } = select(store_store).getEditorSettings();
15497 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
15498 return availableTemplates[templateSlug];
15499 }
15500 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', {
15501 kind: 'postType',
15502 name: 'wp_template'
15503 }) && select(store_store).getCurrentTemplateId();
15504 return template?.title || template?.slug || availableTemplates?.[templateSlug];
15505 }, []);
15506 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15507 __next40pxDefaultSize: true,
15508 variant: "tertiary",
15509 "aria-expanded": isOpen,
15510 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'),
15511 onClick: onClick,
15512 children: templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')
15513 });
15514 }
15515
15516 /**
15517 * Renders the dropdown content for selecting a post template.
15518 *
15519 * @param {Object} props The component props.
15520 * @param {Function} props.onClose The function to close the dropdown.
15521 *
15522 * @return {React.ReactNode} The rendered dropdown content.
15523 */
15524 function PostTemplateDropdownContent({
15525 onClose
15526 }) {
15527 var _options$find, _selectedOption$value;
15528 const allowSwitchingTemplate = useAllowSwitchingTemplates();
15529 const {
15530 availableTemplates,
15531 fetchedTemplates,
15532 selectedTemplateSlug,
15533 canCreate,
15534 canEdit,
15535 currentTemplateId,
15536 onNavigateToEntityRecord,
15537 getEditorSettings
15538 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15539 const {
15540 canUser,
15541 getEntityRecords
15542 } = select(external_wp_coreData_namespaceObject.store);
15543 const editorSettings = select(store_store).getEditorSettings();
15544 const canCreateTemplates = canUser('create', {
15545 kind: 'postType',
15546 name: 'wp_template'
15547 });
15548 const _currentTemplateId = select(store_store).getCurrentTemplateId();
15549 return {
15550 availableTemplates: editorSettings.availableTemplates,
15551 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
15552 post_type: select(store_store).getCurrentPostType(),
15553 per_page: -1
15554 }) : undefined,
15555 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'),
15556 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
15557 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
15558 currentTemplateId: _currentTemplateId,
15559 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
15560 getEditorSettings: select(store_store).getEditorSettings
15561 };
15562 }, [allowSwitchingTemplate]);
15563 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({
15564 ...availableTemplates,
15565 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
15566 slug,
15567 title
15568 }) => [slug, title.rendered]))
15569 }).map(([slug, title]) => ({
15570 value: slug,
15571 label: title
15572 })), [availableTemplates, fetchedTemplates]);
15573 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.
15574
15575 const {
15576 editPost
15577 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15578 const {
15579 createSuccessNotice
15580 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15581 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
15582 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15583 className: "editor-post-template__classic-theme-dropdown",
15584 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
15585 title: (0,external_wp_i18n_namespaceObject.__)('Template'),
15586 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'),
15587 actions: canCreate ? [{
15588 icon: add_template,
15589 label: (0,external_wp_i18n_namespaceObject.__)('Add template'),
15590 onClick: () => setIsCreateModalOpen(true)
15591 }] : [],
15592 onClose: onClose
15593 }), !allowSwitchingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
15594 status: "warning",
15595 isDismissible: false,
15596 children: (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')
15597 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
15598 __next40pxDefaultSize: true,
15599 __nextHasNoMarginBottom: true,
15600 hideLabelFromVision: true,
15601 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
15602 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
15603 options: options,
15604 onChange: slug => editPost({
15605 template: slug || ''
15606 })
15607 }), canEdit && onNavigateToEntityRecord && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15608 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15609 __next40pxDefaultSize: true,
15610 variant: "link",
15611 onClick: () => {
15612 onNavigateToEntityRecord({
15613 postId: currentTemplateId,
15614 postType: 'wp_template'
15615 });
15616 onClose();
15617 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
15618 type: 'snackbar',
15619 actions: [{
15620 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
15621 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
15622 }]
15623 });
15624 },
15625 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
15626 })
15627 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
15628 onClose: () => setIsCreateModalOpen(false)
15629 })]
15630 });
15631 }
15632 function ClassicThemeControl() {
15633 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
15634 popoverProps: POPOVER_PROPS,
15635 focusOnMount: true,
15636 renderToggle: ({
15637 isOpen,
15638 onToggle
15639 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateToggle, {
15640 isOpen: isOpen,
15641 onClick: onToggle
15642 }),
15643 renderContent: ({
15644 onClose
15645 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateDropdownContent, {
15646 onClose: onClose
15647 })
15648 });
15649 }
15650
15651 /**
15652 * Provides a dropdown menu for selecting and managing post templates.
15653 *
15654 * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
15655 *
15656 * @return {React.ReactNode} The rendered ClassicThemeControl component.
15657 */
15658 /* harmony default export */ const classic_theme = (ClassicThemeControl);
15659
15660 ;// external ["wp","warning"]
15661 const external_wp_warning_namespaceObject = window["wp"]["warning"];
15662 ;// ./packages/editor/build-module/components/preferences-modal/enable-panel.js
15663 /**
15664 * WordPress dependencies
15665 */
15666
15667
15668
15669 /**
15670 * Internal dependencies
15671 */
15672
15673
15674
15675 const {
15676 PreferenceBaseOption
15677 } = unlock(external_wp_preferences_namespaceObject.privateApis);
15678 function EnablePanelOption(props) {
15679 const {
15680 toggleEditorPanelEnabled
15681 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15682 const {
15683 isChecked,
15684 isRemoved
15685 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15686 const {
15687 isEditorPanelEnabled,
15688 isEditorPanelRemoved
15689 } = select(store_store);
15690 return {
15691 isChecked: isEditorPanelEnabled(props.panelName),
15692 isRemoved: isEditorPanelRemoved(props.panelName)
15693 };
15694 }, [props.panelName]);
15695 if (isRemoved) {
15696 return null;
15697 }
15698 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceBaseOption, {
15699 isChecked: isChecked,
15700 onChange: () => toggleEditorPanelEnabled(props.panelName),
15701 ...props
15702 });
15703 }
15704
15705 ;// ./packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js
15706 /**
15707 * WordPress dependencies
15708 */
15709
15710
15711 /**
15712 * Internal dependencies
15713 */
15714
15715
15716 const {
15717 Fill,
15718 Slot
15719 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
15720 const EnablePluginDocumentSettingPanelOption = ({
15721 label,
15722 panelName
15723 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Fill, {
15724 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
15725 label: label,
15726 panelName: panelName
15727 })
15728 });
15729 EnablePluginDocumentSettingPanelOption.Slot = Slot;
15730 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
15731
15732 ;// ./packages/editor/build-module/components/plugin-document-setting-panel/index.js
15733 /**
15734 * WordPress dependencies
15735 */
15736
15737
15738
15739
15740
15741 /**
15742 * Internal dependencies
15743 */
15744
15745
15746
15747 const {
15748 Fill: plugin_document_setting_panel_Fill,
15749 Slot: plugin_document_setting_panel_Slot
15750 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
15751
15752 /**
15753 * Renders items below the Status & Availability panel in the Document Sidebar.
15754 *
15755 * @param {Object} props Component properties.
15756 * @param {string} props.name Required. A machine-friendly name for the panel.
15757 * @param {string} [props.className] An optional class name added to the row.
15758 * @param {string} [props.title] The title of the panel
15759 * @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.
15760 * @param {React.ReactNode} props.children Children to be rendered
15761 *
15762 * @example
15763 * ```js
15764 * // Using ES5 syntax
15765 * var el = React.createElement;
15766 * var __ = wp.i18n.__;
15767 * var registerPlugin = wp.plugins.registerPlugin;
15768 * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
15769 *
15770 * function MyDocumentSettingPlugin() {
15771 * return el(
15772 * PluginDocumentSettingPanel,
15773 * {
15774 * className: 'my-document-setting-plugin',
15775 * title: 'My Panel',
15776 * name: 'my-panel',
15777 * },
15778 * __( 'My Document Setting Panel' )
15779 * );
15780 * }
15781 *
15782 * registerPlugin( 'my-document-setting-plugin', {
15783 * render: MyDocumentSettingPlugin
15784 * } );
15785 * ```
15786 *
15787 * @example
15788 * ```jsx
15789 * // Using ESNext syntax
15790 * import { registerPlugin } from '@wordpress/plugins';
15791 * import { PluginDocumentSettingPanel } from '@wordpress/editor';
15792 *
15793 * const MyDocumentSettingTest = () => (
15794 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
15795 * <p>My Document Setting Panel</p>
15796 * </PluginDocumentSettingPanel>
15797 * );
15798 *
15799 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
15800 * ```
15801 *
15802 * @return {React.ReactNode} The component to be rendered.
15803 */
15804 const PluginDocumentSettingPanel = ({
15805 name,
15806 className,
15807 title,
15808 icon,
15809 children
15810 }) => {
15811 const {
15812 name: pluginName
15813 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
15814 const panelName = `${pluginName}/${name}`;
15815 const {
15816 opened,
15817 isEnabled
15818 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15819 const {
15820 isEditorPanelOpened,
15821 isEditorPanelEnabled
15822 } = select(store_store);
15823 return {
15824 opened: isEditorPanelOpened(panelName),
15825 isEnabled: isEditorPanelEnabled(panelName)
15826 };
15827 }, [panelName]);
15828 const {
15829 toggleEditorPanelOpened
15830 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15831 if (undefined === name) {
15832 false ? 0 : void 0;
15833 }
15834 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15835 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel, {
15836 label: title,
15837 panelName: panelName
15838 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel_Fill, {
15839 children: isEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
15840 className: className,
15841 title: title,
15842 icon: icon,
15843 opened: opened,
15844 onToggle: () => toggleEditorPanelOpened(panelName),
15845 children: children
15846 })
15847 })]
15848 });
15849 };
15850 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
15851 /* harmony default export */ const plugin_document_setting_panel = (PluginDocumentSettingPanel);
15852
15853 ;// ./packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
15854 /* wp:polyfill */
15855 /**
15856 * WordPress dependencies
15857 */
15858
15859
15860
15861
15862 const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
15863
15864 /**
15865 * Plugins may want to add an item to the menu either for every block
15866 * or only for the specific ones provided in the `allowedBlocks` component property.
15867 *
15868 * If there are multiple blocks selected the item will be rendered if every block
15869 * is of one allowed type (not necessarily the same).
15870 *
15871 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
15872 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
15873 * @return {boolean} Whether the item will be rendered or not.
15874 */
15875 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
15876
15877 /**
15878 * Renders a new item in the block settings menu.
15879 *
15880 * @param {Object} props Component props.
15881 * @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.
15882 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
15883 * @param {string} props.label The menu item text.
15884 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
15885 * @param {boolean} [props.small] Whether to render the label or not.
15886 * @param {string} [props.role] The ARIA role for the menu item.
15887 *
15888 * @example
15889 * ```js
15890 * // Using ES5 syntax
15891 * var __ = wp.i18n.__;
15892 * var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
15893 *
15894 * function doOnClick(){
15895 * // To be called when the user clicks the menu item.
15896 * }
15897 *
15898 * function MyPluginBlockSettingsMenuItem() {
15899 * return React.createElement(
15900 * PluginBlockSettingsMenuItem,
15901 * {
15902 * allowedBlocks: [ 'core/paragraph' ],
15903 * icon: 'dashicon-name',
15904 * label: __( 'Menu item text' ),
15905 * onClick: doOnClick,
15906 * }
15907 * );
15908 * }
15909 * ```
15910 *
15911 * @example
15912 * ```jsx
15913 * // Using ESNext syntax
15914 * import { __ } from '@wordpress/i18n';
15915 * import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
15916 *
15917 * const doOnClick = ( ) => {
15918 * // To be called when the user clicks the menu item.
15919 * };
15920 *
15921 * const MyPluginBlockSettingsMenuItem = () => (
15922 * <PluginBlockSettingsMenuItem
15923 * allowedBlocks={ [ 'core/paragraph' ] }
15924 * icon='dashicon-name'
15925 * label={ __( 'Menu item text' ) }
15926 * onClick={ doOnClick } />
15927 * );
15928 * ```
15929 *
15930 * @return {React.ReactNode} The rendered component.
15931 */
15932 const PluginBlockSettingsMenuItem = ({
15933 allowedBlocks,
15934 icon,
15935 label,
15936 onClick,
15937 small,
15938 role
15939 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
15940 children: ({
15941 selectedBlocks,
15942 onClose
15943 }) => {
15944 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
15945 return null;
15946 }
15947 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
15948 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
15949 icon: icon,
15950 label: small ? label : undefined,
15951 role: role,
15952 children: !small && label
15953 });
15954 }
15955 });
15956 /* harmony default export */ const plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
15957
15958 ;// ./packages/editor/build-module/components/plugin-more-menu-item/index.js
15959 /**
15960 * WordPress dependencies
15961 */
15962
15963
15964
15965
15966 /**
15967 * 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.
15968 * The text within the component appears as the menu item label.
15969 *
15970 * @param {Object} props Component properties.
15971 * @param {React.ReactNode} [props.children] Children to be rendered.
15972 * @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.
15973 * @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.
15974 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
15975 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
15976 *
15977 * @example
15978 * ```js
15979 * // Using ES5 syntax
15980 * var __ = wp.i18n.__;
15981 * var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
15982 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
15983 *
15984 * function onButtonClick() {
15985 * alert( 'Button clicked.' );
15986 * }
15987 *
15988 * function MyButtonMoreMenuItem() {
15989 * return wp.element.createElement(
15990 * PluginMoreMenuItem,
15991 * {
15992 * icon: moreIcon,
15993 * onClick: onButtonClick,
15994 * },
15995 * __( 'My button title' )
15996 * );
15997 * }
15998 * ```
15999 *
16000 * @example
16001 * ```jsx
16002 * // Using ESNext syntax
16003 * import { __ } from '@wordpress/i18n';
16004 * import { PluginMoreMenuItem } from '@wordpress/editor';
16005 * import { more } from '@wordpress/icons';
16006 *
16007 * function onButtonClick() {
16008 * alert( 'Button clicked.' );
16009 * }
16010 *
16011 * const MyButtonMoreMenuItem = () => (
16012 * <PluginMoreMenuItem
16013 * icon={ more }
16014 * onClick={ onButtonClick }
16015 * >
16016 * { __( 'My button title' ) }
16017 * </PluginMoreMenuItem>
16018 * );
16019 * ```
16020 *
16021 * @return {React.ReactNode} The rendered component.
16022 */
16023
16024 function PluginMoreMenuItem(props) {
16025 var _props$as;
16026 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
16027 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
16028 name: "core/plugin-more-menu",
16029 as: (_props$as = props.as) !== null && _props$as !== void 0 ? _props$as : external_wp_components_namespaceObject.MenuItem,
16030 icon: props.icon || context.icon,
16031 ...props
16032 });
16033 }
16034
16035 ;// ./packages/editor/build-module/components/plugin-post-publish-panel/index.js
16036 /**
16037 * WordPress dependencies
16038 */
16039
16040
16041
16042 const {
16043 Fill: plugin_post_publish_panel_Fill,
16044 Slot: plugin_post_publish_panel_Slot
16045 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
16046
16047 /**
16048 * Renders provided content to the post-publish panel in the publish flow
16049 * (side panel that opens after a user publishes the post).
16050 *
16051 * @param {Object} props Component properties.
16052 * @param {string} [props.className] An optional class name added to the panel.
16053 * @param {string} [props.title] Title displayed at the top of the panel.
16054 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
16055 * @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.
16056 * @param {React.ReactNode} props.children Children to be rendered
16057 *
16058 * @example
16059 * ```jsx
16060 * // Using ESNext syntax
16061 * import { __ } from '@wordpress/i18n';
16062 * import { PluginPostPublishPanel } from '@wordpress/editor';
16063 *
16064 * const MyPluginPostPublishPanel = () => (
16065 * <PluginPostPublishPanel
16066 * className="my-plugin-post-publish-panel"
16067 * title={ __( 'My panel title' ) }
16068 * initialOpen={ true }
16069 * >
16070 * { __( 'My panel content' ) }
16071 * </PluginPostPublishPanel>
16072 * );
16073 * ```
16074 *
16075 * @return {React.ReactNode} The rendered component.
16076 */
16077 const PluginPostPublishPanel = ({
16078 children,
16079 className,
16080 title,
16081 initialOpen = false,
16082 icon
16083 }) => {
16084 const {
16085 icon: pluginIcon
16086 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
16087 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_publish_panel_Fill, {
16088 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16089 className: className,
16090 initialOpen: initialOpen || !title,
16091 title: title,
16092 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
16093 children: children
16094 })
16095 });
16096 };
16097 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
16098 /* harmony default export */ const plugin_post_publish_panel = (PluginPostPublishPanel);
16099
16100 ;// ./packages/editor/build-module/components/plugin-post-status-info/index.js
16101 /**
16102 * Defines as extensibility slot for the Summary panel.
16103 */
16104
16105 /**
16106 * WordPress dependencies
16107 */
16108
16109
16110 const {
16111 Fill: plugin_post_status_info_Fill,
16112 Slot: plugin_post_status_info_Slot
16113 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
16114
16115 /**
16116 * Renders a row in the Summary panel of the Document sidebar.
16117 * It should be noted that this is named and implemented around the function it serves
16118 * and not its location, which may change in future iterations.
16119 *
16120 * @param {Object} props Component properties.
16121 * @param {string} [props.className] An optional class name added to the row.
16122 * @param {React.ReactNode} props.children Children to be rendered.
16123 *
16124 * @example
16125 * ```js
16126 * // Using ES5 syntax
16127 * var __ = wp.i18n.__;
16128 * var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;
16129 *
16130 * function MyPluginPostStatusInfo() {
16131 * return React.createElement(
16132 * PluginPostStatusInfo,
16133 * {
16134 * className: 'my-plugin-post-status-info',
16135 * },
16136 * __( 'My post status info' )
16137 * )
16138 * }
16139 * ```
16140 *
16141 * @example
16142 * ```jsx
16143 * // Using ESNext syntax
16144 * import { __ } from '@wordpress/i18n';
16145 * import { PluginPostStatusInfo } from '@wordpress/editor';
16146 *
16147 * const MyPluginPostStatusInfo = () => (
16148 * <PluginPostStatusInfo
16149 * className="my-plugin-post-status-info"
16150 * >
16151 * { __( 'My post status info' ) }
16152 * </PluginPostStatusInfo>
16153 * );
16154 * ```
16155 *
16156 * @return {React.ReactNode} The rendered component.
16157 */
16158 const PluginPostStatusInfo = ({
16159 children,
16160 className
16161 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info_Fill, {
16162 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
16163 className: className,
16164 children: children
16165 })
16166 });
16167 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
16168 /* harmony default export */ const plugin_post_status_info = (PluginPostStatusInfo);
16169
16170 ;// ./packages/editor/build-module/components/plugin-pre-publish-panel/index.js
16171 /**
16172 * WordPress dependencies
16173 */
16174
16175
16176
16177 const {
16178 Fill: plugin_pre_publish_panel_Fill,
16179 Slot: plugin_pre_publish_panel_Slot
16180 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
16181
16182 /**
16183 * Renders provided content to the pre-publish side panel in the publish flow
16184 * (side panel that opens when a user first pushes "Publish" from the main editor).
16185 *
16186 * @param {Object} props Component props.
16187 * @param {string} [props.className] An optional class name added to the panel.
16188 * @param {string} [props.title] Title displayed at the top of the panel.
16189 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
16190 * When no title is provided it is always opened.
16191 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
16192 * icon slug string, or an SVG WP element, to be rendered when
16193 * the sidebar is pinned to toolbar.
16194 * @param {React.ReactNode} props.children Children to be rendered
16195 *
16196 * @example
16197 * ```jsx
16198 * // Using ESNext syntax
16199 * import { __ } from '@wordpress/i18n';
16200 * import { PluginPrePublishPanel } from '@wordpress/editor';
16201 *
16202 * const MyPluginPrePublishPanel = () => (
16203 * <PluginPrePublishPanel
16204 * className="my-plugin-pre-publish-panel"
16205 * title={ __( 'My panel title' ) }
16206 * initialOpen={ true }
16207 * >
16208 * { __( 'My panel content' ) }
16209 * </PluginPrePublishPanel>
16210 * );
16211 * ```
16212 *
16213 * @return {React.ReactNode} The rendered component.
16214 */
16215 const PluginPrePublishPanel = ({
16216 children,
16217 className,
16218 title,
16219 initialOpen = false,
16220 icon
16221 }) => {
16222 const {
16223 icon: pluginIcon
16224 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
16225 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_pre_publish_panel_Fill, {
16226 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16227 className: className,
16228 initialOpen: initialOpen || !title,
16229 title: title,
16230 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
16231 children: children
16232 })
16233 });
16234 };
16235 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
16236 /* harmony default export */ const plugin_pre_publish_panel = (PluginPrePublishPanel);
16237
16238 ;// ./packages/editor/build-module/components/plugin-preview-menu-item/index.js
16239 /**
16240 * WordPress dependencies
16241 */
16242
16243
16244
16245
16246 /**
16247 * Renders a menu item in the Preview dropdown, which can be used as a button or link depending on the props provided.
16248 * The text within the component appears as the menu item label.
16249 *
16250 * @param {Object} props Component properties.
16251 * @param {React.ReactNode} [props.children] Children to be rendered.
16252 * @param {string} [props.href] When `href` is provided, the menu item is rendered as an anchor instead of a button. It corresponds to the `href` attribute of the anchor.
16253 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The icon to be rendered to the left of the menu item label. Can be a Dashicon slug or an SVG WP element.
16254 * @param {Function} [props.onClick] The callback function to be executed when the user clicks the menu item.
16255 * @param {...*} [props.other] Any additional props are passed through to the underlying MenuItem component.
16256 *
16257 * @example
16258 * ```jsx
16259 * import { __ } from '@wordpress/i18n';
16260 * import { PluginPreviewMenuItem } from '@wordpress/editor';
16261 * import { external } from '@wordpress/icons';
16262 *
16263 * function onPreviewClick() {
16264 * // Handle preview action
16265 * }
16266 *
16267 * const ExternalPreviewMenuItem = () => (
16268 * <PluginPreviewMenuItem
16269 * icon={ external }
16270 * onClick={ onPreviewClick }
16271 * >
16272 * { __( 'Preview in new tab' ) }
16273 * </PluginPreviewMenuItem>
16274 * );
16275 * registerPlugin( 'external-preview-menu-item', {
16276 * render: ExternalPreviewMenuItem,
16277 * } );
16278 * ```
16279 *
16280 * @return {React.ReactNode} The rendered menu item component.
16281 */
16282
16283 function PluginPreviewMenuItem(props) {
16284 var _props$as;
16285 const context = (0,external_wp_plugins_namespaceObject.usePluginContext)();
16286 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
16287 name: "core/plugin-preview-menu",
16288 as: (_props$as = props.as) !== null && _props$as !== void 0 ? _props$as : external_wp_components_namespaceObject.MenuItem,
16289 icon: props.icon || context.icon,
16290 ...props
16291 });
16292 }
16293
16294 ;// ./packages/editor/build-module/components/plugin-sidebar/index.js
16295 /**
16296 * WordPress dependencies
16297 */
16298
16299
16300 /**
16301 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
16302 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
16303 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
16304 *
16305 * ```js
16306 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
16307 * ```
16308 *
16309 * @see PluginSidebarMoreMenuItem
16310 *
16311 * @param {Object} props Element props.
16312 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
16313 * @param {React.ReactNode} [props.children] Children to be rendered.
16314 * @param {string} [props.className] An optional class name added to the sidebar body.
16315 * @param {string} props.title Title displayed at the top of the sidebar.
16316 * @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.
16317 * @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.
16318 *
16319 * @example
16320 * ```js
16321 * // Using ES5 syntax
16322 * var __ = wp.i18n.__;
16323 * var el = React.createElement;
16324 * var PanelBody = wp.components.PanelBody;
16325 * var PluginSidebar = wp.editor.PluginSidebar;
16326 * var moreIcon = React.createElement( 'svg' ); //... svg element.
16327 *
16328 * function MyPluginSidebar() {
16329 * return el(
16330 * PluginSidebar,
16331 * {
16332 * name: 'my-sidebar',
16333 * title: 'My sidebar title',
16334 * icon: moreIcon,
16335 * },
16336 * el(
16337 * PanelBody,
16338 * {},
16339 * __( 'My sidebar content' )
16340 * )
16341 * );
16342 * }
16343 * ```
16344 *
16345 * @example
16346 * ```jsx
16347 * // Using ESNext syntax
16348 * import { __ } from '@wordpress/i18n';
16349 * import { PanelBody } from '@wordpress/components';
16350 * import { PluginSidebar } from '@wordpress/editor';
16351 * import { more } from '@wordpress/icons';
16352 *
16353 * const MyPluginSidebar = () => (
16354 * <PluginSidebar
16355 * name="my-sidebar"
16356 * title="My sidebar title"
16357 * icon={ more }
16358 * >
16359 * <PanelBody>
16360 * { __( 'My sidebar content' ) }
16361 * </PanelBody>
16362 * </PluginSidebar>
16363 * );
16364 * ```
16365 */
16366
16367 function PluginSidebar({
16368 className,
16369 ...props
16370 }) {
16371 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area, {
16372 panelClassName: className,
16373 className: "editor-sidebar",
16374 scope: "core",
16375 ...props
16376 });
16377 }
16378
16379 ;// ./packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js
16380 /**
16381 * WordPress dependencies
16382 */
16383
16384
16385 /**
16386 * Renders a menu item in `Plugins` group in `More Menu` drop down,
16387 * and can be used to activate the corresponding `PluginSidebar` component.
16388 * The text within the component appears as the menu item label.
16389 *
16390 * @param {Object} props Component props.
16391 * @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.
16392 * @param {React.ReactNode} [props.children] Children to be rendered.
16393 * @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.
16394 *
16395 * @example
16396 * ```js
16397 * // Using ES5 syntax
16398 * var __ = wp.i18n.__;
16399 * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
16400 * var moreIcon = React.createElement( 'svg' ); //... svg element.
16401 *
16402 * function MySidebarMoreMenuItem() {
16403 * return React.createElement(
16404 * PluginSidebarMoreMenuItem,
16405 * {
16406 * target: 'my-sidebar',
16407 * icon: moreIcon,
16408 * },
16409 * __( 'My sidebar title' )
16410 * )
16411 * }
16412 * ```
16413 *
16414 * @example
16415 * ```jsx
16416 * // Using ESNext syntax
16417 * import { __ } from '@wordpress/i18n';
16418 * import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
16419 * import { more } from '@wordpress/icons';
16420 *
16421 * const MySidebarMoreMenuItem = () => (
16422 * <PluginSidebarMoreMenuItem
16423 * target="my-sidebar"
16424 * icon={ more }
16425 * >
16426 * { __( 'My sidebar title' ) }
16427 * </PluginSidebarMoreMenuItem>
16428 * );
16429 * ```
16430 *
16431 * @return {React.ReactNode} The rendered component.
16432 */
16433
16434 function PluginSidebarMoreMenuItem(props) {
16435 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem
16436 // Menu item is marked with unstable prop for backward compatibility.
16437 // @see https://github.com/WordPress/gutenberg/issues/14457
16438 , {
16439 __unstableExplicitMenuItem: true,
16440 scope: "core",
16441 ...props
16442 });
16443 }
16444
16445 ;// ./packages/editor/build-module/components/post-template/swap-template-button.js
16446 /* wp:polyfill */
16447 /**
16448 * WordPress dependencies
16449 */
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459 /**
16460 * Internal dependencies
16461 */
16462
16463
16464 function SwapTemplateButton({
16465 onClick
16466 }) {
16467 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
16468 const {
16469 postType,
16470 postId
16471 } = useEditedPostContext();
16472 const availableTemplates = useAvailableTemplates(postType);
16473 const {
16474 editEntityRecord
16475 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
16476 if (!availableTemplates?.length) {
16477 return null;
16478 }
16479 const onTemplateSelect = async template => {
16480 editEntityRecord('postType', postType, postId, {
16481 template: template.name
16482 }, {
16483 undoIgnore: true
16484 });
16485 setShowModal(false); // Close the template suggestions modal first.
16486 onClick();
16487 };
16488 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16489 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
16490 onClick: () => setShowModal(true),
16491 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
16492 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
16493 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
16494 onRequestClose: () => setShowModal(false),
16495 overlayClassName: "editor-post-template__swap-template-modal",
16496 isFullScreen: true,
16497 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16498 className: "editor-post-template__swap-template-modal-content",
16499 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatesList, {
16500 postType: postType,
16501 onSelect: onTemplateSelect
16502 })
16503 })
16504 })]
16505 });
16506 }
16507 function TemplatesList({
16508 postType,
16509 onSelect
16510 }) {
16511 const availableTemplates = useAvailableTemplates(postType);
16512 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
16513 name: template.slug,
16514 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
16515 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
16516 id: template.id
16517 })), [availableTemplates]);
16518 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
16519 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
16520 blockPatterns: templatesAsPatterns,
16521 onClickPattern: onSelect
16522 });
16523 }
16524
16525 ;// ./packages/editor/build-module/components/post-template/reset-default-template.js
16526 /**
16527 * WordPress dependencies
16528 */
16529
16530
16531
16532
16533
16534 /**
16535 * Internal dependencies
16536 */
16537
16538
16539 function ResetDefaultTemplate({
16540 onClick
16541 }) {
16542 const currentTemplateSlug = useCurrentTemplateSlug();
16543 const allowSwitchingTemplate = useAllowSwitchingTemplates();
16544 const {
16545 postType,
16546 postId
16547 } = useEditedPostContext();
16548 const {
16549 editEntityRecord
16550 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
16551 // The default template in a post is indicated by an empty string.
16552 if (!currentTemplateSlug || !allowSwitchingTemplate) {
16553 return null;
16554 }
16555 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
16556 onClick: () => {
16557 editEntityRecord('postType', postType, postId, {
16558 template: ''
16559 }, {
16560 undoIgnore: true
16561 });
16562 onClick();
16563 },
16564 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
16565 });
16566 }
16567
16568 ;// ./packages/editor/build-module/components/post-template/create-new-template.js
16569 /**
16570 * WordPress dependencies
16571 */
16572
16573
16574
16575
16576
16577
16578 /**
16579 * Internal dependencies
16580 */
16581
16582
16583
16584 function CreateNewTemplate({
16585 onClick
16586 }) {
16587 const {
16588 canCreateTemplates
16589 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16590 const {
16591 canUser
16592 } = select(external_wp_coreData_namespaceObject.store);
16593 return {
16594 canCreateTemplates: canUser('create', {
16595 kind: 'postType',
16596 name: 'wp_template'
16597 })
16598 };
16599 }, []);
16600 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
16601 const allowSwitchingTemplate = useAllowSwitchingTemplates();
16602
16603 // The default template in a post is indicated by an empty string.
16604 if (!canCreateTemplates || !allowSwitchingTemplate) {
16605 return null;
16606 }
16607 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16608 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
16609 onClick: () => {
16610 setIsCreateModalOpen(true);
16611 },
16612 children: (0,external_wp_i18n_namespaceObject.__)('Create new template')
16613 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
16614 onClose: () => {
16615 setIsCreateModalOpen(false);
16616 onClick();
16617 }
16618 })]
16619 });
16620 }
16621
16622 ;// ./packages/editor/build-module/components/post-template/block-theme.js
16623 /**
16624 * WordPress dependencies
16625 */
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635 /**
16636 * Internal dependencies
16637 */
16638
16639
16640
16641
16642
16643
16644 const block_theme_POPOVER_PROPS = {
16645 className: 'editor-post-template__dropdown',
16646 placement: 'bottom-start'
16647 };
16648 function BlockThemeControl({
16649 id
16650 }) {
16651 const {
16652 isTemplateHidden,
16653 onNavigateToEntityRecord,
16654 getEditorSettings,
16655 hasGoBack
16656 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16657 const {
16658 getRenderingMode,
16659 getEditorSettings: _getEditorSettings
16660 } = unlock(select(store_store));
16661 const editorSettings = _getEditorSettings();
16662 return {
16663 isTemplateHidden: getRenderingMode() === 'post-only',
16664 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
16665 getEditorSettings: _getEditorSettings,
16666 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
16667 };
16668 }, []);
16669 const {
16670 get: getPreference
16671 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
16672 const {
16673 editedRecord: template,
16674 hasResolved
16675 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id);
16676 const {
16677 createSuccessNotice
16678 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
16679 const {
16680 setRenderingMode
16681 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16682 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
16683 kind: 'postType',
16684 name: 'wp_template'
16685 }), []);
16686 if (!hasResolved) {
16687 return null;
16688 }
16689
16690 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
16691 // and assigns its own backlink to focusMode pages.
16692 const notificationAction = hasGoBack ? [{
16693 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
16694 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
16695 }] : undefined;
16696 const mayShowTemplateEditNotice = () => {
16697 if (!getPreference('core/edit-site', 'welcomeGuideTemplate')) {
16698 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
16699 type: 'snackbar',
16700 actions: notificationAction
16701 });
16702 }
16703 };
16704 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
16705 popoverProps: block_theme_POPOVER_PROPS,
16706 focusOnMount: true,
16707 toggleProps: {
16708 size: 'compact',
16709 variant: 'tertiary',
16710 tooltipPosition: 'middle left'
16711 },
16712 label: (0,external_wp_i18n_namespaceObject.__)('Template options'),
16713 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title),
16714 icon: null,
16715 children: ({
16716 onClose
16717 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16718 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
16719 children: [canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
16720 onClick: () => {
16721 onNavigateToEntityRecord({
16722 postId: template.id,
16723 postType: 'wp_template'
16724 });
16725 onClose();
16726 mayShowTemplateEditNotice();
16727 },
16728 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
16729 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SwapTemplateButton, {
16730 onClick: onClose
16731 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetDefaultTemplate, {
16732 onClick: onClose
16733 }), canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplate, {
16734 onClick: onClose
16735 })]
16736 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
16737 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
16738 icon: !isTemplateHidden ? library_check : undefined,
16739 isSelected: !isTemplateHidden,
16740 role: "menuitemcheckbox",
16741 onClick: () => {
16742 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
16743 },
16744 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
16745 })
16746 })]
16747 })
16748 });
16749 }
16750
16751 ;// ./packages/editor/build-module/components/post-template/panel.js
16752 /**
16753 * WordPress dependencies
16754 */
16755
16756
16757
16758
16759 /**
16760 * Internal dependencies
16761 */
16762
16763
16764
16765
16766
16767 /**
16768 * Displays the template controls based on the current editor settings and user permissions.
16769 *
16770 * @return {React.ReactNode} The rendered PostTemplatePanel component.
16771 */
16772
16773 function PostTemplatePanel() {
16774 const {
16775 templateId,
16776 isBlockTheme
16777 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16778 const {
16779 getCurrentTemplateId,
16780 getEditorSettings
16781 } = select(store_store);
16782 return {
16783 templateId: getCurrentTemplateId(),
16784 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
16785 };
16786 }, []);
16787 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
16788 var _select$canUser;
16789 const postTypeSlug = select(store_store).getCurrentPostType();
16790 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
16791 if (!postType?.viewable) {
16792 return false;
16793 }
16794 const settings = select(store_store).getEditorSettings();
16795 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
16796 if (hasTemplates) {
16797 return true;
16798 }
16799 if (!settings.supportsTemplateMode) {
16800 return false;
16801 }
16802 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', {
16803 kind: 'postType',
16804 name: 'wp_template'
16805 })) !== null && _select$canUser !== void 0 ? _select$canUser : false;
16806 return canCreateTemplates;
16807 }, []);
16808 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => {
16809 var _select$canUser2;
16810 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', {
16811 kind: 'postType',
16812 name: 'wp_template'
16813 })) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
16814 }, []);
16815 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
16816 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
16817 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
16818 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(classic_theme, {})
16819 });
16820 }
16821 if (isBlockTheme && !!templateId) {
16822 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
16823 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
16824 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockThemeControl, {
16825 id: templateId
16826 })
16827 });
16828 }
16829 return null;
16830 }
16831
16832 ;// ./packages/editor/build-module/components/post-author/constants.js
16833 const BASE_QUERY = {
16834 _fields: 'id,name',
16835 context: 'view' // Allows non-admins to perform requests.
16836 };
16837 const AUTHORS_QUERY = {
16838 who: 'authors',
16839 per_page: 100,
16840 ...BASE_QUERY
16841 };
16842
16843 ;// ./packages/editor/build-module/components/post-author/hook.js
16844 /* wp:polyfill */
16845 /**
16846 * WordPress dependencies
16847 */
16848
16849
16850
16851
16852
16853
16854 /**
16855 * Internal dependencies
16856 */
16857
16858
16859 function useAuthorsQuery(search) {
16860 const {
16861 authorId,
16862 authors,
16863 postAuthor
16864 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16865 const {
16866 getUser,
16867 getUsers
16868 } = select(external_wp_coreData_namespaceObject.store);
16869 const {
16870 getEditedPostAttribute
16871 } = select(store_store);
16872 const _authorId = getEditedPostAttribute('author');
16873 const query = {
16874 ...AUTHORS_QUERY
16875 };
16876 if (search) {
16877 query.search = search;
16878 query.search_columns = ['name'];
16879 }
16880 return {
16881 authorId: _authorId,
16882 authors: getUsers(query),
16883 postAuthor: getUser(_authorId, BASE_QUERY)
16884 };
16885 }, [search]);
16886 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
16887 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
16888 return {
16889 value: author.id,
16890 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
16891 };
16892 });
16893
16894 // Ensure the current author is included in the dropdown list.
16895 const foundAuthor = fetchedAuthors.findIndex(({
16896 value
16897 }) => postAuthor?.id === value);
16898 let currentAuthor = [];
16899 if (foundAuthor < 0 && postAuthor) {
16900 currentAuthor = [{
16901 value: postAuthor.id,
16902 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
16903 }];
16904 } else if (foundAuthor < 0 && !postAuthor) {
16905 currentAuthor = [{
16906 value: 0,
16907 label: (0,external_wp_i18n_namespaceObject.__)('(No author)')
16908 }];
16909 }
16910 return [...currentAuthor, ...fetchedAuthors];
16911 }, [authors, postAuthor]);
16912 return {
16913 authorId,
16914 authorOptions,
16915 postAuthor
16916 };
16917 }
16918
16919 ;// ./packages/editor/build-module/components/post-author/combobox.js
16920 /**
16921 * WordPress dependencies
16922 */
16923
16924
16925
16926
16927
16928
16929 /**
16930 * Internal dependencies
16931 */
16932
16933
16934
16935 function PostAuthorCombobox() {
16936 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
16937 const {
16938 editPost
16939 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16940 const {
16941 authorId,
16942 authorOptions
16943 } = useAuthorsQuery(fieldValue);
16944
16945 /**
16946 * Handle author selection.
16947 *
16948 * @param {number} postAuthorId The selected Author.
16949 */
16950 const handleSelect = postAuthorId => {
16951 if (!postAuthorId) {
16952 return;
16953 }
16954 editPost({
16955 author: postAuthorId
16956 });
16957 };
16958
16959 /**
16960 * Handle user input.
16961 *
16962 * @param {string} inputValue The current value of the input field.
16963 */
16964 const handleKeydown = inputValue => {
16965 setFieldValue(inputValue);
16966 };
16967 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
16968 __nextHasNoMarginBottom: true,
16969 __next40pxDefaultSize: true,
16970 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
16971 options: authorOptions,
16972 value: authorId,
16973 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
16974 onChange: handleSelect,
16975 allowReset: false,
16976 hideLabelFromVision: true
16977 });
16978 }
16979
16980 ;// ./packages/editor/build-module/components/post-author/select.js
16981 /**
16982 * WordPress dependencies
16983 */
16984
16985
16986
16987
16988 /**
16989 * Internal dependencies
16990 */
16991
16992
16993
16994 function PostAuthorSelect() {
16995 const {
16996 editPost
16997 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16998 const {
16999 authorId,
17000 authorOptions
17001 } = useAuthorsQuery();
17002 const setAuthorId = value => {
17003 const author = Number(value);
17004 editPost({
17005 author
17006 });
17007 };
17008 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
17009 __next40pxDefaultSize: true,
17010 __nextHasNoMarginBottom: true,
17011 className: "post-author-selector",
17012 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
17013 options: authorOptions,
17014 onChange: setAuthorId,
17015 value: authorId,
17016 hideLabelFromVision: true
17017 });
17018 }
17019
17020 ;// ./packages/editor/build-module/components/post-author/index.js
17021 /**
17022 * WordPress dependencies
17023 */
17024
17025
17026
17027 /**
17028 * Internal dependencies
17029 */
17030
17031
17032
17033
17034 const minimumUsersForCombobox = 25;
17035
17036 /**
17037 * Renders the component for selecting the post author.
17038 *
17039 * @return {React.ReactNode} The rendered component.
17040 */
17041 function PostAuthor() {
17042 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
17043 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
17044 return authors?.length >= minimumUsersForCombobox;
17045 }, []);
17046 if (showCombobox) {
17047 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCombobox, {});
17048 }
17049 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorSelect, {});
17050 }
17051 /* harmony default export */ const post_author = (PostAuthor);
17052
17053 ;// ./packages/editor/build-module/components/post-author/check.js
17054 /**
17055 * WordPress dependencies
17056 */
17057
17058
17059
17060 /**
17061 * Internal dependencies
17062 */
17063
17064
17065
17066
17067 /**
17068 * Wrapper component that renders its children only if the post type supports the author.
17069 *
17070 * @param {Object} props The component props.
17071 * @param {React.ReactNode} props.children Children to be rendered.
17072 *
17073 * @return {React.ReactNode} The component to be rendered. Return `null` if the post type doesn't
17074 * supports the author or if there are no authors available.
17075 */
17076
17077 function PostAuthorCheck({
17078 children
17079 }) {
17080 const {
17081 hasAssignAuthorAction,
17082 hasAuthors
17083 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17084 var _post$_links$wpActio;
17085 const post = select(store_store).getCurrentPost();
17086 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
17087 return {
17088 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
17089 hasAuthors: authors?.length >= 1
17090 };
17091 }, []);
17092 if (!hasAssignAuthorAction || !hasAuthors) {
17093 return null;
17094 }
17095 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17096 supportKeys: "author",
17097 children: children
17098 });
17099 }
17100
17101 ;// ./packages/editor/build-module/components/post-author/panel.js
17102 /**
17103 * WordPress dependencies
17104 */
17105
17106
17107
17108
17109
17110
17111 /**
17112 * Internal dependencies
17113 */
17114
17115
17116
17117
17118
17119 function PostAuthorToggle({
17120 isOpen,
17121 onClick
17122 }) {
17123 const {
17124 postAuthor
17125 } = useAuthorsQuery();
17126 const authorName = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor?.name) || (0,external_wp_i18n_namespaceObject.__)('(No author)');
17127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17128 size: "compact",
17129 className: "editor-post-author__panel-toggle",
17130 variant: "tertiary",
17131 "aria-expanded": isOpen,
17132 "aria-label":
17133 // translators: %s: Author name.
17134 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change author: %s'), authorName),
17135 onClick: onClick,
17136 children: authorName
17137 });
17138 }
17139
17140 /**
17141 * Renders the Post Author Panel component.
17142 *
17143 * @return {React.ReactNode} The rendered component.
17144 */
17145 function panel_PostAuthor() {
17146 // Use internal state instead of a ref to make sure that the component
17147 // re-renders when the popover's anchor updates.
17148 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
17149 // Memoize popoverProps to avoid returning a new object every time.
17150 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
17151 // Anchor the popover to the middle of the entire row so that it doesn't
17152 // move around when the label changes.
17153 anchor: popoverAnchor,
17154 placement: 'left-start',
17155 offset: 36,
17156 shift: true
17157 }), [popoverAnchor]);
17158 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCheck, {
17159 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17160 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
17161 ref: setPopoverAnchor,
17162 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
17163 popoverProps: popoverProps,
17164 contentClassName: "editor-post-author__panel-dialog",
17165 focusOnMount: true,
17166 renderToggle: ({
17167 isOpen,
17168 onToggle
17169 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorToggle, {
17170 isOpen: isOpen,
17171 onClick: onToggle
17172 }),
17173 renderContent: ({
17174 onClose
17175 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
17176 className: "editor-post-author",
17177 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
17178 title: (0,external_wp_i18n_namespaceObject.__)('Author'),
17179 onClose: onClose
17180 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_author, {
17181 onClose: onClose
17182 })]
17183 })
17184 })
17185 })
17186 });
17187 }
17188 /* harmony default export */ const panel = (panel_PostAuthor);
17189
17190 ;// ./packages/editor/build-module/components/post-comments/index.js
17191 /**
17192 * WordPress dependencies
17193 */
17194
17195
17196
17197
17198 /**
17199 * Internal dependencies
17200 */
17201
17202
17203 const COMMENT_OPTIONS = [{
17204 label: (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'),
17205 value: 'open',
17206 description: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
17207 }, {
17208 label: (0,external_wp_i18n_namespaceObject.__)('Closed'),
17209 value: 'closed',
17210 description: [(0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.'), (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')].join(' ')
17211 }];
17212 function PostComments() {
17213 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
17214 var _select$getEditedPost;
17215 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
17216 }, []);
17217 const {
17218 editPost
17219 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17220 const handleStatus = newCommentStatus => editPost({
17221 comment_status: newCommentStatus
17222 });
17223 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
17224 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
17225 spacing: 4,
17226 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
17227 className: "editor-change-status__options",
17228 hideLabelFromVision: true,
17229 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
17230 options: COMMENT_OPTIONS,
17231 onChange: handleStatus,
17232 selected: commentStatus
17233 })
17234 })
17235 });
17236 }
17237
17238 /**
17239 * A form for managing comment status.
17240 *
17241 * @return {React.ReactNode} The rendered PostComments component.
17242 */
17243 /* harmony default export */ const post_comments = (PostComments);
17244
17245 ;// ./packages/editor/build-module/components/post-pingbacks/index.js
17246 /**
17247 * WordPress dependencies
17248 */
17249
17250
17251
17252
17253 /**
17254 * Internal dependencies
17255 */
17256
17257
17258 function PostPingbacks() {
17259 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
17260 var _select$getEditedPost;
17261 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
17262 }, []);
17263 const {
17264 editPost
17265 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17266 const onTogglePingback = () => editPost({
17267 ping_status: pingStatus === 'open' ? 'closed' : 'open'
17268 });
17269 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
17270 __nextHasNoMarginBottom: true,
17271 label: (0,external_wp_i18n_namespaceObject.__)('Enable pingbacks & trackbacks'),
17272 checked: pingStatus === 'open',
17273 onChange: onTogglePingback,
17274 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
17275 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/trackbacks-and-pingbacks/'),
17276 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about pingbacks & trackbacks')
17277 })
17278 });
17279 }
17280
17281 /**
17282 * Renders a control for enabling or disabling pingbacks and trackbacks
17283 * in a WordPress post.
17284 *
17285 * @module PostPingbacks
17286 */
17287 /* harmony default export */ const post_pingbacks = (PostPingbacks);
17288
17289 ;// ./packages/editor/build-module/components/post-discussion/panel.js
17290 /**
17291 * WordPress dependencies
17292 */
17293
17294
17295
17296
17297
17298
17299
17300 /**
17301 * Internal dependencies
17302 */
17303
17304
17305
17306
17307
17308
17309 const panel_PANEL_NAME = 'discussion-panel';
17310 function ModalContents({
17311 onClose
17312 }) {
17313 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
17314 className: "editor-post-discussion",
17315 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
17316 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
17317 onClose: onClose
17318 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
17319 spacing: 4,
17320 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17321 supportKeys: "comments",
17322 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_comments, {})
17323 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17324 supportKeys: "trackbacks",
17325 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pingbacks, {})
17326 })]
17327 })]
17328 });
17329 }
17330 function PostDiscussionToggle({
17331 isOpen,
17332 onClick
17333 }) {
17334 const {
17335 commentStatus,
17336 pingStatus,
17337 commentsSupported,
17338 trackbacksSupported
17339 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17340 var _getEditedPostAttribu, _getEditedPostAttribu2;
17341 const {
17342 getEditedPostAttribute
17343 } = select(store_store);
17344 const {
17345 getPostType
17346 } = select(external_wp_coreData_namespaceObject.store);
17347 const postType = getPostType(getEditedPostAttribute('type'));
17348 return {
17349 commentStatus: (_getEditedPostAttribu = getEditedPostAttribute('comment_status')) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : 'open',
17350 pingStatus: (_getEditedPostAttribu2 = getEditedPostAttribute('ping_status')) !== null && _getEditedPostAttribu2 !== void 0 ? _getEditedPostAttribu2 : 'open',
17351 commentsSupported: !!postType.supports.comments,
17352 trackbacksSupported: !!postType.supports.trackbacks
17353 };
17354 }, []);
17355 let label;
17356 if (commentStatus === 'open') {
17357 if (pingStatus === 'open') {
17358 label = (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
17359 } else {
17360 label = trackbacksSupported ? (0,external_wp_i18n_namespaceObject.__)('Comments only') : (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
17361 }
17362 } else if (pingStatus === 'open') {
17363 label = commentsSupported ? (0,external_wp_i18n_namespaceObject.__)('Pings only') : (0,external_wp_i18n_namespaceObject.__)('Pings enabled');
17364 } else {
17365 label = (0,external_wp_i18n_namespaceObject.__)('Closed');
17366 }
17367 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17368 size: "compact",
17369 className: "editor-post-discussion__panel-toggle",
17370 variant: "tertiary",
17371 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion options'),
17372 "aria-expanded": isOpen,
17373 onClick: onClick,
17374 children: label
17375 });
17376 }
17377
17378 /**
17379 * This component allows to update comment and pingback
17380 * settings for the current post. Internally there are
17381 * checks whether the current post has support for the
17382 * above and if the `discussion-panel` panel is enabled.
17383 *
17384 * @return {React.ReactNode} The rendered PostDiscussionPanel component.
17385 */
17386 function PostDiscussionPanel() {
17387 const {
17388 isEnabled
17389 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17390 const {
17391 isEditorPanelEnabled
17392 } = select(store_store);
17393 return {
17394 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME)
17395 };
17396 }, []);
17397
17398 // Use internal state instead of a ref to make sure that the component
17399 // re-renders when the popover's anchor updates.
17400 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
17401 // Memoize popoverProps to avoid returning a new object every time.
17402 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
17403 // Anchor the popover to the middle of the entire row so that it doesn't
17404 // move around when the label changes.
17405 anchor: popoverAnchor,
17406 placement: 'left-start',
17407 offset: 36,
17408 shift: true
17409 }), [popoverAnchor]);
17410 if (!isEnabled) {
17411 return null;
17412 }
17413 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17414 supportKeys: ['comments', 'trackbacks'],
17415 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17416 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
17417 ref: setPopoverAnchor,
17418 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
17419 popoverProps: popoverProps,
17420 className: "editor-post-discussion__panel-dropdown",
17421 contentClassName: "editor-post-discussion__panel-dialog",
17422 focusOnMount: true,
17423 renderToggle: ({
17424 isOpen,
17425 onToggle
17426 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionToggle, {
17427 isOpen: isOpen,
17428 onClick: onToggle
17429 }),
17430 renderContent: ({
17431 onClose
17432 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ModalContents, {
17433 onClose: onClose
17434 })
17435 })
17436 })
17437 });
17438 }
17439
17440 ;// ./packages/editor/build-module/components/post-excerpt/index.js
17441 /**
17442 * WordPress dependencies
17443 */
17444
17445
17446
17447
17448
17449
17450 /**
17451 * Internal dependencies
17452 */
17453
17454
17455 /**
17456 * Renders an editable textarea for the post excerpt.
17457 * Templates, template parts and patterns use the `excerpt` field as a description semantically.
17458 * Additionally templates and template parts override the `excerpt` field as `description` in
17459 * REST API. So this component handles proper labeling and updating the edited entity.
17460 *
17461 * @param {Object} props - Component props.
17462 * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
17463 * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
17464 */
17465
17466 function PostExcerpt({
17467 hideLabelFromVision = false,
17468 updateOnBlur = false
17469 }) {
17470 const {
17471 excerpt,
17472 shouldUseDescriptionLabel,
17473 usedAttribute
17474 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17475 const {
17476 getCurrentPostType,
17477 getEditedPostAttribute
17478 } = select(store_store);
17479 const postType = getCurrentPostType();
17480 // This special case is unfortunate, but the REST API of wp_template and wp_template_part
17481 // support the excerpt field throught the "description" field rather than "excerpt".
17482 const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
17483 return {
17484 excerpt: getEditedPostAttribute(_usedAttribute),
17485 // There are special cases where we want to label the excerpt as a description.
17486 shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
17487 usedAttribute: _usedAttribute
17488 };
17489 }, []);
17490 const {
17491 editPost
17492 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17493 const [localExcerpt, setLocalExcerpt] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt));
17494 const updatePost = value => {
17495 editPost({
17496 [usedAttribute]: value
17497 });
17498 };
17499 const label = shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Write a description (optional)') : (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)');
17500 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
17501 className: "editor-post-excerpt",
17502 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
17503 __nextHasNoMarginBottom: true,
17504 label: label,
17505 hideLabelFromVision: hideLabelFromVision,
17506 className: "editor-post-excerpt__textarea",
17507 onChange: updateOnBlur ? setLocalExcerpt : updatePost,
17508 onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
17509 value: updateOnBlur ? localExcerpt : excerpt,
17510 help: !shouldUseDescriptionLabel ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
17511 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'),
17512 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')
17513 }) : (0,external_wp_i18n_namespaceObject.__)('Write a description')
17514 })
17515 });
17516 }
17517
17518 ;// ./packages/editor/build-module/components/post-excerpt/check.js
17519 /**
17520 * Internal dependencies
17521 */
17522
17523
17524 /**
17525 * Component for checking if the post type supports the excerpt field.
17526 *
17527 * @param {Object} props Props.
17528 * @param {React.ReactNode} props.children Children to be rendered.
17529 *
17530 * @return {React.ReactNode} The rendered component.
17531 */
17532
17533 function PostExcerptCheck({
17534 children
17535 }) {
17536 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17537 supportKeys: "excerpt",
17538 children: children
17539 });
17540 }
17541 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
17542
17543 ;// ./packages/editor/build-module/components/post-excerpt/plugin.js
17544 /**
17545 * Defines as extensibility slot for the Excerpt panel.
17546 */
17547
17548 /**
17549 * WordPress dependencies
17550 */
17551
17552
17553 const {
17554 Fill: plugin_Fill,
17555 Slot: plugin_Slot
17556 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt');
17557
17558 /**
17559 * Renders a post excerpt panel in the post sidebar.
17560 *
17561 * @param {Object} props Component properties.
17562 * @param {string} [props.className] An optional class name added to the row.
17563 * @param {React.ReactNode} props.children Children to be rendered.
17564 *
17565 * @example
17566 * ```js
17567 * // Using ES5 syntax
17568 * var __ = wp.i18n.__;
17569 * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
17570 *
17571 * function MyPluginPostExcerpt() {
17572 * return React.createElement(
17573 * PluginPostExcerpt,
17574 * {
17575 * className: 'my-plugin-post-excerpt',
17576 * },
17577 * __( 'Post excerpt custom content' )
17578 * )
17579 * }
17580 * ```
17581 *
17582 * @example
17583 * ```jsx
17584 * // Using ESNext syntax
17585 * import { __ } from '@wordpress/i18n';
17586 * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
17587 *
17588 * const MyPluginPostExcerpt = () => (
17589 * <PluginPostExcerpt className="my-plugin-post-excerpt">
17590 * { __( 'Post excerpt custom content' ) }
17591 * </PluginPostExcerpt>
17592 * );
17593 * ```
17594 *
17595 * @return {React.ReactNode} The rendered component.
17596 */
17597 const PluginPostExcerpt = ({
17598 children,
17599 className
17600 }) => {
17601 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_Fill, {
17602 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
17603 className: className,
17604 children: children
17605 })
17606 });
17607 };
17608 PluginPostExcerpt.Slot = plugin_Slot;
17609 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt);
17610
17611 ;// ./packages/editor/build-module/components/post-excerpt/panel.js
17612 /**
17613 * WordPress dependencies
17614 */
17615
17616
17617
17618
17619
17620
17621
17622
17623 /**
17624 * Internal dependencies
17625 */
17626
17627
17628
17629
17630
17631
17632 /**
17633 * Module Constants
17634 */
17635
17636 const post_excerpt_panel_PANEL_NAME = 'post-excerpt';
17637 function ExcerptPanel() {
17638 const {
17639 isOpened,
17640 isEnabled,
17641 postType
17642 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17643 const {
17644 isEditorPanelOpened,
17645 isEditorPanelEnabled,
17646 getCurrentPostType
17647 } = select(store_store);
17648 return {
17649 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME),
17650 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME),
17651 postType: getCurrentPostType()
17652 };
17653 }, []);
17654 const {
17655 toggleEditorPanelOpened
17656 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17657 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME);
17658 if (!isEnabled) {
17659 return null;
17660 }
17661
17662 // There are special cases where we want to label the excerpt as a description.
17663 const shouldUseDescriptionLabel = ['wp_template', 'wp_template_part', 'wp_block'].includes(postType);
17664 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
17665 title: shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
17666 opened: isOpened,
17667 onToggle: toggleExcerptPanel,
17668 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
17669 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17670 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {}), fills]
17671 })
17672 })
17673 });
17674 }
17675
17676 /**
17677 * Is rendered if the post type supports excerpts and allows editing the excerpt.
17678 *
17679 * @return {React.ReactNode} The rendered PostExcerptPanel component.
17680 */
17681 function PostExcerptPanel() {
17682 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
17683 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExcerptPanel, {})
17684 });
17685 }
17686 function PrivatePostExcerptPanel() {
17687 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
17688 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateExcerpt, {})
17689 });
17690 }
17691 function PrivateExcerpt() {
17692 const {
17693 shouldRender,
17694 excerpt,
17695 shouldBeUsedAsDescription,
17696 allowEditing
17697 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17698 const {
17699 getCurrentPostType,
17700 getCurrentPostId,
17701 getEditedPostAttribute,
17702 isEditorPanelEnabled
17703 } = select(store_store);
17704 const postType = getCurrentPostType();
17705 const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
17706 const isPattern = postType === 'wp_block';
17707 // These post types use the `excerpt` field as a description semantically, so we need to
17708 // handle proper labeling and some flows where we should always render them as text.
17709 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart || isPattern;
17710 const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
17711 // We need to fetch the entity in this case to check if we'll allow editing.
17712 const template = isTemplateOrTemplatePart && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, getCurrentPostId());
17713 // For post types that use excerpt as description, we do not abide
17714 // by the `isEnabled` panel flag in order to render them as text.
17715 const _shouldRender = isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) || _shouldBeUsedAsDescription;
17716 return {
17717 excerpt: getEditedPostAttribute(_usedAttribute),
17718 shouldRender: _shouldRender,
17719 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
17720 // If we should render, allow editing for all post types that are not used as description.
17721 // For the rest allow editing only for user generated entities.
17722 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template && template.source === TEMPLATE_ORIGINS.custom && !template.has_theme_file && template.is_custom)
17723 };
17724 }, []);
17725 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
17726 const label = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt');
17727 // Memoize popoverProps to avoid returning a new object every time.
17728 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
17729 // Anchor the popover to the middle of the entire row so that it doesn't
17730 // move around when the label changes.
17731 anchor: popoverAnchor,
17732 'aria-label': label,
17733 headerTitle: label,
17734 placement: 'left-start',
17735 offset: 36,
17736 shift: true
17737 }), [popoverAnchor, label]);
17738 if (!shouldRender) {
17739 return false;
17740 }
17741 const excerptText = !!excerpt && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
17742 align: "left",
17743 numberOfLines: 4,
17744 truncate: allowEditing,
17745 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt)
17746 });
17747 if (!allowEditing) {
17748 return excerptText;
17749 }
17750 const excerptPlaceholder = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Add a description…') : (0,external_wp_i18n_namespaceObject.__)('Add an excerpt…');
17751 const triggerEditLabel = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Edit description') : (0,external_wp_i18n_namespaceObject.__)('Edit excerpt');
17752 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
17753 children: [excerptText, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
17754 className: "editor-post-excerpt__dropdown",
17755 contentClassName: "editor-post-excerpt__dropdown__content",
17756 popoverProps: popoverProps,
17757 focusOnMount: true,
17758 ref: setPopoverAnchor,
17759 renderToggle: ({
17760 onToggle
17761 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17762 __next40pxDefaultSize: true,
17763 onClick: onToggle,
17764 variant: "link",
17765 children: excerptText ? triggerEditLabel : excerptPlaceholder
17766 }),
17767 renderContent: ({
17768 onClose
17769 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17770 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
17771 title: label,
17772 onClose: onClose
17773 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
17774 spacing: 4,
17775 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
17776 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17777 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {
17778 hideLabelFromVision: true,
17779 updateOnBlur: true
17780 }), fills]
17781 })
17782 })
17783 })]
17784 })
17785 })]
17786 });
17787 }
17788
17789 ;// ./packages/editor/build-module/components/theme-support-check/index.js
17790 /* wp:polyfill */
17791 /**
17792 * WordPress dependencies
17793 */
17794
17795
17796
17797 /**
17798 * Internal dependencies
17799 */
17800
17801
17802 /**
17803 * Checks if the current theme supports specific features and renders the children if supported.
17804 *
17805 * @param {Object} props The component props.
17806 * @param {React.ReactElement} props.children The children to render if the theme supports the specified features.
17807 * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
17808 *
17809 * @return {React.ReactElement} The rendered children if the theme supports the specified features, otherwise null.
17810 */
17811 function ThemeSupportCheck({
17812 children,
17813 supportKeys
17814 }) {
17815 const {
17816 postType,
17817 themeSupports
17818 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17819 return {
17820 postType: select(store_store).getEditedPostAttribute('type'),
17821 themeSupports: select(external_wp_coreData_namespaceObject.store).getThemeSupports()
17822 };
17823 }, []);
17824 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
17825 var _themeSupports$key;
17826 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false;
17827 // 'post-thumbnails' can be boolean or an array of post types.
17828 // In the latter case, we need to verify `postType` exists
17829 // within `supported`. If `postType` isn't passed, then the check
17830 // should fail.
17831 if ('post-thumbnails' === key && Array.isArray(supported)) {
17832 return supported.includes(postType);
17833 }
17834 return supported;
17835 });
17836 if (!isSupported) {
17837 return null;
17838 }
17839 return children;
17840 }
17841
17842 ;// ./packages/editor/build-module/components/post-featured-image/check.js
17843 /**
17844 * Internal dependencies
17845 */
17846
17847
17848
17849 /**
17850 * Wrapper component that renders its children only if the post type supports a featured image
17851 * and the theme supports post thumbnails.
17852 *
17853 * @param {Object} props Props.
17854 * @param {React.ReactNode} props.children Children to be rendered.
17855 *
17856 * @return {React.ReactNode} The rendered component.
17857 */
17858
17859 function PostFeaturedImageCheck({
17860 children
17861 }) {
17862 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ThemeSupportCheck, {
17863 supportKeys: "post-thumbnails",
17864 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17865 supportKeys: "thumbnail",
17866 children: children
17867 })
17868 });
17869 }
17870 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
17871
17872 ;// ./packages/editor/build-module/components/post-featured-image/index.js
17873 /**
17874 * External dependencies
17875 */
17876
17877
17878 /**
17879 * WordPress dependencies
17880 */
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891 /**
17892 * Internal dependencies
17893 */
17894
17895
17896
17897 const ALLOWED_MEDIA_TYPES = ['image'];
17898
17899 // Used when labels from post type were not yet loaded or when they are not present.
17900 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
17901 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Add a featured image');
17902 const instructions = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
17903 children: (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')
17904 });
17905 function getMediaDetails(media, postId) {
17906 var _media$media_details$, _media$media_details$2;
17907 if (!media) {
17908 return {};
17909 }
17910 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
17911 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) {
17912 return {
17913 mediaWidth: media.media_details.sizes[defaultSize].width,
17914 mediaHeight: media.media_details.sizes[defaultSize].height,
17915 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
17916 };
17917 }
17918
17919 // Use fallbackSize when defaultSize is not available.
17920 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
17921 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) {
17922 return {
17923 mediaWidth: media.media_details.sizes[fallbackSize].width,
17924 mediaHeight: media.media_details.sizes[fallbackSize].height,
17925 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
17926 };
17927 }
17928
17929 // Use full image size when fallbackSize and defaultSize are not available.
17930 return {
17931 mediaWidth: media.media_details.width,
17932 mediaHeight: media.media_details.height,
17933 mediaSourceUrl: media.source_url
17934 };
17935 }
17936 function PostFeaturedImage({
17937 currentPostId,
17938 featuredImageId,
17939 onUpdateImage,
17940 onRemoveImage,
17941 media,
17942 postType,
17943 noticeUI,
17944 noticeOperations,
17945 isRequestingFeaturedImageMedia
17946 }) {
17947 const returnsFocusRef = (0,external_wp_element_namespaceObject.useRef)(false);
17948 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
17949 const {
17950 getSettings
17951 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
17952 const {
17953 mediaSourceUrl
17954 } = getMediaDetails(media, currentPostId);
17955 function onDropFiles(filesList) {
17956 getSettings().mediaUpload({
17957 allowedTypes: ALLOWED_MEDIA_TYPES,
17958 filesList,
17959 onFileChange([image]) {
17960 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
17961 setIsLoading(true);
17962 return;
17963 }
17964 if (image) {
17965 onUpdateImage(image);
17966 }
17967 setIsLoading(false);
17968 },
17969 onError(message) {
17970 noticeOperations.removeAllNotices();
17971 noticeOperations.createErrorNotice(message);
17972 }
17973 });
17974 }
17975
17976 /**
17977 * Generates the featured image alt text for this editing context.
17978 *
17979 * @param {Object} imageMedia The image media object.
17980 * @param {string} imageMedia.alt_text The alternative text of the image.
17981 * @param {Object} imageMedia.media_details The media details of the image.
17982 * @param {Object} imageMedia.media_details.sizes The sizes of the image.
17983 * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.
17984 * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.
17985 * @param {string} imageMedia.slug The slug of the image.
17986 * @return {string} The featured image alt text.
17987 */
17988 function getImageDescription(imageMedia) {
17989 if (imageMedia.alt_text) {
17990 return (0,external_wp_i18n_namespaceObject.sprintf)(
17991 // Translators: %s: The selected image alt text.
17992 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), imageMedia.alt_text);
17993 }
17994 return (0,external_wp_i18n_namespaceObject.sprintf)(
17995 // Translators: %s: The selected image filename.
17996 (0,external_wp_i18n_namespaceObject.__)('The current image has no alternative text. The file name is: %s'), imageMedia.media_details.sizes?.full?.file || imageMedia.slug);
17997 }
17998 function returnFocus(node) {
17999 if (returnsFocusRef.current && node) {
18000 node.focus();
18001 returnsFocusRef.current = false;
18002 }
18003 }
18004 const isMissingMedia = !isRequestingFeaturedImageMedia && !!featuredImageId && !media;
18005 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_featured_image_check, {
18006 children: [noticeUI, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18007 className: "editor-post-featured-image",
18008 children: [media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18009 id: `editor-post-featured-image-${featuredImageId}-describedby`,
18010 className: "hidden",
18011 children: getImageDescription(media)
18012 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
18013 fallback: instructions,
18014 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, {
18015 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
18016 onSelect: onUpdateImage,
18017 unstableFeaturedImageFlow: true,
18018 allowedTypes: ALLOWED_MEDIA_TYPES,
18019 modalClass: "editor-post-featured-image__media-modal",
18020 render: ({
18021 open
18022 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18023 className: "editor-post-featured-image__container",
18024 children: [isMissingMedia ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
18025 status: "warning",
18026 isDismissible: false,
18027 children: (0,external_wp_i18n_namespaceObject.__)('Could not retrieve the featured image data.')
18028 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
18029 __next40pxDefaultSize: true,
18030 ref: returnFocus,
18031 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
18032 onClick: open,
18033 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the featured image'),
18034 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
18035 "aria-haspopup": "dialog",
18036 disabled: isLoading,
18037 accessibleWhenDisabled: true,
18038 children: [!!featuredImageId && media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
18039 className: "editor-post-featured-image__preview-image",
18040 src: mediaSourceUrl,
18041 alt: getImageDescription(media)
18042 }), (isLoading || isRequestingFeaturedImageMedia) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)]
18043 }), !!featuredImageId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
18044 className: dist_clsx('editor-post-featured-image__actions', {
18045 'editor-post-featured-image__actions-missing-image': isMissingMedia,
18046 'editor-post-featured-image__actions-is-requesting-image': isRequestingFeaturedImageMedia
18047 }),
18048 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18049 __next40pxDefaultSize: true,
18050 className: "editor-post-featured-image__action",
18051 onClick: open,
18052 "aria-haspopup": "dialog",
18053 variant: isMissingMedia ? 'secondary' : undefined,
18054 children: (0,external_wp_i18n_namespaceObject.__)('Replace')
18055 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18056 __next40pxDefaultSize: true,
18057 className: "editor-post-featured-image__action",
18058 onClick: () => {
18059 onRemoveImage();
18060 // Signal that the toggle button should be focused,
18061 // when it is rendered. Can't focus it directly here
18062 // because it's rendered conditionally.
18063 returnsFocusRef.current = true;
18064 },
18065 variant: isMissingMedia ? 'secondary' : undefined,
18066 isDestructive: isMissingMedia,
18067 children: (0,external_wp_i18n_namespaceObject.__)('Remove')
18068 })]
18069 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
18070 onFilesDrop: onDropFiles
18071 })]
18072 }),
18073 value: featuredImageId
18074 })
18075 })]
18076 })]
18077 });
18078 }
18079 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
18080 const {
18081 getMedia,
18082 getPostType,
18083 hasFinishedResolution
18084 } = select(external_wp_coreData_namespaceObject.store);
18085 const {
18086 getCurrentPostId,
18087 getEditedPostAttribute
18088 } = select(store_store);
18089 const featuredImageId = getEditedPostAttribute('featured_media');
18090 return {
18091 media: featuredImageId ? getMedia(featuredImageId, {
18092 context: 'view'
18093 }) : null,
18094 currentPostId: getCurrentPostId(),
18095 postType: getPostType(getEditedPostAttribute('type')),
18096 featuredImageId,
18097 isRequestingFeaturedImageMedia: !!featuredImageId && !hasFinishedResolution('getMedia', [featuredImageId, {
18098 context: 'view'
18099 }])
18100 };
18101 });
18102 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
18103 noticeOperations
18104 }, {
18105 select
18106 }) => {
18107 const {
18108 editPost
18109 } = dispatch(store_store);
18110 return {
18111 onUpdateImage(image) {
18112 editPost({
18113 featured_media: image.id
18114 });
18115 },
18116 onDropImage(filesList) {
18117 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
18118 allowedTypes: ['image'],
18119 filesList,
18120 onFileChange([image]) {
18121 editPost({
18122 featured_media: image.id
18123 });
18124 },
18125 onError(message) {
18126 noticeOperations.removeAllNotices();
18127 noticeOperations.createErrorNotice(message);
18128 }
18129 });
18130 },
18131 onRemoveImage() {
18132 editPost({
18133 featured_media: 0
18134 });
18135 }
18136 };
18137 });
18138
18139 /**
18140 * Renders the component for managing the featured image of a post.
18141 *
18142 * @param {Object} props Props.
18143 * @param {number} props.currentPostId ID of the current post.
18144 * @param {number} props.featuredImageId ID of the featured image.
18145 * @param {Function} props.onUpdateImage Function to call when the image is updated.
18146 * @param {Function} props.onRemoveImage Function to call when the image is removed.
18147 * @param {Object} props.media The media object representing the featured image.
18148 * @param {string} props.postType Post type.
18149 * @param {Element} props.noticeUI UI for displaying notices.
18150 * @param {Object} props.noticeOperations Operations for managing notices.
18151 *
18152 * @return {Element} Component to be rendered .
18153 */
18154 /* 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));
18155
18156 ;// ./packages/editor/build-module/components/post-featured-image/panel.js
18157 /**
18158 * WordPress dependencies
18159 */
18160
18161
18162
18163
18164
18165 /**
18166 * Internal dependencies
18167 */
18168
18169
18170
18171
18172 const post_featured_image_panel_PANEL_NAME = 'featured-image';
18173
18174 /**
18175 * Renders the panel for the post featured image.
18176 *
18177 * @param {Object} props Props.
18178 * @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
18179 *
18180 * @return {React.ReactNode} The component to be rendered.
18181 * Return Null if the editor panel is disabled for featured image.
18182 */
18183 function PostFeaturedImagePanel({
18184 withPanelBody = true
18185 }) {
18186 var _postType$labels$feat;
18187 const {
18188 postType,
18189 isEnabled,
18190 isOpened
18191 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18192 const {
18193 getEditedPostAttribute,
18194 isEditorPanelEnabled,
18195 isEditorPanelOpened
18196 } = select(store_store);
18197 const {
18198 getPostType
18199 } = select(external_wp_coreData_namespaceObject.store);
18200 return {
18201 postType: getPostType(getEditedPostAttribute('type')),
18202 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME),
18203 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME)
18204 };
18205 }, []);
18206 const {
18207 toggleEditorPanelOpened
18208 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18209 if (!isEnabled) {
18210 return null;
18211 }
18212 if (!withPanelBody) {
18213 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
18214 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
18215 });
18216 }
18217 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
18218 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
18219 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'),
18220 opened: isOpened,
18221 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME),
18222 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
18223 })
18224 });
18225 }
18226
18227 ;// ./packages/editor/build-module/components/post-format/check.js
18228 /**
18229 * WordPress dependencies
18230 */
18231
18232
18233 /**
18234 * Internal dependencies
18235 */
18236
18237
18238
18239 /**
18240 * Component check if there are any post formats.
18241 *
18242 * @param {Object} props The component props.
18243 * @param {React.ReactNode} props.children The child elements to render.
18244 *
18245 * @return {React.ReactNode} The rendered component or null if post formats are disabled.
18246 */
18247
18248 function PostFormatCheck({
18249 children
18250 }) {
18251 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []);
18252 if (disablePostFormats) {
18253 return null;
18254 }
18255 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
18256 supportKeys: "post-formats",
18257 children: children
18258 });
18259 }
18260
18261 ;// ./packages/editor/build-module/components/post-format/index.js
18262 /* wp:polyfill */
18263 /**
18264 * WordPress dependencies
18265 */
18266
18267
18268
18269
18270
18271
18272 /**
18273 * Internal dependencies
18274 */
18275
18276
18277
18278 // All WP post formats, sorted alphabetically by translated name.
18279
18280 const POST_FORMATS = [{
18281 id: 'aside',
18282 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
18283 }, {
18284 id: 'audio',
18285 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
18286 }, {
18287 id: 'chat',
18288 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
18289 }, {
18290 id: 'gallery',
18291 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
18292 }, {
18293 id: 'image',
18294 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
18295 }, {
18296 id: 'link',
18297 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
18298 }, {
18299 id: 'quote',
18300 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
18301 }, {
18302 id: 'standard',
18303 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
18304 }, {
18305 id: 'status',
18306 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
18307 }, {
18308 id: 'video',
18309 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
18310 }].sort((a, b) => {
18311 const normalizedA = a.caption.toUpperCase();
18312 const normalizedB = b.caption.toUpperCase();
18313 if (normalizedA < normalizedB) {
18314 return -1;
18315 }
18316 if (normalizedA > normalizedB) {
18317 return 1;
18318 }
18319 return 0;
18320 });
18321
18322 /**
18323 * `PostFormat` a component that allows changing the post format while also providing a suggestion for the current post.
18324 *
18325 * @example
18326 * ```jsx
18327 * <PostFormat />
18328 * ```
18329 *
18330 * @return {React.ReactNode} The rendered PostFormat component.
18331 */
18332 function PostFormat() {
18333 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
18334 const postFormatSelectorId = `post-format-selector-${instanceId}`;
18335 const {
18336 postFormat,
18337 suggestedFormat,
18338 supportedFormats
18339 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18340 const {
18341 getEditedPostAttribute,
18342 getSuggestedPostFormat
18343 } = select(store_store);
18344 const _postFormat = getEditedPostAttribute('format');
18345 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
18346 return {
18347 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
18348 suggestedFormat: getSuggestedPostFormat(),
18349 supportedFormats: themeSupports.formats
18350 };
18351 }, []);
18352 const formats = POST_FORMATS.filter(format => {
18353 // Ensure current format is always in the set.
18354 // The current format may not be a format supported by the theme.
18355 return supportedFormats?.includes(format.id) || postFormat === format.id;
18356 });
18357 const suggestion = formats.find(format => format.id === suggestedFormat);
18358 const {
18359 editPost
18360 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18361 const onUpdatePostFormat = format => editPost({
18362 format
18363 });
18364 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatCheck, {
18365 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18366 className: "editor-post-format",
18367 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
18368 className: "editor-post-format__options",
18369 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'),
18370 selected: postFormat,
18371 onChange: format => onUpdatePostFormat(format),
18372 id: postFormatSelectorId,
18373 options: formats.map(format => ({
18374 label: format.caption,
18375 value: format.id
18376 })),
18377 hideLabelFromVision: true
18378 }), suggestion && suggestion.id !== postFormat && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18379 className: "editor-post-format__suggestion",
18380 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18381 __next40pxDefaultSize: true,
18382 variant: "link",
18383 onClick: () => onUpdatePostFormat(suggestion.id),
18384 children: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post format */
18385 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption)
18386 })
18387 })]
18388 })
18389 });
18390 }
18391
18392 ;// ./packages/editor/build-module/components/post-last-revision/check.js
18393 /**
18394 * WordPress dependencies
18395 */
18396
18397
18398 /**
18399 * Internal dependencies
18400 */
18401
18402
18403
18404 /**
18405 * Wrapper component that renders its children if the post has more than one revision.
18406 *
18407 * @param {Object} props Props.
18408 * @param {React.ReactNode} props.children Children to be rendered.
18409 *
18410 * @return {React.ReactNode} Rendered child components if post has more than one revision, otherwise null.
18411 */
18412
18413 function PostLastRevisionCheck({
18414 children
18415 }) {
18416 const {
18417 lastRevisionId,
18418 revisionsCount
18419 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18420 const {
18421 getCurrentPostLastRevisionId,
18422 getCurrentPostRevisionsCount
18423 } = select(store_store);
18424 return {
18425 lastRevisionId: getCurrentPostLastRevisionId(),
18426 revisionsCount: getCurrentPostRevisionsCount()
18427 };
18428 }, []);
18429 if (!lastRevisionId || revisionsCount < 2) {
18430 return null;
18431 }
18432 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
18433 supportKeys: "revisions",
18434 children: children
18435 });
18436 }
18437 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck);
18438
18439 ;// ./packages/editor/build-module/components/post-last-revision/index.js
18440 /**
18441 * WordPress dependencies
18442 */
18443
18444
18445
18446
18447
18448
18449 /**
18450 * Internal dependencies
18451 */
18452
18453
18454
18455
18456 function usePostLastRevisionInfo() {
18457 return (0,external_wp_data_namespaceObject.useSelect)(select => {
18458 const {
18459 getCurrentPostLastRevisionId,
18460 getCurrentPostRevisionsCount
18461 } = select(store_store);
18462 return {
18463 lastRevisionId: getCurrentPostLastRevisionId(),
18464 revisionsCount: getCurrentPostRevisionsCount()
18465 };
18466 }, []);
18467 }
18468
18469 /**
18470 * Renders the component for displaying the last revision of a post.
18471 *
18472 * @return {React.ReactNode} The rendered component.
18473 */
18474 function PostLastRevision() {
18475 const {
18476 lastRevisionId,
18477 revisionsCount
18478 } = usePostLastRevisionInfo();
18479 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
18480 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18481 __next40pxDefaultSize: true,
18482 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
18483 revision: lastRevisionId
18484 }),
18485 className: "editor-post-last-revision__title",
18486 icon: library_backup,
18487 iconPosition: "right",
18488 text: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: number of revisions. */
18489 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount)
18490 })
18491 });
18492 }
18493 function PrivatePostLastRevision() {
18494 const {
18495 lastRevisionId,
18496 revisionsCount
18497 } = usePostLastRevisionInfo();
18498 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
18499 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
18500 label: (0,external_wp_i18n_namespaceObject.__)('Revisions'),
18501 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18502 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
18503 revision: lastRevisionId
18504 }),
18505 className: "editor-private-post-last-revision__button",
18506 text: revisionsCount,
18507 variant: "tertiary",
18508 size: "compact"
18509 })
18510 })
18511 });
18512 }
18513 /* harmony default export */ const post_last_revision = (PostLastRevision);
18514
18515 ;// ./packages/editor/build-module/components/post-last-revision/panel.js
18516 /**
18517 * WordPress dependencies
18518 */
18519
18520
18521 /**
18522 * Internal dependencies
18523 */
18524
18525
18526
18527 /**
18528 * Renders the panel for displaying the last revision of a post.
18529 *
18530 * @return {React.ReactNode} The rendered component.
18531 */
18532
18533 function PostLastRevisionPanel() {
18534 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
18535 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
18536 className: "editor-post-last-revision__panel",
18537 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision, {})
18538 })
18539 });
18540 }
18541 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel);
18542
18543 ;// ./packages/editor/build-module/components/post-locked-modal/index.js
18544 /**
18545 * WordPress dependencies
18546 */
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556 /**
18557 * Internal dependencies
18558 */
18559
18560
18561 /**
18562 * A modal component that is displayed when a post is locked for editing by another user.
18563 * The modal provides information about the lock status and options to take over or exit the editor.
18564 *
18565 * @return {React.ReactNode} The rendered PostLockedModal component.
18566 */
18567
18568 function PostLockedModal() {
18569 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
18570 const hookName = 'core/editor/post-locked-modal-' + instanceId;
18571 const {
18572 autosave,
18573 updatePostLock
18574 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18575 const {
18576 isLocked,
18577 isTakeover,
18578 user,
18579 postId,
18580 postLockUtils,
18581 activePostLock,
18582 postType,
18583 previewLink
18584 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18585 const {
18586 isPostLocked,
18587 isPostLockTakeover,
18588 getPostLockUser,
18589 getCurrentPostId,
18590 getActivePostLock,
18591 getEditedPostAttribute,
18592 getEditedPostPreviewLink,
18593 getEditorSettings
18594 } = select(store_store);
18595 const {
18596 getPostType
18597 } = select(external_wp_coreData_namespaceObject.store);
18598 return {
18599 isLocked: isPostLocked(),
18600 isTakeover: isPostLockTakeover(),
18601 user: getPostLockUser(),
18602 postId: getCurrentPostId(),
18603 postLockUtils: getEditorSettings().postLockUtils,
18604 activePostLock: getActivePostLock(),
18605 postType: getPostType(getEditedPostAttribute('type')),
18606 previewLink: getEditedPostPreviewLink()
18607 };
18608 }, []);
18609 (0,external_wp_element_namespaceObject.useEffect)(() => {
18610 /**
18611 * Keep the lock refreshed.
18612 *
18613 * When the user does not send a heartbeat in a heartbeat-tick
18614 * the user is no longer editing and another user can start editing.
18615 *
18616 * @param {Object} data Data to send in the heartbeat request.
18617 */
18618 function sendPostLock(data) {
18619 if (isLocked) {
18620 return;
18621 }
18622 data['wp-refresh-post-lock'] = {
18623 lock: activePostLock,
18624 post_id: postId
18625 };
18626 }
18627
18628 /**
18629 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
18630 *
18631 * @param {Object} data Data received in the heartbeat request
18632 */
18633 function receivePostLock(data) {
18634 if (!data['wp-refresh-post-lock']) {
18635 return;
18636 }
18637 const received = data['wp-refresh-post-lock'];
18638 if (received.lock_error) {
18639 // Auto save and display the takeover modal.
18640 autosave();
18641 updatePostLock({
18642 isLocked: true,
18643 isTakeover: true,
18644 user: {
18645 name: received.lock_error.name,
18646 avatar: received.lock_error.avatar_src_2x
18647 }
18648 });
18649 } else if (received.new_lock) {
18650 updatePostLock({
18651 isLocked: false,
18652 activePostLock: received.new_lock
18653 });
18654 }
18655 }
18656
18657 /**
18658 * Unlock the post before the window is exited.
18659 */
18660 function releasePostLock() {
18661 if (isLocked || !activePostLock) {
18662 return;
18663 }
18664 const data = new window.FormData();
18665 data.append('action', 'wp-remove-post-lock');
18666 data.append('_wpnonce', postLockUtils.unlockNonce);
18667 data.append('post_ID', postId);
18668 data.append('active_post_lock', activePostLock);
18669 if (window.navigator.sendBeacon) {
18670 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
18671 } else {
18672 const xhr = new window.XMLHttpRequest();
18673 xhr.open('POST', postLockUtils.ajaxUrl, false);
18674 xhr.send(data);
18675 }
18676 }
18677
18678 // Details on these events on the Heartbeat API docs
18679 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
18680 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
18681 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
18682 window.addEventListener('beforeunload', releasePostLock);
18683 return () => {
18684 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
18685 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
18686 window.removeEventListener('beforeunload', releasePostLock);
18687 };
18688 }, []);
18689 if (!isLocked) {
18690 return null;
18691 }
18692 const userDisplayName = user.name;
18693 const userAvatar = user.avatar;
18694 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
18695 'get-post-lock': '1',
18696 lockKey: true,
18697 post: postId,
18698 action: 'edit',
18699 _wpnonce: postLockUtils.nonce
18700 });
18701 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
18702 post_type: postType?.slug
18703 });
18704 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
18705 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
18706 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'),
18707 focusOnMount: true,
18708 shouldCloseOnClickOutside: false,
18709 shouldCloseOnEsc: false,
18710 isDismissible: false
18711 // Do not remove this class, as this class is used by third party plugins.
18712 ,
18713 className: "editor-post-locked-modal",
18714 size: "medium",
18715 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
18716 alignment: "top",
18717 spacing: 6,
18718 children: [!!userAvatar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
18719 src: userAvatar,
18720 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
18721 className: "editor-post-locked-modal__avatar",
18722 width: 64,
18723 height: 64
18724 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18725 children: [!!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18726 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: user's display name */
18727 (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.'), {
18728 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
18729 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18730 href: previewLink,
18731 children: (0,external_wp_i18n_namespaceObject.__)('preview')
18732 })
18733 })
18734 }), !isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18735 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18736 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: user's display name */
18737 (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.'), {
18738 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
18739 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18740 href: previewLink,
18741 children: (0,external_wp_i18n_namespaceObject.__)('preview')
18742 })
18743 })
18744 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18745 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.')
18746 })]
18747 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
18748 className: "editor-post-locked-modal__buttons",
18749 justify: "flex-end",
18750 children: [!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18751 __next40pxDefaultSize: true,
18752 variant: "tertiary",
18753 href: unlockUrl,
18754 children: (0,external_wp_i18n_namespaceObject.__)('Take over')
18755 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18756 __next40pxDefaultSize: true,
18757 variant: "primary",
18758 href: allPostsUrl,
18759 children: allPostsLabel
18760 })]
18761 })]
18762 })]
18763 })
18764 });
18765 }
18766
18767 ;// ./packages/editor/build-module/components/post-pending-status/check.js
18768 /**
18769 * WordPress dependencies
18770 */
18771
18772
18773 /**
18774 * Internal dependencies
18775 */
18776
18777
18778 /**
18779 * This component checks the publishing status of the current post.
18780 * If the post is already published or the user doesn't have the
18781 * capability to publish, it returns null.
18782 *
18783 * @param {Object} props Component properties.
18784 * @param {React.ReactElement} props.children Children to be rendered.
18785 *
18786 * @return {React.ReactElement} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
18787 */
18788 function PostPendingStatusCheck({
18789 children
18790 }) {
18791 const {
18792 hasPublishAction,
18793 isPublished
18794 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18795 var _getCurrentPost$_link;
18796 const {
18797 isCurrentPostPublished,
18798 getCurrentPost
18799 } = select(store_store);
18800 return {
18801 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
18802 isPublished: isCurrentPostPublished()
18803 };
18804 }, []);
18805 if (isPublished || !hasPublishAction) {
18806 return null;
18807 }
18808 return children;
18809 }
18810 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck);
18811
18812 ;// ./packages/editor/build-module/components/post-pending-status/index.js
18813 /**
18814 * WordPress dependencies
18815 */
18816
18817
18818
18819
18820 /**
18821 * Internal dependencies
18822 */
18823
18824
18825
18826 /**
18827 * A component for displaying and toggling the pending status of a post.
18828 *
18829 * @return {React.ReactNode} The rendered component.
18830 */
18831
18832 function PostPendingStatus() {
18833 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []);
18834 const {
18835 editPost
18836 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18837 const togglePendingStatus = () => {
18838 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
18839 editPost({
18840 status: updatedStatus
18841 });
18842 };
18843 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pending_status_check, {
18844 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
18845 __nextHasNoMarginBottom: true,
18846 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
18847 checked: status === 'pending',
18848 onChange: togglePendingStatus
18849 })
18850 });
18851 }
18852 /* harmony default export */ const post_pending_status = (PostPendingStatus);
18853
18854 ;// ./packages/editor/build-module/components/post-preview-button/index.js
18855 /**
18856 * WordPress dependencies
18857 */
18858
18859
18860
18861
18862
18863
18864
18865 /**
18866 * Internal dependencies
18867 */
18868
18869
18870 function writeInterstitialMessage(targetDocument) {
18871 let markup = (0,external_wp_element_namespaceObject.renderToString)(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18872 className: "editor-post-preview-button__interstitial-message",
18873 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
18874 xmlns: "http://www.w3.org/2000/svg",
18875 viewBox: "0 0 96 96",
18876 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
18877 className: "outer",
18878 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
18879 fill: "none"
18880 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
18881 className: "inner",
18882 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",
18883 fill: "none"
18884 })]
18885 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
18886 children: (0,external_wp_i18n_namespaceObject.__)('Generating preview…')
18887 })]
18888 }));
18889 markup += `
18890 <style>
18891 body {
18892 margin: 0;
18893 }
18894 .editor-post-preview-button__interstitial-message {
18895 display: flex;
18896 flex-direction: column;
18897 align-items: center;
18898 justify-content: center;
18899 height: 100vh;
18900 width: 100vw;
18901 }
18902 @-webkit-keyframes paint {
18903 0% {
18904 stroke-dashoffset: 0;
18905 }
18906 }
18907 @-moz-keyframes paint {
18908 0% {
18909 stroke-dashoffset: 0;
18910 }
18911 }
18912 @-o-keyframes paint {
18913 0% {
18914 stroke-dashoffset: 0;
18915 }
18916 }
18917 @keyframes paint {
18918 0% {
18919 stroke-dashoffset: 0;
18920 }
18921 }
18922 .editor-post-preview-button__interstitial-message svg {
18923 width: 192px;
18924 height: 192px;
18925 stroke: #555d66;
18926 stroke-width: 0.75;
18927 }
18928 .editor-post-preview-button__interstitial-message svg .outer,
18929 .editor-post-preview-button__interstitial-message svg .inner {
18930 stroke-dasharray: 280;
18931 stroke-dashoffset: 280;
18932 -webkit-animation: paint 1.5s ease infinite alternate;
18933 -moz-animation: paint 1.5s ease infinite alternate;
18934 -o-animation: paint 1.5s ease infinite alternate;
18935 animation: paint 1.5s ease infinite alternate;
18936 }
18937 p {
18938 text-align: center;
18939 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
18940 }
18941 </style>
18942 `;
18943
18944 /**
18945 * Filters the interstitial message shown when generating previews.
18946 *
18947 * @param {string} markup The preview interstitial markup.
18948 */
18949 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
18950 targetDocument.write(markup);
18951 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
18952 targetDocument.close();
18953 }
18954
18955 /**
18956 * Renders a button that opens a new window or tab for the preview,
18957 * writes the interstitial message to this window, and then navigates
18958 * to the actual preview link. The button is not rendered if the post
18959 * is not viewable and disabled if the post is not saveable.
18960 *
18961 * @param {Object} props The component props.
18962 * @param {string} props.className The class name for the button.
18963 * @param {string} props.textContent The text content for the button.
18964 * @param {boolean} props.forceIsAutosaveable Whether to force autosave.
18965 * @param {string} props.role The role attribute for the button.
18966 * @param {Function} props.onPreview The callback function for preview event.
18967 *
18968 * @return {React.ReactNode} The rendered button component.
18969 */
18970 function PostPreviewButton({
18971 className,
18972 textContent,
18973 forceIsAutosaveable,
18974 role,
18975 onPreview
18976 }) {
18977 const {
18978 postId,
18979 currentPostLink,
18980 previewLink,
18981 isSaveable,
18982 isViewable
18983 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18984 var _postType$viewable;
18985 const editor = select(store_store);
18986 const core = select(external_wp_coreData_namespaceObject.store);
18987 const postType = core.getPostType(editor.getCurrentPostType('type'));
18988 return {
18989 postId: editor.getCurrentPostId(),
18990 currentPostLink: editor.getCurrentPostAttribute('link'),
18991 previewLink: editor.getEditedPostPreviewLink(),
18992 isSaveable: editor.isEditedPostSaveable(),
18993 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
18994 };
18995 }, []);
18996 const {
18997 __unstableSaveForPreview
18998 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18999 if (!isViewable) {
19000 return null;
19001 }
19002 const targetId = `wp-preview-${postId}`;
19003 const openPreviewWindow = async event => {
19004 // Our Preview button has its 'href' and 'target' set correctly for a11y
19005 // purposes. Unfortunately, though, we can't rely on the default 'click'
19006 // handler since sometimes it incorrectly opens a new tab instead of reusing
19007 // the existing one.
19008 // https://github.com/WordPress/gutenberg/pull/8330
19009 event.preventDefault();
19010
19011 // Open up a Preview tab if needed. This is where we'll show the preview.
19012 const previewWindow = window.open('', targetId);
19013
19014 // Focus the Preview tab. This might not do anything, depending on the browser's
19015 // and user's preferences.
19016 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
19017 previewWindow.focus();
19018 writeInterstitialMessage(previewWindow.document);
19019 const link = await __unstableSaveForPreview({
19020 forceIsAutosaveable
19021 });
19022 previewWindow.location = link;
19023 onPreview?.();
19024 };
19025
19026 // Link to the `?preview=true` URL if we have it, since this lets us see
19027 // changes that were autosaved since the post was last published. Otherwise,
19028 // just link to the post's URL.
19029 const href = previewLink || currentPostLink;
19030 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19031 variant: !className ? 'tertiary' : undefined,
19032 className: className || 'editor-post-preview',
19033 href: href,
19034 target: targetId,
19035 accessibleWhenDisabled: true,
19036 disabled: !isSaveable,
19037 onClick: openPreviewWindow,
19038 role: role,
19039 size: "compact",
19040 children: textContent || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
19041 children: [(0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
19042 as: "span",
19043 children: /* translators: accessibility text */
19044 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
19045 })]
19046 })
19047 });
19048 }
19049
19050 ;// ./packages/editor/build-module/components/post-publish-button/label.js
19051 /**
19052 * WordPress dependencies
19053 */
19054
19055
19056
19057
19058 /**
19059 * Internal dependencies
19060 */
19061
19062
19063 /**
19064 * Renders the label for the publish button.
19065 *
19066 * @return {string} The label for the publish button.
19067 */
19068 function PublishButtonLabel() {
19069 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
19070 const {
19071 isPublished,
19072 isBeingScheduled,
19073 isSaving,
19074 isPublishing,
19075 hasPublishAction,
19076 isAutosaving,
19077 hasNonPostEntityChanges,
19078 postStatusHasChanged,
19079 postStatus
19080 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19081 var _getCurrentPost$_link;
19082 const {
19083 isCurrentPostPublished,
19084 isEditedPostBeingScheduled,
19085 isSavingPost,
19086 isPublishingPost,
19087 getCurrentPost,
19088 getCurrentPostType,
19089 isAutosavingPost,
19090 getPostEdits,
19091 getEditedPostAttribute
19092 } = select(store_store);
19093 return {
19094 isPublished: isCurrentPostPublished(),
19095 isBeingScheduled: isEditedPostBeingScheduled(),
19096 isSaving: isSavingPost(),
19097 isPublishing: isPublishingPost(),
19098 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
19099 postType: getCurrentPostType(),
19100 isAutosaving: isAutosavingPost(),
19101 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
19102 postStatusHasChanged: !!getPostEdits()?.status,
19103 postStatus: getEditedPostAttribute('status')
19104 };
19105 }, []);
19106 if (isPublishing) {
19107 /* translators: button label text should, if possible, be under 16 characters. */
19108 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
19109 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
19110 /* translators: button label text should, if possible, be under 16 characters. */
19111 return (0,external_wp_i18n_namespaceObject.__)('Saving…');
19112 }
19113 if (!hasPublishAction) {
19114 // TODO: this is because "Submit for review" string is too long in some languages.
19115 // @see https://github.com/WordPress/gutenberg/issues/10475
19116 return isSmallerThanMediumViewport ? (0,external_wp_i18n_namespaceObject.__)('Publish') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
19117 }
19118 if (hasNonPostEntityChanges || isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || !postStatusHasChanged && postStatus === 'future') {
19119 return (0,external_wp_i18n_namespaceObject.__)('Save');
19120 }
19121 if (isBeingScheduled) {
19122 return (0,external_wp_i18n_namespaceObject.__)('Schedule');
19123 }
19124 return (0,external_wp_i18n_namespaceObject.__)('Publish');
19125 }
19126
19127 ;// ./packages/editor/build-module/components/post-publish-button/index.js
19128 /* wp:polyfill */
19129 /**
19130 * WordPress dependencies
19131 */
19132
19133
19134
19135
19136
19137 /**
19138 * Internal dependencies
19139 */
19140
19141
19142
19143 const post_publish_button_noop = () => {};
19144 class PostPublishButton extends external_wp_element_namespaceObject.Component {
19145 constructor(props) {
19146 super(props);
19147 this.createOnClick = this.createOnClick.bind(this);
19148 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
19149 this.state = {
19150 entitiesSavedStatesCallback: false
19151 };
19152 }
19153 createOnClick(callback) {
19154 return (...args) => {
19155 const {
19156 hasNonPostEntityChanges,
19157 setEntitiesSavedStatesCallback
19158 } = this.props;
19159 // If a post with non-post entities is published, but the user
19160 // elects to not save changes to the non-post entities, those
19161 // entities will still be dirty when the Publish button is clicked.
19162 // We also need to check that the `setEntitiesSavedStatesCallback`
19163 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
19164 if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) {
19165 // The modal for multiple entity saving will open,
19166 // hold the callback for saving/publishing the post
19167 // so that we can call it if the post entity is checked.
19168 this.setState({
19169 entitiesSavedStatesCallback: () => callback(...args)
19170 });
19171
19172 // Open the save panel by setting its callback.
19173 // To set a function on the useState hook, we must set it
19174 // with another function (() => myFunction). Passing the
19175 // function on its own will cause an error when called.
19176 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates);
19177 return post_publish_button_noop;
19178 }
19179 return callback(...args);
19180 };
19181 }
19182 closeEntitiesSavedStates(savedEntities) {
19183 const {
19184 postType,
19185 postId
19186 } = this.props;
19187 const {
19188 entitiesSavedStatesCallback
19189 } = this.state;
19190 this.setState({
19191 entitiesSavedStatesCallback: false
19192 }, () => {
19193 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
19194 // The post entity was checked, call the held callback from `createOnClick`.
19195 entitiesSavedStatesCallback();
19196 }
19197 });
19198 }
19199 render() {
19200 const {
19201 forceIsDirty,
19202 hasPublishAction,
19203 isBeingScheduled,
19204 isOpen,
19205 isPostSavingLocked,
19206 isPublishable,
19207 isPublished,
19208 isSaveable,
19209 isSaving,
19210 isAutoSaving,
19211 isToggle,
19212 savePostStatus,
19213 onSubmit = post_publish_button_noop,
19214 onToggle,
19215 visibility,
19216 hasNonPostEntityChanges,
19217 isSavingNonPostEntityChanges,
19218 postStatus,
19219 postStatusHasChanged
19220 } = this.props;
19221 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
19222 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
19223
19224 // If the new status has not changed explicitely, we derive it from
19225 // other factors, like having a publish action, etc.. We need to preserve
19226 // this because it affects when to show the pre and post publish panels.
19227 // If it has changed though explicitely, we need to respect that.
19228 let publishStatus = 'publish';
19229 if (postStatusHasChanged) {
19230 publishStatus = postStatus;
19231 } else if (!hasPublishAction) {
19232 publishStatus = 'pending';
19233 } else if (visibility === 'private') {
19234 publishStatus = 'private';
19235 } else if (isBeingScheduled) {
19236 publishStatus = 'future';
19237 }
19238 const onClickButton = () => {
19239 if (isButtonDisabled) {
19240 return;
19241 }
19242 onSubmit();
19243 savePostStatus(publishStatus);
19244 };
19245
19246 // Callback to open the publish panel.
19247 const onClickToggle = () => {
19248 if (isToggleDisabled) {
19249 return;
19250 }
19251 onToggle();
19252 };
19253 const buttonProps = {
19254 'aria-disabled': isButtonDisabled,
19255 className: 'editor-post-publish-button',
19256 isBusy: !isAutoSaving && isSaving,
19257 variant: 'primary',
19258 onClick: this.createOnClick(onClickButton),
19259 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined
19260 };
19261 const toggleProps = {
19262 'aria-disabled': isToggleDisabled,
19263 'aria-expanded': isOpen,
19264 className: 'editor-post-publish-panel__toggle',
19265 isBusy: isSaving && isPublished,
19266 variant: 'primary',
19267 size: 'compact',
19268 onClick: this.createOnClick(onClickToggle),
19269 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined
19270 };
19271 const componentProps = isToggle ? toggleProps : buttonProps;
19272 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
19273 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
19274 ...componentProps,
19275 className: `${componentProps.className} editor-post-publish-button__button`,
19276 size: "compact",
19277 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PublishButtonLabel, {})
19278 })
19279 });
19280 }
19281 }
19282
19283 /**
19284 * Renders the publish button.
19285 */
19286 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
19287 var _getCurrentPost$_link;
19288 const {
19289 isSavingPost,
19290 isAutosavingPost,
19291 isEditedPostBeingScheduled,
19292 getEditedPostVisibility,
19293 isCurrentPostPublished,
19294 isEditedPostSaveable,
19295 isEditedPostPublishable,
19296 isPostSavingLocked,
19297 getCurrentPost,
19298 getCurrentPostType,
19299 getCurrentPostId,
19300 hasNonPostEntityChanges,
19301 isSavingNonPostEntityChanges,
19302 getEditedPostAttribute,
19303 getPostEdits
19304 } = select(store_store);
19305 return {
19306 isSaving: isSavingPost(),
19307 isAutoSaving: isAutosavingPost(),
19308 isBeingScheduled: isEditedPostBeingScheduled(),
19309 visibility: getEditedPostVisibility(),
19310 isSaveable: isEditedPostSaveable(),
19311 isPostSavingLocked: isPostSavingLocked(),
19312 isPublishable: isEditedPostPublishable(),
19313 isPublished: isCurrentPostPublished(),
19314 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
19315 postType: getCurrentPostType(),
19316 postId: getCurrentPostId(),
19317 postStatus: getEditedPostAttribute('status'),
19318 postStatusHasChanged: getPostEdits()?.status,
19319 hasNonPostEntityChanges: hasNonPostEntityChanges(),
19320 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
19321 };
19322 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
19323 const {
19324 editPost,
19325 savePost
19326 } = dispatch(store_store);
19327 return {
19328 savePostStatus: status => {
19329 editPost({
19330 status
19331 }, {
19332 undoIgnore: true
19333 });
19334 savePost();
19335 }
19336 };
19337 })])(PostPublishButton));
19338
19339 ;// ./packages/icons/build-module/library/wordpress.js
19340 /**
19341 * WordPress dependencies
19342 */
19343
19344
19345 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19346 xmlns: "http://www.w3.org/2000/svg",
19347 viewBox: "-2 -2 24 24",
19348 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19349 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"
19350 })
19351 });
19352 /* harmony default export */ const library_wordpress = (wordpress);
19353
19354 ;// ./packages/editor/build-module/components/post-visibility/utils.js
19355 /**
19356 * WordPress dependencies
19357 */
19358
19359 const visibilityOptions = {
19360 public: {
19361 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
19362 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
19363 },
19364 private: {
19365 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
19366 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
19367 },
19368 password: {
19369 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
19370 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
19371 }
19372 };
19373
19374 ;// ./packages/editor/build-module/components/post-visibility/index.js
19375 /**
19376 * WordPress dependencies
19377 */
19378
19379
19380
19381
19382
19383
19384
19385 /**
19386 * Internal dependencies
19387 */
19388
19389
19390
19391 /**
19392 * Allows users to set the visibility of a post.
19393 *
19394 * @param {Object} props The component props.
19395 * @param {Function} props.onClose Function to call when the popover is closed.
19396 * @return {React.ReactNode} The rendered component.
19397 */
19398
19399 function PostVisibility({
19400 onClose
19401 }) {
19402 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
19403 const {
19404 status,
19405 visibility,
19406 password
19407 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
19408 status: select(store_store).getEditedPostAttribute('status'),
19409 visibility: select(store_store).getEditedPostVisibility(),
19410 password: select(store_store).getEditedPostAttribute('password')
19411 }));
19412 const {
19413 editPost,
19414 savePost
19415 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
19416 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
19417 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
19418 const setPublic = () => {
19419 editPost({
19420 status: visibility === 'private' ? 'draft' : status,
19421 password: ''
19422 });
19423 setHasPassword(false);
19424 };
19425 const setPrivate = () => {
19426 setShowPrivateConfirmDialog(true);
19427 };
19428 const confirmPrivate = () => {
19429 editPost({
19430 status: 'private',
19431 password: ''
19432 });
19433 setHasPassword(false);
19434 setShowPrivateConfirmDialog(false);
19435 savePost();
19436 };
19437 const handleDialogCancel = () => {
19438 setShowPrivateConfirmDialog(false);
19439 };
19440 const setPasswordProtected = () => {
19441 editPost({
19442 status: visibility === 'private' ? 'draft' : status,
19443 password: password || ''
19444 });
19445 setHasPassword(true);
19446 };
19447 const updatePassword = event => {
19448 editPost({
19449 password: event.target.value
19450 });
19451 };
19452 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19453 className: "editor-post-visibility",
19454 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
19455 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
19456 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
19457 onClose: onClose
19458 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
19459 className: "editor-post-visibility__fieldset",
19460 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
19461 as: "legend",
19462 children: (0,external_wp_i18n_namespaceObject.__)('Visibility')
19463 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
19464 instanceId: instanceId,
19465 value: "public",
19466 label: visibilityOptions.public.label,
19467 info: visibilityOptions.public.info,
19468 checked: visibility === 'public' && !hasPassword,
19469 onChange: setPublic
19470 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
19471 instanceId: instanceId,
19472 value: "private",
19473 label: visibilityOptions.private.label,
19474 info: visibilityOptions.private.info,
19475 checked: visibility === 'private',
19476 onChange: setPrivate
19477 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
19478 instanceId: instanceId,
19479 value: "password",
19480 label: visibilityOptions.password.label,
19481 info: visibilityOptions.password.info,
19482 checked: hasPassword,
19483 onChange: setPasswordProtected
19484 }), hasPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19485 className: "editor-post-visibility__password",
19486 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
19487 as: "label",
19488 htmlFor: `editor-post-visibility__password-input-${instanceId}`,
19489 children: (0,external_wp_i18n_namespaceObject.__)('Create password')
19490 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
19491 className: "editor-post-visibility__password-input",
19492 id: `editor-post-visibility__password-input-${instanceId}`,
19493 type: "text",
19494 onChange: updatePassword,
19495 value: password,
19496 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
19497 })]
19498 })]
19499 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
19500 isOpen: showPrivateConfirmDialog,
19501 onConfirm: confirmPrivate,
19502 onCancel: handleDialogCancel,
19503 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Publish'),
19504 size: "medium",
19505 children: (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')
19506 })]
19507 });
19508 }
19509 function PostVisibilityChoice({
19510 instanceId,
19511 value,
19512 label,
19513 info,
19514 ...props
19515 }) {
19516 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
19517 className: "editor-post-visibility__choice",
19518 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
19519 type: "radio",
19520 name: `editor-post-visibility__setting-${instanceId}`,
19521 value: value,
19522 id: `editor-post-${value}-${instanceId}`,
19523 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
19524 className: "editor-post-visibility__radio",
19525 ...props
19526 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
19527 htmlFor: `editor-post-${value}-${instanceId}`,
19528 className: "editor-post-visibility__label",
19529 children: label
19530 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
19531 id: `editor-post-${value}-${instanceId}-description`,
19532 className: "editor-post-visibility__info",
19533 children: info
19534 })]
19535 });
19536 }
19537
19538 ;// ./packages/editor/build-module/components/post-visibility/label.js
19539 /**
19540 * WordPress dependencies
19541 */
19542
19543
19544 /**
19545 * Internal dependencies
19546 */
19547
19548
19549
19550 /**
19551 * Returns the label for the current post visibility setting.
19552 *
19553 * @return {string} Post visibility label.
19554 */
19555 function PostVisibilityLabel() {
19556 return usePostVisibilityLabel();
19557 }
19558
19559 /**
19560 * Get the label for the current post visibility setting.
19561 *
19562 * @return {string} Post visibility label.
19563 */
19564 function usePostVisibilityLabel() {
19565 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
19566 return visibilityOptions[visibility]?.label;
19567 }
19568
19569 ;// ./node_modules/date-fns/toDate.mjs
19570 /**
19571 * @name toDate
19572 * @category Common Helpers
19573 * @summary Convert the given argument to an instance of Date.
19574 *
19575 * @description
19576 * Convert the given argument to an instance of Date.
19577 *
19578 * If the argument is an instance of Date, the function returns its clone.
19579 *
19580 * If the argument is a number, it is treated as a timestamp.
19581 *
19582 * If the argument is none of the above, the function returns Invalid Date.
19583 *
19584 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
19585 *
19586 * @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).
19587 *
19588 * @param argument - The value to convert
19589 *
19590 * @returns The parsed date in the local time zone
19591 *
19592 * @example
19593 * // Clone the date:
19594 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
19595 * //=> Tue Feb 11 2014 11:30:30
19596 *
19597 * @example
19598 * // Convert the timestamp to date:
19599 * const result = toDate(1392098430000)
19600 * //=> Tue Feb 11 2014 11:30:30
19601 */
19602 function toDate(argument) {
19603 const argStr = Object.prototype.toString.call(argument);
19604
19605 // Clone the date
19606 if (
19607 argument instanceof Date ||
19608 (typeof argument === "object" && argStr === "[object Date]")
19609 ) {
19610 // Prevent the date to lose the milliseconds when passed to new Date() in IE10
19611 return new argument.constructor(+argument);
19612 } else if (
19613 typeof argument === "number" ||
19614 argStr === "[object Number]" ||
19615 typeof argument === "string" ||
19616 argStr === "[object String]"
19617 ) {
19618 // TODO: Can we get rid of as?
19619 return new Date(argument);
19620 } else {
19621 // TODO: Can we get rid of as?
19622 return new Date(NaN);
19623 }
19624 }
19625
19626 // Fallback for modularized imports:
19627 /* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate)));
19628
19629 ;// ./node_modules/date-fns/startOfMonth.mjs
19630
19631
19632 /**
19633 * @name startOfMonth
19634 * @category Month Helpers
19635 * @summary Return the start of a month for the given date.
19636 *
19637 * @description
19638 * Return the start of a month for the given date.
19639 * The result will be in the local timezone.
19640 *
19641 * @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).
19642 *
19643 * @param date - The original date
19644 *
19645 * @returns The start of a month
19646 *
19647 * @example
19648 * // The start of a month for 2 September 2014 11:55:00:
19649 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
19650 * //=> Mon Sep 01 2014 00:00:00
19651 */
19652 function startOfMonth(date) {
19653 const _date = toDate(date);
19654 _date.setDate(1);
19655 _date.setHours(0, 0, 0, 0);
19656 return _date;
19657 }
19658
19659 // Fallback for modularized imports:
19660 /* harmony default export */ const date_fns_startOfMonth = ((/* unused pure expression or super */ null && (startOfMonth)));
19661
19662 ;// ./node_modules/date-fns/endOfMonth.mjs
19663
19664
19665 /**
19666 * @name endOfMonth
19667 * @category Month Helpers
19668 * @summary Return the end of a month for the given date.
19669 *
19670 * @description
19671 * Return the end of a month for the given date.
19672 * The result will be in the local timezone.
19673 *
19674 * @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).
19675 *
19676 * @param date - The original date
19677 *
19678 * @returns The end of a month
19679 *
19680 * @example
19681 * // The end of a month for 2 September 2014 11:55:00:
19682 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
19683 * //=> Tue Sep 30 2014 23:59:59.999
19684 */
19685 function endOfMonth(date) {
19686 const _date = toDate(date);
19687 const month = _date.getMonth();
19688 _date.setFullYear(_date.getFullYear(), month + 1, 0);
19689 _date.setHours(23, 59, 59, 999);
19690 return _date;
19691 }
19692
19693 // Fallback for modularized imports:
19694 /* harmony default export */ const date_fns_endOfMonth = ((/* unused pure expression or super */ null && (endOfMonth)));
19695
19696 ;// ./node_modules/date-fns/constants.mjs
19697 /**
19698 * @module constants
19699 * @summary Useful constants
19700 * @description
19701 * Collection of useful date constants.
19702 *
19703 * The constants could be imported from `date-fns/constants`:
19704 *
19705 * ```ts
19706 * import { maxTime, minTime } from "./constants/date-fns/constants";
19707 *
19708 * function isAllowedTime(time) {
19709 * return time <= maxTime && time >= minTime;
19710 * }
19711 * ```
19712 */
19713
19714 /**
19715 * @constant
19716 * @name daysInWeek
19717 * @summary Days in 1 week.
19718 */
19719 const daysInWeek = 7;
19720
19721 /**
19722 * @constant
19723 * @name daysInYear
19724 * @summary Days in 1 year.
19725 *
19726 * @description
19727 * How many days in a year.
19728 *
19729 * One years equals 365.2425 days according to the formula:
19730 *
19731 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
19732 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
19733 */
19734 const daysInYear = 365.2425;
19735
19736 /**
19737 * @constant
19738 * @name maxTime
19739 * @summary Maximum allowed time.
19740 *
19741 * @example
19742 * import { maxTime } from "./constants/date-fns/constants";
19743 *
19744 * const isValid = 8640000000000001 <= maxTime;
19745 * //=> false
19746 *
19747 * new Date(8640000000000001);
19748 * //=> Invalid Date
19749 */
19750 const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
19751
19752 /**
19753 * @constant
19754 * @name minTime
19755 * @summary Minimum allowed time.
19756 *
19757 * @example
19758 * import { minTime } from "./constants/date-fns/constants";
19759 *
19760 * const isValid = -8640000000000001 >= minTime;
19761 * //=> false
19762 *
19763 * new Date(-8640000000000001)
19764 * //=> Invalid Date
19765 */
19766 const minTime = -maxTime;
19767
19768 /**
19769 * @constant
19770 * @name millisecondsInWeek
19771 * @summary Milliseconds in 1 week.
19772 */
19773 const millisecondsInWeek = 604800000;
19774
19775 /**
19776 * @constant
19777 * @name millisecondsInDay
19778 * @summary Milliseconds in 1 day.
19779 */
19780 const millisecondsInDay = 86400000;
19781
19782 /**
19783 * @constant
19784 * @name millisecondsInMinute
19785 * @summary Milliseconds in 1 minute
19786 */
19787 const millisecondsInMinute = 60000;
19788
19789 /**
19790 * @constant
19791 * @name millisecondsInHour
19792 * @summary Milliseconds in 1 hour
19793 */
19794 const millisecondsInHour = 3600000;
19795
19796 /**
19797 * @constant
19798 * @name millisecondsInSecond
19799 * @summary Milliseconds in 1 second
19800 */
19801 const millisecondsInSecond = 1000;
19802
19803 /**
19804 * @constant
19805 * @name minutesInYear
19806 * @summary Minutes in 1 year.
19807 */
19808 const minutesInYear = 525600;
19809
19810 /**
19811 * @constant
19812 * @name minutesInMonth
19813 * @summary Minutes in 1 month.
19814 */
19815 const minutesInMonth = 43200;
19816
19817 /**
19818 * @constant
19819 * @name minutesInDay
19820 * @summary Minutes in 1 day.
19821 */
19822 const minutesInDay = 1440;
19823
19824 /**
19825 * @constant
19826 * @name minutesInHour
19827 * @summary Minutes in 1 hour.
19828 */
19829 const minutesInHour = 60;
19830
19831 /**
19832 * @constant
19833 * @name monthsInQuarter
19834 * @summary Months in 1 quarter.
19835 */
19836 const monthsInQuarter = 3;
19837
19838 /**
19839 * @constant
19840 * @name monthsInYear
19841 * @summary Months in 1 year.
19842 */
19843 const monthsInYear = 12;
19844
19845 /**
19846 * @constant
19847 * @name quartersInYear
19848 * @summary Quarters in 1 year
19849 */
19850 const quartersInYear = 4;
19851
19852 /**
19853 * @constant
19854 * @name secondsInHour
19855 * @summary Seconds in 1 hour.
19856 */
19857 const secondsInHour = 3600;
19858
19859 /**
19860 * @constant
19861 * @name secondsInMinute
19862 * @summary Seconds in 1 minute.
19863 */
19864 const secondsInMinute = 60;
19865
19866 /**
19867 * @constant
19868 * @name secondsInDay
19869 * @summary Seconds in 1 day.
19870 */
19871 const secondsInDay = secondsInHour * 24;
19872
19873 /**
19874 * @constant
19875 * @name secondsInWeek
19876 * @summary Seconds in 1 week.
19877 */
19878 const secondsInWeek = secondsInDay * 7;
19879
19880 /**
19881 * @constant
19882 * @name secondsInYear
19883 * @summary Seconds in 1 year.
19884 */
19885 const secondsInYear = secondsInDay * daysInYear;
19886
19887 /**
19888 * @constant
19889 * @name secondsInMonth
19890 * @summary Seconds in 1 month
19891 */
19892 const secondsInMonth = secondsInYear / 12;
19893
19894 /**
19895 * @constant
19896 * @name secondsInQuarter
19897 * @summary Seconds in 1 quarter.
19898 */
19899 const secondsInQuarter = secondsInMonth * 3;
19900
19901 ;// ./node_modules/date-fns/parseISO.mjs
19902
19903
19904 /**
19905 * The {@link parseISO} function options.
19906 */
19907
19908 /**
19909 * @name parseISO
19910 * @category Common Helpers
19911 * @summary Parse ISO string
19912 *
19913 * @description
19914 * Parse the given string in ISO 8601 format and return an instance of Date.
19915 *
19916 * Function accepts complete ISO 8601 formats as well as partial implementations.
19917 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
19918 *
19919 * If the argument isn't a string, the function cannot parse the string or
19920 * the values are invalid, it returns Invalid Date.
19921 *
19922 * @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).
19923 *
19924 * @param argument - The value to convert
19925 * @param options - An object with options
19926 *
19927 * @returns The parsed date in the local time zone
19928 *
19929 * @example
19930 * // Convert string '2014-02-11T11:30:30' to date:
19931 * const result = parseISO('2014-02-11T11:30:30')
19932 * //=> Tue Feb 11 2014 11:30:30
19933 *
19934 * @example
19935 * // Convert string '+02014101' to date,
19936 * // if the additional number of digits in the extended year format is 1:
19937 * const result = parseISO('+02014101', { additionalDigits: 1 })
19938 * //=> Fri Apr 11 2014 00:00:00
19939 */
19940 function parseISO(argument, options) {
19941 const additionalDigits = options?.additionalDigits ?? 2;
19942 const dateStrings = splitDateString(argument);
19943
19944 let date;
19945 if (dateStrings.date) {
19946 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
19947 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
19948 }
19949
19950 if (!date || isNaN(date.getTime())) {
19951 return new Date(NaN);
19952 }
19953
19954 const timestamp = date.getTime();
19955 let time = 0;
19956 let offset;
19957
19958 if (dateStrings.time) {
19959 time = parseTime(dateStrings.time);
19960 if (isNaN(time)) {
19961 return new Date(NaN);
19962 }
19963 }
19964
19965 if (dateStrings.timezone) {
19966 offset = parseTimezone(dateStrings.timezone);
19967 if (isNaN(offset)) {
19968 return new Date(NaN);
19969 }
19970 } else {
19971 const dirtyDate = new Date(timestamp + time);
19972 // JS parsed string assuming it's in UTC timezone
19973 // but we need it to be parsed in our timezone
19974 // so we use utc values to build date in our timezone.
19975 // Year values from 0 to 99 map to the years 1900 to 1999
19976 // so set year explicitly with setFullYear.
19977 const result = new Date(0);
19978 result.setFullYear(
19979 dirtyDate.getUTCFullYear(),
19980 dirtyDate.getUTCMonth(),
19981 dirtyDate.getUTCDate(),
19982 );
19983 result.setHours(
19984 dirtyDate.getUTCHours(),
19985 dirtyDate.getUTCMinutes(),
19986 dirtyDate.getUTCSeconds(),
19987 dirtyDate.getUTCMilliseconds(),
19988 );
19989 return result;
19990 }
19991
19992 return new Date(timestamp + time + offset);
19993 }
19994
19995 const patterns = {
19996 dateTimeDelimiter: /[T ]/,
19997 timeZoneDelimiter: /[Z ]/i,
19998 timezone: /([Z+-].*)$/,
19999 };
20000
20001 const dateRegex =
20002 /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
20003 const timeRegex =
20004 /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
20005 const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
20006
20007 function splitDateString(dateString) {
20008 const dateStrings = {};
20009 const array = dateString.split(patterns.dateTimeDelimiter);
20010 let timeString;
20011
20012 // The regex match should only return at maximum two array elements.
20013 // [date], [time], or [date, time].
20014 if (array.length > 2) {
20015 return dateStrings;
20016 }
20017
20018 if (/:/.test(array[0])) {
20019 timeString = array[0];
20020 } else {
20021 dateStrings.date = array[0];
20022 timeString = array[1];
20023 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
20024 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
20025 timeString = dateString.substr(
20026 dateStrings.date.length,
20027 dateString.length,
20028 );
20029 }
20030 }
20031
20032 if (timeString) {
20033 const token = patterns.timezone.exec(timeString);
20034 if (token) {
20035 dateStrings.time = timeString.replace(token[1], "");
20036 dateStrings.timezone = token[1];
20037 } else {
20038 dateStrings.time = timeString;
20039 }
20040 }
20041
20042 return dateStrings;
20043 }
20044
20045 function parseYear(dateString, additionalDigits) {
20046 const regex = new RegExp(
20047 "^(?:(\\d{4}|[+-]\\d{" +
20048 (4 + additionalDigits) +
20049 "})|(\\d{2}|[+-]\\d{" +
20050 (2 + additionalDigits) +
20051 "})$)",
20052 );
20053
20054 const captures = dateString.match(regex);
20055 // Invalid ISO-formatted year
20056 if (!captures) return { year: NaN, restDateString: "" };
20057
20058 const year = captures[1] ? parseInt(captures[1]) : null;
20059 const century = captures[2] ? parseInt(captures[2]) : null;
20060
20061 // either year or century is null, not both
20062 return {
20063 year: century === null ? year : century * 100,
20064 restDateString: dateString.slice((captures[1] || captures[2]).length),
20065 };
20066 }
20067
20068 function parseDate(dateString, year) {
20069 // Invalid ISO-formatted year
20070 if (year === null) return new Date(NaN);
20071
20072 const captures = dateString.match(dateRegex);
20073 // Invalid ISO-formatted string
20074 if (!captures) return new Date(NaN);
20075
20076 const isWeekDate = !!captures[4];
20077 const dayOfYear = parseDateUnit(captures[1]);
20078 const month = parseDateUnit(captures[2]) - 1;
20079 const day = parseDateUnit(captures[3]);
20080 const week = parseDateUnit(captures[4]);
20081 const dayOfWeek = parseDateUnit(captures[5]) - 1;
20082
20083 if (isWeekDate) {
20084 if (!validateWeekDate(year, week, dayOfWeek)) {
20085 return new Date(NaN);
20086 }
20087 return dayOfISOWeekYear(year, week, dayOfWeek);
20088 } else {
20089 const date = new Date(0);
20090 if (
20091 !validateDate(year, month, day) ||
20092 !validateDayOfYearDate(year, dayOfYear)
20093 ) {
20094 return new Date(NaN);
20095 }
20096 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
20097 return date;
20098 }
20099 }
20100
20101 function parseDateUnit(value) {
20102 return value ? parseInt(value) : 1;
20103 }
20104
20105 function parseTime(timeString) {
20106 const captures = timeString.match(timeRegex);
20107 if (!captures) return NaN; // Invalid ISO-formatted time
20108
20109 const hours = parseTimeUnit(captures[1]);
20110 const minutes = parseTimeUnit(captures[2]);
20111 const seconds = parseTimeUnit(captures[3]);
20112
20113 if (!validateTime(hours, minutes, seconds)) {
20114 return NaN;
20115 }
20116
20117 return (
20118 hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000
20119 );
20120 }
20121
20122 function parseTimeUnit(value) {
20123 return (value && parseFloat(value.replace(",", "."))) || 0;
20124 }
20125
20126 function parseTimezone(timezoneString) {
20127 if (timezoneString === "Z") return 0;
20128
20129 const captures = timezoneString.match(timezoneRegex);
20130 if (!captures) return 0;
20131
20132 const sign = captures[1] === "+" ? -1 : 1;
20133 const hours = parseInt(captures[2]);
20134 const minutes = (captures[3] && parseInt(captures[3])) || 0;
20135
20136 if (!validateTimezone(hours, minutes)) {
20137 return NaN;
20138 }
20139
20140 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
20141 }
20142
20143 function dayOfISOWeekYear(isoWeekYear, week, day) {
20144 const date = new Date(0);
20145 date.setUTCFullYear(isoWeekYear, 0, 4);
20146 const fourthOfJanuaryDay = date.getUTCDay() || 7;
20147 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
20148 date.setUTCDate(date.getUTCDate() + diff);
20149 return date;
20150 }
20151
20152 // Validation functions
20153
20154 // February is null to handle the leap year (using ||)
20155 const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
20156
20157 function isLeapYearIndex(year) {
20158 return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
20159 }
20160
20161 function validateDate(year, month, date) {
20162 return (
20163 month >= 0 &&
20164 month <= 11 &&
20165 date >= 1 &&
20166 date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28))
20167 );
20168 }
20169
20170 function validateDayOfYearDate(year, dayOfYear) {
20171 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
20172 }
20173
20174 function validateWeekDate(_year, week, day) {
20175 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
20176 }
20177
20178 function validateTime(hours, minutes, seconds) {
20179 if (hours === 24) {
20180 return minutes === 0 && seconds === 0;
20181 }
20182
20183 return (
20184 seconds >= 0 &&
20185 seconds < 60 &&
20186 minutes >= 0 &&
20187 minutes < 60 &&
20188 hours >= 0 &&
20189 hours < 25
20190 );
20191 }
20192
20193 function validateTimezone(_hours, minutes) {
20194 return minutes >= 0 && minutes <= 59;
20195 }
20196
20197 // Fallback for modularized imports:
20198 /* harmony default export */ const date_fns_parseISO = ((/* unused pure expression or super */ null && (parseISO)));
20199
20200 ;// ./packages/editor/build-module/components/post-schedule/index.js
20201 /* wp:polyfill */
20202 /**
20203 * External dependencies
20204 */
20205
20206
20207 /**
20208 * WordPress dependencies
20209 */
20210
20211
20212
20213
20214
20215
20216
20217 /**
20218 * Internal dependencies
20219 */
20220
20221
20222
20223 const {
20224 PrivatePublishDateTimePicker
20225 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
20226
20227 /**
20228 * Renders the PostSchedule component. It allows the user to schedule a post.
20229 *
20230 * @param {Object} props Props.
20231 * @param {Function} props.onClose Function to close the component.
20232 *
20233 * @return {React.ReactNode} The rendered component.
20234 */
20235 function PostSchedule(props) {
20236 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
20237 ...props,
20238 showPopoverHeaderActions: true,
20239 isCompact: false
20240 });
20241 }
20242 function PrivatePostSchedule({
20243 onClose,
20244 showPopoverHeaderActions,
20245 isCompact
20246 }) {
20247 const {
20248 postDate,
20249 postType
20250 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
20251 postDate: select(store_store).getEditedPostAttribute('date'),
20252 postType: select(store_store).getCurrentPostType()
20253 }), []);
20254 const {
20255 editPost
20256 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20257 const onUpdateDate = date => editPost({
20258 date
20259 });
20260 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate)));
20261
20262 // Pick up published and schduled site posts.
20263 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
20264 status: 'publish,future',
20265 after: startOfMonth(previewedMonth).toISOString(),
20266 before: endOfMonth(previewedMonth).toISOString(),
20267 exclude: [select(store_store).getCurrentPostId()],
20268 per_page: 100,
20269 _fields: 'id,date'
20270 }), [previewedMonth, postType]);
20271 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({
20272 date: eventDate
20273 }) => ({
20274 date: new Date(eventDate)
20275 })), [eventsByPostType]);
20276 const settings = (0,external_wp_date_namespaceObject.getSettings)();
20277
20278 // To know if the current timezone is a 12 hour time with look for "a" in the time format
20279 // We also make sure this a is not escaped by a "/"
20280 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
20281 .replace(/\\\\/g, '') // Replace "//" with empty strings.
20282 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
20283 );
20284 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePublishDateTimePicker, {
20285 currentDate: postDate,
20286 onChange: onUpdateDate,
20287 is12Hour: is12HourTime,
20288 dateOrder: /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
20289 (0,external_wp_i18n_namespaceObject._x)('dmy', 'date order'),
20290 events: events,
20291 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)),
20292 onClose: onClose,
20293 isCompact: isCompact,
20294 showPopoverHeaderActions: showPopoverHeaderActions
20295 });
20296 }
20297
20298 ;// ./packages/editor/build-module/components/post-schedule/label.js
20299 /**
20300 * WordPress dependencies
20301 */
20302
20303
20304
20305
20306 /**
20307 * Internal dependencies
20308 */
20309
20310
20311 /**
20312 * Renders the PostScheduleLabel component.
20313 *
20314 * @param {Object} props Props.
20315 *
20316 * @return {React.ReactNode} The rendered component.
20317 */
20318 function PostScheduleLabel(props) {
20319 return usePostScheduleLabel(props);
20320 }
20321
20322 /**
20323 * Custom hook to get the label for post schedule.
20324 *
20325 * @param {Object} options Options for the hook.
20326 * @param {boolean} options.full Whether to get the full label or not. Default is false.
20327 *
20328 * @return {string} The label for post schedule.
20329 */
20330 function usePostScheduleLabel({
20331 full = false
20332 } = {}) {
20333 const {
20334 date,
20335 isFloating
20336 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
20337 date: select(store_store).getEditedPostAttribute('date'),
20338 isFloating: select(store_store).isEditedPostDateFloating()
20339 }), []);
20340 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, {
20341 isFloating
20342 });
20343 }
20344 function getFullPostScheduleLabel(dateAttribute) {
20345 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
20346 const timezoneAbbreviation = getTimezoneAbbreviation();
20347 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(
20348 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
20349 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
20350 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
20351 }
20352 function getPostScheduleLabel(dateAttribute, {
20353 isFloating = false,
20354 now = new Date()
20355 } = {}) {
20356 if (!dateAttribute || isFloating) {
20357 return (0,external_wp_i18n_namespaceObject.__)('Immediately');
20358 }
20359
20360 // If the user timezone does not equal the site timezone then using words
20361 // like 'tomorrow' is confusing, so show the full date.
20362 if (!isTimezoneSameAsSiteTimezone(now)) {
20363 return getFullPostScheduleLabel(dateAttribute);
20364 }
20365 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
20366 if (isSameDay(date, now)) {
20367 return (0,external_wp_i18n_namespaceObject.sprintf)(
20368 // translators: %s: Time of day the post is scheduled for.
20369 (0,external_wp_i18n_namespaceObject.__)('Today at %s'),
20370 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
20371 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
20372 }
20373 const tomorrow = new Date(now);
20374 tomorrow.setDate(tomorrow.getDate() + 1);
20375 if (isSameDay(date, tomorrow)) {
20376 return (0,external_wp_i18n_namespaceObject.sprintf)(
20377 // translators: %s: Time of day the post is scheduled for.
20378 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'),
20379 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
20380 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
20381 }
20382 if (date.getFullYear() === now.getFullYear()) {
20383 return (0,external_wp_date_namespaceObject.dateI18n)(
20384 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
20385 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date);
20386 }
20387 return (0,external_wp_date_namespaceObject.dateI18n)(
20388 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
20389 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
20390 }
20391 function getTimezoneAbbreviation() {
20392 const {
20393 timezone
20394 } = (0,external_wp_date_namespaceObject.getSettings)();
20395 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
20396 return timezone.abbr;
20397 }
20398 const symbol = timezone.offset < 0 ? '' : '+';
20399 return `UTC${symbol}${timezone.offsetFormatted}`;
20400 }
20401 function isTimezoneSameAsSiteTimezone(date) {
20402 const {
20403 timezone
20404 } = (0,external_wp_date_namespaceObject.getSettings)();
20405 const siteOffset = Number(timezone.offset);
20406 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
20407 return siteOffset === dateOffset;
20408 }
20409 function isSameDay(left, right) {
20410 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
20411 }
20412
20413 ;// ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
20414 /* wp:polyfill */
20415 /**
20416 * WordPress dependencies
20417 */
20418
20419
20420
20421
20422 /**
20423 * Internal dependencies
20424 */
20425
20426
20427 const MIN_MOST_USED_TERMS = 3;
20428 const DEFAULT_QUERY = {
20429 per_page: 10,
20430 orderby: 'count',
20431 order: 'desc',
20432 hide_empty: true,
20433 _fields: 'id,name,count',
20434 context: 'view'
20435 };
20436 function MostUsedTerms({
20437 onSelect,
20438 taxonomy
20439 }) {
20440 const {
20441 _terms,
20442 showTerms
20443 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20444 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
20445 return {
20446 _terms: mostUsedTerms,
20447 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
20448 };
20449 }, [taxonomy.slug]);
20450 if (!showTerms) {
20451 return null;
20452 }
20453 const terms = unescapeTerms(_terms);
20454 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
20455 className: "editor-post-taxonomies__flat-term-most-used",
20456 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
20457 as: "h3",
20458 className: "editor-post-taxonomies__flat-term-most-used-label",
20459 children: taxonomy.labels.most_used
20460 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
20461 role: "list",
20462 className: "editor-post-taxonomies__flat-term-most-used-list",
20463 children: terms.map(term => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
20464 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20465 __next40pxDefaultSize: true,
20466 variant: "link",
20467 onClick: () => onSelect(term),
20468 children: term.name
20469 })
20470 }, term.id))
20471 })]
20472 });
20473 }
20474
20475 ;// ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
20476 /* wp:polyfill */
20477 /**
20478 * WordPress dependencies
20479 */
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490 /**
20491 * Internal dependencies
20492 */
20493
20494
20495
20496
20497 /**
20498 * Shared reference to an empty array for cases where it is important to avoid
20499 * returning a new array reference on every invocation.
20500 *
20501 * @type {Array<any>}
20502 */
20503
20504 const flat_term_selector_EMPTY_ARRAY = [];
20505
20506 /**
20507 * How the max suggestions limit was chosen:
20508 * - Matches the `per_page` range set by the REST API.
20509 * - Can't use "unbound" query. The `FormTokenField` needs a fixed number.
20510 * - Matches default for `FormTokenField`.
20511 */
20512 const MAX_TERMS_SUGGESTIONS = 100;
20513 const flat_term_selector_DEFAULT_QUERY = {
20514 per_page: MAX_TERMS_SUGGESTIONS,
20515 _fields: 'id,name',
20516 context: 'view'
20517 };
20518 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
20519 const termNamesToIds = (names, terms) => {
20520 return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
20521 };
20522 const Wrapper = ({
20523 children,
20524 __nextHasNoMarginBottom
20525 }) => __nextHasNoMarginBottom ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
20526 spacing: 4,
20527 children: children
20528 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
20529 children: children
20530 });
20531
20532 /**
20533 * Renders a flat term selector component.
20534 *
20535 * @param {Object} props The component props.
20536 * @param {string} props.slug The slug of the taxonomy.
20537 * @param {boolean} props.__nextHasNoMarginBottom Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 7.0. (The prop can be safely removed once this happens.)
20538 *
20539 * @return {React.ReactNode} The rendered flat term selector component.
20540 */
20541 function FlatTermSelector({
20542 slug,
20543 __nextHasNoMarginBottom
20544 }) {
20545 var _taxonomy$labels$add_, _taxonomy$labels$sing2;
20546 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
20547 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
20548 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
20549 if (!__nextHasNoMarginBottom) {
20550 external_wp_deprecated_default()('Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector', {
20551 since: '6.7',
20552 version: '7.0',
20553 hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.'
20554 });
20555 }
20556 const {
20557 terms,
20558 termIds,
20559 taxonomy,
20560 hasAssignAction,
20561 hasCreateAction,
20562 hasResolvedTerms
20563 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20564 var _post$_links, _post$_links2;
20565 const {
20566 getCurrentPost,
20567 getEditedPostAttribute
20568 } = select(store_store);
20569 const {
20570 getEntityRecords,
20571 getTaxonomy,
20572 hasFinishedResolution
20573 } = select(external_wp_coreData_namespaceObject.store);
20574 const post = getCurrentPost();
20575 const _taxonomy = getTaxonomy(slug);
20576 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
20577 const query = {
20578 ...flat_term_selector_DEFAULT_QUERY,
20579 include: _termIds?.join(','),
20580 per_page: -1
20581 };
20582 return {
20583 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
20584 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
20585 taxonomy: _taxonomy,
20586 termIds: _termIds,
20587 terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
20588 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
20589 };
20590 }, [slug]);
20591 const {
20592 searchResults
20593 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20594 const {
20595 getEntityRecords
20596 } = select(external_wp_coreData_namespaceObject.store);
20597 return {
20598 searchResults: !!search ? getEntityRecords('taxonomy', slug, {
20599 ...flat_term_selector_DEFAULT_QUERY,
20600 search
20601 }) : flat_term_selector_EMPTY_ARRAY
20602 };
20603 }, [search, slug]);
20604
20605 // Update terms state only after the selectors are resolved.
20606 // We're using this to avoid terms temporarily disappearing on slow networks
20607 // while core data makes REST API requests.
20608 (0,external_wp_element_namespaceObject.useEffect)(() => {
20609 if (hasResolvedTerms) {
20610 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
20611 setValues(newValues);
20612 }
20613 }, [terms, hasResolvedTerms]);
20614 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
20615 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
20616 }, [searchResults]);
20617 const {
20618 editPost
20619 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20620 const {
20621 saveEntityRecord
20622 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
20623 const {
20624 createErrorNotice
20625 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
20626 if (!hasAssignAction) {
20627 return null;
20628 }
20629 async function findOrCreateTerm(term) {
20630 try {
20631 const newTerm = await saveEntityRecord('taxonomy', slug, term, {
20632 throwOnError: true
20633 });
20634 return unescapeTerm(newTerm);
20635 } catch (error) {
20636 if (error.code !== 'term_exists') {
20637 throw error;
20638 }
20639 return {
20640 id: error.data.term_id,
20641 name: term.name
20642 };
20643 }
20644 }
20645 function onUpdateTerms(newTermIds) {
20646 editPost({
20647 [taxonomy.rest_base]: newTermIds
20648 });
20649 }
20650 function onChange(termNames) {
20651 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
20652 const uniqueTerms = termNames.reduce((acc, name) => {
20653 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
20654 acc.push(name);
20655 }
20656 return acc;
20657 }, []);
20658 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
20659
20660 // Optimistically update term values.
20661 // The selector will always re-fetch terms later.
20662 setValues(uniqueTerms);
20663 if (newTermNames.length === 0) {
20664 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
20665 return;
20666 }
20667 if (!hasCreateAction) {
20668 return;
20669 }
20670 Promise.all(newTermNames.map(termName => findOrCreateTerm({
20671 name: termName
20672 }))).then(newTerms => {
20673 const newAvailableTerms = availableTerms.concat(newTerms);
20674 onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
20675 }).catch(error => {
20676 createErrorNotice(error.message, {
20677 type: 'snackbar'
20678 });
20679 // In case of a failure, try assigning available terms.
20680 // This will invalidate the optimistic update.
20681 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
20682 });
20683 }
20684 function appendTerm(newTerm) {
20685 var _taxonomy$labels$sing;
20686 if (termIds.includes(newTerm.id)) {
20687 return;
20688 }
20689 const newTermIds = [...termIds, newTerm.id];
20690 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
20691 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
20692 (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);
20693 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
20694 onUpdateTerms(newTermIds);
20695 }
20696 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');
20697 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');
20698 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
20699 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
20700 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
20701 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
20702 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
20703 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
20704 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Wrapper, {
20705 __nextHasNoMarginBottom: __nextHasNoMarginBottom,
20706 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
20707 __next40pxDefaultSize: true,
20708 value: values,
20709 suggestions: suggestions,
20710 onChange: onChange,
20711 onInputChange: debouncedSearch,
20712 maxSuggestions: MAX_TERMS_SUGGESTIONS,
20713 label: newTermLabel,
20714 messages: {
20715 added: termAddedLabel,
20716 removed: termRemovedLabel,
20717 remove: removeTermLabel
20718 },
20719 __nextHasNoMarginBottom: __nextHasNoMarginBottom
20720 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MostUsedTerms, {
20721 taxonomy: taxonomy,
20722 onSelect: appendTerm
20723 })]
20724 });
20725 }
20726 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
20727
20728 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
20729 /**
20730 * WordPress dependencies
20731 */
20732
20733
20734
20735
20736
20737
20738 /**
20739 * Internal dependencies
20740 */
20741
20742
20743
20744 const TagsPanel = () => {
20745 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
20746 className: "editor-post-publish-panel__link",
20747 children: (0,external_wp_i18n_namespaceObject.__)('Add tags')
20748 }, "label")];
20749 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
20750 initialOpen: false,
20751 title: panelBodyTitle,
20752 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
20753 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.')
20754 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flat_term_selector, {
20755 slug: "post_tag",
20756 __nextHasNoMarginBottom: true
20757 })]
20758 });
20759 };
20760 const MaybeTagsPanel = () => {
20761 const {
20762 hasTags,
20763 isPostTypeSupported
20764 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20765 const postType = select(store_store).getCurrentPostType();
20766 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
20767 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
20768 const areTagsFetched = tagsTaxonomy !== undefined;
20769 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
20770 return {
20771 hasTags: !!tags?.length,
20772 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
20773 };
20774 }, []);
20775 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags);
20776 if (!isPostTypeSupported) {
20777 return null;
20778 }
20779
20780 /*
20781 * We only want to show the tag panel if the post didn't have
20782 * any tags when the user hit the Publish button.
20783 *
20784 * We can't use the prop.hasTags because it'll change to true
20785 * if the user adds a new tag within the pre-publish panel.
20786 * This would force a re-render and a new prop.hasTags check,
20787 * hiding this panel and keeping the user from adding
20788 * more than one tag.
20789 */
20790 if (!hadTagsWhenOpeningThePanel) {
20791 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TagsPanel, {});
20792 }
20793 return null;
20794 };
20795 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel);
20796
20797 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
20798 /* wp:polyfill */
20799 /**
20800 * WordPress dependencies
20801 */
20802
20803
20804
20805
20806
20807 /**
20808 * Internal dependencies
20809 */
20810
20811
20812
20813 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
20814 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id));
20815 return formats.find(format => format.id === suggestedPostFormat);
20816 };
20817 const PostFormatSuggestion = ({
20818 suggestedPostFormat,
20819 suggestionText,
20820 onUpdatePostFormat
20821 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20822 __next40pxDefaultSize: true,
20823 variant: "link",
20824 onClick: () => onUpdatePostFormat(suggestedPostFormat),
20825 children: suggestionText
20826 });
20827 function PostFormatPanel() {
20828 const {
20829 currentPostFormat,
20830 suggestion
20831 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20832 var _select$getThemeSuppo;
20833 const {
20834 getEditedPostAttribute,
20835 getSuggestedPostFormat
20836 } = select(store_store);
20837 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
20838 return {
20839 currentPostFormat: getEditedPostAttribute('format'),
20840 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
20841 };
20842 }, []);
20843 const {
20844 editPost
20845 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20846 const onUpdatePostFormat = format => editPost({
20847 format
20848 });
20849 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
20850 className: "editor-post-publish-panel__link",
20851 children: (0,external_wp_i18n_namespaceObject.__)('Use a post format')
20852 }, "label")];
20853 if (!suggestion || suggestion.id === currentPostFormat) {
20854 return null;
20855 }
20856 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
20857 initialOpen: false,
20858 title: panelBodyTitle,
20859 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
20860 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.')
20861 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
20862 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatSuggestion, {
20863 onUpdatePostFormat: onUpdatePostFormat,
20864 suggestedPostFormat: suggestion.id,
20865 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post format */
20866 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
20867 })
20868 })]
20869 });
20870 }
20871
20872 ;// ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
20873 /* wp:polyfill */
20874 /**
20875 * WordPress dependencies
20876 */
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887 /**
20888 * Internal dependencies
20889 */
20890
20891
20892
20893 /**
20894 * Module Constants
20895 */
20896
20897 const hierarchical_term_selector_DEFAULT_QUERY = {
20898 per_page: -1,
20899 orderby: 'name',
20900 order: 'asc',
20901 _fields: 'id,name,parent',
20902 context: 'view'
20903 };
20904 const MIN_TERMS_COUNT_FOR_FILTER = 8;
20905 const hierarchical_term_selector_EMPTY_ARRAY = [];
20906
20907 /**
20908 * Sort Terms by Selected.
20909 *
20910 * @param {Object[]} termsTree Array of terms in tree format.
20911 * @param {number[]} terms Selected terms.
20912 *
20913 * @return {Object[]} Sorted array of terms.
20914 */
20915 function sortBySelected(termsTree, terms) {
20916 const treeHasSelection = termTree => {
20917 if (terms.indexOf(termTree.id) !== -1) {
20918 return true;
20919 }
20920 if (undefined === termTree.children) {
20921 return false;
20922 }
20923 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
20924 };
20925 const termOrChildIsSelected = (termA, termB) => {
20926 const termASelected = treeHasSelection(termA);
20927 const termBSelected = treeHasSelection(termB);
20928 if (termASelected === termBSelected) {
20929 return 0;
20930 }
20931 if (termASelected && !termBSelected) {
20932 return -1;
20933 }
20934 if (!termASelected && termBSelected) {
20935 return 1;
20936 }
20937 return 0;
20938 };
20939 const newTermTree = [...termsTree];
20940 newTermTree.sort(termOrChildIsSelected);
20941 return newTermTree;
20942 }
20943
20944 /**
20945 * Find term by parent id or name.
20946 *
20947 * @param {Object[]} terms Array of Terms.
20948 * @param {number|string} parent id.
20949 * @param {string} name Term name.
20950 * @return {Object} Term object.
20951 */
20952 function findTerm(terms, parent, name) {
20953 return terms.find(term => {
20954 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
20955 });
20956 }
20957
20958 /**
20959 * Get filter matcher function.
20960 *
20961 * @param {string} filterValue Filter value.
20962 * @return {(function(Object): (Object|boolean))} Matcher function.
20963 */
20964 function getFilterMatcher(filterValue) {
20965 const matchTermsForFilter = originalTerm => {
20966 if ('' === filterValue) {
20967 return originalTerm;
20968 }
20969
20970 // Shallow clone, because we'll be filtering the term's children and
20971 // don't want to modify the original term.
20972 const term = {
20973 ...originalTerm
20974 };
20975
20976 // Map and filter the children, recursive so we deal with grandchildren
20977 // and any deeper levels.
20978 if (term.children.length > 0) {
20979 term.children = term.children.map(matchTermsForFilter).filter(child => child);
20980 }
20981
20982 // If the term's name contains the filterValue, or it has children
20983 // (i.e. some child matched at some point in the tree) then return it.
20984 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
20985 return term;
20986 }
20987
20988 // Otherwise, return false. After mapping, the list of terms will need
20989 // to have false values filtered out.
20990 return false;
20991 };
20992 return matchTermsForFilter;
20993 }
20994
20995 /**
20996 * Hierarchical term selector.
20997 *
20998 * @param {Object} props Component props.
20999 * @param {string} props.slug Taxonomy slug.
21000 * @return {Element} Hierarchical term selector component.
21001 */
21002 function HierarchicalTermSelector({
21003 slug
21004 }) {
21005 var _taxonomy$labels$sear, _taxonomy$name;
21006 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
21007 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
21008 /**
21009 * @type {[number|'', Function]}
21010 */
21011 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
21012 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
21013 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
21014 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
21015 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
21016 const {
21017 hasCreateAction,
21018 hasAssignAction,
21019 terms,
21020 loading,
21021 availableTerms,
21022 taxonomy
21023 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21024 var _post$_links, _post$_links2;
21025 const {
21026 getCurrentPost,
21027 getEditedPostAttribute
21028 } = select(store_store);
21029 const {
21030 getTaxonomy,
21031 getEntityRecords,
21032 isResolving
21033 } = select(external_wp_coreData_namespaceObject.store);
21034 const _taxonomy = getTaxonomy(slug);
21035 const post = getCurrentPost();
21036 return {
21037 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
21038 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
21039 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
21040 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
21041 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
21042 taxonomy: _taxonomy
21043 };
21044 }, [slug]);
21045 const {
21046 editPost
21047 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21048 const {
21049 saveEntityRecord
21050 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
21051 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(terms_buildTermsTree(availableTerms), terms),
21052 // Remove `terms` from the dependency list to avoid reordering every time
21053 // checking or unchecking a term.
21054 [availableTerms]);
21055 const {
21056 createErrorNotice
21057 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
21058 if (!hasAssignAction) {
21059 return null;
21060 }
21061
21062 /**
21063 * Append new term.
21064 *
21065 * @param {Object} term Term object.
21066 * @return {Promise} A promise that resolves to save term object.
21067 */
21068 const addTerm = term => {
21069 return saveEntityRecord('taxonomy', slug, term, {
21070 throwOnError: true
21071 });
21072 };
21073
21074 /**
21075 * Update terms for post.
21076 *
21077 * @param {number[]} termIds Term ids.
21078 */
21079 const onUpdateTerms = termIds => {
21080 editPost({
21081 [taxonomy.rest_base]: termIds
21082 });
21083 };
21084
21085 /**
21086 * Handler for checking term.
21087 *
21088 * @param {number} termId
21089 */
21090 const onChange = termId => {
21091 const hasTerm = terms.includes(termId);
21092 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
21093 onUpdateTerms(newTerms);
21094 };
21095 const onChangeFormName = value => {
21096 setFormName(value);
21097 };
21098
21099 /**
21100 * Handler for changing form parent.
21101 *
21102 * @param {number|''} parentId Parent post id.
21103 */
21104 const onChangeFormParent = parentId => {
21105 setFormParent(parentId);
21106 };
21107 const onToggleForm = () => {
21108 setShowForm(!showForm);
21109 };
21110 const onAddTerm = async event => {
21111 var _taxonomy$labels$sing;
21112 event.preventDefault();
21113 if (formName === '' || adding) {
21114 return;
21115 }
21116
21117 // Check if the term we are adding already exists.
21118 const existingTerm = findTerm(availableTerms, formParent, formName);
21119 if (existingTerm) {
21120 // If the term we are adding exists but is not selected select it.
21121 if (!terms.some(term => term === existingTerm.id)) {
21122 onUpdateTerms([...terms, existingTerm.id]);
21123 }
21124 setFormName('');
21125 setFormParent('');
21126 return;
21127 }
21128 setAdding(true);
21129 let newTerm;
21130 try {
21131 newTerm = await addTerm({
21132 name: formName,
21133 parent: formParent ? formParent : undefined
21134 });
21135 } catch (error) {
21136 createErrorNotice(error.message, {
21137 type: 'snackbar'
21138 });
21139 return;
21140 }
21141 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term');
21142 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: term name. */
21143 (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);
21144 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
21145 setAdding(false);
21146 setFormName('');
21147 setFormParent('');
21148 onUpdateTerms([...terms, newTerm.id]);
21149 };
21150 const setFilter = value => {
21151 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
21152 const getResultCount = termsTree => {
21153 let count = 0;
21154 for (let i = 0; i < termsTree.length; i++) {
21155 count++;
21156 if (undefined !== termsTree[i].children) {
21157 count += getResultCount(termsTree[i].children);
21158 }
21159 }
21160 return count;
21161 };
21162 setFilterValue(value);
21163 setFilteredTermsTree(newFilteredTermsTree);
21164 const resultCount = getResultCount(newFilteredTermsTree);
21165 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %d: number of results. */
21166 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
21167 debouncedSpeak(resultsFoundMessage, 'assertive');
21168 };
21169 const renderTerms = renderedTerms => {
21170 return renderedTerms.map(term => {
21171 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21172 className: "editor-post-taxonomies__hierarchical-terms-choice",
21173 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
21174 __nextHasNoMarginBottom: true,
21175 checked: terms.indexOf(term.id) !== -1,
21176 onChange: () => {
21177 const termId = parseInt(term.id, 10);
21178 onChange(termId);
21179 },
21180 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name)
21181 }), !!term.children.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21182 className: "editor-post-taxonomies__hierarchical-terms-subchoices",
21183 children: renderTerms(term.children)
21184 })]
21185 }, term.id);
21186 });
21187 };
21188 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
21189 var _taxonomy$labels$labe;
21190 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
21191 };
21192 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
21193 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
21194 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
21195 const noParentOption = `— ${parentSelectLabel} —`;
21196 const newTermSubmitLabel = newTermButtonLabel;
21197 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');
21198 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms');
21199 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
21200 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
21201 direction: "column",
21202 gap: "4",
21203 children: [showFilter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
21204 __next40pxDefaultSize: true,
21205 __nextHasNoMarginBottom: true,
21206 label: filterLabel,
21207 placeholder: filterLabel,
21208 value: filterValue,
21209 onChange: setFilter
21210 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21211 className: "editor-post-taxonomies__hierarchical-terms-list",
21212 tabIndex: "0",
21213 role: "group",
21214 "aria-label": groupLabel,
21215 children: renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)
21216 }), !loading && hasCreateAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21217 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21218 __next40pxDefaultSize: true,
21219 onClick: onToggleForm,
21220 className: "editor-post-taxonomies__hierarchical-terms-add",
21221 "aria-expanded": showForm,
21222 variant: "link",
21223 children: newTermButtonLabel
21224 })
21225 }), showForm && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
21226 onSubmit: onAddTerm,
21227 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
21228 direction: "column",
21229 gap: "4",
21230 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
21231 __next40pxDefaultSize: true,
21232 __nextHasNoMarginBottom: true,
21233 className: "editor-post-taxonomies__hierarchical-terms-input",
21234 label: newTermLabel,
21235 value: formName,
21236 onChange: onChangeFormName,
21237 required: true
21238 }), !!availableTerms.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TreeSelect, {
21239 __next40pxDefaultSize: true,
21240 __nextHasNoMarginBottom: true,
21241 label: parentSelectLabel,
21242 noOptionLabel: noParentOption,
21243 onChange: onChangeFormParent,
21244 selectedId: formParent,
21245 tree: availableTermsTree
21246 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21247 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21248 __next40pxDefaultSize: true,
21249 variant: "secondary",
21250 type: "submit",
21251 className: "editor-post-taxonomies__hierarchical-terms-submit",
21252 children: newTermSubmitLabel
21253 })
21254 })]
21255 })
21256 })]
21257 });
21258 }
21259 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
21260
21261 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
21262 /* wp:polyfill */
21263 /**
21264 * WordPress dependencies
21265 */
21266
21267
21268
21269
21270
21271
21272 /**
21273 * Internal dependencies
21274 */
21275
21276
21277
21278 function MaybeCategoryPanel() {
21279 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
21280 const postType = select(store_store).getCurrentPostType();
21281 const {
21282 canUser,
21283 getEntityRecord,
21284 getTaxonomy
21285 } = select(external_wp_coreData_namespaceObject.store);
21286 const categoriesTaxonomy = getTaxonomy('category');
21287 const defaultCategoryId = canUser('read', {
21288 kind: 'root',
21289 name: 'site'
21290 }) ? getEntityRecord('root', 'site')?.default_category : undefined;
21291 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
21292 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
21293 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
21294
21295 // This boolean should return true if everything is loaded
21296 // ( categoriesTaxonomy, defaultCategory )
21297 // and the post has not been assigned a category different than "uncategorized".
21298 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
21299 }, []);
21300 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
21301 (0,external_wp_element_namespaceObject.useEffect)(() => {
21302 // We use state to avoid hiding the panel if the user edits the categories
21303 // and adds one within the panel itself (while visible).
21304 if (hasNoCategory) {
21305 setShouldShowPanel(true);
21306 }
21307 }, [hasNoCategory]);
21308 if (!shouldShowPanel) {
21309 return null;
21310 }
21311 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21312 className: "editor-post-publish-panel__link",
21313 children: (0,external_wp_i18n_namespaceObject.__)('Assign a category')
21314 }, "label")];
21315 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
21316 initialOpen: false,
21317 title: panelBodyTitle,
21318 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21319 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.')
21320 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(hierarchical_term_selector, {
21321 slug: "category"
21322 })]
21323 });
21324 }
21325 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
21326
21327 ;// ./node_modules/uuid/dist/esm-browser/native.js
21328 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
21329 /* harmony default export */ const esm_browser_native = ({
21330 randomUUID
21331 });
21332 ;// ./node_modules/uuid/dist/esm-browser/rng.js
21333 // Unique ID creation requires a high quality random # generator. In the browser we therefore
21334 // require the crypto API and do not support built-in fallback to lower quality random number
21335 // generators (like Math.random()).
21336 let getRandomValues;
21337 const rnds8 = new Uint8Array(16);
21338 function rng() {
21339 // lazy load so that environments that need to polyfill have a chance to do so
21340 if (!getRandomValues) {
21341 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
21342 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
21343
21344 if (!getRandomValues) {
21345 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
21346 }
21347 }
21348
21349 return getRandomValues(rnds8);
21350 }
21351 ;// ./node_modules/uuid/dist/esm-browser/stringify.js
21352
21353 /**
21354 * Convert array of 16 byte values to UUID string format of the form:
21355 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
21356 */
21357
21358 const byteToHex = [];
21359
21360 for (let i = 0; i < 256; ++i) {
21361 byteToHex.push((i + 0x100).toString(16).slice(1));
21362 }
21363
21364 function unsafeStringify(arr, offset = 0) {
21365 // Note: Be careful editing this code! It's been tuned for performance
21366 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
21367 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
21368 }
21369
21370 function stringify(arr, offset = 0) {
21371 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
21372 // of the following:
21373 // - One or more input array values don't map to a hex octet (leading to
21374 // "undefined" in the uuid)
21375 // - Invalid input values for the RFC `version` or `variant` fields
21376
21377 if (!validate(uuid)) {
21378 throw TypeError('Stringified UUID is invalid');
21379 }
21380
21381 return uuid;
21382 }
21383
21384 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
21385 ;// ./node_modules/uuid/dist/esm-browser/v4.js
21386
21387
21388
21389
21390 function v4(options, buf, offset) {
21391 if (esm_browser_native.randomUUID && !buf && !options) {
21392 return esm_browser_native.randomUUID();
21393 }
21394
21395 options = options || {};
21396 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
21397
21398 rnds[6] = rnds[6] & 0x0f | 0x40;
21399 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
21400
21401 if (buf) {
21402 offset = offset || 0;
21403
21404 for (let i = 0; i < 16; ++i) {
21405 buf[offset + i] = rnds[i];
21406 }
21407
21408 return buf;
21409 }
21410
21411 return unsafeStringify(rnds);
21412 }
21413
21414 /* harmony default export */ const esm_browser_v4 = (v4);
21415 ;// ./packages/editor/build-module/components/post-publish-panel/media-util.js
21416 /* wp:polyfill */
21417 /**
21418 * External dependencies
21419 */
21420
21421
21422 /**
21423 * WordPress dependencies
21424 */
21425
21426
21427 /**
21428 * Generate a list of unique basenames given a list of URLs.
21429 *
21430 * We want all basenames to be unique, since sometimes the extension
21431 * doesn't reflect the mime type, and may end up getting changed by
21432 * the server, on upload.
21433 *
21434 * @param {string[]} urls The list of URLs
21435 * @return {Record< string, string >} A URL => basename record.
21436 */
21437 function generateUniqueBasenames(urls) {
21438 const basenames = new Set();
21439 return Object.fromEntries(urls.map(url => {
21440 // We prefer to match the remote filename, if possible.
21441 const filename = (0,external_wp_url_namespaceObject.getFilename)(url);
21442 let basename = '';
21443 if (filename) {
21444 const parts = filename.split('.');
21445 if (parts.length > 1) {
21446 // Assume the last part is the extension.
21447 parts.pop();
21448 }
21449 basename = parts.join('.');
21450 }
21451 if (!basename) {
21452 // It looks like we don't have a basename, so let's use a UUID.
21453 basename = esm_browser_v4();
21454 }
21455 if (basenames.has(basename)) {
21456 // Append a UUID to deduplicate the basename.
21457 // The server will try to deduplicate on its own if we don't do this,
21458 // but it may run into a race condition
21459 // (see https://github.com/WordPress/gutenberg/issues/64899).
21460 // Deduplicating the filenames before uploading is safer.
21461 basename = `${basename}-${esm_browser_v4()}`;
21462 }
21463 basenames.add(basename);
21464 return [url, basename];
21465 }));
21466 }
21467
21468 /**
21469 * Fetch a list of URLs, turning those into promises for files with
21470 * unique filenames.
21471 *
21472 * @param {string[]} urls The list of URLs
21473 * @return {Record< string, Promise< File > >} A URL => File promise record.
21474 */
21475 function fetchMedia(urls) {
21476 return Object.fromEntries(Object.entries(generateUniqueBasenames(urls)).map(([url, basename]) => {
21477 const filePromise = window.fetch(url.includes('?') ? url : url + '?').then(response => response.blob()).then(blob => {
21478 // The server will reject the upload if it doesn't have an extension,
21479 // even though it'll rewrite the file name to match the mime type.
21480 // Here we provide it with a safe extension to get it past that check.
21481 return new File([blob], `${basename}.png`, {
21482 type: blob.type
21483 });
21484 });
21485 return [url, filePromise];
21486 }));
21487 }
21488
21489 ;// ./packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js
21490 /* wp:polyfill */
21491 /**
21492 * WordPress dependencies
21493 */
21494
21495
21496
21497
21498
21499
21500
21501 /**
21502 * Internal dependencies
21503 */
21504
21505
21506 function flattenBlocks(blocks) {
21507 const result = [];
21508 blocks.forEach(block => {
21509 result.push(block);
21510 result.push(...flattenBlocks(block.innerBlocks));
21511 });
21512 return result;
21513 }
21514
21515 /**
21516 * Determine whether a block has external media.
21517 *
21518 * Different blocks use different attribute names (and potentially
21519 * different logic as well) in determining whether the media is
21520 * present, and whether it's external.
21521 *
21522 * @param {{name: string, attributes: Object}} block The block.
21523 * @return {boolean?} Whether the block has external media
21524 */
21525 function hasExternalMedia(block) {
21526 if (block.name === 'core/image' || block.name === 'core/cover') {
21527 return block.attributes.url && !block.attributes.id;
21528 }
21529 if (block.name === 'core/media-text') {
21530 return block.attributes.mediaUrl && !block.attributes.mediaId;
21531 }
21532 return undefined;
21533 }
21534
21535 /**
21536 * Retrieve media info from a block.
21537 *
21538 * Different blocks use different attribute names, so we need this
21539 * function to normalize things into a consistent naming scheme.
21540 *
21541 * @param {{name: string, attributes: Object}} block The block.
21542 * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.
21543 */
21544 function getMediaInfo(block) {
21545 if (block.name === 'core/image' || block.name === 'core/cover') {
21546 const {
21547 url,
21548 alt,
21549 id
21550 } = block.attributes;
21551 return {
21552 url,
21553 alt,
21554 id
21555 };
21556 }
21557 if (block.name === 'core/media-text') {
21558 const {
21559 mediaUrl: url,
21560 mediaAlt: alt,
21561 mediaId: id
21562 } = block.attributes;
21563 return {
21564 url,
21565 alt,
21566 id
21567 };
21568 }
21569 return {};
21570 }
21571
21572 // Image component to represent a single image in the upload dialog.
21573 function Image({
21574 clientId,
21575 alt,
21576 url
21577 }) {
21578 const {
21579 selectBlock
21580 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
21581 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
21582 tabIndex: 0,
21583 role: "button",
21584 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'),
21585 onClick: () => {
21586 selectBlock(clientId);
21587 },
21588 onKeyDown: event => {
21589 if (event.key === 'Enter' || event.key === ' ') {
21590 selectBlock(clientId);
21591 event.preventDefault();
21592 }
21593 },
21594 alt: alt,
21595 src: url,
21596 animate: {
21597 opacity: 1
21598 },
21599 exit: {
21600 opacity: 0,
21601 scale: 0
21602 },
21603 style: {
21604 width: '32px',
21605 height: '32px',
21606 objectFit: 'cover',
21607 borderRadius: '2px',
21608 cursor: 'pointer'
21609 },
21610 whileHover: {
21611 scale: 1.08
21612 }
21613 }, clientId);
21614 }
21615 function MaybeUploadMediaPanel() {
21616 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false);
21617 const [isAnimating, setIsAnimating] = (0,external_wp_element_namespaceObject.useState)(false);
21618 const [hadUploadError, setHadUploadError] = (0,external_wp_element_namespaceObject.useState)(false);
21619 const {
21620 editorBlocks,
21621 mediaUpload
21622 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
21623 editorBlocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks(),
21624 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload
21625 }), []);
21626
21627 // Get a list of blocks with external media.
21628 const blocksWithExternalMedia = flattenBlocks(editorBlocks).filter(block => hasExternalMedia(block));
21629 const {
21630 updateBlockAttributes
21631 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
21632 if (!mediaUpload || !blocksWithExternalMedia.length) {
21633 return null;
21634 }
21635 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21636 className: "editor-post-publish-panel__link",
21637 children: (0,external_wp_i18n_namespaceObject.__)('External media')
21638 }, "label")];
21639
21640 /**
21641 * Update an individual block to point to newly-added library media.
21642 *
21643 * Different blocks use different attribute names, so we need this
21644 * function to ensure we modify the correct attributes for each type.
21645 *
21646 * @param {{name: string, attributes: Object}} block The block.
21647 * @param {{id: number, url: string}} media Media library file info.
21648 */
21649 function updateBlockWithUploadedMedia(block, media) {
21650 if (block.name === 'core/image' || block.name === 'core/cover') {
21651 updateBlockAttributes(block.clientId, {
21652 id: media.id,
21653 url: media.url
21654 });
21655 }
21656 if (block.name === 'core/media-text') {
21657 updateBlockAttributes(block.clientId, {
21658 mediaId: media.id,
21659 mediaUrl: media.url
21660 });
21661 }
21662 }
21663
21664 // Handle fetching and uploading all external media in the post.
21665 function uploadImages() {
21666 setIsUploading(true);
21667 setHadUploadError(false);
21668
21669 // Multiple blocks can be using the same URL, so we
21670 // should ensure we only fetch and upload each of them once.
21671 const mediaUrls = new Set(blocksWithExternalMedia.map(block => {
21672 const {
21673 url
21674 } = getMediaInfo(block);
21675 return url;
21676 }));
21677
21678 // Create an upload promise for each URL, that we can wait for in all
21679 // blocks that make use of that media.
21680 const uploadPromises = Object.fromEntries(Object.entries(fetchMedia([...mediaUrls])).map(([url, filePromise]) => {
21681 const uploadPromise = filePromise.then(blob => new Promise((resolve, reject) => {
21682 mediaUpload({
21683 filesList: [blob],
21684 onFileChange: ([media]) => {
21685 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
21686 return;
21687 }
21688 resolve(media);
21689 },
21690 onError() {
21691 reject();
21692 }
21693 });
21694 }));
21695 return [url, uploadPromise];
21696 }));
21697
21698 // Wait for all blocks to be updated with library media.
21699 Promise.allSettled(blocksWithExternalMedia.map(block => {
21700 const {
21701 url
21702 } = getMediaInfo(block);
21703 return uploadPromises[url].then(media => updateBlockWithUploadedMedia(block, media)).then(() => setIsAnimating(true)).catch(() => setHadUploadError(true));
21704 })).finally(() => {
21705 setIsUploading(false);
21706 });
21707 }
21708 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
21709 initialOpen: true,
21710 title: panelBodyTitle,
21711 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21712 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.')
21713 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21714 style: {
21715 display: 'inline-flex',
21716 flexWrap: 'wrap',
21717 gap: '8px'
21718 },
21719 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
21720 onExitComplete: () => setIsAnimating(false),
21721 children: blocksWithExternalMedia.map(block => {
21722 const {
21723 url,
21724 alt
21725 } = getMediaInfo(block);
21726 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Image, {
21727 clientId: block.clientId,
21728 url: url,
21729 alt: alt
21730 }, block.clientId);
21731 })
21732 }), isUploading || isAnimating ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21733 size: "compact",
21734 variant: "primary",
21735 onClick: uploadImages,
21736 children: (0,external_wp_i18n_namespaceObject._x)('Upload', 'verb')
21737 })]
21738 }), hadUploadError && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21739 children: (0,external_wp_i18n_namespaceObject.__)('Upload failed, try again.')
21740 })]
21741 });
21742 }
21743
21744 ;// ./packages/editor/build-module/components/post-publish-panel/prepublish.js
21745 /**
21746 * WordPress dependencies
21747 */
21748
21749
21750
21751
21752
21753
21754
21755
21756 /**
21757 * Internal dependencies
21758 */
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769 function PostPublishPanelPrepublish({
21770 children
21771 }) {
21772 const {
21773 isBeingScheduled,
21774 isRequestingSiteIcon,
21775 hasPublishAction,
21776 siteIconUrl,
21777 siteTitle,
21778 siteHome
21779 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21780 var _getCurrentPost$_link;
21781 const {
21782 getCurrentPost,
21783 isEditedPostBeingScheduled
21784 } = select(store_store);
21785 const {
21786 getEntityRecord,
21787 isResolving
21788 } = select(external_wp_coreData_namespaceObject.store);
21789 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
21790 return {
21791 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
21792 isBeingScheduled: isEditedPostBeingScheduled(),
21793 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
21794 siteIconUrl: siteData.site_icon_url,
21795 siteTitle: siteData.name,
21796 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
21797 };
21798 }, []);
21799 let siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
21800 className: "components-site-icon",
21801 size: "36px",
21802 icon: library_wordpress
21803 });
21804 if (siteIconUrl) {
21805 siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
21806 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
21807 className: "components-site-icon",
21808 src: siteIconUrl
21809 });
21810 }
21811 if (isRequestingSiteIcon) {
21812 siteIcon = null;
21813 }
21814 let prePublishTitle, prePublishBodyText;
21815 if (!hasPublishAction) {
21816 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
21817 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be reviewed and then approved.');
21818 } else if (isBeingScheduled) {
21819 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
21820 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
21821 } else {
21822 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
21823 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
21824 }
21825 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21826 className: "editor-post-publish-panel__prepublish",
21827 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21828 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
21829 children: prePublishTitle
21830 })
21831 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21832 children: prePublishBodyText
21833 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21834 className: "components-site-card",
21835 children: [siteIcon, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21836 className: "components-site-info",
21837 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21838 className: "components-site-name",
21839 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')
21840 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21841 className: "components-site-home",
21842 children: siteHome
21843 })]
21844 })]
21845 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MaybeUploadMediaPanel, {}), hasPublishAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21846 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
21847 initialOpen: false,
21848 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21849 className: "editor-post-publish-panel__link",
21850 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityLabel, {})
21851 }, "label")],
21852 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibility, {})
21853 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
21854 initialOpen: false,
21855 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
21856 className: "editor-post-publish-panel__link",
21857 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {})
21858 }, "label")],
21859 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {})
21860 })]
21861 }), /*#__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]
21862 });
21863 }
21864 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
21865
21866 ;// ./packages/editor/build-module/components/post-publish-panel/postpublish.js
21867 /**
21868 * WordPress dependencies
21869 */
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879 /**
21880 * Internal dependencies
21881 */
21882
21883
21884
21885 const POSTNAME = '%postname%';
21886 const PAGENAME = '%pagename%';
21887
21888 /**
21889 * Returns URL for a future post.
21890 *
21891 * @param {Object} post Post object.
21892 *
21893 * @return {string} PostPublish URL.
21894 */
21895
21896 const getFuturePostUrl = post => {
21897 const {
21898 slug
21899 } = post;
21900 if (post.permalink_template.includes(POSTNAME)) {
21901 return post.permalink_template.replace(POSTNAME, slug);
21902 }
21903 if (post.permalink_template.includes(PAGENAME)) {
21904 return post.permalink_template.replace(PAGENAME, slug);
21905 }
21906 return post.permalink_template;
21907 };
21908 function postpublish_CopyButton({
21909 text
21910 }) {
21911 const [showCopyConfirmation, setShowCopyConfirmation] = (0,external_wp_element_namespaceObject.useState)(false);
21912 const timeoutIdRef = (0,external_wp_element_namespaceObject.useRef)();
21913 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, () => {
21914 setShowCopyConfirmation(true);
21915 if (timeoutIdRef.current) {
21916 clearTimeout(timeoutIdRef.current);
21917 }
21918 timeoutIdRef.current = setTimeout(() => {
21919 setShowCopyConfirmation(false);
21920 }, 4000);
21921 });
21922 (0,external_wp_element_namespaceObject.useEffect)(() => {
21923 return () => {
21924 if (timeoutIdRef.current) {
21925 clearTimeout(timeoutIdRef.current);
21926 }
21927 };
21928 }, []);
21929 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21930 __next40pxDefaultSize: true,
21931 variant: "secondary",
21932 ref: ref,
21933 children: showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')
21934 });
21935 }
21936 function PostPublishPanelPostpublish({
21937 focusOnMount,
21938 children
21939 }) {
21940 const {
21941 post,
21942 postType,
21943 isScheduled
21944 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21945 const {
21946 getEditedPostAttribute,
21947 getCurrentPost,
21948 isCurrentPostScheduled
21949 } = select(store_store);
21950 const {
21951 getPostType
21952 } = select(external_wp_coreData_namespaceObject.store);
21953 return {
21954 post: getCurrentPost(),
21955 postType: getPostType(getEditedPostAttribute('type')),
21956 isScheduled: isCurrentPostScheduled()
21957 };
21958 }, []);
21959 const postLabel = postType?.labels?.singular_name;
21960 const viewPostLabel = postType?.labels?.view_item;
21961 const addNewPostLabel = postType?.labels?.add_new_item;
21962 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
21963 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
21964 post_type: post.type
21965 });
21966 const postLinkRef = (0,external_wp_element_namespaceObject.useCallback)(node => {
21967 if (focusOnMount && node) {
21968 node.focus();
21969 }
21970 }, [focusOnMount]);
21971 const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21972 children: [(0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {}), "."]
21973 }) : (0,external_wp_i18n_namespaceObject.__)('is now live.');
21974 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21975 className: "post-publish-panel__postpublish",
21976 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
21977 className: "post-publish-panel__postpublish-header",
21978 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
21979 ref: postLinkRef,
21980 href: link,
21981 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')
21982 }), ' ', postPublishNonLinkHeader]
21983 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
21984 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
21985 className: "post-publish-panel__postpublish-subheader",
21986 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
21987 children: (0,external_wp_i18n_namespaceObject.__)('What’s next?')
21988 })
21989 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21990 className: "post-publish-panel__postpublish-post-address-container",
21991 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
21992 __next40pxDefaultSize: true,
21993 __nextHasNoMarginBottom: true,
21994 className: "post-publish-panel__postpublish-post-address",
21995 readOnly: true,
21996 label: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: post type singular name */
21997 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
21998 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
21999 onFocus: event => event.target.select()
22000 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22001 className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
22002 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish_CopyButton, {
22003 text: link
22004 })
22005 })]
22006 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22007 className: "post-publish-panel__postpublish-buttons",
22008 children: [!isScheduled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22009 variant: "primary",
22010 href: link,
22011 __next40pxDefaultSize: true,
22012 children: viewPostLabel
22013 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22014 variant: isScheduled ? 'primary' : 'secondary',
22015 __next40pxDefaultSize: true,
22016 href: addLink,
22017 children: addNewPostLabel
22018 })]
22019 })]
22020 }), children]
22021 });
22022 }
22023
22024 ;// ./packages/editor/build-module/components/post-publish-panel/index.js
22025 /**
22026 * WordPress dependencies
22027 */
22028
22029
22030
22031
22032
22033
22034
22035
22036 /**
22037 * Internal dependencies
22038 */
22039
22040
22041
22042
22043
22044 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
22045 constructor() {
22046 super(...arguments);
22047 this.onSubmit = this.onSubmit.bind(this);
22048 this.cancelButtonNode = (0,external_wp_element_namespaceObject.createRef)();
22049 }
22050 componentDidMount() {
22051 // This timeout is necessary to make sure the `useEffect` hook of
22052 // `useFocusReturn` gets the correct element (the button that opens the
22053 // PostPublishPanel) otherwise it will get this button.
22054 this.timeoutID = setTimeout(() => {
22055 this.cancelButtonNode.current.focus();
22056 }, 0);
22057 }
22058 componentWillUnmount() {
22059 clearTimeout(this.timeoutID);
22060 }
22061 componentDidUpdate(prevProps) {
22062 // Automatically collapse the publish sidebar when a post
22063 // is published and the user makes an edit.
22064 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty || this.props.currentPostId !== prevProps.currentPostId) {
22065 this.props.onClose();
22066 }
22067 }
22068 onSubmit() {
22069 const {
22070 onClose,
22071 hasPublishAction,
22072 isPostTypeViewable
22073 } = this.props;
22074 if (!hasPublishAction || !isPostTypeViewable) {
22075 onClose();
22076 }
22077 }
22078 render() {
22079 const {
22080 forceIsDirty,
22081 isBeingScheduled,
22082 isPublished,
22083 isPublishSidebarEnabled,
22084 isScheduled,
22085 isSaving,
22086 isSavingNonPostEntityChanges,
22087 onClose,
22088 onTogglePublishSidebar,
22089 PostPublishExtension,
22090 PrePublishExtension,
22091 currentPostId,
22092 ...additionalProps
22093 } = this.props;
22094 const {
22095 hasPublishAction,
22096 isDirty,
22097 isPostTypeViewable,
22098 ...propsForPanel
22099 } = additionalProps;
22100 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
22101 const isPrePublish = !isPublishedOrScheduled && !isSaving;
22102 const isPostPublish = isPublishedOrScheduled && !isSaving;
22103 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22104 className: "editor-post-publish-panel",
22105 ...propsForPanel,
22106 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22107 className: "editor-post-publish-panel__header",
22108 children: isPostPublish ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22109 size: "compact",
22110 onClick: onClose,
22111 icon: close_small,
22112 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
22113 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22114 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22115 className: "editor-post-publish-panel__header-cancel-button",
22116 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22117 ref: this.cancelButtonNode,
22118 accessibleWhenDisabled: true,
22119 disabled: isSavingNonPostEntityChanges,
22120 onClick: onClose,
22121 variant: "secondary",
22122 size: "compact",
22123 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
22124 })
22125 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22126 className: "editor-post-publish-panel__header-publish-button",
22127 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
22128 onSubmit: this.onSubmit,
22129 forceIsDirty: forceIsDirty
22130 })
22131 })]
22132 })
22133 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22134 className: "editor-post-publish-panel__content",
22135 children: [isPrePublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(prepublish, {
22136 children: PrePublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrePublishExtension, {})
22137 }), isPostPublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishPanelPostpublish, {
22138 focusOnMount: true,
22139 children: PostPublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishExtension, {})
22140 }), isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {})]
22141 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22142 className: "editor-post-publish-panel__footer",
22143 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
22144 __nextHasNoMarginBottom: true,
22145 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
22146 checked: isPublishSidebarEnabled,
22147 onChange: onTogglePublishSidebar
22148 })
22149 })]
22150 });
22151 }
22152 }
22153
22154 /**
22155 * Renders a panel for publishing a post.
22156 */
22157 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
22158 var _getCurrentPost$_link;
22159 const {
22160 getPostType
22161 } = select(external_wp_coreData_namespaceObject.store);
22162 const {
22163 getCurrentPost,
22164 getCurrentPostId,
22165 getEditedPostAttribute,
22166 isCurrentPostPublished,
22167 isCurrentPostScheduled,
22168 isEditedPostBeingScheduled,
22169 isEditedPostDirty,
22170 isAutosavingPost,
22171 isSavingPost,
22172 isSavingNonPostEntityChanges
22173 } = select(store_store);
22174 const {
22175 isPublishSidebarEnabled
22176 } = select(store_store);
22177 const postType = getPostType(getEditedPostAttribute('type'));
22178 return {
22179 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
22180 isPostTypeViewable: postType?.viewable,
22181 isBeingScheduled: isEditedPostBeingScheduled(),
22182 isDirty: isEditedPostDirty(),
22183 isPublished: isCurrentPostPublished(),
22184 isPublishSidebarEnabled: isPublishSidebarEnabled(),
22185 isSaving: isSavingPost() && !isAutosavingPost(),
22186 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
22187 isScheduled: isCurrentPostScheduled(),
22188 currentPostId: getCurrentPostId()
22189 };
22190 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
22191 isPublishSidebarEnabled
22192 }) => {
22193 const {
22194 disablePublishSidebar,
22195 enablePublishSidebar
22196 } = dispatch(store_store);
22197 return {
22198 onTogglePublishSidebar: () => {
22199 if (isPublishSidebarEnabled) {
22200 disablePublishSidebar();
22201 } else {
22202 enablePublishSidebar();
22203 }
22204 }
22205 };
22206 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
22207
22208 ;// ./packages/icons/build-module/library/cloud-upload.js
22209 /**
22210 * WordPress dependencies
22211 */
22212
22213
22214 const cloudUpload = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22215 xmlns: "http://www.w3.org/2000/svg",
22216 viewBox: "0 0 24 24",
22217 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22218 d: "M17.3 10.1C17.3 7.60001 15.2 5.70001 12.5 5.70001C10.3 5.70001 8.4 7.10001 7.9 9.00001H7.7C5.7 9.00001 4 10.7 4 12.8C4 14.9 5.7 16.6 7.7 16.6H9.5V15.2H7.7C6.5 15.2 5.5 14.1 5.5 12.9C5.5 11.7 6.5 10.5 7.7 10.5H9L9.3 9.40001C9.7 8.10001 11 7.20001 12.5 7.20001C14.3 7.20001 15.8 8.50001 15.8 10.1V11.4L17.1 11.6C17.9 11.7 18.5 12.5 18.5 13.4C18.5 14.4 17.7 15.2 16.8 15.2H14.5V16.6H16.7C18.5 16.6 19.9 15.1 19.9 13.3C20 11.7 18.8 10.4 17.3 10.1Z M14.1245 14.2426L15.1852 13.182L12.0032 10L8.82007 13.1831L9.88072 14.2438L11.25 12.8745V18H12.75V12.8681L14.1245 14.2426Z"
22219 })
22220 });
22221 /* harmony default export */ const cloud_upload = (cloudUpload);
22222
22223 ;// ./packages/icons/build-module/library/cloud.js
22224 /**
22225 * WordPress dependencies
22226 */
22227
22228
22229 const cloud = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22230 xmlns: "http://www.w3.org/2000/svg",
22231 viewBox: "0 0 24 24",
22232 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22233 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"
22234 })
22235 });
22236 /* harmony default export */ const library_cloud = (cloud);
22237
22238 ;// ./packages/editor/build-module/components/post-sticky/check.js
22239 /**
22240 * WordPress dependencies
22241 */
22242
22243
22244 /**
22245 * Internal dependencies
22246 */
22247
22248
22249 /**
22250 * Wrapper component that renders its children only if post has a sticky action.
22251 *
22252 * @param {Object} props Props.
22253 * @param {React.ReactElement} props.children Children to be rendered.
22254 *
22255 * @return {React.ReactElement} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
22256 */
22257 function PostStickyCheck({
22258 children
22259 }) {
22260 const {
22261 hasStickyAction,
22262 postType
22263 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22264 var _post$_links$wpActio;
22265 const post = select(store_store).getCurrentPost();
22266 return {
22267 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
22268 postType: select(store_store).getCurrentPostType()
22269 };
22270 }, []);
22271 if (postType !== 'post' || !hasStickyAction) {
22272 return null;
22273 }
22274 return children;
22275 }
22276
22277 ;// ./packages/editor/build-module/components/post-sticky/index.js
22278 /**
22279 * WordPress dependencies
22280 */
22281
22282
22283
22284
22285 /**
22286 * Internal dependencies
22287 */
22288
22289
22290
22291 /**
22292 * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
22293 *
22294 * @return {React.ReactNode} The rendered component.
22295 */
22296
22297 function PostSticky() {
22298 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => {
22299 var _select$getEditedPost;
22300 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false;
22301 }, []);
22302 const {
22303 editPost
22304 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22305 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStickyCheck, {
22306 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
22307 className: "editor-post-sticky__checkbox-control",
22308 label: (0,external_wp_i18n_namespaceObject.__)('Sticky'),
22309 help: (0,external_wp_i18n_namespaceObject.__)('Pin this post to the top of the blog'),
22310 checked: postSticky,
22311 onChange: () => editPost({
22312 sticky: !postSticky
22313 }),
22314 __nextHasNoMarginBottom: true
22315 })
22316 });
22317 }
22318
22319 ;// ./packages/editor/build-module/components/post-status/index.js
22320 /**
22321 * WordPress dependencies
22322 */
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332 /**
22333 * Internal dependencies
22334 */
22335
22336
22337
22338
22339
22340
22341 const postStatusesInfo = {
22342 'auto-draft': {
22343 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
22344 icon: library_drafts
22345 },
22346 draft: {
22347 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
22348 icon: library_drafts
22349 },
22350 pending: {
22351 label: (0,external_wp_i18n_namespaceObject.__)('Pending'),
22352 icon: library_pending
22353 },
22354 private: {
22355 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
22356 icon: not_allowed
22357 },
22358 future: {
22359 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
22360 icon: library_scheduled
22361 },
22362 publish: {
22363 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
22364 icon: library_published
22365 }
22366 };
22367 const STATUS_OPTIONS = [{
22368 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
22369 value: 'draft',
22370 description: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
22371 }, {
22372 label: (0,external_wp_i18n_namespaceObject.__)('Pending'),
22373 value: 'pending',
22374 description: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
22375 }, {
22376 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
22377 value: 'private',
22378 description: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
22379 }, {
22380 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
22381 value: 'future',
22382 description: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
22383 }, {
22384 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
22385 value: 'publish',
22386 description: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
22387 }];
22388 const DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
22389 function PostStatus() {
22390 const {
22391 status,
22392 date,
22393 password,
22394 postId,
22395 postType,
22396 canEdit
22397 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22398 var _getCurrentPost$_link;
22399 const {
22400 getEditedPostAttribute,
22401 getCurrentPostId,
22402 getCurrentPostType,
22403 getCurrentPost
22404 } = select(store_store);
22405 return {
22406 status: getEditedPostAttribute('status'),
22407 date: getEditedPostAttribute('date'),
22408 password: getEditedPostAttribute('password'),
22409 postId: getCurrentPostId(),
22410 postType: getCurrentPostType(),
22411 canEdit: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
22412 };
22413 }, []);
22414 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
22415 const passwordInputId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostStatus, 'editor-change-status__password-input');
22416 const {
22417 editEntityRecord
22418 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
22419 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
22420 // Memoize popoverProps to avoid returning a new object every time.
22421 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
22422 // Anchor the popover to the middle of the entire row so that it doesn't
22423 // move around when the label changes.
22424 anchor: popoverAnchor,
22425 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
22426 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
22427 placement: 'left-start',
22428 offset: 36,
22429 shift: true
22430 }), [popoverAnchor]);
22431 if (DESIGN_POST_TYPES.includes(postType)) {
22432 return null;
22433 }
22434 const updatePost = ({
22435 status: newStatus = status,
22436 password: newPassword = password,
22437 date: newDate = date
22438 }) => {
22439 editEntityRecord('postType', postType, postId, {
22440 status: newStatus,
22441 date: newDate,
22442 password: newPassword
22443 });
22444 };
22445 const handleTogglePassword = value => {
22446 setShowPassword(value);
22447 if (!value) {
22448 updatePost({
22449 password: ''
22450 });
22451 }
22452 };
22453 const handleStatus = value => {
22454 let newDate = date;
22455 let newPassword = password;
22456 if (status === 'future' && new Date(date) > new Date()) {
22457 newDate = null;
22458 }
22459 if (value === 'private' && password) {
22460 newPassword = '';
22461 }
22462 updatePost({
22463 status: value,
22464 date: newDate,
22465 password: newPassword
22466 });
22467 };
22468 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
22469 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
22470 ref: setPopoverAnchor,
22471 children: canEdit ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
22472 className: "editor-post-status",
22473 contentClassName: "editor-change-status__content",
22474 popoverProps: popoverProps,
22475 focusOnMount: true,
22476 renderToggle: ({
22477 onToggle,
22478 isOpen
22479 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22480 className: "editor-post-status__toggle",
22481 variant: "tertiary",
22482 size: "compact",
22483 onClick: onToggle,
22484 icon: postStatusesInfo[status]?.icon,
22485 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
22486 // translators: %s: Current post status.
22487 (0,external_wp_i18n_namespaceObject.__)('Change status: %s'), postStatusesInfo[status]?.label),
22488 "aria-expanded": isOpen,
22489 children: postStatusesInfo[status]?.label
22490 }),
22491 renderContent: ({
22492 onClose
22493 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22494 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
22495 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
22496 onClose: onClose
22497 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
22498 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
22499 spacing: 4,
22500 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
22501 className: "editor-change-status__options",
22502 hideLabelFromVision: true,
22503 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
22504 options: STATUS_OPTIONS,
22505 onChange: handleStatus,
22506 selected: status === 'auto-draft' ? 'draft' : status
22507 }), status === 'future' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22508 className: "editor-change-status__publish-date-wrapper",
22509 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
22510 showPopoverHeaderActions: false,
22511 isCompact: true
22512 })
22513 }), status !== 'private' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
22514 as: "fieldset",
22515 spacing: 4,
22516 className: "editor-change-status__password-fieldset",
22517 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
22518 __nextHasNoMarginBottom: true,
22519 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
22520 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
22521 checked: showPassword,
22522 onChange: handleTogglePassword
22523 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22524 className: "editor-change-status__password-input",
22525 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
22526 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
22527 onChange: value => updatePost({
22528 password: value
22529 }),
22530 value: password,
22531 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
22532 type: "text",
22533 id: passwordInputId,
22534 __next40pxDefaultSize: true,
22535 __nextHasNoMarginBottom: true,
22536 maxLength: 255
22537 })
22538 })]
22539 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSticky, {})]
22540 })
22541 })]
22542 })
22543 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22544 className: "editor-post-status is-read-only",
22545 children: postStatusesInfo[status]?.label
22546 })
22547 });
22548 }
22549
22550 ;// ./packages/editor/build-module/components/post-saved-state/index.js
22551 /* wp:polyfill */
22552 /**
22553 * External dependencies
22554 */
22555
22556
22557 /**
22558 * WordPress dependencies
22559 */
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569 /**
22570 * Internal dependencies
22571 */
22572
22573
22574
22575 /**
22576 * Component showing whether the post is saved or not and providing save
22577 * buttons.
22578 *
22579 * @param {Object} props Component props.
22580 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
22581 * as dirty.
22582 * @return {import('react').ComponentType} The component.
22583 */
22584
22585 function PostSavedState({
22586 forceIsDirty
22587 }) {
22588 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
22589 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
22590 const {
22591 isAutosaving,
22592 isDirty,
22593 isNew,
22594 isPublished,
22595 isSaveable,
22596 isSaving,
22597 isScheduled,
22598 hasPublishAction,
22599 showIconLabels,
22600 postStatus,
22601 postStatusHasChanged
22602 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22603 var _getCurrentPost$_link;
22604 const {
22605 isEditedPostNew,
22606 isCurrentPostPublished,
22607 isCurrentPostScheduled,
22608 isEditedPostDirty,
22609 isSavingPost,
22610 isEditedPostSaveable,
22611 getCurrentPost,
22612 isAutosavingPost,
22613 getEditedPostAttribute,
22614 getPostEdits
22615 } = select(store_store);
22616 const {
22617 get
22618 } = select(external_wp_preferences_namespaceObject.store);
22619 return {
22620 isAutosaving: isAutosavingPost(),
22621 isDirty: forceIsDirty || isEditedPostDirty(),
22622 isNew: isEditedPostNew(),
22623 isPublished: isCurrentPostPublished(),
22624 isSaving: isSavingPost(),
22625 isSaveable: isEditedPostSaveable(),
22626 isScheduled: isCurrentPostScheduled(),
22627 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
22628 showIconLabels: get('core', 'showIconLabels'),
22629 postStatus: getEditedPostAttribute('status'),
22630 postStatusHasChanged: !!getPostEdits()?.status
22631 };
22632 }, [forceIsDirty]);
22633 const isPending = postStatus === 'pending';
22634 const {
22635 savePost
22636 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22637 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
22638 (0,external_wp_element_namespaceObject.useEffect)(() => {
22639 let timeoutId;
22640 if (wasSaving && !isSaving) {
22641 setForceSavedMessage(true);
22642 timeoutId = setTimeout(() => {
22643 setForceSavedMessage(false);
22644 }, 1000);
22645 }
22646 return () => clearTimeout(timeoutId);
22647 }, [isSaving]);
22648
22649 // Once the post has been submitted for review this button
22650 // is not needed for the contributor role.
22651 if (!hasPublishAction && isPending) {
22652 return null;
22653 }
22654
22655 // We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.
22656 // The reason for this is that this button handles the `save as pending` and `save draft` actions.
22657 // An exception for this is when the post has a custom status and there should be a way to save changes without
22658 // having to publish. This should be handled better in the future when custom statuses have better support.
22659 // @see https://github.com/WordPress/gutenberg/issues/3144.
22660 const isIneligibleStatus = !['pending', 'draft', 'auto-draft'].includes(postStatus) && STATUS_OPTIONS.map(({
22661 value
22662 }) => value).includes(postStatus);
22663 if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ['pending', 'draft'].includes(postStatus)) {
22664 return null;
22665 }
22666
22667 /* translators: button label text should, if possible, be under 16 characters. */
22668 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
22669
22670 /* translators: button label text should, if possible, be under 16 characters. */
22671 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
22672 const isSaved = forceSavedMessage || !isNew && !isDirty;
22673 const isSavedState = isSaving || isSaved;
22674 const isDisabled = isSaving || isSaved || !isSaveable;
22675 let text;
22676 if (isSaving) {
22677 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
22678 } else if (isSaved) {
22679 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
22680 } else if (isLargeViewport) {
22681 text = label;
22682 } else if (showIconLabels) {
22683 text = shortLabel;
22684 }
22685
22686 // Use common Button instance for all saved states so that focus is not
22687 // lost.
22688 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
22689 className: isSaveable || isSaving ? dist_clsx({
22690 'editor-post-save-draft': !isSavedState,
22691 'editor-post-saved-state': isSavedState,
22692 'is-saving': isSaving,
22693 'is-autosaving': isAutosaving,
22694 'is-saved': isSaved,
22695 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
22696 type: 'loading'
22697 })]: isSaving
22698 }) : undefined,
22699 onClick: isDisabled ? undefined : () => savePost()
22700 /*
22701 * We want the tooltip to show the keyboard shortcut only when the
22702 * button does something, i.e. when it's not disabled.
22703 */,
22704 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
22705 variant: "tertiary",
22706 size: "compact",
22707 icon: isLargeViewport ? undefined : cloud_upload,
22708 label: text || label,
22709 "aria-disabled": isDisabled,
22710 children: [isSavedState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
22711 icon: isSaved ? library_check : library_cloud
22712 }), text]
22713 });
22714 }
22715
22716 ;// ./packages/editor/build-module/components/post-schedule/check.js
22717 /**
22718 * WordPress dependencies
22719 */
22720
22721
22722 /**
22723 * Internal dependencies
22724 */
22725
22726
22727 /**
22728 * Wrapper component that renders its children only if post has a publish action.
22729 *
22730 * @param {Object} props Props.
22731 * @param {React.ReactElement} props.children Children to be rendered.
22732 *
22733 * @return {React.ReactElement} - The component to be rendered or null if there is no publish action.
22734 */
22735 function PostScheduleCheck({
22736 children
22737 }) {
22738 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => {
22739 var _select$getCurrentPos;
22740 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
22741 }, []);
22742 if (!hasPublishAction) {
22743 return null;
22744 }
22745 return children;
22746 }
22747
22748 ;// ./packages/editor/build-module/components/post-schedule/panel.js
22749 /**
22750 * WordPress dependencies
22751 */
22752
22753
22754
22755
22756
22757 /**
22758 * Internal dependencies
22759 */
22760
22761
22762
22763
22764
22765
22766
22767 const panel_DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
22768
22769 /**
22770 * Renders the Post Schedule Panel component.
22771 *
22772 * @return {React.ReactNode} The rendered component.
22773 */
22774 function PostSchedulePanel() {
22775 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
22776 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
22777 // Memoize popoverProps to avoid returning a new object every time.
22778 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
22779 // Anchor the popover to the middle of the entire row so that it doesn't
22780 // move around when the label changes.
22781 anchor: popoverAnchor,
22782 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'),
22783 placement: 'left-start',
22784 offset: 36,
22785 shift: true
22786 }), [popoverAnchor]);
22787 const label = usePostScheduleLabel();
22788 const fullLabel = usePostScheduleLabel({
22789 full: true
22790 });
22791 if (panel_DESIGN_POST_TYPES.includes(postType)) {
22792 return null;
22793 }
22794 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleCheck, {
22795 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
22796 label: (0,external_wp_i18n_namespaceObject.__)('Publish'),
22797 ref: setPopoverAnchor,
22798 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
22799 popoverProps: popoverProps,
22800 focusOnMount: true,
22801 className: "editor-post-schedule__panel-dropdown",
22802 contentClassName: "editor-post-schedule__dialog",
22803 renderToggle: ({
22804 onToggle,
22805 isOpen
22806 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22807 size: "compact",
22808 className: "editor-post-schedule__dialog-toggle",
22809 variant: "tertiary",
22810 tooltipPosition: "middle left",
22811 onClick: onToggle,
22812 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
22813 // translators: %s: Current post date.
22814 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label),
22815 label: fullLabel,
22816 showTooltip: label !== fullLabel,
22817 "aria-expanded": isOpen,
22818 children: label
22819 }),
22820 renderContent: ({
22821 onClose
22822 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {
22823 onClose: onClose
22824 })
22825 })
22826 })
22827 });
22828 }
22829
22830 ;// ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
22831 /**
22832 * WordPress dependencies
22833 */
22834
22835
22836
22837
22838
22839
22840 /**
22841 * Internal dependencies
22842 */
22843
22844
22845 /**
22846 * Renders a button component that allows the user to switch a post to draft status.
22847 *
22848 * @return {React.ReactNode} The rendered component.
22849 */
22850
22851 function PostSwitchToDraftButton() {
22852 external_wp_deprecated_default()('wp.editor.PostSwitchToDraftButton', {
22853 since: '6.7',
22854 version: '6.9'
22855 });
22856 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
22857 const {
22858 editPost,
22859 savePost
22860 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22861 const {
22862 isSaving,
22863 isPublished,
22864 isScheduled
22865 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22866 const {
22867 isSavingPost,
22868 isCurrentPostPublished,
22869 isCurrentPostScheduled
22870 } = select(store_store);
22871 return {
22872 isSaving: isSavingPost(),
22873 isPublished: isCurrentPostPublished(),
22874 isScheduled: isCurrentPostScheduled()
22875 };
22876 }, []);
22877 const isDisabled = isSaving || !isPublished && !isScheduled;
22878 let alertMessage;
22879 let confirmButtonText;
22880 if (isPublished) {
22881 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
22882 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unpublish');
22883 } else if (isScheduled) {
22884 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
22885 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unschedule');
22886 }
22887 const handleConfirm = () => {
22888 setShowConfirmDialog(false);
22889 editPost({
22890 status: 'draft'
22891 });
22892 savePost();
22893 };
22894 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22895 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22896 __next40pxDefaultSize: true,
22897 className: "editor-post-switch-to-draft",
22898 onClick: () => {
22899 if (!isDisabled) {
22900 setShowConfirmDialog(true);
22901 }
22902 },
22903 "aria-disabled": isDisabled,
22904 variant: "secondary",
22905 style: {
22906 flexGrow: '1',
22907 justifyContent: 'center'
22908 },
22909 children: (0,external_wp_i18n_namespaceObject.__)('Switch to draft')
22910 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
22911 isOpen: showConfirmDialog,
22912 onConfirm: handleConfirm,
22913 onCancel: () => setShowConfirmDialog(false),
22914 confirmButtonText: confirmButtonText,
22915 children: alertMessage
22916 })]
22917 });
22918 }
22919
22920 ;// ./packages/editor/build-module/components/post-sync-status/index.js
22921 /**
22922 * WordPress dependencies
22923 */
22924
22925
22926
22927 /**
22928 * Internal dependencies
22929 */
22930
22931
22932
22933 /**
22934 * Renders the sync status of a post.
22935 *
22936 * @return {React.ReactNode} The rendered sync status component.
22937 */
22938
22939 function PostSyncStatus() {
22940 const {
22941 syncStatus,
22942 postType
22943 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22944 const {
22945 getEditedPostAttribute
22946 } = select(store_store);
22947 const meta = getEditedPostAttribute('meta');
22948
22949 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
22950 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
22951 return {
22952 syncStatus: currentSyncStatus,
22953 postType: getEditedPostAttribute('type')
22954 };
22955 });
22956 if (postType !== 'wp_block') {
22957 return null;
22958 }
22959 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
22960 label: (0,external_wp_i18n_namespaceObject.__)('Sync status'),
22961 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22962 className: "editor-post-sync-status__value",
22963 children: syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'pattern (singular)') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)')
22964 })
22965 });
22966 }
22967
22968 ;// ./packages/editor/build-module/components/post-taxonomies/index.js
22969 /* wp:polyfill */
22970 /**
22971 * WordPress dependencies
22972 */
22973
22974
22975
22976
22977 /**
22978 * Internal dependencies
22979 */
22980
22981
22982
22983
22984 const post_taxonomies_identity = x => x;
22985 function PostTaxonomies({
22986 taxonomyWrapper = post_taxonomies_identity
22987 }) {
22988 const {
22989 postType,
22990 taxonomies
22991 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22992 return {
22993 postType: select(store_store).getCurrentPostType(),
22994 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
22995 per_page: -1
22996 })
22997 };
22998 }, []);
22999 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
23000 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
23001 // https://github.com/WordPress/gutenberg/issues/40326
23002 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
23003 return visibleTaxonomies.map(taxonomy => {
23004 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
23005 const taxonomyComponentProps = {
23006 slug: taxonomy.slug,
23007 ...(taxonomy.hierarchical ? {} : {
23008 __nextHasNoMarginBottom: true
23009 })
23010 };
23011 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
23012 children: taxonomyWrapper(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyComponent, {
23013 ...taxonomyComponentProps
23014 }), taxonomy)
23015 }, `taxonomy-${taxonomy.slug}`);
23016 });
23017 }
23018
23019 /**
23020 * Renders the taxonomies associated with a post.
23021 *
23022 * @param {Object} props The component props.
23023 * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
23024 *
23025 * @return {Array} An array of JSX elements representing the visible taxonomies.
23026 */
23027 /* harmony default export */ const post_taxonomies = (PostTaxonomies);
23028
23029 ;// ./packages/editor/build-module/components/post-taxonomies/check.js
23030 /**
23031 * WordPress dependencies
23032 */
23033
23034
23035
23036 /**
23037 * Internal dependencies
23038 */
23039
23040
23041 /**
23042 * Renders the children components only if the current post type has taxonomies.
23043 *
23044 * @param {Object} props The component props.
23045 * @param {React.ReactNode} props.children The children components to render.
23046 *
23047 * @return {React.ReactElement} The rendered children components or null if the current post type has no taxonomies.
23048 */
23049 function PostTaxonomiesCheck({
23050 children
23051 }) {
23052 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => {
23053 const postType = select(store_store).getCurrentPostType();
23054 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({
23055 per_page: -1
23056 });
23057 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
23058 }, []);
23059 if (!hasTaxonomies) {
23060 return null;
23061 }
23062 return children;
23063 }
23064
23065 ;// ./packages/editor/build-module/components/post-taxonomies/panel.js
23066 /**
23067 * WordPress dependencies
23068 */
23069
23070
23071
23072 /**
23073 * Internal dependencies
23074 */
23075
23076
23077
23078
23079 /**
23080 * Renders a panel for a specific taxonomy.
23081 *
23082 * @param {Object} props The component props.
23083 * @param {Object} props.taxonomy The taxonomy object.
23084 * @param {React.ReactNode} props.children The child components.
23085 *
23086 * @return {React.ReactNode} The rendered taxonomy panel.
23087 */
23088
23089 function TaxonomyPanel({
23090 taxonomy,
23091 children
23092 }) {
23093 const slug = taxonomy?.slug;
23094 const panelName = slug ? `taxonomy-panel-${slug}` : '';
23095 const {
23096 isEnabled,
23097 isOpened
23098 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23099 const {
23100 isEditorPanelEnabled,
23101 isEditorPanelOpened
23102 } = select(store_store);
23103 return {
23104 isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
23105 isOpened: slug ? isEditorPanelOpened(panelName) : false
23106 };
23107 }, [panelName, slug]);
23108 const {
23109 toggleEditorPanelOpened
23110 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23111 if (!isEnabled) {
23112 return null;
23113 }
23114 const taxonomyMenuName = taxonomy?.labels?.menu_name;
23115 if (!taxonomyMenuName) {
23116 return null;
23117 }
23118 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
23119 title: taxonomyMenuName,
23120 opened: isOpened,
23121 onToggle: () => toggleEditorPanelOpened(panelName),
23122 children: children
23123 });
23124 }
23125
23126 /**
23127 * Component that renders the post taxonomies panel.
23128 *
23129 * @return {React.ReactNode} The rendered component.
23130 */
23131 function panel_PostTaxonomies() {
23132 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTaxonomiesCheck, {
23133 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
23134 taxonomyWrapper: (content, taxonomy) => {
23135 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyPanel, {
23136 taxonomy: taxonomy,
23137 children: content
23138 });
23139 }
23140 })
23141 });
23142 }
23143
23144 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
23145 var lib = __webpack_require__(4132);
23146 ;// ./packages/editor/build-module/components/post-text-editor/index.js
23147 /**
23148 * External dependencies
23149 */
23150
23151
23152 /**
23153 * WordPress dependencies
23154 */
23155
23156
23157
23158
23159
23160
23161
23162
23163 /**
23164 * Internal dependencies
23165 */
23166
23167
23168 /**
23169 * Displays the Post Text Editor along with content in Visual and Text mode.
23170 *
23171 * @return {React.ReactNode} The rendered PostTextEditor component.
23172 */
23173
23174 function PostTextEditor() {
23175 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
23176 const {
23177 content,
23178 blocks,
23179 type,
23180 id
23181 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23182 const {
23183 getEditedEntityRecord
23184 } = select(external_wp_coreData_namespaceObject.store);
23185 const {
23186 getCurrentPostType,
23187 getCurrentPostId
23188 } = select(store_store);
23189 const _type = getCurrentPostType();
23190 const _id = getCurrentPostId();
23191 const editedRecord = getEditedEntityRecord('postType', _type, _id);
23192 return {
23193 content: editedRecord?.content,
23194 blocks: editedRecord?.blocks,
23195 type: _type,
23196 id: _id
23197 };
23198 }, []);
23199 const {
23200 editEntityRecord
23201 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
23202 // Replicates the logic found in getEditedPostContent().
23203 const value = (0,external_wp_element_namespaceObject.useMemo)(() => {
23204 if (content instanceof Function) {
23205 return content({
23206 blocks
23207 });
23208 } else if (blocks) {
23209 // If we have parsed blocks already, they should be our source of truth.
23210 // Parsing applies block deprecations and legacy block conversions that
23211 // unparsed content will not have.
23212 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
23213 }
23214 return content;
23215 }, [content, blocks]);
23216 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23217 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23218 as: "label",
23219 htmlFor: `post-content-${instanceId}`,
23220 children: (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')
23221 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(lib/* default */.A, {
23222 autoComplete: "off",
23223 dir: "auto",
23224 value: value,
23225 onChange: event => {
23226 editEntityRecord('postType', type, id, {
23227 content: event.target.value,
23228 blocks: undefined,
23229 selection: undefined
23230 });
23231 },
23232 className: "editor-post-text-editor",
23233 id: `post-content-${instanceId}`,
23234 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
23235 })]
23236 });
23237 }
23238
23239 ;// ./packages/editor/build-module/components/post-title/constants.js
23240 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text';
23241 const REGEXP_NEWLINES = /[\r\n]+/g;
23242
23243 ;// ./packages/editor/build-module/components/post-title/use-post-title-focus.js
23244 /**
23245 * WordPress dependencies
23246 */
23247
23248
23249
23250 /**
23251 * Internal dependencies
23252 */
23253
23254
23255 /**
23256 * Custom hook that manages the focus behavior of the post title input field.
23257 *
23258 * @param {Element} forwardedRef - The forwarded ref for the input field.
23259 *
23260 * @return {Object} - The ref object.
23261 */
23262 function usePostTitleFocus(forwardedRef) {
23263 const ref = (0,external_wp_element_namespaceObject.useRef)();
23264 const {
23265 isCleanNewPost
23266 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23267 const {
23268 isCleanNewPost: _isCleanNewPost
23269 } = select(store_store);
23270 return {
23271 isCleanNewPost: _isCleanNewPost()
23272 };
23273 }, []);
23274 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
23275 focus: () => {
23276 ref?.current?.focus();
23277 }
23278 }));
23279 (0,external_wp_element_namespaceObject.useEffect)(() => {
23280 if (!ref.current) {
23281 return;
23282 }
23283 const {
23284 defaultView
23285 } = ref.current.ownerDocument;
23286 const {
23287 name,
23288 parent
23289 } = defaultView;
23290 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
23291 const {
23292 activeElement,
23293 body
23294 } = ownerDocument;
23295
23296 // Only autofocus the title when the post is entirely empty. This should
23297 // only happen for a new post, which means we focus the title on new
23298 // post so the author can start typing right away, without needing to
23299 // click anything.
23300 if (isCleanNewPost && (!activeElement || body === activeElement)) {
23301 ref.current.focus();
23302 }
23303 }, [isCleanNewPost]);
23304 return {
23305 ref
23306 };
23307 }
23308
23309 ;// ./packages/editor/build-module/components/post-title/use-post-title.js
23310 /**
23311 * WordPress dependencies
23312 */
23313
23314 /**
23315 * Internal dependencies
23316 */
23317
23318
23319 /**
23320 * Custom hook for managing the post title in the editor.
23321 *
23322 * @return {Object} An object containing the current title and a function to update the title.
23323 */
23324 function usePostTitle() {
23325 const {
23326 editPost
23327 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23328 const {
23329 title
23330 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23331 const {
23332 getEditedPostAttribute
23333 } = select(store_store);
23334 return {
23335 title: getEditedPostAttribute('title')
23336 };
23337 }, []);
23338 function updateTitle(newTitle) {
23339 editPost({
23340 title: newTitle
23341 });
23342 }
23343 return {
23344 title,
23345 setTitle: updateTitle
23346 };
23347 }
23348
23349 ;// ./packages/editor/build-module/components/post-title/index.js
23350 /**
23351 * External dependencies
23352 */
23353
23354 /**
23355 * WordPress dependencies
23356 */
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368 /**
23369 * Internal dependencies
23370 */
23371
23372
23373
23374
23375
23376 const PostTitle = (0,external_wp_element_namespaceObject.forwardRef)((_, forwardedRef) => {
23377 const {
23378 placeholder
23379 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23380 const {
23381 getSettings
23382 } = select(external_wp_blockEditor_namespaceObject.store);
23383 const {
23384 titlePlaceholder
23385 } = getSettings();
23386 return {
23387 placeholder: titlePlaceholder
23388 };
23389 }, []);
23390 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
23391 const {
23392 ref: focusRef
23393 } = usePostTitleFocus(forwardedRef);
23394 const {
23395 title,
23396 setTitle: onUpdate
23397 } = usePostTitle();
23398 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
23399 const {
23400 clearSelectedBlock,
23401 insertBlocks,
23402 insertDefaultBlock
23403 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
23404 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
23405 const {
23406 value,
23407 onChange,
23408 ref: richTextRef
23409 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
23410 value: title,
23411 onChange(newValue) {
23412 onUpdate(newValue.replace(REGEXP_NEWLINES, ' '));
23413 },
23414 placeholder: decodedPlaceholder,
23415 selectionStart: selection.start,
23416 selectionEnd: selection.end,
23417 onSelectionChange(newStart, newEnd) {
23418 setSelection(sel => {
23419 const {
23420 start,
23421 end
23422 } = sel;
23423 if (start === newStart && end === newEnd) {
23424 return sel;
23425 }
23426 return {
23427 start: newStart,
23428 end: newEnd
23429 };
23430 });
23431 },
23432 __unstableDisableFormats: false
23433 });
23434 function onInsertBlockAfter(blocks) {
23435 insertBlocks(blocks, 0);
23436 }
23437 function onSelect() {
23438 setIsSelected(true);
23439 clearSelectedBlock();
23440 }
23441 function onUnselect() {
23442 setIsSelected(false);
23443 setSelection({});
23444 }
23445 function onEnterPress() {
23446 insertDefaultBlock(undefined, undefined, 0);
23447 }
23448 function onKeyDown(event) {
23449 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
23450 event.preventDefault();
23451 onEnterPress();
23452 }
23453 }
23454 function onPaste(event) {
23455 const clipboardData = event.clipboardData;
23456 let plainText = '';
23457 let html = '';
23458 try {
23459 plainText = clipboardData.getData('text/plain');
23460 html = clipboardData.getData('text/html');
23461 } catch (error) {
23462 // Some browsers like UC Browser paste plain text by default and
23463 // don't support clipboardData at all, so allow default
23464 // behaviour.
23465 return;
23466 }
23467
23468 // Allows us to ask for this information when we get a report.
23469 window.console.log('Received HTML:\n\n', html);
23470 window.console.log('Received plain text:\n\n', plainText);
23471 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
23472 HTML: html,
23473 plainText
23474 });
23475 event.preventDefault();
23476 if (!content.length) {
23477 return;
23478 }
23479 if (typeof content !== 'string') {
23480 const [firstBlock] = content;
23481 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
23482 // Strip HTML to avoid unwanted HTML being added to the title.
23483 // In the majority of cases it is assumed that HTML in the title
23484 // is undesirable.
23485 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content);
23486 onUpdate(contentNoHTML);
23487 onInsertBlockAfter(content.slice(1));
23488 } else {
23489 onInsertBlockAfter(content);
23490 }
23491 } else {
23492 // Strip HTML to avoid unwanted HTML being added to the title.
23493 // In the majority of cases it is assumed that HTML in the title
23494 // is undesirable.
23495 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content);
23496 onChange((0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
23497 html: contentNoHTML
23498 })));
23499 }
23500 }
23501
23502 // The wp-block className is important for editor styles.
23503 // This same block is used in both the visual and the code editor.
23504 const className = dist_clsx(DEFAULT_CLASSNAMES, {
23505 'is-selected': isSelected
23506 });
23507 return /*#__PURE__*/ /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
23508 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]),
23509 contentEditable: true,
23510 className: className,
23511 "aria-label": decodedPlaceholder,
23512 role: "textbox",
23513 "aria-multiline": "true",
23514 onFocus: onSelect,
23515 onBlur: onUnselect,
23516 onKeyDown: onKeyDown,
23517 onPaste: onPaste
23518 })
23519 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */;
23520 });
23521
23522 /**
23523 * Renders the `PostTitle` component.
23524 *
23525 * @param {Object} _ Unused parameter.
23526 * @param {Element} forwardedRef Forwarded ref for the component.
23527 *
23528 * @return {React.ReactNode} The rendered PostTitle component.
23529 */
23530 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)((_, forwardedRef) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
23531 supportKeys: "title",
23532 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTitle, {
23533 ref: forwardedRef
23534 })
23535 })));
23536
23537 ;// ./packages/editor/build-module/components/post-title/post-title-raw.js
23538 /**
23539 * External dependencies
23540 */
23541
23542
23543 /**
23544 * WordPress dependencies
23545 */
23546
23547
23548
23549
23550
23551
23552
23553 /**
23554 * Internal dependencies
23555 */
23556
23557
23558
23559
23560 /**
23561 * Renders a raw post title input field.
23562 *
23563 * @param {Object} _ Unused parameter.
23564 * @param {Element} forwardedRef Reference to the component's DOM node.
23565 *
23566 * @return {React.ReactNode} The rendered component.
23567 */
23568
23569 function PostTitleRaw(_, forwardedRef) {
23570 const {
23571 placeholder
23572 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23573 const {
23574 getSettings
23575 } = select(external_wp_blockEditor_namespaceObject.store);
23576 const {
23577 titlePlaceholder
23578 } = getSettings();
23579 return {
23580 placeholder: titlePlaceholder
23581 };
23582 }, []);
23583 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
23584 const {
23585 title,
23586 setTitle: onUpdate
23587 } = usePostTitle();
23588 const {
23589 ref: focusRef
23590 } = usePostTitleFocus(forwardedRef);
23591 function onChange(value) {
23592 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
23593 }
23594 function onSelect() {
23595 setIsSelected(true);
23596 }
23597 function onUnselect() {
23598 setIsSelected(false);
23599 }
23600
23601 // The wp-block className is important for editor styles.
23602 // This same block is used in both the visual and the code editor.
23603 const className = dist_clsx(DEFAULT_CLASSNAMES, {
23604 'is-selected': isSelected,
23605 'is-raw-text': true
23606 });
23607 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
23608 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
23609 ref: focusRef,
23610 value: title,
23611 onChange: onChange,
23612 onFocus: onSelect,
23613 onBlur: onUnselect,
23614 label: placeholder,
23615 className: className,
23616 placeholder: decodedPlaceholder,
23617 hideLabelFromVision: true,
23618 autoComplete: "off",
23619 dir: "auto",
23620 rows: 1,
23621 __nextHasNoMarginBottom: true
23622 });
23623 }
23624 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw));
23625
23626 ;// ./packages/editor/build-module/components/post-trash/check.js
23627 /**
23628 * WordPress dependencies
23629 */
23630
23631
23632
23633 /**
23634 * Internal dependencies
23635 */
23636
23637
23638
23639 /**
23640 * Wrapper component that renders its children only if the post can be trashed.
23641 *
23642 * @param {Object} props The component props.
23643 * @param {React.ReactElement} props.children The child components.
23644 *
23645 * @return {React.ReactElement | null} The rendered child components or null if the post can't be trashed.
23646 */
23647 function PostTrashCheck({
23648 children
23649 }) {
23650 const {
23651 canTrashPost
23652 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23653 const {
23654 isEditedPostNew,
23655 getCurrentPostId,
23656 getCurrentPostType
23657 } = select(store_store);
23658 const {
23659 canUser
23660 } = select(external_wp_coreData_namespaceObject.store);
23661 const postType = getCurrentPostType();
23662 const postId = getCurrentPostId();
23663 const isNew = isEditedPostNew();
23664 const canUserDelete = !!postId ? canUser('delete', {
23665 kind: 'postType',
23666 name: postType,
23667 id: postId
23668 }) : false;
23669 return {
23670 canTrashPost: (!isNew || postId) && canUserDelete && !GLOBAL_POST_TYPES.includes(postType)
23671 };
23672 }, []);
23673 if (!canTrashPost) {
23674 return null;
23675 }
23676 return children;
23677 }
23678
23679 ;// ./packages/editor/build-module/components/post-trash/index.js
23680 /**
23681 * WordPress dependencies
23682 */
23683
23684
23685
23686
23687
23688 /**
23689 * Internal dependencies
23690 */
23691
23692
23693
23694 /**
23695 * Displays the Post Trash Button and Confirm Dialog in the Editor.
23696 *
23697 * @param {?{onActionPerformed: Object}} An object containing the onActionPerformed function.
23698 * @return {React.ReactNode} The rendered PostTrash component.
23699 */
23700
23701 function PostTrash({
23702 onActionPerformed
23703 }) {
23704 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
23705 const {
23706 isNew,
23707 isDeleting,
23708 postId,
23709 title
23710 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23711 const store = select(store_store);
23712 return {
23713 isNew: store.isEditedPostNew(),
23714 isDeleting: store.isDeletingPost(),
23715 postId: store.getCurrentPostId(),
23716 title: store.getCurrentPostAttribute('title')
23717 };
23718 }, []);
23719 const {
23720 trashPost
23721 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23722 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
23723 if (isNew || !postId) {
23724 return null;
23725 }
23726 const handleConfirm = async () => {
23727 setShowConfirmDialog(false);
23728 await trashPost();
23729 const item = await registry.resolveSelect(store_store).getCurrentPost();
23730 // After the post is trashed, we want to trigger the onActionPerformed callback, so the user is redirect
23731 // to the post view depending on if the user is on post editor or site editor.
23732 onActionPerformed?.('move-to-trash', [item]);
23733 };
23734 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PostTrashCheck, {
23735 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23736 __next40pxDefaultSize: true,
23737 className: "editor-post-trash",
23738 isDestructive: true,
23739 variant: "secondary",
23740 isBusy: isDeleting,
23741 "aria-disabled": isDeleting,
23742 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true),
23743 children: (0,external_wp_i18n_namespaceObject.__)('Move to trash')
23744 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
23745 isOpen: showConfirmDialog,
23746 onConfirm: handleConfirm,
23747 onCancel: () => setShowConfirmDialog(false),
23748 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
23749 size: "small",
23750 children: (0,external_wp_i18n_namespaceObject.sprintf)(
23751 // translators: %s: The item's title.
23752 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move "%s" to the trash?'), title)
23753 })]
23754 });
23755 }
23756
23757 ;// ./packages/editor/build-module/components/post-url/index.js
23758 /**
23759 * WordPress dependencies
23760 */
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772 /**
23773 * Internal dependencies
23774 */
23775
23776
23777 /**
23778 * Renders the `PostURL` component.
23779 *
23780 * @example
23781 * ```jsx
23782 * <PostURL />
23783 * ```
23784 *
23785 * @param {{ onClose: () => void }} props The props for the component.
23786 * @param {() => void} props.onClose Callback function to be executed when the popover is closed.
23787 *
23788 * @return {React.ReactNode} The rendered PostURL component.
23789 */
23790
23791 function PostURL({
23792 onClose
23793 }) {
23794 const {
23795 isEditable,
23796 postSlug,
23797 postLink,
23798 permalinkPrefix,
23799 permalinkSuffix,
23800 permalink
23801 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23802 var _post$_links$wpActio;
23803 const post = select(store_store).getCurrentPost();
23804 const postTypeSlug = select(store_store).getCurrentPostType();
23805 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
23806 const permalinkParts = select(store_store).getPermalinkParts();
23807 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false;
23808 return {
23809 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction,
23810 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()),
23811 viewPostLabel: postType?.labels.view_item,
23812 postLink: post.link,
23813 permalinkPrefix: permalinkParts?.prefix,
23814 permalinkSuffix: permalinkParts?.suffix,
23815 permalink: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getPermalink())
23816 };
23817 }, []);
23818 const {
23819 editPost
23820 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23821 const {
23822 createNotice
23823 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
23824 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
23825 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
23826 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied Permalink to clipboard.'), {
23827 isDismissible: true,
23828 type: 'snackbar'
23829 });
23830 });
23831 const postUrlSlugDescriptionId = 'editor-post-url__slug-description-' + (0,external_wp_compose_namespaceObject.useInstanceId)(PostURL);
23832 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23833 className: "editor-post-url",
23834 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
23835 title: (0,external_wp_i18n_namespaceObject.__)('Slug'),
23836 onClose: onClose
23837 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
23838 spacing: 3,
23839 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
23840 className: "editor-post-url__intro",
23841 children: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>'), {
23842 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
23843 id: postUrlSlugDescriptionId
23844 }),
23845 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
23846 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink')
23847 })
23848 })
23849 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23850 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23851 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
23852 __next40pxDefaultSize: true,
23853 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
23854 children: "/"
23855 }),
23856 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlSuffixWrapper, {
23857 variant: "control",
23858 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23859 icon: copy_small,
23860 ref: copyButtonRef,
23861 size: "small",
23862 label: "Copy"
23863 })
23864 }),
23865 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
23866 hideLabelFromVision: true,
23867 value: forceEmptyField ? '' : postSlug,
23868 autoComplete: "off",
23869 spellCheck: "false",
23870 type: "text",
23871 className: "editor-post-url__input",
23872 onChange: newValue => {
23873 editPost({
23874 slug: newValue
23875 });
23876 // When we delete the field the permalink gets
23877 // reverted to the original value.
23878 // The forceEmptyField logic allows the user to have
23879 // the field temporarily empty while typing.
23880 if (!newValue) {
23881 if (!forceEmptyField) {
23882 setForceEmptyField(true);
23883 }
23884 return;
23885 }
23886 if (forceEmptyField) {
23887 setForceEmptyField(false);
23888 }
23889 },
23890 onBlur: event => {
23891 editPost({
23892 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
23893 });
23894 if (forceEmptyField) {
23895 setForceEmptyField(false);
23896 }
23897 },
23898 "aria-describedby": postUrlSlugDescriptionId
23899 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", {
23900 className: "editor-post-url__permalink",
23901 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
23902 className: "editor-post-url__permalink-visual-label",
23903 children: (0,external_wp_i18n_namespaceObject.__)('Permalink:')
23904 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
23905 className: "editor-post-url__link",
23906 href: postLink,
23907 target: "_blank",
23908 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
23909 className: "editor-post-url__link-prefix",
23910 children: permalinkPrefix
23911 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
23912 className: "editor-post-url__link-slug",
23913 children: postSlug
23914 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
23915 className: "editor-post-url__link-suffix",
23916 children: permalinkSuffix
23917 })]
23918 })]
23919 })]
23920 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
23921 className: "editor-post-url__link",
23922 href: postLink,
23923 target: "_blank",
23924 children: postLink
23925 })]
23926 })]
23927 })]
23928 });
23929 }
23930
23931 ;// ./packages/editor/build-module/components/post-url/check.js
23932 /**
23933 * WordPress dependencies
23934 */
23935
23936
23937
23938 /**
23939 * Internal dependencies
23940 */
23941
23942
23943 /**
23944 * Check if the post URL is valid and visible.
23945 *
23946 * @param {Object} props The component props.
23947 * @param {React.ReactElement} props.children The child components.
23948 *
23949 * @return {React.ReactElement} The child components if the post URL is valid and visible, otherwise null.
23950 */
23951 function PostURLCheck({
23952 children
23953 }) {
23954 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
23955 const postTypeSlug = select(store_store).getCurrentPostType();
23956 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
23957 if (!postType?.viewable) {
23958 return false;
23959 }
23960 const post = select(store_store).getCurrentPost();
23961 if (!post.link) {
23962 return false;
23963 }
23964 const permalinkParts = select(store_store).getPermalinkParts();
23965 if (!permalinkParts) {
23966 return false;
23967 }
23968 return true;
23969 }, []);
23970 if (!isVisible) {
23971 return null;
23972 }
23973 return children;
23974 }
23975
23976 ;// ./packages/editor/build-module/components/post-url/label.js
23977 /**
23978 * WordPress dependencies
23979 */
23980
23981
23982
23983 /**
23984 * Internal dependencies
23985 */
23986
23987
23988 /**
23989 * Represents a label component for a post URL.
23990 *
23991 * @return {React.ReactNode} The PostURLLabel component.
23992 */
23993 function PostURLLabel() {
23994 return usePostURLLabel();
23995 }
23996
23997 /**
23998 * Custom hook to get the label for the post URL.
23999 *
24000 * @return {string} The filtered and decoded post URL label.
24001 */
24002 function usePostURLLabel() {
24003 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []);
24004 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink));
24005 }
24006
24007 ;// ./packages/editor/build-module/components/post-url/panel.js
24008 /**
24009 * WordPress dependencies
24010 */
24011
24012
24013
24014
24015
24016
24017
24018 /**
24019 * Internal dependencies
24020 */
24021
24022
24023
24024
24025
24026 /**
24027 * Renders the `PostURLPanel` component.
24028 *
24029 * @return {React.ReactNode} The rendered PostURLPanel component.
24030 */
24031
24032 function PostURLPanel() {
24033 const {
24034 isFrontPage
24035 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24036 const {
24037 getCurrentPostId
24038 } = select(store_store);
24039 const {
24040 getEditedEntityRecord,
24041 canUser
24042 } = select(external_wp_coreData_namespaceObject.store);
24043 const siteSettings = canUser('read', {
24044 kind: 'root',
24045 name: 'site'
24046 }) ? getEditedEntityRecord('root', 'site') : undefined;
24047 const _id = getCurrentPostId();
24048 return {
24049 isFrontPage: siteSettings?.page_on_front === _id
24050 };
24051 }, []);
24052 // Use internal state instead of a ref to make sure that the component
24053 // re-renders when the popover's anchor updates.
24054 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
24055 // Memoize popoverProps to avoid returning a new object every time.
24056 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
24057 // Anchor the popover to the middle of the entire row so that it doesn't
24058 // move around when the label changes.
24059 anchor: popoverAnchor,
24060 placement: 'left-start',
24061 offset: 36,
24062 shift: true
24063 }), [popoverAnchor]);
24064 const label = isFrontPage ? (0,external_wp_i18n_namespaceObject.__)('Link') : (0,external_wp_i18n_namespaceObject.__)('Slug');
24065 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLCheck, {
24066 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_panel_row, {
24067 label: label,
24068 ref: setPopoverAnchor,
24069 children: [!isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
24070 popoverProps: popoverProps,
24071 className: "editor-post-url__panel-dropdown",
24072 contentClassName: "editor-post-url__panel-dialog",
24073 focusOnMount: true,
24074 renderToggle: ({
24075 isOpen,
24076 onToggle
24077 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLToggle, {
24078 isOpen: isOpen,
24079 onClick: onToggle
24080 }),
24081 renderContent: ({
24082 onClose
24083 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURL, {
24084 onClose: onClose
24085 })
24086 }), isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FrontPageLink, {})]
24087 })
24088 });
24089 }
24090 function PostURLToggle({
24091 isOpen,
24092 onClick
24093 }) {
24094 const {
24095 slug
24096 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24097 return {
24098 slug: select(store_store).getEditedPostSlug()
24099 };
24100 }, []);
24101 const decodedSlug = (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(slug);
24102 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24103 size: "compact",
24104 className: "editor-post-url__panel-toggle",
24105 variant: "tertiary",
24106 "aria-expanded": isOpen,
24107 "aria-label":
24108 // translators: %s: Current post link.
24109 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change link: %s'), decodedSlug),
24110 onClick: onClick,
24111 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24112 children: decodedSlug
24113 })
24114 });
24115 }
24116 function FrontPageLink() {
24117 const {
24118 postLink
24119 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24120 const {
24121 getCurrentPost
24122 } = select(store_store);
24123 return {
24124 postLink: getCurrentPost()?.link
24125 };
24126 }, []);
24127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
24128 className: "editor-post-url__front-page-link",
24129 href: postLink,
24130 target: "_blank",
24131 children: postLink
24132 });
24133 }
24134
24135 ;// ./packages/editor/build-module/components/post-visibility/check.js
24136 /**
24137 * WordPress dependencies
24138 */
24139
24140
24141 /**
24142 * Internal dependencies
24143 */
24144
24145
24146 /**
24147 * Determines if the current post can be edited (published)
24148 * and passes this information to the provided render function.
24149 *
24150 * @param {Object} props The component props.
24151 * @param {Function} props.render Function to render the component.
24152 * Receives an object with a `canEdit` property.
24153 * @return {React.ReactNode} The rendered component.
24154 */
24155 function PostVisibilityCheck({
24156 render
24157 }) {
24158 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => {
24159 var _select$getCurrentPos;
24160 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
24161 });
24162 return render({
24163 canEdit
24164 });
24165 }
24166
24167 ;// ./packages/icons/build-module/library/info.js
24168 /**
24169 * WordPress dependencies
24170 */
24171
24172
24173 const info = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
24174 viewBox: "0 0 24 24",
24175 xmlns: "http://www.w3.org/2000/svg",
24176 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
24177 fillRule: "evenodd",
24178 clipRule: "evenodd",
24179 d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"
24180 })
24181 });
24182 /* harmony default export */ const library_info = (info);
24183
24184 ;// external ["wp","wordcount"]
24185 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
24186 ;// ./packages/editor/build-module/components/word-count/index.js
24187 /**
24188 * WordPress dependencies
24189 */
24190
24191
24192
24193
24194 /**
24195 * Internal dependencies
24196 */
24197
24198
24199 /**
24200 * Renders the word count of the post content.
24201 *
24202 * @return {React.ReactNode} The rendered WordCount component.
24203 */
24204
24205 function WordCount() {
24206 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
24207
24208 /*
24209 * translators: If your word count is based on single characters (e.g. East Asian characters),
24210 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
24211 * Do not translate into your own language.
24212 */
24213 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
24214 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24215 className: "word-count",
24216 children: (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)
24217 });
24218 }
24219
24220 ;// ./packages/editor/build-module/components/time-to-read/index.js
24221 /**
24222 * WordPress dependencies
24223 */
24224
24225
24226
24227
24228
24229 /**
24230 * Internal dependencies
24231 */
24232
24233
24234 /**
24235 * Average reading rate - based on average taken from
24236 * https://irisreading.com/average-reading-speed-in-various-languages/
24237 * (Characters/minute used for Chinese rather than words).
24238 *
24239 * @type {number} A rough estimate of the average reading rate across multiple languages.
24240 */
24241
24242 const AVERAGE_READING_RATE = 189;
24243
24244 /**
24245 * Component for showing Time To Read in Content.
24246 *
24247 * @return {React.ReactNode} The rendered TimeToRead component.
24248 */
24249 function TimeToRead() {
24250 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
24251
24252 /*
24253 * translators: If your word count is based on single characters (e.g. East Asian characters),
24254 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
24255 * Do not translate into your own language.
24256 */
24257 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
24258 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE);
24259 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), {
24260 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
24261 }) : (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: the number of minutes to read the post. */
24262 (0,external_wp_i18n_namespaceObject._n)('<span>%s</span> minute', '<span>%s</span> minutes', minutesToRead), minutesToRead), {
24263 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
24264 });
24265 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24266 className: "time-to-read",
24267 children: minutesToReadString
24268 });
24269 }
24270
24271 ;// ./packages/editor/build-module/components/character-count/index.js
24272 /**
24273 * WordPress dependencies
24274 */
24275
24276
24277
24278 /**
24279 * Internal dependencies
24280 */
24281
24282
24283 /**
24284 * Renders the character count of the post content.
24285 *
24286 * @return {number} The character count.
24287 */
24288 function CharacterCount() {
24289 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
24290 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
24291 }
24292
24293 ;// ./packages/editor/build-module/components/table-of-contents/panel.js
24294 /**
24295 * WordPress dependencies
24296 */
24297
24298
24299
24300
24301 /**
24302 * Internal dependencies
24303 */
24304
24305
24306
24307
24308
24309 function TableOfContentsPanel({
24310 hasOutlineItemsDisabled,
24311 onRequestClose
24312 }) {
24313 const {
24314 headingCount,
24315 paragraphCount,
24316 numberOfBlocks
24317 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24318 const {
24319 getGlobalBlockCount
24320 } = select(external_wp_blockEditor_namespaceObject.store);
24321 return {
24322 headingCount: getGlobalBlockCount('core/heading'),
24323 paragraphCount: getGlobalBlockCount('core/paragraph'),
24324 numberOfBlocks: getGlobalBlockCount()
24325 };
24326 }, []);
24327 return (
24328 /*#__PURE__*/
24329 /*
24330 * Disable reason: The `list` ARIA role is redundant but
24331 * Safari+VoiceOver won't announce the list otherwise.
24332 */
24333 /* eslint-disable jsx-a11y/no-redundant-roles */
24334 (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24335 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24336 className: "table-of-contents__wrapper",
24337 role: "note",
24338 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
24339 tabIndex: "0",
24340 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
24341 role: "list",
24342 className: "table-of-contents__counts",
24343 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24344 className: "table-of-contents__count",
24345 children: [(0,external_wp_i18n_namespaceObject.__)('Words'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
24346 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24347 className: "table-of-contents__count",
24348 children: [(0,external_wp_i18n_namespaceObject.__)('Characters'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24349 className: "table-of-contents__number",
24350 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
24351 })]
24352 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24353 className: "table-of-contents__count",
24354 children: [(0,external_wp_i18n_namespaceObject.__)('Time to read'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
24355 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24356 className: "table-of-contents__count",
24357 children: [(0,external_wp_i18n_namespaceObject.__)('Headings'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24358 className: "table-of-contents__number",
24359 children: headingCount
24360 })]
24361 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24362 className: "table-of-contents__count",
24363 children: [(0,external_wp_i18n_namespaceObject.__)('Paragraphs'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24364 className: "table-of-contents__number",
24365 children: paragraphCount
24366 })]
24367 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24368 className: "table-of-contents__count",
24369 children: [(0,external_wp_i18n_namespaceObject.__)('Blocks'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
24370 className: "table-of-contents__number",
24371 children: numberOfBlocks
24372 })]
24373 })]
24374 })
24375 }), headingCount > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24376 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
24377 className: "table-of-contents__title",
24378 children: (0,external_wp_i18n_namespaceObject.__)('Document Outline')
24379 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {
24380 onSelect: onRequestClose,
24381 hasOutlineItemsDisabled: hasOutlineItemsDisabled
24382 })]
24383 })]
24384 })
24385 /* eslint-enable jsx-a11y/no-redundant-roles */
24386 );
24387 }
24388 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel);
24389
24390 ;// ./packages/editor/build-module/components/table-of-contents/index.js
24391 /**
24392 * WordPress dependencies
24393 */
24394
24395
24396
24397
24398
24399
24400
24401 /**
24402 * Internal dependencies
24403 */
24404
24405
24406 function TableOfContents({
24407 hasOutlineItemsDisabled,
24408 repositionDropdown,
24409 ...props
24410 }, ref) {
24411 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
24412 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
24413 popoverProps: {
24414 placement: repositionDropdown ? 'right' : 'bottom'
24415 },
24416 className: "table-of-contents",
24417 contentClassName: "table-of-contents__popover",
24418 renderToggle: ({
24419 isOpen,
24420 onToggle
24421 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24422 __next40pxDefaultSize: true,
24423 ...props,
24424 ref: ref,
24425 onClick: hasBlocks ? onToggle : undefined,
24426 icon: library_info,
24427 "aria-expanded": isOpen,
24428 "aria-haspopup": "true"
24429 /* translators: button label text should, if possible, be under 16 characters. */,
24430 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
24431 tooltipPosition: "bottom",
24432 "aria-disabled": !hasBlocks
24433 }),
24434 renderContent: ({
24435 onClose
24436 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(table_of_contents_panel, {
24437 onRequestClose: onClose,
24438 hasOutlineItemsDisabled: hasOutlineItemsDisabled
24439 })
24440 });
24441 }
24442
24443 /**
24444 * Renders a table of contents component.
24445 *
24446 * @param {Object} props The component props.
24447 * @param {boolean} props.hasOutlineItemsDisabled Whether outline items are disabled.
24448 * @param {boolean} props.repositionDropdown Whether to reposition the dropdown.
24449 * @param {Element.ref} ref The component's ref.
24450 *
24451 * @return {React.ReactNode} The rendered table of contents component.
24452 */
24453 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
24454
24455 ;// ./packages/editor/build-module/components/unsaved-changes-warning/index.js
24456 /**
24457 * WordPress dependencies
24458 */
24459
24460
24461
24462
24463
24464 /**
24465 * Warns the user if there are unsaved changes before leaving the editor.
24466 * Compatible with Post Editor and Site Editor.
24467 *
24468 * @return {React.ReactNode} The component.
24469 */
24470 function UnsavedChangesWarning() {
24471 const {
24472 __experimentalGetDirtyEntityRecords
24473 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
24474 (0,external_wp_element_namespaceObject.useEffect)(() => {
24475 /**
24476 * Warns the user if there are unsaved changes before leaving the editor.
24477 *
24478 * @param {Event} event `beforeunload` event.
24479 *
24480 * @return {string | undefined} Warning prompt message, if unsaved changes exist.
24481 */
24482 const warnIfUnsavedChanges = event => {
24483 // We need to call the selector directly in the listener to avoid race
24484 // conditions with `BrowserURL` where `componentDidUpdate` gets the
24485 // new value of `isEditedPostDirty` before this component does,
24486 // causing this component to incorrectly think a trashed post is still dirty.
24487 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
24488 if (dirtyEntityRecords.length > 0) {
24489 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
24490 return event.returnValue;
24491 }
24492 };
24493 window.addEventListener('beforeunload', warnIfUnsavedChanges);
24494 return () => {
24495 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
24496 };
24497 }, [__experimentalGetDirtyEntityRecords]);
24498 return null;
24499 }
24500
24501 ;// ./packages/editor/build-module/components/provider/with-registry-provider.js
24502 /**
24503 * WordPress dependencies
24504 */
24505
24506
24507
24508
24509
24510 /**
24511 * Internal dependencies
24512 */
24513
24514
24515 function getSubRegistry(subRegistries, registry, useSubRegistry) {
24516 if (!useSubRegistry) {
24517 return registry;
24518 }
24519 let subRegistry = subRegistries.get(registry);
24520 if (!subRegistry) {
24521 subRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
24522 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
24523 }, registry);
24524 // Todo: The interface store should also be created per instance.
24525 subRegistry.registerStore('core/editor', storeConfig);
24526 subRegistries.set(registry, subRegistry);
24527 }
24528 return subRegistry;
24529 }
24530 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ({
24531 useSubRegistry = true,
24532 ...props
24533 }) => {
24534 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
24535 const [subRegistries] = (0,external_wp_element_namespaceObject.useState)(() => new WeakMap());
24536 const subRegistry = getSubRegistry(subRegistries, registry, useSubRegistry);
24537 if (subRegistry === registry) {
24538 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
24539 registry: registry,
24540 ...props
24541 });
24542 }
24543 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_data_namespaceObject.RegistryProvider, {
24544 value: subRegistry,
24545 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
24546 registry: subRegistry,
24547 ...props
24548 })
24549 });
24550 }, 'withRegistryProvider');
24551 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
24552
24553 ;// ./packages/editor/build-module/components/media-categories/index.js
24554 /* wp:polyfill */
24555 /**
24556 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
24557 * See `packages/editor/src/components/media-categories/index.js`.
24558 *
24559 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
24560 * The rest of the settings would still need to be in sync though.
24561 */
24562
24563 /**
24564 * WordPress dependencies
24565 */
24566
24567
24568
24569
24570 /**
24571 * Internal dependencies
24572 */
24573
24574
24575 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
24576 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
24577 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
24578
24579 const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
24580 const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
24581 const getOpenverseLicense = (license, licenseVersion) => {
24582 let licenseName = license.trim();
24583 // PDM has no abbreviation
24584 if (license !== 'pdm') {
24585 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
24586 }
24587 // If version is known, append version to the name.
24588 // The license has to have a version to be valid. Only
24589 // PDM (public domain mark) doesn't have a version.
24590 if (licenseVersion) {
24591 licenseName += ` ${licenseVersion}`;
24592 }
24593 // For licenses other than public-domain marks, prepend 'CC' to the name.
24594 if (!['pdm', 'cc0'].includes(license)) {
24595 licenseName = `CC ${licenseName}`;
24596 }
24597 return licenseName;
24598 };
24599 const getOpenverseCaption = item => {
24600 const {
24601 title,
24602 foreign_landing_url: foreignLandingUrl,
24603 creator,
24604 creator_url: creatorUrl,
24605 license,
24606 license_version: licenseVersion,
24607 license_url: licenseUrl
24608 } = item;
24609 const fullLicense = getOpenverseLicense(license, licenseVersion);
24610 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator);
24611 let _caption;
24612 if (_creator) {
24613 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
24614 // 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".
24615 (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)(
24616 // 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".
24617 (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);
24618 } else {
24619 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
24620 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
24621 (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)(
24622 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
24623 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
24624 }
24625 return _caption.replace(/\s{2}/g, ' ');
24626 };
24627 const coreMediaFetch = async (query = {}) => {
24628 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({
24629 ...query,
24630 orderBy: !!query?.search ? 'relevance' : 'date'
24631 });
24632 return mediaItems.map(mediaItem => ({
24633 ...mediaItem,
24634 alt: mediaItem.alt_text,
24635 url: mediaItem.source_url,
24636 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
24637 caption: mediaItem.caption?.raw
24638 }));
24639 };
24640
24641 /** @type {InserterMediaCategory[]} */
24642 const inserterMediaCategories = [{
24643 name: 'images',
24644 labels: {
24645 name: (0,external_wp_i18n_namespaceObject.__)('Images'),
24646 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images')
24647 },
24648 mediaType: 'image',
24649 async fetch(query = {}) {
24650 return coreMediaFetch({
24651 ...query,
24652 media_type: 'image'
24653 });
24654 }
24655 }, {
24656 name: 'videos',
24657 labels: {
24658 name: (0,external_wp_i18n_namespaceObject.__)('Videos'),
24659 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos')
24660 },
24661 mediaType: 'video',
24662 async fetch(query = {}) {
24663 return coreMediaFetch({
24664 ...query,
24665 media_type: 'video'
24666 });
24667 }
24668 }, {
24669 name: 'audio',
24670 labels: {
24671 name: (0,external_wp_i18n_namespaceObject.__)('Audio'),
24672 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio')
24673 },
24674 mediaType: 'audio',
24675 async fetch(query = {}) {
24676 return coreMediaFetch({
24677 ...query,
24678 media_type: 'audio'
24679 });
24680 }
24681 }, {
24682 name: 'openverse',
24683 labels: {
24684 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'),
24685 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse')
24686 },
24687 mediaType: 'image',
24688 async fetch(query = {}) {
24689 const defaultArgs = {
24690 mature: false,
24691 excluded_source: 'flickr,inaturalist,wikimedia',
24692 license: 'pdm,cc0'
24693 };
24694 const finalQuery = {
24695 ...query,
24696 ...defaultArgs
24697 };
24698 const mapFromInserterMediaRequest = {
24699 per_page: 'page_size',
24700 search: 'q'
24701 };
24702 const url = new URL('https://api.openverse.org/v1/images/');
24703 Object.entries(finalQuery).forEach(([key, value]) => {
24704 const queryKey = mapFromInserterMediaRequest[key] || key;
24705 url.searchParams.set(queryKey, value);
24706 });
24707 const response = await window.fetch(url, {
24708 headers: {
24709 'User-Agent': 'WordPress/inserter-media-fetch'
24710 }
24711 });
24712 const jsonResponse = await response.json();
24713 const results = jsonResponse.results;
24714 return results.map(result => ({
24715 ...result,
24716 // This is a temp solution for better titles, until Openverse API
24717 // completes the cleaning up of some titles of their upstream data.
24718 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
24719 sourceId: result.id,
24720 id: undefined,
24721 caption: getOpenverseCaption(result),
24722 previewUrl: result.thumbnail
24723 }));
24724 },
24725 getReportUrl: ({
24726 sourceId
24727 }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
24728 isExternalResource: true
24729 }];
24730 /* harmony default export */ const media_categories = (inserterMediaCategories);
24731
24732 ;// ./packages/editor/build-module/utils/media-upload/index.js
24733 /**
24734 * External dependencies
24735 */
24736
24737
24738 /**
24739 * WordPress dependencies
24740 */
24741
24742
24743
24744 /**
24745 * Internal dependencies
24746 */
24747
24748 const media_upload_noop = () => {};
24749
24750 /**
24751 * Upload a media file when the file upload button is activated.
24752 * Wrapper around mediaUpload() that injects the current post ID.
24753 *
24754 * @param {Object} $0 Parameters object passed to the function.
24755 * @param {?Object} $0.additionalData Additional data to include in the request.
24756 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
24757 * @param {Array} $0.filesList List of files.
24758 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
24759 * @param {Function} $0.onError Function called when an error happens.
24760 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
24761 * @param {Function} $0.onSuccess Function called after the final representation of the file is available.
24762 */
24763 function mediaUpload({
24764 additionalData = {},
24765 allowedTypes,
24766 filesList,
24767 maxUploadFileSize,
24768 onError = media_upload_noop,
24769 onFileChange,
24770 onSuccess
24771 }) {
24772 const {
24773 getCurrentPost,
24774 getEditorSettings
24775 } = (0,external_wp_data_namespaceObject.select)(store_store);
24776 const {
24777 lockPostAutosaving,
24778 unlockPostAutosaving,
24779 lockPostSaving,
24780 unlockPostSaving
24781 } = (0,external_wp_data_namespaceObject.dispatch)(store_store);
24782 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
24783 const lockKey = `image-upload-${esm_browser_v4()}`;
24784 let imageIsUploading = false;
24785 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
24786 const currentPost = getCurrentPost();
24787 // Templates and template parts' numerical ID is stored in `wp_id`.
24788 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
24789 const setSaveLock = () => {
24790 lockPostSaving(lockKey);
24791 lockPostAutosaving(lockKey);
24792 imageIsUploading = true;
24793 };
24794 const postData = currentPostId ? {
24795 post: currentPostId
24796 } : {};
24797 const clearSaveLock = () => {
24798 unlockPostSaving(lockKey);
24799 unlockPostAutosaving(lockKey);
24800 imageIsUploading = false;
24801 };
24802 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
24803 allowedTypes,
24804 filesList,
24805 onFileChange: file => {
24806 if (!imageIsUploading) {
24807 setSaveLock();
24808 } else {
24809 clearSaveLock();
24810 }
24811 onFileChange?.(file);
24812 },
24813 onSuccess,
24814 additionalData: {
24815 ...postData,
24816 ...additionalData
24817 },
24818 maxUploadFileSize,
24819 onError: ({
24820 message
24821 }) => {
24822 clearSaveLock();
24823 onError(message);
24824 },
24825 wpAllowedMimeTypes
24826 });
24827 }
24828
24829 ;// ./packages/editor/build-module/utils/media-sideload/index.js
24830 /**
24831 * WordPress dependencies
24832 */
24833
24834
24835 /**
24836 * Internal dependencies
24837 */
24838
24839 const {
24840 sideloadMedia: mediaSideload
24841 } = unlock(external_wp_mediaUtils_namespaceObject.privateApis);
24842 /* harmony default export */ const media_sideload = (mediaSideload);
24843
24844 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
24845 var cjs = __webpack_require__(66);
24846 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
24847 ;// ./node_modules/is-plain-object/dist/is-plain-object.mjs
24848 /*!
24849 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
24850 *
24851 * Copyright (c) 2014-2017, Jon Schlinkert.
24852 * Released under the MIT License.
24853 */
24854
24855 function isObject(o) {
24856 return Object.prototype.toString.call(o) === '[object Object]';
24857 }
24858
24859 function isPlainObject(o) {
24860 var ctor,prot;
24861
24862 if (isObject(o) === false) return false;
24863
24864 // If has modified constructor
24865 ctor = o.constructor;
24866 if (ctor === undefined) return true;
24867
24868 // If has modified prototype
24869 prot = ctor.prototype;
24870 if (isObject(prot) === false) return false;
24871
24872 // If constructor does not have an Object-specific method
24873 if (prot.hasOwnProperty('isPrototypeOf') === false) {
24874 return false;
24875 }
24876
24877 // Most likely a plain Object
24878 return true;
24879 }
24880
24881
24882
24883 ;// ./packages/editor/build-module/components/global-styles-provider/index.js
24884 /**
24885 * External dependencies
24886 */
24887
24888
24889
24890 /**
24891 * WordPress dependencies
24892 */
24893
24894
24895
24896
24897
24898 /**
24899 * Internal dependencies
24900 */
24901
24902
24903 const {
24904 GlobalStylesContext: global_styles_provider_GlobalStylesContext,
24905 cleanEmptyObject
24906 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24907 function mergeBaseAndUserConfigs(base, user) {
24908 return cjs_default()(base, user, {
24909 /*
24910 * We only pass as arrays the presets,
24911 * in which case we want the new array of values
24912 * to override the old array (no merging).
24913 */
24914 isMergeableObject: isPlainObject,
24915 /*
24916 * Exceptions to the above rule.
24917 * Background images should be replaced, not merged,
24918 * as they themselves are specific object definitions for the style.
24919 */
24920 customMerge: key => {
24921 if (key === 'backgroundImage') {
24922 return (baseConfig, userConfig) => userConfig;
24923 }
24924 return undefined;
24925 }
24926 });
24927 }
24928 function useGlobalStylesUserConfig() {
24929 const {
24930 globalStylesId,
24931 isReady,
24932 settings,
24933 styles,
24934 _links
24935 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24936 const {
24937 getEntityRecord,
24938 getEditedEntityRecord,
24939 hasFinishedResolution,
24940 canUser
24941 } = select(external_wp_coreData_namespaceObject.store);
24942 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
24943 let record;
24944
24945 /*
24946 * Ensure that the global styles ID request is complete by testing `_globalStylesId`,
24947 * before firing off the `canUser` OPTIONS request for user capabilities, otherwise it will
24948 * fetch `/wp/v2/global-styles` instead of `/wp/v2/global-styles/{id}`.
24949 * NOTE: Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,
24950 * or set using the `block_editor_rest_api_preload_paths` filter, if this changes.
24951 */
24952 const userCanEditGlobalStyles = _globalStylesId ? canUser('update', {
24953 kind: 'root',
24954 name: 'globalStyles',
24955 id: _globalStylesId
24956 }) : null;
24957 if (_globalStylesId &&
24958 /*
24959 * Test that the OPTIONS request for user capabilities is complete
24960 * before fetching the global styles entity record.
24961 * This is to avoid fetching the global styles entity unnecessarily.
24962 */
24963 typeof userCanEditGlobalStyles === 'boolean') {
24964 /*
24965 * Fetch the global styles entity record based on the user's capabilities.
24966 * The default context is `edit` for users who can edit global styles.
24967 * Otherwise, the context is `view`.
24968 * NOTE: There is an equivalent conditional check using `current_user_can()` in the backend
24969 * to preload the global styles entity. Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,
24970 * or set using `block_editor_rest_api_preload_paths` filter, if this changes.
24971 */
24972 if (userCanEditGlobalStyles) {
24973 record = getEditedEntityRecord('root', 'globalStyles', _globalStylesId);
24974 } else {
24975 record = getEntityRecord('root', 'globalStyles', _globalStylesId, {
24976 context: 'view'
24977 });
24978 }
24979 }
24980 let hasResolved = false;
24981 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
24982 if (_globalStylesId) {
24983 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : hasFinishedResolution('getEntityRecord', ['root', 'globalStyles', _globalStylesId, {
24984 context: 'view'
24985 }]);
24986 } else {
24987 hasResolved = true;
24988 }
24989 }
24990 return {
24991 globalStylesId: _globalStylesId,
24992 isReady: hasResolved,
24993 settings: record?.settings,
24994 styles: record?.styles,
24995 _links: record?._links
24996 };
24997 }, []);
24998 const {
24999 getEditedEntityRecord
25000 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
25001 const {
25002 editEntityRecord
25003 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25004 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
25005 return {
25006 settings: settings !== null && settings !== void 0 ? settings : {},
25007 styles: styles !== null && styles !== void 0 ? styles : {},
25008 _links: _links !== null && _links !== void 0 ? _links : {}
25009 };
25010 }, [settings, styles, _links]);
25011 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(
25012 /**
25013 * Set the global styles config.
25014 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
25015 * Otherwise, overwrite the current config with the incoming object.
25016 * @param {Object} options Options for editEntityRecord Core selector.
25017 */
25018 (callbackOrObject, options = {}) => {
25019 var _record$styles, _record$settings, _record$_links;
25020 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
25021 const currentConfig = {
25022 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
25023 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {},
25024 _links: (_record$_links = record?._links) !== null && _record$_links !== void 0 ? _record$_links : {}
25025 };
25026 const updatedConfig = typeof callbackOrObject === 'function' ? callbackOrObject(currentConfig) : callbackOrObject;
25027 editEntityRecord('root', 'globalStyles', globalStylesId, {
25028 styles: cleanEmptyObject(updatedConfig.styles) || {},
25029 settings: cleanEmptyObject(updatedConfig.settings) || {},
25030 _links: cleanEmptyObject(updatedConfig._links) || {}
25031 }, options);
25032 }, [globalStylesId, editEntityRecord, getEditedEntityRecord]);
25033 return [isReady, config, setConfig];
25034 }
25035 function useGlobalStylesBaseConfig() {
25036 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles(), []);
25037 return [!!baseConfig, baseConfig];
25038 }
25039 function useGlobalStylesContext() {
25040 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
25041 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
25042 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
25043 if (!baseConfig || !userConfig) {
25044 return {};
25045 }
25046 return mergeBaseAndUserConfigs(baseConfig, userConfig);
25047 }, [userConfig, baseConfig]);
25048 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
25049 return {
25050 isReady: isUserConfigReady && isBaseConfigReady,
25051 user: userConfig,
25052 base: baseConfig,
25053 merged: mergedConfig,
25054 setUserConfig
25055 };
25056 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
25057 return context;
25058 }
25059 function GlobalStylesProvider({
25060 children
25061 }) {
25062 const context = useGlobalStylesContext();
25063 if (!context.isReady) {
25064 return null;
25065 }
25066 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(global_styles_provider_GlobalStylesContext.Provider, {
25067 value: context,
25068 children: children
25069 });
25070 }
25071
25072 ;// ./packages/editor/build-module/components/provider/use-block-editor-settings.js
25073 /* wp:polyfill */
25074 /**
25075 * WordPress dependencies
25076 */
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086 /**
25087 * Internal dependencies
25088 */
25089
25090
25091
25092
25093
25094
25095 const use_block_editor_settings_EMPTY_OBJECT = {};
25096 function __experimentalReusableBlocksSelect(select) {
25097 const {
25098 RECEIVE_INTERMEDIATE_RESULTS
25099 } = unlock(external_wp_coreData_namespaceObject.privateApis);
25100 const {
25101 getEntityRecords
25102 } = select(external_wp_coreData_namespaceObject.store);
25103 return getEntityRecords('postType', 'wp_block', {
25104 per_page: -1,
25105 [RECEIVE_INTERMEDIATE_RESULTS]: true
25106 });
25107 }
25108 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', 'alignWide', 'blockInspectorTabs', 'maxUploadFileSize', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'canUpdateBlockBindings', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'onNavigateToEntityRecord', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isPreviewMode', 'isRTL', 'locale', 'maxWidth', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme'];
25109 const {
25110 globalStylesDataKey,
25111 globalStylesLinksDataKey,
25112 selectBlockPatternsKey,
25113 reusableBlocksSelectKey,
25114 sectionRootClientIdKey
25115 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
25116
25117 /**
25118 * React hook used to compute the block editor settings to use for the post editor.
25119 *
25120 * @param {Object} settings EditorProvider settings prop.
25121 * @param {string} postType Editor root level post type.
25122 * @param {string} postId Editor root level post ID.
25123 * @param {string} renderingMode Editor rendering mode.
25124 *
25125 * @return {Object} Block Editor Settings.
25126 */
25127 function useBlockEditorSettings(settings, postType, postId, renderingMode) {
25128 var _mergedGlobalStyles$s, _mergedGlobalStyles$_, _settings$__experimen, _settings$__experimen2;
25129 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
25130 const {
25131 allowRightClickOverrides,
25132 blockTypes,
25133 focusMode,
25134 hasFixedToolbar,
25135 isDistractionFree,
25136 keepCaretInsideBlock,
25137 hasUploadPermissions,
25138 hiddenBlockTypes,
25139 canUseUnfilteredHTML,
25140 userCanCreatePages,
25141 pageOnFront,
25142 pageForPosts,
25143 userPatternCategories,
25144 restBlockPatternCategories,
25145 sectionRootClientId
25146 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25147 var _canUser;
25148 const {
25149 canUser,
25150 getRawEntityRecord,
25151 getEntityRecord,
25152 getUserPatternCategories,
25153 getBlockPatternCategories
25154 } = select(external_wp_coreData_namespaceObject.store);
25155 const {
25156 get
25157 } = select(external_wp_preferences_namespaceObject.store);
25158 const {
25159 getBlockTypes
25160 } = select(external_wp_blocks_namespaceObject.store);
25161 const {
25162 getBlocksByName,
25163 getBlockAttributes
25164 } = select(external_wp_blockEditor_namespaceObject.store);
25165 const siteSettings = canUser('read', {
25166 kind: 'root',
25167 name: 'site'
25168 }) ? getEntityRecord('root', 'site') : undefined;
25169 function getSectionRootBlock() {
25170 var _getBlocksByName$find;
25171 if (renderingMode === 'template-locked') {
25172 var _getBlocksByName$;
25173 return (_getBlocksByName$ = getBlocksByName('core/post-content')?.[0]) !== null && _getBlocksByName$ !== void 0 ? _getBlocksByName$ : '';
25174 }
25175 return (_getBlocksByName$find = getBlocksByName('core/group').find(clientId => getBlockAttributes(clientId)?.tagName === 'main')) !== null && _getBlocksByName$find !== void 0 ? _getBlocksByName$find : '';
25176 }
25177 return {
25178 allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
25179 blockTypes: getBlockTypes(),
25180 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
25181 focusMode: get('core', 'focusMode'),
25182 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
25183 hiddenBlockTypes: get('core', 'hiddenBlockTypes'),
25184 isDistractionFree: get('core', 'distractionFree'),
25185 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
25186 hasUploadPermissions: (_canUser = canUser('create', {
25187 kind: 'root',
25188 name: 'media'
25189 })) !== null && _canUser !== void 0 ? _canUser : true,
25190 userCanCreatePages: canUser('create', {
25191 kind: 'postType',
25192 name: 'page'
25193 }),
25194 pageOnFront: siteSettings?.page_on_front,
25195 pageForPosts: siteSettings?.page_for_posts,
25196 userPatternCategories: getUserPatternCategories(),
25197 restBlockPatternCategories: getBlockPatternCategories(),
25198 sectionRootClientId: getSectionRootBlock()
25199 };
25200 }, [postType, postId, isLargeViewport, renderingMode]);
25201 const {
25202 merged: mergedGlobalStyles
25203 } = useGlobalStylesContext();
25204 const globalStylesData = (_mergedGlobalStyles$s = mergedGlobalStyles.styles) !== null && _mergedGlobalStyles$s !== void 0 ? _mergedGlobalStyles$s : use_block_editor_settings_EMPTY_OBJECT;
25205 const globalStylesLinksData = (_mergedGlobalStyles$_ = mergedGlobalStyles._links) !== null && _mergedGlobalStyles$_ !== void 0 ? _mergedGlobalStyles$_ : use_block_editor_settings_EMPTY_OBJECT;
25206 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
25207 // WP 6.0
25208 settings.__experimentalBlockPatterns; // WP 5.9
25209 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 :
25210 // WP 6.0
25211 settings.__experimentalBlockPatternCategories; // WP 5.9
25212
25213 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({
25214 postTypes
25215 }) => {
25216 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType);
25217 }), [settingsBlockPatterns, postType]);
25218 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
25219 const {
25220 undo,
25221 setIsInserterOpened
25222 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
25223 const {
25224 saveEntityRecord
25225 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25226
25227 /**
25228 * Creates a Post entity.
25229 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
25230 *
25231 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
25232 * @return {Object} the post type object that was created.
25233 */
25234 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => {
25235 if (!userCanCreatePages) {
25236 return Promise.reject({
25237 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
25238 });
25239 }
25240 return saveEntityRecord('postType', 'page', options);
25241 }, [saveEntityRecord, userCanCreatePages]);
25242 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
25243 // Omit hidden block types if exists and non-empty.
25244 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
25245 // Defer to passed setting for `allowedBlockTypes` if provided as
25246 // anything other than `true` (where `true` is equivalent to allow
25247 // all block types).
25248 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({
25249 name
25250 }) => name) : settings.allowedBlockTypes || [];
25251 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
25252 }
25253 return settings.allowedBlockTypes;
25254 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
25255 const forceDisableFocusMode = settings.focusMode === false;
25256 return (0,external_wp_element_namespaceObject.useMemo)(() => {
25257 const blockEditorSettings = {
25258 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
25259 [globalStylesDataKey]: globalStylesData,
25260 [globalStylesLinksDataKey]: globalStylesLinksData,
25261 allowedBlockTypes,
25262 allowRightClickOverrides,
25263 focusMode: focusMode && !forceDisableFocusMode,
25264 hasFixedToolbar,
25265 isDistractionFree,
25266 keepCaretInsideBlock,
25267 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
25268 mediaSideload: hasUploadPermissions ? media_sideload : undefined,
25269 __experimentalBlockPatterns: blockPatterns,
25270 [selectBlockPatternsKey]: select => {
25271 const {
25272 hasFinishedResolution,
25273 getBlockPatternsForPostType
25274 } = unlock(select(external_wp_coreData_namespaceObject.store));
25275 const patterns = getBlockPatternsForPostType(postType);
25276 return hasFinishedResolution('getBlockPatterns') ? patterns : undefined;
25277 },
25278 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
25279 __experimentalBlockPatternCategories: blockPatternCategories,
25280 __experimentalUserPatternCategories: userPatternCategories,
25281 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
25282 inserterMediaCategories: media_categories,
25283 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
25284 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
25285 // This might be better as a generic "canUser" selector.
25286 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
25287 //Todo: this is only needed for native and should probably be removed.
25288 __experimentalUndo: undo,
25289 // Check whether we want all site editor frames to have outlines
25290 // including the navigation / pattern / parts editors.
25291 outlineMode: !isDistractionFree && postType === 'wp_template',
25292 // Check these two properties: they were not present in the site editor.
25293 __experimentalCreatePageEntity: createPageEntity,
25294 __experimentalUserCanCreatePages: userCanCreatePages,
25295 pageOnFront,
25296 pageForPosts,
25297 __experimentalPreferPatternsOnRoot: postType === 'wp_template',
25298 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
25299 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
25300 __experimentalSetIsInserterOpened: setIsInserterOpened,
25301 [sectionRootClientIdKey]: sectionRootClientId,
25302 editorTool: renderingMode === 'post-only' && postType !== 'wp_template' ? 'edit' : undefined
25303 };
25304 return blockEditorSettings;
25305 }, [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened, sectionRootClientId, globalStylesData, globalStylesLinksData, renderingMode]);
25306 }
25307 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
25308
25309 ;// ./packages/editor/build-module/components/provider/use-post-content-blocks.js
25310 /**
25311 * WordPress dependencies
25312 */
25313
25314
25315
25316
25317 /**
25318 * Internal dependencies
25319 */
25320
25321
25322 const POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
25323 function usePostContentBlocks() {
25324 const contentOnlyBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => [...(0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', POST_CONTENT_BLOCK_TYPES)], []);
25325
25326 // Note that there are two separate subscriptions because the result for each
25327 // returns a new array.
25328 const contentOnlyIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
25329 const {
25330 getPostBlocksByName
25331 } = unlock(select(store_store));
25332 return getPostBlocksByName(contentOnlyBlockTypes);
25333 }, [contentOnlyBlockTypes]);
25334 return contentOnlyIds;
25335 }
25336
25337 ;// ./packages/editor/build-module/components/provider/disable-non-page-content-blocks.js
25338 /* wp:polyfill */
25339 /**
25340 * WordPress dependencies
25341 */
25342
25343
25344
25345
25346 /**
25347 * Internal dependencies
25348 */
25349
25350
25351 /**
25352 * Component that when rendered, makes it so that the site editor allows only
25353 * page content to be edited.
25354 */
25355 function DisableNonPageContentBlocks() {
25356 const contentOnlyIds = usePostContentBlocks();
25357 const {
25358 templateParts,
25359 isNavigationMode
25360 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25361 const {
25362 getBlocksByName,
25363 isNavigationMode: _isNavigationMode
25364 } = select(external_wp_blockEditor_namespaceObject.store);
25365 return {
25366 templateParts: getBlocksByName('core/template-part'),
25367 isNavigationMode: _isNavigationMode()
25368 };
25369 }, []);
25370 const disabledIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
25371 const {
25372 getBlockOrder
25373 } = select(external_wp_blockEditor_namespaceObject.store);
25374 return templateParts.flatMap(clientId => getBlockOrder(clientId));
25375 }, [templateParts]);
25376 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
25377
25378 // The code here is split into multiple `useEffects` calls.
25379 // This is done to avoid setting/unsetting block editing modes multiple times unnecessarily.
25380 //
25381 // For example, the block editing mode of the root block (clientId: '') only
25382 // needs to be set once, not when `contentOnlyIds` or `disabledIds` change.
25383 //
25384 // It's also unlikely that these different types of blocks are being inserted
25385 // or removed at the same time, so using different effects reflects that.
25386 (0,external_wp_element_namespaceObject.useEffect)(() => {
25387 const {
25388 setBlockEditingMode,
25389 unsetBlockEditingMode
25390 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
25391 setBlockEditingMode('', 'disabled');
25392 return () => {
25393 unsetBlockEditingMode('');
25394 };
25395 }, [registry]);
25396 (0,external_wp_element_namespaceObject.useEffect)(() => {
25397 const {
25398 setBlockEditingMode,
25399 unsetBlockEditingMode
25400 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
25401 registry.batch(() => {
25402 for (const clientId of contentOnlyIds) {
25403 setBlockEditingMode(clientId, 'contentOnly');
25404 }
25405 });
25406 return () => {
25407 registry.batch(() => {
25408 for (const clientId of contentOnlyIds) {
25409 unsetBlockEditingMode(clientId);
25410 }
25411 });
25412 };
25413 }, [contentOnlyIds, registry]);
25414 (0,external_wp_element_namespaceObject.useEffect)(() => {
25415 const {
25416 setBlockEditingMode,
25417 unsetBlockEditingMode
25418 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
25419 registry.batch(() => {
25420 if (!isNavigationMode) {
25421 for (const clientId of templateParts) {
25422 setBlockEditingMode(clientId, 'contentOnly');
25423 }
25424 }
25425 });
25426 return () => {
25427 registry.batch(() => {
25428 if (!isNavigationMode) {
25429 for (const clientId of templateParts) {
25430 unsetBlockEditingMode(clientId);
25431 }
25432 }
25433 });
25434 };
25435 }, [templateParts, isNavigationMode, registry]);
25436 (0,external_wp_element_namespaceObject.useEffect)(() => {
25437 const {
25438 setBlockEditingMode,
25439 unsetBlockEditingMode
25440 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
25441 registry.batch(() => {
25442 for (const clientId of disabledIds) {
25443 setBlockEditingMode(clientId, 'disabled');
25444 }
25445 });
25446 return () => {
25447 registry.batch(() => {
25448 for (const clientId of disabledIds) {
25449 unsetBlockEditingMode(clientId);
25450 }
25451 });
25452 };
25453 }, [disabledIds, registry]);
25454 return null;
25455 }
25456
25457 ;// ./packages/editor/build-module/components/provider/navigation-block-editing-mode.js
25458 /**
25459 * WordPress dependencies
25460 */
25461
25462
25463
25464
25465 /**
25466 * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
25467 *
25468 * Set block editing mode to contentOnly when entering Navigation focus mode.
25469 * this ensures that non-content controls on the block will be hidden and thus
25470 * the user can focus on editing the Navigation Menu content only.
25471 */
25472
25473 function NavigationBlockEditingMode() {
25474 // In the navigation block editor,
25475 // the navigation block is the only root block.
25476 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []);
25477 const {
25478 setBlockEditingMode,
25479 unsetBlockEditingMode
25480 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
25481 (0,external_wp_element_namespaceObject.useEffect)(() => {
25482 if (!blockClientId) {
25483 return;
25484 }
25485 setBlockEditingMode(blockClientId, 'contentOnly');
25486 return () => {
25487 unsetBlockEditingMode(blockClientId);
25488 };
25489 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
25490 }
25491
25492 ;// ./packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js
25493 /**
25494 * WordPress dependencies
25495 */
25496
25497
25498
25499 // These post types are "structural" block lists.
25500 // We should be allowed to use
25501 // the post content and template parts blocks within them.
25502 const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template', 'wp_template_part'];
25503
25504 /**
25505 * In some specific contexts,
25506 * the template part and post content blocks need to be hidden.
25507 *
25508 * @param {string} postType Post Type
25509 * @param {string} mode Rendering mode
25510 */
25511 function useHideBlocksFromInserter(postType, mode) {
25512 (0,external_wp_element_namespaceObject.useEffect)(() => {
25513 /*
25514 * Prevent adding template part in the editor.
25515 */
25516 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
25517 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
25518 return false;
25519 }
25520 return canInsert;
25521 });
25522
25523 /*
25524 * Prevent adding post content block (except in query block) in the editor.
25525 */
25526 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
25527 getBlockParentsByBlockName
25528 }) => {
25529 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/post-content') {
25530 return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
25531 }
25532 return canInsert;
25533 });
25534 return () => {
25535 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
25536 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
25537 };
25538 }, [postType, mode]);
25539 }
25540
25541 ;// ./packages/icons/build-module/library/keyboard.js
25542 /**
25543 * WordPress dependencies
25544 */
25545
25546
25547 const keyboard = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
25548 xmlns: "http://www.w3.org/2000/svg",
25549 viewBox: "0 0 24 24",
25550 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25551 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"
25552 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25553 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"
25554 })]
25555 });
25556 /* harmony default export */ const library_keyboard = (keyboard);
25557
25558 ;// ./packages/icons/build-module/library/list-view.js
25559 /**
25560 * WordPress dependencies
25561 */
25562
25563
25564 const listView = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25565 viewBox: "0 0 24 24",
25566 xmlns: "http://www.w3.org/2000/svg",
25567 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25568 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"
25569 })
25570 });
25571 /* harmony default export */ const list_view = (listView);
25572
25573 ;// ./packages/icons/build-module/library/code.js
25574 /**
25575 * WordPress dependencies
25576 */
25577
25578
25579 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25580 viewBox: "0 0 24 24",
25581 xmlns: "http://www.w3.org/2000/svg",
25582 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25583 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"
25584 })
25585 });
25586 /* harmony default export */ const library_code = (code);
25587
25588 ;// ./packages/icons/build-module/library/drawer-left.js
25589 /**
25590 * WordPress dependencies
25591 */
25592
25593
25594 const drawerLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25595 width: "24",
25596 height: "24",
25597 xmlns: "http://www.w3.org/2000/svg",
25598 viewBox: "0 0 24 24",
25599 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25600 fillRule: "evenodd",
25601 clipRule: "evenodd",
25602 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"
25603 })
25604 });
25605 /* harmony default export */ const drawer_left = (drawerLeft);
25606
25607 ;// ./packages/icons/build-module/library/drawer-right.js
25608 /**
25609 * WordPress dependencies
25610 */
25611
25612
25613 const drawerRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25614 width: "24",
25615 height: "24",
25616 xmlns: "http://www.w3.org/2000/svg",
25617 viewBox: "0 0 24 24",
25618 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25619 fillRule: "evenodd",
25620 clipRule: "evenodd",
25621 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"
25622 })
25623 });
25624 /* harmony default export */ const drawer_right = (drawerRight);
25625
25626 ;// ./packages/icons/build-module/library/block-default.js
25627 /**
25628 * WordPress dependencies
25629 */
25630
25631
25632 const blockDefault = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25633 xmlns: "http://www.w3.org/2000/svg",
25634 viewBox: "0 0 24 24",
25635 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25636 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"
25637 })
25638 });
25639 /* harmony default export */ const block_default = (blockDefault);
25640
25641 ;// ./packages/icons/build-module/library/format-list-bullets.js
25642 /**
25643 * WordPress dependencies
25644 */
25645
25646
25647 const formatListBullets = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25648 xmlns: "http://www.w3.org/2000/svg",
25649 viewBox: "0 0 24 24",
25650 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25651 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"
25652 })
25653 });
25654 /* harmony default export */ const format_list_bullets = (formatListBullets);
25655
25656 ;// ./packages/icons/build-module/library/pencil.js
25657 /**
25658 * WordPress dependencies
25659 */
25660
25661
25662 const pencil = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25663 xmlns: "http://www.w3.org/2000/svg",
25664 viewBox: "0 0 24 24",
25665 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25666 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"
25667 })
25668 });
25669 /* harmony default export */ const library_pencil = (pencil);
25670
25671 ;// ./packages/icons/build-module/library/edit.js
25672 /**
25673 * Internal dependencies
25674 */
25675
25676
25677 /* harmony default export */ const library_edit = (library_pencil);
25678
25679 ;// ./packages/icons/build-module/library/rotate-right.js
25680 /**
25681 * WordPress dependencies
25682 */
25683
25684
25685 const rotateRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25686 xmlns: "http://www.w3.org/2000/svg",
25687 viewBox: "0 0 24 24",
25688 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25689 d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z"
25690 })
25691 });
25692 /* harmony default export */ const rotate_right = (rotateRight);
25693
25694 ;// ./packages/icons/build-module/library/rotate-left.js
25695 /**
25696 * WordPress dependencies
25697 */
25698
25699
25700 const rotateLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25701 xmlns: "http://www.w3.org/2000/svg",
25702 viewBox: "0 0 24 24",
25703 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25704 d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z"
25705 })
25706 });
25707 /* harmony default export */ const rotate_left = (rotateLeft);
25708
25709 ;// ./packages/editor/build-module/components/pattern-rename-modal/index.js
25710 /**
25711 * WordPress dependencies
25712 */
25713
25714
25715
25716
25717
25718 /**
25719 * Internal dependencies
25720 */
25721
25722
25723
25724
25725 const {
25726 RenamePatternModal
25727 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25728 const modalName = 'editor/pattern-rename';
25729 function PatternRenameModal() {
25730 const {
25731 record,
25732 postType
25733 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25734 const {
25735 getCurrentPostType,
25736 getCurrentPostId
25737 } = select(store_store);
25738 const {
25739 getEditedEntityRecord
25740 } = select(external_wp_coreData_namespaceObject.store);
25741 const _postType = getCurrentPostType();
25742 return {
25743 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
25744 postType: _postType
25745 };
25746 }, []);
25747 const {
25748 closeModal
25749 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25750 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(modalName));
25751 if (!isActive || postType !== PATTERN_POST_TYPE) {
25752 return null;
25753 }
25754 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenamePatternModal, {
25755 onClose: closeModal,
25756 pattern: record
25757 });
25758 }
25759
25760 ;// ./packages/editor/build-module/components/pattern-duplicate-modal/index.js
25761 /**
25762 * WordPress dependencies
25763 */
25764
25765
25766
25767
25768
25769 /**
25770 * Internal dependencies
25771 */
25772
25773
25774
25775
25776 const {
25777 DuplicatePatternModal
25778 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25779 const pattern_duplicate_modal_modalName = 'editor/pattern-duplicate';
25780 function PatternDuplicateModal() {
25781 const {
25782 record,
25783 postType
25784 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25785 const {
25786 getCurrentPostType,
25787 getCurrentPostId
25788 } = select(store_store);
25789 const {
25790 getEditedEntityRecord
25791 } = select(external_wp_coreData_namespaceObject.store);
25792 const _postType = getCurrentPostType();
25793 return {
25794 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
25795 postType: _postType
25796 };
25797 }, []);
25798 const {
25799 closeModal
25800 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25801 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(pattern_duplicate_modal_modalName));
25802 if (!isActive || postType !== PATTERN_POST_TYPE) {
25803 return null;
25804 }
25805 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DuplicatePatternModal, {
25806 onClose: closeModal,
25807 onSuccess: () => closeModal(),
25808 pattern: record
25809 });
25810 }
25811
25812 ;// ./packages/editor/build-module/components/commands/index.js
25813 /**
25814 * WordPress dependencies
25815 */
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828 /**
25829 * Internal dependencies
25830 */
25831
25832
25833
25834
25835
25836
25837 const getEditorCommandLoader = () => function useEditorCommandLoader() {
25838 const {
25839 editorMode,
25840 isListViewOpen,
25841 showBlockBreadcrumbs,
25842 isDistractionFree,
25843 isFocusMode,
25844 isPreviewMode,
25845 isViewable,
25846 isCodeEditingEnabled,
25847 isRichEditingEnabled,
25848 isPublishSidebarEnabled
25849 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25850 var _get, _getPostType$viewable;
25851 const {
25852 get
25853 } = select(external_wp_preferences_namespaceObject.store);
25854 const {
25855 isListViewOpened,
25856 getCurrentPostType,
25857 getEditorSettings
25858 } = select(store_store);
25859 const {
25860 getSettings
25861 } = select(external_wp_blockEditor_namespaceObject.store);
25862 const {
25863 getPostType
25864 } = select(external_wp_coreData_namespaceObject.store);
25865 return {
25866 editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
25867 isListViewOpen: isListViewOpened(),
25868 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
25869 isDistractionFree: get('core', 'distractionFree'),
25870 isFocusMode: get('core', 'focusMode'),
25871 isPreviewMode: getSettings().isPreviewMode,
25872 isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
25873 isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
25874 isRichEditingEnabled: getEditorSettings().richEditingEnabled,
25875 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled()
25876 };
25877 }, []);
25878 const {
25879 getActiveComplementaryArea
25880 } = (0,external_wp_data_namespaceObject.useSelect)(store);
25881 const {
25882 toggle
25883 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
25884 const {
25885 createInfoNotice
25886 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25887 const {
25888 __unstableSaveForPreview,
25889 setIsListViewOpened,
25890 switchEditorMode,
25891 toggleDistractionFree,
25892 toggleSpotlightMode,
25893 toggleTopToolbar
25894 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
25895 const {
25896 openModal,
25897 enableComplementaryArea,
25898 disableComplementaryArea
25899 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25900 const {
25901 getCurrentPostId
25902 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
25903 const {
25904 isBlockBasedTheme,
25905 canCreateTemplate
25906 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25907 return {
25908 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
25909 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
25910 kind: 'postType',
25911 name: 'wp_template'
25912 })
25913 };
25914 }, []);
25915 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
25916 if (isPreviewMode) {
25917 return {
25918 commands: [],
25919 isLoading: false
25920 };
25921 }
25922 const commands = [];
25923 commands.push({
25924 name: 'core/open-shortcut-help',
25925 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
25926 icon: library_keyboard,
25927 callback: ({
25928 close
25929 }) => {
25930 close();
25931 openModal('editor/keyboard-shortcut-help');
25932 }
25933 });
25934 commands.push({
25935 name: 'core/toggle-distraction-free',
25936 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction free'),
25937 callback: ({
25938 close
25939 }) => {
25940 toggleDistractionFree();
25941 close();
25942 }
25943 });
25944 commands.push({
25945 name: 'core/open-preferences',
25946 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'),
25947 callback: ({
25948 close
25949 }) => {
25950 close();
25951 openModal('editor/preferences');
25952 }
25953 });
25954 commands.push({
25955 name: 'core/toggle-spotlight-mode',
25956 label: isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Exit Spotlight mode') : (0,external_wp_i18n_namespaceObject.__)('Enter Spotlight mode'),
25957 callback: ({
25958 close
25959 }) => {
25960 toggleSpotlightMode();
25961 close();
25962 }
25963 });
25964 commands.push({
25965 name: 'core/toggle-list-view',
25966 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'),
25967 icon: list_view,
25968 callback: ({
25969 close
25970 }) => {
25971 setIsListViewOpened(!isListViewOpen);
25972 close();
25973 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), {
25974 id: 'core/editor/toggle-list-view/notice',
25975 type: 'snackbar'
25976 });
25977 }
25978 });
25979 commands.push({
25980 name: 'core/toggle-top-toolbar',
25981 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
25982 callback: ({
25983 close
25984 }) => {
25985 toggleTopToolbar();
25986 close();
25987 }
25988 });
25989 if (allowSwitchEditorMode) {
25990 commands.push({
25991 name: 'core/toggle-code-editor',
25992 label: editorMode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Open code editor') : (0,external_wp_i18n_namespaceObject.__)('Exit code editor'),
25993 icon: library_code,
25994 callback: ({
25995 close
25996 }) => {
25997 switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
25998 close();
25999 }
26000 });
26001 }
26002 commands.push({
26003 name: 'core/toggle-breadcrumbs',
26004 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'),
26005 callback: ({
26006 close
26007 }) => {
26008 toggle('core', 'showBlockBreadcrumbs');
26009 close();
26010 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), {
26011 id: 'core/editor/toggle-breadcrumbs/notice',
26012 type: 'snackbar'
26013 });
26014 }
26015 });
26016 commands.push({
26017 name: 'core/open-settings-sidebar',
26018 label: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings panel.'),
26019 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
26020 callback: ({
26021 close
26022 }) => {
26023 const activeSidebar = getActiveComplementaryArea('core');
26024 close();
26025 if (activeSidebar === 'edit-post/document') {
26026 disableComplementaryArea('core');
26027 } else {
26028 enableComplementaryArea('core', 'edit-post/document');
26029 }
26030 }
26031 });
26032 commands.push({
26033 name: 'core/open-block-inspector',
26034 label: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Block settings panel'),
26035 icon: block_default,
26036 callback: ({
26037 close
26038 }) => {
26039 const activeSidebar = getActiveComplementaryArea('core');
26040 close();
26041 if (activeSidebar === 'edit-post/block') {
26042 disableComplementaryArea('core');
26043 } else {
26044 enableComplementaryArea('core', 'edit-post/block');
26045 }
26046 }
26047 });
26048 commands.push({
26049 name: 'core/toggle-publish-sidebar',
26050 label: isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Disable pre-publish checks') : (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks'),
26051 icon: format_list_bullets,
26052 callback: ({
26053 close
26054 }) => {
26055 close();
26056 toggle('core', 'isPublishSidebarEnabled');
26057 createInfoNotice(isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks disabled.') : (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks enabled.'), {
26058 id: 'core/editor/publish-sidebar/notice',
26059 type: 'snackbar'
26060 });
26061 }
26062 });
26063 if (isViewable) {
26064 commands.push({
26065 name: 'core/preview-link',
26066 label: (0,external_wp_i18n_namespaceObject.__)('Preview in a new tab'),
26067 icon: library_external,
26068 callback: async ({
26069 close
26070 }) => {
26071 close();
26072 const postId = getCurrentPostId();
26073 const link = await __unstableSaveForPreview();
26074 window.open(link, `wp-preview-${postId}`);
26075 }
26076 });
26077 }
26078 if (canCreateTemplate && isBlockBasedTheme) {
26079 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
26080 if (!isSiteEditor) {
26081 commands.push({
26082 name: 'core/go-to-site-editor',
26083 label: (0,external_wp_i18n_namespaceObject.__)('Open Site Editor'),
26084 callback: ({
26085 close
26086 }) => {
26087 close();
26088 document.location = 'site-editor.php';
26089 }
26090 });
26091 }
26092 }
26093 return {
26094 commands,
26095 isLoading: false
26096 };
26097 };
26098 const getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() {
26099 const {
26100 postType
26101 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26102 const {
26103 getCurrentPostType
26104 } = select(store_store);
26105 return {
26106 postType: getCurrentPostType()
26107 };
26108 }, []);
26109 const {
26110 openModal
26111 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26112 const commands = [];
26113 if (postType === PATTERN_POST_TYPE) {
26114 commands.push({
26115 name: 'core/rename-pattern',
26116 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'),
26117 icon: library_edit,
26118 callback: ({
26119 close
26120 }) => {
26121 openModal(modalName);
26122 close();
26123 }
26124 });
26125 commands.push({
26126 name: 'core/duplicate-pattern',
26127 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'),
26128 icon: library_symbol,
26129 callback: ({
26130 close
26131 }) => {
26132 openModal(pattern_duplicate_modal_modalName);
26133 close();
26134 }
26135 });
26136 }
26137 return {
26138 isLoading: false,
26139 commands
26140 };
26141 };
26142 const getPageContentFocusCommands = () => function usePageContentFocusCommands() {
26143 const {
26144 onNavigateToEntityRecord,
26145 goBack,
26146 templateId,
26147 isPreviewMode
26148 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26149 const {
26150 getRenderingMode,
26151 getEditorSettings: _getEditorSettings,
26152 getCurrentTemplateId
26153 } = unlock(select(store_store));
26154 const editorSettings = _getEditorSettings();
26155 return {
26156 isTemplateHidden: getRenderingMode() === 'post-only',
26157 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
26158 getEditorSettings: _getEditorSettings,
26159 goBack: editorSettings.onNavigateToPreviousEntityRecord,
26160 templateId: getCurrentTemplateId(),
26161 isPreviewMode: editorSettings.isPreviewMode
26162 };
26163 }, []);
26164 const {
26165 editedRecord: template,
26166 hasResolved
26167 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', templateId);
26168 if (isPreviewMode) {
26169 return {
26170 isLoading: false,
26171 commands: []
26172 };
26173 }
26174 const commands = [];
26175 if (templateId && hasResolved) {
26176 commands.push({
26177 name: 'core/switch-to-template-focus',
26178 label: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: template title */
26179 (0,external_wp_i18n_namespaceObject.__)('Edit template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)),
26180 icon: library_layout,
26181 callback: ({
26182 close
26183 }) => {
26184 onNavigateToEntityRecord({
26185 postId: templateId,
26186 postType: 'wp_template'
26187 });
26188 close();
26189 }
26190 });
26191 }
26192 if (!!goBack) {
26193 commands.push({
26194 name: 'core/switch-to-previous-entity',
26195 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
26196 icon: library_page,
26197 callback: ({
26198 close
26199 }) => {
26200 goBack();
26201 close();
26202 }
26203 });
26204 }
26205 return {
26206 isLoading: false,
26207 commands
26208 };
26209 };
26210 const getManipulateDocumentCommands = () => function useManipulateDocumentCommands() {
26211 const {
26212 postType,
26213 postId
26214 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26215 const {
26216 getCurrentPostId,
26217 getCurrentPostType
26218 } = select(store_store);
26219 return {
26220 postType: getCurrentPostType(),
26221 postId: getCurrentPostId()
26222 };
26223 }, []);
26224 const {
26225 editedRecord: template,
26226 hasResolved
26227 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', postType, postId);
26228 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
26229 const {
26230 revertTemplate
26231 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
26232 if (!hasResolved || ![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
26233 return {
26234 isLoading: true,
26235 commands: []
26236 };
26237 }
26238 const commands = [];
26239 if (isTemplateRevertable(template)) {
26240 const label = template.type === TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: template title */
26241 (0,external_wp_i18n_namespaceObject.__)('Reset template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: template part title */
26242 (0,external_wp_i18n_namespaceObject.__)('Reset template part: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title));
26243 commands.push({
26244 name: 'core/reset-template',
26245 label,
26246 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left,
26247 callback: ({
26248 close
26249 }) => {
26250 revertTemplate(template);
26251 close();
26252 }
26253 });
26254 }
26255 return {
26256 isLoading: !hasResolved,
26257 commands
26258 };
26259 };
26260 function useCommands() {
26261 (0,external_wp_commands_namespaceObject.useCommandLoader)({
26262 name: 'core/editor/edit-ui',
26263 hook: getEditorCommandLoader()
26264 });
26265 (0,external_wp_commands_namespaceObject.useCommandLoader)({
26266 name: 'core/editor/contextual-commands',
26267 hook: getEditedEntityContextualCommands(),
26268 context: 'entity-edit'
26269 });
26270 (0,external_wp_commands_namespaceObject.useCommandLoader)({
26271 name: 'core/editor/page-content-focus',
26272 hook: getPageContentFocusCommands(),
26273 context: 'entity-edit'
26274 });
26275 (0,external_wp_commands_namespaceObject.useCommandLoader)({
26276 name: 'core/edit-site/manipulate-document',
26277 hook: getManipulateDocumentCommands()
26278 });
26279 }
26280
26281 ;// ./packages/editor/build-module/components/block-removal-warnings/index.js
26282 /* wp:polyfill */
26283 /**
26284 * WordPress dependencies
26285 */
26286
26287
26288
26289
26290
26291
26292 /**
26293 * Internal dependencies
26294 */
26295
26296
26297
26298 const {
26299 BlockRemovalWarningModal
26300 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
26301
26302 // Prevent accidental removal of certain blocks, asking the user for confirmation first.
26303 const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
26304 const BLOCK_REMOVAL_RULES = [{
26305 // Template blocks.
26306 // The warning is only shown when a user manipulates templates or template parts.
26307 postTypes: ['wp_template', 'wp_template_part'],
26308 callback(removedBlocks) {
26309 const removedTemplateBlocks = removedBlocks.filter(({
26310 name
26311 }) => TEMPLATE_BLOCKS.includes(name));
26312 if (removedTemplateBlocks.length) {
26313 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);
26314 }
26315 }
26316 }, {
26317 // Pattern overrides.
26318 // The warning is only shown when the user edits a pattern.
26319 postTypes: ['wp_block'],
26320 callback(removedBlocks) {
26321 const removedBlocksWithOverrides = removedBlocks.filter(({
26322 attributes
26323 }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
26324 if (removedBlocksWithOverrides.length) {
26325 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);
26326 }
26327 }
26328 }];
26329 function BlockRemovalWarnings() {
26330 const currentPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
26331 const removalRulesForPostType = (0,external_wp_element_namespaceObject.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
26332
26333 // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
26334 // across react native and web. However, `BlockRemovalWarningModal` is web only.
26335 // Check it exists before trying to render it.
26336 if (!BlockRemovalWarningModal) {
26337 return null;
26338 }
26339 if (!removalRulesForPostType) {
26340 return null;
26341 }
26342 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarningModal, {
26343 rules: removalRulesForPostType
26344 });
26345 }
26346
26347 ;// ./packages/editor/build-module/components/start-page-options/index.js
26348 /**
26349 * WordPress dependencies
26350 */
26351
26352
26353
26354
26355
26356 /**
26357 * Internal dependencies
26358 */
26359
26360 function StartPageOptions() {
26361 const {
26362 postId,
26363 shouldEnable
26364 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26365 const {
26366 isEditedPostDirty,
26367 isEditedPostEmpty,
26368 getCurrentPostId,
26369 getCurrentPostType
26370 } = select(store_store);
26371 const preferencesModalActive = select(store).isModalActive('editor/preferences');
26372 const choosePatternModalEnabled = select(external_wp_preferences_namespaceObject.store).get('core', 'enableChoosePatternModal');
26373 return {
26374 postId: getCurrentPostId(),
26375 shouldEnable: choosePatternModalEnabled && !preferencesModalActive && !isEditedPostDirty() && isEditedPostEmpty() && 'page' === getCurrentPostType()
26376 };
26377 }, []);
26378 const {
26379 setIsInserterOpened
26380 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
26381 (0,external_wp_element_namespaceObject.useEffect)(() => {
26382 if (shouldEnable) {
26383 setIsInserterOpened({
26384 tab: 'patterns',
26385 category: 'core/starter-content'
26386 });
26387 }
26388 }, [postId, shouldEnable, setIsInserterOpened]);
26389 return null;
26390 }
26391
26392 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js
26393 /**
26394 * WordPress dependencies
26395 */
26396
26397 const textFormattingShortcuts = [{
26398 keyCombination: {
26399 modifier: 'primary',
26400 character: 'b'
26401 },
26402 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
26403 }, {
26404 keyCombination: {
26405 modifier: 'primary',
26406 character: 'i'
26407 },
26408 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
26409 }, {
26410 keyCombination: {
26411 modifier: 'primary',
26412 character: 'k'
26413 },
26414 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
26415 }, {
26416 keyCombination: {
26417 modifier: 'primaryShift',
26418 character: 'k'
26419 },
26420 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
26421 }, {
26422 keyCombination: {
26423 character: '[['
26424 },
26425 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.')
26426 }, {
26427 keyCombination: {
26428 modifier: 'primary',
26429 character: 'u'
26430 },
26431 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
26432 }, {
26433 keyCombination: {
26434 modifier: 'access',
26435 character: 'd'
26436 },
26437 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
26438 }, {
26439 keyCombination: {
26440 modifier: 'access',
26441 character: 'x'
26442 },
26443 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
26444 }, {
26445 keyCombination: {
26446 modifier: 'access',
26447 character: '0'
26448 },
26449 aliases: [{
26450 modifier: 'access',
26451 character: '7'
26452 }],
26453 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.')
26454 }, {
26455 keyCombination: {
26456 modifier: 'access',
26457 character: '1-6'
26458 },
26459 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.')
26460 }, {
26461 keyCombination: {
26462 modifier: 'primaryShift',
26463 character: 'SPACE'
26464 },
26465 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.')
26466 }];
26467
26468 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js
26469 /* wp:polyfill */
26470 /**
26471 * WordPress dependencies
26472 */
26473
26474
26475
26476 function KeyCombination({
26477 keyCombination,
26478 forceAriaLabel
26479 }) {
26480 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
26481 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
26482 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
26483 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
26484 "aria-label": forceAriaLabel || ariaLabel,
26485 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
26486 if (character === '+') {
26487 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
26488 children: character
26489 }, index);
26490 }
26491 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
26492 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
26493 children: character
26494 }, index);
26495 })
26496 });
26497 }
26498 function Shortcut({
26499 description,
26500 keyCombination,
26501 aliases = [],
26502 ariaLabel
26503 }) {
26504 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26505 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26506 className: "editor-keyboard-shortcut-help-modal__shortcut-description",
26507 children: description
26508 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26509 className: "editor-keyboard-shortcut-help-modal__shortcut-term",
26510 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
26511 keyCombination: keyCombination,
26512 forceAriaLabel: ariaLabel
26513 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
26514 keyCombination: alias,
26515 forceAriaLabel: ariaLabel
26516 }, index))]
26517 })]
26518 });
26519 }
26520 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut);
26521
26522 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
26523 /**
26524 * WordPress dependencies
26525 */
26526
26527
26528
26529 /**
26530 * Internal dependencies
26531 */
26532
26533
26534 function DynamicShortcut({
26535 name
26536 }) {
26537 const {
26538 keyCombination,
26539 description,
26540 aliases
26541 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26542 const {
26543 getShortcutKeyCombination,
26544 getShortcutDescription,
26545 getShortcutAliases
26546 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
26547 return {
26548 keyCombination: getShortcutKeyCombination(name),
26549 aliases: getShortcutAliases(name),
26550 description: getShortcutDescription(name)
26551 };
26552 }, [name]);
26553 if (!keyCombination) {
26554 return null;
26555 }
26556 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
26557 keyCombination: keyCombination,
26558 description: description,
26559 aliases: aliases
26560 });
26561 }
26562 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut);
26563
26564 ;// ./packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js
26565 /* wp:polyfill */
26566 /**
26567 * External dependencies
26568 */
26569
26570
26571 /**
26572 * WordPress dependencies
26573 */
26574
26575
26576
26577
26578
26579
26580 /**
26581 * Internal dependencies
26582 */
26583
26584
26585
26586
26587 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';
26588 const ShortcutList = ({
26589 shortcuts
26590 }) =>
26591 /*#__PURE__*/
26592 /*
26593 * Disable reason: The `list` ARIA role is redundant but
26594 * Safari+VoiceOver won't announce the list otherwise.
26595 */
26596 /* eslint-disable jsx-a11y/no-redundant-roles */
26597 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
26598 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
26599 role: "list",
26600 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
26601 className: "editor-keyboard-shortcut-help-modal__shortcut",
26602 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, {
26603 name: shortcut
26604 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
26605 ...shortcut
26606 })
26607 }, index))
26608 })
26609 /* eslint-enable jsx-a11y/no-redundant-roles */;
26610 const ShortcutSection = ({
26611 title,
26612 shortcuts,
26613 className
26614 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
26615 className: dist_clsx('editor-keyboard-shortcut-help-modal__section', className),
26616 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
26617 className: "editor-keyboard-shortcut-help-modal__section-title",
26618 children: title
26619 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, {
26620 shortcuts: shortcuts
26621 })]
26622 });
26623 const ShortcutCategorySection = ({
26624 title,
26625 categoryName,
26626 additionalShortcuts = []
26627 }) => {
26628 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
26629 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
26630 }, [categoryName]);
26631 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
26632 title: title,
26633 shortcuts: categoryShortcuts.concat(additionalShortcuts)
26634 });
26635 };
26636 function KeyboardShortcutHelpModal() {
26637 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), []);
26638 const {
26639 openModal,
26640 closeModal
26641 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26642 const toggleModal = () => {
26643 if (isModalActive) {
26644 closeModal();
26645 } else {
26646 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
26647 }
26648 };
26649 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/keyboard-shortcuts', toggleModal);
26650 if (!isModalActive) {
26651 return null;
26652 }
26653 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
26654 className: "editor-keyboard-shortcut-help-modal",
26655 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
26656 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
26657 onRequestClose: toggleModal,
26658 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
26659 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
26660 shortcuts: ['core/editor/keyboard-shortcuts']
26661 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
26662 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
26663 categoryName: "global"
26664 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
26665 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
26666 categoryName: "selection"
26667 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
26668 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
26669 categoryName: "block",
26670 additionalShortcuts: [{
26671 keyCombination: {
26672 character: '/'
26673 },
26674 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
26675 /* translators: The forward-slash character. e.g. '/'. */
26676 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
26677 }]
26678 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
26679 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
26680 shortcuts: textFormattingShortcuts
26681 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
26682 title: (0,external_wp_i18n_namespaceObject.__)('List View shortcuts'),
26683 categoryName: "list-view"
26684 })]
26685 });
26686 }
26687 /* harmony default export */ const keyboard_shortcut_help_modal = (KeyboardShortcutHelpModal);
26688
26689 ;// ./packages/editor/build-module/components/block-settings-menu/content-only-settings-menu.js
26690 /* wp:polyfill */
26691 /**
26692 * WordPress dependencies
26693 */
26694
26695
26696
26697
26698
26699
26700 /**
26701 * Internal dependencies
26702 */
26703
26704
26705
26706
26707 function ContentOnlySettingsMenuItems({
26708 clientId,
26709 onClose
26710 }) {
26711 const postContentBlocks = usePostContentBlocks();
26712 const {
26713 entity,
26714 onNavigateToEntityRecord,
26715 canEditTemplates
26716 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26717 const {
26718 getBlockParentsByBlockName,
26719 getSettings,
26720 getBlockAttributes,
26721 getBlockParents
26722 } = select(external_wp_blockEditor_namespaceObject.store);
26723 const {
26724 getCurrentTemplateId,
26725 getRenderingMode
26726 } = select(store_store);
26727 const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
26728 let record;
26729 if (patternParent) {
26730 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
26731 } else if (getRenderingMode() === 'template-locked' && !getBlockParents(clientId).some(parent => postContentBlocks.includes(parent))) {
26732 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', getCurrentTemplateId());
26733 }
26734 if (!record) {
26735 return {};
26736 }
26737 const _canEditTemplates = select(external_wp_coreData_namespaceObject.store).canUser('create', {
26738 kind: 'postType',
26739 name: 'wp_template'
26740 });
26741 return {
26742 canEditTemplates: _canEditTemplates,
26743 entity: record,
26744 onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
26745 };
26746 }, [clientId, postContentBlocks]);
26747 if (!entity) {
26748 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateLockContentOnlyMenuItems, {
26749 clientId: clientId,
26750 onClose: onClose
26751 });
26752 }
26753 const isPattern = entity.type === 'wp_block';
26754 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.');
26755 if (!canEditTemplates) {
26756 helpText = (0,external_wp_i18n_namespaceObject.__)('Only users with permissions to edit the template can move or delete this block');
26757 }
26758 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26759 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
26760 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
26761 onClick: () => {
26762 onNavigateToEntityRecord({
26763 postId: entity.id,
26764 postType: entity.type
26765 });
26766 },
26767 disabled: !canEditTemplates,
26768 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit pattern') : (0,external_wp_i18n_namespaceObject.__)('Edit template')
26769 })
26770 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26771 variant: "muted",
26772 as: "p",
26773 className: "editor-content-only-settings-menu__description",
26774 children: helpText
26775 })]
26776 });
26777 }
26778 function TemplateLockContentOnlyMenuItems({
26779 clientId,
26780 onClose
26781 }) {
26782 const {
26783 contentLockingParent
26784 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26785 const {
26786 getContentLockingParent
26787 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
26788 return {
26789 contentLockingParent: getContentLockingParent(clientId)
26790 };
26791 }, [clientId]);
26792 const blockDisplayInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(contentLockingParent);
26793 const blockEditorActions = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
26794 if (!blockDisplayInformation?.title) {
26795 return null;
26796 }
26797 const {
26798 modifyContentLockBlock
26799 } = unlock(blockEditorActions);
26800 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26801 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
26802 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
26803 onClick: () => {
26804 modifyContentLockBlock(contentLockingParent);
26805 onClose();
26806 },
26807 children: (0,external_wp_i18n_namespaceObject._x)('Unlock', 'Unlock content locked blocks')
26808 })
26809 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26810 variant: "muted",
26811 as: "p",
26812 className: "editor-content-only-settings-menu__description",
26813 children: (0,external_wp_i18n_namespaceObject.__)('Temporarily unlock the parent block to edit, delete or make further changes to this block.')
26814 })]
26815 });
26816 }
26817 function ContentOnlySettingsMenu() {
26818 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
26819 children: ({
26820 selectedClientIds,
26821 onClose
26822 }) => selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenuItems, {
26823 clientId: selectedClientIds[0],
26824 onClose: onClose
26825 })
26826 });
26827 }
26828
26829 ;// ./packages/editor/build-module/components/start-template-options/index.js
26830 /* wp:polyfill */
26831 /**
26832 * WordPress dependencies
26833 */
26834
26835
26836
26837
26838
26839
26840
26841
26842 /**
26843 * Internal dependencies
26844 */
26845
26846
26847
26848 function useFallbackTemplateContent(slug, isCustom = false) {
26849 return (0,external_wp_data_namespaceObject.useSelect)(select => {
26850 const {
26851 getEntityRecord,
26852 getDefaultTemplateId
26853 } = select(external_wp_coreData_namespaceObject.store);
26854 const templateId = getDefaultTemplateId({
26855 slug,
26856 is_custom: isCustom,
26857 ignore_empty: true
26858 });
26859 return templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
26860 }, [slug, isCustom]);
26861 }
26862 function useStartPatterns(fallbackContent) {
26863 const {
26864 slug,
26865 patterns
26866 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26867 const {
26868 getCurrentPostType,
26869 getCurrentPostId
26870 } = select(store_store);
26871 const {
26872 getEntityRecord,
26873 getBlockPatterns
26874 } = select(external_wp_coreData_namespaceObject.store);
26875 const postId = getCurrentPostId();
26876 const postType = getCurrentPostType();
26877 const record = getEntityRecord('postType', postType, postId);
26878 return {
26879 slug: record.slug,
26880 patterns: getBlockPatterns()
26881 };
26882 }, []);
26883 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet);
26884
26885 // Duplicated from packages/block-library/src/pattern/edit.js.
26886 function injectThemeAttributeInBlockTemplateContent(block) {
26887 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
26888 block.innerBlocks = block.innerBlocks.map(innerBlock => {
26889 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
26890 innerBlock.attributes.theme = currentThemeStylesheet;
26891 }
26892 return innerBlock;
26893 });
26894 }
26895 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
26896 block.attributes.theme = currentThemeStylesheet;
26897 }
26898 return block;
26899 }
26900 return (0,external_wp_element_namespaceObject.useMemo)(() => {
26901 // filter patterns that are supposed to be used in the current template being edited.
26902 return [{
26903 name: 'fallback',
26904 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent),
26905 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content')
26906 }, ...patterns.filter(pattern => {
26907 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
26908 }).map(pattern => {
26909 return {
26910 ...pattern,
26911 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
26912 };
26913 })];
26914 }, [fallbackContent, slug, patterns]);
26915 }
26916 function PatternSelection({
26917 fallbackContent,
26918 onChoosePattern,
26919 postType
26920 }) {
26921 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType);
26922 const blockPatterns = useStartPatterns(fallbackContent);
26923 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
26924 blockPatterns: blockPatterns,
26925 onClickPattern: (pattern, blocks) => {
26926 onChange(blocks, {
26927 selection: undefined
26928 });
26929 onChoosePattern();
26930 }
26931 });
26932 }
26933 function StartModal({
26934 slug,
26935 isCustom,
26936 onClose,
26937 postType
26938 }) {
26939 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
26940 if (!fallbackContent) {
26941 return null;
26942 }
26943 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
26944 className: "editor-start-template-options__modal",
26945 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
26946 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
26947 focusOnMount: "firstElement",
26948 onRequestClose: onClose,
26949 isFullScreen: true,
26950 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26951 className: "editor-start-template-options__modal-content",
26952 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternSelection, {
26953 fallbackContent: fallbackContent,
26954 slug: slug,
26955 isCustom: isCustom,
26956 postType: postType,
26957 onChoosePattern: () => {
26958 onClose();
26959 }
26960 })
26961 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
26962 className: "editor-start-template-options__modal__actions",
26963 justify: "flex-end",
26964 expanded: false,
26965 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
26966 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26967 __next40pxDefaultSize: true,
26968 variant: "tertiary",
26969 onClick: onClose,
26970 children: (0,external_wp_i18n_namespaceObject.__)('Skip')
26971 })
26972 })
26973 })]
26974 });
26975 }
26976 function StartTemplateOptions() {
26977 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
26978 const {
26979 shouldOpenModal,
26980 slug,
26981 isCustom,
26982 postType,
26983 postId
26984 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26985 const {
26986 getCurrentPostType,
26987 getCurrentPostId
26988 } = select(store_store);
26989 const _postType = getCurrentPostType();
26990 const _postId = getCurrentPostId();
26991 const {
26992 getEditedEntityRecord,
26993 hasEditsForEntityRecord
26994 } = select(external_wp_coreData_namespaceObject.store);
26995 const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
26996 const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
26997 return {
26998 shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
26999 slug: templateRecord.slug,
27000 isCustom: templateRecord.is_custom,
27001 postType: _postType,
27002 postId: _postId
27003 };
27004 }, []);
27005 (0,external_wp_element_namespaceObject.useEffect)(() => {
27006 // Should reset the modal state when navigating to a new page/post.
27007 setIsClosed(false);
27008 }, [postType, postId]);
27009 if (!shouldOpenModal || isClosed) {
27010 return null;
27011 }
27012 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartModal, {
27013 slug: slug,
27014 isCustom: isCustom,
27015 postType: postType,
27016 onClose: () => setIsClosed(true)
27017 });
27018 }
27019
27020 ;// ./packages/editor/build-module/components/template-part-menu-items/convert-to-regular.js
27021 /**
27022 * WordPress dependencies
27023 */
27024
27025
27026
27027
27028
27029 function ConvertToRegularBlocks({
27030 clientId,
27031 onClose
27032 }) {
27033 const {
27034 getBlocks
27035 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
27036 const {
27037 replaceBlocks
27038 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
27039 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
27040 if (!canRemove) {
27041 return null;
27042 }
27043 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
27044 onClick: () => {
27045 replaceBlocks(clientId, getBlocks(clientId));
27046 onClose();
27047 },
27048 children: (0,external_wp_i18n_namespaceObject.__)('Detach')
27049 });
27050 }
27051
27052 ;// ./packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.js
27053 /**
27054 * WordPress dependencies
27055 */
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065 /**
27066 * Internal dependencies
27067 */
27068
27069
27070 function ConvertToTemplatePart({
27071 clientIds,
27072 blocks
27073 }) {
27074 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
27075 const {
27076 replaceBlocks
27077 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
27078 const {
27079 createSuccessNotice
27080 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
27081 const {
27082 canCreate
27083 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27084 return {
27085 canCreate: select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType('core/template-part')
27086 };
27087 }, []);
27088 if (!canCreate) {
27089 return null;
27090 }
27091 const onConvert = async templatePart => {
27092 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
27093 slug: templatePart.slug,
27094 theme: templatePart.theme
27095 }));
27096 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
27097 type: 'snackbar'
27098 });
27099
27100 // The modal and this component will be unmounted because of `replaceBlocks` above,
27101 // so no need to call `closeModal` or `onClose`.
27102 };
27103 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27104 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
27105 icon: symbol_filled,
27106 onClick: () => {
27107 setIsModalOpen(true);
27108 },
27109 "aria-expanded": isModalOpen,
27110 "aria-haspopup": "dialog",
27111 children: (0,external_wp_i18n_namespaceObject.__)('Create template part')
27112 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModal, {
27113 closeModal: () => {
27114 setIsModalOpen(false);
27115 },
27116 blocks: blocks,
27117 onCreate: onConvert
27118 })]
27119 });
27120 }
27121
27122 ;// ./packages/editor/build-module/components/template-part-menu-items/index.js
27123 /**
27124 * WordPress dependencies
27125 */
27126
27127
27128
27129 /**
27130 * Internal dependencies
27131 */
27132
27133
27134
27135 function TemplatePartMenuItems() {
27136 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
27137 children: ({
27138 selectedClientIds,
27139 onClose
27140 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartConverterMenuItem, {
27141 clientIds: selectedClientIds,
27142 onClose: onClose
27143 })
27144 });
27145 }
27146 function TemplatePartConverterMenuItem({
27147 clientIds,
27148 onClose
27149 }) {
27150 const {
27151 blocks
27152 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27153 const {
27154 getBlocksByClientId
27155 } = select(external_wp_blockEditor_namespaceObject.store);
27156 return {
27157 blocks: getBlocksByClientId(clientIds)
27158 };
27159 }, [clientIds]);
27160
27161 // Allow converting a single template part to standard blocks.
27162 if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') {
27163 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToRegularBlocks, {
27164 clientId: clientIds[0],
27165 onClose: onClose
27166 });
27167 }
27168 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToTemplatePart, {
27169 clientIds: clientIds,
27170 blocks: blocks
27171 });
27172 }
27173
27174 ;// ./packages/editor/build-module/components/provider/index.js
27175 /**
27176 * WordPress dependencies
27177 */
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187 /**
27188 * Internal dependencies
27189 */
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208 const {
27209 ExperimentalBlockEditorProvider
27210 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27211 const {
27212 PatternsMenuItems
27213 } = unlock(external_wp_patterns_namespaceObject.privateApis);
27214 const provider_noop = () => {};
27215
27216 /**
27217 * These are global entities that are only there to split blocks into logical units
27218 * They don't provide a "context" for the current post/page being rendered.
27219 * So we should not use their ids as post context. This is important to allow post blocks
27220 * (post content, post title) to be used within them without issues.
27221 */
27222 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_navigation', 'wp_template_part'];
27223
27224 /**
27225 * Depending on the post, template and template mode,
27226 * returns the appropriate blocks and change handlers for the block editor provider.
27227 *
27228 * @param {Array} post Block list.
27229 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
27230 * @param {string} mode Rendering mode.
27231 *
27232 * @example
27233 * ```jsx
27234 * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );
27235 * ```
27236 *
27237 * @return {Array} Block editor props.
27238 */
27239 function useBlockEditorProps(post, template, mode) {
27240 const rootLevelPost = mode === 'template-locked' ? 'template' : 'post';
27241 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, {
27242 id: post.id
27243 });
27244 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, {
27245 id: template?.id
27246 });
27247 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
27248 if (post.type === 'wp_navigation') {
27249 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
27250 ref: post.id,
27251 // As the parent editor is locked with `templateLock`, the template locking
27252 // must be explicitly "unset" on the block itself to allow the user to modify
27253 // the block's content.
27254 templateLock: false
27255 })];
27256 }
27257 }, [post.type, post.id]);
27258
27259 // It is important that we don't create a new instance of blocks on every change
27260 // We should only create a new instance if the blocks them selves change, not a dependency of them.
27261 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
27262 if (maybeNavigationBlocks) {
27263 return maybeNavigationBlocks;
27264 }
27265 if (rootLevelPost === 'template') {
27266 return templateBlocks;
27267 }
27268 return postBlocks;
27269 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
27270
27271 // Handle fallback to postBlocks outside of the above useMemo, to ensure
27272 // that constructed block templates that call `createBlock` are not generated
27273 // too frequently. This ensures that clientIds are stable.
27274 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
27275 if (disableRootLevelChanges) {
27276 return [blocks, provider_noop, provider_noop];
27277 }
27278 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
27279 }
27280
27281 /**
27282 * This component provides the editor context and manages the state of the block editor.
27283 *
27284 * @param {Object} props The component props.
27285 * @param {Object} props.post The post object.
27286 * @param {Object} props.settings The editor settings.
27287 * @param {boolean} props.recovery Indicates if the editor is in recovery mode.
27288 * @param {Array} props.initialEdits The initial edits for the editor.
27289 * @param {Object} props.children The child components.
27290 * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.
27291 * @param {Object} [props.__unstableTemplate] The template object.
27292 *
27293 * @example
27294 * ```jsx
27295 * <ExperimentalEditorProvider
27296 * post={ post }
27297 * settings={ settings }
27298 * recovery={ recovery }
27299 * initialEdits={ initialEdits }
27300 * __unstableTemplate={ template }
27301 * >
27302 * { children }
27303 * </ExperimentalEditorProvider>
27304 *
27305 * @return {Object} The rendered ExperimentalEditorProvider component.
27306 */
27307 const ExperimentalEditorProvider = with_registry_provider(({
27308 post,
27309 settings,
27310 recovery,
27311 initialEdits,
27312 children,
27313 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
27314 __unstableTemplate: template
27315 }) => {
27316 const hasTemplate = !!template;
27317 const {
27318 editorSettings,
27319 selection,
27320 isReady,
27321 mode,
27322 defaultMode,
27323 postTypeEntities,
27324 hasLoadedPostObject
27325 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27326 const {
27327 getEditorSettings,
27328 getEditorSelection,
27329 getRenderingMode,
27330 __unstableIsEditorReady
27331 } = select(store_store);
27332 const {
27333 getEntitiesConfig
27334 } = select(external_wp_coreData_namespaceObject.store);
27335 const postTypeObject = select(external_wp_coreData_namespaceObject.store).getPostType(post.type);
27336 const _hasLoadedPostObject = select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getPostType', [post.type]);
27337 return {
27338 hasLoadedPostObject: _hasLoadedPostObject,
27339 editorSettings: getEditorSettings(),
27340 isReady: __unstableIsEditorReady(),
27341 mode: getRenderingMode(),
27342 defaultMode: hasTemplate && postTypeObject?.default_rendering_mode ? postTypeObject?.default_rendering_mode : 'post-only',
27343 selection: getEditorSelection(),
27344 postTypeEntities: post.type === 'wp_template' ? getEntitiesConfig('postType') : null
27345 };
27346 }, [post.type, hasTemplate]);
27347 const shouldRenderTemplate = !!template && mode !== 'post-only';
27348 const rootLevelPost = shouldRenderTemplate ? template : post;
27349 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
27350 const postContext = {};
27351 // If it is a template, try to inherit the post type from the name.
27352 if (post.type === 'wp_template') {
27353 if (post.slug === 'page') {
27354 postContext.postType = 'page';
27355 } else if (post.slug === 'single') {
27356 postContext.postType = 'post';
27357 } else if (post.slug.split('-')[0] === 'single') {
27358 // If the slug is single-{postType}, infer the post type from the name.
27359 const postTypeNames = postTypeEntities?.map(entity => entity.name) || [];
27360 const match = post.slug.match(`^single-(${postTypeNames.join('|')})(?:-.+)?$`);
27361 if (match) {
27362 postContext.postType = match[1];
27363 }
27364 }
27365 } else if (!NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate) {
27366 postContext.postId = post.id;
27367 postContext.postType = post.type;
27368 }
27369 return {
27370 ...postContext,
27371 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
27372 };
27373 }, [shouldRenderTemplate, post.id, post.type, post.slug, rootLevelPost.type, rootLevelPost.slug, postTypeEntities]);
27374 const {
27375 id,
27376 type
27377 } = rootLevelPost;
27378 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id, mode);
27379 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
27380 const {
27381 updatePostLock,
27382 setupEditor,
27383 updateEditorSettings,
27384 setCurrentTemplateId,
27385 setEditedPost,
27386 setRenderingMode
27387 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
27388 const {
27389 createWarningNotice
27390 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
27391
27392 // Ideally this should be synced on each change and not just something you do once.
27393 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
27394 // Assume that we don't need to initialize in the case of an error recovery.
27395 if (recovery) {
27396 return;
27397 }
27398 updatePostLock(settings.postLock);
27399 setupEditor(post, initialEdits, settings.template);
27400 if (settings.autosave) {
27401 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
27402 id: 'autosave-exists',
27403 actions: [{
27404 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
27405 url: settings.autosave.editLink
27406 }]
27407 });
27408 }
27409
27410 // The dependencies of the hook are omitted deliberately
27411 // We only want to run setupEditor (with initialEdits) only once per post.
27412 // A better solution in the future would be to split this effect into multiple ones.
27413 }, []);
27414
27415 // Synchronizes the active post with the state
27416 (0,external_wp_element_namespaceObject.useEffect)(() => {
27417 setEditedPost(post.type, post.id);
27418 }, [post.type, post.id, setEditedPost]);
27419
27420 // Synchronize the editor settings as they change.
27421 (0,external_wp_element_namespaceObject.useEffect)(() => {
27422 updateEditorSettings(settings);
27423 }, [settings, updateEditorSettings]);
27424
27425 // Synchronizes the active template with the state.
27426 (0,external_wp_element_namespaceObject.useEffect)(() => {
27427 setCurrentTemplateId(template?.id);
27428 }, [template?.id, setCurrentTemplateId]);
27429
27430 // Sets the right rendering mode when loading the editor.
27431 (0,external_wp_element_namespaceObject.useEffect)(() => {
27432 setRenderingMode(defaultMode);
27433 }, [defaultMode, setRenderingMode]);
27434 useHideBlocksFromInserter(post.type, mode);
27435
27436 // Register the editor commands.
27437 useCommands();
27438 if (!isReady || !mode || !hasLoadedPostObject) {
27439 return null;
27440 }
27441 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
27442 kind: "root",
27443 type: "site",
27444 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
27445 kind: "postType",
27446 type: post.type,
27447 id: post.id,
27448 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
27449 value: defaultBlockContext,
27450 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockEditorProviderComponent, {
27451 value: blocks,
27452 onChange: onChange,
27453 onInput: onInput,
27454 selection: selection,
27455 settings: blockEditorSettings,
27456 useSubRegistry: false,
27457 children: [children, !settings.isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27458 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, {})]
27459 })]
27460 })
27461 })
27462 })
27463 });
27464 });
27465
27466 /**
27467 * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).
27468 *
27469 * It supports a large number of post types, including post, page, templates,
27470 * custom post types, patterns, template parts.
27471 *
27472 * All modification and changes are performed to the `@wordpress/core-data` store.
27473 *
27474 * @param {Object} props The component props.
27475 * @param {Object} [props.post] The post object to edit. This is required.
27476 * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.
27477 * This is optional and can only be used when the post type supports templates (like posts and pages).
27478 * @param {Object} [props.settings] The settings object to use for the editor.
27479 * This is optional and can be used to override the default settings.
27480 * @param {Element} [props.children] Children elements for which the BlockEditorProvider context should apply.
27481 * This is optional.
27482 *
27483 * @example
27484 * ```jsx
27485 * <EditorProvider
27486 * post={ post }
27487 * settings={ settings }
27488 * __unstableTemplate={ template }
27489 * >
27490 * { children }
27491 * </EditorProvider>
27492 * ```
27493 *
27494 * @return {React.ReactNode} The rendered EditorProvider component.
27495 */
27496 function EditorProvider(props) {
27497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalEditorProvider, {
27498 ...props,
27499 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider,
27500 children: props.children
27501 });
27502 }
27503 /* harmony default export */ const provider = (EditorProvider);
27504
27505 ;// external ["wp","serverSideRender"]
27506 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
27507 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
27508 ;// ./packages/editor/build-module/components/deprecated.js
27509 /* wp:polyfill */
27510 // Block Creation Components.
27511 /**
27512 * WordPress dependencies
27513 */
27514
27515
27516
27517
27518
27519 function deprecateComponent(name, Wrapped, staticsToHoist = []) {
27520 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
27521 external_wp_deprecated_default()('wp.editor.' + name, {
27522 since: '5.3',
27523 alternative: 'wp.blockEditor.' + name,
27524 version: '6.2'
27525 });
27526 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapped, {
27527 ref: ref,
27528 ...props
27529 });
27530 });
27531 staticsToHoist.forEach(staticName => {
27532 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
27533 });
27534 return Component;
27535 }
27536 function deprecateFunction(name, func) {
27537 return (...args) => {
27538 external_wp_deprecated_default()('wp.editor.' + name, {
27539 since: '5.3',
27540 alternative: 'wp.blockEditor.' + name,
27541 version: '6.2'
27542 });
27543 return func(...args);
27544 };
27545 }
27546
27547 /**
27548 * @deprecated since 5.3, use `wp.blockEditor.RichText` instead.
27549 */
27550 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
27551 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
27552
27553
27554 /**
27555 * @deprecated since 5.3, use `wp.blockEditor.Autocomplete` instead.
27556 */
27557 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
27558 /**
27559 * @deprecated since 5.3, use `wp.blockEditor.AlignmentToolbar` instead.
27560 */
27561 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
27562 /**
27563 * @deprecated since 5.3, use `wp.blockEditor.BlockAlignmentToolbar` instead.
27564 */
27565 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
27566 /**
27567 * @deprecated since 5.3, use `wp.blockEditor.BlockControls` instead.
27568 */
27569 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
27570 /**
27571 * @deprecated since 5.3, use `wp.blockEditor.BlockEdit` instead.
27572 */
27573 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
27574 /**
27575 * @deprecated since 5.3, use `wp.blockEditor.BlockEditorKeyboardShortcuts` instead.
27576 */
27577 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
27578 /**
27579 * @deprecated since 5.3, use `wp.blockEditor.BlockFormatControls` instead.
27580 */
27581 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
27582 /**
27583 * @deprecated since 5.3, use `wp.blockEditor.BlockIcon` instead.
27584 */
27585 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
27586 /**
27587 * @deprecated since 5.3, use `wp.blockEditor.BlockInspector` instead.
27588 */
27589 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
27590 /**
27591 * @deprecated since 5.3, use `wp.blockEditor.BlockList` instead.
27592 */
27593 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
27594 /**
27595 * @deprecated since 5.3, use `wp.blockEditor.BlockMover` instead.
27596 */
27597 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
27598 /**
27599 * @deprecated since 5.3, use `wp.blockEditor.BlockNavigationDropdown` instead.
27600 */
27601 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
27602 /**
27603 * @deprecated since 5.3, use `wp.blockEditor.BlockSelectionClearer` instead.
27604 */
27605 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
27606 /**
27607 * @deprecated since 5.3, use `wp.blockEditor.BlockSettingsMenu` instead.
27608 */
27609 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
27610 /**
27611 * @deprecated since 5.3, use `wp.blockEditor.BlockTitle` instead.
27612 */
27613 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
27614 /**
27615 * @deprecated since 5.3, use `wp.blockEditor.BlockToolbar` instead.
27616 */
27617 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
27618 /**
27619 * @deprecated since 5.3, use `wp.blockEditor.ColorPalette` instead.
27620 */
27621 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
27622 /**
27623 * @deprecated since 5.3, use `wp.blockEditor.ContrastChecker` instead.
27624 */
27625 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
27626 /**
27627 * @deprecated since 5.3, use `wp.blockEditor.CopyHandler` instead.
27628 */
27629 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
27630 /**
27631 * @deprecated since 5.3, use `wp.blockEditor.DefaultBlockAppender` instead.
27632 */
27633 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
27634 /**
27635 * @deprecated since 5.3, use `wp.blockEditor.FontSizePicker` instead.
27636 */
27637 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
27638 /**
27639 * @deprecated since 5.3, use `wp.blockEditor.Inserter` instead.
27640 */
27641 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
27642 /**
27643 * @deprecated since 5.3, use `wp.blockEditor.InnerBlocks` instead.
27644 */
27645 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
27646 /**
27647 * @deprecated since 5.3, use `wp.blockEditor.InspectorAdvancedControls` instead.
27648 */
27649 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
27650 /**
27651 * @deprecated since 5.3, use `wp.blockEditor.InspectorControls` instead.
27652 */
27653 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
27654 /**
27655 * @deprecated since 5.3, use `wp.blockEditor.PanelColorSettings` instead.
27656 */
27657 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
27658 /**
27659 * @deprecated since 5.3, use `wp.blockEditor.PlainText` instead.
27660 */
27661 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
27662 /**
27663 * @deprecated since 5.3, use `wp.blockEditor.RichTextShortcut` instead.
27664 */
27665 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
27666 /**
27667 * @deprecated since 5.3, use `wp.blockEditor.RichTextToolbarButton` instead.
27668 */
27669 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
27670 /**
27671 * @deprecated since 5.3, use `wp.blockEditor.__unstableRichTextInputEvent` instead.
27672 */
27673 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
27674 /**
27675 * @deprecated since 5.3, use `wp.blockEditor.MediaPlaceholder` instead.
27676 */
27677 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
27678 /**
27679 * @deprecated since 5.3, use `wp.blockEditor.MediaUpload` instead.
27680 */
27681 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
27682 /**
27683 * @deprecated since 5.3, use `wp.blockEditor.MediaUploadCheck` instead.
27684 */
27685 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
27686 /**
27687 * @deprecated since 5.3, use `wp.blockEditor.MultiSelectScrollIntoView` instead.
27688 */
27689 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
27690 /**
27691 * @deprecated since 5.3, use `wp.blockEditor.NavigableToolbar` instead.
27692 */
27693 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
27694 /**
27695 * @deprecated since 5.3, use `wp.blockEditor.ObserveTyping` instead.
27696 */
27697 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
27698 /**
27699 * @deprecated since 5.3, use `wp.blockEditor.SkipToSelectedBlock` instead.
27700 */
27701 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
27702 /**
27703 * @deprecated since 5.3, use `wp.blockEditor.URLInput` instead.
27704 */
27705 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
27706 /**
27707 * @deprecated since 5.3, use `wp.blockEditor.URLInputButton` instead.
27708 */
27709 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
27710 /**
27711 * @deprecated since 5.3, use `wp.blockEditor.URLPopover` instead.
27712 */
27713 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
27714 /**
27715 * @deprecated since 5.3, use `wp.blockEditor.Warning` instead.
27716 */
27717 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
27718 /**
27719 * @deprecated since 5.3, use `wp.blockEditor.WritingFlow` instead.
27720 */
27721 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
27722
27723 /**
27724 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
27725 */
27726 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
27727 /**
27728 * @deprecated since 5.3, use `wp.blockEditor.getColorClassName` instead.
27729 */
27730 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
27731 /**
27732 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByAttributeValues` instead.
27733 */
27734 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
27735 /**
27736 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByColorValue` instead.
27737 */
27738 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
27739 /**
27740 * @deprecated since 5.3, use `wp.blockEditor.getFontSize` instead.
27741 */
27742 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
27743 /**
27744 * @deprecated since 5.3, use `wp.blockEditor.getFontSizeClass` instead.
27745 */
27746 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
27747 /**
27748 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
27749 */
27750 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
27751 /**
27752 * @deprecated since 5.3, use `wp.blockEditor.withColors` instead.
27753 */
27754 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
27755 /**
27756 * @deprecated since 5.3, use `wp.blockEditor.withFontSizes` instead.
27757 */
27758 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
27759
27760 ;// ./packages/editor/build-module/components/index.js
27761 /**
27762 * Internal dependencies
27763 */
27764
27765
27766 // Block Creation Components.
27767
27768
27769 // Post Related Components.
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857 // State Related Components.
27858
27859
27860
27861 /**
27862 * Handles the keyboard shortcuts for the editor.
27863 *
27864 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
27865 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
27866 * and toggling the sidebar.
27867 */
27868 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
27869
27870 /**
27871 * Handles the keyboard shortcuts for the editor.
27872 *
27873 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
27874 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
27875 * and toggling the sidebar.
27876 */
27877 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
27878
27879 ;// ./packages/editor/build-module/utils/url.js
27880 /**
27881 * WordPress dependencies
27882 */
27883
27884
27885
27886 /**
27887 * Performs some basic cleanup of a string for use as a post slug
27888 *
27889 * This replicates some of what sanitize_title() does in WordPress core, but
27890 * is only designed to approximate what the slug will be.
27891 *
27892 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
27893 * Removes combining diacritical marks. Converts whitespace, periods,
27894 * and forward slashes to hyphens. Removes any remaining non-word characters
27895 * except hyphens and underscores. Converts remaining string to lowercase.
27896 * It does not account for octets, HTML entities, or other encoded characters.
27897 *
27898 * @param {string} string Title or slug to be processed
27899 *
27900 * @return {string} Processed string
27901 */
27902 function cleanForSlug(string) {
27903 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
27904 since: '12.7',
27905 plugin: 'Gutenberg',
27906 alternative: 'wp.url.cleanForSlug'
27907 });
27908 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
27909 }
27910
27911 ;// ./packages/editor/build-module/utils/index.js
27912 /**
27913 * Internal dependencies
27914 */
27915
27916
27917
27918
27919
27920 ;// ./packages/editor/build-module/components/editor-interface/content-slot-fill.js
27921 /**
27922 * WordPress dependencies
27923 */
27924
27925 const EditorContentSlotFill = (0,external_wp_components_namespaceObject.createSlotFill)(Symbol('EditCanvasContainerSlot'));
27926 /* harmony default export */ const content_slot_fill = (EditorContentSlotFill);
27927
27928 ;// ./packages/editor/build-module/components/header/back-button.js
27929 /**
27930 * WordPress dependencies
27931 */
27932
27933
27934 // Keeping an old name for backward compatibility.
27935
27936 const slotName = '__experimentalMainDashboardButton';
27937 const useHasBackButton = () => {
27938 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
27939 return Boolean(fills && fills.length);
27940 };
27941 const {
27942 Fill: back_button_Fill,
27943 Slot: back_button_Slot
27944 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
27945 const BackButton = back_button_Fill;
27946 const BackButtonSlot = () => {
27947 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
27948 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button_Slot, {
27949 bubblesVirtually: true,
27950 fillProps: {
27951 length: !fills ? 0 : fills.length
27952 }
27953 });
27954 };
27955 BackButton.Slot = BackButtonSlot;
27956 /* harmony default export */ const back_button = (BackButton);
27957
27958 ;// ./packages/icons/build-module/library/comment.js
27959 /**
27960 * WordPress dependencies
27961 */
27962
27963
27964 const comment = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27965 viewBox: "0 0 24 24",
27966 xmlns: "http://www.w3.org/2000/svg",
27967 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27968 d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z"
27969 })
27970 });
27971 /* harmony default export */ const library_comment = (comment);
27972
27973 ;// ./packages/editor/build-module/components/collab-sidebar/constants.js
27974 const collabHistorySidebarName = 'edit-post/collab-history-sidebar';
27975 const collabSidebarName = 'edit-post/collab-sidebar';
27976
27977 ;// ./packages/icons/build-module/library/more-vertical.js
27978 /**
27979 * WordPress dependencies
27980 */
27981
27982
27983 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
27984 xmlns: "http://www.w3.org/2000/svg",
27985 viewBox: "0 0 24 24",
27986 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
27987 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
27988 })
27989 });
27990 /* harmony default export */ const more_vertical = (moreVertical);
27991
27992 ;// ./packages/editor/build-module/components/collab-sidebar/comment-author-info.js
27993 /**
27994 * WordPress dependencies
27995 */
27996
27997
27998
27999
28000
28001
28002
28003 /**
28004 * Render author information for a comment.
28005 *
28006 * @param {Object} props - Component properties.
28007 * @param {string} props.avatar - URL of the author's avatar.
28008 * @param {string} props.name - Name of the author.
28009 * @param {string} props.date - Date of the comment.
28010 *
28011 * @return {React.ReactNode} The JSX element representing the author's information.
28012 */
28013
28014 function CommentAuthorInfo({
28015 avatar,
28016 name,
28017 date
28018 }) {
28019 const dateSettings = (0,external_wp_date_namespaceObject.getSettings)();
28020 const [dateTimeFormat = dateSettings.formats.time] = (0,external_wp_coreData_namespaceObject.useEntityProp)('root', 'site', 'time_format');
28021 const {
28022 currentUserAvatar,
28023 currentUserName
28024 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28025 var _userData$avatar_urls;
28026 const userData = select(external_wp_coreData_namespaceObject.store).getCurrentUser();
28027 const {
28028 getSettings
28029 } = select(external_wp_blockEditor_namespaceObject.store);
28030 const {
28031 __experimentalDiscussionSettings
28032 } = getSettings();
28033 const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
28034 return {
28035 currentUserAvatar: (_userData$avatar_urls = userData?.avatar_urls[48]) !== null && _userData$avatar_urls !== void 0 ? _userData$avatar_urls : defaultAvatar,
28036 currentUserName: userData?.name
28037 };
28038 }, []);
28039 const currentDate = new Date();
28040 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28041 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
28042 src: avatar !== null && avatar !== void 0 ? avatar : currentUserAvatar,
28043 className: "editor-collab-sidebar-panel__user-avatar"
28044 // translators: alt text for user avatar image
28045 ,
28046 alt: (0,external_wp_i18n_namespaceObject.__)('User avatar'),
28047 width: 32,
28048 height: 32
28049 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28050 spacing: "0",
28051 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
28052 className: "editor-collab-sidebar-panel__user-name",
28053 children: name !== null && name !== void 0 ? name : currentUserName
28054 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("time", {
28055 dateTime: (0,external_wp_date_namespaceObject.dateI18n)('c', date !== null && date !== void 0 ? date : currentDate),
28056 className: "editor-collab-sidebar-panel__user-time",
28057 children: (0,external_wp_date_namespaceObject.dateI18n)(dateTimeFormat, date !== null && date !== void 0 ? date : currentDate)
28058 })]
28059 })]
28060 });
28061 }
28062 /* harmony default export */ const comment_author_info = (CommentAuthorInfo);
28063
28064 ;// ./packages/editor/build-module/components/collab-sidebar/utils.js
28065 /* wp:polyfill */
28066 /**
28067 * Sanitizes a comment string by removing non-printable ASCII characters.
28068 *
28069 * @param {string} str - The comment string to sanitize.
28070 * @return {string} - The sanitized comment string.
28071 */
28072 function sanitizeCommentString(str) {
28073 return str.trim();
28074 }
28075
28076 /**
28077 * Extracts comment IDs from an array of blocks.
28078 *
28079 * This function recursively traverses the blocks and their inner blocks to
28080 * collect all comment IDs found in the block attributes.
28081 *
28082 * @param {Array} blocks - The array of blocks to extract comment IDs from.
28083 * @return {Array} An array of comment IDs extracted from the blocks.
28084 */
28085 function getCommentIdsFromBlocks(blocks) {
28086 // Recursive function to extract comment IDs from blocks
28087 const extractCommentIds = items => {
28088 return items.reduce((commentIds, block) => {
28089 // Check for comment IDs in the current block's attributes
28090 if (block.attributes && block.attributes.blockCommentId && !commentIds.includes(block.attributes.blockCommentId)) {
28091 commentIds.push(block.attributes.blockCommentId);
28092 }
28093
28094 // Recursively check inner blocks
28095 if (block.innerBlocks && block.innerBlocks.length > 0) {
28096 const innerCommentIds = extractCommentIds(block.innerBlocks);
28097 commentIds.push(...innerCommentIds);
28098 }
28099 return commentIds;
28100 }, []);
28101 };
28102
28103 // Extract all comment IDs recursively
28104 return extractCommentIds(blocks);
28105 }
28106
28107 ;// ./packages/editor/build-module/components/collab-sidebar/comment-form.js
28108 /**
28109 * WordPress dependencies
28110 */
28111
28112
28113
28114
28115 /**
28116 * Internal dependencies
28117 */
28118
28119
28120 /**
28121 * EditComment component.
28122 *
28123 * @param {Object} props - The component props.
28124 * @param {Function} props.onSubmit - The function to call when updating the comment.
28125 * @param {Function} props.onCancel - The function to call when canceling the comment update.
28126 * @param {Object} props.thread - The comment thread object.
28127 * @param {string} props.submitButtonText - The text to display on the submit button.
28128 * @return {React.ReactNode} The CommentForm component.
28129 */
28130
28131 function CommentForm({
28132 onSubmit,
28133 onCancel,
28134 thread,
28135 submitButtonText
28136 }) {
28137 var _thread$content$raw;
28138 const [inputComment, setInputComment] = (0,external_wp_element_namespaceObject.useState)((_thread$content$raw = thread?.content?.raw) !== null && _thread$content$raw !== void 0 ? _thread$content$raw : '');
28139 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28140 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
28141 __next40pxDefaultSize: true,
28142 __nextHasNoMarginBottom: true,
28143 value: inputComment !== null && inputComment !== void 0 ? inputComment : '',
28144 onChange: setInputComment
28145 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
28146 alignment: "left",
28147 spacing: "3",
28148 justify: "flex-start",
28149 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28150 __next40pxDefaultSize: true,
28151 accessibleWhenDisabled: true,
28152 variant: "primary",
28153 onClick: () => {
28154 onSubmit(inputComment);
28155 setInputComment('');
28156 },
28157 disabled: 0 === sanitizeCommentString(inputComment).length,
28158 text: submitButtonText
28159 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28160 __next40pxDefaultSize: true,
28161 variant: "tertiary",
28162 onClick: onCancel,
28163 text: (0,external_wp_i18n_namespaceObject._x)('Cancel', 'Cancel comment button')
28164 })]
28165 })]
28166 });
28167 }
28168 /* harmony default export */ const comment_form = (CommentForm);
28169
28170 ;// ./packages/editor/build-module/components/collab-sidebar/comments.js
28171 /* wp:polyfill */
28172 /**
28173 * External dependencies
28174 */
28175
28176
28177 /**
28178 * WordPress dependencies
28179 */
28180
28181
28182
28183
28184
28185
28186
28187 /**
28188 * Internal dependencies
28189 */
28190
28191
28192
28193 /**
28194 * Renders the Comments component.
28195 *
28196 * @param {Object} props - The component props.
28197 * @param {Array} props.threads - The array of comment threads.
28198 * @param {Function} props.onEditComment - The function to handle comment editing.
28199 * @param {Function} props.onAddReply - The function to add a reply to a comment.
28200 * @param {Function} props.onCommentDelete - The function to delete a comment.
28201 * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
28202 * @param {boolean} props.showCommentBoard - Whether to show the comment board.
28203 * @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.
28204 * @return {React.ReactNode} The rendered Comments component.
28205 */
28206
28207 function Comments({
28208 threads,
28209 onEditComment,
28210 onAddReply,
28211 onCommentDelete,
28212 onCommentResolve,
28213 showCommentBoard,
28214 setShowCommentBoard
28215 }) {
28216 const {
28217 blockCommentId
28218 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28219 const {
28220 getBlockAttributes,
28221 getSelectedBlockClientId
28222 } = select(external_wp_blockEditor_namespaceObject.store);
28223 const _clientId = getSelectedBlockClientId();
28224 return {
28225 blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null
28226 };
28227 }, []);
28228 const [focusThread, setFocusThread] = (0,external_wp_element_namespaceObject.useState)(showCommentBoard && blockCommentId ? blockCommentId : null);
28229 const clearThreadFocus = () => {
28230 setFocusThread(null);
28231 setShowCommentBoard(false);
28232 };
28233 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28234 children: [
28235 // If there are no comments, show a message indicating no comments are available.
28236 (!Array.isArray(threads) || threads.length === 0) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
28237 alignment: "left",
28238 className: "editor-collab-sidebar-panel__thread",
28239 justify: "flex-start",
28240 spacing: "3",
28241 children:
28242 // translators: message displayed when there are no comments available
28243 (0,external_wp_i18n_namespaceObject.__)('No comments available')
28244 }), Array.isArray(threads) && threads.length > 0 && threads.map(thread => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
28245 className: dist_clsx('editor-collab-sidebar-panel__thread', {
28246 'editor-collab-sidebar-panel__active-thread': blockCommentId && blockCommentId === thread.id,
28247 'editor-collab-sidebar-panel__focus-thread': focusThread && focusThread === thread.id
28248 }),
28249 id: thread.id,
28250 spacing: "3",
28251 onClick: () => setFocusThread(thread.id),
28252 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Thread, {
28253 thread: thread,
28254 onAddReply: onAddReply,
28255 onCommentDelete: onCommentDelete,
28256 onCommentResolve: onCommentResolve,
28257 onEditComment: onEditComment,
28258 isFocused: focusThread === thread.id,
28259 clearThreadFocus: clearThreadFocus
28260 })
28261 }, thread.id))]
28262 });
28263 }
28264 function Thread({
28265 thread,
28266 onEditComment,
28267 onAddReply,
28268 onCommentDelete,
28269 onCommentResolve,
28270 isFocused,
28271 clearThreadFocus
28272 }) {
28273 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28274 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentBoard, {
28275 thread: thread,
28276 onResolve: onCommentResolve,
28277 onEdit: onEditComment,
28278 onDelete: onCommentDelete,
28279 status: thread.status
28280 }), 0 < thread?.reply?.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28281 children: [!isFocused && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
28282 className: "editor-collab-sidebar-panel__show-more-reply",
28283 children: (0,external_wp_i18n_namespaceObject.sprintf)(
28284 // translators: 1: number of replies.
28285 (0,external_wp_i18n_namespaceObject._x)('%s more replies..', 'Show replies button'), thread?.reply?.length)
28286 }), isFocused && thread.reply.map(reply => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28287 className: "editor-collab-sidebar-panel__child-thread",
28288 id: reply.id,
28289 spacing: "2",
28290 children: ['approved' !== thread.status && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentBoard, {
28291 thread: reply,
28292 onEdit: onEditComment,
28293 onDelete: onCommentDelete
28294 }), 'approved' === thread.status && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentBoard, {
28295 thread: reply
28296 })]
28297 }, reply.id))]
28298 }), 'approved' !== thread.status && isFocused && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28299 className: "editor-collab-sidebar-panel__child-thread",
28300 spacing: "2",
28301 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
28302 alignment: "left",
28303 spacing: "3",
28304 justify: "flex-start",
28305 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_author_info, {})
28306 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
28307 spacing: "3",
28308 className: "editor-collab-sidebar-panel__comment-field",
28309 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_form, {
28310 onSubmit: inputComment => {
28311 onAddReply(inputComment, thread.id);
28312 },
28313 onCancel: event => {
28314 event.stopPropagation(); // Prevent the parent onClick from being triggered
28315 clearThreadFocus();
28316 },
28317 submitButtonText: (0,external_wp_i18n_namespaceObject._x)('Reply', 'Add reply comment')
28318 })
28319 })]
28320 })]
28321 });
28322 }
28323 const CommentBoard = ({
28324 thread,
28325 onResolve,
28326 onEdit,
28327 onDelete,
28328 status
28329 }) => {
28330 const [actionState, setActionState] = (0,external_wp_element_namespaceObject.useState)(false);
28331 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
28332 const handleConfirmDelete = () => {
28333 onDelete(thread.id);
28334 setActionState(false);
28335 setShowConfirmDialog(false);
28336 };
28337 const handleConfirmResolve = () => {
28338 onResolve(thread.id);
28339 setActionState(false);
28340 setShowConfirmDialog(false);
28341 };
28342 const handleCancel = () => {
28343 setActionState(false);
28344 setShowConfirmDialog(false);
28345 };
28346 const actions = [onEdit && {
28347 title: (0,external_wp_i18n_namespaceObject._x)('Edit', 'Edit comment'),
28348 onClick: () => {
28349 setActionState('edit');
28350 }
28351 }, onDelete && {
28352 title: (0,external_wp_i18n_namespaceObject._x)('Delete', 'Delete comment'),
28353 onClick: () => {
28354 setActionState('delete');
28355 setShowConfirmDialog(true);
28356 }
28357 }];
28358 const moreActions = actions.filter(item => item?.onClick);
28359 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28360 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
28361 alignment: "left",
28362 spacing: "3",
28363 justify: "flex-start",
28364 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_author_info, {
28365 avatar: thread?.author_avatar_urls?.[48],
28366 name: thread?.author_name,
28367 date: thread?.date
28368 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("span", {
28369 className: "editor-collab-sidebar-panel__comment-status",
28370 children: [status !== 'approved' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
28371 alignment: "right",
28372 justify: "flex-end",
28373 spacing: "0",
28374 children: [0 === thread?.parent && onResolve && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28375 label: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'Mark comment as resolved'),
28376 __next40pxDefaultSize: true,
28377 icon: library_published,
28378 onClick: () => {
28379 setActionState('resolve');
28380 setShowConfirmDialog(true);
28381 },
28382 showTooltip: true
28383 }), 0 < moreActions.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
28384 icon: more_vertical,
28385 label: (0,external_wp_i18n_namespaceObject._x)('Select an action', 'Select comment action'),
28386 className: "editor-collab-sidebar-panel__comment-dropdown-menu",
28387 controls: moreActions
28388 })]
28389 }), status === 'approved' &&
28390 /*#__PURE__*/
28391 // translators: tooltip for resolved comment
28392 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
28393 text: (0,external_wp_i18n_namespaceObject.__)('Resolved'),
28394 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
28395 icon: library_check
28396 })
28397 })]
28398 })]
28399 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
28400 alignment: "left",
28401 spacing: "3",
28402 justify: "flex-start",
28403 className: "editor-collab-sidebar-panel__user-comment",
28404 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28405 spacing: "3",
28406 className: "editor-collab-sidebar-panel__comment-field",
28407 children: ['edit' === actionState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_form, {
28408 onSubmit: value => {
28409 onEdit(thread.id, value);
28410 setActionState(false);
28411 },
28412 onCancel: () => handleCancel(),
28413 thread: thread,
28414 submitButtonText: (0,external_wp_i18n_namespaceObject._x)('Update', 'verb')
28415 }), 'edit' !== actionState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, {
28416 children: thread?.content?.raw
28417 })]
28418 })
28419 }), 'resolve' === actionState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
28420 isOpen: showConfirmDialog,
28421 onConfirm: handleConfirmResolve,
28422 onCancel: handleCancel,
28423 confirmButtonText: "Yes",
28424 cancelButtonText: "No",
28425 children:
28426 // translators: message displayed when confirming an action
28427 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to mark this comment as resolved?')
28428 }), 'delete' === actionState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
28429 isOpen: showConfirmDialog,
28430 onConfirm: handleConfirmDelete,
28431 onCancel: handleCancel,
28432 confirmButtonText: "Yes",
28433 cancelButtonText: "No",
28434 children:
28435 // translators: message displayed when confirming an action
28436 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this comment?')
28437 })]
28438 });
28439 };
28440
28441 ;// ./packages/editor/build-module/components/collab-sidebar/add-comment.js
28442 /**
28443 * WordPress dependencies
28444 */
28445
28446
28447
28448
28449
28450 /**
28451 * Internal dependencies
28452 */
28453
28454
28455
28456 /**
28457 * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.
28458 *
28459 * @param {Object} props - The component props.
28460 * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
28461 * @param {boolean} props.showCommentBoard - The function to edit the comment.
28462 * @param {Function} props.setShowCommentBoard - The function to delete the comment.
28463 * @return {React.ReactNode} The rendered comment input UI.
28464 */
28465
28466 function AddComment({
28467 onSubmit,
28468 showCommentBoard,
28469 setShowCommentBoard
28470 }) {
28471 const {
28472 clientId,
28473 blockCommentId
28474 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28475 const {
28476 getSelectedBlock
28477 } = select(external_wp_blockEditor_namespaceObject.store);
28478 const selectedBlock = getSelectedBlock();
28479 return {
28480 clientId: selectedBlock?.clientId,
28481 blockCommentId: selectedBlock?.attributes?.blockCommentId
28482 };
28483 });
28484 if (!showCommentBoard || !clientId || undefined !== blockCommentId) {
28485 return null;
28486 }
28487 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28488 spacing: "3",
28489 className: "editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread editor-collab-sidebar-panel__focus-thread",
28490 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
28491 alignment: "left",
28492 spacing: "3",
28493 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_author_info, {})
28494 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(comment_form, {
28495 onSubmit: inputComment => {
28496 onSubmit(inputComment);
28497 },
28498 onCancel: () => {
28499 setShowCommentBoard(false);
28500 },
28501 submitButtonText: (0,external_wp_i18n_namespaceObject._x)('Comment', 'Add comment button')
28502 })]
28503 });
28504 }
28505
28506 ;// ./packages/editor/build-module/components/collab-sidebar/comment-button.js
28507 /**
28508 * WordPress dependencies
28509 */
28510
28511
28512
28513
28514
28515 /**
28516 * Internal dependencies
28517 */
28518
28519
28520 const {
28521 CommentIconSlotFill
28522 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
28523 const AddCommentButton = ({
28524 onClick
28525 }) => {
28526 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentIconSlotFill.Fill, {
28527 children: ({
28528 onClose
28529 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
28530 icon: library_comment,
28531 onClick: () => {
28532 onClick();
28533 onClose();
28534 },
28535 "aria-haspopup": "dialog",
28536 children: (0,external_wp_i18n_namespaceObject._x)('Comment', 'Add comment button')
28537 })
28538 });
28539 };
28540 /* harmony default export */ const comment_button = (AddCommentButton);
28541
28542 ;// ./packages/editor/build-module/components/collab-sidebar/comment-button-toolbar.js
28543 /**
28544 * WordPress dependencies
28545 */
28546
28547
28548
28549
28550
28551 /**
28552 * Internal dependencies
28553 */
28554
28555
28556 const {
28557 CommentIconToolbarSlotFill
28558 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
28559 const AddCommentToolbarButton = ({
28560 onClick
28561 }) => {
28562 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CommentIconToolbarSlotFill.Fill, {
28563 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, {
28564 accessibleWhenDisabled: true,
28565 icon: library_comment,
28566 label: (0,external_wp_i18n_namespaceObject._x)('Comment', 'View comment'),
28567 onClick: onClick
28568 })
28569 });
28570 };
28571 /* harmony default export */ const comment_button_toolbar = (AddCommentToolbarButton);
28572
28573 ;// ./packages/editor/build-module/components/collab-sidebar/index.js
28574 /* wp:polyfill */
28575 /**
28576 * WordPress dependencies
28577 */
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588 /**
28589 * Internal dependencies
28590 */
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601 const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
28602 const modifyBlockCommentAttributes = settings => {
28603 if (!settings.attributes.blockCommentId) {
28604 settings.attributes = {
28605 ...settings.attributes,
28606 blockCommentId: {
28607 type: 'number'
28608 }
28609 };
28610 }
28611 return settings;
28612 };
28613
28614 // Apply the filter to all core blocks
28615 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
28616 function CollabSidebarContent({
28617 showCommentBoard,
28618 setShowCommentBoard,
28619 styles,
28620 comments
28621 }) {
28622 const {
28623 createNotice
28624 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
28625 const {
28626 saveEntityRecord,
28627 deleteEntityRecord
28628 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
28629 const {
28630 getEntityRecord
28631 } = (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store);
28632 const {
28633 postId
28634 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28635 const {
28636 getCurrentPostId
28637 } = select(store_store);
28638 const _postId = getCurrentPostId();
28639 return {
28640 postId: _postId
28641 };
28642 }, []);
28643 const {
28644 getSelectedBlockClientId
28645 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
28646 const {
28647 updateBlockAttributes
28648 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
28649
28650 // Function to save the comment.
28651 const addNewComment = async (comment, parentCommentId) => {
28652 const args = {
28653 post: postId,
28654 content: comment,
28655 comment_type: 'block_comment',
28656 comment_approved: 0
28657 };
28658
28659 // Create a new object, conditionally including the parent property
28660 const updatedArgs = {
28661 ...args,
28662 ...(parentCommentId ? {
28663 parent: parentCommentId
28664 } : {})
28665 };
28666 const savedRecord = await saveEntityRecord('root', 'comment', updatedArgs);
28667 if (savedRecord) {
28668 // If it's a main comment, update the block attributes with the comment id.
28669 if (!parentCommentId) {
28670 updateBlockAttributes(getSelectedBlockClientId(), {
28671 blockCommentId: savedRecord?.id
28672 });
28673 }
28674 createNotice('snackbar', parentCommentId ?
28675 // translators: Reply added successfully
28676 (0,external_wp_i18n_namespaceObject.__)('Reply added successfully.') :
28677 // translators: Comment added successfully
28678 (0,external_wp_i18n_namespaceObject.__)('Comment added successfully.'), {
28679 type: 'snackbar',
28680 isDismissible: true
28681 });
28682 } else {
28683 onError();
28684 }
28685 };
28686 const onCommentResolve = async commentId => {
28687 const savedRecord = await saveEntityRecord('root', 'comment', {
28688 id: commentId,
28689 status: 'approved'
28690 });
28691 if (savedRecord) {
28692 // translators: Comment resolved successfully
28693 createNotice('snackbar', (0,external_wp_i18n_namespaceObject.__)('Comment marked as resolved.'), {
28694 type: 'snackbar',
28695 isDismissible: true
28696 });
28697 } else {
28698 onError();
28699 }
28700 };
28701 const onEditComment = async (commentId, comment) => {
28702 const savedRecord = await saveEntityRecord('root', 'comment', {
28703 id: commentId,
28704 content: comment
28705 });
28706 if (savedRecord) {
28707 createNotice('snackbar',
28708 // translators: Comment edited successfully
28709 (0,external_wp_i18n_namespaceObject.__)('Comment edited successfully.'), {
28710 type: 'snackbar',
28711 isDismissible: true
28712 });
28713 } else {
28714 onError();
28715 }
28716 };
28717 const onError = () => {
28718 createNotice('error',
28719 // translators: Error message when comment submission fails
28720 (0,external_wp_i18n_namespaceObject.__)('Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'), {
28721 isDismissible: true
28722 });
28723 };
28724 const onCommentDelete = async commentId => {
28725 const childComment = await getEntityRecord('root', 'comment', commentId);
28726 await deleteEntityRecord('root', 'comment', commentId);
28727 if (childComment && !childComment.parent) {
28728 updateBlockAttributes(getSelectedBlockClientId(), {
28729 blockCommentId: undefined
28730 });
28731 }
28732 createNotice('snackbar',
28733 // translators: Comment deleted successfully
28734 (0,external_wp_i18n_namespaceObject.__)('Comment deleted successfully.'), {
28735 type: 'snackbar',
28736 isDismissible: true
28737 });
28738 };
28739 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28740 className: "editor-collab-sidebar-panel",
28741 style: styles,
28742 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AddComment, {
28743 onSubmit: addNewComment,
28744 showCommentBoard: showCommentBoard,
28745 setShowCommentBoard: setShowCommentBoard
28746 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Comments, {
28747 threads: comments,
28748 onEditComment: onEditComment,
28749 onAddReply: addNewComment,
28750 onCommentDelete: onCommentDelete,
28751 onCommentResolve: onCommentResolve,
28752 showCommentBoard: showCommentBoard,
28753 setShowCommentBoard: setShowCommentBoard
28754 }, getSelectedBlockClientId())]
28755 });
28756 }
28757
28758 /**
28759 * Renders the Collab sidebar.
28760 */
28761 function CollabSidebar() {
28762 const [showCommentBoard, setShowCommentBoard] = (0,external_wp_element_namespaceObject.useState)(false);
28763 const {
28764 enableComplementaryArea
28765 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28766 const {
28767 getActiveComplementaryArea
28768 } = (0,external_wp_data_namespaceObject.useSelect)(store);
28769 const {
28770 postId,
28771 postType,
28772 postStatus,
28773 threads
28774 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28775 const {
28776 getCurrentPostId,
28777 getCurrentPostType
28778 } = select(store_store);
28779 const _postId = getCurrentPostId();
28780 const data = !!_postId && typeof _postId === 'number' ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('root', 'comment', {
28781 post: _postId,
28782 type: 'block_comment',
28783 status: 'any',
28784 per_page: 100
28785 }) : null;
28786 return {
28787 postId: _postId,
28788 postType: getCurrentPostType(),
28789 postStatus: select(store_store).getEditedPostAttribute('status'),
28790 threads: data
28791 };
28792 }, []);
28793 const {
28794 blockCommentId
28795 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28796 const {
28797 getBlockAttributes,
28798 getSelectedBlockClientId
28799 } = select(external_wp_blockEditor_namespaceObject.store);
28800 const _clientId = getSelectedBlockClientId();
28801 return {
28802 blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null
28803 };
28804 }, []);
28805 const openCollabBoard = () => {
28806 setShowCommentBoard(true);
28807 enableComplementaryArea('core', 'edit-post/collab-sidebar');
28808 };
28809 const [blocks] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType, {
28810 id: postId
28811 });
28812
28813 // Process comments to build the tree structure
28814 const {
28815 resultComments,
28816 sortedThreads
28817 } = (0,external_wp_element_namespaceObject.useMemo)(() => {
28818 // Create a compare to store the references to all objects by id
28819 const compare = {};
28820 const result = [];
28821 const filteredComments = (threads !== null && threads !== void 0 ? threads : []).filter(comment => comment.status !== 'trash');
28822
28823 // Initialize each object with an empty `reply` array
28824 filteredComments.forEach(item => {
28825 compare[item.id] = {
28826 ...item,
28827 reply: []
28828 };
28829 });
28830
28831 // Iterate over the data to build the tree structure
28832 filteredComments.forEach(item => {
28833 if (item.parent === 0) {
28834 // If parent is 0, it's a root item, push it to the result array
28835 result.push(compare[item.id]);
28836 } else if (compare[item.parent]) {
28837 // Otherwise, find its parent and push it to the parent's `reply` array
28838 compare[item.parent].reply.push(compare[item.id]);
28839 }
28840 });
28841 if (0 === result?.length) {
28842 return {
28843 resultComments: [],
28844 sortedThreads: []
28845 };
28846 }
28847 const updatedResult = result.map(item => ({
28848 ...item,
28849 reply: [...item.reply].reverse()
28850 }));
28851 const blockCommentIds = getCommentIdsFromBlocks(blocks);
28852 const threadIdMap = new Map(updatedResult.map(thread => [thread.id, thread]));
28853 const sortedComments = blockCommentIds.map(id => threadIdMap.get(id)).filter(thread => thread !== undefined);
28854 return {
28855 resultComments: updatedResult,
28856 sortedThreads: sortedComments
28857 };
28858 }, [threads, blocks]);
28859
28860 // Get the global styles to set the background color of the sidebar.
28861 const {
28862 merged: GlobalStyles
28863 } = useGlobalStylesContext();
28864 const backgroundColor = GlobalStyles?.styles?.color?.background;
28865 if (0 < resultComments.length) {
28866 const unsubscribe = (0,external_wp_data_namespaceObject.subscribe)(() => {
28867 const activeSidebar = getActiveComplementaryArea('core');
28868 if (!activeSidebar) {
28869 enableComplementaryArea('core', collabSidebarName);
28870 unsubscribe();
28871 }
28872 });
28873 }
28874
28875 // Check if the experimental flag is enabled.
28876 if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
28877 return null; // or maybe return some message indicating no threads are available.
28878 }
28879 const AddCommentComponent = blockCommentId ? comment_button_toolbar : comment_button;
28880 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28881 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AddCommentComponent, {
28882 onClick: openCollabBoard
28883 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
28884 identifier: collabHistorySidebarName
28885 // translators: Comments sidebar title
28886 ,
28887 title: (0,external_wp_i18n_namespaceObject.__)('Comments'),
28888 icon: library_comment,
28889 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollabSidebarContent, {
28890 comments: resultComments,
28891 showCommentBoard: showCommentBoard,
28892 setShowCommentBoard: setShowCommentBoard
28893 })
28894 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
28895 isPinnable: false,
28896 header: false,
28897 identifier: collabSidebarName,
28898 className: "editor-collab-sidebar",
28899 headerClassName: "editor-collab-sidebar__header",
28900 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollabSidebarContent, {
28901 comments: sortedThreads,
28902 showCommentBoard: showCommentBoard,
28903 setShowCommentBoard: setShowCommentBoard,
28904 styles: {
28905 backgroundColor
28906 }
28907 })
28908 })]
28909 });
28910 }
28911
28912 ;// ./packages/icons/build-module/library/next.js
28913 /**
28914 * WordPress dependencies
28915 */
28916
28917
28918 const next = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
28919 xmlns: "http://www.w3.org/2000/svg",
28920 viewBox: "0 0 24 24",
28921 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
28922 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"
28923 })
28924 });
28925 /* harmony default export */ const library_next = (next);
28926
28927 ;// ./packages/icons/build-module/library/previous.js
28928 /**
28929 * WordPress dependencies
28930 */
28931
28932
28933 const previous = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
28934 xmlns: "http://www.w3.org/2000/svg",
28935 viewBox: "0 0 24 24",
28936 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
28937 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"
28938 })
28939 });
28940 /* harmony default export */ const library_previous = (previous);
28941
28942 ;// ./packages/editor/build-module/components/collapsible-block-toolbar/index.js
28943 /**
28944 * External dependencies
28945 */
28946
28947
28948 /**
28949 * WordPress dependencies
28950 */
28951
28952
28953
28954
28955
28956
28957
28958 /**
28959 * Internal dependencies
28960 */
28961
28962
28963 const {
28964 useHasBlockToolbar
28965 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
28966 function CollapsibleBlockToolbar({
28967 isCollapsed,
28968 onToggle
28969 }) {
28970 const {
28971 blockSelectionStart
28972 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28973 return {
28974 blockSelectionStart: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
28975 };
28976 }, []);
28977 const hasBlockToolbar = useHasBlockToolbar();
28978 const hasBlockSelection = !!blockSelectionStart;
28979 (0,external_wp_element_namespaceObject.useEffect)(() => {
28980 // If we have a new block selection, show the block tools
28981 if (blockSelectionStart) {
28982 onToggle(false);
28983 }
28984 }, [blockSelectionStart, onToggle]);
28985 if (!hasBlockToolbar) {
28986 return null;
28987 }
28988 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28989 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
28990 className: dist_clsx('editor-collapsible-block-toolbar', {
28991 'is-collapsed': isCollapsed || !hasBlockSelection
28992 }),
28993 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
28994 hideDragHandle: true
28995 })
28996 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {
28997 name: "block-toolbar"
28998 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28999 className: "editor-collapsible-block-toolbar__toggle",
29000 icon: isCollapsed ? library_next : library_previous,
29001 onClick: () => {
29002 onToggle(!isCollapsed);
29003 },
29004 label: isCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools'),
29005 size: "compact"
29006 })]
29007 });
29008 }
29009
29010 ;// ./packages/icons/build-module/library/plus.js
29011 /**
29012 * WordPress dependencies
29013 */
29014
29015
29016 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
29017 xmlns: "http://www.w3.org/2000/svg",
29018 viewBox: "0 0 24 24",
29019 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
29020 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
29021 })
29022 });
29023 /* harmony default export */ const library_plus = (plus);
29024
29025 ;// ./packages/editor/build-module/components/document-tools/index.js
29026 /**
29027 * External dependencies
29028 */
29029
29030
29031 /**
29032 * WordPress dependencies
29033 */
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044 /**
29045 * Internal dependencies
29046 */
29047
29048
29049
29050
29051
29052 function DocumentTools({
29053 className,
29054 disableBlockTools = false
29055 }) {
29056 const {
29057 setIsInserterOpened,
29058 setIsListViewOpened
29059 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
29060 const {
29061 isDistractionFree,
29062 isInserterOpened,
29063 isListViewOpen,
29064 listViewShortcut,
29065 inserterSidebarToggleRef,
29066 listViewToggleRef,
29067 showIconLabels,
29068 showTools
29069 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29070 const {
29071 get
29072 } = select(external_wp_preferences_namespaceObject.store);
29073 const {
29074 isListViewOpened,
29075 getEditorMode,
29076 getInserterSidebarToggleRef,
29077 getListViewToggleRef,
29078 getRenderingMode,
29079 getCurrentPostType
29080 } = unlock(select(store_store));
29081 const {
29082 getShortcutRepresentation
29083 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
29084 return {
29085 isInserterOpened: select(store_store).isInserterOpened(),
29086 isListViewOpen: isListViewOpened(),
29087 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
29088 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
29089 listViewToggleRef: getListViewToggleRef(),
29090 showIconLabels: get('core', 'showIconLabels'),
29091 isDistractionFree: get('core', 'distractionFree'),
29092 isVisualMode: getEditorMode() === 'visual',
29093 showTools: !!window?.__experimentalEditorWriteMode && (getRenderingMode() !== 'post-only' || getCurrentPostType() === 'wp_template')
29094 };
29095 }, []);
29096 const preventDefault = event => {
29097 // Because the inserter behaves like a dialog,
29098 // if the inserter is opened already then when we click on the toggle button
29099 // then the initial click event will close the inserter and then be propagated
29100 // to the inserter toggle and it will open it again.
29101 // To prevent this we need to stop the propagation of the event.
29102 // This won't be necessary when the inserter no longer behaves like a dialog.
29103
29104 if (isInserterOpened) {
29105 event.preventDefault();
29106 }
29107 };
29108 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
29109 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
29110
29111 /* translators: accessibility text for the editor toolbar */
29112 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
29113 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
29114 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => setIsInserterOpened(!isInserterOpened), [isInserterOpened, setIsInserterOpened]);
29115
29116 /* translators: button label text should, if possible, be under 16 characters. */
29117 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Block Inserter', 'Generic label for block inserter button');
29118 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
29119 return (
29120 /*#__PURE__*/
29121 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
29122 // find the toolbar and inject UI elements into it. This is not officially
29123 // supported, but we're keeping it in the list of class names for backwards
29124 // compatibility.
29125 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
29126 className: dist_clsx('editor-document-tools', 'edit-post-header-toolbar', className),
29127 "aria-label": toolbarAriaLabel,
29128 variant: "unstyled",
29129 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
29130 className: "editor-document-tools__left",
29131 children: [!isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, {
29132 ref: inserterSidebarToggleRef,
29133 className: "editor-document-tools__inserter-toggle",
29134 variant: "primary",
29135 isPressed: isInserterOpened,
29136 onMouseDown: preventDefault,
29137 onClick: toggleInserter,
29138 disabled: disableBlockTools,
29139 icon: library_plus,
29140 label: showIconLabels ? shortLabel : longLabel,
29141 showTooltip: !showIconLabels,
29142 "aria-expanded": isInserterOpened
29143 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29144 children: [showTools && isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
29145 as: external_wp_blockEditor_namespaceObject.ToolSelector,
29146 showTooltip: !showIconLabels,
29147 variant: showIconLabels ? 'tertiary' : undefined,
29148 disabled: disableBlockTools,
29149 size: "compact"
29150 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
29151 as: editor_history_undo,
29152 showTooltip: !showIconLabels,
29153 variant: showIconLabels ? 'tertiary' : undefined,
29154 size: "compact"
29155 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
29156 as: editor_history_redo,
29157 showTooltip: !showIconLabels,
29158 variant: showIconLabels ? 'tertiary' : undefined,
29159 size: "compact"
29160 }), !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, {
29161 className: "editor-document-tools__document-overview-toggle",
29162 icon: list_view,
29163 disabled: disableBlockTools,
29164 isPressed: isListViewOpen
29165 /* translators: button label text should, if possible, be under 16 characters. */,
29166 label: (0,external_wp_i18n_namespaceObject.__)('Document Overview'),
29167 onClick: toggleListView,
29168 shortcut: listViewShortcut,
29169 showTooltip: !showIconLabels,
29170 variant: showIconLabels ? 'tertiary' : undefined,
29171 "aria-expanded": isListViewOpen,
29172 ref: listViewToggleRef
29173 })]
29174 })]
29175 })
29176 })
29177 );
29178 }
29179 /* harmony default export */ const document_tools = (DocumentTools);
29180
29181 ;// ./packages/editor/build-module/components/more-menu/copy-content-menu-item.js
29182 /**
29183 * WordPress dependencies
29184 */
29185
29186
29187
29188
29189
29190
29191
29192
29193 /**
29194 * Internal dependencies
29195 */
29196
29197
29198 function CopyContentMenuItem() {
29199 const {
29200 createNotice
29201 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
29202 const {
29203 getCurrentPostId,
29204 getCurrentPostType
29205 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
29206 const {
29207 getEditedEntityRecord
29208 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
29209 function getText() {
29210 const record = getEditedEntityRecord('postType', getCurrentPostType(), getCurrentPostId());
29211 if (!record) {
29212 return '';
29213 }
29214 if (typeof record.content === 'function') {
29215 return record.content(record);
29216 } else if (record.blocks) {
29217 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
29218 } else if (record.content) {
29219 return record.content;
29220 }
29221 }
29222 function onSuccess() {
29223 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
29224 isDismissible: true,
29225 type: 'snackbar'
29226 });
29227 }
29228 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
29229 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
29230 ref: ref,
29231 children: (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')
29232 });
29233 }
29234
29235 ;// ./packages/editor/build-module/components/mode-switcher/index.js
29236 /* wp:polyfill */
29237 /**
29238 * WordPress dependencies
29239 */
29240
29241
29242
29243
29244
29245 /**
29246 * Internal dependencies
29247 */
29248
29249
29250 /**
29251 * Set of available mode options.
29252 *
29253 * @type {Array}
29254 */
29255
29256 const MODES = [{
29257 value: 'visual',
29258 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
29259 }, {
29260 value: 'text',
29261 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
29262 }];
29263 function ModeSwitcher() {
29264 const {
29265 shortcut,
29266 isRichEditingEnabled,
29267 isCodeEditingEnabled,
29268 mode
29269 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
29270 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-mode'),
29271 isRichEditingEnabled: select(store_store).getEditorSettings().richEditingEnabled,
29272 isCodeEditingEnabled: select(store_store).getEditorSettings().codeEditingEnabled,
29273 mode: select(store_store).getEditorMode()
29274 }), []);
29275 const {
29276 switchEditorMode
29277 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
29278 let selectedMode = mode;
29279 if (!isRichEditingEnabled && mode === 'visual') {
29280 selectedMode = 'text';
29281 }
29282 if (!isCodeEditingEnabled && mode === 'text') {
29283 selectedMode = 'visual';
29284 }
29285 const choices = MODES.map(choice => {
29286 if (!isCodeEditingEnabled && choice.value === 'text') {
29287 choice = {
29288 ...choice,
29289 disabled: true
29290 };
29291 }
29292 if (!isRichEditingEnabled && choice.value === 'visual') {
29293 choice = {
29294 ...choice,
29295 disabled: true,
29296 info: (0,external_wp_i18n_namespaceObject.__)('You can enable the visual editor in your profile settings.')
29297 };
29298 }
29299 if (choice.value !== selectedMode && !choice.disabled) {
29300 return {
29301 ...choice,
29302 shortcut
29303 };
29304 }
29305 return choice;
29306 });
29307 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29308 label: (0,external_wp_i18n_namespaceObject.__)('Editor'),
29309 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
29310 choices: choices,
29311 value: selectedMode,
29312 onSelect: switchEditorMode
29313 })
29314 });
29315 }
29316 /* harmony default export */ const mode_switcher = (ModeSwitcher);
29317
29318 ;// ./packages/editor/build-module/components/more-menu/tools-more-menu-group.js
29319 /**
29320 * WordPress dependencies
29321 */
29322
29323
29324 const {
29325 Fill: ToolsMoreMenuGroup,
29326 Slot: tools_more_menu_group_Slot
29327 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
29328 ToolsMoreMenuGroup.Slot = ({
29329 fillProps
29330 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group_Slot, {
29331 fillProps: fillProps
29332 });
29333 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
29334
29335 ;// ./packages/editor/build-module/components/more-menu/view-more-menu-group.js
29336 /**
29337 * WordPress dependencies
29338 */
29339
29340
29341
29342 const {
29343 Fill: ViewMoreMenuGroup,
29344 Slot: view_more_menu_group_Slot
29345 } = (0,external_wp_components_namespaceObject.createSlotFill)(external_wp_element_namespaceObject.Platform.OS === 'web' ? Symbol('ViewMoreMenuGroup') : 'ViewMoreMenuGroup');
29346 ViewMoreMenuGroup.Slot = ({
29347 fillProps
29348 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group_Slot, {
29349 fillProps: fillProps
29350 });
29351 /* harmony default export */ const view_more_menu_group = (ViewMoreMenuGroup);
29352
29353 ;// ./packages/editor/build-module/components/more-menu/index.js
29354 /**
29355 * WordPress dependencies
29356 */
29357
29358
29359
29360
29361
29362
29363
29364
29365 /**
29366 * Internal dependencies
29367 */
29368
29369
29370
29371
29372
29373
29374 function MoreMenu() {
29375 const {
29376 openModal
29377 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
29378 const {
29379 set: setPreference
29380 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
29381 const {
29382 toggleDistractionFree
29383 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
29384 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'), []);
29385 const turnOffDistractionFree = () => {
29386 setPreference('core', 'distractionFree', false);
29387 };
29388 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29389 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
29390 icon: more_vertical,
29391 label: (0,external_wp_i18n_namespaceObject.__)('Options'),
29392 popoverProps: {
29393 placement: 'bottom-end',
29394 className: 'more-menu-dropdown__content'
29395 },
29396 toggleProps: {
29397 showTooltip: !showIconLabels,
29398 ...(showIconLabels && {
29399 variant: 'tertiary'
29400 }),
29401 tooltipPosition: 'bottom',
29402 size: 'compact'
29403 },
29404 children: ({
29405 onClose
29406 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29407 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
29408 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'),
29409 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
29410 scope: "core",
29411 name: "fixedToolbar",
29412 onToggle: turnOffDistractionFree,
29413 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
29414 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
29415 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated.'),
29416 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated.')
29417 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
29418 scope: "core",
29419 name: "distractionFree",
29420 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'),
29421 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'),
29422 handleToggling: false,
29423 onToggle: () => toggleDistractionFree({
29424 createNotice: false
29425 }),
29426 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated.'),
29427 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated.'),
29428 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\')
29429 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
29430 scope: "core",
29431 name: "focusMode",
29432 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
29433 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
29434 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated.'),
29435 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated.')
29436 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group.Slot, {
29437 fillProps: {
29438 onClose
29439 }
29440 })]
29441 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(mode_switcher, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
29442 name: "core/plugin-more-menu",
29443 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
29444 fillProps: {
29445 onClick: onClose
29446 }
29447 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
29448 label: (0,external_wp_i18n_namespaceObject.__)('Tools'),
29449 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
29450 onClick: () => openModal('editor/keyboard-shortcut-help'),
29451 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'),
29452 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')
29453 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyContentMenuItem, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
29454 icon: library_external,
29455 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'),
29456 target: "_blank",
29457 rel: "noopener noreferrer",
29458 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
29459 as: "span",
29460 children: /* translators: accessibility text */
29461 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
29462 })]
29463 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group.Slot, {
29464 fillProps: {
29465 onClose
29466 }
29467 })]
29468 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29469 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
29470 onClick: () => openModal('editor/preferences'),
29471 children: (0,external_wp_i18n_namespaceObject.__)('Preferences')
29472 })
29473 })]
29474 })
29475 })
29476 });
29477 }
29478
29479 ;// ./packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js
29480 /**
29481 * WordPress dependencies
29482 */
29483
29484
29485
29486 /**
29487 * Internal dependencies
29488 */
29489
29490
29491
29492 const IS_TOGGLE = 'toggle';
29493 const IS_BUTTON = 'button';
29494 function PostPublishButtonOrToggle({
29495 forceIsDirty,
29496 setEntitiesSavedStatesCallback
29497 }) {
29498 let component;
29499 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
29500 const {
29501 togglePublishSidebar
29502 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
29503 const {
29504 hasPublishAction,
29505 isBeingScheduled,
29506 isPending,
29507 isPublished,
29508 isPublishSidebarEnabled,
29509 isPublishSidebarOpened,
29510 isScheduled,
29511 postStatus,
29512 postStatusHasChanged
29513 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29514 var _select$getCurrentPos;
29515 return {
29516 hasPublishAction: (_select$getCurrentPos = !!select(store_store).getCurrentPost()?._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false,
29517 isBeingScheduled: select(store_store).isEditedPostBeingScheduled(),
29518 isPending: select(store_store).isCurrentPostPending(),
29519 isPublished: select(store_store).isCurrentPostPublished(),
29520 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled(),
29521 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
29522 isScheduled: select(store_store).isCurrentPostScheduled(),
29523 postStatus: select(store_store).getEditedPostAttribute('status'),
29524 postStatusHasChanged: select(store_store).getPostEdits()?.status
29525 };
29526 }, []);
29527
29528 /**
29529 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
29530 *
29531 * 1) We want to show a BUTTON when the post status is at the _final stage_
29532 * for a particular role (see https://wordpress.org/documentation/article/post-status/):
29533 *
29534 * - is published
29535 * - post status has changed explicitely to something different than 'future' or 'publish'
29536 * - is scheduled to be published
29537 * - is pending and can't be published (but only for viewports >= medium).
29538 * Originally, we considered showing a button for pending posts that couldn't be published
29539 * (for example, for an author with the contributor role). Some languages can have
29540 * long translations for "Submit for review", so given the lack of UI real estate available
29541 * we decided to take into account the viewport in that case.
29542 * See: https://github.com/WordPress/gutenberg/issues/10475
29543 *
29544 * 2) Then, in small viewports, we'll show a TOGGLE.
29545 *
29546 * 3) Finally, we'll use the publish sidebar status to decide:
29547 *
29548 * - if it is enabled, we show a TOGGLE
29549 * - if it is disabled, we show a BUTTON
29550 */
29551 if (isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
29552 component = IS_BUTTON;
29553 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled) {
29554 component = IS_TOGGLE;
29555 } else {
29556 component = IS_BUTTON;
29557 }
29558 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
29559 forceIsDirty: forceIsDirty,
29560 isOpen: isPublishSidebarOpened,
29561 isToggle: component === IS_TOGGLE,
29562 onToggle: togglePublishSidebar,
29563 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
29564 });
29565 }
29566
29567 ;// ./packages/editor/build-module/components/post-view-link/index.js
29568 /**
29569 * WordPress dependencies
29570 */
29571
29572
29573
29574
29575
29576
29577
29578 /**
29579 * Internal dependencies
29580 */
29581
29582
29583 function PostViewLink() {
29584 const {
29585 hasLoaded,
29586 permalink,
29587 isPublished,
29588 label,
29589 showIconLabels
29590 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29591 // Grab post type to retrieve the view_item label.
29592 const postTypeSlug = select(store_store).getCurrentPostType();
29593 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
29594 const {
29595 get
29596 } = select(external_wp_preferences_namespaceObject.store);
29597 return {
29598 permalink: select(store_store).getPermalink(),
29599 isPublished: select(store_store).isCurrentPostPublished(),
29600 label: postType?.labels.view_item,
29601 hasLoaded: !!postType,
29602 showIconLabels: get('core', 'showIconLabels')
29603 };
29604 }, []);
29605
29606 // Only render the view button if the post is published and has a permalink.
29607 if (!isPublished || !permalink || !hasLoaded) {
29608 return null;
29609 }
29610 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29611 icon: library_external,
29612 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'),
29613 href: permalink,
29614 target: "_blank",
29615 showTooltip: !showIconLabels,
29616 size: "compact"
29617 });
29618 }
29619
29620 ;// ./packages/icons/build-module/library/desktop.js
29621 /**
29622 * WordPress dependencies
29623 */
29624
29625
29626 const desktop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
29627 xmlns: "http://www.w3.org/2000/svg",
29628 viewBox: "0 0 24 24",
29629 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
29630 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"
29631 })
29632 });
29633 /* harmony default export */ const library_desktop = (desktop);
29634
29635 ;// ./packages/icons/build-module/library/mobile.js
29636 /**
29637 * WordPress dependencies
29638 */
29639
29640
29641 const mobile = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
29642 xmlns: "http://www.w3.org/2000/svg",
29643 viewBox: "0 0 24 24",
29644 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
29645 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"
29646 })
29647 });
29648 /* harmony default export */ const library_mobile = (mobile);
29649
29650 ;// ./packages/icons/build-module/library/tablet.js
29651 /**
29652 * WordPress dependencies
29653 */
29654
29655
29656 const tablet = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
29657 xmlns: "http://www.w3.org/2000/svg",
29658 viewBox: "0 0 24 24",
29659 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
29660 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"
29661 })
29662 });
29663 /* harmony default export */ const library_tablet = (tablet);
29664
29665 ;// ./packages/editor/build-module/components/preview-dropdown/index.js
29666 /**
29667 * External dependencies
29668 */
29669
29670
29671 /**
29672 * WordPress dependencies
29673 */
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683 /**
29684 * Internal dependencies
29685 */
29686
29687
29688
29689
29690
29691 function PreviewDropdown({
29692 forceIsAutosaveable,
29693 disabled
29694 }) {
29695 const {
29696 deviceType,
29697 homeUrl,
29698 isTemplate,
29699 isViewable,
29700 showIconLabels,
29701 isTemplateHidden,
29702 templateId
29703 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29704 var _getPostType$viewable;
29705 const {
29706 getDeviceType,
29707 getCurrentPostType,
29708 getCurrentTemplateId
29709 } = select(store_store);
29710 const {
29711 getRenderingMode
29712 } = unlock(select(store_store));
29713 const {
29714 getEntityRecord,
29715 getPostType
29716 } = select(external_wp_coreData_namespaceObject.store);
29717 const {
29718 get
29719 } = select(external_wp_preferences_namespaceObject.store);
29720 const _currentPostType = getCurrentPostType();
29721 return {
29722 deviceType: getDeviceType(),
29723 homeUrl: getEntityRecord('root', '__unstableBase')?.home,
29724 isTemplate: _currentPostType === 'wp_template',
29725 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
29726 showIconLabels: get('core', 'showIconLabels'),
29727 isTemplateHidden: getRenderingMode() === 'post-only',
29728 templateId: getCurrentTemplateId()
29729 };
29730 }, []);
29731 const {
29732 setDeviceType,
29733 setRenderingMode
29734 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
29735 const {
29736 resetZoomLevel
29737 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
29738 const handleDevicePreviewChange = newDeviceType => {
29739 setDeviceType(newDeviceType);
29740 resetZoomLevel();
29741 };
29742 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
29743 if (isMobile) {
29744 return null;
29745 }
29746 const popoverProps = {
29747 placement: 'bottom-end'
29748 };
29749 const toggleProps = {
29750 className: 'editor-preview-dropdown__toggle',
29751 iconPosition: 'right',
29752 size: 'compact',
29753 showTooltip: !showIconLabels,
29754 disabled,
29755 accessibleWhenDisabled: disabled
29756 };
29757 const menuProps = {
29758 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
29759 };
29760 const deviceIcons = {
29761 desktop: library_desktop,
29762 mobile: library_mobile,
29763 tablet: library_tablet
29764 };
29765
29766 /**
29767 * The choices for the device type.
29768 *
29769 * @type {Array}
29770 */
29771 const choices = [{
29772 value: 'Desktop',
29773 label: (0,external_wp_i18n_namespaceObject.__)('Desktop'),
29774 icon: library_desktop
29775 }, {
29776 value: 'Tablet',
29777 label: (0,external_wp_i18n_namespaceObject.__)('Tablet'),
29778 icon: library_tablet
29779 }, {
29780 value: 'Mobile',
29781 label: (0,external_wp_i18n_namespaceObject.__)('Mobile'),
29782 icon: library_mobile
29783 }];
29784 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
29785 className: dist_clsx('editor-preview-dropdown', `editor-preview-dropdown--${deviceType.toLowerCase()}`),
29786 popoverProps: popoverProps,
29787 toggleProps: toggleProps,
29788 menuProps: menuProps,
29789 icon: deviceIcons[deviceType.toLowerCase()],
29790 label: (0,external_wp_i18n_namespaceObject.__)('View'),
29791 disableOpenOnArrowDown: disabled,
29792 children: ({
29793 onClose
29794 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29795 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29796 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
29797 choices: choices,
29798 value: deviceType,
29799 onSelect: handleDevicePreviewChange
29800 })
29801 }), isTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29802 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
29803 href: homeUrl,
29804 target: "_blank",
29805 icon: library_external,
29806 onClick: onClose,
29807 children: [(0,external_wp_i18n_namespaceObject.__)('View site'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
29808 as: "span",
29809 children: /* translators: accessibility text */
29810 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
29811 })]
29812 })
29813 }), !isTemplate && !!templateId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29814 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
29815 icon: !isTemplateHidden ? library_check : undefined,
29816 isSelected: !isTemplateHidden,
29817 role: "menuitemcheckbox",
29818 onClick: () => {
29819 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
29820 },
29821 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
29822 })
29823 }), isViewable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
29824 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
29825 className: "editor-preview-dropdown__button-external",
29826 role: "menuitem",
29827 forceIsAutosaveable: forceIsAutosaveable,
29828 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Preview in new tab'),
29829 textContent: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
29830 children: [(0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
29831 icon: library_external
29832 })]
29833 }),
29834 onPreview: onClose
29835 })
29836 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
29837 name: "core/plugin-preview-menu",
29838 fillProps: {
29839 onClick: onClose
29840 }
29841 })]
29842 })
29843 });
29844 }
29845
29846 ;// ./packages/icons/build-module/library/square.js
29847 /**
29848 * WordPress dependencies
29849 */
29850
29851
29852 const square = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
29853 xmlns: "http://www.w3.org/2000/svg",
29854 viewBox: "0 0 24 24",
29855 fill: "none",
29856 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
29857 fill: "none",
29858 d: "M5.75 12.75V18.25H11.25M12.75 5.75H18.25V11.25",
29859 stroke: "currentColor",
29860 strokeWidth: "1.5",
29861 strokeLinecap: "square"
29862 })
29863 });
29864 /* harmony default export */ const library_square = (square);
29865
29866 ;// ./packages/editor/build-module/components/zoom-out-toggle/index.js
29867 /**
29868 * WordPress dependencies
29869 */
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880 /**
29881 * Internal dependencies
29882 */
29883
29884
29885 const ZoomOutToggle = ({
29886 disabled
29887 }) => {
29888 const {
29889 isZoomOut,
29890 showIconLabels,
29891 isDistractionFree
29892 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
29893 isZoomOut: unlock(select(external_wp_blockEditor_namespaceObject.store)).isZoomOut(),
29894 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'),
29895 isDistractionFree: select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree')
29896 }));
29897 const {
29898 resetZoomLevel,
29899 setZoomLevel
29900 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
29901 const {
29902 registerShortcut,
29903 unregisterShortcut
29904 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
29905 (0,external_wp_element_namespaceObject.useEffect)(() => {
29906 registerShortcut({
29907 name: 'core/editor/zoom',
29908 category: 'global',
29909 description: (0,external_wp_i18n_namespaceObject.__)('Enter or exit zoom out.'),
29910 keyCombination: {
29911 // `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching
29912 // to input mode in Windows, so apply a different key combination.
29913 modifier: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? 'primaryShift' : 'secondary',
29914 character: '0'
29915 }
29916 });
29917 return () => {
29918 unregisterShortcut('core/editor/zoom');
29919 };
29920 }, [registerShortcut, unregisterShortcut]);
29921 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/zoom', () => {
29922 if (isZoomOut) {
29923 resetZoomLevel();
29924 } else {
29925 setZoomLevel('auto-scaled');
29926 }
29927 }, {
29928 isDisabled: isDistractionFree
29929 });
29930 const handleZoomOut = () => {
29931 if (isZoomOut) {
29932 resetZoomLevel();
29933 } else {
29934 setZoomLevel('auto-scaled');
29935 }
29936 };
29937 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
29938 accessibleWhenDisabled: true,
29939 disabled: disabled,
29940 onClick: handleZoomOut,
29941 icon: library_square,
29942 label: (0,external_wp_i18n_namespaceObject.__)('Zoom Out'),
29943 isPressed: isZoomOut,
29944 size: "compact",
29945 showTooltip: !showIconLabels,
29946 className: "editor-zoom-out-toggle"
29947 });
29948 };
29949 /* harmony default export */ const zoom_out_toggle = (ZoomOutToggle);
29950
29951 ;// ./packages/editor/build-module/components/header/index.js
29952 /**
29953 * WordPress dependencies
29954 */
29955
29956
29957
29958
29959
29960
29961
29962
29963 /**
29964 * Internal dependencies
29965 */
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982 const toolbarVariations = {
29983 distractionFreeDisabled: {
29984 y: '-50px'
29985 },
29986 distractionFreeHover: {
29987 y: 0
29988 },
29989 distractionFreeHidden: {
29990 y: '-50px'
29991 },
29992 visible: {
29993 y: 0
29994 },
29995 hidden: {
29996 y: 0
29997 }
29998 };
29999 const backButtonVariations = {
30000 distractionFreeDisabled: {
30001 x: '-100%'
30002 },
30003 distractionFreeHover: {
30004 x: 0
30005 },
30006 distractionFreeHidden: {
30007 x: '-100%'
30008 },
30009 visible: {
30010 x: 0
30011 },
30012 hidden: {
30013 x: 0
30014 }
30015 };
30016 function header_Header({
30017 customSaveButton,
30018 forceIsDirty,
30019 forceDisableBlockTools,
30020 setEntitiesSavedStatesCallback,
30021 title
30022 }) {
30023 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
30024 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
30025 const isTooNarrowForDocumentBar = (0,external_wp_compose_namespaceObject.useMediaQuery)('(max-width: 403px)');
30026 const {
30027 postType,
30028 isTextEditor,
30029 isPublishSidebarOpened,
30030 showIconLabels,
30031 hasFixedToolbar,
30032 hasBlockSelection
30033 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30034 const {
30035 get: getPreference
30036 } = select(external_wp_preferences_namespaceObject.store);
30037 const {
30038 getEditorMode,
30039 getCurrentPostType,
30040 isPublishSidebarOpened: _isPublishSidebarOpened
30041 } = select(store_store);
30042 return {
30043 postType: getCurrentPostType(),
30044 isTextEditor: getEditorMode() === 'text',
30045 isPublishSidebarOpened: _isPublishSidebarOpened(),
30046 showIconLabels: getPreference('core', 'showIconLabels'),
30047 hasFixedToolbar: getPreference('core', 'fixedToolbar'),
30048 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
30049 };
30050 }, []);
30051 const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType);
30052 const disablePreviewOption = [NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType);
30053 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true);
30054 const hasCenter = !isTooNarrowForDocumentBar && (!hasFixedToolbar || hasFixedToolbar && (!hasBlockSelection || isBlockToolsCollapsed));
30055 const hasBackButton = useHasBackButton();
30056 const hasSectionRootClientId = (0,external_wp_data_namespaceObject.useSelect)(select => !!unlock(select(external_wp_blockEditor_namespaceObject.store)).getSectionRootClientId(), []);
30057
30058 /*
30059 * The edit-post-header classname is only kept for backward compatability
30060 * as some plugins might be relying on its presence.
30061 */
30062 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30063 className: "editor-header edit-post-header",
30064 children: [hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
30065 className: "editor-header__back-button",
30066 variants: backButtonVariations,
30067 transition: {
30068 type: 'tween'
30069 },
30070 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button.Slot, {})
30071 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
30072 variants: toolbarVariations,
30073 className: "editor-header__toolbar",
30074 transition: {
30075 type: 'tween'
30076 },
30077 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_tools, {
30078 disableBlockTools: forceDisableBlockTools || isTextEditor
30079 }), hasFixedToolbar && isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollapsibleBlockToolbar, {
30080 isCollapsed: isBlockToolsCollapsed,
30081 onToggle: setIsBlockToolsCollapsed
30082 })]
30083 }), hasCenter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
30084 className: "editor-header__center",
30085 variants: toolbarVariations,
30086 transition: {
30087 type: 'tween'
30088 },
30089 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentBar, {
30090 title: title
30091 })
30092 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
30093 variants: toolbarVariations,
30094 transition: {
30095 type: 'tween'
30096 },
30097 className: "editor-header__settings",
30098 children: [!customSaveButton && !isPublishSidebarOpened &&
30099 /*#__PURE__*/
30100 /*
30101 * This button isn't completely hidden by the publish sidebar.
30102 * We can't hide the whole toolbar when the publish sidebar is open because
30103 * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
30104 * We track that DOM node to return focus to the PostPublishButtonOrToggle
30105 * when the publish sidebar has been closed.
30106 */
30107 (0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSavedState, {
30108 forceIsDirty: forceIsDirty
30109 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostViewLink, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewDropdown, {
30110 forceIsAutosaveable: forceIsDirty,
30111 disabled: disablePreviewOption
30112 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
30113 className: "editor-header__post-preview-button",
30114 forceIsAutosaveable: forceIsDirty
30115 }), canBeZoomedOut && isWideViewport && hasSectionRootClientId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(zoom_out_toggle, {
30116 disabled: forceDisableBlockTools
30117 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items.Slot, {
30118 scope: "core"
30119 }), !customSaveButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishButtonOrToggle, {
30120 forceIsDirty: forceIsDirty,
30121 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
30122 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollabSidebar, {}), customSaveButton, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})]
30123 })]
30124 });
30125 }
30126 /* harmony default export */ const components_header = (header_Header);
30127
30128 ;// ./packages/editor/build-module/components/inserter-sidebar/index.js
30129 /**
30130 * WordPress dependencies
30131 */
30132
30133
30134
30135
30136
30137
30138
30139
30140 /**
30141 * Internal dependencies
30142 */
30143
30144
30145
30146 const {
30147 PrivateInserterLibrary
30148 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
30149 function InserterSidebar() {
30150 const {
30151 blockSectionRootClientId,
30152 inserterSidebarToggleRef,
30153 inserter,
30154 showMostUsedBlocks,
30155 sidebarIsOpened
30156 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30157 const {
30158 getInserterSidebarToggleRef,
30159 getInserter,
30160 isPublishSidebarOpened
30161 } = unlock(select(store_store));
30162 const {
30163 getBlockRootClientId,
30164 isZoomOut,
30165 getSectionRootClientId
30166 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
30167 const {
30168 get
30169 } = select(external_wp_preferences_namespaceObject.store);
30170 const {
30171 getActiveComplementaryArea
30172 } = select(store);
30173 const getBlockSectionRootClientId = () => {
30174 if (isZoomOut()) {
30175 const sectionRootClientId = getSectionRootClientId();
30176 if (sectionRootClientId) {
30177 return sectionRootClientId;
30178 }
30179 }
30180 return getBlockRootClientId();
30181 };
30182 return {
30183 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
30184 inserter: getInserter(),
30185 showMostUsedBlocks: get('core', 'mostUsedBlocks'),
30186 blockSectionRootClientId: getBlockSectionRootClientId(),
30187 sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
30188 };
30189 }, []);
30190 const {
30191 setIsInserterOpened
30192 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
30193 const {
30194 disableComplementaryArea
30195 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30196 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
30197 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
30198
30199 // When closing the inserter, focus should return to the toggle button.
30200 const closeInserterSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
30201 setIsInserterOpened(false);
30202 inserterSidebarToggleRef.current?.focus();
30203 }, [inserterSidebarToggleRef, setIsInserterOpened]);
30204 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
30205 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
30206 event.preventDefault();
30207 closeInserterSidebar();
30208 }
30209 }, [closeInserterSidebar]);
30210 const inserterContents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30211 className: "editor-inserter-sidebar__content",
30212 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
30213 showMostUsedBlocks: showMostUsedBlocks,
30214 showInserterHelpPanel: true,
30215 shouldFocusBlock: isMobileViewport,
30216 rootClientId: blockSectionRootClientId,
30217 onSelect: inserter.onSelect,
30218 __experimentalInitialTab: inserter.tab,
30219 __experimentalInitialCategory: inserter.category,
30220 __experimentalFilterValue: inserter.filterValue,
30221 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
30222 ref: libraryRef,
30223 onClose: closeInserterSidebar
30224 })
30225 });
30226 return (
30227 /*#__PURE__*/
30228 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
30229 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30230 onKeyDown: closeOnEscape,
30231 className: "editor-inserter-sidebar",
30232 children: inserterContents
30233 })
30234 );
30235 }
30236
30237 ;// ./packages/editor/build-module/components/list-view-sidebar/list-view-outline.js
30238 /**
30239 * WordPress dependencies
30240 */
30241
30242
30243
30244 /**
30245 * Internal dependencies
30246 */
30247
30248
30249
30250
30251
30252 function ListViewOutline() {
30253 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30254 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30255 className: "editor-list-view-sidebar__outline",
30256 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30257 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
30258 children: (0,external_wp_i18n_namespaceObject.__)('Characters:')
30259 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
30260 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
30261 })]
30262 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30263 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
30264 children: (0,external_wp_i18n_namespaceObject.__)('Words:')
30265 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
30266 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30267 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
30268 children: (0,external_wp_i18n_namespaceObject.__)('Time to read:')
30269 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
30270 })]
30271 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {})]
30272 });
30273 }
30274
30275 ;// ./packages/editor/build-module/components/list-view-sidebar/index.js
30276 /* wp:polyfill */
30277 /**
30278 * WordPress dependencies
30279 */
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289 /**
30290 * Internal dependencies
30291 */
30292
30293
30294
30295
30296 const {
30297 TabbedSidebar
30298 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
30299 function ListViewSidebar() {
30300 const {
30301 setIsListViewOpened
30302 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
30303 const {
30304 getListViewToggleRef
30305 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store));
30306
30307 // This hook handles focus when the sidebar first renders.
30308 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
30309
30310 // When closing the list view, focus should return to the toggle button.
30311 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => {
30312 setIsListViewOpened(false);
30313 getListViewToggleRef().current?.focus();
30314 }, [getListViewToggleRef, setIsListViewOpened]);
30315 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
30316 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
30317 event.preventDefault();
30318 closeListView();
30319 }
30320 }, [closeListView]);
30321
30322 // Use internal state instead of a ref to make sure that the component
30323 // re-renders when the dropZoneElement updates.
30324 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null);
30325 // Tracks our current tab.
30326 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view');
30327
30328 // This ref refers to the sidebar as a whole.
30329 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)();
30330 // This ref refers to the tab panel.
30331 const tabsRef = (0,external_wp_element_namespaceObject.useRef)();
30332 // This ref refers to the list view application area.
30333 const listViewRef = (0,external_wp_element_namespaceObject.useRef)();
30334
30335 // Must merge the refs together so focus can be handled properly in the next function.
30336 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]);
30337
30338 /*
30339 * Callback function to handle list view or outline focus.
30340 *
30341 * @param {string} currentTab The current tab. Either list view or outline.
30342 *
30343 * @return void
30344 */
30345 function handleSidebarFocus(currentTab) {
30346 // Tab panel focus.
30347 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0];
30348 // List view tab is selected.
30349 if (currentTab === 'list-view') {
30350 // 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.
30351 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0];
30352 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus;
30353 listViewFocusArea.focus();
30354 // Outline tab is selected.
30355 } else {
30356 tabPanelFocus.focus();
30357 }
30358 }
30359 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => {
30360 // If the sidebar has focus, it is safe to close.
30361 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
30362 closeListView();
30363 } else {
30364 // If the list view or outline does not have focus, focus should be moved to it.
30365 handleSidebarFocus(tab);
30366 }
30367 }, [closeListView, tab]);
30368
30369 // This only fires when the sidebar is open because of the conditional rendering.
30370 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
30371 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut);
30372 return (
30373 /*#__PURE__*/
30374 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
30375 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30376 className: "editor-list-view-sidebar",
30377 onKeyDown: closeOnEscape,
30378 ref: sidebarRef,
30379 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TabbedSidebar, {
30380 tabs: [{
30381 name: 'list-view',
30382 title: (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview'),
30383 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30384 className: "editor-list-view-sidebar__list-view-container",
30385 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30386 className: "editor-list-view-sidebar__list-view-panel-content",
30387 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
30388 dropZoneElement: dropZoneElement
30389 })
30390 })
30391 }),
30392 panelRef: listViewContainerRef
30393 }, {
30394 name: 'outline',
30395 title: (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview'),
30396 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30397 className: "editor-list-view-sidebar__list-view-container",
30398 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewOutline, {})
30399 })
30400 }],
30401 onClose: closeListView,
30402 onSelect: tabName => setTab(tabName),
30403 defaultTabId: "list-view",
30404 ref: tabsRef,
30405 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close')
30406 })
30407 })
30408 );
30409 }
30410
30411 ;// ./packages/editor/build-module/components/save-publish-panels/index.js
30412 /**
30413 * WordPress dependencies
30414 */
30415
30416
30417
30418
30419
30420 /**
30421 * Internal dependencies
30422 */
30423
30424
30425
30426
30427
30428
30429 const {
30430 Fill: save_publish_panels_Fill,
30431 Slot: save_publish_panels_Slot
30432 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
30433 const ActionsPanelFill = (/* unused pure expression or super */ null && (save_publish_panels_Fill));
30434 function SavePublishPanels({
30435 setEntitiesSavedStatesCallback,
30436 closeEntitiesSavedStates,
30437 isEntitiesSavedStatesOpen,
30438 forceIsDirtyPublishPanel
30439 }) {
30440 const {
30441 closePublishSidebar,
30442 togglePublishSidebar
30443 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
30444 const {
30445 publishSidebarOpened,
30446 isPublishable,
30447 isDirty,
30448 hasOtherEntitiesChanges
30449 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30450 const {
30451 isPublishSidebarOpened,
30452 isEditedPostPublishable,
30453 isCurrentPostPublished,
30454 isEditedPostDirty,
30455 hasNonPostEntityChanges
30456 } = select(store_store);
30457 const _hasOtherEntitiesChanges = hasNonPostEntityChanges();
30458 return {
30459 publishSidebarOpened: isPublishSidebarOpened(),
30460 isPublishable: !isCurrentPostPublished() && isEditedPostPublishable(),
30461 isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
30462 hasOtherEntitiesChanges: _hasOtherEntitiesChanges
30463 };
30464 }, []);
30465 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []);
30466
30467 // It is ok for these components to be unmounted when not in visual use.
30468 // We don't want more than one present at a time, decide which to render.
30469 let unmountableContent;
30470 if (publishSidebarOpened) {
30471 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_panel, {
30472 onClose: closePublishSidebar,
30473 forceIsDirty: forceIsDirtyPublishPanel,
30474 PrePublishExtension: plugin_pre_publish_panel.Slot,
30475 PostPublishExtension: plugin_post_publish_panel.Slot
30476 });
30477 } else if (isPublishable && !hasOtherEntitiesChanges) {
30478 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30479 className: "editor-layout__toggle-publish-panel",
30480 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
30481 __next40pxDefaultSize: true,
30482 variant: "secondary",
30483 onClick: togglePublishSidebar,
30484 "aria-expanded": false,
30485 children: (0,external_wp_i18n_namespaceObject.__)('Open publish panel')
30486 })
30487 });
30488 } else {
30489 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
30490 className: "editor-layout__toggle-entities-saved-states-panel",
30491 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
30492 __next40pxDefaultSize: true,
30493 variant: "secondary",
30494 onClick: openEntitiesSavedStates,
30495 "aria-expanded": false,
30496 "aria-haspopup": "dialog",
30497 disabled: !isDirty,
30498 accessibleWhenDisabled: true,
30499 children: (0,external_wp_i18n_namespaceObject.__)('Open save panel')
30500 })
30501 });
30502 }
30503
30504 // Since EntitiesSavedStates controls its own panel, we can keep it
30505 // always mounted to retain its own component state (such as checkboxes).
30506 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30507 children: [isEntitiesSavedStatesOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStates, {
30508 close: closeEntitiesSavedStates,
30509 renderDialog: true
30510 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(save_publish_panels_Slot, {
30511 bubblesVirtually: true
30512 }), !isEntitiesSavedStatesOpen && unmountableContent]
30513 });
30514 }
30515
30516 ;// ./packages/editor/build-module/components/text-editor/index.js
30517 /**
30518 * WordPress dependencies
30519 */
30520
30521
30522
30523
30524
30525
30526 /**
30527 * Internal dependencies
30528 */
30529
30530
30531
30532
30533 function TextEditor({
30534 autoFocus = false
30535 }) {
30536 const {
30537 switchEditorMode
30538 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
30539 const {
30540 shortcut,
30541 isRichEditingEnabled
30542 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30543 const {
30544 getEditorSettings
30545 } = select(store_store);
30546 const {
30547 getShortcutRepresentation
30548 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
30549 return {
30550 shortcut: getShortcutRepresentation('core/editor/toggle-mode'),
30551 isRichEditingEnabled: getEditorSettings().richEditingEnabled
30552 };
30553 }, []);
30554 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
30555 (0,external_wp_element_namespaceObject.useEffect)(() => {
30556 if (autoFocus) {
30557 return;
30558 }
30559 titleRef?.current?.focus();
30560 }, [autoFocus]);
30561 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30562 className: "editor-text-editor",
30563 children: [isRichEditingEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30564 className: "editor-text-editor__toolbar",
30565 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
30566 children: (0,external_wp_i18n_namespaceObject.__)('Editing code')
30567 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
30568 __next40pxDefaultSize: true,
30569 variant: "tertiary",
30570 onClick: () => switchEditorMode('visual'),
30571 shortcut: shortcut,
30572 children: (0,external_wp_i18n_namespaceObject.__)('Exit code editor')
30573 })]
30574 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
30575 className: "editor-text-editor__body",
30576 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title_raw, {
30577 ref: titleRef
30578 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTextEditor, {})]
30579 })]
30580 });
30581 }
30582
30583 ;// ./packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js
30584 /**
30585 * WordPress dependencies
30586 */
30587
30588
30589
30590
30591
30592
30593 /**
30594 * Internal dependencies
30595 */
30596
30597
30598 /**
30599 * Component that:
30600 *
30601 * - Displays a 'Edit your template to edit this block' notification when the
30602 * user is focusing on editing page content and clicks on a disabled template
30603 * block.
30604 * - Displays a 'Edit your template to edit this block' dialog when the user
30605 * is focusing on editing page conetnt and double clicks on a disabled
30606 * template block.
30607 *
30608 * @param {Object} props
30609 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
30610 * editor iframe canvas.
30611 */
30612
30613 function EditTemplateBlocksNotification({
30614 contentRef
30615 }) {
30616 const {
30617 onNavigateToEntityRecord,
30618 templateId
30619 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30620 const {
30621 getEditorSettings,
30622 getCurrentTemplateId
30623 } = select(store_store);
30624 return {
30625 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
30626 templateId: getCurrentTemplateId()
30627 };
30628 }, []);
30629 const canEditTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
30630 kind: 'postType',
30631 name: 'wp_template'
30632 }), []);
30633 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
30634 (0,external_wp_element_namespaceObject.useEffect)(() => {
30635 const handleDblClick = event => {
30636 if (!canEditTemplate) {
30637 return;
30638 }
30639 if (!event.target.classList.contains('is-root-container') || event.target.dataset?.type === 'core/template-part') {
30640 return;
30641 }
30642 if (!event.defaultPrevented) {
30643 event.preventDefault();
30644 setIsDialogOpen(true);
30645 }
30646 };
30647 const canvas = contentRef.current;
30648 canvas?.addEventListener('dblclick', handleDblClick);
30649 return () => {
30650 canvas?.removeEventListener('dblclick', handleDblClick);
30651 };
30652 }, [contentRef, canEditTemplate]);
30653 if (!canEditTemplate) {
30654 return null;
30655 }
30656 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
30657 isOpen: isDialogOpen,
30658 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'),
30659 onConfirm: () => {
30660 setIsDialogOpen(false);
30661 onNavigateToEntityRecord({
30662 postId: templateId,
30663 postType: 'wp_template'
30664 });
30665 },
30666 onCancel: () => setIsDialogOpen(false),
30667 size: "medium",
30668 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?')
30669 });
30670 }
30671
30672 ;// ./packages/editor/build-module/components/resizable-editor/resize-handle.js
30673 /**
30674 * WordPress dependencies
30675 */
30676
30677
30678
30679
30680 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
30681
30682 function ResizeHandle({
30683 direction,
30684 resizeWidthBy
30685 }) {
30686 function handleKeyDown(event) {
30687 const {
30688 keyCode
30689 } = event;
30690 if (keyCode !== external_wp_keycodes_namespaceObject.LEFT && keyCode !== external_wp_keycodes_namespaceObject.RIGHT) {
30691 return;
30692 }
30693 event.preventDefault();
30694 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
30695 resizeWidthBy(DELTA_DISTANCE);
30696 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
30697 resizeWidthBy(-DELTA_DISTANCE);
30698 }
30699 }
30700 const resizeHandleVariants = {
30701 active: {
30702 opacity: 1,
30703 scaleY: 1.3
30704 }
30705 };
30706 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
30707 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
30708 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
30709 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
30710 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.button, {
30711 className: `editor-resizable-editor__resize-handle is-${direction}`,
30712 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
30713 "aria-describedby": resizableHandleHelpId,
30714 onKeyDown: handleKeyDown,
30715 variants: resizeHandleVariants,
30716 whileFocus: "active",
30717 whileHover: "active",
30718 whileTap: "active",
30719 role: "separator",
30720 "aria-orientation": "vertical"
30721 }, "handle")
30722 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
30723 id: resizableHandleHelpId,
30724 children: (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')
30725 })]
30726 });
30727 }
30728
30729 ;// ./packages/editor/build-module/components/resizable-editor/index.js
30730 /**
30731 * External dependencies
30732 */
30733
30734
30735 /**
30736 * WordPress dependencies
30737 */
30738
30739
30740
30741 /**
30742 * Internal dependencies
30743 */
30744
30745
30746 // Removes the inline styles in the drag handles.
30747
30748 const HANDLE_STYLES_OVERRIDE = {
30749 position: undefined,
30750 userSelect: undefined,
30751 cursor: undefined,
30752 width: undefined,
30753 height: undefined,
30754 top: undefined,
30755 right: undefined,
30756 bottom: undefined,
30757 left: undefined
30758 };
30759 function ResizableEditor({
30760 className,
30761 enableResizing,
30762 height,
30763 children
30764 }) {
30765 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
30766 const resizableRef = (0,external_wp_element_namespaceObject.useRef)();
30767 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
30768 if (resizableRef.current) {
30769 setWidth(resizableRef.current.offsetWidth + deltaPixels);
30770 }
30771 }, []);
30772 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ResizableBox, {
30773 className: dist_clsx('editor-resizable-editor', className, {
30774 'is-resizable': enableResizing
30775 }),
30776 ref: api => {
30777 resizableRef.current = api?.resizable;
30778 },
30779 size: {
30780 width: enableResizing ? width : '100%',
30781 height: enableResizing && height ? height : '100%'
30782 },
30783 onResizeStop: (event, direction, element) => {
30784 setWidth(element.style.width);
30785 },
30786 minWidth: 300,
30787 maxWidth: "100%",
30788 maxHeight: "100%",
30789 enable: {
30790 left: enableResizing,
30791 right: enableResizing
30792 },
30793 showHandle: enableResizing
30794 // The editor is centered horizontally, resizing it only
30795 // moves half the distance. Hence double the ratio to correctly
30796 // align the cursor to the resizer handle.
30797 ,
30798 resizeRatio: 2,
30799 handleComponent: {
30800 left: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
30801 direction: "left",
30802 resizeWidthBy: resizeWidthBy
30803 }),
30804 right: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
30805 direction: "right",
30806 resizeWidthBy: resizeWidthBy
30807 })
30808 },
30809 handleClasses: undefined,
30810 handleStyles: {
30811 left: HANDLE_STYLES_OVERRIDE,
30812 right: HANDLE_STYLES_OVERRIDE
30813 },
30814 children: children
30815 });
30816 }
30817 /* harmony default export */ const resizable_editor = (ResizableEditor);
30818
30819 ;// ./packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.js
30820 /* wp:polyfill */
30821 /**
30822 * WordPress dependencies
30823 */
30824
30825
30826
30827
30828 /**
30829 * Internal dependencies
30830 */
30831
30832 const DISTANCE_THRESHOLD = 500;
30833 function clamp(value, min, max) {
30834 return Math.min(Math.max(value, min), max);
30835 }
30836 function distanceFromRect(x, y, rect) {
30837 const dx = x - clamp(x, rect.left, rect.right);
30838 const dy = y - clamp(y, rect.top, rect.bottom);
30839 return Math.sqrt(dx * dx + dy * dy);
30840 }
30841 function useSelectNearestEditableBlock({
30842 isEnabled = true
30843 } = {}) {
30844 const {
30845 getEnabledClientIdsTree,
30846 getBlockName,
30847 getBlockOrder
30848 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
30849 const {
30850 selectBlock
30851 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
30852 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
30853 if (!isEnabled) {
30854 return;
30855 }
30856 const selectNearestEditableBlock = (x, y) => {
30857 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({
30858 clientId
30859 }) => {
30860 const blockName = getBlockName(clientId);
30861 if (blockName === 'core/template-part') {
30862 return [];
30863 }
30864 if (blockName === 'core/post-content') {
30865 const innerBlocks = getBlockOrder(clientId);
30866 if (innerBlocks.length) {
30867 return innerBlocks;
30868 }
30869 }
30870 return [clientId];
30871 });
30872 let nearestDistance = Infinity,
30873 nearestClientId = null;
30874 for (const clientId of editableBlockClientIds) {
30875 const block = element.querySelector(`[data-block="${clientId}"]`);
30876 if (!block) {
30877 continue;
30878 }
30879 const rect = block.getBoundingClientRect();
30880 const distance = distanceFromRect(x, y, rect);
30881 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
30882 nearestDistance = distance;
30883 nearestClientId = clientId;
30884 }
30885 }
30886 if (nearestClientId) {
30887 selectBlock(nearestClientId);
30888 }
30889 };
30890 const handleClick = event => {
30891 const shouldSelect = event.target === element || event.target.classList.contains('is-root-container');
30892 if (shouldSelect) {
30893 selectNearestEditableBlock(event.clientX, event.clientY);
30894 }
30895 };
30896 element.addEventListener('click', handleClick);
30897 return () => element.removeEventListener('click', handleClick);
30898 }, [isEnabled]);
30899 }
30900
30901 ;// ./packages/editor/build-module/components/visual-editor/use-zoom-out-mode-exit.js
30902 /**
30903 * WordPress dependencies
30904 */
30905
30906
30907
30908
30909 /**
30910 * Internal dependencies
30911 */
30912
30913
30914 /**
30915 * Allows Zoom Out mode to be exited by double clicking in the selected block.
30916 */
30917 function useZoomOutModeExit() {
30918 const {
30919 getSettings,
30920 isZoomOut
30921 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
30922 const {
30923 resetZoomLevel
30924 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
30925 return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
30926 function onDoubleClick(event) {
30927 if (!isZoomOut()) {
30928 return;
30929 }
30930 if (!event.defaultPrevented) {
30931 event.preventDefault();
30932 const {
30933 __experimentalSetIsInserterOpened
30934 } = getSettings();
30935 if (typeof __experimentalSetIsInserterOpened === 'function') {
30936 __experimentalSetIsInserterOpened(false);
30937 }
30938 resetZoomLevel();
30939 }
30940 }
30941 node.addEventListener('dblclick', onDoubleClick);
30942 return () => {
30943 node.removeEventListener('dblclick', onDoubleClick);
30944 };
30945 }, [getSettings, isZoomOut, resetZoomLevel]);
30946 }
30947
30948 ;// ./packages/editor/build-module/components/visual-editor/index.js
30949 /**
30950 * External dependencies
30951 */
30952
30953
30954 /**
30955 * WordPress dependencies
30956 */
30957
30958
30959
30960
30961
30962
30963
30964 /**
30965 * Internal dependencies
30966 */
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976 const {
30977 LayoutStyle,
30978 useLayoutClasses,
30979 useLayoutStyles,
30980 ExperimentalBlockCanvas: BlockCanvas,
30981 useFlashEditableBlocks
30982 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
30983
30984 /**
30985 * These post types have a special editor where they don't allow you to fill the title
30986 * and they don't apply the layout styles.
30987 */
30988 const visual_editor_DESIGN_POST_TYPES = [PATTERN_POST_TYPE, TEMPLATE_POST_TYPE, NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE];
30989
30990 /**
30991 * Given an array of nested blocks, find the first Post Content
30992 * block inside it, recursing through any nesting levels,
30993 * and return its attributes.
30994 *
30995 * @param {Array} blocks A list of blocks.
30996 *
30997 * @return {Object | undefined} The Post Content block.
30998 */
30999 function getPostContentAttributes(blocks) {
31000 for (let i = 0; i < blocks.length; i++) {
31001 if (blocks[i].name === 'core/post-content') {
31002 return blocks[i].attributes;
31003 }
31004 if (blocks[i].innerBlocks.length) {
31005 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
31006 if (nestedPostContent) {
31007 return nestedPostContent;
31008 }
31009 }
31010 }
31011 }
31012 function checkForPostContentAtRootLevel(blocks) {
31013 for (let i = 0; i < blocks.length; i++) {
31014 if (blocks[i].name === 'core/post-content') {
31015 return true;
31016 }
31017 }
31018 return false;
31019 }
31020 function VisualEditor({
31021 // Ideally as we unify post and site editors, we won't need these props.
31022 autoFocus,
31023 styles,
31024 disableIframe = false,
31025 iframeProps,
31026 contentRef,
31027 className
31028 }) {
31029 const [contentHeight, setContentHeight] = (0,external_wp_element_namespaceObject.useState)('');
31030 const effectContentHeight = (0,external_wp_compose_namespaceObject.useResizeObserver)(([entry]) => {
31031 setContentHeight(entry.borderBoxSize[0].blockSize);
31032 });
31033 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
31034 const {
31035 renderingMode,
31036 postContentAttributes,
31037 editedPostTemplate = {},
31038 wrapperBlockName,
31039 wrapperUniqueId,
31040 deviceType,
31041 isFocusedEntity,
31042 isDesignPostType,
31043 postType,
31044 isPreview
31045 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31046 const {
31047 getCurrentPostId,
31048 getCurrentPostType,
31049 getCurrentTemplateId,
31050 getEditorSettings,
31051 getRenderingMode,
31052 getDeviceType
31053 } = select(store_store);
31054 const {
31055 getPostType,
31056 getEditedEntityRecord
31057 } = select(external_wp_coreData_namespaceObject.store);
31058 const postTypeSlug = getCurrentPostType();
31059 const _renderingMode = getRenderingMode();
31060 let _wrapperBlockName;
31061 if (postTypeSlug === PATTERN_POST_TYPE) {
31062 _wrapperBlockName = 'core/block';
31063 } else if (_renderingMode === 'post-only') {
31064 _wrapperBlockName = 'core/post-content';
31065 }
31066 const editorSettings = getEditorSettings();
31067 const supportsTemplateMode = editorSettings.supportsTemplateMode;
31068 const postTypeObject = getPostType(postTypeSlug);
31069 const currentTemplateId = getCurrentTemplateId();
31070 const template = currentTemplateId ? getEditedEntityRecord('postType', TEMPLATE_POST_TYPE, currentTemplateId) : undefined;
31071 return {
31072 renderingMode: _renderingMode,
31073 postContentAttributes: editorSettings.postContentAttributes,
31074 isDesignPostType: visual_editor_DESIGN_POST_TYPES.includes(postTypeSlug),
31075 // Post template fetch returns a 404 on classic themes, which
31076 // messes with e2e tests, so check it's a block theme first.
31077 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode ? template : undefined,
31078 wrapperBlockName: _wrapperBlockName,
31079 wrapperUniqueId: getCurrentPostId(),
31080 deviceType: getDeviceType(),
31081 isFocusedEntity: !!editorSettings.onNavigateToPreviousEntityRecord,
31082 postType: postTypeSlug,
31083 isPreview: editorSettings.isPreviewMode
31084 };
31085 }, []);
31086 const {
31087 isCleanNewPost
31088 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
31089 const {
31090 hasRootPaddingAwareAlignments,
31091 themeHasDisabledLayoutStyles,
31092 themeSupportsLayout,
31093 isZoomedOut
31094 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31095 const {
31096 getSettings,
31097 isZoomOut: _isZoomOut
31098 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
31099 const _settings = getSettings();
31100 return {
31101 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
31102 themeSupportsLayout: _settings.supportsLayout,
31103 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
31104 isZoomedOut: _isZoomOut()
31105 };
31106 }, []);
31107 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
31108 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout');
31109
31110 // fallbackLayout is used if there is no Post Content,
31111 // and for Post Title.
31112 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
31113 if (renderingMode !== 'post-only' || isDesignPostType) {
31114 return {
31115 type: 'default'
31116 };
31117 }
31118 if (themeSupportsLayout) {
31119 // We need to ensure support for wide and full alignments,
31120 // so we add the constrained type.
31121 return {
31122 ...globalLayoutSettings,
31123 type: 'constrained'
31124 };
31125 }
31126 // Set default layout for classic themes so all alignments are supported.
31127 return {
31128 type: 'default'
31129 };
31130 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]);
31131 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => {
31132 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
31133 return postContentAttributes;
31134 }
31135 // When in template editing mode, we can access the blocks directly.
31136 if (editedPostTemplate?.blocks) {
31137 return getPostContentAttributes(editedPostTemplate?.blocks);
31138 }
31139 // If there are no blocks, we have to parse the content string.
31140 // Best double-check it's a string otherwise the parse function gets unhappy.
31141 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
31142 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {};
31143 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
31144 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => {
31145 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
31146 return false;
31147 }
31148 // When in template editing mode, we can access the blocks directly.
31149 if (editedPostTemplate?.blocks) {
31150 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
31151 }
31152 // If there are no blocks, we have to parse the content string.
31153 // Best double-check it's a string otherwise the parse function gets unhappy.
31154 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
31155 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false;
31156 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
31157 const {
31158 layout = {},
31159 align = ''
31160 } = newestPostContentAttributes || {};
31161 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
31162 const blockListLayoutClass = dist_clsx({
31163 'is-layout-flow': !themeSupportsLayout
31164 }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
31165 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
31166
31167 // Update type for blocks using legacy layouts.
31168 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
31169 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
31170 ...globalLayoutSettings,
31171 ...layout,
31172 type: 'constrained'
31173 } : {
31174 ...globalLayoutSettings,
31175 ...layout,
31176 type: 'default'
31177 };
31178 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
31179
31180 // If there is a Post Content block we use its layout for the block list;
31181 // if not, this must be a classic theme, in which case we use the fallback layout.
31182 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
31183 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
31184 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)();
31185 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
31186 (0,external_wp_element_namespaceObject.useEffect)(() => {
31187 if (!autoFocus || !isCleanNewPost()) {
31188 return;
31189 }
31190 titleRef?.current?.focus();
31191 }, [autoFocus, isCleanNewPost]);
31192
31193 // Add some styles for alignwide/alignfull Post Content and its children.
31194 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
31195 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
31196 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
31197 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
31198 const forceFullHeight = postType === NAVIGATION_POST_TYPE;
31199 const enableResizing = [NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType) &&
31200 // Disable in previews / view mode.
31201 !isPreview &&
31202 // Disable resizing in mobile viewport.
31203 !isMobileViewport &&
31204 // Dsiable resizing in zoomed-out mode.
31205 !isZoomedOut;
31206 const iframeStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
31207 return [...(styles !== null && styles !== void 0 ? styles : []), {
31208 // Ensures margins of children are contained so that the body background paints behind them.
31209 // Otherwise, the background of html (when zoomed out) would show there and appear broken. It’s
31210 // important mostly for post-only views yet conceivably an issue in templated views too.
31211 css: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${
31212 // Some themes will have `min-height: 100vh` for the root container,
31213 // which isn't a requirement in auto resize mode.
31214 enableResizing ? 'min-height:0!important;' : ''}}`
31215 }];
31216 }, [styles, enableResizing]);
31217 const localRef = (0,external_wp_element_namespaceObject.useRef)();
31218 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)();
31219 contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, contentRef, renderingMode === 'post-only' ? typewriterRef : null, useFlashEditableBlocks({
31220 isEnabled: renderingMode === 'template-locked'
31221 }), useSelectNearestEditableBlock({
31222 isEnabled: renderingMode === 'template-locked'
31223 }), useZoomOutModeExit(),
31224 // Avoid resize listeners when not needed, these will trigger
31225 // unnecessary re-renders when animating the iframe width.
31226 enableResizing ? effectContentHeight : null]);
31227 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
31228 className: dist_clsx('editor-visual-editor',
31229 // this class is here for backward compatibility reasons.
31230 'edit-post-visual-editor', className, {
31231 'has-padding': isFocusedEntity || enableResizing,
31232 'is-resizable': enableResizing,
31233 'is-iframed': !disableIframe,
31234 'is-scrollable': disableIframe || deviceType !== 'Desktop'
31235 }),
31236 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(resizable_editor, {
31237 enableResizing: enableResizing,
31238 height: contentHeight && !forceFullHeight ? contentHeight : '100%',
31239 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockCanvas, {
31240 shouldIframe: !disableIframe,
31241 contentRef: contentRef,
31242 styles: iframeStyles,
31243 height: "100%",
31244 iframeProps: {
31245 ...iframeProps,
31246 style: {
31247 ...iframeProps?.style,
31248 ...deviceStyles
31249 }
31250 },
31251 children: [themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31252 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
31253 selector: ".editor-visual-editor__post-title-wrapper",
31254 layout: fallbackLayout
31255 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
31256 selector: ".block-editor-block-list__layout.is-root-container",
31257 layout: postEditorLayout
31258 }), align && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
31259 css: alignCSS
31260 }), postContentLayoutStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
31261 layout: postContentLayout,
31262 css: postContentLayoutStyles
31263 })]
31264 }), renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
31265 className: dist_clsx('editor-visual-editor__post-title-wrapper',
31266 // The following class is only here for backward comapatibility
31267 // some themes might be using it to style the post title.
31268 'edit-post-visual-editor__post-title-wrapper', {
31269 'has-global-padding': hasRootPaddingAwareAlignments
31270 }),
31271 contentEditable: false,
31272 ref: observeTypingRef,
31273 style: {
31274 // This is using inline styles
31275 // so it's applied for both iframed and non iframed editors.
31276 marginTop: '4rem'
31277 },
31278 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title, {
31279 ref: titleRef
31280 })
31281 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
31282 blockName: wrapperBlockName,
31283 uniqueId: wrapperUniqueId,
31284 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, {
31285 className: dist_clsx('is-' + deviceType.toLowerCase() + '-preview', renderingMode !== 'post-only' || isDesignPostType ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content`,
31286 // Ensure root level blocks receive default/flow blockGap styling rules.
31287 {
31288 'has-global-padding': renderingMode === 'post-only' && !isDesignPostType && hasRootPaddingAwareAlignments
31289 }),
31290 layout: blockListLayout,
31291 dropZoneElement:
31292 // When iframed, pass in the html element of the iframe to
31293 // ensure the drop zone extends to the edges of the iframe.
31294 disableIframe ? localRef.current : localRef.current?.parentNode,
31295 __unstableDisableDropZone:
31296 // In template preview mode, disable drop zones at the root of the template.
31297 renderingMode === 'template-locked' ? true : false
31298 }), renderingMode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditTemplateBlocksNotification, {
31299 contentRef: localRef
31300 })]
31301 })]
31302 })
31303 })
31304 });
31305 }
31306 /* harmony default export */ const visual_editor = (VisualEditor);
31307
31308 ;// ./packages/editor/build-module/components/editor-interface/index.js
31309 /**
31310 * External dependencies
31311 */
31312
31313
31314 /**
31315 * WordPress dependencies
31316 */
31317
31318
31319
31320
31321
31322
31323
31324
31325 /**
31326 * Internal dependencies
31327 */
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338 const interfaceLabels = {
31339 /* translators: accessibility text for the editor top bar landmark region. */
31340 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
31341 /* translators: accessibility text for the editor content landmark region. */
31342 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
31343 /* translators: accessibility text for the editor settings landmark region. */
31344 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
31345 /* translators: accessibility text for the editor publish landmark region. */
31346 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
31347 /* translators: accessibility text for the editor footer landmark region. */
31348 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
31349 };
31350 function EditorInterface({
31351 className,
31352 styles,
31353 children,
31354 forceIsDirty,
31355 contentRef,
31356 disableIframe,
31357 autoFocus,
31358 customSaveButton,
31359 customSavePanel,
31360 forceDisableBlockTools,
31361 title,
31362 iframeProps
31363 }) {
31364 const {
31365 mode,
31366 isRichEditingEnabled,
31367 isInserterOpened,
31368 isListViewOpened,
31369 isDistractionFree,
31370 isPreviewMode,
31371 showBlockBreadcrumbs,
31372 documentLabel
31373 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31374 const {
31375 get
31376 } = select(external_wp_preferences_namespaceObject.store);
31377 const {
31378 getEditorSettings,
31379 getPostTypeLabel
31380 } = select(store_store);
31381 const editorSettings = getEditorSettings();
31382 const postTypeLabel = getPostTypeLabel();
31383 return {
31384 mode: select(store_store).getEditorMode(),
31385 isRichEditingEnabled: editorSettings.richEditingEnabled,
31386 isInserterOpened: select(store_store).isInserterOpened(),
31387 isListViewOpened: select(store_store).isListViewOpened(),
31388 isDistractionFree: get('core', 'distractionFree'),
31389 isPreviewMode: editorSettings.isPreviewMode,
31390 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
31391 documentLabel:
31392 // translators: Default label for the Document in the Block Breadcrumb.
31393 postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun, breadcrumb')
31394 };
31395 }, []);
31396 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
31397 const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('Document Overview') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
31398
31399 // Local state for save panel.
31400 // Note 'truthy' callback implies an open panel.
31401 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
31402 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
31403 if (typeof entitiesSavedStatesCallback === 'function') {
31404 entitiesSavedStatesCallback(arg);
31405 }
31406 setEntitiesSavedStatesCallback(false);
31407 }, [entitiesSavedStatesCallback]);
31408 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(interface_skeleton, {
31409 isDistractionFree: isDistractionFree,
31410 className: dist_clsx('editor-editor-interface', className, {
31411 'is-entity-save-view-open': !!entitiesSavedStatesCallback,
31412 'is-distraction-free': isDistractionFree && !isPreviewMode
31413 }),
31414 labels: {
31415 ...interfaceLabels,
31416 secondarySidebar: secondarySidebarLabel
31417 },
31418 header: !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_header, {
31419 forceIsDirty: forceIsDirty,
31420 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
31421 customSaveButton: customSaveButton,
31422 forceDisableBlockTools: forceDisableBlockTools,
31423 title: title
31424 }),
31425 editorNotices: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}),
31426 secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InserterSidebar, {}) || isListViewOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewSidebar, {})),
31427 sidebar: !isPreviewMode && !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area.Slot, {
31428 scope: "core"
31429 }),
31430 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31431 children: [!isDistractionFree && !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(content_slot_fill.Slot, {
31432 children: ([editorCanvasView]) => editorCanvasView ? editorCanvasView : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
31433 children: [!isPreviewMode && (mode === 'text' || !isRichEditingEnabled) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TextEditor
31434 // We should auto-focus the canvas (title) on load.
31435 // eslint-disable-next-line jsx-a11y/no-autofocus
31436 , {
31437 autoFocus: autoFocus
31438 }), !isPreviewMode && !isLargeViewport && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
31439 hideDragHandle: true
31440 }), (isPreviewMode || isRichEditingEnabled && mode === 'visual') && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(visual_editor, {
31441 styles: styles,
31442 contentRef: contentRef,
31443 disableIframe: disableIframe
31444 // We should auto-focus the canvas (title) on load.
31445 // eslint-disable-next-line jsx-a11y/no-autofocus
31446 ,
31447 autoFocus: autoFocus,
31448 iframeProps: iframeProps
31449 }), children]
31450 })
31451 })]
31452 }),
31453 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && isRichEditingEnabled && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
31454 rootLabelText: documentLabel
31455 }),
31456 actions: !isPreviewMode ? customSavePanel || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SavePublishPanels, {
31457 closeEntitiesSavedStates: closeEntitiesSavedStates,
31458 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
31459 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
31460 forceIsDirtyPublishPanel: forceIsDirty
31461 }) : undefined
31462 });
31463 }
31464
31465 ;// ./packages/editor/build-module/components/pattern-overrides-panel/index.js
31466 /**
31467 * WordPress dependencies
31468 */
31469
31470
31471
31472 /**
31473 * Internal dependencies
31474 */
31475
31476
31477
31478 const {
31479 OverridesPanel
31480 } = unlock(external_wp_patterns_namespaceObject.privateApis);
31481 function PatternOverridesPanel() {
31482 const supportsPatternOverridesPanel = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === 'wp_block', []);
31483 if (!supportsPatternOverridesPanel) {
31484 return null;
31485 }
31486 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverridesPanel, {});
31487 }
31488
31489 ;// ./packages/editor/build-module/utils/get-item-title.js
31490 /**
31491 * WordPress dependencies
31492 */
31493
31494
31495 /**
31496 * Helper function to get the title of a post item.
31497 * This is duplicated from the `@wordpress/fields` package.
31498 * `packages/fields/src/actions/utils.ts`
31499 *
31500 * @param {Object} item The post item.
31501 * @return {string} The title of the item, or an empty string if the title is not found.
31502 */
31503 function get_item_title_getItemTitle(item) {
31504 if (typeof item.title === 'string') {
31505 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
31506 }
31507 if (item.title && 'rendered' in item.title) {
31508 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.rendered);
31509 }
31510 if (item.title && 'raw' in item.title) {
31511 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.raw);
31512 }
31513 return '';
31514 }
31515
31516 ;// ./packages/editor/build-module/components/post-actions/set-as-homepage.js
31517 /**
31518 * WordPress dependencies
31519 */
31520
31521
31522
31523
31524
31525
31526
31527 /**
31528 * Internal dependencies
31529 */
31530
31531
31532 const SetAsHomepageModal = ({
31533 items,
31534 closeModal
31535 }) => {
31536 const [item] = items;
31537 const pageTitle = get_item_title_getItemTitle(item);
31538 const {
31539 showOnFront,
31540 currentHomePage,
31541 isSaving
31542 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31543 const {
31544 getEntityRecord,
31545 isSavingEntityRecord
31546 } = select(external_wp_coreData_namespaceObject.store);
31547 const siteSettings = getEntityRecord('root', 'site');
31548 const currentHomePageItem = getEntityRecord('postType', 'page', siteSettings?.page_on_front);
31549 return {
31550 showOnFront: siteSettings?.show_on_front,
31551 currentHomePage: currentHomePageItem,
31552 isSaving: isSavingEntityRecord('root', 'site')
31553 };
31554 });
31555 const {
31556 saveEntityRecord
31557 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
31558 const {
31559 createSuccessNotice,
31560 createErrorNotice
31561 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
31562 async function onSetPageAsHomepage(event) {
31563 event.preventDefault();
31564 try {
31565 await saveEntityRecord('root', 'site', {
31566 page_on_front: item.id,
31567 show_on_front: 'page'
31568 });
31569 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Homepage updated.'), {
31570 type: 'snackbar'
31571 });
31572 } catch (error) {
31573 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while setting the homepage.');
31574 createErrorNotice(errorMessage, {
31575 type: 'snackbar'
31576 });
31577 } finally {
31578 closeModal?.();
31579 }
31580 }
31581 let modalWarning = '';
31582 if ('posts' === showOnFront) {
31583 modalWarning = (0,external_wp_i18n_namespaceObject.__)('This will replace the current homepage which is set to display latest posts.');
31584 } else if (currentHomePage) {
31585 modalWarning = (0,external_wp_i18n_namespaceObject.sprintf)(
31586 // translators: %s: title of the current home page.
31587 (0,external_wp_i18n_namespaceObject.__)('This will replace the current homepage: "%s"'), get_item_title_getItemTitle(currentHomePage));
31588 }
31589 const modalText = (0,external_wp_i18n_namespaceObject.sprintf)(
31590 // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.
31591 (0,external_wp_i18n_namespaceObject.__)('Set "%1$s" as the site homepage? %2$s'), pageTitle, modalWarning).trim();
31592
31593 // translators: Button label to confirm setting the specified page as the homepage.
31594 const modalButtonLabel = (0,external_wp_i18n_namespaceObject.__)('Set homepage');
31595 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
31596 onSubmit: onSetPageAsHomepage,
31597 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
31598 spacing: "5",
31599 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
31600 children: modalText
31601 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
31602 justify: "right",
31603 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
31604 __next40pxDefaultSize: true,
31605 variant: "tertiary",
31606 onClick: () => {
31607 closeModal?.();
31608 },
31609 disabled: isSaving,
31610 accessibleWhenDisabled: true,
31611 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
31612 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
31613 __next40pxDefaultSize: true,
31614 variant: "primary",
31615 type: "submit",
31616 disabled: isSaving,
31617 accessibleWhenDisabled: true,
31618 children: modalButtonLabel
31619 })]
31620 })]
31621 })
31622 });
31623 };
31624 const useSetAsHomepageAction = () => {
31625 const {
31626 pageOnFront,
31627 pageForPosts
31628 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31629 const {
31630 getEntityRecord,
31631 canUser
31632 } = select(external_wp_coreData_namespaceObject.store);
31633 const siteSettings = canUser('read', {
31634 kind: 'root',
31635 name: 'site'
31636 }) ? getEntityRecord('root', 'site') : undefined;
31637 return {
31638 pageOnFront: siteSettings?.page_on_front,
31639 pageForPosts: siteSettings?.page_for_posts
31640 };
31641 });
31642 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
31643 id: 'set-as-homepage',
31644 label: (0,external_wp_i18n_namespaceObject.__)('Set as homepage'),
31645 isEligible(post) {
31646 if (post.status !== 'publish') {
31647 return false;
31648 }
31649 if (post.type !== 'page') {
31650 return false;
31651 }
31652
31653 // Don't show the action if the page is already set as the homepage.
31654 if (pageOnFront === post.id) {
31655 return false;
31656 }
31657
31658 // Don't show the action if the page is already set as the page for posts.
31659 if (pageForPosts === post.id) {
31660 return false;
31661 }
31662 return true;
31663 },
31664 RenderModal: SetAsHomepageModal
31665 }), [pageForPosts, pageOnFront]);
31666 };
31667
31668 ;// ./packages/editor/build-module/components/post-actions/set-as-posts-page.js
31669 /**
31670 * WordPress dependencies
31671 */
31672
31673
31674
31675
31676
31677
31678
31679 /**
31680 * Internal dependencies
31681 */
31682
31683
31684 const SetAsPostsPageModal = ({
31685 items,
31686 closeModal
31687 }) => {
31688 const [item] = items;
31689 const pageTitle = get_item_title_getItemTitle(item);
31690 const {
31691 currentPostsPage,
31692 isPageForPostsSet,
31693 isSaving
31694 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31695 const {
31696 getEntityRecord,
31697 isSavingEntityRecord
31698 } = select(external_wp_coreData_namespaceObject.store);
31699 const siteSettings = getEntityRecord('root', 'site');
31700 const currentPostsPageItem = getEntityRecord('postType', 'page', siteSettings?.page_for_posts);
31701 return {
31702 currentPostsPage: currentPostsPageItem,
31703 isPageForPostsSet: siteSettings?.page_for_posts !== 0,
31704 isSaving: isSavingEntityRecord('root', 'site')
31705 };
31706 });
31707 const {
31708 saveEntityRecord
31709 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
31710 const {
31711 createSuccessNotice,
31712 createErrorNotice
31713 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
31714 async function onSetPageAsPostsPage(event) {
31715 event.preventDefault();
31716 try {
31717 await saveEntityRecord('root', 'site', {
31718 page_for_posts: item.id,
31719 show_on_front: 'page'
31720 });
31721 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Posts page updated.'), {
31722 type: 'snackbar'
31723 });
31724 } catch (error) {
31725 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while setting the posts page.');
31726 createErrorNotice(errorMessage, {
31727 type: 'snackbar'
31728 });
31729 } finally {
31730 closeModal?.();
31731 }
31732 }
31733 const modalWarning = isPageForPostsSet && currentPostsPage ? (0,external_wp_i18n_namespaceObject.sprintf)(
31734 // translators: %s: title of the current posts page.
31735 (0,external_wp_i18n_namespaceObject.__)('This will replace the current posts page: "%s"'), get_item_title_getItemTitle(currentPostsPage)) : (0,external_wp_i18n_namespaceObject.__)('This page will show the latest posts.');
31736 const modalText = (0,external_wp_i18n_namespaceObject.sprintf)(
31737 // translators: %1$s: title of the page to be set as the posts page, %2$s: posts page replacement warning message.
31738 (0,external_wp_i18n_namespaceObject.__)('Set "%1$s" as the posts page? %2$s'), pageTitle, modalWarning);
31739
31740 // translators: Button label to confirm setting the specified page as the posts page.
31741 const modalButtonLabel = (0,external_wp_i18n_namespaceObject.__)('Set posts page');
31742 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
31743 onSubmit: onSetPageAsPostsPage,
31744 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
31745 spacing: "5",
31746 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
31747 children: modalText
31748 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
31749 justify: "right",
31750 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
31751 __next40pxDefaultSize: true,
31752 variant: "tertiary",
31753 onClick: () => {
31754 closeModal?.();
31755 },
31756 disabled: isSaving,
31757 accessibleWhenDisabled: true,
31758 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
31759 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
31760 __next40pxDefaultSize: true,
31761 variant: "primary",
31762 type: "submit",
31763 disabled: isSaving,
31764 accessibleWhenDisabled: true,
31765 children: modalButtonLabel
31766 })]
31767 })]
31768 })
31769 });
31770 };
31771 const useSetAsPostsPageAction = () => {
31772 const {
31773 pageOnFront,
31774 pageForPosts
31775 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31776 const {
31777 getEntityRecord,
31778 canUser
31779 } = select(external_wp_coreData_namespaceObject.store);
31780 const siteSettings = canUser('read', {
31781 kind: 'root',
31782 name: 'site'
31783 }) ? getEntityRecord('root', 'site') : undefined;
31784 return {
31785 pageOnFront: siteSettings?.page_on_front,
31786 pageForPosts: siteSettings?.page_for_posts
31787 };
31788 });
31789 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
31790 id: 'set-as-posts-page',
31791 label: (0,external_wp_i18n_namespaceObject.__)('Set as posts page'),
31792 isEligible(post) {
31793 if (post.status !== 'publish') {
31794 return false;
31795 }
31796 if (post.type !== 'page') {
31797 return false;
31798 }
31799
31800 // Don't show the action if the page is already set as the homepage.
31801 if (pageOnFront === post.id) {
31802 return false;
31803 }
31804
31805 // Don't show the action if the page is already set as the page for posts.
31806 if (pageForPosts === post.id) {
31807 return false;
31808 }
31809 return true;
31810 },
31811 RenderModal: SetAsPostsPageModal
31812 }), [pageForPosts, pageOnFront]);
31813 };
31814
31815 ;// ./packages/editor/build-module/components/post-actions/actions.js
31816 /* wp:polyfill */
31817 /**
31818 * WordPress dependencies
31819 */
31820
31821
31822
31823
31824 /**
31825 * Internal dependencies
31826 */
31827
31828
31829
31830
31831
31832 function usePostActions({
31833 postType,
31834 onActionPerformed,
31835 context
31836 }) {
31837 const {
31838 defaultActions
31839 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31840 const {
31841 getEntityActions
31842 } = unlock(select(store_store));
31843 return {
31844 defaultActions: getEntityActions('postType', postType)
31845 };
31846 }, [postType]);
31847 const {
31848 canManageOptions,
31849 hasFrontPageTemplate
31850 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31851 const {
31852 getEntityRecords
31853 } = select(external_wp_coreData_namespaceObject.store);
31854 const templates = getEntityRecords('postType', 'wp_template', {
31855 per_page: -1
31856 });
31857 return {
31858 canManageOptions: select(external_wp_coreData_namespaceObject.store).canUser('update', {
31859 kind: 'root',
31860 name: 'site'
31861 }),
31862 hasFrontPageTemplate: !!templates?.find(template => template?.slug === 'front-page')
31863 };
31864 });
31865 const setAsHomepageAction = useSetAsHomepageAction();
31866 const setAsPostsPageAction = useSetAsPostsPageAction();
31867 const shouldShowHomepageActions = canManageOptions && !hasFrontPageTemplate;
31868 const {
31869 registerPostTypeSchema
31870 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
31871 (0,external_wp_element_namespaceObject.useEffect)(() => {
31872 registerPostTypeSchema(postType);
31873 }, [registerPostTypeSchema, postType]);
31874 return (0,external_wp_element_namespaceObject.useMemo)(() => {
31875 let actions = [...defaultActions];
31876 if (shouldShowHomepageActions) {
31877 actions.push(setAsHomepageAction, setAsPostsPageAction);
31878 }
31879
31880 // Ensure "Move to trash" is always the last action.
31881 actions = actions.sort((a, b) => b.id === 'move-to-trash' ? -1 : 0);
31882
31883 // Filter actions based on provided context. If not provided
31884 // all actions are returned. We'll have a single entry for getting the actions
31885 // and the consumer should provide the context to filter the actions, if needed.
31886 // Actions should also provide the `context` they support, if it's specific, to
31887 // compare with the provided context to get all the actions.
31888 // Right now the only supported context is `list`.
31889 actions = actions.filter(action => {
31890 if (!action.context) {
31891 return true;
31892 }
31893 return action.context === context;
31894 });
31895 if (onActionPerformed) {
31896 for (let i = 0; i < actions.length; ++i) {
31897 if (actions[i].callback) {
31898 const existingCallback = actions[i].callback;
31899 actions[i] = {
31900 ...actions[i],
31901 callback: (items, argsObject) => {
31902 existingCallback(items, {
31903 ...argsObject,
31904 onActionPerformed: _items => {
31905 if (argsObject?.onActionPerformed) {
31906 argsObject.onActionPerformed(_items);
31907 }
31908 onActionPerformed(actions[i].id, _items);
31909 }
31910 });
31911 }
31912 };
31913 }
31914 if (actions[i].RenderModal) {
31915 const ExistingRenderModal = actions[i].RenderModal;
31916 actions[i] = {
31917 ...actions[i],
31918 RenderModal: props => {
31919 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExistingRenderModal, {
31920 ...props,
31921 onActionPerformed: _items => {
31922 if (props.onActionPerformed) {
31923 props.onActionPerformed(_items);
31924 }
31925 onActionPerformed(actions[i].id, _items);
31926 }
31927 });
31928 }
31929 };
31930 }
31931 }
31932 }
31933 return actions;
31934 }, [context, defaultActions, onActionPerformed, setAsHomepageAction, setAsPostsPageAction, shouldShowHomepageActions]);
31935 }
31936
31937 ;// ./packages/editor/build-module/components/post-actions/index.js
31938 /* wp:polyfill */
31939 /**
31940 * WordPress dependencies
31941 */
31942
31943
31944
31945
31946
31947
31948
31949 /**
31950 * Internal dependencies
31951 */
31952
31953
31954
31955 const {
31956 Menu,
31957 kebabCase
31958 } = unlock(external_wp_components_namespaceObject.privateApis);
31959 function useEditedEntityRecordsWithPermissions(postType, postIds) {
31960 const {
31961 items,
31962 permissions
31963 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31964 const {
31965 getEditedEntityRecord,
31966 getEntityRecordPermissions
31967 } = unlock(select(external_wp_coreData_namespaceObject.store));
31968 return {
31969 items: postIds.map(postId => getEditedEntityRecord('postType', postType, postId)),
31970 permissions: postIds.map(postId => getEntityRecordPermissions('postType', postType, postId))
31971 };
31972 }, [postIds, postType]);
31973 return (0,external_wp_element_namespaceObject.useMemo)(() => {
31974 return items.map((item, index) => ({
31975 ...item,
31976 permissions: permissions[index]
31977 }));
31978 }, [items, permissions]);
31979 }
31980 function PostActions({
31981 postType,
31982 postId,
31983 onActionPerformed
31984 }) {
31985 const [activeModalAction, setActiveModalAction] = (0,external_wp_element_namespaceObject.useState)(null);
31986 const _postIds = (0,external_wp_element_namespaceObject.useMemo)(() => {
31987 if (Array.isArray(postId)) {
31988 return postId;
31989 }
31990 return postId ? [postId] : [];
31991 }, [postId]);
31992 const itemsWithPermissions = useEditedEntityRecordsWithPermissions(postType, _postIds);
31993 const allActions = usePostActions({
31994 postType,
31995 onActionPerformed
31996 });
31997 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => {
31998 return allActions.filter(action => {
31999 return (!action.isEligible || itemsWithPermissions.some(itemWithPermissions => action.isEligible(itemWithPermissions))) && (itemsWithPermissions.length < 2 || action.supportsBulk);
32000 });
32001 }, [allActions, itemsWithPermissions]);
32002 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
32003 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Menu, {
32004 placement: "bottom-end",
32005 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.TriggerButton, {
32006 render: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
32007 size: "small",
32008 icon: more_vertical,
32009 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
32010 disabled: !actions.length,
32011 accessibleWhenDisabled: true,
32012 className: "editor-all-actions-button"
32013 })
32014 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.Popover, {
32015 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionsDropdownMenuGroup, {
32016 actions: actions,
32017 items: itemsWithPermissions,
32018 setActiveModalAction: setActiveModalAction
32019 })
32020 })]
32021 }), !!activeModalAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionModal, {
32022 action: activeModalAction,
32023 items: itemsWithPermissions,
32024 closeModal: () => setActiveModalAction(null)
32025 })]
32026 });
32027 }
32028
32029 // From now on all the functions on this file are copied as from the dataviews packages,
32030 // The editor packages should not be using the dataviews packages directly,
32031 // and the dataviews package should not be using the editor packages directly,
32032 // so duplicating the code here seems like the least bad option.
32033
32034 function DropdownMenuItemTrigger({
32035 action,
32036 onClick,
32037 items
32038 }) {
32039 const label = typeof action.label === 'string' ? action.label : action.label(items);
32040 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.Item, {
32041 onClick: onClick,
32042 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.ItemLabel, {
32043 children: label
32044 })
32045 });
32046 }
32047 function ActionModal({
32048 action,
32049 items,
32050 closeModal
32051 }) {
32052 const label = typeof action.label === 'string' ? action.label : action.label(items);
32053 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
32054 title: action.modalHeader || label,
32055 __experimentalHideHeader: !!action.hideModalHeader,
32056 onRequestClose: closeModal !== null && closeModal !== void 0 ? closeModal : () => {},
32057 focusOnMount: "firstContentElement",
32058 size: "medium",
32059 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
32060 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action.RenderModal, {
32061 items: items,
32062 closeModal: closeModal
32063 })
32064 });
32065 }
32066 function ActionsDropdownMenuGroup({
32067 actions,
32068 items,
32069 setActiveModalAction
32070 }) {
32071 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
32072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Menu.Group, {
32073 children: actions.map(action => {
32074 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemTrigger, {
32075 action: action,
32076 onClick: () => {
32077 if ('RenderModal' in action) {
32078 setActiveModalAction(action);
32079 return;
32080 }
32081 action.callback(items, {
32082 registry
32083 });
32084 },
32085 items: items
32086 }, action.id);
32087 })
32088 });
32089 }
32090
32091 ;// ./packages/editor/build-module/components/post-card-panel/index.js
32092 /**
32093 * WordPress dependencies
32094 */
32095
32096
32097
32098
32099
32100
32101
32102 /**
32103 * Internal dependencies
32104 */
32105
32106
32107
32108
32109
32110
32111
32112 const {
32113 Badge: post_card_panel_Badge
32114 } = unlock(external_wp_components_namespaceObject.privateApis);
32115
32116 /**
32117 * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.
32118 *
32119 * @param {Object} props - Component props.
32120 * @param {string} [props.postType] - The post type string.
32121 * @param {string|string[]} [props.postId] - The post id or list of post ids.
32122 * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.
32123 * @return {React.ReactNode} The rendered component.
32124 */
32125 function PostCardPanel({
32126 postType,
32127 postId,
32128 onActionPerformed
32129 }) {
32130 const postIds = (0,external_wp_element_namespaceObject.useMemo)(() => Array.isArray(postId) ? postId : [postId], [postId]);
32131 const {
32132 postTitle,
32133 icon,
32134 labels
32135 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32136 const {
32137 getEditedEntityRecord,
32138 getEntityRecord,
32139 getPostType
32140 } = select(external_wp_coreData_namespaceObject.store);
32141 const {
32142 getPostIcon
32143 } = unlock(select(store_store));
32144 let _title = '';
32145 const _record = getEditedEntityRecord('postType', postType, postIds[0]);
32146 if (postIds.length === 1) {
32147 var _getEntityRecord;
32148 const {
32149 default_template_types: templateTypes = []
32150 } = (_getEntityRecord = getEntityRecord('root', '__unstableBase')) !== null && _getEntityRecord !== void 0 ? _getEntityRecord : {};
32151 const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType) ? getTemplateInfo({
32152 template: _record,
32153 templateTypes
32154 }) : {};
32155 _title = _templateInfo?.title || _record?.title;
32156 }
32157 return {
32158 postTitle: _title,
32159 icon: getPostIcon(postType, {
32160 area: _record?.area
32161 }),
32162 labels: getPostType(postType)?.labels
32163 };
32164 }, [postIds, postType]);
32165 const pageTypeBadge = usePageTypeBadge(postId);
32166 let title = (0,external_wp_i18n_namespaceObject.__)('No title');
32167 if (labels?.name && postIds.length > 1) {
32168 title = (0,external_wp_i18n_namespaceObject.sprintf)(
32169 // translators: %i number of selected items %s: Name of the plural post type e.g: "Posts".
32170 (0,external_wp_i18n_namespaceObject.__)('%i %s'), postId.length, labels?.name);
32171 } else if (postTitle) {
32172 title = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(postTitle);
32173 }
32174 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32175 spacing: 1,
32176 className: "editor-post-card-panel",
32177 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
32178 spacing: 2,
32179 className: "editor-post-card-panel__header",
32180 align: "flex-start",
32181 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
32182 className: "editor-post-card-panel__icon",
32183 icon: icon
32184 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
32185 numberOfLines: 2,
32186 truncate: true,
32187 className: "editor-post-card-panel__title",
32188 as: "h2",
32189 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
32190 className: "editor-post-card-panel__title-name",
32191 children: title
32192 }), pageTypeBadge && postIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_card_panel_Badge, {
32193 children: pageTypeBadge
32194 })]
32195 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostActions, {
32196 postType: postType,
32197 postId: postId,
32198 onActionPerformed: onActionPerformed
32199 })]
32200 }), postIds.length > 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
32201 className: "editor-post-card-panel__description",
32202 children: (0,external_wp_i18n_namespaceObject.sprintf)(
32203 // translators: %s: Name of the plural post type e.g: "Posts".
32204 (0,external_wp_i18n_namespaceObject.__)('Changes will be applied to all selected %s.'), labels?.name.toLowerCase())
32205 })]
32206 });
32207 }
32208
32209 ;// ./packages/editor/build-module/components/post-content-information/index.js
32210 /**
32211 * WordPress dependencies
32212 */
32213
32214
32215
32216
32217
32218
32219
32220 /**
32221 * Internal dependencies
32222 */
32223
32224
32225
32226 // Taken from packages/editor/src/components/time-to-read/index.js.
32227
32228 const post_content_information_AVERAGE_READING_RATE = 189;
32229
32230 // This component renders the wordcount and reading time for the post.
32231 function PostContentInformation() {
32232 const {
32233 postContent
32234 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32235 const {
32236 getEditedPostAttribute,
32237 getCurrentPostType,
32238 getCurrentPostId
32239 } = select(store_store);
32240 const {
32241 canUser
32242 } = select(external_wp_coreData_namespaceObject.store);
32243 const {
32244 getEntityRecord
32245 } = select(external_wp_coreData_namespaceObject.store);
32246 const siteSettings = canUser('read', {
32247 kind: 'root',
32248 name: 'site'
32249 }) ? getEntityRecord('root', 'site') : undefined;
32250 const postType = getCurrentPostType();
32251 const _id = getCurrentPostId();
32252 const isPostsPage = +_id === siteSettings?.page_for_posts;
32253 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
32254 return {
32255 postContent: showPostContentInfo && getEditedPostAttribute('content')
32256 };
32257 }, []);
32258
32259 /*
32260 * translators: If your word count is based on single characters (e.g. East Asian characters),
32261 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
32262 * Do not translate into your own language.
32263 */
32264 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
32265 const wordsCounted = (0,external_wp_element_namespaceObject.useMemo)(() => postContent ? (0,external_wp_wordcount_namespaceObject.count)(postContent, wordCountType) : 0, [postContent, wordCountType]);
32266 if (!wordsCounted) {
32267 return null;
32268 }
32269 const readingTime = Math.round(wordsCounted / post_content_information_AVERAGE_READING_RATE);
32270 const wordsCountText = (0,external_wp_i18n_namespaceObject.sprintf)(
32271 // translators: %s: the number of words in the post.
32272 (0,external_wp_i18n_namespaceObject._n)('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
32273 const minutesText = readingTime <= 1 ? (0,external_wp_i18n_namespaceObject.__)('1 minute') : (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: the number of minutes to read the post. */
32274 (0,external_wp_i18n_namespaceObject._n)('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
32275 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
32276 className: "editor-post-content-information",
32277 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
32278 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.) */
32279 (0,external_wp_i18n_namespaceObject.__)('%1$s, %2$s read time.'), wordsCountText, minutesText)
32280 })
32281 });
32282 }
32283
32284 ;// ./packages/editor/build-module/components/post-format/panel.js
32285 /* wp:polyfill */
32286 /**
32287 * WordPress dependencies
32288 */
32289
32290
32291
32292
32293
32294
32295 /**
32296 * Internal dependencies
32297 */
32298
32299
32300
32301
32302
32303 /**
32304 * Renders the Post Author Panel component.
32305 *
32306 * @return {React.ReactNode} The rendered component.
32307 */
32308
32309 function panel_PostFormat() {
32310 const {
32311 postFormat
32312 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32313 const {
32314 getEditedPostAttribute
32315 } = select(store_store);
32316 const _postFormat = getEditedPostAttribute('format');
32317 return {
32318 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard'
32319 };
32320 }, []);
32321 const activeFormat = POST_FORMATS.find(format => format.id === postFormat);
32322
32323 // Use internal state instead of a ref to make sure that the component
32324 // re-renders when the popover's anchor updates.
32325 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
32326 // Memoize popoverProps to avoid returning a new object every time.
32327 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
32328 // Anchor the popover to the middle of the entire row so that it doesn't
32329 // move around when the label changes.
32330 anchor: popoverAnchor,
32331 placement: 'left-start',
32332 offset: 36,
32333 shift: true
32334 }), [popoverAnchor]);
32335 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatCheck, {
32336 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
32337 label: (0,external_wp_i18n_namespaceObject.__)('Format'),
32338 ref: setPopoverAnchor,
32339 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
32340 popoverProps: popoverProps,
32341 contentClassName: "editor-post-format__dialog",
32342 focusOnMount: true,
32343 renderToggle: ({
32344 isOpen,
32345 onToggle
32346 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
32347 size: "compact",
32348 variant: "tertiary",
32349 "aria-expanded": isOpen,
32350 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
32351 // translators: %s: Current post format.
32352 (0,external_wp_i18n_namespaceObject.__)('Change format: %s'), activeFormat?.caption),
32353 onClick: onToggle,
32354 children: activeFormat?.caption
32355 }),
32356 renderContent: ({
32357 onClose
32358 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
32359 className: "editor-post-format__dialog-content",
32360 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
32361 title: (0,external_wp_i18n_namespaceObject.__)('Format'),
32362 onClose: onClose
32363 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormat, {})]
32364 })
32365 })
32366 })
32367 });
32368 }
32369 /* harmony default export */ const post_format_panel = (panel_PostFormat);
32370
32371 ;// ./packages/editor/build-module/components/post-last-edited-panel/index.js
32372 /**
32373 * WordPress dependencies
32374 */
32375
32376
32377
32378
32379
32380 /**
32381 * Internal dependencies
32382 */
32383
32384
32385 function PostLastEditedPanel() {
32386 const modified = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('modified'), []);
32387 const lastEditedText = modified && (0,external_wp_i18n_namespaceObject.sprintf)(
32388 // translators: %s: Human-readable time difference, e.g. "2 days ago".
32389 (0,external_wp_i18n_namespaceObject.__)('Last edited %s.'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified));
32390 if (!lastEditedText) {
32391 return null;
32392 }
32393 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
32394 className: "editor-post-last-edited-panel",
32395 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
32396 children: lastEditedText
32397 })
32398 });
32399 }
32400
32401 ;// ./packages/editor/build-module/components/post-panel-section/index.js
32402 /**
32403 * External dependencies
32404 */
32405
32406
32407 /**
32408 * WordPress dependencies
32409 */
32410
32411
32412 function PostPanelSection({
32413 className,
32414 children
32415 }) {
32416 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
32417 className: dist_clsx('editor-post-panel__section', className),
32418 children: children
32419 });
32420 }
32421 /* harmony default export */ const post_panel_section = (PostPanelSection);
32422
32423 ;// ./packages/editor/build-module/components/blog-title/index.js
32424 /**
32425 * WordPress dependencies
32426 */
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436 /**
32437 * Internal dependencies
32438 */
32439
32440
32441
32442
32443 const blog_title_EMPTY_OBJECT = {};
32444 function BlogTitle() {
32445 const {
32446 editEntityRecord
32447 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
32448 const {
32449 postsPageTitle,
32450 postsPageId,
32451 isTemplate,
32452 postSlug
32453 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32454 const {
32455 getEntityRecord,
32456 getEditedEntityRecord,
32457 canUser
32458 } = select(external_wp_coreData_namespaceObject.store);
32459 const siteSettings = canUser('read', {
32460 kind: 'root',
32461 name: 'site'
32462 }) ? getEntityRecord('root', 'site') : undefined;
32463 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : blog_title_EMPTY_OBJECT;
32464 const {
32465 getEditedPostAttribute,
32466 getCurrentPostType
32467 } = select(store_store);
32468 return {
32469 postsPageId: _postsPageRecord?.id,
32470 postsPageTitle: _postsPageRecord?.title,
32471 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
32472 postSlug: getEditedPostAttribute('slug')
32473 };
32474 }, []);
32475 // Use internal state instead of a ref to make sure that the component
32476 // re-renders when the popover's anchor updates.
32477 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
32478 // Memoize popoverProps to avoid returning a new object every time.
32479 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
32480 // Anchor the popover to the middle of the entire row so that it doesn't
32481 // move around when the label changes.
32482 anchor: popoverAnchor,
32483 placement: 'left-start',
32484 offset: 36,
32485 shift: true
32486 }), [popoverAnchor]);
32487 if (!isTemplate || !['home', 'index'].includes(postSlug) || !postsPageId) {
32488 return null;
32489 }
32490 const setPostsPageTitle = newValue => {
32491 editEntityRecord('postType', 'page', postsPageId, {
32492 title: newValue
32493 });
32494 };
32495 const decodedTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postsPageTitle);
32496 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
32497 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
32498 ref: setPopoverAnchor,
32499 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
32500 popoverProps: popoverProps,
32501 contentClassName: "editor-blog-title-dropdown__content",
32502 focusOnMount: true,
32503 renderToggle: ({
32504 isOpen,
32505 onToggle
32506 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
32507 size: "compact",
32508 variant: "tertiary",
32509 "aria-expanded": isOpen,
32510 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
32511 // translators: %s: Current post link.
32512 (0,external_wp_i18n_namespaceObject.__)('Change blog title: %s'), decodedTitle),
32513 onClick: onToggle,
32514 children: decodedTitle
32515 }),
32516 renderContent: ({
32517 onClose
32518 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
32519 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
32520 title: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
32521 onClose: onClose
32522 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
32523 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
32524 size: "__unstable-large",
32525 value: postsPageTitle,
32526 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300),
32527 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
32528 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.'),
32529 hideLabelFromVision: true
32530 })]
32531 })
32532 })
32533 });
32534 }
32535
32536 ;// ./packages/editor/build-module/components/posts-per-page/index.js
32537 /**
32538 * WordPress dependencies
32539 */
32540
32541
32542
32543
32544
32545
32546
32547 /**
32548 * Internal dependencies
32549 */
32550
32551
32552
32553
32554 function PostsPerPage() {
32555 const {
32556 editEntityRecord
32557 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
32558 const {
32559 postsPerPage,
32560 isTemplate,
32561 postSlug
32562 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32563 const {
32564 getEditedPostAttribute,
32565 getCurrentPostType
32566 } = select(store_store);
32567 const {
32568 getEditedEntityRecord,
32569 canUser
32570 } = select(external_wp_coreData_namespaceObject.store);
32571 const siteSettings = canUser('read', {
32572 kind: 'root',
32573 name: 'site'
32574 }) ? getEditedEntityRecord('root', 'site') : undefined;
32575 return {
32576 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
32577 postSlug: getEditedPostAttribute('slug'),
32578 postsPerPage: siteSettings?.posts_per_page || 1
32579 };
32580 }, []);
32581 // Use internal state instead of a ref to make sure that the component
32582 // re-renders when the popover's anchor updates.
32583 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
32584 // Memoize popoverProps to avoid returning a new object every time.
32585 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
32586 // Anchor the popover to the middle of the entire row so that it doesn't
32587 // move around when the label changes.
32588 anchor: popoverAnchor,
32589 placement: 'left-start',
32590 offset: 36,
32591 shift: true
32592 }), [popoverAnchor]);
32593 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
32594 return null;
32595 }
32596 const setPostsPerPage = newValue => {
32597 editEntityRecord('root', 'site', undefined, {
32598 posts_per_page: newValue
32599 });
32600 };
32601 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
32602 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
32603 ref: setPopoverAnchor,
32604 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
32605 popoverProps: popoverProps,
32606 contentClassName: "editor-posts-per-page-dropdown__content",
32607 focusOnMount: true,
32608 renderToggle: ({
32609 isOpen,
32610 onToggle
32611 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
32612 size: "compact",
32613 variant: "tertiary",
32614 "aria-expanded": isOpen,
32615 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change posts per page'),
32616 onClick: onToggle,
32617 children: postsPerPage
32618 }),
32619 renderContent: ({
32620 onClose
32621 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
32622 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
32623 title: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
32624 onClose: onClose
32625 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
32626 placeholder: 0,
32627 value: postsPerPage,
32628 size: "__unstable-large",
32629 spinControls: "custom",
32630 step: "1",
32631 min: "1",
32632 onChange: setPostsPerPage,
32633 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
32634 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.'),
32635 hideLabelFromVision: true
32636 })]
32637 })
32638 })
32639 });
32640 }
32641
32642 ;// ./packages/editor/build-module/components/site-discussion/index.js
32643 /**
32644 * WordPress dependencies
32645 */
32646
32647
32648
32649
32650
32651
32652
32653 /**
32654 * Internal dependencies
32655 */
32656
32657
32658
32659
32660 const site_discussion_COMMENT_OPTIONS = [{
32661 label: (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'),
32662 value: 'open',
32663 description: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
32664 }, {
32665 label: (0,external_wp_i18n_namespaceObject.__)('Closed'),
32666 value: '',
32667 description: [(0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.'), (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')].join(' ')
32668 }];
32669 function SiteDiscussion() {
32670 const {
32671 editEntityRecord
32672 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
32673 const {
32674 allowCommentsOnNewPosts,
32675 isTemplate,
32676 postSlug
32677 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32678 const {
32679 getEditedPostAttribute,
32680 getCurrentPostType
32681 } = select(store_store);
32682 const {
32683 getEditedEntityRecord,
32684 canUser
32685 } = select(external_wp_coreData_namespaceObject.store);
32686 const siteSettings = canUser('read', {
32687 kind: 'root',
32688 name: 'site'
32689 }) ? getEditedEntityRecord('root', 'site') : undefined;
32690 return {
32691 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
32692 postSlug: getEditedPostAttribute('slug'),
32693 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ''
32694 };
32695 }, []);
32696 // Use internal state instead of a ref to make sure that the component
32697 // re-renders when the popover's anchor updates.
32698 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
32699 // Memoize popoverProps to avoid returning a new object every time.
32700 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
32701 // Anchor the popover to the middle of the entire row so that it doesn't
32702 // move around when the label changes.
32703 anchor: popoverAnchor,
32704 placement: 'left-start',
32705 offset: 36,
32706 shift: true
32707 }), [popoverAnchor]);
32708 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
32709 return null;
32710 }
32711 const setAllowCommentsOnNewPosts = newValue => {
32712 editEntityRecord('root', 'site', undefined, {
32713 default_comment_status: newValue ? 'open' : null
32714 });
32715 };
32716 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
32717 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
32718 ref: setPopoverAnchor,
32719 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
32720 popoverProps: popoverProps,
32721 contentClassName: "editor-site-discussion-dropdown__content",
32722 focusOnMount: true,
32723 renderToggle: ({
32724 isOpen,
32725 onToggle
32726 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
32727 size: "compact",
32728 variant: "tertiary",
32729 "aria-expanded": isOpen,
32730 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion settings'),
32731 onClick: onToggle,
32732 children: allowCommentsOnNewPosts ? (0,external_wp_i18n_namespaceObject.__)('Comments open') : (0,external_wp_i18n_namespaceObject.__)('Comments closed')
32733 }),
32734 renderContent: ({
32735 onClose
32736 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
32737 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
32738 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
32739 onClose: onClose
32740 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32741 spacing: 3,
32742 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
32743 children: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.')
32744 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
32745 className: "editor-site-discussion__options",
32746 hideLabelFromVision: true,
32747 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
32748 options: site_discussion_COMMENT_OPTIONS,
32749 onChange: setAllowCommentsOnNewPosts,
32750 selected: allowCommentsOnNewPosts
32751 })]
32752 })]
32753 })
32754 })
32755 });
32756 }
32757
32758 ;// ./packages/editor/build-module/components/sidebar/post-summary.js
32759 /**
32760 * WordPress dependencies
32761 */
32762
32763
32764
32765 /**
32766 * Internal dependencies
32767 */
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791 /**
32792 * Module Constants
32793 */
32794
32795 const post_summary_PANEL_NAME = 'post-status';
32796 function PostSummary({
32797 onActionPerformed
32798 }) {
32799 const {
32800 isRemovedPostStatusPanel,
32801 postType,
32802 postId
32803 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32804 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
32805 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
32806 const {
32807 isEditorPanelRemoved,
32808 getCurrentPostType,
32809 getCurrentPostId
32810 } = select(store_store);
32811 return {
32812 isRemovedPostStatusPanel: isEditorPanelRemoved(post_summary_PANEL_NAME),
32813 postType: getCurrentPostType(),
32814 postId: getCurrentPostId()
32815 };
32816 }, []);
32817 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_section, {
32818 className: "editor-post-summary",
32819 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info.Slot, {
32820 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
32821 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32822 spacing: 4,
32823 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostCardPanel, {
32824 postType: postType,
32825 postId: postId,
32826 onActionPerformed: onActionPerformed
32827 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFeaturedImagePanel, {
32828 withPanelBody: false
32829 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostExcerptPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32830 spacing: 1,
32831 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostContentInformation, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostLastEditedPanel, {})]
32832 }), !isRemovedPostStatusPanel && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32833 spacing: 4,
32834 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
32835 spacing: 1,
32836 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, {}), fills]
32837 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTrash, {
32838 onActionPerformed: onActionPerformed
32839 })]
32840 })]
32841 })
32842 })
32843 })
32844 });
32845 }
32846
32847 ;// ./packages/editor/build-module/components/post-transform-panel/hooks.js
32848 /* wp:polyfill */
32849 /**
32850 * WordPress dependencies
32851 */
32852
32853
32854
32855
32856
32857
32858 /**
32859 * Internal dependencies
32860 */
32861
32862
32863 const {
32864 EXCLUDED_PATTERN_SOURCES,
32865 PATTERN_TYPES: hooks_PATTERN_TYPES
32866 } = unlock(external_wp_patterns_namespaceObject.privateApis);
32867 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
32868 block.innerBlocks = block.innerBlocks.map(innerBlock => {
32869 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet);
32870 });
32871 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
32872 block.attributes.theme = currentThemeStylesheet;
32873 }
32874 return block;
32875 }
32876
32877 /**
32878 * Filter all patterns and return only the ones that are compatible with the current template.
32879 *
32880 * @param {Array} patterns An array of patterns.
32881 * @param {Object} template The current template.
32882 * @return {Array} Array of patterns that are compatible with the current template.
32883 */
32884 function filterPatterns(patterns, template) {
32885 // Filter out duplicates.
32886 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name);
32887
32888 // Filter out core/directory patterns not included in theme.json.
32889 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
32890
32891 // Looks for patterns that have the same template type as the current template,
32892 // or have a block type that matches the current template area.
32893 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug) || pattern.blockTypes?.includes('core/template-part/' + template.area);
32894 return patterns.filter((pattern, index, items) => {
32895 return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
32896 });
32897 }
32898 function preparePatterns(patterns, currentThemeStylesheet) {
32899 return patterns.map(pattern => ({
32900 ...pattern,
32901 keywords: pattern.keywords || [],
32902 type: hooks_PATTERN_TYPES.theme,
32903 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
32904 __unstableSkipMigrationLogs: true
32905 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet))
32906 }));
32907 }
32908 function useAvailablePatterns(template) {
32909 const {
32910 blockPatterns,
32911 restBlockPatterns,
32912 currentThemeStylesheet
32913 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32914 var _settings$__experimen;
32915 const {
32916 getEditorSettings
32917 } = select(store_store);
32918 const settings = getEditorSettings();
32919 return {
32920 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns,
32921 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
32922 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet
32923 };
32924 }, []);
32925 return (0,external_wp_element_namespaceObject.useMemo)(() => {
32926 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])];
32927 const filteredPatterns = filterPatterns(mergedPatterns, template);
32928 return preparePatterns(filteredPatterns, template, currentThemeStylesheet);
32929 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]);
32930 }
32931
32932 ;// ./packages/editor/build-module/components/post-transform-panel/index.js
32933 /**
32934 * WordPress dependencies
32935 */
32936
32937
32938
32939
32940
32941
32942
32943 /**
32944 * Internal dependencies
32945 */
32946
32947
32948
32949
32950 function post_transform_panel_TemplatesList({
32951 availableTemplates,
32952 onSelect
32953 }) {
32954 if (!availableTemplates || availableTemplates?.length === 0) {
32955 return null;
32956 }
32957 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
32958 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
32959 blockPatterns: availableTemplates,
32960 onClickPattern: onSelect,
32961 showTitlesAsTooltip: true
32962 });
32963 }
32964 function PostTransform() {
32965 const {
32966 record,
32967 postType,
32968 postId
32969 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32970 const {
32971 getCurrentPostType,
32972 getCurrentPostId
32973 } = select(store_store);
32974 const {
32975 getEditedEntityRecord
32976 } = select(external_wp_coreData_namespaceObject.store);
32977 const type = getCurrentPostType();
32978 const id = getCurrentPostId();
32979 return {
32980 postType: type,
32981 postId: id,
32982 record: getEditedEntityRecord('postType', type, id)
32983 };
32984 }, []);
32985 const {
32986 editEntityRecord
32987 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
32988 const availablePatterns = useAvailablePatterns(record);
32989 const onTemplateSelect = async selectedTemplate => {
32990 await editEntityRecord('postType', postType, postId, {
32991 blocks: selectedTemplate.blocks,
32992 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks)
32993 });
32994 };
32995 if (!availablePatterns?.length) {
32996 return null;
32997 }
32998 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
32999 title: (0,external_wp_i18n_namespaceObject.__)('Design'),
33000 initialOpen: record.type === TEMPLATE_PART_POST_TYPE,
33001 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_transform_panel_TemplatesList, {
33002 availableTemplates: availablePatterns,
33003 onSelect: onTemplateSelect
33004 })
33005 });
33006 }
33007 function PostTransformPanel() {
33008 const {
33009 postType
33010 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33011 const {
33012 getCurrentPostType
33013 } = select(store_store);
33014 return {
33015 postType: getCurrentPostType()
33016 };
33017 }, []);
33018 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
33019 return null;
33020 }
33021 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransform, {});
33022 }
33023
33024 ;// ./packages/editor/build-module/components/sidebar/constants.js
33025 const sidebars = {
33026 document: 'edit-post/document',
33027 block: 'edit-post/block'
33028 };
33029
33030 ;// ./packages/editor/build-module/components/sidebar/header.js
33031 /**
33032 * WordPress dependencies
33033 */
33034
33035
33036
33037
33038
33039 /**
33040 * Internal dependencies
33041 */
33042
33043
33044
33045
33046 const {
33047 Tabs
33048 } = unlock(external_wp_components_namespaceObject.privateApis);
33049 const SidebarHeader = (_, ref) => {
33050 const {
33051 documentLabel
33052 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33053 const {
33054 getPostTypeLabel
33055 } = select(store_store);
33056 return {
33057 documentLabel:
33058 // translators: Default label for the Document sidebar tab, not selected.
33059 getPostTypeLabel() || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun, sidebar')
33060 };
33061 }, []);
33062 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs.TabList, {
33063 ref: ref,
33064 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
33065 tabId: sidebars.document
33066 // Used for focus management in the SettingsSidebar component.
33067 ,
33068 "data-tab-id": sidebars.document,
33069 children: documentLabel
33070 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
33071 tabId: sidebars.block
33072 // Used for focus management in the SettingsSidebar component.
33073 ,
33074 "data-tab-id": sidebars.block,
33075 children: (0,external_wp_i18n_namespaceObject.__)('Block')
33076 })]
33077 });
33078 };
33079 /* harmony default export */ const sidebar_header = ((0,external_wp_element_namespaceObject.forwardRef)(SidebarHeader));
33080
33081 ;// ./packages/editor/build-module/components/template-content-panel/index.js
33082 /**
33083 * WordPress dependencies
33084 */
33085
33086
33087
33088
33089
33090
33091
33092
33093 /**
33094 * Internal dependencies
33095 */
33096
33097
33098
33099
33100 const {
33101 BlockQuickNavigation
33102 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
33103 const template_content_panel_POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
33104 const TEMPLATE_PART_BLOCK = 'core/template-part';
33105 function TemplateContentPanel() {
33106 const postContentBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', template_content_panel_POST_CONTENT_BLOCK_TYPES), []);
33107 const {
33108 clientIds,
33109 postType,
33110 renderingMode
33111 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33112 const {
33113 getCurrentPostType,
33114 getPostBlocksByName,
33115 getRenderingMode
33116 } = unlock(select(store_store));
33117 const _postType = getCurrentPostType();
33118 return {
33119 postType: _postType,
33120 clientIds: getPostBlocksByName(TEMPLATE_POST_TYPE === _postType ? TEMPLATE_PART_BLOCK : postContentBlockTypes),
33121 renderingMode: getRenderingMode()
33122 };
33123 }, [postContentBlockTypes]);
33124 const {
33125 enableComplementaryArea
33126 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
33127 if (renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE || clientIds.length === 0) {
33128 return null;
33129 }
33130 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
33131 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
33132 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
33133 clientIds: clientIds,
33134 onSelect: () => {
33135 enableComplementaryArea('core', 'edit-post/document');
33136 }
33137 })
33138 });
33139 }
33140
33141 ;// ./packages/editor/build-module/components/template-part-content-panel/index.js
33142 /* wp:polyfill */
33143 /**
33144 * WordPress dependencies
33145 */
33146
33147
33148
33149
33150
33151
33152
33153 /**
33154 * Internal dependencies
33155 */
33156
33157
33158
33159
33160 const {
33161 BlockQuickNavigation: template_part_content_panel_BlockQuickNavigation
33162 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
33163 function TemplatePartContentPanelInner() {
33164 const blockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => {
33165 const {
33166 getBlockTypes
33167 } = select(external_wp_blocks_namespaceObject.store);
33168 return getBlockTypes();
33169 }, []);
33170 const themeBlockNames = (0,external_wp_element_namespaceObject.useMemo)(() => {
33171 return blockTypes.filter(blockType => {
33172 return blockType.category === 'theme';
33173 }).map(({
33174 name
33175 }) => name);
33176 }, [blockTypes]);
33177 const themeBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => {
33178 const {
33179 getBlocksByName
33180 } = select(external_wp_blockEditor_namespaceObject.store);
33181 return getBlocksByName(themeBlockNames);
33182 }, [themeBlockNames]);
33183 if (themeBlocks.length === 0) {
33184 return null;
33185 }
33186 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
33187 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
33188 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(template_part_content_panel_BlockQuickNavigation, {
33189 clientIds: themeBlocks
33190 })
33191 });
33192 }
33193 function TemplatePartContentPanel() {
33194 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
33195 const {
33196 getCurrentPostType
33197 } = select(store_store);
33198 return getCurrentPostType();
33199 }, []);
33200 if (postType !== TEMPLATE_PART_POST_TYPE) {
33201 return null;
33202 }
33203 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartContentPanelInner, {});
33204 }
33205
33206 ;// ./packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js
33207 /**
33208 * WordPress dependencies
33209 */
33210
33211
33212
33213
33214
33215
33216 /**
33217 * This listener hook monitors for block selection and triggers the appropriate
33218 * sidebar state.
33219 */
33220 function useAutoSwitchEditorSidebars() {
33221 const {
33222 hasBlockSelection
33223 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33224 return {
33225 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
33226 };
33227 }, []);
33228 const {
33229 getActiveComplementaryArea
33230 } = (0,external_wp_data_namespaceObject.useSelect)(store);
33231 const {
33232 enableComplementaryArea
33233 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
33234 const {
33235 get: getPreference
33236 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
33237 (0,external_wp_element_namespaceObject.useEffect)(() => {
33238 const activeGeneralSidebar = getActiveComplementaryArea('core');
33239 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
33240 const isDistractionFree = getPreference('core', 'distractionFree');
33241 if (!isEditorSidebarOpened || isDistractionFree) {
33242 return;
33243 }
33244 if (hasBlockSelection) {
33245 enableComplementaryArea('core', 'edit-post/block');
33246 } else {
33247 enableComplementaryArea('core', 'edit-post/document');
33248 }
33249 }, [hasBlockSelection, getActiveComplementaryArea, enableComplementaryArea, getPreference]);
33250 }
33251 /* harmony default export */ const use_auto_switch_editor_sidebars = (useAutoSwitchEditorSidebars);
33252
33253 ;// ./packages/editor/build-module/components/sidebar/index.js
33254 /* wp:polyfill */
33255 /**
33256 * WordPress dependencies
33257 */
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267 /**
33268 * Internal dependencies
33269 */
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285 const {
33286 Tabs: sidebar_Tabs
33287 } = unlock(external_wp_components_namespaceObject.privateApis);
33288 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
33289 web: true,
33290 native: false
33291 });
33292 const SidebarContent = ({
33293 tabName,
33294 keyboardShortcut,
33295 onActionPerformed,
33296 extraPanels
33297 }) => {
33298 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null);
33299 // Because `PluginSidebar` renders a `ComplementaryArea`, we
33300 // need to forward the `Tabs` context so it can be passed through the
33301 // underlying slot/fill.
33302 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_Tabs.Context);
33303
33304 // This effect addresses a race condition caused by tabbing from the last
33305 // block in the editor into the settings sidebar. Without this effect, the
33306 // selected tab and browser focus can become separated in an unexpected way
33307 // (e.g the "block" tab is focused, but the "post" tab is selected).
33308 (0,external_wp_element_namespaceObject.useEffect)(() => {
33309 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
33310 const selectedTabElement = tabsElements.find(
33311 // We are purposefully using a custom `data-tab-id` attribute here
33312 // because we don't want rely on any assumptions about `Tabs`
33313 // component internals.
33314 element => element.getAttribute('data-tab-id') === tabName);
33315 const activeElement = selectedTabElement?.ownerDocument.activeElement;
33316 const tabsHasFocus = tabsElements.some(element => {
33317 return activeElement && activeElement.id === element.id;
33318 });
33319 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
33320 selectedTabElement?.focus();
33321 }
33322 }, [tabName]);
33323 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
33324 identifier: tabName,
33325 header: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.Context.Provider, {
33326 value: tabsContextValue,
33327 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_header, {
33328 ref: tabListRef
33329 })
33330 }),
33331 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings')
33332 // This classname is added so we can apply a corrective negative
33333 // margin to the panel.
33334 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
33335 ,
33336 className: "editor-sidebar__panel",
33337 headerClassName: "editor-sidebar__panel-tabs",
33338 title: /* translators: button label text should, if possible, be under 16 characters. */
33339 (0,external_wp_i18n_namespaceObject._x)('Settings', 'sidebar button label'),
33340 toggleShortcut: keyboardShortcut,
33341 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
33342 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
33343 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.Context.Provider, {
33344 value: tabsContextValue,
33345 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.TabPanel, {
33346 tabId: sidebars.document,
33347 focusable: false,
33348 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSummary, {
33349 onActionPerformed: onActionPerformed
33350 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransformPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(panel_PostTaxonomies, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesPanel, {}), extraPanels]
33351 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.TabPanel, {
33352 tabId: sidebars.block,
33353 focusable: false,
33354 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {})
33355 })]
33356 })
33357 });
33358 };
33359 const Sidebar = ({
33360 extraPanels,
33361 onActionPerformed
33362 }) => {
33363 use_auto_switch_editor_sidebars();
33364 const {
33365 tabName,
33366 keyboardShortcut,
33367 showSummary
33368 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33369 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar');
33370 const sidebar = select(store).getActiveComplementaryArea('core');
33371 const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
33372 let _tabName = sidebar;
33373 if (!_isEditorSidebarOpened) {
33374 _tabName = !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() ? sidebars.block : sidebars.document;
33375 }
33376 return {
33377 tabName: _tabName,
33378 keyboardShortcut: shortcut,
33379 showSummary: ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE].includes(select(store_store).getCurrentPostType())
33380 };
33381 }, []);
33382 const {
33383 enableComplementaryArea
33384 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
33385 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => {
33386 if (!!newSelectedTabId) {
33387 enableComplementaryArea('core', newSelectedTabId);
33388 }
33389 }, [enableComplementaryArea]);
33390 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs, {
33391 selectedTabId: tabName,
33392 onSelect: onTabSelect,
33393 selectOnMove: false,
33394 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarContent, {
33395 tabName: tabName,
33396 keyboardShortcut: keyboardShortcut,
33397 showSummary: showSummary,
33398 onActionPerformed: onActionPerformed,
33399 extraPanels: extraPanels
33400 })
33401 });
33402 };
33403 /* harmony default export */ const components_sidebar = (Sidebar);
33404
33405 ;// ./packages/editor/build-module/components/editor/index.js
33406 /**
33407 * WordPress dependencies
33408 */
33409
33410
33411
33412
33413
33414 /**
33415 * Internal dependencies
33416 */
33417
33418
33419
33420
33421
33422 function Editor({
33423 postType,
33424 postId,
33425 templateId,
33426 settings,
33427 children,
33428 initialEdits,
33429 // This could be part of the settings.
33430 onActionPerformed,
33431 // The following abstractions are not ideal but necessary
33432 // to account for site editor and post editor differences for now.
33433 extraContent,
33434 extraSidebarPanels,
33435 ...props
33436 }) {
33437 const {
33438 post,
33439 template,
33440 hasLoadedPost
33441 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33442 const {
33443 getEntityRecord,
33444 hasFinishedResolution
33445 } = select(external_wp_coreData_namespaceObject.store);
33446 return {
33447 post: getEntityRecord('postType', postType, postId),
33448 template: templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId) : undefined,
33449 hasLoadedPost: hasFinishedResolution('getEntityRecord', ['postType', postType, postId])
33450 };
33451 }, [postType, postId, templateId]);
33452 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
33453 children: [hasLoadedPost && !post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
33454 status: "warning",
33455 isDismissible: false,
33456 children: (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")
33457 }), !!post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ExperimentalEditorProvider, {
33458 post: post,
33459 __unstableTemplate: template,
33460 settings: settings,
33461 initialEdits: initialEdits,
33462 useSubRegistry: false,
33463 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorInterface, {
33464 ...props,
33465 children: extraContent
33466 }), children, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_sidebar, {
33467 onActionPerformed: onActionPerformed,
33468 extraPanels: extraSidebarPanels
33469 })]
33470 })]
33471 });
33472 }
33473 /* harmony default export */ const editor = (Editor);
33474
33475 ;// ./packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js
33476 /**
33477 * WordPress dependencies
33478 */
33479
33480
33481
33482 /**
33483 * Internal dependencies
33484 */
33485
33486
33487
33488 const {
33489 PreferenceBaseOption: enable_publish_sidebar_PreferenceBaseOption
33490 } = unlock(external_wp_preferences_namespaceObject.privateApis);
33491 function EnablePublishSidebarOption(props) {
33492 const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => {
33493 return select(store_store).isPublishSidebarEnabled();
33494 }, []);
33495 const {
33496 enablePublishSidebar,
33497 disablePublishSidebar
33498 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
33499 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_publish_sidebar_PreferenceBaseOption, {
33500 isChecked: isChecked,
33501 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar(),
33502 ...props
33503 });
33504 }
33505
33506 ;// ./packages/editor/build-module/components/preferences-modal/block-visibility.js
33507 /* wp:polyfill */
33508 /**
33509 * WordPress dependencies
33510 */
33511
33512
33513
33514
33515
33516
33517 /**
33518 * Internal dependencies
33519 */
33520
33521
33522
33523 const {
33524 BlockManager
33525 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
33526 function BlockVisibility() {
33527 const {
33528 showBlockTypes,
33529 hideBlockTypes
33530 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
33531 const {
33532 blockTypes,
33533 allowedBlockTypes: _allowedBlockTypes,
33534 hiddenBlockTypes: _hiddenBlockTypes
33535 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33536 var _select$get;
33537 return {
33538 blockTypes: select(external_wp_blocks_namespaceObject.store).getBlockTypes(),
33539 allowedBlockTypes: select(store_store).getEditorSettings().allowedBlockTypes,
33540 hiddenBlockTypes: (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : []
33541 };
33542 }, []);
33543 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
33544 if (_allowedBlockTypes === true) {
33545 return blockTypes;
33546 }
33547 return blockTypes.filter(({
33548 name
33549 }) => {
33550 return _allowedBlockTypes?.includes(name);
33551 });
33552 }, [_allowedBlockTypes, blockTypes]);
33553 const filteredBlockTypes = allowedBlockTypes.filter(blockType => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'inserter', true) && (!blockType.parent || blockType.parent.includes('core/post-content')));
33554
33555 // Some hidden blocks become unregistered
33556 // by removing for instance the plugin that registered them, yet
33557 // they're still remain as hidden by the user's action.
33558 // We consider "hidden", blocks which were hidden and
33559 // are still registered.
33560 const hiddenBlockTypes = _hiddenBlockTypes.filter(hiddenBlock => {
33561 return filteredBlockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
33562 });
33563 const selectedBlockTypes = filteredBlockTypes.filter(blockType => !hiddenBlockTypes.includes(blockType.name));
33564 const onChangeSelectedBlockTypes = newSelectedBlockTypes => {
33565 if (selectedBlockTypes.length > newSelectedBlockTypes.length) {
33566 const blockTypesToHide = selectedBlockTypes.filter(blockType => !newSelectedBlockTypes.find(({
33567 name
33568 }) => name === blockType.name));
33569 hideBlockTypes(blockTypesToHide.map(({
33570 name
33571 }) => name));
33572 } else if (selectedBlockTypes.length < newSelectedBlockTypes.length) {
33573 const blockTypesToShow = newSelectedBlockTypes.filter(blockType => !selectedBlockTypes.find(({
33574 name
33575 }) => name === blockType.name));
33576 showBlockTypes(blockTypesToShow.map(({
33577 name
33578 }) => name));
33579 }
33580 };
33581 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockManager, {
33582 blockTypes: filteredBlockTypes,
33583 selectedBlockTypes: selectedBlockTypes,
33584 onChange: onChangeSelectedBlockTypes
33585 });
33586 }
33587
33588 ;// ./packages/editor/build-module/components/preferences-modal/index.js
33589 /* wp:polyfill */
33590 /**
33591 * WordPress dependencies
33592 */
33593
33594
33595
33596
33597
33598
33599
33600
33601 /**
33602 * Internal dependencies
33603 */
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616 const {
33617 PreferencesModal,
33618 PreferencesModalTabs,
33619 PreferencesModalSection,
33620 PreferenceToggleControl
33621 } = unlock(external_wp_preferences_namespaceObject.privateApis);
33622 function EditorPreferencesModal({
33623 extraSections = {}
33624 }) {
33625 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => {
33626 return select(store).isModalActive('editor/preferences');
33627 }, []);
33628 const {
33629 closeModal
33630 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
33631 if (!isActive) {
33632 return null;
33633 }
33634
33635 // Please wrap all contents inside PreferencesModalContents to prevent all
33636 // hooks from executing when the modal is not open.
33637 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
33638 closeModal: closeModal,
33639 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalContents, {
33640 extraSections: extraSections
33641 })
33642 });
33643 }
33644 function PreferencesModalContents({
33645 extraSections = {}
33646 }) {
33647 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
33648 const showBlockBreadcrumbsOption = (0,external_wp_data_namespaceObject.useSelect)(select => {
33649 const {
33650 getEditorSettings
33651 } = select(store_store);
33652 const {
33653 get
33654 } = select(external_wp_preferences_namespaceObject.store);
33655 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
33656 const isDistractionFreeEnabled = get('core', 'distractionFree');
33657 return !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled;
33658 }, [isLargeViewport]);
33659 const {
33660 setIsListViewOpened,
33661 setIsInserterOpened
33662 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
33663 const {
33664 set: setPreference
33665 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
33666 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
33667 name: 'general',
33668 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
33669 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
33670 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
33671 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
33672 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33673 scope: "core",
33674 featureName: "showListViewByDefault",
33675 help: (0,external_wp_i18n_namespaceObject.__)('Opens the List View sidebar by default.'),
33676 label: (0,external_wp_i18n_namespaceObject.__)('Always open List View')
33677 }), showBlockBreadcrumbsOption && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33678 scope: "core",
33679 featureName: "showBlockBreadcrumbs",
33680 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'),
33681 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs')
33682 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33683 scope: "core",
33684 featureName: "allowRightClickOverrides",
33685 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual List View menus via right-click, overriding browser defaults.'),
33686 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus')
33687 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33688 scope: "core",
33689 featureName: "enableChoosePatternModal",
33690 help: (0,external_wp_i18n_namespaceObject.__)('Shows starter patterns when creating a new page.'),
33691 label: (0,external_wp_i18n_namespaceObject.__)('Show starter patterns')
33692 })]
33693 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
33694 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
33695 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.'),
33696 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
33697 taxonomyWrapper: (content, taxonomy) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
33698 label: taxonomy.labels.menu_name,
33699 panelName: `taxonomy-panel-${taxonomy.slug}`
33700 })
33701 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
33702 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
33703 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
33704 panelName: "featured-image"
33705 })
33706 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
33707 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
33708 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
33709 panelName: "post-excerpt"
33710 })
33711 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
33712 supportKeys: ['comments', 'trackbacks'],
33713 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
33714 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
33715 panelName: "discussion-panel"
33716 })
33717 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
33718 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
33719 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
33720 panelName: "page-attributes"
33721 })
33722 })]
33723 }), isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
33724 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
33725 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePublishSidebarOption, {
33726 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
33727 label: (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks')
33728 })
33729 }), extraSections?.general]
33730 })
33731 }, {
33732 name: 'appearance',
33733 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
33734 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
33735 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
33736 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.'),
33737 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33738 scope: "core",
33739 featureName: "fixedToolbar",
33740 onToggle: () => setPreference('core', 'distractionFree', false),
33741 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'),
33742 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar')
33743 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33744 scope: "core",
33745 featureName: "distractionFree",
33746 onToggle: () => {
33747 setPreference('core', 'fixedToolbar', true);
33748 setIsInserterOpened(false);
33749 setIsListViewOpened(false);
33750 },
33751 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'),
33752 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free')
33753 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33754 scope: "core",
33755 featureName: "focusMode",
33756 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
33757 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
33758 }), extraSections?.appearance]
33759 })
33760 }, {
33761 name: 'accessibility',
33762 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'),
33763 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
33764 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
33765 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
33766 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.'),
33767 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33768 scope: "core",
33769 featureName: "keepCaretInsideBlock",
33770 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.'),
33771 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
33772 })
33773 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
33774 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
33775 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33776 scope: "core",
33777 featureName: "showIconLabels",
33778 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
33779 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.')
33780 })
33781 })]
33782 })
33783 }, {
33784 name: 'blocks',
33785 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
33786 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
33787 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
33788 title: (0,external_wp_i18n_namespaceObject.__)('Inserter'),
33789 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33790 scope: "core",
33791 featureName: "mostUsedBlocks",
33792 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'),
33793 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
33794 })
33795 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
33796 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'),
33797 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."),
33798 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockVisibility, {})
33799 })]
33800 })
33801 }, window.__experimentalMediaProcessing && {
33802 name: 'media',
33803 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Media'),
33804 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
33805 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
33806 title: (0,external_wp_i18n_namespaceObject.__)('General'),
33807 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the media upload flow.'),
33808 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33809 scope: "core/media",
33810 featureName: "optimizeOnUpload",
33811 help: (0,external_wp_i18n_namespaceObject.__)('Compress media items before uploading to the server.'),
33812 label: (0,external_wp_i18n_namespaceObject.__)('Pre-upload compression')
33813 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
33814 scope: "core/media",
33815 featureName: "requireApproval",
33816 help: (0,external_wp_i18n_namespaceObject.__)('Require approval step when optimizing existing media.'),
33817 label: (0,external_wp_i18n_namespaceObject.__)('Approval step')
33818 })]
33819 })
33820 })
33821 }].filter(Boolean), [showBlockBreadcrumbsOption, extraSections, setIsInserterOpened, setIsListViewOpened, setPreference, isLargeViewport]);
33822 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalTabs, {
33823 sections: sections
33824 });
33825 }
33826
33827 ;// ./packages/editor/build-module/components/post-fields/index.js
33828 /* wp:polyfill */
33829 /**
33830 * WordPress dependencies
33831 */
33832
33833
33834
33835 /**
33836 * Internal dependencies
33837 */
33838
33839
33840 function usePostFields({
33841 postType
33842 }) {
33843 const {
33844 registerPostTypeSchema
33845 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
33846 (0,external_wp_element_namespaceObject.useEffect)(() => {
33847 registerPostTypeSchema(postType);
33848 }, [registerPostTypeSchema, postType]);
33849 const {
33850 defaultFields
33851 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
33852 const {
33853 getEntityFields
33854 } = unlock(select(store_store));
33855 return {
33856 defaultFields: getEntityFields('postType', postType)
33857 };
33858 }, [postType]);
33859 const {
33860 records: authors,
33861 isResolving: isLoadingAuthors
33862 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('root', 'user', {
33863 per_page: -1
33864 });
33865 const fields = (0,external_wp_element_namespaceObject.useMemo)(() => defaultFields.map(field => {
33866 if (field.id === 'author') {
33867 return {
33868 ...field,
33869 elements: authors?.map(({
33870 id,
33871 name
33872 }) => ({
33873 value: id,
33874 label: name
33875 }))
33876 };
33877 }
33878 return field;
33879 }), [authors, defaultFields]);
33880 return {
33881 isLoading: isLoadingAuthors,
33882 fields
33883 };
33884 }
33885
33886 /**
33887 * Hook to get the fields for a post (BasePost or BasePostWithEmbeddedAuthor).
33888 */
33889 /* harmony default export */ const post_fields = (usePostFields);
33890
33891 ;// ./packages/editor/build-module/bindings/pattern-overrides.js
33892 /* wp:polyfill */
33893 /**
33894 * WordPress dependencies
33895 */
33896
33897 const CONTENT = 'content';
33898 /* harmony default export */ const pattern_overrides = ({
33899 name: 'core/pattern-overrides',
33900 getValues({
33901 select,
33902 clientId,
33903 context,
33904 bindings
33905 }) {
33906 const patternOverridesContent = context['pattern/overrides'];
33907 const {
33908 getBlockAttributes
33909 } = select(external_wp_blockEditor_namespaceObject.store);
33910 const currentBlockAttributes = getBlockAttributes(clientId);
33911 const overridesValues = {};
33912 for (const attributeName of Object.keys(bindings)) {
33913 const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
33914
33915 // If it has not been overriden, return the original value.
33916 // Check undefined because empty string is a valid value.
33917 if (overridableValue === undefined) {
33918 overridesValues[attributeName] = currentBlockAttributes[attributeName];
33919 continue;
33920 } else {
33921 overridesValues[attributeName] = overridableValue === '' ? undefined : overridableValue;
33922 }
33923 }
33924 return overridesValues;
33925 },
33926 setValues({
33927 select,
33928 dispatch,
33929 clientId,
33930 bindings
33931 }) {
33932 const {
33933 getBlockAttributes,
33934 getBlockParentsByBlockName,
33935 getBlocks
33936 } = select(external_wp_blockEditor_namespaceObject.store);
33937 const currentBlockAttributes = getBlockAttributes(clientId);
33938 const blockName = currentBlockAttributes?.metadata?.name;
33939 if (!blockName) {
33940 return;
33941 }
33942 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
33943
33944 // Extract the updated attributes from the source bindings.
33945 const attributes = Object.entries(bindings).reduce((attrs, [key, {
33946 newValue
33947 }]) => {
33948 attrs[key] = newValue;
33949 return attrs;
33950 }, {});
33951
33952 // If there is no pattern client ID, sync blocks with the same name and same attributes.
33953 if (!patternClientId) {
33954 const syncBlocksWithSameName = blocks => {
33955 for (const block of blocks) {
33956 if (block.attributes?.metadata?.name === blockName) {
33957 dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(block.clientId, attributes);
33958 }
33959 syncBlocksWithSameName(block.innerBlocks);
33960 }
33961 };
33962 syncBlocksWithSameName(getBlocks());
33963 return;
33964 }
33965 const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
33966 dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(patternClientId, {
33967 [CONTENT]: {
33968 ...currentBindingValue,
33969 [blockName]: {
33970 ...currentBindingValue?.[blockName],
33971 ...Object.entries(attributes).reduce((acc, [key, value]) => {
33972 // TODO: We need a way to represent `undefined` in the serialized overrides.
33973 // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
33974 // We use an empty string to represent undefined for now until
33975 // we support a richer format for overrides and the block bindings API.
33976 acc[key] = value === undefined ? '' : value;
33977 return acc;
33978 }, {})
33979 }
33980 }
33981 });
33982 },
33983 canUserEditValue: () => true
33984 });
33985
33986 ;// ./packages/editor/build-module/bindings/post-meta.js
33987 /* wp:polyfill */
33988 /**
33989 * WordPress dependencies
33990 */
33991
33992
33993 /**
33994 * Internal dependencies
33995 */
33996
33997
33998
33999 /**
34000 * Gets a list of post meta fields with their values and labels
34001 * to be consumed in the needed callbacks.
34002 * If the value is not available based on context, like in templates,
34003 * it falls back to the default value, label, or key.
34004 *
34005 * @param {Object} select The select function from the data store.
34006 * @param {Object} context The context provided.
34007 * @return {Object} List of post meta fields with their value and label.
34008 *
34009 * @example
34010 * ```js
34011 * {
34012 * field_1_key: {
34013 * label: 'Field 1 Label',
34014 * value: 'Field 1 Value',
34015 * },
34016 * field_2_key: {
34017 * label: 'Field 2 Label',
34018 * value: 'Field 2 Value',
34019 * },
34020 * ...
34021 * }
34022 * ```
34023 */
34024 function getPostMetaFields(select, context) {
34025 const {
34026 getEditedEntityRecord
34027 } = select(external_wp_coreData_namespaceObject.store);
34028 const {
34029 getRegisteredPostMeta
34030 } = unlock(select(external_wp_coreData_namespaceObject.store));
34031 let entityMetaValues;
34032 // Try to get the current entity meta values.
34033 if (context?.postType && context?.postId) {
34034 entityMetaValues = getEditedEntityRecord('postType', context?.postType, context?.postId).meta;
34035 }
34036 const registeredFields = getRegisteredPostMeta(context?.postType);
34037 const metaFields = {};
34038 Object.entries(registeredFields || {}).forEach(([key, props]) => {
34039 // Don't include footnotes or private fields.
34040 if (key !== 'footnotes' && key.charAt(0) !== '_') {
34041 var _entityMetaValues$key;
34042 metaFields[key] = {
34043 label: props.title || key,
34044 value: // When using the entity value, an empty string IS a valid value.
34045 (_entityMetaValues$key = entityMetaValues?.[key]) !== null && _entityMetaValues$key !== void 0 ? _entityMetaValues$key :
34046 // When using the default, an empty string IS NOT a valid value.
34047 props.default || undefined,
34048 type: props.type
34049 };
34050 }
34051 });
34052 if (!Object.keys(metaFields || {}).length) {
34053 return null;
34054 }
34055 return metaFields;
34056 }
34057 /* harmony default export */ const post_meta = ({
34058 name: 'core/post-meta',
34059 getValues({
34060 select,
34061 context,
34062 bindings
34063 }) {
34064 const metaFields = getPostMetaFields(select, context);
34065 const newValues = {};
34066 for (const [attributeName, source] of Object.entries(bindings)) {
34067 var _ref;
34068 // Use the value, the field label, or the field key.
34069 const fieldKey = source.args.key;
34070 const {
34071 value: fieldValue,
34072 label: fieldLabel
34073 } = metaFields?.[fieldKey] || {};
34074 newValues[attributeName] = (_ref = fieldValue !== null && fieldValue !== void 0 ? fieldValue : fieldLabel) !== null && _ref !== void 0 ? _ref : fieldKey;
34075 }
34076 return newValues;
34077 },
34078 setValues({
34079 dispatch,
34080 context,
34081 bindings
34082 }) {
34083 const newMeta = {};
34084 Object.values(bindings).forEach(({
34085 args,
34086 newValue
34087 }) => {
34088 newMeta[args.key] = newValue;
34089 });
34090 dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', context?.postType, context?.postId, {
34091 meta: newMeta
34092 });
34093 },
34094 canUserEditValue({
34095 select,
34096 context,
34097 args
34098 }) {
34099 // Lock editing in query loop.
34100 if (context?.query || context?.queryId) {
34101 return false;
34102 }
34103
34104 // Lock editing when `postType` is not defined.
34105 if (!context?.postType) {
34106 return false;
34107 }
34108 const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
34109 // Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
34110 if (fieldValue === undefined) {
34111 return false;
34112 }
34113 // Check that custom fields metabox is not enabled.
34114 const areCustomFieldsEnabled = select(store_store).getEditorSettings().enableCustomFields;
34115 if (areCustomFieldsEnabled) {
34116 return false;
34117 }
34118
34119 // Check that the user has the capability to edit post meta.
34120 const canUserEdit = select(external_wp_coreData_namespaceObject.store).canUser('update', {
34121 kind: 'postType',
34122 name: context?.postType,
34123 id: context?.postId
34124 });
34125 if (!canUserEdit) {
34126 return false;
34127 }
34128 return true;
34129 },
34130 getFieldsList({
34131 select,
34132 context
34133 }) {
34134 return getPostMetaFields(select, context);
34135 }
34136 });
34137
34138 ;// ./packages/editor/build-module/bindings/api.js
34139 /**
34140 * WordPress dependencies
34141 */
34142
34143
34144 /**
34145 * Internal dependencies
34146 */
34147
34148
34149
34150 /**
34151 * Function to register core block bindings sources provided by the editor.
34152 *
34153 * @example
34154 * ```js
34155 * import { registerCoreBlockBindingsSources } from '@wordpress/editor';
34156 *
34157 * registerCoreBlockBindingsSources();
34158 * ```
34159 */
34160 function registerCoreBlockBindingsSources() {
34161 (0,external_wp_blocks_namespaceObject.registerBlockBindingsSource)(pattern_overrides);
34162 (0,external_wp_blocks_namespaceObject.registerBlockBindingsSource)(post_meta);
34163 }
34164
34165 ;// ./packages/editor/build-module/private-apis.js
34166 /**
34167 * WordPress dependencies
34168 */
34169
34170
34171 /**
34172 * Internal dependencies
34173 */
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191 const {
34192 store: interfaceStore,
34193 ...remainingInterfaceApis
34194 } = build_module_namespaceObject;
34195 const privateApis = {};
34196 lock(privateApis, {
34197 CreateTemplatePartModal: CreateTemplatePartModal,
34198 BackButton: back_button,
34199 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible,
34200 Editor: editor,
34201 EditorContentSlotFill: content_slot_fill,
34202 GlobalStylesProvider: GlobalStylesProvider,
34203 mergeBaseAndUserConfigs: mergeBaseAndUserConfigs,
34204 PluginPostExcerpt: post_excerpt_plugin,
34205 PostCardPanel: PostCardPanel,
34206 PreferencesModal: EditorPreferencesModal,
34207 usePostActions: usePostActions,
34208 usePostFields: post_fields,
34209 ToolsMoreMenuGroup: tools_more_menu_group,
34210 ViewMoreMenuGroup: view_more_menu_group,
34211 ResizableEditor: resizable_editor,
34212 registerCoreBlockBindingsSources: registerCoreBlockBindingsSources,
34213 getTemplateInfo: getTemplateInfo,
34214 // This is a temporary private API while we're updating the site editor to use EditorProvider.
34215 interfaceStore,
34216 ...remainingInterfaceApis
34217 });
34218
34219 ;// ./packages/editor/build-module/dataviews/api.js
34220 /**
34221 * WordPress dependencies
34222 */
34223
34224
34225 /**
34226 * Internal dependencies
34227 */
34228
34229
34230
34231 /**
34232 * @typedef {import('@wordpress/dataviews').Action} Action
34233 * @typedef {import('@wordpress/dataviews').Field} Field
34234 */
34235
34236 /**
34237 * Registers a new DataViews action.
34238 *
34239 * This is an experimental API and is subject to change.
34240 * it's only available in the Gutenberg plugin for now.
34241 *
34242 * @param {string} kind Entity kind.
34243 * @param {string} name Entity name.
34244 * @param {Action} config Action configuration.
34245 */
34246
34247 function api_registerEntityAction(kind, name, config) {
34248 const {
34249 registerEntityAction: _registerEntityAction
34250 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
34251 if (true) {
34252 _registerEntityAction(kind, name, config);
34253 }
34254 }
34255
34256 /**
34257 * Unregisters a DataViews action.
34258 *
34259 * This is an experimental API and is subject to change.
34260 * it's only available in the Gutenberg plugin for now.
34261 *
34262 * @param {string} kind Entity kind.
34263 * @param {string} name Entity name.
34264 * @param {string} actionId Action ID.
34265 */
34266 function api_unregisterEntityAction(kind, name, actionId) {
34267 const {
34268 unregisterEntityAction: _unregisterEntityAction
34269 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
34270 if (true) {
34271 _unregisterEntityAction(kind, name, actionId);
34272 }
34273 }
34274
34275 /**
34276 * Registers a new DataViews field.
34277 *
34278 * This is an experimental API and is subject to change.
34279 * it's only available in the Gutenberg plugin for now.
34280 *
34281 * @param {string} kind Entity kind.
34282 * @param {string} name Entity name.
34283 * @param {Field} config Field configuration.
34284 */
34285 function api_registerEntityField(kind, name, config) {
34286 const {
34287 registerEntityField: _registerEntityField
34288 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
34289 if (true) {
34290 _registerEntityField(kind, name, config);
34291 }
34292 }
34293
34294 /**
34295 * Unregisters a DataViews field.
34296 *
34297 * This is an experimental API and is subject to change.
34298 * it's only available in the Gutenberg plugin for now.
34299 *
34300 * @param {string} kind Entity kind.
34301 * @param {string} name Entity name.
34302 * @param {string} fieldId Field ID.
34303 */
34304 function api_unregisterEntityField(kind, name, fieldId) {
34305 const {
34306 unregisterEntityField: _unregisterEntityField
34307 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
34308 if (true) {
34309 _unregisterEntityField(kind, name, fieldId);
34310 }
34311 }
34312
34313 ;// ./packages/editor/build-module/index.js
34314 /**
34315 * Internal dependencies
34316 */
34317
34318
34319
34320
34321
34322
34323
34324 /*
34325 * Backward compatibility
34326 */
34327
34328
34329 })();
34330
34331 (window.wp = window.wp || {}).editor = __webpack_exports__;
34332 /******/ })()
34333 ;